lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [3/8] lucy-clownfish git commit: Don't include prereq class headers in XS
Date Sat, 10 Jan 2015 17:31:19 GMT
Don't include prereq class headers in XS

Remove the #include directives for classes from prerequisite parcels from
the generated XS. For this to work, the class singletons must be declared
in the parcel header files.


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

Branch: refs/heads/master
Commit: 9e194259cdaf5ee9e8c2a4d68354f02ea70337b0
Parents: 3a4d248
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sun Nov 30 20:33:45 2014 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun Jan 4 23:59:18 2015 +0100

----------------------------------------------------------------------
 compiler/src/CFCBindClass.c |  9 +--------
 compiler/src/CFCBindCore.c  | 16 ++++++++++++----
 compiler/src/CFCPerl.c      |  1 +
 3 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/9e194259/compiler/src/CFCBindClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindClass.c b/compiler/src/CFCBindClass.c
index cb8a1db..eba1c10 100644
--- a/compiler/src/CFCBindClass.c
+++ b/compiler/src/CFCBindClass.c
@@ -188,8 +188,6 @@ S_ivars_func(CFCBindClass *self) {
 static char*
 S_to_c_header_dynamic(CFCBindClass *self) {
     const char *privacy_symbol  = CFCClass_privacy_symbol(self->client);
-    const char *class_var       = CFCClass_full_class_var(self->client);
-    const char *PREFIX          = CFCClass_get_PREFIX(self->client);
     char *ivars                 = S_ivars_func(self);
     char *struct_def            = S_struct_definition(self);
     char *parent_include        = S_parent_include(self);
@@ -235,11 +233,6 @@ S_to_c_header_dynamic(CFCBindClass *self) {
         "\n"
         "%s\n"
         "\n"
-        "/* Declare the Class singleton for this class.\n"
-        " */\n"
-        "\n"
-        "extern %sVISIBLE cfish_Class *%s;\n"
-        "\n"
         "/* Define \"short names\" for this class's symbols.\n"
         " */\n"
         "\n"
@@ -249,7 +242,7 @@ S_to_c_header_dynamic(CFCBindClass *self) {
         = CFCUtil_sprintf(pattern, parent_include, privacy_symbol, ivars,
                           struct_def, privacy_symbol, inert_var_defs,
                           sub_declarations, method_typedefs, method_defs,
-                          PREFIX, class_var, short_names);
+                          short_names);
 
     FREEMEM(ivars);
     FREEMEM(struct_def);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/9e194259/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index 679da04..391d79c 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -154,8 +154,10 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
     const char   *PREFIX      = CFCParcel_get_PREFIX(parcel);
     const char   *privacy_sym = CFCParcel_get_privacy_sym(parcel);
 
-    // Declare object structs for all instantiable classes.
-    char *typedefs = CFCUtil_strdup("");
+    // Declare object structs and class singletons for all instantiable
+    // classes.
+    char *typedefs    = CFCUtil_strdup("");
+    char *class_decls = CFCUtil_strdup("");
     CFCClass **ordered = CFCHierarchy_ordered_classes(hierarchy);
     for (int i = 0; ordered[i] != NULL; i++) {
         CFCClass *klass = ordered[i];
@@ -166,6 +168,10 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
             const char *full_struct = CFCClass_full_struct_sym(klass);
             typedefs = CFCUtil_cat(typedefs, "typedef struct ", full_struct,
                                    " ", full_struct, ";\n", NULL);
+            const char *class_var = CFCClass_full_class_var(klass);
+            class_decls = CFCUtil_cat(class_decls, "extern ", PREFIX,
+                                      "VISIBLE cfish_Class *", class_var,
+                                      ";\n", NULL);
         }
     }
     FREEMEM(ordered);
@@ -311,6 +317,8 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
         "\n"
         "%s" // Typedefs.
         "\n"
+        "%s" // Class singletons.
+        "\n"
         "%s" // Extra definitions.
         "%sVISIBLE void\n"
         "%sbootstrap_inheritance();\n"
@@ -332,8 +340,8 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
     char *file_content
         = CFCUtil_sprintf(pattern, self->c_header, PREFIX, PREFIX,
                           extra_includes, privacy_sym, PREFIX, PREFIX,
-                          typedefs, extra_defs, PREFIX, prefix, PREFIX, prefix,
-                          prefix, PREFIX, self->c_footer);
+                          typedefs, class_decls, extra_defs, PREFIX, prefix,
+                          PREFIX, prefix, prefix, PREFIX, self->c_footer);
 
     // Unlink then write file.
     const char *inc_dest = CFCHierarchy_get_include_dest(hierarchy);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/9e194259/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerl.c b/compiler/src/CFCPerl.c
index 6637dee..7103eac 100644
--- a/compiler/src/CFCPerl.c
+++ b/compiler/src/CFCPerl.c
@@ -440,6 +440,7 @@ CFCPerl_write_bindings(CFCPerl *self) {
     // Pound-includes for generated headers.
     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);
         generated_xs = CFCUtil_cat(generated_xs, "#include \"", include_h,
                                    "\"\n", NULL);


Mime
View raw message