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 2016/03/01 04:03:15 UTC
[07/22] lucy-clownfish git commit: Declare C arg vars in Py glue.
Declare C arg vars in Py glue.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/f11b123c
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/f11b123c
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/f11b123c
Branch: refs/heads/master
Commit: f11b123c496486c51d3a402e16636fc6430fe379
Parents: 74878d3
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Mon Feb 22 19:34:59 2016 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Wed Feb 24 15:24:52 2016 -0800
----------------------------------------------------------------------
compiler/src/CFCPyMethod.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/f11b123c/compiler/src/CFCPyMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPyMethod.c b/compiler/src/CFCPyMethod.c
index fcbeee1..dc98fb4 100644
--- a/compiler/src/CFCPyMethod.c
+++ b/compiler/src/CFCPyMethod.c
@@ -67,6 +67,20 @@ S_build_py_args(CFCParamList *param_list) {
return py_args;
}
+static char*
+S_gen_decs(CFCParamList *param_list, int first_tick) {
+ char *decs = CFCUtil_strdup("");
+ int num_vars = CFCParamList_num_vars(param_list);
+ CFCVariable **vars = CFCParamList_get_variables(param_list);
+ for (int i = first_tick; i < num_vars; i++) {
+ CFCType *type = CFCVariable_get_type(vars[i]);
+ const char *name = CFCVariable_get_name(vars[i]);
+ decs = CFCUtil_cat(decs, " ", CFCType_to_c(type), " ", name,
+ "_ARG = 0;\n", NULL);
+ }
+ return decs;
+}
+
/* Generate the code which parses arguments passed from Python and converts
* them to Clownfish-flavored C values.
*/
@@ -286,11 +300,13 @@ S_meth_top(CFCMethod *method) {
if (!arg_parsing) {
return NULL;
}
+ char *decs = S_gen_decs(param_list, 1);
char pattern[] =
"(PyObject *self, PyObject *args, PyObject *kwargs) {\n"
+ "%s" // decs
"%s"
;
- char *result = CFCUtil_sprintf(pattern, arg_parsing);
+ char *result = CFCUtil_sprintf(pattern, decs, arg_parsing);
FREEMEM(arg_parsing);
return result;
}