lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [17/22] lucy-clownfish git commit: Gen arg parsing for Py constructor glue.
Date Tue, 01 Mar 2016 03:03:25 GMT
Gen arg parsing for Py constructor 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/a6068b41
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/a6068b41
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/a6068b41

Branch: refs/heads/master
Commit: a6068b41523b9c216bb63ace4d66f9f5cccf1477
Parents: 5443a74
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Tue Feb 2 18:43:41 2016 -0800
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Wed Feb 24 15:36:07 2016 -0800

----------------------------------------------------------------------
 compiler/src/CFCPyMethod.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6068b41/compiler/src/CFCPyMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPyMethod.c b/compiler/src/CFCPyMethod.c
index c93252e..2f6168a 100644
--- a/compiler/src/CFCPyMethod.c
+++ b/compiler/src/CFCPyMethod.c
@@ -521,19 +521,33 @@ CFCPyMethod_wrapper(CFCMethod *method, CFCClass *invoker) {
 
 char*
 CFCPyMethod_constructor_wrapper(CFCFunction *init_func, CFCClass *invoker) {
+    CFCParamList *param_list  = CFCFunction_get_param_list(init_func);
+    char *decs       = S_gen_decs(param_list, 1);
     const char *struct_sym = CFCClass_full_struct_sym(invoker);
+    char *error = NULL;
+    char *arg_parsing = S_gen_arg_parsing(param_list, 1, &error);
+    if (error) {
+        CFCUtil_die("%s in constructor for %s", error,
+                    CFCClass_get_name(invoker));
+    }
+    if (!arg_parsing) {
+        CFCUtil_die("Unexpected arg parsing error for %s",
+                    CFCClass_get_name(invoker));
+    }
 
     char pattern[] =
         "static PyObject*\n"
         "S_%s_PY_NEW(PyTypeObject *type, PyObject *args, PyObject *kwargs) {\n"
-        "    CFISH_UNUSED_VAR(type);\n"
-        "    CFISH_UNUSED_VAR(args);\n"
-        "    CFISH_UNUSED_VAR(kwargs);\n"
+        "%s" // decs
+        "%s" // arg_parsing
         "    Py_RETURN_NONE;\n"
         "}\n"
         ;
-    char *wrapper = CFCUtil_sprintf(pattern, struct_sym);
+    char *wrapper = CFCUtil_sprintf(pattern, struct_sym, decs,
+                                    arg_parsing);
 
+    FREEMEM(decs);
+    FREEMEM(arg_parsing);
     return wrapper;
 }
 


Mime
View raw message