lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [2/4] lucy-clownfish git commit: Don't export private methods via Go.
Date Sat, 07 Nov 2015 03:45:36 GMT
Don't export private methods via Go.

Downcase the first letter of the Go method name for methods not marked
as `public`, so that they are not exported by the Go package.


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

Branch: refs/heads/master
Commit: d442877690b4eaa03e6f2b2185e3b5fd2849c8bb
Parents: a0a3c6d
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Tue Nov 3 18:47:49 2015 -0800
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Fri Nov 6 19:03:00 2015 -0800

----------------------------------------------------------------------
 compiler/src/CFCGoFunc.c   | 9 +++++++--
 compiler/src/CFCGoFunc.h   | 2 +-
 compiler/src/CFCGoMethod.c | 6 ++++--
 3 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/d4428776/compiler/src/CFCGoFunc.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoFunc.c b/compiler/src/CFCGoFunc.c
index 83b6775..6226b06 100644
--- a/compiler/src/CFCGoFunc.c
+++ b/compiler/src/CFCGoFunc.c
@@ -17,6 +17,8 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <ctype.h>
+
 #include "CFCGoFunc.h"
 #include "CFCGoTypeMap.h"
 #include "CFCBase.h"
@@ -42,9 +44,12 @@ enum {
 };
 
 char*
-CFCGoFunc_go_meth_name(const char *orig) {
+CFCGoFunc_go_meth_name(const char *orig, int is_public) {
     char *go_name = CFCUtil_strdup(orig);
-    for (int i = 0, j = 0, max = strlen(go_name) + 1; i < max; i++) {
+    if (!is_public) {
+        go_name[0] = tolower(go_name[0]);
+    }
+    for (int i = 1, j = 1, max = strlen(go_name) + 1; i < max; i++) {
         if (go_name[i] != '_') {
             go_name[j++] = go_name[i];
         }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/d4428776/compiler/src/CFCGoFunc.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoFunc.h b/compiler/src/CFCGoFunc.h
index b22276a..9d1b13a 100644
--- a/compiler/src/CFCGoFunc.h
+++ b/compiler/src/CFCGoFunc.h
@@ -29,7 +29,7 @@ struct CFCClass;
 struct CFCParamList;
 
 char*
-CFCGoFunc_go_meth_name(const char *orig);
+CFCGoFunc_go_meth_name(const char *orig, int is_public);
 
 char*
 CFCGoFunc_meth_start(struct CFCParcel *parcel, const char *name,

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/d4428776/compiler/src/CFCGoMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoMethod.c b/compiler/src/CFCGoMethod.c
index 5e52d94..7de4f09 100644
--- a/compiler/src/CFCGoMethod.c
+++ b/compiler/src/CFCGoMethod.c
@@ -93,7 +93,8 @@ S_lazy_init_sig(CFCGoMethod *self, CFCClass *invoker) {
     CFCMethod *method = self->method;
     CFCParcel *parcel = CFCClass_get_parcel(invoker);
     CFCType *return_type = CFCMethod_get_return_type(method);
-    char *name = CFCGoFunc_go_meth_name(CFCMethod_get_name(method));
+    char *name = CFCGoFunc_go_meth_name(CFCMethod_get_name(method),
+                                        CFCMethod_public(method));
     char *go_ret_type = CFCType_is_void(return_type)
                         ? CFCUtil_strdup("")
                         : CFCGoTypeMap_go_type_name(return_type, parcel);
@@ -143,7 +144,8 @@ CFCGoMethod_func_def(CFCGoMethod *self, CFCClass *invoker) {
     CFCParcel    *parcel     = CFCClass_get_parcel(invoker);
     CFCParamList *param_list = CFCMethod_get_param_list(novel_method);
     CFCType      *ret_type   = CFCMethod_get_return_type(novel_method);
-    char *name = CFCGoFunc_go_meth_name(CFCMethod_get_name(novel_method));
+    char *name = CFCGoFunc_go_meth_name(CFCMethod_get_name(novel_method),
+                                        CFCMethod_public(novel_method));
     char *first_line = CFCGoFunc_meth_start(parcel, name, invoker,
                                             param_list, ret_type);
     char *cfunc;


Mime
View raw message