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 2013/04/16 02:46:59 UTC

[lucy-commits] [2/2] git commit: refs/heads/cfish-extends-host-obj - Prepend host-dependent members onto Obj.

Prepend host-dependent members onto Obj.

Prepend a a host-dependent macro, `CFISH_OBJ_HEAD`, onto object struct
definitions.  For now the macro is a dummy for all hosts.


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

Branch: refs/heads/cfish-extends-host-obj
Commit: 39a9fc99976d9d8cc88bc2662a4a5fc624563aa9
Parents: c22898f
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Wed Apr 10 18:50:33 2013 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Mon Apr 15 17:36:04 2013 -0700

----------------------------------------------------------------------
 clownfish/compiler/c/cfc.c                         |    1 +
 clownfish/compiler/perl/lib/Clownfish/CFC.xs       |    6 +++
 .../compiler/perl/lib/Clownfish/CFC/Perl/Build.pm  |    1 +
 clownfish/compiler/ruby/ext/Clownfish/CFC.c        |   12 +++++++
 clownfish/compiler/src/CFCBindClass.c              |    2 +-
 clownfish/compiler/src/CFCBindCore.c               |    1 +
 clownfish/compiler/src/CFCC.c                      |   26 +++++++++++++++
 clownfish/compiler/src/CFCC.h                      |    5 +++
 clownfish/compiler/src/CFCPerl.c                   |   26 +++++++++++++++
 clownfish/compiler/src/CFCPerl.h                   |    5 +++
 clownfish/compiler/src/CFCRuby.c                   |   26 +++++++++++++++
 clownfish/compiler/src/CFCRuby.h                   |    4 ++
 clownfish/runtime/ruby/Rakefile                    |    1 +
 13 files changed, 115 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/c/cfc.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/c/cfc.c b/clownfish/compiler/c/cfc.c
