lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [3/5] git commit: refs/heads/master - Use "PREFIX" instead of "Prefix" for methods.
Date Fri, 23 Aug 2013 00:01:30 GMT
Use "PREFIX" instead of "Prefix" for methods.

Replace mixed-case Prefix with all-caps PREFIX for method symbols of all
types:

*   method invocations:     PREFIX_Foo_Do_Stuff
*   method typedefs:        PREFIX_Foo_Do_Stuff_t
*   method implementations: PREFIX_Foo_Do_Stuff_IMP
*   method offsets:         PREFIX_Foo_Do_Stuff_OFFSET
*   method overrides:       PREFIX_Foo_Do_Stuff_OVERRIDE

Maintain compat macros temporarily.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/36b503db
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/36b503db
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/36b503db

Branch: refs/heads/master
Commit: 36b503db093956d85595f88b9837ebdfdd781975
Parents: 63a9781
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Wed Aug 21 16:40:48 2013 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Thu Aug 22 16:57:50 2013 -0700

----------------------------------------------------------------------
 clownfish/compiler/src/CFCBindMethod.c | 38 +++++++++++++++++++++++++++--
 clownfish/compiler/src/CFCMethod.c     | 15 ++++++++----
 clownfish/compiler/src/CFCMethod.h     |  3 +++
 3 files changed, 49 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/36b503db/clownfish/compiler/src/CFCBindMethod.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindMethod.c b/clownfish/compiler/src/CFCBindMethod.c
index e6ac41f..605e5cd 100644
--- a/clownfish/compiler/src/CFCBindMethod.c
+++ b/clownfish/compiler/src/CFCBindMethod.c
@@ -26,6 +26,34 @@
 #include "CFCSymbol.h"
 #include "CFCClass.h"
 
+/* Provided temporary compatibility for old-style method names with mixed-case
+ * prefixes.
+ */
+char*
+S_old_method_compat(CFCMethod *method, CFCClass *klass) {
+    char *short_meth_sym = CFCMethod_short_method_sym(method, klass);
+    char *short_typedef  = CFCMethod_short_typedef(method, klass);
+    const char *Prefix = CFCClass_get_Prefix(klass);
+    const char *PREFIX = CFCClass_get_PREFIX(klass);
+    char pattern[]
+        = "#define %s%s %s%s\n"
+          "#define %s%s %s%s\n"
+          "#define %s%s_OFFSET %s%s_OFFSET\n"
+          "#define %s%s_IMP %s%s_IMP\n";
+    char *result = CFCUtil_sprintf(pattern,
+                                   Prefix, short_meth_sym,
+                                   PREFIX, short_meth_sym,
+                                   Prefix, short_typedef,
+                                   PREFIX, short_typedef,
+                                   Prefix, short_meth_sym,
+                                   PREFIX, short_meth_sym,
+                                   Prefix, short_meth_sym,
+                                   PREFIX, short_meth_sym);
+    FREEMEM(short_meth_sym);
+    FREEMEM(short_typedef);
+    return result;
+}
+
 /* Create a macro definition that aliases to a function name directly, since
  * this method may not be overridden. */
 static char*
