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/07/20 23:29:21 UTC
[4/7] lucy-clownfish git commit: Generalize Go func first line
conversion.
Generalize Go func first line conversion.
Prepare to make the conversion function which generates the first part
of a Go method binding work with constructors and inert functions in
addition to 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/611b0d44
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/611b0d44
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/611b0d44
Branch: refs/heads/master
Commit: 611b0d441cfd8375964ed779ebed137c3b1529d4
Parents: d09f15a
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Mon Jul 13 17:57:29 2015 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Mon Jul 20 13:40:36 2015 -0700
----------------------------------------------------------------------
compiler/src/CFCGoFunc.c | 18 ++++++++++++------
compiler/src/CFCGoFunc.h | 4 ++--
compiler/src/CFCGoMethod.c | 4 ++--
3 files changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/611b0d44/compiler/src/CFCGoFunc.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoFunc.c b/compiler/src/CFCGoFunc.c
index ad74bde..3bde6b1 100644
--- a/compiler/src/CFCGoFunc.c
+++ b/compiler/src/CFCGoFunc.c
@@ -52,15 +52,14 @@ CFCGoFunc_go_meth_name(const char *orig) {
return go_name;
}
-char*
-CFCGoFunc_func_start(CFCParcel *parcel, const char *name, CFCClass *invoker,
- CFCParamList *param_list, CFCType *return_type,
- int is_method) {
+static char*
+S_prep_start(CFCParcel *parcel, const char *name, CFCClass *invoker,
+ CFCParamList *param_list, CFCType *return_type, int targ) {
CFCVariable **param_vars = CFCParamList_get_variables(param_list);
char *invocant;
char go_name[GO_NAME_BUF_SIZE];
- if (is_method) {
+ if (targ == IS_METHOD) {
const char *struct_sym = CFCClass_get_struct_sym(invoker);
CFCGoTypeMap_go_meth_receiever(struct_sym, param_list, go_name,
GO_NAME_BUF_SIZE);
@@ -71,7 +70,7 @@ CFCGoFunc_func_start(CFCParcel *parcel, const char *name, CFCClass *invoker,
}
char *params = CFCUtil_strdup("");
- int start = is_method ? 1 : 0;
+ int start = targ == IS_METHOD ? 1 : 0;
for (int i = start; param_vars[i] != NULL; i++) {
CFCVariable *var = param_vars[i];
CFCType *type = CFCVariable_get_type(var);
@@ -107,6 +106,13 @@ CFCGoFunc_func_start(CFCParcel *parcel, const char *name, CFCClass *invoker,
return content;
}
+char*
+CFCGoFunc_meth_start(CFCParcel *parcel, const char *name, CFCClass *invoker,
+ CFCParamList *param_list, CFCType *return_type) {
+ return S_prep_start(parcel, name, invoker, param_list, return_type,
+ IS_METHOD);
+}
+
static char*
S_prep_cfargs(CFCParcel *parcel, CFCClass *invoker,
CFCParamList *param_list, int targ) {
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/611b0d44/compiler/src/CFCGoFunc.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoFunc.h b/compiler/src/CFCGoFunc.h
index e11fa0d..a2b71ee 100644
--- a/compiler/src/CFCGoFunc.h
+++ b/compiler/src/CFCGoFunc.h
@@ -32,10 +32,10 @@ char*
CFCGoFunc_go_meth_name(const char *orig);
char*
-CFCGoFunc_func_start(struct CFCParcel *parcel, const char *name,
+CFCGoFunc_meth_start(struct CFCParcel *parcel, const char *name,
struct CFCClass *invoker,
struct CFCParamList *param_list,
- struct CFCType *return_type, int is_method);
+ struct CFCType *return_type);
/** Convert Go method arguments to comma-separated Clownfish-flavored C
* arguments, to be passed to a Clownfish method.
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/611b0d44/compiler/src/CFCGoMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoMethod.c b/compiler/src/CFCGoMethod.c
index f5b7cb4..5e52d94 100644
--- a/compiler/src/CFCGoMethod.c
+++ b/compiler/src/CFCGoMethod.c
@@ -144,8 +144,8 @@ CFCGoMethod_func_def(CFCGoMethod *self, CFCClass *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 *first_line = CFCGoFunc_func_start(parcel, name, invoker,
- param_list, ret_type, true);
+ char *first_line = CFCGoFunc_meth_start(parcel, name, invoker,
+ param_list, ret_type);
char *cfunc;
if (CFCMethod_novel(self->method) && CFCMethod_final(self->method)) {
cfunc = CFCUtil_strdup(CFCMethod_imp_func(self->method, invoker));