You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2015/04/07 02:31:21 UTC

[1/3] lucy-clownfish git commit: Generalize test for whether func can be bound.

Repository: lucy-clownfish
Updated Branches:
  refs/heads/master d8ecb8d38 -> 4adae97b2


Generalize test for whether func can be bound.

The algorithm for determining whether bindings can be generated
automatically for a Clownfish function will likely the same across all
all hosts.


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

Branch: refs/heads/master
Commit: 1892f4fbb62c4f785c27c99fa043f8748cca26de
Parents: d8ecb8d
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Mon Apr 6 16:22:42 2015 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Mon Apr 6 17:19:36 2015 -0700

----------------------------------------------------------------------
 compiler/src/CFCFunction.c   | 23 +++++++++++++++++++++++
 compiler/src/CFCFunction.h   |  5 +++++
 compiler/src/CFCPerlClass.c  |  7 ++++---
 compiler/src/CFCPerlMethod.c |  2 +-
 compiler/src/CFCPerlSub.c    | 24 ------------------------
 compiler/src/CFCPerlSub.h    |  5 -----
 6 files changed, 33 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/1892f4fb/compiler/src/CFCFunction.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCFunction.c b/compiler/src/CFCFunction.c
index f0ee468..c875507 100644
--- a/compiler/src/CFCFunction.c
+++ b/compiler/src/CFCFunction.c
@@ -27,6 +27,7 @@
 #include "CFCParcel.h"
 #include "CFCType.h"
 #include "CFCParamList.h"
+#include "CFCVariable.h"
 #include "CFCDocuComment.h"
 #include "CFCUtil.h"
 
@@ -97,6 +98,28 @@ CFCFunction_destroy(CFCFunction *self) {
     CFCSymbol_destroy((CFCSymbol*)self);
 }
 