@@ -69,15 +97,18 @@ S_final_method_def(CFCMethod *method, CFCClass *klass) {
 
     char *full_meth_sym   = CFCMethod_full_method_sym(method, klass);
     char *full_offset_sym = CFCMethod_full_offset_sym(method, klass);
+    char *compat = S_old_method_compat(method, klass);
 
     const char pattern[] =
+        "%s\n"
         "extern size_t %s;\n"
         "#define %s(%s) \\\n"
         "    %s((%s)%s)\n";
     char *method_def
-        = CFCUtil_sprintf(pattern, full_offset_sym, full_meth_sym, arg_names,
+        = CFCUtil_sprintf(pattern, compat, full_offset_sym, full_meth_sym, arg_names,
                           full_func_sym, self_type, arg_names);
 
+    FREEMEM(compat);
     FREEMEM(full_offset_sym);
     FREEMEM(full_meth_sym);
     return method_def;
@@ -114,7 +145,9 @@ S_virtual_method_def(CFCMethod *method, CFCClass *klass) {
     const char *ret_type_str = CFCType_to_c(return_type);
     const char *maybe_return = CFCType_is_void(return_type) ? "" : "return ";
 
+    char *compat = S_old_method_compat(method, klass);
     const char pattern[] =
+        "%s\n"
         "extern %sVISIBLE size_t %s;\n"
         "static CFISH_INLINE %s\n"
         "%s(const %s *self%s) {\n"
@@ -122,12 +155,13 @@ S_virtual_method_def(CFCMethod *method, CFCClass *klass) {
         "    %smethod((%s*)self%s);\n"
         "}\n";
     char *method_def
-        = CFCUtil_sprintf(pattern, PREFIX, full_offset_sym, ret_type_str,
+        = CFCUtil_sprintf(pattern, compat, PREFIX, full_offset_sym, ret_type_str,
                           full_meth_sym, invoker_struct, params_minus_invoker,
                           full_typedef, full_typedef, full_offset_sym,
                           maybe_return, common_struct,
                           arg_names_minus_invoker);
 
+    FREEMEM(compat);
     FREEMEM(full_offset_sym);
     FREEMEM(full_meth_sym);
     FREEMEM(full_typedef);

http://git-wip-us.apache.org/repos/asf/lucy/blob/36b503db/clownfish/compiler/src/CFCMethod.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCMethod.c b/clownfish/compiler/src/CFCMethod.c
index 9bcf8a0..d647ea2 100644
--- a/clownfish/compiler/src/CFCMethod.c
+++ b/clownfish/compiler/src/CFCMethod.c
@@ -138,7 +138,7 @@ CFCMethod_init(CFCMethod *self, CFCParcel *parcel, const char *exposure,
     self->short_imp_func
         = CFCUtil_sprintf("%s_%s_IMP", CFCMethod_get_class_cnick(self),
                           self->macro_sym);
-    self->imp_func = CFCUtil_sprintf("%s%s", CFCMethod_get_Prefix(self),
+    self->imp_func = CFCUtil_sprintf("%s%s", CFCMethod_get_PREFIX(self),
                                      self->short_imp_func);
 
     // Assume that this method is novel until we discover when applying
@@ -295,17 +295,17 @@ S_short_method_sym(CFCMethod *self, CFCClass *invoker, const char *postfix)
{
 
 static char*
 S_full_method_sym(CFCMethod *self, CFCClass *invoker, const char *postfix) {
-    const char *Prefix;
+    const char *PREFIX;
     const char *cnick;
     if (invoker) {
-        Prefix = CFCClass_get_Prefix(invoker);
+        PREFIX = CFCClass_get_PREFIX(invoker);
         cnick  = CFCClass_get_cnick(invoker);
     }
     else {
-        Prefix = CFCMethod_get_Prefix(self);
+        PREFIX = CFCMethod_get_PREFIX(self);
         cnick  = CFCMethod_get_class_cnick(self);
     }
-    return CFCUtil_sprintf("%s%s_%s%s", Prefix, cnick, self->macro_sym,
+    return CFCUtil_sprintf("%s%s_%s%s", PREFIX, cnick, self->macro_sym,
                            postfix);
 }
 
@@ -393,6 +393,11 @@ CFCMethod_get_Prefix(CFCMethod *self) {
 }
 
 const char*
+CFCMethod_get_PREFIX(CFCMethod *self) {
+    return CFCSymbol_get_PREFIX((CFCSymbol*)self);
+}
+
+const char*
 CFCMethod_get_exposure(CFCMethod *self) {
     return CFCSymbol_get_exposure((CFCSymbol*)self);
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/36b503db/clownfish/compiler/src/CFCMethod.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCMethod.h b/clownfish/compiler/src/CFCMethod.h
index 931580c..a6a23cc 100644
--- a/clownfish/compiler/src/CFCMethod.h
+++ b/clownfish/compiler/src/CFCMethod.h
@@ -210,6 +210,9 @@ const char*
 CFCMethod_get_Prefix(CFCMethod *self);
 
 const char*
+CFCMethod_get_PREFIX(CFCMethod *self);
+
+const char*
 CFCMethod_get_exposure(CFCMethod *self);
 
 const char*


Mime
View raw message