lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [3/6] git commit: refs/heads/cfish-string-prep1 - Fix the invocant type on method typedefs.
Date Mon, 30 Sep 2013 21:15:36 GMT
Fix the invocant type on method typedefs.

Method typedefs, like method invocation inline functions, are defined
for each class in the inheritance chain.  Prior to this fix, the "self"
type in the typedef was the type of the last concrete implementor
rather than the type of the invocant.


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

Branch: refs/heads/cfish-string-prep1
Commit: 08974ea7a3410a070070fade5450f459c9eccf7c
Parents: f7b728a
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Mon Sep 30 11:52:32 2013 -0700
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Mon Sep 30 23:13:31 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCBindMethod.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/08974ea7/clownfish/compiler/src/CFCBindMethod.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindMethod.c b/clownfish/compiler/src/CFCBindMethod.c
index c60cc98..0a2f7c9 100644
--- a/clownfish/compiler/src/CFCBindMethod.c
+++ b/clownfish/compiler/src/CFCBindMethod.c
@@ -88,8 +88,6 @@ S_virtual_method_def(CFCMethod *method, CFCClass *klass) {
     CFCParamList *param_list = CFCMethod_get_param_list(method);
     const char *PREFIX         = CFCClass_get_PREFIX(klass);
     const char *invoker_struct = CFCClass_full_struct_sym(klass);
-    const char *common_struct 
-        = CFCType_get_specifier(CFCMethod_self_type(method));
 
     char *full_meth_sym   = CFCMethod_full_method_sym(method, klass);
     char *full_offset_sym = CFCMethod_full_offset_sym(method, klass);
@@ -125,7 +123,7 @@ S_virtual_method_def(CFCMethod *method, CFCClass *klass) {
         = CFCUtil_sprintf(pattern, 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,
+                          maybe_return, invoker_struct,
                           arg_names_minus_invoker);
 
     FREEMEM(full_offset_sym);
@@ -136,11 +134,17 @@ S_virtual_method_def(CFCMethod *method, CFCClass *klass) {
 
 char*
 CFCBindMeth_typedef_dec(struct CFCMethod *method, CFCClass *klass) {
-    const char *params = CFCParamList_to_c(CFCMethod_get_param_list(method));
+    const char *params_minus_invoker
+        = CFCParamList_to_c(CFCMethod_get_param_list(method));
+    while (*params_minus_invoker && *params_minus_invoker != ',') {
+        params_minus_invoker++;
+    }
+    const char *self_struct = CFCClass_full_struct_sym(klass);
     const char *ret_type = CFCType_to_c(CFCMethod_get_return_type(method));
     char *full_typedef = CFCMethod_full_typedef(method, klass);
-    char *buf = CFCUtil_sprintf("typedef %s\n(*%s)(%s);\n", ret_type,
-                                full_typedef, params);
+    char *buf = CFCUtil_sprintf("typedef %s\n(*%s)(%s *self%s);\n", ret_type,
+                                full_typedef, self_struct,
+                                params_minus_invoker);
     FREEMEM(full_typedef);
     return buf;
 }


Mime
View raw message