+int
+CFCFunction_can_be_bound(CFCFunction *self) {
+    // Test whether parameters can be mapped automatically.
+    CFCVariable **arg_vars = CFCParamList_get_variables(self->param_list);
+    for (size_t i = 0; arg_vars[i] != NULL; i++) {
+        CFCType *type = CFCVariable_get_type(arg_vars[i]);
+        if (!CFCType_is_object(type) && !CFCType_is_primitive(type)) {
+            return false;
+        }
+    }
+
+    // Test whether return type can be mapped automatically.
+    if (!CFCType_is_void(self->return_type)
+        && !CFCType_is_object(self->return_type)
+        && !CFCType_is_primitive(self->return_type)
+    ) {
+        return false;
+    }
+
+    return true;
+}
+
 CFCType*
 CFCFunction_get_return_type(CFCFunction *self) {
     return self->return_type;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/1892f4fb/compiler/src/CFCFunction.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCFunction.h b/compiler/src/CFCFunction.h
index 752d2da..f2b6794 100644
--- a/compiler/src/CFCFunction.h
+++ b/compiler/src/CFCFunction.h
@@ -78,6 +78,11 @@ CFCFunction_init(CFCFunction *self, struct CFCParcel *parcel,
 void
 CFCFunction_destroy(CFCFunction *self);
 
+/** Test whether bindings can be generated for a function.
+  */
+int
+CFCFunction_can_be_bound(CFCFunction *function);
+
 struct CFCType*
 CFCFunction_get_return_type(CFCFunction *self);
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/1892f4fb/compiler/src/CFCPerlClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlClass.c b/compiler/src/CFCPerlClass.c
index 782f719..e7263c4 100644
--- a/compiler/src/CFCPerlClass.c
+++ b/compiler/src/CFCPerlClass.c
@@ -23,6 +23,7 @@
 #include "CFCPerlClass.h"
 #include "CFCUtil.h"
 #include "CFCClass.h"
+#include "CFCFunction.h"
 #include "CFCMethod.h"
 #include "CFCParcel.h"
 #include "CFCParamList.h"
@@ -288,7 +289,7 @@ CFCPerlClass_constructor_bindings(CFCClass *klass) {
         if (perl_class == NULL) {
             // Bind init() to new() when possible.
             if (strcmp(micro_sym, "init") == 0
-                && CFCPerlSub_can_be_bound(function)
+                && CFCFunction_can_be_bound(function)
                ) {
                 alias = NEW;
             }
@@ -297,7 +298,7 @@ CFCPerlClass_constructor_bindings(CFCClass *klass) {
             for (size_t j = 0; j < perl_class->num_cons; j++) {
                 if (strcmp(micro_sym, perl_class->cons_inits[j]) == 0) {
                     alias = perl_class->cons_aliases[j];
-                    if (!CFCPerlSub_can_be_bound(function)) {
+                    if (!CFCFunction_can_be_bound(function)) {
                         CFCUtil_die("Can't bind %s as %s"
                                     " -- types can't be mapped",
                                     micro_sym, alias);
@@ -310,7 +311,7 @@ CFCPerlClass_constructor_bindings(CFCClass *klass) {
             if (!alias
                 && !perl_class->exclude_cons
                 && strcmp(micro_sym, "init") == 0
-                && CFCPerlSub_can_be_bound(function)
+                && CFCFunction_can_be_bound(function)
                ) {
                 int saw_new = 0;
                 for (size_t j = 0; j < perl_class->num_cons; j++) {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/1892f4fb/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index 2a2aa5f..7d0a7fa 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -129,7 +129,7 @@ CFCPerlMethod_can_be_bound(CFCMethod *method) {
      * - methods with types which cannot be mapped automatically
      */
     return !CFCSymbol_private((CFCSymbol*)method)
-           && CFCPerlSub_can_be_bound((CFCFunction*)method);
+           && CFCFunction_can_be_bound((CFCFunction*)method);
 }
 
 char*

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/1892f4fb/compiler/src/CFCPerlSub.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlSub.c b/compiler/src/CFCPerlSub.c
index d114521..0051258 100644
--- a/compiler/src/CFCPerlSub.c
+++ b/compiler/src/CFCPerlSub.c
@@ -73,30 +73,6 @@ CFCPerlSub_destroy(CFCPerlSub *self) {
     CFCBase_destroy((CFCBase*)self);
 }
 
-int
-CFCPerlSub_can_be_bound(CFCFunction *function) {
-    // Test whether parameters can be mapped automatically.
-    CFCParamList  *param_list = CFCFunction_get_param_list(function);
-    CFCVariable  **arg_vars   = CFCParamList_get_variables(param_list);
-    for (size_t i = 0; arg_vars[i] != NULL; i++) {
-        CFCType *type = CFCVariable_get_type(arg_vars[i]);
-        if (!CFCType_is_object(type) && !CFCType_is_primitive(type)) {
-            return false;
-        }
-    }
-
-    // Test whether return type can be mapped automatically.
-    CFCType *return_type = CFCFunction_get_return_type(function);
-    if (!CFCType_is_void(return_type)
-        && !CFCType_is_object(return_type)
-        && !CFCType_is_primitive(return_type)
-    ) {
-        return false;
-    }
-
-    return true;
-}
-
 char*
 CFCPerlSub_params_hash_def(CFCPerlSub *self) {
     if (!self->use_labeled_params) {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/1892f4fb/compiler/src/CFCPerlSub.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlSub.h b/compiler/src/CFCPerlSub.h
index 8582818..945ad6d 100644
--- a/compiler/src/CFCPerlSub.h
+++ b/compiler/src/CFCPerlSub.h
@@ -65,11 +65,6 @@ CFCPerlSub_init(CFCPerlSub *self, struct CFCParamList *param_list,
 void
 CFCPerlSub_destroy(CFCPerlSub *self);
 
-/** Test whether bindings can be generated for a function.
-  */
-int
-CFCPerlSub_can_be_bound(struct CFCFunction *function);
-
 /** Return Perl code initializing a package-global hash where all the keys are
  * the names of labeled params.  The hash's name consists of the the binding's
  * perl_name() plus "_PARAMS".


[3/3] lucy-clownfish git commit: Merge branch 'CLOWNFISH-32-can_be_bound'

Posted by ma...@apache.org.
Merge branch 'CLOWNFISH-32-can_be_bound'

Consolidate tests for whether Clownfish functions and methods can be
bound to a host.

This closes #8.


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

Branch: refs/heads/master
Commit: 4adae97b24b2b0e46f6a541ca5129b02e3dc69d3
Parents: d8ecb8d bba99f7
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Mon Apr 6 17:20:53 2015 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Mon Apr 6 17:30:19 2015 -0700

----------------------------------------------------------------------
 compiler/src/CFCFunction.c   | 23 +++++++++++++++++++++++
 compiler/src/CFCFunction.h   |  5 +++++
 compiler/src/CFCMethod.c     | 11 +++++++++++
 compiler/src/CFCMethod.h     |  5 +++++
 compiler/src/CFCPerlClass.c  |  9 +++++----
 compiler/src/CFCPerlMethod.c | 13 +------------
 compiler/src/CFCPerlMethod.h |  5 -----
 compiler/src/CFCPerlSub.c    | 24 ------------------------
 compiler/src/CFCPerlSub.h    |  5 -----
 9 files changed, 50 insertions(+), 50 deletions(-)
----------------------------------------------------------------------



[2/3] lucy-clownfish git commit: Generalize test for whether method can be bound.

Posted by ma...@apache.org.
Generalize test for whether method can be bound.

As with Clownfish functions, the algorithm for determining whether
bindings can be generated automatically for a Clownfish method will
likely the same across all all hosts.


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

Branch: refs/heads/master
Commit: bba99f79024330fb38e9db7f40bf83af6cc75126
Parents: 1892f4f
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Mon Apr 6 16:48:04 2015 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Mon Apr 6 17:19:44 2015 -0700

----------------------------------------------------------------------
 compiler/src/CFCMethod.c     | 11 +++++++++++
 compiler/src/CFCMethod.h     |  5 +++++
 compiler/src/CFCPerlClass.c  |  2 +-
 compiler/src/CFCPerlMethod.c | 13 +------------
 compiler/src/CFCPerlMethod.h |  5 -----
 5 files changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/bba99f79/compiler/src/CFCMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCMethod.c b/compiler/src/CFCMethod.c
index 3173681..5f8c951 100644
--- a/compiler/src/CFCMethod.c
+++ b/compiler/src/CFCMethod.c
@@ -261,6 +261,17 @@ CFCMethod_finalize(CFCMethod *self) {
     return finalized;
 }
 
+int
+CFCMethod_can_be_bound(CFCMethod *method) {
+    /*
+     * Check for
+     * - private methods
+     * - methods with types which cannot be mapped automatically
+     */
+    return !CFCSymbol_private((CFCSymbol*)method)
+           && CFCFunction_can_be_bound((CFCFunction*)method);
+}
+
 void
 CFCMethod_set_host_alias(CFCMethod *self, const char *alias) {
     if (!alias || !alias[0]) {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/bba99f79/compiler/src/CFCMethod.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCMethod.h b/compiler/src/CFCMethod.h
index 9baea2b..deff2a3 100644
--- a/compiler/src/CFCMethod.h
+++ b/compiler/src/CFCMethod.h
@@ -107,6 +107,11 @@ CFCMethod_override(CFCMethod *self, CFCMethod *orig);
 CFCMethod*
 CFCMethod_finalize(CFCMethod *self);
 
+/** Test whether bindings should be generated for a method.
+  */
+int
+CFCMethod_can_be_bound(CFCMethod *method);
+
 /**
  * Find the first declaration of the method in the class hierarchy.
  */

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/bba99f79/compiler/src/CFCPerlClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlClass.c b/compiler/src/CFCPerlClass.c
index e7263c4..7ff21dc 100644
--- a/compiler/src/CFCPerlClass.c
+++ b/compiler/src/CFCPerlClass.c
@@ -245,7 +245,7 @@ CFCPerlClass_method_bindings(CFCClass *klass) {
         }
 
         // Skip methods that shouldn't be bound.
-        if (!CFCPerlMethod_can_be_bound(method)) {
+        if (!CFCMethod_can_be_bound(method)) {
             continue;
         }
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/bba99f79/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index 7d0a7fa..0f6f5ec 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -121,17 +121,6 @@ CFCPerlMethod_destroy(CFCPerlMethod *self) {
     CFCPerlSub_destroy((CFCPerlSub*)self);
 }
 
-int
-CFCPerlMethod_can_be_bound(CFCMethod *method) {
-    /*
-     * Check for
-     * - private methods
-     * - methods with types which cannot be mapped automatically
-     */
-    return !CFCSymbol_private((CFCSymbol*)method)
-           && CFCFunction_can_be_bound((CFCFunction*)method);
-}
-
 char*
 CFCPerlMethod_perl_name(CFCMethod *method) {
     // See if the user wants the method to have a specific alias.
@@ -445,7 +434,7 @@ 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)) {
+    if (!CFCMethod_can_be_bound(method)) {
         return S_invalid_callback_def(method);
     }
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/bba99f79/compiler/src/CFCPerlMethod.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.h b/compiler/src/CFCPerlMethod.h
index a0fbd83..cf5bc5e 100644
--- a/compiler/src/CFCPerlMethod.h
+++ b/compiler/src/CFCPerlMethod.h
@@ -46,11 +46,6 @@ CFCPerlMethod_init(CFCPerlMethod *self, struct CFCMethod *method);
 void
 CFCPerlMethod_destroy(CFCPerlMethod *self);
 
-/** Test whether bindings should be generated for a method.
-  */
-int
-CFCPerlMethod_can_be_bound(struct CFCMethod *method);
-
 /**
  * Create the Perl name of the method.
  */