index 70bb820..9185e33 100644
--- a/clownfish/compiler/c/cfc.c
+++ b/clownfish/compiler/c/cfc.c
@@ -188,6 +188,7 @@ main(int argc, char **argv) {
 
     c_binding = CFCC_new(hierarchy, header, footer);
     CFCC_write_callbacks(c_binding);
+    CFCC_write_hostdefs(c_binding);
     CFCC_write_man_pages(c_binding);
 
     CFCBase_decref((CFCBase*)c_binding);

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC.xs b/clownfish/compiler/perl/lib/Clownfish/CFC.xs
index dbcc709..347ccca 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC.xs
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC.xs
@@ -1911,6 +1911,12 @@ PPCODE:
     CFCPerl_write_boot(self);
 
 void
+write_hostdefs(self)
+    CFCPerl *self;
+PPCODE:
+    CFCPerl_write_hostdefs(self);
+
+void
 write_bindings(self)
     CFCPerl *self;
 PPCODE:

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
index 19ada50..b816f1c 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
@@ -323,6 +323,7 @@ sub ACTION_clownfish {
         $self->add_to_cleanup($xs_filepath);
         $perl_binding->write_callbacks;
         $perl_binding->write_boot;
+        $perl_binding->write_hostdefs;
         $perl_binding->write_bindings;
         $self->_write_pod($perl_binding);
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/ruby/ext/Clownfish/CFC.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/ruby/ext/Clownfish/CFC.c b/clownfish/compiler/ruby/ext/Clownfish/CFC.c
index 0619ce4..4910ebf 100644
--- a/clownfish/compiler/ruby/ext/Clownfish/CFC.c
+++ b/clownfish/compiler/ruby/ext/Clownfish/CFC.c
@@ -109,6 +109,16 @@ S_CFC_Binding_Ruby_Write_Boot(VALUE self_rb) {
     return Qnil;
 }
 
+static VALUE
+S_CFC_Binding_Ruby_Write_Hostdefs(VALUE self_rb) {
+
+    CFCRuby *self;
+    Data_Get_Struct(self_rb, CFCRuby, self);
+    CFCRuby_write_hostdefs(self);
+
+    return Qnil;
+}
+
 static void
 S_init_Binding_Ruby(void) {
     cBindRuby = rb_define_class_under(mBinding, "Ruby", rb_cObject);
@@ -116,6 +126,8 @@ S_init_Binding_Ruby(void) {
     rb_define_method(cBindRuby, "initialize", S_CFC_Binding_Ruby_Init, 1);
     rb_define_method(cBindRuby, "write_boot",
                      S_CFC_Binding_Ruby_Write_Boot, 0);
+    rb_define_method(cBindRuby, "write_hostdefs",
+                     S_CFC_Binding_Ruby_Write_Hostdefs, 0);
 }
 
 static VALUE

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/src/CFCBindClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindClass.c b/clownfish/compiler/src/CFCBindClass.c
index aa9783c..21a6daf 100644
--- a/clownfish/compiler/src/CFCBindClass.c
+++ b/clownfish/compiler/src/CFCBindClass.c
@@ -344,7 +344,7 @@ S_struct_definition(CFCBindClass *self) {
         strcat(member_decs, member_dec);
     }
 
-    char pattern[] = "struct %s {%s\n};\n";
+    char pattern[] = "struct %s {\n    CFISH_OBJ_HEAD%s\n};\n";
     char *struct_def = CFCUtil_sprintf(pattern, struct_sym, member_decs);
 
     FREEMEM(member_decs);

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index a48db49..5cd6414 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -158,6 +158,7 @@ S_write_parcel_h(CFCBindCore *self) {
         "\n"
         "#include <stddef.h>\n"
         "#include \"charmony.h\"\n"
+        "#include \"hostdefs.h\"\n"
         "\n"
         "#ifdef CFP_LUCY\n"
         "  #define LUCY_VISIBLE CHY_EXPORT\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/src/CFCC.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCC.c b/clownfish/compiler/src/CFCC.c
index fbd1719..1b5b58a 100644
--- a/clownfish/compiler/src/CFCC.c
+++ b/clownfish/compiler/src/CFCC.c
@@ -167,4 +167,30 @@ CFCC_write_man_pages(CFCC *self) {
     FREEMEM(ordered);
 }
 
+void
+CFCC_write_hostdefs(CFCC *self) {
+    const char pattern[] =
+        "%s\n"
+        "\n"
+        "#ifndef H_CFISH_HOSTDEFS\n"
+        "#define H_CFISH_HOSTDEFS 1\n"
+        "\n"
+        "#define CFISH_OBJ_HEAD\n"
+        "\n"
+        "#endif /* H_CFISH_HOSTDEFS */\n"
+        "\n"
+        "%s\n";
+    char *content
+        = CFCUtil_sprintf(pattern, self->header, self->footer);
+
+    // Unlink then write file.
+    const char *inc_dest = CFCHierarchy_get_include_dest(self->hierarchy);
+    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "hostdefs.h", inc_dest);
+    remove(filepath);
+    CFCUtil_write_file(filepath, content, strlen(content));
+    FREEMEM(filepath);
+
+    FREEMEM(content);
+}
+
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/src/CFCC.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCC.h b/clownfish/compiler/src/CFCC.h
index e66a900..3dfcd61 100644
--- a/clownfish/compiler/src/CFCC.h
+++ b/clownfish/compiler/src/CFCC.h
@@ -49,6 +49,11 @@ CFCC_destroy(CFCC *self);
 void
 CFCC_write_callbacks(CFCC *self);
 
+/** Write the "hostdefs.h" header file.
+ */
+void
+CFCC_write_hostdefs(CFCC *self);
+
 /** Write all man pages.
  */
 void

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerl.c b/clownfish/compiler/src/CFCPerl.c
index c28037b..459c5fd 100644
--- a/clownfish/compiler/src/CFCPerl.c
+++ b/clownfish/compiler/src/CFCPerl.c
@@ -315,6 +315,32 @@ S_write_boot_c(CFCPerl *self) {
 }
 
 void
+CFCPerl_write_hostdefs(CFCPerl *self) {
+    const char pattern[] =
+        "%s\n"
+        "\n"
+        "#ifndef H_CFISH_HOSTDEFS\n"
+        "#define H_CFISH_HOSTDEFS 1\n"
+        "\n"
+        "#define CFISH_OBJ_HEAD\n"
+        "\n"
+        "#endif /* H_CFISH_HOSTDEFS */\n"
+        "\n"
+        "%s\n";
+    char *content
+        = CFCUtil_sprintf(pattern, self->header, self->footer);
+
+    // Unlink then write file.
+    const char *inc_dest = CFCHierarchy_get_include_dest(self->hierarchy);
+    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "hostdefs.h", inc_dest);
+    remove(filepath);
+    CFCUtil_write_file(filepath, content, strlen(content));
+    FREEMEM(filepath);
+
+    FREEMEM(content);
+}
+
+void
 CFCPerl_write_boot(CFCPerl *self) {
     S_write_boot_h(self);
     S_write_boot_c(self);

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/src/CFCPerl.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerl.h b/clownfish/compiler/src/CFCPerl.h
index 8dfb61f..04f0c53 100644
--- a/clownfish/compiler/src/CFCPerl.h
+++ b/clownfish/compiler/src/CFCPerl.h
@@ -103,6 +103,11 @@ CFCPerl_write_bindings(CFCPerl *self);
 void
 CFCPerl_write_callbacks(CFCPerl *self);
 
+/** Generate hostdefs file.
+ */
+void
+CFCPerl_write_hostdefs(CFCPerl *self);
+
 /** Generate the "typemap" file needed by the XS compiler.
  */
 void

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/src/CFCRuby.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCRuby.c b/clownfish/compiler/src/CFCRuby.c
index 37824b2..b4a58ce 100644
--- a/clownfish/compiler/src/CFCRuby.c
+++ b/clownfish/compiler/src/CFCRuby.c
@@ -235,3 +235,29 @@ CFCRuby_write_boot(CFCRuby *self) {
     S_write_boot_c(self);
 }
 
+void
+CFCRuby_write_hostdefs(CFCRuby *self) {
+    const char pattern[] =
+        "%s\n"
+        "\n"
+        "#ifndef H_CFISH_HOSTDEFS\n"
+        "#define H_CFISH_HOSTDEFS 1\n"
+        "\n"
+        "#define CFISH_OBJ_HEAD\n"
+        "\n"
+        "#endif /* H_CFISH_HOSTDEFS */\n"
+        "\n"
+        "%s\n";
+    char *content
+        = CFCUtil_sprintf(pattern, self->header, self->footer);
+
+    // Unlink then write file.
+    const char *inc_dest = CFCHierarchy_get_include_dest(self->hierarchy);
+    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "hostdefs.h", inc_dest);
+    remove(filepath);
+    CFCUtil_write_file(filepath, content, strlen(content));
+    FREEMEM(filepath);
+
+    FREEMEM(content);
+}
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/compiler/src/CFCRuby.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCRuby.h b/clownfish/compiler/src/CFCRuby.h
index 657cb9f..a694e56 100644
--- a/clownfish/compiler/src/CFCRuby.h
+++ b/clownfish/compiler/src/CFCRuby.h
@@ -85,6 +85,10 @@ CFCRuby_destroy(CFCRuby *self);
 void
 CFCRuby_write_boot(CFCRuby *self);
 
+/** Write out hostdefs.h file.
+ */
+void
+CFCRuby_write_hostdefs(CFCRuby *self);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/39a9fc99/clownfish/runtime/ruby/Rakefile
----------------------------------------------------------------------
diff --git a/clownfish/runtime/ruby/Rakefile b/clownfish/runtime/ruby/Rakefile
index ade30b3..f9a821a 100644
--- a/clownfish/runtime/ruby/Rakefile
+++ b/clownfish/runtime/ruby/Rakefile
@@ -78,6 +78,7 @@ task :build_clownfish => [:build_charmonizer_tests] do
   if (modified)
     puts "Building Binding Code"
     ruby_binding.write_boot
+    ruby_binding.write_hostdefs
   end
   Rake::Task['compile'].invoke