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/02/25 00:07:35 UTC

[08/20] lucy-clownfish git commit: Add CF pound-includes in autogen Py module file.

Add CF pound-includes in autogen Py module file.


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

Branch: refs/heads/master
Commit: 82d79df8bc4c57ff42922a60436425c078ae6731
Parents: 5d3809b
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Tue Jan 26 17:24:22 2016 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Tue Feb 23 18:22:03 2016 -0800

----------------------------------------------------------------------
 compiler/src/CFCPython.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/82d79df8/compiler/src/CFCPython.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPython.c b/compiler/src/CFCPython.c
index 2c57eb0..3efaa3a 100644
--- a/compiler/src/CFCPython.c
+++ b/compiler/src/CFCPython.c
@@ -125,12 +125,26 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest) {
         helper_mod_name[i] = tolower(helper_mod_name[i]);
     }
 
+    CFCClass  **ordered = CFCHierarchy_ordered_classes(self->hierarchy);
+    CFCParcel **parcels = CFCParcel_all_parcels();
+    char *pound_includes     = CFCUtil_strdup("");
+
+    for (size_t i = 0; ordered[i] != NULL; i++) {
+        CFCClass *klass = ordered[i];
+        if (CFCClass_included(klass)) { continue; }
+
+        const char *include_h  = CFCClass_include_h(klass);
+        pound_includes = CFCUtil_cat(pound_includes, "#include \"",
+                                     include_h, "\"\n", NULL);
+    }
+
     const char pattern[] =
         "%s\n"
         "\n"
         "#include \"Python.h\"\n"
         "#include \"cfish_parcel.h\"\n"
         "#include \"CFBind.h\"\n"
+        "%s\n"
         "\n"
         "static PyModuleDef module_def = {\n"
         "    PyModuleDef_HEAD_INIT,\n"
@@ -150,7 +164,7 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest) {
         "\n";
 
     char *content
-        = CFCUtil_sprintf(pattern, self->header,
+        = CFCUtil_sprintf(pattern, self->header, pound_includes,
                           helper_mod_name, last_component, self->footer);
 
     char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "_%s.c", dest,
@@ -161,6 +175,8 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest) {
     FREEMEM(content);
     FREEMEM(helper_mod_name);
     FREEMEM(pymod_name);
+    FREEMEM(pound_includes);
+    FREEMEM(ordered);
 }
 
 void