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:56:11 UTC

[10/36] lucy-clownfish git commit: Bootstrap Clownfish parcels in Python build.

Bootstrap Clownfish parcels in Python build.

Finally, the Python implementation is complete enough that we can run
the bootstrapping for the Clownfish parcel.


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

Branch: refs/heads/py_exp13
Commit: 67b76306dd136fe88a392d4d489bfd26f0f2f750
Parents: c9cbb2d
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Mon Feb 1 17:08:27 2016 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Wed Feb 24 15:20:38 2016 -0800

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


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/67b76306/compiler/src/CFCPython.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPython.c b/compiler/src/CFCPython.c
index a2d28df..068c9c4 100644
--- a/compiler/src/CFCPython.c
+++ b/compiler/src/CFCPython.c
@@ -457,8 +457,18 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest) {
     char *type_linkups       = S_gen_type_linkups(self, parcel, ordered);
     char *pound_includes     = CFCUtil_strdup("");
     char *class_bindings     = S_gen_class_bindings(self, parcel, pymod_name, ordered);
+    char *parcel_boots       = CFCUtil_strdup("");
     char *pytype_ready_calls = CFCUtil_strdup("");
 
+    // Add parcel bootstrapping calls.
+    for (size_t i = 0; parcels[i]; ++i) {
+        if (!CFCParcel_included(parcels[i])) {
+            const char *prefix = CFCParcel_get_prefix(parcels[i]);
+            parcel_boots = CFCUtil_cat(parcel_boots, "    ", prefix,
+                                       "bootstrap_parcel();\n", NULL);
+        }
+    }
+
     for (size_t i = 0; ordered[i] != NULL; i++) {
         CFCClass *klass = ordered[i];
         if (CFCClass_included(klass)) { continue; }
@@ -508,6 +518,9 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest) {
         "%s\n" // PyType_Ready calls
         "\n"
         "    S_link_py_types();\n"
+        "\n"
+        "%s\n" // parcel boots
+        "\n"
         "    PyObject *module = PyModule_Create(&module_def);\n"
         "    return module;\n"
         "}\n"
@@ -518,7 +531,8 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest) {
     char *content
         = CFCUtil_sprintf(pattern, self->header, pound_includes, callbacks,
                           helper_mod_name, class_bindings, type_linkups,
-                          last_component, pytype_ready_calls, self->footer);
+                          last_component, pytype_ready_calls, parcel_boots,
+                          self->footer);
 
     char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "_%s.c", dest,
                                      last_component);
@@ -527,6 +541,7 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest) {
 
     FREEMEM(content);
     FREEMEM(pytype_ready_calls);
+    FREEMEM(parcel_boots);
     FREEMEM(class_bindings);
     FREEMEM(helper_mod_name);
     FREEMEM(pymod_name);