lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [04/10] git commit: refs/heads/charmonizer-decoupling - Port more macros from CHY to CFISH namespace
Date Sun, 21 Jul 2013 13:35:13 GMT
Port more macros from CHY to CFISH namespace


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

Branch: refs/heads/charmonizer-decoupling
Commit: 281679dfaee6ca8e7fa985c18fed15debf4f114f
Parents: 814c070
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sun Jul 21 11:58:31 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun Jul 21 15:04:04 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/common/charmonizer.main |   3 +
 clownfish/compiler/src/CFCBindCore.c       | 116 +++++++++++++++++++++---
 devel/bin/regen_charmonizer.pl             |  10 +-
 3 files changed, 111 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/281679df/clownfish/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/clownfish/compiler/common/charmonizer.main b/clownfish/compiler/common/charmonizer.main
index eeae5fe..1803a3b 100644
--- a/clownfish/compiler/common/charmonizer.main
+++ b/clownfish/compiler/common/charmonizer.main
@@ -263,12 +263,15 @@ int main(int argc, const char **argv) {
     chaz_BuildEnv_run();
     chaz_DirManip_run();
     chaz_Headers_run();
+    chaz_AtomicOps_run();
     chaz_FuncMacro_run();
     chaz_Booleans_run();
     chaz_Integers_run();
     chaz_Strings_run();
+    chaz_Memory_run();
     chaz_SymbolVisibility_run();
     chaz_UnusedVars_run();
+    chaz_VariadicMacros_run();
 
     if (args.write_makefile) {
         S_write_makefile(&args);

http://git-wip-us.apache.org/repos/asf/lucy/blob/281679df/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index 5a7c94a..430c608 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -55,11 +55,20 @@ static char*
 S_charmony_defines();
 
 static char*
+S_charmony_feature_defines();
+
+static char*
+S_charmony_string_defines();
+
+static char*
 S_charmony_stdbool_defines();
 
-char*
+static char*
 S_charmony_stdint_defines();
 
+static char*
+S_charmony_alloca_defines();
+
 static const CFCMeta CFCBINDCORE_META = {
     "Clownfish::CFC::Binding::Core",
     sizeof(CFCBindCore),
@@ -140,8 +149,6 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
     const char   *PREFIX      = CFCParcel_get_PREFIX(parcel);
     const char   *privacy_sym = CFCParcel_get_privacy_sym(parcel);
 
-    char *charmony_defines = S_charmony_defines();
-
     // Declare object structs for all instantiable classes.
     char *typedefs = CFCUtil_strdup("");
     CFCClass **ordered = CFCHierarchy_ordered_classes(hierarchy);
@@ -158,13 +165,16 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
     }
     FREEMEM(ordered);
 
-    // Special includes for Clownfish parcel.
+    // Special includes and macros for Clownfish parcel.
     const char *cfish_includes_pattern =
         "#include <stdarg.h>\n"
         "#include <stddef.h>\n"
         "\n"
         "%s"
         "\n"
+        "#define CFISH_UNUSED_VAR(var) ((void)var)\n"
+        "#define CFISH_UNREACHABLE_RETURN(type) return (type)0\n"
+        "\n"
         "#include \"cfish_hostdefs.h\"\n";
 
     // Special definitions for Clownfish parcel.
@@ -270,8 +280,10 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
     char *extra_includes;
     if (strcmp(prefix, "cfish_") == 0) {
         extra_defs = cfish_defs;
+        char *charmony_defines = S_charmony_defines();
         extra_includes = CFCUtil_sprintf(cfish_includes_pattern,
                                          charmony_defines);
+        FREEMEM(charmony_defines);
     }
     else {
         extra_defs = "";
@@ -339,7 +351,6 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
     CFCUtil_write_file(filepath, file_content, strlen(file_content));
     FREEMEM(filepath);
 
-    FREEMEM(charmony_defines);
     FREEMEM(typedefs);
     FREEMEM(extra_includes);
     FREEMEM(file_content);
@@ -553,22 +564,87 @@ CFCBindCore_write_callbacks_h(CFCBindCore *self) {
 
 static char*
 S_charmony_defines() {
+    char *feature_defs = S_charmony_feature_defines();
+    char *string_defs  = S_charmony_string_defines();
     char *stdbool_defs = S_charmony_stdbool_defines();
     char *stdint_defs  = S_charmony_stdint_defines();
+    char *alloca_defs  = S_charmony_alloca_defines();
 
     const char *pattern =
-        "#define CFISH_INLINE %s\n"
-        "#define CFISH_EXPORT %s\n"
-        "#define CFISH_IMPORT %s\n"
+        "%s"
+        "%s"
         "\n"
         "%s"
+        "%s"
+        "\n"
         "%s";
     char *defines
-        = CFCUtil_sprintf(pattern, XSTRING(CHY_INLINE), XSTRING(CHY_EXPORT),
-                          XSTRING(CHY_IMPORT), stdbool_defs, stdint_defs);
+        = CFCUtil_sprintf(pattern, feature_defs, string_defs, stdbool_defs,
+                          stdint_defs, alloca_defs);
 
+    FREEMEM(feature_defs);
+    FREEMEM(string_defs);
     FREEMEM(stdbool_defs);
     FREEMEM(stdint_defs);
+    FREEMEM(alloca_defs);
+    return defines;
+}
+
+static char*
+S_charmony_feature_defines() {
+    char *defines = CFCUtil_strdup("");
+
+#ifdef CHY_HAS_WINDOWS_H
+    defines = CFCUtil_cat(defines, "#define CFISH_HAS_WINDOWS_H\n", NULL);
+#endif
+#ifdef CHY_HAS_SYS_ATOMIC_H
+    defines = CFCUtil_cat(defines, "#define CFISH_HAS_SYS_ATOMIC_H\n", NULL);
+#endif
+#ifdef CHY_HAS_PTHREAD_H
+    defines = CFCUtil_cat(defines, "#define CFISH_HAS_PTHREAD_H\n", NULL);
+#endif
+#ifdef CHY_LITTLE_END
+    defines = CFCUtil_cat(defines, "#define CFISH_LITTLE_END\n", NULL);
+#endif
+#ifdef CHY_BIG_END
+    defines = CFCUtil_cat(defines, "#define CFISH_BIG_END\n", NULL);
+#endif
+#ifdef CHY_HAS_FUNC_MACRO
+    defines = CFCUtil_cat(defines, "#define CFISH_HAS_FUNC_MACRO\n", NULL);
+#endif
+#ifdef CHY_HAS_VARIADIC_MACROS
+    defines = CFCUtil_cat(defines, "#define CFISH_HAS_VARIADIC_MACROS\n",
+                          NULL);
+#endif
+#ifdef CHY_HAS_ISO_VARIADIC_MACROS
+    defines = CFCUtil_cat(defines, "#define CFISH_HAS_ISO_VARIADIC_MACROS\n",
+                          NULL);
+#endif
+#ifdef CHY_HAS_GNUC_VARIADIC_MACROS
+    defines = CFCUtil_cat(defines, "#define CFISH_HAS_GNUC_VARIADIC_MACROS\n",
+                          NULL);
+#endif
+#ifdef CHY_HAS_OSATOMIC_CAS_PTR
+    defines = CFCUtil_cat(defines, "#define CFISH_HAS_OSATOMIC_CAS_PTR\n",
+                          NULL);
+#endif
+
+    return defines;
+}
+
+static char*
+S_charmony_string_defines() {
+    const char *pattern =
+        "#define CFISH_INLINE %s\n"
+        "#define CFISH_EXPORT %s\n"
+        "#define CFISH_IMPORT %s\n"
+        "#define CFISH_FUNC_MACRO %s\n"
+        "#define CFISH_U64_TO_DOUBLE(x) %s\n";
+    char *defines
+        = CFCUtil_sprintf(pattern, XSTRING(CHY_INLINE), XSTRING(CHY_EXPORT),
+                          XSTRING(CHY_IMPORT), XSTRING(CHY_FUNC_MACRO),
+                          XSTRING(CHY_U64_TO_DOUBLE(x)));
+
     return defines;
 }
 
@@ -592,7 +668,7 @@ S_charmony_stdbool_defines() {
     return CFCUtil_strdup(defines);
 }
 
-char*
+static char*
 S_charmony_stdint_defines() {
 #ifdef CHY_HAS_STDINT_H
     return CFCUtil_strdup("#include <stdint.h>\n");
@@ -616,4 +692,22 @@ S_charmony_stdint_defines() {
 #endif
 }
 
+static char*
+S_charmony_alloca_defines() {
+    char *defines = CFCUtil_strdup("");
+
+#if defined(CHY_HAS_ALLOCA_H)
+    defines = CFCUtil_cat(defines, "#include <alloca.h>\n", NULL);
+#elif defined(CHY_HAS_MALLOC_H)
+    defines = CFCUtil_cat(defines, "#include <malloc.h>\n", NULL);
+#elif defined(CHY_ALLOCA_IN_STDLIB_H)
+    defines = CFCUtil_cat(defines, "#include <stdlib.h>\n", NULL);
+#endif
+
+    defines = CFCUtil_cat(defines, "#define cfish_alloca ",
+                          XSTRING(chy_alloca), "\n", NULL);
+
+    return defines;
+}
+
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/281679df/devel/bin/regen_charmonizer.pl
----------------------------------------------------------------------
diff --git a/devel/bin/regen_charmonizer.pl b/devel/bin/regen_charmonizer.pl
index 1fda312..1e42dd3 100755
--- a/devel/bin/regen_charmonizer.pl
+++ b/devel/bin/regen_charmonizer.pl
@@ -29,15 +29,11 @@ my $MELD_EXE = catfile( $CHAZ_DIR, 'buildbin', 'meld.pl' );
 
 # Clownfish compiler.
 {
-    my $probes = join( ',', qw(
-        Booleans BuildEnv DirManip FuncMacro Headers Integers Strings
-        SymbolVisibility UnusedVars
-    ) );
-    my $main   = catfile(qw( clownfish compiler common charmonizer.main ));
-    my $out    = $main;
+    my $main = catfile(qw( clownfish compiler common charmonizer.main ));
+    my $out  = $main;
     $out =~ s/\.main/.c/ or die "no match";
     unlink $out;
-    system( $MELD_EXE, "--probes=$probes", "--files=$main", "--out=$out" );
+    system( $MELD_EXE, "--probes=", "--files=$main", "--out=$out" );
 }
 
 # Clownfish runtime.


Mime
View raw message