Map clownfish.Obj to Go `interface{}`.

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

Branch: refs/heads/master
Commit: 8c26a1d851753f2d692fff82ff681d303eacb3c6
Parents: 258e19a
Author: Marvin Humphrey <[email protected]>
Authored: Mon Aug 3 17:19:23 2015 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Mon Aug 3 17:19:23 2015 -0700

----------------------------------------------------------------------
 compiler/src/CFCGoFunc.c    | 13 +++++++++++--
 compiler/src/CFCGoTypeMap.c |  5 ++++-
 2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8c26a1d8/compiler/src/CFCGoFunc.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoFunc.c b/compiler/src/CFCGoFunc.c
index ea6c09e..d8a33c8 100644
--- a/compiler/src/CFCGoFunc.c
+++ b/compiler/src/CFCGoFunc.c
@@ -88,7 +88,10 @@ S_prep_start(CFCParcel *parcel, const char *name, CFCClass 
*invoker,
         // Convert certain types and defer their destruction until after the
         // Clownfish call returns.
         const char *class_var;
-        if (CFCType_cfish_string(type)) {
+        if (CFCType_cfish_obj(type)) {
+            class_var = "CFISH_OBJ";
+        }
+        else if (CFCType_cfish_string(type)) {
             class_var = "CFISH_STRING";
         }
         else if (CFCType_cfish_vector(type)) {
@@ -185,7 +188,8 @@ S_prep_cfargs(CFCParcel *parcel, CFCClass *invoker,
             cfargs = CFCUtil_cat(cfargs, "C.", CFCType_get_specifier(type),
                                  "(", go_name, ")", NULL);
         }
-        else if ((CFCType_cfish_string(type)
+        else if ((CFCType_cfish_obj(type)
+                  || CFCType_cfish_string(type)
                   || CFCType_cfish_blob(type)
                   || CFCType_cfish_vector(type)
                   || CFCType_cfish_hash(type))
@@ -245,6 +249,11 @@ CFCGoFunc_return_statement(CFCParcel *parcel, CFCType 
*return_type,
         if (CFCType_is_primitive(return_type)) {
             statement = CFCUtil_sprintf("\treturn %s(retvalCF)\n", 
ret_type_str);
         }
+        else if (CFCType_cfish_obj(return_type)) {
+            char pattern[] =
+                "%s\treturn %sToGo(unsafe.Pointer(retvalCF))\n";
+            statement = CFCUtil_sprintf(pattern, maybe_decref, clownfish_dot);
+        }
         else if (CFCType_cfish_string(return_type)) {
             char pattern[] =
                 "%s\treturn %sCFStringToGo(unsafe.Pointer(retvalCF))\n";

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8c26a1d8/compiler/src/CFCGoTypeMap.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoTypeMap.c b/compiler/src/CFCGoTypeMap.c
index 703c890..f8757c6 100644
--- a/compiler/src/CFCGoTypeMap.c
+++ b/compiler/src/CFCGoTypeMap.c
@@ -93,7 +93,10 @@ static int num_go_keywords = sizeof(go_keywords) / 
sizeof(go_keywords[0]);
 
 char*
 CFCGoTypeMap_go_type_name(CFCType *type, CFCParcel *current_parcel) {
-    if (CFCType_cfish_string(type)) {
+    if (CFCType_cfish_obj(type)) {
+        return CFCUtil_strdup("interface{}");
+    }
+    else if (CFCType_cfish_string(type)) {
         return CFCUtil_strdup("string");
     }
     else if (CFCType_cfish_blob(type)) {

Reply via email to