Repository: lucy-clownfish
Updated Branches:
  refs/heads/overridden_exclusions [created] fc8f8c8ce


Consolidate invalid callback check

Create a callback that throws an error whenever a method can't be bound
including private and excluded methods.


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

Branch: refs/heads/overridden_exclusions
Commit: fc8f8c8cef8472622a005f00bdfddd14447c3e96
Parents: 7ece5f5
Author: Nick Wellnhofer <[email protected]>
Authored: Thu Jul 31 14:15:34 2014 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Mon Aug 11 16:37:07 2014 +0200

----------------------------------------------------------------------
 compiler/src/CFCPerlMethod.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/fc8f8c8c/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index 9b412dc..24ee475 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -444,18 +444,18 @@ S_xsub_def_positional_args(CFCPerlMethod *self) {
 
 char*
 CFCPerlMethod_callback_def(CFCMethod *method) {
+    // Return a callback wrapper that throws an error if there are no
+    // bindings for a method.
+    if (!CFCPerlMethod_can_be_bound(method)) {
+        return S_invalid_callback_def(method);
+    }
+
     CFCType *return_type = CFCMethod_get_return_type(method);
     char *start = S_callback_start(method);
     char *callback_def = NULL;
     char *refcount_mods = S_callback_refcount_mods(method);
 
-    if (!start) {
-        // Can't map vars, because there's at least one type in the argument
-        // list we don't yet support.  Return a callback wrapper that throws
-        // an error error.
-        callback_def = S_invalid_callback_def(method);
-    }
-    else if (CFCType_is_void(return_type)) {
+    if (CFCType_is_void(return_type)) {
         callback_def = S_void_callback_def(method, start, refcount_mods);
     }
     else if (CFCType_is_object(return_type)) {
@@ -573,9 +573,9 @@ S_callback_start(CFCMethod *method) {
                                  name, ");\n", NULL);
         }
         else {
-            // Can't map variable type.  Signal to caller.
-            FREEMEM(params);
-            return NULL;
+            // Can't map variable type.
+            const char *type_str = CFCType_to_c(type);
+            CFCUtil_die("Can't map type '%s' to Perl", type_str);
         }
     }
 

Reply via email to