You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/05/18 21:23:46 UTC

[lucy-commits] [01/15] git commit: refs/heads/install-c-library - Add parcel prefix to parcel.c and parcel.h

Updated Branches:
  refs/heads/install-c-library [created] 27018f3ba


Add parcel prefix to parcel.c and parcel.h

The parcel header file must be publicly available, so add parcel prefix
to avoid name clashes.


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

Branch: refs/heads/install-c-library
Commit: 6716917eccfc96ce61f04535539400a5146e60cc
Parents: 637d4e6
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri May 17 22:42:56 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 13:11:55 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCBindClass.c |   12 ++++---
 clownfish/compiler/src/CFCBindCore.c  |   47 ++++++++++++++++-----------
 clownfish/compiler/src/CFCPerl.c      |   25 +++++++++-----
 clownfish/compiler/src/CFCRuby.c      |   17 +++-------
 common/charmonizer.c                  |    5 ++-
 common/charmonizer.main               |    5 ++-
 6 files changed, 62 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/6716917e/clownfish/compiler/src/CFCBindClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindClass.c b/clownfish/compiler/src/CFCBindClass.c
index 21a6daf..e483530 100644
--- a/clownfish/compiler/src/CFCBindClass.c
+++ b/clownfish/compiler/src/CFCBindClass.c
@@ -119,13 +119,14 @@ CFCBindClass_to_c_header(CFCBindClass *self) {
 
 static char*
 S_to_c_header_inert(CFCBindClass *self) {
+    const char *prefix    = CFCClass_get_prefix(self->client);
     char *inert_func_decs = S_sub_declarations(self);
     char *inert_var_defs  = S_inert_var_declarations(self);
     char *short_names     = S_short_names(self);
 
     char pattern[] =
         "#include \"charmony.h\"\n"
-        "#include \"parcel.h\"\n"
+        "#include \"%sparcel.h\"\n"
         "\n"
         "/* Declare this class's inert variables.\n"
         " */\n"
@@ -142,8 +143,8 @@ S_to_c_header_inert(CFCBindClass *self) {
         "\n"
         "%s\n"
         "\n";
-    char *content = CFCUtil_sprintf(pattern, inert_var_defs, inert_func_decs,
-                                    short_names);
+    char *content = CFCUtil_sprintf(pattern, prefix, inert_var_defs,
+                                    inert_func_decs, short_names);
 
     FREEMEM(inert_var_defs);
     FREEMEM(inert_func_decs);
@@ -155,6 +156,7 @@ static char*
 S_to_c_header_dynamic(CFCBindClass *self) {
     const char *privacy_symbol  = CFCClass_privacy_symbol(self->client);
     const char *vt_var          = CFCClass_full_vtable_var(self->client);
+    const char *prefix          = CFCClass_get_prefix(self->client);
     const char *PREFIX          = CFCClass_get_PREFIX(self->client);
     char *struct_def            = S_struct_definition(self);
     char *parent_include        = S_parent_include(self);
@@ -166,7 +168,7 @@ S_to_c_header_dynamic(CFCBindClass *self) {
 
     char pattern[] =
         "#include \"charmony.h\"\n"
-        "#include \"parcel.h\"\n"
+        "#include \"%sparcel.h\"\n"
         "\n"
         "/* Include the header for this class's parent. \n"
         " */\n"
@@ -213,7 +215,7 @@ S_to_c_header_dynamic(CFCBindClass *self) {
         "%s\n"
         "\n";
     char *content
-        = CFCUtil_sprintf(pattern, parent_include, privacy_symbol,
+        = CFCUtil_sprintf(pattern, prefix, parent_include, privacy_symbol,
                           struct_def, privacy_symbol, inert_var_defs,
                           sub_declarations, method_typedefs, method_defs,
                           PREFIX, vt_var, short_names);

http://git-wip-us.apache.org/repos/asf/lucy/blob/6716917e/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index 662d20e..642569b 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -137,12 +137,13 @@ S_write_parcel_h(CFCBindCore *self) {
             parcel = CFCClass_get_parcel(klass);
         }
     }
+    FREEMEM(ordered);
+
     if (!parcel) {
         CFCUtil_die("No source classes found.");
     }
     const char *prefix = CFCParcel_get_prefix(parcel);
     const char *PREFIX = CFCParcel_get_PREFIX(parcel);
-    FREEMEM(ordered);
 
     // Create Clownfish aliases if necessary.
     char *aliases = CFCBindAliases_c_aliases();
@@ -269,7 +270,8 @@ S_write_parcel_h(CFCBindCore *self) {
 
     // Unlink then write file.
     const char *inc_dest = CFCHierarchy_get_include_dest(hierarchy);
-    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "parcel.h", inc_dest);
+    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "%sparcel.h", inc_dest,
+                                     prefix);
     remove(filepath);
     CFCUtil_write_file(filepath, file_content, strlen(file_content));
     FREEMEM(filepath);
@@ -324,19 +326,20 @@ S_write_parcel_c(CFCBindCore *self) {
         }
         parcel = CFCClass_get_parcel(klass);
     }
+    vt_specs = CFCUtil_cat(vt_specs, "\n};\n", NULL);
+    FREEMEM(ordered);
+
     if (!parcel) {
         CFCUtil_die("No source classes found.");
     }
     const char *prefix = CFCParcel_get_prefix(parcel);
-    vt_specs = CFCUtil_cat(vt_specs, "\n};\n", NULL);
-    FREEMEM(ordered);
 
     char pattern[] =
         "%s\n"
         "\n"
         "#define C_LUCY_VTABLE\n"
         "%s\n"
-        "#include \"parcel.h\"\n"
+        "#include \"%sparcel.h\"\n"
         "#include \"callbacks.h\"\n"
         "#include \"Clownfish/VTable.h\"\n"
         "%s\n"
@@ -358,13 +361,14 @@ S_write_parcel_c(CFCBindCore *self) {
         "\n"
         "%s\n";
     char *file_content
-        = CFCUtil_sprintf(pattern, self->header, privacy_syms, includes,
-                          c_data, vt_specs, prefix, num_specs, prefix,
-                          self->footer);
+        = CFCUtil_sprintf(pattern, self->header, privacy_syms, prefix,
+                          includes, c_data, vt_specs, prefix, num_specs,
+                          prefix, self->footer);
 
     // Unlink then open file.
     const char *src_dest = CFCHierarchy_get_source_dest(hierarchy);
-    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "parcel.c", src_dest);
+    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "%sparcel.c", src_dest,
+                                     prefix);
     remove(filepath);
     CFCUtil_write_file(filepath, file_content, strlen(file_content));
     FREEMEM(filepath);
@@ -383,6 +387,7 @@ void
 CFCBindCore_write_callbacks_h(CFCBindCore *self) {
     CFCHierarchy  *hierarchy   = self->hierarchy;
     CFCClass     **ordered     = CFCHierarchy_ordered_classes(hierarchy);
+    CFCParcel     *parcel      = NULL;
     char          *includes    = CFCUtil_strdup("");
     char          *all_cb_decs = CFCUtil_strdup("");
 
@@ -399,11 +404,21 @@ CFCBindCore_write_callbacks_h(CFCBindCore *self) {
             all_cb_decs = CFCUtil_cat(all_cb_decs, cb_decs, NULL);
             FREEMEM(cb_decs);
             CFCBase_decref((CFCBase*)class_binding);
+
+            if (parcel && CFCClass_get_parcel(klass) != parcel) {
+                CFCUtil_die("Multiple parcels not yet supported.");
+            }
+            parcel = CFCClass_get_parcel(klass);
         }
     }
 
     FREEMEM(ordered);
 
+    if (!parcel) {
+        CFCUtil_die("No source classes found.");
+    }
+    const char *prefix = CFCParcel_get_prefix(parcel);
+
     const char pattern[] =
         "%s\n"
         "#ifndef CFCCALLBACKS_H\n"
@@ -413,7 +428,7 @@ CFCBindCore_write_callbacks_h(CFCBindCore *self) {
         "extern \"C\" {\n"
         "#endif\n"
         "\n"
-        "#include \"parcel.h\"\n"
+        "#include \"%sparcel.h\"\n"
         "%s"
         "\n"
         "%s"
@@ -426,15 +441,9 @@ CFCBindCore_write_callbacks_h(CFCBindCore *self) {
         "\n"
         "%s\n"
         "\n";
-    size_t size = sizeof(pattern)
-                  + strlen(self->header)
-                  + strlen(includes)
-                  + strlen(all_cb_decs)
-                  + strlen(self->footer)
-                  + 50;
-    char *file_content = (char*)MALLOCATE(size);
-    sprintf(file_content, pattern, self->header, includes, all_cb_decs,
-            self->footer);
+    char *file_content
+        = CFCUtil_sprintf(pattern, self->header, prefix, includes, all_cb_decs,
+                          self->footer);
 
     // Unlink then write file.
     const char *inc_dest = CFCHierarchy_get_include_dest(hierarchy);

http://git-wip-us.apache.org/repos/asf/lucy/blob/6716917e/clownfish/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerl.c b/clownfish/compiler/src/CFCPerl.c
index d8e3ef6..419799f 100644
--- a/clownfish/compiler/src/CFCPerl.c
+++ b/clownfish/compiler/src/CFCPerl.c
@@ -48,6 +48,7 @@ struct CFCPerl {
     char *boot_h_path;
     char *boot_c_path;
     char *boot_func;
+    char *parcel_h_file;
 };
 
 // Modify a string in place, swapping out "::" for the supplied character.
@@ -112,6 +113,9 @@ CFCPerl_init(CFCPerl *self, CFCParcel *parcel, CFCHierarchy *hierarchy,
         }
     }
 
+    // Derive the name of the "parcel.h" file.
+    self->parcel_h_file = CFCUtil_sprintf("%sparcel.h", prefix);
+
     return self;
 }
 
@@ -129,6 +133,7 @@ CFCPerl_destroy(CFCPerl *self) {
     FREEMEM(self->boot_h_path);
     FREEMEM(self->boot_c_path);
     FREEMEM(self->boot_func);
+    FREEMEM(self->parcel_h_file);
     CFCBase_destroy((CFCBase*)self);
 }
 
@@ -283,7 +288,7 @@ S_write_boot_c(CFCPerl *self) {
         "#include \"perl.h\"\n"
         "#include \"XSUB.h\"\n"
         "#include \"%s\"\n"
-        "#include \"parcel.h\"\n"
+        "#include \"%s\"\n"
         "#include \"Clownfish/CharBuf.h\"\n"
         "#include \"Clownfish/VTable.h\"\n"
         "%s\n"
@@ -303,8 +308,8 @@ S_write_boot_c(CFCPerl *self) {
         "\n";
     char *content
         = CFCUtil_sprintf(pattern, self->header, self->boot_h_file,
-                          pound_includes, self->boot_func, prefix, alias_adds,
-                          isa_pushes, self->footer);
+                          self->parcel_h_file, pound_includes, self->boot_func,
+                          prefix, alias_adds, isa_pushes, self->footer);
     CFCUtil_write_file(self->boot_c_path, content, strlen(content));
 
     FREEMEM(content);
@@ -360,7 +365,7 @@ S_xs_file_contents(CFCPerl *self, const char *generated_xs,
         "%s"
         "\n"
         "#include \"XSBind.h\"\n"
-        "#include \"parcel.h\"\n"
+        "#include \"%s\"\n"
         "#include \"%s\"\n"
         "\n"
         "#include \"Clownfish/Util/Memory.h\"\n"
@@ -383,9 +388,10 @@ S_xs_file_contents(CFCPerl *self, const char *generated_xs,
         "\n"
         "%s";
     char *contents
-        = CFCUtil_sprintf(pattern, self->header, self->boot_h_file,
-                          generated_xs, self->boot_class, self->boot_class,
-                          xs_init, hand_rolled_xs, self->footer);
+        = CFCUtil_sprintf(pattern, self->header, self->parcel_h_file,
+                          self->boot_h_file, generated_xs, self->boot_class,
+                          self->boot_class, xs_init, hand_rolled_xs,
+                          self->footer);
 
     return contents;
 }
@@ -497,7 +503,7 @@ S_write_callbacks_c(CFCPerl *self) {
         "\n"
         "#include \"XSBind.h\"\n"
         "#include \"callbacks.h\"\n"
-        "#include \"parcel.h\"\n"
+        "#include \"%s\"\n"
         "\n"
         "static void\n"
         "S_finish_callback_void(const char *meth_name) {\n"
@@ -570,7 +576,8 @@ S_write_callbacks_c(CFCPerl *self) {
         "    return retval;\n"
         "}\n"
         "\n";
-    char *content = CFCUtil_sprintf(pattern, self->header);
+    char *content
+        = CFCUtil_sprintf(pattern, self->header, self->parcel_h_file);
 
     for (size_t i = 0; ordered[i] != NULL; i++) {
         CFCClass *klass = ordered[i];

http://git-wip-us.apache.org/repos/asf/lucy/blob/6716917e/clownfish/compiler/src/CFCRuby.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCRuby.c b/clownfish/compiler/src/CFCRuby.c
index 6921522..678327d 100644
--- a/clownfish/compiler/src/CFCRuby.c
+++ b/clownfish/compiler/src/CFCRuby.c
@@ -196,7 +196,7 @@ S_write_boot_c(CFCRuby *self) {
         "\n"
         "#include \"charmony.h\"\n"
         "#include \"%s\"\n"
-        "#include \"parcel.h\"\n"
+        "#include \"%sparcel.h\"\n"
         "#include \"Clownfish/CharBuf.h\"\n"
         "#include \"Clownfish/VTable.h\"\n"
         "%s\n"
@@ -211,17 +211,10 @@ S_write_boot_c(CFCRuby *self) {
         "%s\n"
         "\n";
 
-    size_t size = sizeof(pattern)
-                  + strlen(self->header)
-                  + strlen(self->boot_h_file)
-                  + strlen(pound_includes)
-                  + strlen(self->boot_func)
-                  + strlen(prefix)
-                  + strlen(self->footer)
-                  + 100;
-    char *content = (char*)MALLOCATE(size);
-    sprintf(content, pattern, self->header, self->boot_h_file, pound_includes,
-            self->boot_func, prefix, self->footer);
+    char *content
+        = CFCUtil_sprintf(pattern, self->header, self->boot_h_file, prefix,
+                          pound_includes, self->boot_func, prefix,
+                          self->footer);
     CFCUtil_write_file(self->boot_c_path, content, strlen(content));
 
     FREEMEM(content);

http://git-wip-us.apache.org/repos/asf/lucy/blob/6716917e/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/common/charmonizer.c b/common/charmonizer.c
index 6d2cfb7..3b51644 100644
--- a/common/charmonizer.c
+++ b/common/charmonizer.c
@@ -6839,7 +6839,7 @@ S_write_makefile(struct chaz_CLIArgs *args) {
     free(scratch);
 
     scratch = chaz_Util_join("", "autogen", dir_sep, "source", dir_sep,
-                             "parcel", obj_ext, NULL);
+                             "lucy_parcel", obj_ext, NULL);
     chaz_MakeVar_append(var, scratch);
     free(scratch);
 
@@ -6878,7 +6878,8 @@ S_write_makefile(struct chaz_CLIArgs *args) {
     free(scratch);
 
     /* Needed for parallel builds. */
-    scratch = chaz_Util_join(dir_sep, "autogen", "source", "parcel.c", NULL);
+    scratch = chaz_Util_join(dir_sep, "autogen", "source", "lucy_parcel.c",
+                             NULL);
     rule = chaz_MakeFile_add_rule(makefile, scratch, "autogen");
     free(scratch);
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/6716917e/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/common/charmonizer.main b/common/charmonizer.main
index 831e5f4..f0cad62 100644
--- a/common/charmonizer.main
+++ b/common/charmonizer.main
@@ -242,7 +242,7 @@ S_write_makefile(struct chaz_CLIArgs *args) {
     free(scratch);
 
     scratch = chaz_Util_join("", "autogen", dir_sep, "source", dir_sep,
-                             "parcel", obj_ext, NULL);
+                             "lucy_parcel", obj_ext, NULL);
     chaz_MakeVar_append(var, scratch);
     free(scratch);
 
@@ -281,7 +281,8 @@ S_write_makefile(struct chaz_CLIArgs *args) {
     free(scratch);
 
     /* Needed for parallel builds. */
-    scratch = chaz_Util_join(dir_sep, "autogen", "source", "parcel.c", NULL);
+    scratch = chaz_Util_join(dir_sep, "autogen", "source", "lucy_parcel.c",
+                             NULL);
     rule = chaz_MakeFile_add_rule(makefile, scratch, "autogen");
     free(scratch);
 


[lucy-commits] [11/15] git commit: refs/heads/install-c-library - Rename hostdefs.h to cfish_hostdefs.h

Posted by nw...@apache.org.
Rename hostdefs.h to cfish_hostdefs.h

This header must be publicly available, so add a prefix to avoid name
clashes.


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

Branch: refs/heads/install-c-library
Commit: a70454f5f26c52750f798f71324bc78b1a89cfd1
Parents: b37b804
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 12:59:54 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 19:15:56 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCBindCore.c |    2 +-
 clownfish/compiler/src/CFCC.c        |    3 ++-
 clownfish/compiler/src/CFCC.h        |    2 +-
 clownfish/compiler/src/CFCPerl.c     |    3 ++-
 clownfish/compiler/src/CFCRuby.c     |    3 ++-
 clownfish/compiler/src/CFCRuby.h     |    2 +-
 6 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/a70454f5/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index 2f179ec..63bcda3 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -176,7 +176,7 @@ S_write_parcel_h(CFCBindCore *self) {
         "\n"
         "%s"
         "\n"
-        "#include \"hostdefs.h\"\n"
+        "#include \"cfish_hostdefs.h\"\n"
         "\n"
         "#ifdef CFP_LUCY\n"
         "  #include \"charmony.h\"\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/a70454f5/clownfish/compiler/src/CFCC.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCC.c b/clownfish/compiler/src/CFCC.c
index 3e52374..3f21a0d 100644
--- a/clownfish/compiler/src/CFCC.c
+++ b/clownfish/compiler/src/CFCC.c
@@ -186,7 +186,8 @@ CFCC_write_hostdefs(CFCC *self) {
 
     // 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);
+    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "cfish_hostdefs.h",
+                                     inc_dest);
     remove(filepath);
     CFCUtil_write_file(filepath, content, strlen(content));
     FREEMEM(filepath);

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

http://git-wip-us.apache.org/repos/asf/lucy/blob/a70454f5/clownfish/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerl.c b/clownfish/compiler/src/CFCPerl.c
index a2634de..8efc0a1 100644
--- a/clownfish/compiler/src/CFCPerl.c
+++ b/clownfish/compiler/src/CFCPerl.c
@@ -344,7 +344,8 @@ CFCPerl_write_hostdefs(CFCPerl *self) {
 
     // 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);
+    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "cfish_hostdefs.h",
+                                     inc_dest);
     remove(filepath);
     CFCUtil_write_file(filepath, content, strlen(content));
     FREEMEM(filepath);

http://git-wip-us.apache.org/repos/asf/lucy/blob/a70454f5/clownfish/compiler/src/CFCRuby.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCRuby.c b/clownfish/compiler/src/CFCRuby.c
index 678327d..64b3466 100644
--- a/clownfish/compiler/src/CFCRuby.c
+++ b/clownfish/compiler/src/CFCRuby.c
@@ -253,7 +253,8 @@ CFCRuby_write_hostdefs(CFCRuby *self) {
 
     // 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);
+    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "cfish_hostdefs.h",
+                                     inc_dest);
     remove(filepath);
     CFCUtil_write_file(filepath, content, strlen(content));
     FREEMEM(filepath);

http://git-wip-us.apache.org/repos/asf/lucy/blob/a70454f5/clownfish/compiler/src/CFCRuby.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCRuby.h b/clownfish/compiler/src/CFCRuby.h
index a694e56..ebe2cfa 100644
--- a/clownfish/compiler/src/CFCRuby.h
+++ b/clownfish/compiler/src/CFCRuby.h
@@ -85,7 +85,7 @@ CFCRuby_destroy(CFCRuby *self);
 void
 CFCRuby_write_boot(CFCRuby *self);
 
-/** Write out hostdefs.h file.
+/** Write out cfish_hostdefs.h file.
  */
 void
 CFCRuby_write_hostdefs(CFCRuby *self);


[lucy-commits] [07/15] git commit: refs/heads/install-c-library - Move stdint typedefs from charmony.h to parcel.h

Posted by nw...@apache.org.
Move stdint typedefs from charmony.h to parcel.h

Change ConfWriterC to move global macro definitions, global typedefs,
and system includes into special sections that can be enabled by
defining macros of the form CHY_EMPLOY_MODULE.

Disable the stdint typedefs in Lucy's charmony.h and move them to
parcel.h.


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

Branch: refs/heads/install-c-library
Commit: cf630fcf94cd90392b465efa63bf0280de255be8
Parents: 92dbd8a
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 04:22:14 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 19:09:54 2013 +0200

----------------------------------------------------------------------
 charmonizer/src/Charmonizer/Core/ConfWriterC.c |   86 +++++++++++++-----
 charmonizer/src/Charmonizer/Probe/Booleans.c   |    2 +-
 clownfish/compiler/common/charmonizer.main     |    6 ++
 clownfish/compiler/src/CFCBindCore.c           |   87 ++++++++++++++++++-
 common/charmonizer.main                        |    7 ++
 devel/bin/regen_charmonizer.pl                 |    5 +-
 6 files changed, 166 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/cf630fcf/charmonizer/src/Charmonizer/Core/ConfWriterC.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/ConfWriterC.c b/charmonizer/src/Charmonizer/Core/ConfWriterC.c
index 132a4e4..d50f779 100644
--- a/charmonizer/src/Charmonizer/Core/ConfWriterC.c
+++ b/charmonizer/src/Charmonizer/Core/ConfWriterC.c
@@ -44,6 +44,7 @@ typedef struct chaz_ConfElem {
 /* Static vars. */
 static struct {
     FILE          *fh;
+    char          *MODULE_NAME;
     chaz_ConfElem *defs;
     size_t         def_cap;
     size_t         def_count;
@@ -141,18 +142,17 @@ chaz_ConfWriterC_vappend_conf(const char *fmt, va_list args) {
 
 static int
 chaz_ConfWriterC_sym_is_uppercase(const char *sym) {
-    unsigned i;
-    for (i = 0; sym[i] != 0; i++) {
-        if (!isupper(sym[i])) {
-            if (islower(sym[i])) {
-                return false;
-            }
-            else if (sym[i] != '_') {
-                return true;
-            }
-        }
+    return isupper(sym[0]);
+}
+
+static char*
+chaz_ConfWriterC_uppercase_string(const char *src) {
+    char *retval = chaz_Util_strdup(src);
+    size_t i;
+    for (i = 0; retval[i]; ++i) {
+        retval[i] = toupper(retval[i]);
     }
-    return true;
+    return retval;
 }
 
 static void
@@ -187,9 +187,10 @@ chaz_ConfWriterC_add_global_def(const char *sym, const char *value) {
 
 static void
 chaz_ConfWriterC_append_global_def_to_conf(const char *sym,
-        const char *value) {
+                                           const char *value) {
     char *name_end = strchr(sym, '(');
     if (name_end == NULL) {
+        if (strcmp(sym, value) == 0) { return; }
         fprintf(chaz_ConfWriterC.fh, "#ifndef %s\n", sym);
     }
     else {
@@ -231,7 +232,8 @@ chaz_ConfWriterC_add_global_typedef(const char *type, const char *alias) {
 
 static void
 chaz_ConfWriterC_append_global_typedef_to_conf(const char *type,
-        const char *alias) {
+                                               const char *alias) {
+    if (strcmp(type, alias) == 0) { return; }
     fprintf(chaz_ConfWriterC.fh, "typedef %s %s;\n", type, alias);
 }
 
@@ -260,32 +262,37 @@ chaz_ConfWriterC_append_local_include_to_conf(const char *header) {
 static void
 chaz_ConfWriterC_start_module(const char *module_name) {
     fprintf(chaz_ConfWriterC.fh, "\n/* %s */\n", module_name);
+    chaz_ConfWriterC.MODULE_NAME
+        = chaz_ConfWriterC_uppercase_string(module_name);
 }
 
 static void
 chaz_ConfWriterC_end_module(void) {
+    size_t num_globals = 0;
     size_t i;
     chaz_ConfElem *defs = chaz_ConfWriterC.defs;
     for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
         switch (defs[i].type) {
+            case CHAZ_CONFELEM_GLOBAL_DEF:
+                ++num_globals;
+            /* fall through */
             case CHAZ_CONFELEM_DEF:
                 chaz_ConfWriterC_append_def_to_conf(defs[i].str1,
                                                     defs[i].str2);
                 break;
-            case CHAZ_CONFELEM_GLOBAL_DEF:
-                chaz_ConfWriterC_append_global_def_to_conf(defs[i].str1,
-                                                           defs[i].str2);
-                break;
+            case CHAZ_CONFELEM_GLOBAL_TYPEDEF: {
+                ++num_globals;
+                char *sym = chaz_ConfWriterC_uppercase_string(defs[i].str1);
+                chaz_ConfWriterC_append_def_to_conf(sym, defs[i].str2);
+                free(sym);
+            }
+            /* fall through */
             case CHAZ_CONFELEM_TYPEDEF:
                 chaz_ConfWriterC_append_typedef_to_conf(defs[i].str2,
                                                         defs[i].str1);
                 break;
-            case CHAZ_CONFELEM_GLOBAL_TYPEDEF:
-                chaz_ConfWriterC_append_global_typedef_to_conf(defs[i].str2,
-                                                               defs[i].str1);
-                break;
             case CHAZ_CONFELEM_SYS_INCLUDE:
-                chaz_ConfWriterC_append_sys_include_to_conf(defs[i].str1);
+                ++num_globals;
                 break;
             case CHAZ_CONFELEM_LOCAL_INCLUDE:
                 chaz_ConfWriterC_append_local_include_to_conf(defs[i].str1);
@@ -303,7 +310,7 @@ chaz_ConfWriterC_end_module(void) {
     );
     for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
         switch (defs[i].type) {
-            case CHAZ_CONFELEM_DEF: 
+            case CHAZ_CONFELEM_DEF:
             case CHAZ_CONFELEM_TYPEDEF:
                 {
                     const char *sym = defs[i].str1;
@@ -330,8 +337,41 @@ chaz_ConfWriterC_end_module(void) {
     }
 
     fprintf(chaz_ConfWriterC.fh, "#endif /* USE_SHORT_NAMES */\n");
+
+    /* Write out global definitions and system includes. */
+    if (num_globals) {
+        fprintf(chaz_ConfWriterC.fh, "\n#ifdef CHY_EMPLOY_%s\n\n",
+                chaz_ConfWriterC.MODULE_NAME);
+        for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
+            switch (defs[i].type) {
+                case CHAZ_CONFELEM_GLOBAL_DEF:
+                    chaz_ConfWriterC_append_global_def_to_conf(defs[i].str1,
+                                                               defs[i].str2);
+                    break;
+                case CHAZ_CONFELEM_GLOBAL_TYPEDEF:
+                    chaz_ConfWriterC_append_global_typedef_to_conf(
+                            defs[i].str2, defs[i].str1);
+                    break;
+                case CHAZ_CONFELEM_SYS_INCLUDE:
+                    chaz_ConfWriterC_append_sys_include_to_conf(defs[i].str1);
+                    break;
+                case CHAZ_CONFELEM_DEF:
+                case CHAZ_CONFELEM_TYPEDEF:
+                case CHAZ_CONFELEM_LOCAL_INCLUDE:
+                    /* no-op */
+                    break;
+                default:
+                    chaz_Util_die("Internal error: bad element type %d",
+                                  (int)defs[i].type);
+            }
+        }
+        fprintf(chaz_ConfWriterC.fh, "\n#endif /* EMPLOY_%s */\n",
+                chaz_ConfWriterC.MODULE_NAME);
+    }
+
     fprintf(chaz_ConfWriterC.fh, "\n");
 
+    free(chaz_ConfWriterC.MODULE_NAME);
     chaz_ConfWriterC_clear_def_list();
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/cf630fcf/charmonizer/src/Charmonizer/Probe/Booleans.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe/Booleans.c b/charmonizer/src/Charmonizer/Probe/Booleans.c
index 69ba35f..942e36b 100644
--- a/charmonizer/src/Charmonizer/Probe/Booleans.c
+++ b/charmonizer/src/Charmonizer/Probe/Booleans.c
@@ -30,7 +30,7 @@ chaz_Booleans_run(void) {
     }
     else {
         chaz_ConfWriter_append_conf(
-            "#ifndef __cplusplus\n"
+            "#if (defined(CHY_EMPLOY_BOOLEANS) && !defined(__cplusplus))\n"
             "  typedef int bool;\n"
             "  #ifndef true\n"
             "    #define true 1\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/cf630fcf/clownfish/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/clownfish/compiler/common/charmonizer.main b/clownfish/compiler/common/charmonizer.main
index 460dd7e..b08b7d1 100644
--- a/clownfish/compiler/common/charmonizer.main
+++ b/clownfish/compiler/common/charmonizer.main
@@ -255,12 +255,18 @@ int main(int argc, const char **argv) {
         S_add_compiler_flags(&args);
     }
 
+    /* Define stdint types in charmony.h. */
+    chaz_ConfWriter_append_conf("#define CHY_EMPLOY_INTEGERTYPES\n\n");
+
     /* Run probe modules. */
     chaz_BuildEnv_run();
     chaz_DirManip_run();
     chaz_Headers_run();
+    chaz_FuncMacro_run();
+    chaz_Booleans_run();
     chaz_Integers_run();
     chaz_Strings_run();
+    chaz_SymbolVisibility_run();
     chaz_UnusedVars_run();
 
     if (args.write_makefile) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/cf630fcf/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index 2959349..4dcaf94 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -31,6 +31,9 @@
 #include "CFCParcel.h"
 #include "CFCUtil.h"
 
+#define STRING(s)  #s
+#define XSTRING(s) STRING(s)
+
 struct CFCBindCore {
     CFCBase base;
     CFCHierarchy *hierarchy;
@@ -49,6 +52,15 @@ S_write_parcel_h(CFCBindCore *self);
 static void
 S_write_parcel_c(CFCBindCore *self);
 
+static char*
+S_charmony_defines();
+
+static char*
+S_charmony_stdbool_defines();
+
+char*
+S_charmony_stdint_defines();
+
 static const CFCMeta CFCBINDCORE_META = {
     "Clownfish::CFC::Binding::Core",
     sizeof(CFCBindCore),
@@ -119,6 +131,8 @@ S_write_parcel_h(CFCBindCore *self) {
     CFCHierarchy *hierarchy = self->hierarchy;
     CFCParcel    *parcel    = NULL;
 
+    char *charmony_defines = S_charmony_defines();
+
     // Declare object structs for all instantiable classes.
     // Obtain parcel prefix for use in bootstrap function name.
     char *typedefs = CFCUtil_strdup("");
@@ -160,6 +174,9 @@ S_write_parcel_h(CFCBindCore *self) {
         "#include <stdarg.h>\n"
         "#include <stddef.h>\n"
         "#include \"charmony.h\"\n"
+        "\n"
+        "%s"
+        "\n"
         "#include \"hostdefs.h\"\n"
         "\n"
         "#ifdef CFP_LUCY\n"
@@ -266,8 +283,8 @@ S_write_parcel_h(CFCBindCore *self) {
         "%s\n"
         "\n";
     char *file_content
-        = CFCUtil_sprintf(pattern, self->header, aliases, typedefs, PREFIX,
-                          prefix, prefix, self->footer);
+        = CFCUtil_sprintf(pattern, self->header, charmony_defines, aliases,
+                          typedefs, PREFIX, prefix, prefix, self->footer);
 
     // Unlink then write file.
     const char *inc_dest = CFCHierarchy_get_include_dest(hierarchy);
@@ -277,6 +294,7 @@ S_write_parcel_h(CFCBindCore *self) {
     CFCUtil_write_file(filepath, file_content, strlen(file_content));
     FREEMEM(filepath);
 
+    FREEMEM(charmony_defines);
     FREEMEM(aliases);
     FREEMEM(typedefs);
     FREEMEM(file_content);
@@ -458,4 +476,69 @@ CFCBindCore_write_callbacks_h(CFCBindCore *self) {
     FREEMEM(file_content);
 }
 
+static char*
+S_charmony_defines() {
+    char *stdbool_defs = S_charmony_stdbool_defines();
+    char *stdint_defs  = S_charmony_stdint_defines();
+
+    const char *pattern =
+        "#define CFISH_INLINE %s\n"
+        "#define CFISH_EXPORT %s\n"
+        "#define CFISH_IMPORT %s\n"
+        "\n"
+        "%s"
+        "%s";
+    char *defines
+        = CFCUtil_sprintf(pattern, XSTRING(CHY_INLINE), XSTRING(CHY_EXPORT),
+                          XSTRING(CHY_IMPORT), stdbool_defs, stdint_defs);
+
+    FREEMEM(stdbool_defs);
+    FREEMEM(stdint_defs);
+    return defines;
+}
+
+static char*
+S_charmony_stdbool_defines() {
+#ifdef CHY_HAS_STDBOOL_H
+    const char *defines = "#include <stdbool.h>\n";
+#else
+    const char *defines =
+        "#if (!defined(__cplusplus) && !defined(CFISH_HAS_STDBOOL))\n"
+        "  typedef int bool;\n"
+        "  #ifndef true\n"
+        "    #define true 1\n"
+        "  #endif\n"
+        "  #ifndef false\n"
+        "    #define false 0\n"
+        "  #endif\n"
+        "#endif\n";
+#endif
+
+    return CFCUtil_strdup(defines);
+}
+
+char*
+S_charmony_stdint_defines() {
+#ifdef CHY_HAS_STDINT_H
+    return CFCUtil_strdup("#include <stdint.h>\n");
+#else
+    const char *pattern =
+        "#ifndef CFISH_HAS_STDINT\n"
+        "  typedef %s int8_t;\n"
+        "  typedef %s uint8_t;\n"
+        "  typedef %s int16_t;\n"
+        "  typedef %s uint16_t;\n"
+        "  typedef %s int32_t;\n"
+        "  typedef %s uint32_t;\n"
+        "  typedef %s int64_t;\n"
+        "  typedef %s uint64_t;\n"
+        "#endif\n";
+    return CFCUtil_sprintf(pattern,
+                           XSTRING(CHY_INT8_T),  XSTRING(CHY_UINT8_T),
+                           XSTRING(CHY_INT16_T), XSTRING(CHY_UINT16_T),
+                           XSTRING(CHY_INT32_T), XSTRING(CHY_UINT32_T),
+                           XSTRING(CHY_INT64_T), XSTRING(CHY_UINT64_T));
+#endif
+}
+
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/cf630fcf/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/common/charmonizer.main b/common/charmonizer.main
index e357203..a685a54 100644
--- a/common/charmonizer.main
+++ b/common/charmonizer.main
@@ -426,6 +426,13 @@ int main(int argc, const char **argv) {
         }
     }
 
+    /* Employ integer features but don't define stdint types in charmony.h. */
+    chaz_ConfWriter_append_conf(
+        "#define CHY_EMPLOY_INTEGERLIMITS\n"
+        "#define CHY_EMPLOY_INTEGERLITERALS\n"
+        "#define CHY_EMPLOY_INTEGERFORMATSTRINGS\n\n"
+    );
+
     /* Run probe modules. */
     chaz_BuildEnv_run();
     chaz_DirManip_run();

http://git-wip-us.apache.org/repos/asf/lucy/blob/cf630fcf/devel/bin/regen_charmonizer.pl
----------------------------------------------------------------------
diff --git a/devel/bin/regen_charmonizer.pl b/devel/bin/regen_charmonizer.pl
index 6f550cb..1fda312 100755
--- a/devel/bin/regen_charmonizer.pl
+++ b/devel/bin/regen_charmonizer.pl
@@ -29,7 +29,10 @@ my $MELD_EXE = catfile( $CHAZ_DIR, 'buildbin', 'meld.pl' );
 
 # Clownfish compiler.
 {
-    my $probes = "BuildEnv,DirManip,Headers,Integers,Strings,UnusedVars";
+    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;
     $out =~ s/\.main/.c/ or die "no match";


[lucy-commits] [03/15] git commit: refs/heads/install-c-library - Add CFISH_VISIBLE alias

Posted by nw...@apache.org.
Add CFISH_VISIBLE alias


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

Branch: refs/heads/install-c-library
Commit: f2fc2302c567f9b01d97dd1bf383388518ca37c1
Parents: 3c8a631
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 01:01:56 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 13:12:47 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCBindAliases.c |    2 ++
 clownfish/compiler/src/CFCBindCore.c    |    4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/f2fc2302/clownfish/compiler/src/CFCBindAliases.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindAliases.c b/clownfish/compiler/src/CFCBindAliases.c
index 09a1c84..9eda959 100644
--- a/clownfish/compiler/src/CFCBindAliases.c
+++ b/clownfish/compiler/src/CFCBindAliases.c
@@ -24,6 +24,8 @@ struct alias {
 };
 
 struct alias aliases[] = {
+    {"CFISH_VISIBLE", "LUCY_VISIBLE"},
+
     {"cfish_Obj", "lucy_Obj"},
     {"CFISH_OBJ", "LUCY_OBJ"},
     {"Cfish_Obj_Dump", "Lucy_Obj_Dump"},

http://git-wip-us.apache.org/repos/asf/lucy/blob/f2fc2302/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index 642569b..eff20eb 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -206,7 +206,7 @@ S_write_parcel_h(CFCBindCore *self) {
         "     ((_full_meth ## _t)cfish_super_method(_vtable, \\\n"
         "                                           _full_meth ## _OFFSET))\n"
         "\n"
-        "extern %sVISIBLE size_t cfish_VTable_offset_of_parent;\n"
+        "extern CFISH_VISIBLE size_t cfish_VTable_offset_of_parent;\n"
         "static CHY_INLINE cfish_method_t\n"
         "cfish_super_method(const void *vtable, size_t offset) {\n"
         "    char *vt_as_char = (char*)vtable;\n"
@@ -266,7 +266,7 @@ S_write_parcel_h(CFCBindCore *self) {
         "\n";
     char *file_content
         = CFCUtil_sprintf(pattern, self->header, aliases, typedefs, PREFIX,
-                          PREFIX, prefix, prefix, self->footer);
+                          prefix, prefix, self->footer);
 
     // Unlink then write file.
     const char *inc_dest = CFCHierarchy_get_include_dest(hierarchy);


[lucy-commits] [14/15] git commit: refs/heads/install-c-library - Allow NULL target in Doc#Extract

Posted by nw...@apache.org.
Allow NULL target in Doc#Extract

Something like a simple Doc#Fetch method might be useful for the C
library.


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

Branch: refs/heads/install-c-library
Commit: acb55b73d7694587d8dfb3e4566323c0b5164097
Parents: 174f42b
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 21:18:13 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 21:18:13 2013 +0200

----------------------------------------------------------------------
 c/src/Lucy/Document/Doc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/acb55b73/c/src/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Document/Doc.c b/c/src/Lucy/Document/Doc.c
index 8e898ec..8b44af2 100644
--- a/c/src/Lucy/Document/Doc.c
+++ b/c/src/Lucy/Document/Doc.c
@@ -83,7 +83,7 @@ Doc_extract(Doc *self, CharBuf *field,
     Hash *hash = (Hash *)self->fields;
     Obj  *obj  = Hash_Fetch(hash, (Obj *)field);
 
-    if (obj && Obj_Is_A(obj, CHARBUF)) {
+    if (target && obj && Obj_Is_A(obj, CHARBUF)) {
         ViewCB_Assign(target, (CharBuf *)obj);
     }
 


[lucy-commits] [12/15] git commit: refs/heads/install-c-library - Don't include charmony.h in external code

Posted by nw...@apache.org.
Don't include charmony.h in external code

The public header files don't depend on charmony.h anymore. We still
include charmony.h if CFP_LUCY is defined, but this is only for
convenience. The include could be moved to the C source files now.


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

Branch: refs/heads/install-c-library
Commit: b37b804e12d063726308b600dfffa9ab45a86cea
Parents: 4d99bca
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 12:53:35 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 19:15:56 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCBindCore.c |    2 +-
 common/charmonizer.c                 |    1 -
 common/charmonizer.main              |    1 -
 3 files changed, 1 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/b37b804e/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index cd2aed8..2f179ec 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -173,13 +173,13 @@ S_write_parcel_h(CFCBindCore *self) {
         "\n"
         "#include <stdarg.h>\n"
         "#include <stddef.h>\n"
-        "#include \"charmony.h\"\n"
         "\n"
         "%s"
         "\n"
         "#include \"hostdefs.h\"\n"
         "\n"
         "#ifdef CFP_LUCY\n"
+        "  #include \"charmony.h\"\n"
         "  #define LUCY_VISIBLE CFISH_EXPORT\n"
         "#else\n"
         "  #define LUCY_VISIBLE CFISH_IMPORT\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/b37b804e/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/common/charmonizer.c b/common/charmonizer.c
index d3d0048..82c3421 100644
--- a/common/charmonizer.c
+++ b/common/charmonizer.c
@@ -7025,7 +7025,6 @@ S_write_makefile(struct chaz_CLIArgs *args) {
 
     test_cflags = chaz_CC_new_cflags();
     chaz_CFlags_enable_optimization(test_cflags);
-    chaz_CFlags_add_include_dir(test_cflags, ".");
     chaz_CFlags_add_include_dir(test_cflags, autogen_inc_dir);
     chaz_CFlags_add_library(test_cflags, lib);
     scratch = chaz_Util_join(dir_sep, "t", "test_lucy.c", NULL);

http://git-wip-us.apache.org/repos/asf/lucy/blob/b37b804e/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/common/charmonizer.main b/common/charmonizer.main
index a685a54..99a28c3 100644
--- a/common/charmonizer.main
+++ b/common/charmonizer.main
@@ -313,7 +313,6 @@ S_write_makefile(struct chaz_CLIArgs *args) {
 
     test_cflags = chaz_CC_new_cflags();
     chaz_CFlags_enable_optimization(test_cflags);
-    chaz_CFlags_add_include_dir(test_cflags, ".");
     chaz_CFlags_add_include_dir(test_cflags, autogen_inc_dir);
     chaz_CFlags_add_library(test_cflags, lib);
     scratch = chaz_Util_join(dir_sep, "t", "test_lucy.c", NULL);


[lucy-commits] [08/15] git commit: refs/heads/install-c-library - Switch from CHY_INLINE to CFISH_INLINE

Posted by nw...@apache.org.
Switch from CHY_INLINE to CFISH_INLINE


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

Branch: refs/heads/install-c-library
Commit: 7c9638ebc0d05fedcf9356af76c2054849ef3767
Parents: e7cdce4
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 12:38:40 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 19:15:55 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCBindCore.c     |    6 ++--
 clownfish/compiler/src/CFCBindFunction.c |    2 +-
 clownfish/compiler/src/CFCBindMethod.c   |    2 +-
 clownfish/compiler/src/CFCCBlock.h       |    2 +-
 clownfish/compiler/src/CFCPerl.c         |    2 +-
 core/Clownfish/Err.cfh                   |    2 +-
 core/Clownfish/Obj.cfh                   |    6 ++--
 core/Clownfish/Util/Atomic.cfh           |   12 +++---
 core/Clownfish/Util/NumberUtils.cfh      |   48 ++++++++++++------------
 core/Lucy/Plan/FieldType.cfh             |    2 +-
 perl/xs/XSBind.h                         |    6 ++--
 11 files changed, 45 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index 4dcaf94..392a5ff 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -198,7 +198,7 @@ S_write_parcel_h(CFCBindCore *self) {
         "#define CFISH_METHOD_PTR(_vtable, _full_meth) \\\n"
         "     ((_full_meth ## _t)cfish_method(_vtable, _full_meth ## _OFFSET))\n"
         "\n"
-        "static CHY_INLINE cfish_method_t\n"
+        "static CFISH_INLINE cfish_method_t\n"
         "cfish_method(const void *vtable, size_t offset) {\n"
         "    union { char *cptr; cfish_method_t *fptr; } ptr;\n"
         "    ptr.cptr = (char*)vtable + offset;\n"
@@ -212,7 +212,7 @@ S_write_parcel_h(CFCBindCore *self) {
         "\n"
         "/* Access the function pointer for a given method from the object.\n"
         " */\n"
-        "static CHY_INLINE cfish_method_t\n"
+        "static CFISH_INLINE cfish_method_t\n"
         "cfish_obj_method(const void *object, size_t offset) {\n"
         "    cfish_Dummy *dummy = (cfish_Dummy*)object;\n"
         "    return cfish_method(dummy->vtable, offset);\n"
@@ -225,7 +225,7 @@ S_write_parcel_h(CFCBindCore *self) {
         "                                           _full_meth ## _OFFSET))\n"
         "\n"
         "extern CFISH_VISIBLE size_t cfish_VTable_offset_of_parent;\n"
-        "static CHY_INLINE cfish_method_t\n"
+        "static CFISH_INLINE cfish_method_t\n"
         "cfish_super_method(const void *vtable, size_t offset) {\n"
         "    char *vt_as_char = (char*)vtable;\n"
         "    cfish_VTable **parent_ptr\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/clownfish/compiler/src/CFCBindFunction.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindFunction.c b/clownfish/compiler/src/CFCBindFunction.c
index 2e3ea00..ae71d84 100644
--- a/clownfish/compiler/src/CFCBindFunction.c
+++ b/clownfish/compiler/src/CFCBindFunction.c
@@ -30,7 +30,7 @@ CFCBindFunc_func_declaration(CFCFunction *func) {
     const char   *full_func_sym  = CFCFunction_full_func_sym(func);
     const char   *param_list_str = CFCParamList_to_c(param_list);
     const char   *inline_prop    = CFCFunction_inline(func)
-                                   ? "static CHY_INLINE "
+                                   ? "static CFISH_INLINE "
                                    : "";
     char *buf = CFCUtil_sprintf("%s%s\n%s(%s);", inline_prop, ret_type_str,
                                 full_func_sym, param_list_str);

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/clownfish/compiler/src/CFCBindMethod.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindMethod.c b/clownfish/compiler/src/CFCBindMethod.c
index 5832e90..996192a 100644
--- a/clownfish/compiler/src/CFCBindMethod.c
+++ b/clownfish/compiler/src/CFCBindMethod.c
@@ -113,7 +113,7 @@ S_virtual_method_def(CFCMethod *method, CFCClass *klass) {
 
     const char pattern[] =
         "extern %sVISIBLE size_t %s;\n"
-        "static CHY_INLINE %s\n"
+        "static CFISH_INLINE %s\n"
         "%s(const %s *self%s) {\n"
         "    const %s method = (%s)cfish_obj_method(self, %s);\n"
         "    %smethod((%s*)self%s);\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/clownfish/compiler/src/CFCCBlock.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCCBlock.h b/clownfish/compiler/src/CFCCBlock.h
index 9bb0d46..98ac4d9 100644
--- a/clownfish/compiler/src/CFCCBlock.h
+++ b/clownfish/compiler/src/CFCCBlock.h
@@ -28,7 +28,7 @@
  *
  *     __C__
  *     #include <stdio.h>
- *     static CHY_INLINE void
+ *     static CFISH_INLINE void
  *     crust_Lobster_say_hello(crust_Lobster *self)
  *     {
  *         printf("Prepare to die, human scum.\n");

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/clownfish/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerl.c b/clownfish/compiler/src/CFCPerl.c
index 419799f..a2634de 100644
--- a/clownfish/compiler/src/CFCPerl.c
+++ b/clownfish/compiler/src/CFCPerl.c
@@ -516,7 +516,7 @@ S_write_callbacks_c(CFCPerl *self) {
         "    LEAVE;\n"
         "}\n"
         "\n"
-        "static CHY_INLINE SV*\n"
+        "static CFISH_INLINE SV*\n"
         "SI_do_callback_sv(const char *meth_name) {\n"
         "    int count = call_method(meth_name, G_SCALAR);\n"
         "    if (count != 1) {\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/core/Clownfish/Err.cfh
----------------------------------------------------------------------
diff --git a/core/Clownfish/Err.cfh b/core/Clownfish/Err.cfh
index 558c710..777aab2 100644
--- a/core/Clownfish/Err.cfh
+++ b/core/Clownfish/Err.cfh
@@ -228,7 +228,7 @@ __C__
     lucy_Err_certify((lucy_Obj*)(_obj), (_vtable), \
                      __FILE__, __LINE__, CFISH_ERR_FUNC_MACRO)
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_Err_abstract_class_check(lucy_Obj *obj, lucy_VTable *vtable) {
     lucy_VTable *const my_vtable = (lucy_VTable*)((cfish_Dummy*)obj)->vtable;
     if (my_vtable == vtable) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/core/Clownfish/Obj.cfh
----------------------------------------------------------------------
diff --git a/core/Clownfish/Obj.cfh b/core/Clownfish/Obj.cfh
index de6c928..a801b48 100644
--- a/core/Clownfish/Obj.cfh
+++ b/core/Clownfish/Obj.cfh
@@ -187,7 +187,7 @@ public class Clownfish::Obj {
 }
 
 __C__
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_Obj_super_destroy(lucy_Obj *self, lucy_VTable *vtable) {
     Lucy_Obj_Destroy_t super_destroy
         = CFISH_SUPER_METHOD_PTR(vtable, Lucy_Obj_Destroy);
@@ -197,7 +197,7 @@ lucy_Obj_super_destroy(lucy_Obj *self, lucy_VTable *vtable) {
 #define LUCY_SUPER_DESTROY(_self, _vtable) \
     lucy_Obj_super_destroy((lucy_Obj*)_self, _vtable)
 
-static CHY_INLINE lucy_Obj*
+static CFISH_INLINE lucy_Obj*
 lucy_Obj_incref(lucy_Obj *self) {
     if (self != NULL) { return Lucy_Obj_Inc_RefCount(self); }
     else { return NULL; }
@@ -205,7 +205,7 @@ lucy_Obj_incref(lucy_Obj *self) {
 
 #define CFISH_INCREF(_self) lucy_Obj_incref((lucy_Obj*)_self)
 
-static CHY_INLINE uint32_t
+static CFISH_INLINE uint32_t
 lucy_Obj_decref(lucy_Obj *self) {
     if (self != NULL) { return Lucy_Obj_Dec_RefCount(self); }
     else { return 0; }

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/core/Clownfish/Util/Atomic.cfh
----------------------------------------------------------------------
diff --git a/core/Clownfish/Util/Atomic.cfh b/core/Clownfish/Util/Atomic.cfh
index 774f5a9..91d3d6b 100644
--- a/core/Clownfish/Util/Atomic.cfh
+++ b/core/Clownfish/Util/Atomic.cfh
@@ -26,13 +26,13 @@ __C__
  * matches <code>old_value</code>.  If it does, set <code>target</code> to
  * <code>new_value</code> and return true.  Otherwise, return false.
  */
-static CHY_INLINE bool
+static CFISH_INLINE bool
 lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value);
 
 /************************** Single threaded *******************************/
 #ifdef LUCY_NOTHREADS
 
-static CHY_INLINE bool
+static CFISH_INLINE bool
 lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
     if (*target == old_value) {
         *target = new_value;
@@ -47,7 +47,7 @@ lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
 #elif defined(CHY_HAS_OSATOMIC_CAS_PTR)
 #include <libkern/OSAtomic.h>
 
-static CHY_INLINE bool
+static CFISH_INLINE bool
 lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
     return OSAtomicCompareAndSwapPtr(old_value, new_value, target);
 }
@@ -59,7 +59,7 @@ bool
 lucy_Atomic_wrapped_cas_ptr(void *volatile *target, void *old_value,
                             void *new_value);
 
-static CHY_INLINE bool
+static CFISH_INLINE bool
 lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
     return lucy_Atomic_wrapped_cas_ptr(target, old_value, new_value);
 }
@@ -68,7 +68,7 @@ lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
 #elif defined(CHY_HAS_SYS_ATOMIC_H)
 #include <sys/atomic.h>
 
-static CHY_INLINE bool
+static CFISH_INLINE bool
 lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
     return atomic_cas_ptr(target, old_value, new_value) == old_value;
 }
@@ -79,7 +79,7 @@ lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
 
 extern pthread_mutex_t lucy_Atomic_mutex;
 
-static CHY_INLINE bool
+static CFISH_INLINE bool
 lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
     pthread_mutex_lock(&lucy_Atomic_mutex);
     if (*target == old_value) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/core/Clownfish/Util/NumberUtils.cfh
----------------------------------------------------------------------
diff --git a/core/Clownfish/Util/NumberUtils.cfh b/core/Clownfish/Util/NumberUtils.cfh
index 14b699b..11a5afd 100644
--- a/core/Clownfish/Util/NumberUtils.cfh
+++ b/core/Clownfish/Util/NumberUtils.cfh
@@ -180,7 +180,7 @@ __C__
 
 #include <string.h>
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_encode_bigend_u16(uint16_t value, void *dest_ptr) {
     uint8_t *dest = *(uint8_t**)dest_ptr;
 #ifdef CHY_BIG_END
@@ -192,7 +192,7 @@ lucy_NumUtil_encode_bigend_u16(uint16_t value, void *dest_ptr) {
 #endif // CHY_BIG_END (and little endian)
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_encode_bigend_u32(uint32_t value, void *dest_ptr) {
     uint8_t *dest = *(uint8_t**)dest_ptr;
 #ifdef CHY_BIG_END
@@ -206,7 +206,7 @@ lucy_NumUtil_encode_bigend_u32(uint32_t value, void *dest_ptr) {
 #endif // CHY_BIG_END (and little endian)
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_encode_bigend_u64(uint64_t value, void *dest_ptr) {
     uint8_t *dest = *(uint8_t**)dest_ptr;
 #ifdef CHY_BIG_END
@@ -224,14 +224,14 @@ lucy_NumUtil_encode_bigend_u64(uint64_t value, void *dest_ptr) {
 #endif // CHY_BIG_END (and little endian)
 }
 
-static CHY_INLINE uint16_t
+static CFISH_INLINE uint16_t
 lucy_NumUtil_decode_bigend_u16(void *source) {
     uint8_t *const buf = (uint8_t*)source;
     return  (buf[0] << 8) |
             (buf[1]);
 }
 
-static CHY_INLINE uint32_t
+static CFISH_INLINE uint32_t
 lucy_NumUtil_decode_bigend_u32(void *source) {
     uint8_t *const buf = (uint8_t*)source;
     return  (buf[0]  << 24) |
@@ -240,7 +240,7 @@ lucy_NumUtil_decode_bigend_u32(void *source) {
             (buf[3]);
 }
 
-static CHY_INLINE uint64_t
+static CFISH_INLINE uint64_t
 lucy_NumUtil_decode_bigend_u64(void *source) {
     uint8_t *const buf = (uint8_t*)source;
     uint64_t high_bits = (buf[0]  << 24) |
@@ -256,7 +256,7 @@ lucy_NumUtil_decode_bigend_u64(void *source) {
     return retval;
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_encode_bigend_f32(float value, void *dest_ptr) {
     uint8_t *dest = *(uint8_t**)dest_ptr;
 #ifdef CHY_BIG_END
@@ -268,7 +268,7 @@ lucy_NumUtil_encode_bigend_f32(float value, void *dest_ptr) {
 #endif
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_encode_bigend_f64(double value, void *dest_ptr) {
     uint8_t *dest = *(uint8_t**)dest_ptr;
 #ifdef CHY_BIG_END
@@ -280,7 +280,7 @@ lucy_NumUtil_encode_bigend_f64(double value, void *dest_ptr) {
 #endif
 }
 
-static CHY_INLINE float
+static CFISH_INLINE float
 lucy_NumUtil_decode_bigend_f32(void *source) {
     union { float f; uint32_t u32; } duo;
     memcpy(&duo, source, sizeof(float));
@@ -290,7 +290,7 @@ lucy_NumUtil_decode_bigend_f32(void *source) {
     return duo.f;
 }
 
-static CHY_INLINE double
+static CFISH_INLINE double
 lucy_NumUtil_decode_bigend_f64(void *source) {
     union { double d; uint64_t u64; } duo;
     memcpy(&duo, source, sizeof(double));
@@ -303,7 +303,7 @@ lucy_NumUtil_decode_bigend_f64(void *source) {
 #define LUCY_NUMUTIL_C32_MAX_BYTES  ((sizeof(uint32_t) * 8 / 7) + 1) // 5
 #define LUCY_NUMUTIL_C64_MAX_BYTES ((sizeof(uint64_t) * 8 / 7) + 1)  // 10
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_encode_c32(uint32_t value, char **out_buf) {
     uint8_t   buf[LUCY_NUMUTIL_C32_MAX_BYTES];
     uint8_t  *const limit = buf + sizeof(buf);
@@ -322,7 +322,7 @@ lucy_NumUtil_encode_c32(uint32_t value, char **out_buf) {
     *out_buf += num_bytes;
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_encode_c64(uint64_t value, char **out_buf) {
     uint8_t   buf[LUCY_NUMUTIL_C64_MAX_BYTES];
     uint8_t  *const limit = buf + sizeof(buf);
@@ -341,7 +341,7 @@ lucy_NumUtil_encode_c64(uint64_t value, char **out_buf) {
     *out_buf += num_bytes;
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_encode_padded_c32(uint32_t value, char **out_buf) {
     uint8_t buf[LUCY_NUMUTIL_C32_MAX_BYTES]
         = { 0x80, 0x80, 0x80, 0x80, 0x80 };
@@ -368,7 +368,7 @@ lucy_NumUtil_encode_padded_c32(uint32_t value, char **out_buf) {
         }  \
     } while (0)
 
-static CHY_INLINE uint32_t
+static CFISH_INLINE uint32_t
 lucy_NumUtil_decode_c32(char **source_ptr) {
     char *source = *source_ptr;
     uint32_t decoded;
@@ -377,7 +377,7 @@ lucy_NumUtil_decode_c32(char **source_ptr) {
     return decoded;
 }
 
-static CHY_INLINE uint64_t
+static CFISH_INLINE uint64_t
 lucy_NumUtil_decode_c64(char **source_ptr) {
     char *source = *source_ptr;
     uint64_t decoded;
@@ -386,14 +386,14 @@ lucy_NumUtil_decode_c64(char **source_ptr) {
     return decoded;
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_skip_cint(char **source_ptr) {
     uint8_t *ptr = *(uint8_t**)source_ptr;
     while ((*ptr++ & 0x80) != 0) { }
     *source_ptr = (char*)ptr;
 }
 
-static CHY_INLINE bool
+static CFISH_INLINE bool
 lucy_NumUtil_u1get(void *array, uint32_t tick) {
     uint8_t *const u8bits      = (uint8_t*)array;
     const uint32_t byte_offset = tick >> 3;
@@ -401,7 +401,7 @@ lucy_NumUtil_u1get(void *array, uint32_t tick) {
     return !((u8bits[byte_offset] & mask) == 0);
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_u1set(void *array, uint32_t tick) {
     uint8_t *const u8bits      = (uint8_t*)array;
     const uint32_t byte_offset = tick >> 3;
@@ -409,7 +409,7 @@ lucy_NumUtil_u1set(void *array, uint32_t tick) {
     u8bits[byte_offset] |= mask;
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_u1clear(void *array, uint32_t tick) {
     uint8_t *const u8bits      = (uint8_t*)array;
     const uint32_t byte_offset = tick >> 3;
@@ -417,7 +417,7 @@ lucy_NumUtil_u1clear(void *array, uint32_t tick) {
     u8bits[byte_offset] &= ~mask;
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_u1flip(void *array, uint32_t tick) {
     uint8_t *const u8bits      = (uint8_t*)array;
     const uint32_t byte_offset = tick >> 3;
@@ -425,7 +425,7 @@ lucy_NumUtil_u1flip(void *array, uint32_t tick) {
     u8bits[byte_offset] ^= mask;
 }
 
-static CHY_INLINE uint8_t
+static CFISH_INLINE uint8_t
 lucy_NumUtil_u2get(void *array, uint32_t tick) {
     uint8_t *ints  = (uint8_t*)array;
     uint8_t  byte  = ints[(tick >> 2)];
@@ -433,7 +433,7 @@ lucy_NumUtil_u2get(void *array, uint32_t tick) {
     return (byte >> shift) & 0x3;
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_u2set(void *array, uint32_t tick, uint8_t value) {
     uint8_t *ints     = (uint8_t*)array;
     unsigned sub_tick = tick & 0x3;
@@ -445,7 +445,7 @@ lucy_NumUtil_u2set(void *array, uint32_t tick, uint8_t value) {
 }
 
 
-static CHY_INLINE uint8_t
+static CFISH_INLINE uint8_t
 lucy_NumUtil_u4get(void *array, uint32_t tick) {
     uint8_t *ints  = (uint8_t*)array;
     uint8_t  byte  = ints[(tick >> 1)];
@@ -453,7 +453,7 @@ lucy_NumUtil_u4get(void *array, uint32_t tick) {
     return (byte >> shift) & 0xF;
 }
 
-static CHY_INLINE void
+static CFISH_INLINE void
 lucy_NumUtil_u4set(void *array, uint32_t tick, uint8_t value) {
     uint8_t  *ints     = (uint8_t*)array;
     unsigned  sub_tick = tick & 0x1;

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/core/Lucy/Plan/FieldType.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/FieldType.cfh b/core/Lucy/Plan/FieldType.cfh
index 6e86904..7f3df32 100644
--- a/core/Lucy/Plan/FieldType.cfh
+++ b/core/Lucy/Plan/FieldType.cfh
@@ -167,7 +167,7 @@ public abstract class Lucy::Plan::FieldType cnick FType
 
 __C__
 
-static CHY_INLINE int32_t
+static CFISH_INLINE int32_t
 lucy_FType_null_back_compare_values(lucy_FieldType *self,
                                     lucy_Obj *a, lucy_Obj *b) {
     if (a == NULL) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c9638eb/perl/xs/XSBind.h
----------------------------------------------------------------------
diff --git a/perl/xs/XSBind.h b/perl/xs/XSBind.h
index 347f5c0..8d6e0ba 100644
--- a/perl/xs/XSBind.h
+++ b/perl/xs/XSBind.h
@@ -50,7 +50,7 @@ cfish_XSBind_new_blank_obj(SV *either_sv);
 /** Test whether an SV is defined.  Handles "get" magic, unlike SvOK on its
  * own.
  */
-static CHY_INLINE bool
+static CFISH_INLINE bool
 cfish_XSBind_sv_defined(SV *sv) {
     if (!sv || !SvANY(sv)) { return false; }
     if (SvGMAGICAL(sv)) { mg_get(sv); }
@@ -81,7 +81,7 @@ cfish_XSBind_maybe_sv_to_cfish_obj(SV *sv, cfish_VTable *vtable,
  * The new SV has single refcount for which the caller must take
  * responsibility.
  */
-static CHY_INLINE SV*
+static CFISH_INLINE SV*
 cfish_XSBind_cfish_obj_to_sv(cfish_Obj *obj) {
     return obj ? (SV*)Cfish_Obj_To_Host(obj) : newSV(0);
 }
@@ -94,7 +94,7 @@ cfish_XSBind_cfish_obj_to_sv(cfish_Obj *obj) {
  * after creating the SV. This is useful when the Clownfish expression creates a new
  * refcount, e.g.  a call to a constructor.
  */
-static CHY_INLINE SV*
+static CFISH_INLINE SV*
 cfish_XSBind_cfish_obj_to_sv_noinc(cfish_Obj *obj) {
     SV *retval;
     if (obj) {


[lucy-commits] [04/15] git commit: refs/heads/install-c-library - Don't include charmony.h in class headers

Posted by nw...@apache.org.
Don't include charmony.h in class headers

It's already included via parcel.h.


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

Branch: refs/heads/install-c-library
Commit: 3c8a6317afde6f1479f8c143234ebbf6386948b3
Parents: 6716917
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri May 17 23:43:56 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 13:12:47 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCBindClass.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/3c8a6317/clownfish/compiler/src/CFCBindClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindClass.c b/clownfish/compiler/src/CFCBindClass.c
index e483530..f83a5c1 100644
--- a/clownfish/compiler/src/CFCBindClass.c
+++ b/clownfish/compiler/src/CFCBindClass.c
@@ -125,7 +125,6 @@ S_to_c_header_inert(CFCBindClass *self) {
     char *short_names     = S_short_names(self);
 
     char pattern[] =
-        "#include \"charmony.h\"\n"
         "#include \"%sparcel.h\"\n"
         "\n"
         "/* Declare this class's inert variables.\n"
@@ -167,7 +166,6 @@ S_to_c_header_dynamic(CFCBindClass *self) {
     char *short_names           = S_short_names(self);
 
     char pattern[] =
-        "#include \"charmony.h\"\n"
         "#include \"%sparcel.h\"\n"
         "\n"
         "/* Include the header for this class's parent. \n"


[lucy-commits] [09/15] git commit: refs/heads/install-c-library - Regenerate charmonizer.c

Posted by nw...@apache.org.
Regenerate charmonizer.c


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

Branch: refs/heads/install-c-library
Commit: e7cdce42b6d5ad011f3192d9bbd3727541dd7775
Parents: cf630fc
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 12:28:05 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 19:15:55 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/common/charmonizer.c |  698 +++++++++++++++++++++-----
 clownfish/runtime/common/charmonizer.c  |  405 ++++++++++------
 common/charmonizer.c                    |  412 ++++++++++------
 3 files changed, 1089 insertions(+), 426 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/e7cdce42/clownfish/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/common/charmonizer.c b/clownfish/compiler/common/charmonizer.c
index 3d02760..f89aebe 100644
--- a/clownfish/compiler/common/charmonizer.c
+++ b/clownfish/compiler/common/charmonizer.c
@@ -936,6 +936,36 @@ chaz_Probe_msvc_version_num(void);
 
 /***************************************************************************/
 
+#line 21 "src/Charmonizer/Probe/Booleans.h"
+/* Charmonizer/Probe/Booleans.h -- bool type.
+ *
+ * If stdbool.h is is available, it will be pound-included in the configuration
+ * header.  If it is not, the following typedef will be defined:
+ *
+ * bool
+ *
+ * These symbols will be defined if they are not already:
+ *
+ * true
+ * false
+ */
+
+#ifndef H_CHAZ_BOOLEANS
+#define H_CHAZ_BOOLEANS
+
+#include <stdio.h>
+
+/* Run the Booleans module.
+ */
+void chaz_Booleans_run(void);
+
+#endif /* H_CHAZ_BOOLEANS */
+
+
+
+
+/***************************************************************************/
+
 #line 21 "src/Charmonizer/Probe/BuildEnv.h"
 /* Charmonizer/Probe/BuildEnv.h -- Build environment.
  *
@@ -1013,6 +1043,45 @@ void chaz_DirManip_run(void);
 
 /***************************************************************************/
 
+#line 21 "src/Charmonizer/Probe/FuncMacro.h"
+/* Charmonizer/Probe/FuncMacro.h
+ */
+
+#ifndef H_CHAZ_FUNC_MACRO
+#define H_CHAZ_FUNC_MACRO
+
+#include <stdio.h>
+
+/* Run the FuncMacro module.
+ *
+ * If __func__ successfully resolves, this will be defined:
+ *
+ * HAS_ISO_FUNC_MACRO
+ *
+ * If __FUNCTION__ successfully resolves, this will be defined:
+ *
+ * HAS_GNUC_FUNC_MACRO
+ *
+ * If one or the other succeeds, these will be defined:
+ *
+ * HAS_FUNC_MACRO
+ * FUNC_MACRO
+ *
+ * The "inline" keyword will also be probed for.  If it is available, the
+ * following macro will be defined to "inline", otherwise it will be defined
+ * to nothing.
+ *
+ * INLINE
+ */
+void chaz_FuncMacro_run(void);
+
+#endif /* H_CHAZ_FUNC_MACRO */
+
+
+
+
+/***************************************************************************/
+
 #line 20 "src/Charmonizer/Probe/Headers.h"
 /* Charmonizer/Probe/Headers.h
  */
@@ -1210,6 +1279,22 @@ void chaz_Strings_run(void);
 
 /***************************************************************************/
 
+#line 21 "src/Charmonizer/Probe/SymbolVisibility.h"
+/* Charmonizer/Probe/SymbolVisibility.h
+ */
+
+#ifndef H_CHAZ_SYMBOLVISIBILITY
+#define H_CHAZ_SYMBOLVISIBILITY
+
+void chaz_SymbolVisibility_run(void);
+
+#endif /* H_CHAZ_SYMBOLVISIBILITY */
+
+
+
+
+/***************************************************************************/
+
 #line 21 "src/Charmonizer/Probe/UnusedVars.h"
 /* Charmonizer/Probe/UnusedVars.h
  */
@@ -2177,6 +2262,7 @@ typedef struct chaz_ConfElem {
 /* Static vars. */
 static struct {
     FILE          *fh;
+    char          *MODULE_NAME;
     chaz_ConfElem *defs;
     size_t         def_cap;
     size_t         def_count;
@@ -2274,18 +2360,17 @@ chaz_ConfWriterC_vappend_conf(const char *fmt, va_list args) {
 
 static int
 chaz_ConfWriterC_sym_is_uppercase(const char *sym) {
-    unsigned i;
-    for (i = 0; sym[i] != 0; i++) {
-        if (!isupper(sym[i])) {
-            if (islower(sym[i])) {
-                return false;
-            }
-            else if (sym[i] != '_') {
-                return true;
-            }
-        }
+    return isupper(sym[0]);
+}
+
+static char*
+chaz_ConfWriterC_uppercase_string(const char *src) {
+    char *retval = chaz_Util_strdup(src);
+    size_t i;
+    for (i = 0; retval[i]; ++i) {
+        retval[i] = toupper(retval[i]);
     }
-    return true;
+    return retval;
 }
 
 static void
@@ -2320,9 +2405,10 @@ chaz_ConfWriterC_add_global_def(const char *sym, const char *value) {
 
 static void
 chaz_ConfWriterC_append_global_def_to_conf(const char *sym,
-        const char *value) {
+                                           const char *value) {
     char *name_end = strchr(sym, '(');
     if (name_end == NULL) {
+        if (strcmp(sym, value) == 0) { return; }
         fprintf(chaz_ConfWriterC.fh, "#ifndef %s\n", sym);
     }
     else {
@@ -2364,7 +2450,8 @@ chaz_ConfWriterC_add_global_typedef(const char *type, const char *alias) {
 
 static void
 chaz_ConfWriterC_append_global_typedef_to_conf(const char *type,
-        const char *alias) {
+                                               const char *alias) {
+    if (strcmp(type, alias) == 0) { return; }
     fprintf(chaz_ConfWriterC.fh, "typedef %s %s;\n", type, alias);
 }
 
@@ -2393,32 +2480,37 @@ chaz_ConfWriterC_append_local_include_to_conf(const char *header) {
 static void
 chaz_ConfWriterC_start_module(const char *module_name) {
     fprintf(chaz_ConfWriterC.fh, "\n/* %s */\n", module_name);
+    chaz_ConfWriterC.MODULE_NAME
+        = chaz_ConfWriterC_uppercase_string(module_name);
 }
 
 static void
 chaz_ConfWriterC_end_module(void) {
+    size_t num_globals = 0;
     size_t i;
     chaz_ConfElem *defs = chaz_ConfWriterC.defs;
     for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
         switch (defs[i].type) {
+            case CHAZ_CONFELEM_GLOBAL_DEF:
+                ++num_globals;
+            /* fall through */
             case CHAZ_CONFELEM_DEF:
                 chaz_ConfWriterC_append_def_to_conf(defs[i].str1,
                                                     defs[i].str2);
                 break;
-            case CHAZ_CONFELEM_GLOBAL_DEF:
-                chaz_ConfWriterC_append_global_def_to_conf(defs[i].str1,
-                                                           defs[i].str2);
-                break;
+            case CHAZ_CONFELEM_GLOBAL_TYPEDEF: {
+                ++num_globals;
+                char *sym = chaz_ConfWriterC_uppercase_string(defs[i].str1);
+                chaz_ConfWriterC_append_def_to_conf(sym, defs[i].str2);
+                free(sym);
+            }
+            /* fall through */
             case CHAZ_CONFELEM_TYPEDEF:
                 chaz_ConfWriterC_append_typedef_to_conf(defs[i].str2,
                                                         defs[i].str1);
                 break;
-            case CHAZ_CONFELEM_GLOBAL_TYPEDEF:
-                chaz_ConfWriterC_append_global_typedef_to_conf(defs[i].str2,
-                                                               defs[i].str1);
-                break;
             case CHAZ_CONFELEM_SYS_INCLUDE:
-                chaz_ConfWriterC_append_sys_include_to_conf(defs[i].str1);
+                ++num_globals;
                 break;
             case CHAZ_CONFELEM_LOCAL_INCLUDE:
                 chaz_ConfWriterC_append_local_include_to_conf(defs[i].str1);
@@ -2436,7 +2528,7 @@ chaz_ConfWriterC_end_module(void) {
     );
     for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
         switch (defs[i].type) {
-            case CHAZ_CONFELEM_DEF: 
+            case CHAZ_CONFELEM_DEF:
             case CHAZ_CONFELEM_TYPEDEF:
                 {
                     const char *sym = defs[i].str1;
@@ -2463,8 +2555,41 @@ chaz_ConfWriterC_end_module(void) {
     }
 
     fprintf(chaz_ConfWriterC.fh, "#endif /* USE_SHORT_NAMES */\n");
+
+    /* Write out global definitions and system includes. */
+    if (num_globals) {
+        fprintf(chaz_ConfWriterC.fh, "\n#ifdef CHY_EMPLOY_%s\n\n",
+                chaz_ConfWriterC.MODULE_NAME);
+        for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
+            switch (defs[i].type) {
+                case CHAZ_CONFELEM_GLOBAL_DEF:
+                    chaz_ConfWriterC_append_global_def_to_conf(defs[i].str1,
+                                                               defs[i].str2);
+                    break;
+                case CHAZ_CONFELEM_GLOBAL_TYPEDEF:
+                    chaz_ConfWriterC_append_global_typedef_to_conf(
+                            defs[i].str2, defs[i].str1);
+                    break;
+                case CHAZ_CONFELEM_SYS_INCLUDE:
+                    chaz_ConfWriterC_append_sys_include_to_conf(defs[i].str1);
+                    break;
+                case CHAZ_CONFELEM_DEF:
+                case CHAZ_CONFELEM_TYPEDEF:
+                case CHAZ_CONFELEM_LOCAL_INCLUDE:
+                    /* no-op */
+                    break;
+                default:
+                    chaz_Util_die("Internal error: bad element type %d",
+                                  (int)defs[i].type);
+            }
+        }
+        fprintf(chaz_ConfWriterC.fh, "\n#endif /* EMPLOY_%s */\n",
+                chaz_ConfWriterC.MODULE_NAME);
+    }
+
     fprintf(chaz_ConfWriterC.fh, "\n");
 
+    free(chaz_ConfWriterC.MODULE_NAME);
     chaz_ConfWriterC_clear_def_list();
 }
 
@@ -4454,6 +4579,41 @@ chaz_Probe_msvc_version_num(void) {
 
 /***************************************************************************/
 
+#line 17 "src/Charmonizer/Probe/Booleans.c"
+/* #include "Charmonizer/Core/HeaderChecker.h" */
+/* #include "Charmonizer/Core/ConfWriter.h" */
+/* #include "Charmonizer/Probe/Booleans.h" */
+
+void
+chaz_Booleans_run(void) {
+    int has_stdbool = chaz_HeadCheck_check_header("stdbool.h");
+
+    chaz_ConfWriter_start_module("Booleans");
+
+    if (has_stdbool) {
+        chaz_ConfWriter_add_def("HAS_STDBOOL_H", NULL);
+        chaz_ConfWriter_add_sys_include("stdbool.h");
+    }
+    else {
+        chaz_ConfWriter_append_conf(
+            "#if (defined(CHY_EMPLOY_BOOLEANS) && !defined(__cplusplus))\n"
+            "  typedef int bool;\n"
+            "  #ifndef true\n"
+            "    #define true 1\n"
+            "  #endif\n"
+            "  #ifndef false\n"
+            "    #define false 0\n"
+            "  #endif\n"
+            "#endif\n");
+    }
+
+    chaz_ConfWriter_end_module();
+}
+
+
+
+/***************************************************************************/
+
 #line 17 "src/Charmonizer/Probe/BuildEnv.c"
 /* #include "Charmonizer/Core/HeaderChecker.h" */
 /* #include "Charmonizer/Core/ConfWriter.h" */
@@ -4669,6 +4829,147 @@ chaz_DirManip_run(void) {
 
 /***************************************************************************/
 
+#line 17 "src/Charmonizer/Probe/FuncMacro.c"
+/* #include "Charmonizer/Core/Compiler.h" */
+/* #include "Charmonizer/Core/ConfWriter.h" */
+/* #include "Charmonizer/Core/Util.h" */
+/* #include "Charmonizer/Probe/FuncMacro.h" */
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Probe for ISO func macro. */
+static int
+chaz_FuncMacro_probe_iso() {
+    static const char iso_func_code[] =
+        CHAZ_QUOTE(  #include <stdio.h>                )
+        CHAZ_QUOTE(  int main() {                      )
+        CHAZ_QUOTE(      printf("%s", __func__);       )
+        CHAZ_QUOTE(      return 0;                     )
+        CHAZ_QUOTE(  }                                 );
+    size_t output_len;
+    char *output;
+    int success = false;
+
+    output = chaz_CC_capture_output(iso_func_code, &output_len);
+    if (output != NULL && strncmp(output, "main", 4) == 0) {
+        success = true;
+    }
+    free(output);
+
+    return success;
+}
+
+static int
+chaz_FuncMacro_probe_gnu() {
+    /* Code for verifying GNU func macro. */
+    static const char gnu_func_code[] =
+        CHAZ_QUOTE(  #include <stdio.h>                )
+        CHAZ_QUOTE(  int main() {                      )
+        CHAZ_QUOTE(      printf("%s", __FUNCTION__);   )
+        CHAZ_QUOTE(      return 0;                     )
+        CHAZ_QUOTE(  }                                 );
+    size_t output_len;
+    char *output;
+    int success = false;
+
+    output = chaz_CC_capture_output(gnu_func_code, &output_len);
+    if (output != NULL && strncmp(output, "main", 4) == 0) {
+        success = true;
+    }
+    free(output);
+
+    return success;
+}
+
+/* Attempt to verify inline keyword. */
+static char*
+chaz_FuncMacro_try_inline(const char *keyword, size_t *output_len) {
+    static const char inline_code[] =
+        CHAZ_QUOTE(  #include <stdio.h>                )
+        CHAZ_QUOTE(  static %s int foo() { return 1; } )
+        CHAZ_QUOTE(  int main() {                      )
+        CHAZ_QUOTE(      printf("%%d", foo());         )
+        CHAZ_QUOTE(      return 0;                     )
+        CHAZ_QUOTE(  }                                 );
+    char code[sizeof(inline_code) + 30];
+    sprintf(code, inline_code, keyword);
+    return chaz_CC_capture_output(code, output_len);
+}
+
+static void
+chaz_FuncMacro_probe_inline(void) {
+    static const char* inline_options[] = {
+        "__inline",
+        "__inline__",
+        "inline"
+    };
+    const int num_inline_options = sizeof(inline_options) / sizeof(void*);
+    int has_inline = false;
+    int i;
+
+    for (i = 0; i < num_inline_options; i++) {
+        const char *inline_option = inline_options[i];
+        size_t output_len;
+        char *output = chaz_FuncMacro_try_inline(inline_option, &output_len);
+        if (output != NULL) {
+            has_inline = true;
+            chaz_ConfWriter_add_def("INLINE", inline_option);
+            free(output);
+            break;
+        }
+    }
+    if (!has_inline) {
+        chaz_ConfWriter_add_def("INLINE", NULL);
+    }
+}
+
+void
+chaz_FuncMacro_run(void) {
+    int has_funcmac      = false;
+    int has_iso_funcmac  = false;
+    int has_gnuc_funcmac = false;
+
+    chaz_ConfWriter_start_module("FuncMacro");
+
+    /* Check for func macros. */
+    if (chaz_FuncMacro_probe_iso()) {
+        has_funcmac     = true;
+        has_iso_funcmac = true;
+    }
+    if (chaz_FuncMacro_probe_gnu()) {
+        has_funcmac      = true;
+        has_gnuc_funcmac = true;
+    }
+
+    /* Write out common defines. */
+    if (has_funcmac) {
+        const char *macro_text = has_iso_funcmac
+                                 ? "__func__"
+                                 : "__FUNCTION__";
+        chaz_ConfWriter_add_def("HAS_FUNC_MACRO", NULL);
+        chaz_ConfWriter_add_def("FUNC_MACRO", macro_text);
+    }
+
+    /* Write out specific defines. */
+    if (has_iso_funcmac) {
+        chaz_ConfWriter_add_def("HAS_ISO_FUNC_MACRO", NULL);
+    }
+    if (has_gnuc_funcmac) {
+        chaz_ConfWriter_add_def("HAS_GNUC_FUNC_MACRO", NULL);
+    }
+
+    /* Check for inline keyword. */
+    chaz_FuncMacro_probe_inline();
+
+    chaz_ConfWriter_end_module();
+}
+
+
+
+
+/***************************************************************************/
+
 #line 17 "src/Charmonizer/Probe/Headers.c"
 /* #include "Charmonizer/Core/HeaderChecker.h" */
 /* #include "Charmonizer/Core/ConfWriter.h" */
@@ -4936,7 +5237,7 @@ static const char chaz_Integers_u64_to_double_code[] =
     CHAZ_QUOTE(  #include <stdio.h>                        )
     CHAZ_QUOTE(  int main()                                )
     CHAZ_QUOTE(  {                                         )
-    CHAZ_QUOTE(      unsigned __int64 int_num = 0;         )
+    CHAZ_QUOTE(      unsigned %s int_num = 0;              )
     CHAZ_QUOTE(      double float_num;                     )
     CHAZ_QUOTE(      float_num = (double)int_num;          )
     CHAZ_QUOTE(      printf("%%f\n", float_num);           )
@@ -5093,13 +5394,6 @@ chaz_Integers_run(void) {
         }
     }
 
-    /* Determine whether conversion of unsigned __int64 to double works */
-    if (has___int64) {
-        if (!chaz_CC_test_compile(chaz_Integers_u64_to_double_code)) {
-            can_convert_u64_to_double = false;
-        }
-    }
-
     /* Write out some conditional defines. */
     if (has_inttypes) {
         chaz_ConfWriter_add_def("HAS_INTTYPES_H", NULL);
@@ -5148,92 +5442,179 @@ chaz_Integers_run(void) {
         chaz_ConfWriter_add_def("HAS_INT64_T", NULL);
     }
 
-    /* Write typedefs, maximums/minimums and literals macros. */
-    if (has_inttypes) {
-        chaz_ConfWriter_add_sys_include("inttypes.h");
+    /* Create macro for promoting pointers to integers. */
+    if (has_64) {
+        if (sizeof_ptr == 8) {
+            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
+                                    "((int64_t)(uint64_t)(ptr))");
+        }
+        else {
+            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
+                                    "((int64_t)(uint32_t)(ptr))");
+        }
     }
-    else {
-        if (has_stdint) {
-            chaz_ConfWriter_add_sys_include("stdint.h");
+
+    /* Create macro for converting uint64_t to double. */
+    if (has_64) {
+        /*
+         * Determine whether unsigned 64-bit integers can be converted to
+         * double. Older MSVC versions don't support this conversion.
+         */
+        sprintf(code_buf, chaz_Integers_u64_to_double_code, i64_t_type);
+        output = chaz_CC_capture_output(code_buf, &output_len);
+        if (output != NULL) {
+            chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)", "((double)(num))");
+            free(output);
         }
         else {
-            /* We support only the following subset of stdint.h
-             *   int8_t
-             *   int16_t
-             *   int32_t
-             *   int64_t
-             *   uint8_t
-             *   uint16_t
-             *   uint32_t
-             *   uint64_t
-             *   INT8_MAX
-             *   INT16_MAX
-             *   INT32_MAX
-             *   INT64_MAX
-             *   INT8_MIN
-             *   INT16_MIN
-             *   INT32_MIN
-             *   INT64_MIN
-             *   UINT8_MAX
-             *   UINT16_MAX
-             *   UINT32_MAX
-             *   UINT64_MAX
-             *   SIZE_MAX
-             *   INT32_C
-             *   INT64_C
-             *   UINT32_C
-             *   UINT64_C
-             */
-            if (has_8) {
-                chaz_ConfWriter_add_global_typedef("signed char", "int8_t");
-                chaz_ConfWriter_add_global_typedef("unsigned char", "uint8_t");
-                chaz_ConfWriter_add_global_def("INT8_MAX", "127");
-                chaz_ConfWriter_add_global_def("INT8_MIN", "-128");
-                chaz_ConfWriter_add_global_def("UINT8_MAX", "255");
-            }
-            if (has_16) {
-                chaz_ConfWriter_add_global_typedef("signed short", "int16_t");
-                chaz_ConfWriter_add_global_typedef("unsigned short",
-                                                   "uint16_t");
-                chaz_ConfWriter_add_global_def("INT16_MAX", "32767");
-                chaz_ConfWriter_add_global_def("INT16_MIN", "-32768");
-                chaz_ConfWriter_add_global_def("UINT16_MAX", "65535");
-            }
-            if (has_32) {
-                chaz_ConfWriter_add_global_typedef(i32_t_type, "int32_t");
-                sprintf(scratch, "unsigned %s", i32_t_type);
-                chaz_ConfWriter_add_global_typedef(scratch, "uint32_t");
-                chaz_ConfWriter_add_global_def("INT32_MAX", "2147483647");
-                chaz_ConfWriter_add_global_def("INT32_MIN", "(-INT32_MAX-1)");
-                chaz_ConfWriter_add_global_def("UINT32_MAX", "4294967295U");
-                if (strcmp(i32_t_postfix, "") == 0) {
-                    chaz_ConfWriter_add_global_def("INT32_C(n)", "n");
-                }
-                else {
-                    sprintf(scratch, "n##%s", i32_t_postfix);
-                    chaz_ConfWriter_add_global_def("INT32_C(n)", scratch);
-                }
-                sprintf(scratch, "n##%s", u32_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT32_C(n)", scratch);
+            chaz_ConfWriter_add_def(
+                "U64_TO_DOUBLE(num)",
+                "((num) & UINT64_C(0x8000000000000000) ? "
+                "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
+                "9223372036854775808.0 : "
+                "(double)(int64_t)(num))");
+        }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer typedefs. */
+
+    chaz_ConfWriter_start_module("IntegerTypes");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   int8_t
+         *   int16_t
+         *   int32_t
+         *   int64_t
+         *   uint8_t
+         *   uint16_t
+         *   uint32_t
+         *   uint64_t
+         */
+        if (has_8) {
+            chaz_ConfWriter_add_global_typedef("signed char", "int8_t");
+            chaz_ConfWriter_add_global_typedef("unsigned char", "uint8_t");
+        }
+        if (has_16) {
+            chaz_ConfWriter_add_global_typedef("signed short", "int16_t");
+            chaz_ConfWriter_add_global_typedef("unsigned short", "uint16_t");
+        }
+        if (has_32) {
+            chaz_ConfWriter_add_global_typedef(i32_t_type, "int32_t");
+            sprintf(scratch, "unsigned %s", i32_t_type);
+            chaz_ConfWriter_add_global_typedef(scratch, "uint32_t");
+        }
+        if (has_64) {
+            chaz_ConfWriter_add_global_typedef(i64_t_type, "int64_t");
+            sprintf(scratch, "unsigned %s", i64_t_type);
+            chaz_ConfWriter_add_global_typedef(scratch, "uint64_t");
+        }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer limits. */
+
+    chaz_ConfWriter_start_module("IntegerLimits");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   INT8_MAX
+         *   INT16_MAX
+         *   INT32_MAX
+         *   INT64_MAX
+         *   INT8_MIN
+         *   INT16_MIN
+         *   INT32_MIN
+         *   INT64_MIN
+         *   UINT8_MAX
+         *   UINT16_MAX
+         *   UINT32_MAX
+         *   UINT64_MAX
+         *   SIZE_MAX
+         */
+        if (has_8) {
+            chaz_ConfWriter_add_global_def("INT8_MAX", "127");
+            chaz_ConfWriter_add_global_def("INT8_MIN", "-128");
+            chaz_ConfWriter_add_global_def("UINT8_MAX", "255");
+        }
+        if (has_16) {
+            chaz_ConfWriter_add_global_def("INT16_MAX", "32767");
+            chaz_ConfWriter_add_global_def("INT16_MIN", "-32768");
+            chaz_ConfWriter_add_global_def("UINT16_MAX", "65535");
+        }
+        if (has_32) {
+            chaz_ConfWriter_add_global_def("INT32_MAX", "2147483647");
+            chaz_ConfWriter_add_global_def("INT32_MIN", "(-INT32_MAX-1)");
+            chaz_ConfWriter_add_global_def("UINT32_MAX", "4294967295U");
+        }
+        if (has_64) {
+            sprintf(scratch, "9223372036854775807%s", i64_t_postfix);
+            chaz_ConfWriter_add_global_def("INT64_MAX", scratch);
+            chaz_ConfWriter_add_global_def("INT64_MIN", "(-INT64_MAX-1)");
+            sprintf(scratch, "18446744073709551615%s", u64_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT64_MAX", scratch);
+        }
+        chaz_ConfWriter_add_global_def("SIZE_MAX", "((size_t)-1)");
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer literals. */
+
+    chaz_ConfWriter_start_module("IntegerLiterals");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   INT32_C
+         *   INT64_C
+         *   UINT32_C
+         *   UINT64_C
+         */
+        if (has_32) {
+            if (strcmp(i32_t_postfix, "") == 0) {
+                chaz_ConfWriter_add_global_def("INT32_C(n)", "n");
             }
-            if (has_64) {
-                chaz_ConfWriter_add_global_typedef(i64_t_type, "int64_t");
-                sprintf(scratch, "unsigned %s", i64_t_type);
-                chaz_ConfWriter_add_global_typedef(scratch, "uint64_t");
-                sprintf(scratch, "9223372036854775807%s", i64_t_postfix);
-                chaz_ConfWriter_add_global_def("INT64_MAX", scratch);
-                chaz_ConfWriter_add_global_def("INT64_MIN", "(-INT64_MAX-1)");
-                sprintf(scratch, "18446744073709551615%s", u64_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT64_MAX", scratch);
-                sprintf(scratch, "n##%s", i64_t_postfix);
-                chaz_ConfWriter_add_global_def("INT64_C(n)", scratch);
-                sprintf(scratch, "n##%s", u64_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT64_C(n)", scratch);
+            else {
+                sprintf(scratch, "n##%s", i32_t_postfix);
+                chaz_ConfWriter_add_global_def("INT32_C(n)", scratch);
             }
-            chaz_ConfWriter_add_global_def("SIZE_MAX", "((size_t)-1)");
+            sprintf(scratch, "n##%s", u32_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT32_C(n)", scratch);
         }
+        if (has_64) {
+            sprintf(scratch, "n##%s", i64_t_postfix);
+            chaz_ConfWriter_add_global_def("INT64_C(n)", scratch);
+            sprintf(scratch, "n##%s", u64_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT64_C(n)", scratch);
+        }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer format strings. */
+
+    chaz_ConfWriter_start_module("IntegerFormatStrings");
 
-        /* Create the PRId64 and PRIu64 printf macros. */
+    if (has_inttypes) {
+        chaz_ConfWriter_add_sys_include("inttypes.h");
+    }
+    else {
+        /* We support only the following subset of inttypes.h
+         *   PRId64
+         *   PRIu64
+         */
         if (has_64) {
             int i;
             const char *options[] = {
@@ -5272,32 +5653,6 @@ chaz_Integers_run(void) {
         }
     }
 
-    /* Create macro for promoting pointers to integers. */
-    if (has_64) {
-        if (sizeof_ptr == 8) {
-            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
-                                    "((int64_t)(uint64_t)(ptr))");
-        }
-        else {
-            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
-                                    "((int64_t)(uint32_t)(ptr))");
-        }
-    }
-
-    /* Create macro for converting uint64_t to double. */
-    if (can_convert_u64_to_double) {
-        chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)",
-                                "((double)(num))");
-    }
-    else {
-        chaz_ConfWriter_add_def(
-            "U64_TO_DOUBLE(num)",
-            "((num) & UINT64_C(0x8000000000000000) ? "
-            "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
-            "9223372036854775808.0 : "
-            "(double)(int64_t)(num))");
-    }
-
     chaz_ConfWriter_end_module();
 }
 
@@ -5392,6 +5747,71 @@ chaz_Strings_probe_c99_snprintf(void) {
 
 /***************************************************************************/
 
+#line 17 "src/Charmonizer/Probe/SymbolVisibility.c"
+/* #include "Charmonizer/Probe/SymbolVisibility.h" */
+/* #include "Charmonizer/Core/Compiler.h" */
+/* #include "Charmonizer/Core/ConfWriter.h" */
+/* #include "Charmonizer/Core/Util.h" */
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static const char chaz_SymbolVisibility_symbol_exporting_code[] =
+    CHAZ_QUOTE(  %s int exported_function() {   )
+    CHAZ_QUOTE(      return 42;                 )
+    CHAZ_QUOTE(  }                              )
+    CHAZ_QUOTE(  int main() {                   )
+    CHAZ_QUOTE(      return 0;                  )
+    CHAZ_QUOTE(  }                              );
+
+void
+chaz_SymbolVisibility_run(void) {
+    chaz_CFlags *temp_cflags = chaz_CC_get_temp_cflags();
+    int can_control_visibility = false;
+    char code_buf[sizeof(chaz_SymbolVisibility_symbol_exporting_code) + 100];
+
+    chaz_ConfWriter_start_module("SymbolVisibility");
+    chaz_CFlags_set_warnings_as_errors(temp_cflags);
+
+    /* Windows. */
+    if (!can_control_visibility) {
+        char export_win[] = "__declspec(dllexport)";
+        sprintf(code_buf, chaz_SymbolVisibility_symbol_exporting_code,
+                export_win);
+        if (chaz_CC_test_compile(code_buf)) {
+            can_control_visibility = true;
+            chaz_ConfWriter_add_def("EXPORT", export_win);
+            chaz_ConfWriter_add_def("IMPORT", "__declspec(dllimport)");
+        }
+    }
+
+    /* GCC. */
+    if (!can_control_visibility) {
+        char export_gcc[] = "__attribute__ ((visibility (\"default\")))";
+        sprintf(code_buf, chaz_SymbolVisibility_symbol_exporting_code,
+                export_gcc);
+        if (chaz_CC_test_compile(code_buf)) {
+            can_control_visibility = true;
+            chaz_ConfWriter_add_def("EXPORT", export_gcc);
+            chaz_ConfWriter_add_def("IMPORT", NULL);
+        }
+    }
+
+    chaz_CFlags_clear(temp_cflags);
+
+    /* Default. */
+    if (!can_control_visibility) {
+        chaz_ConfWriter_add_def("EXPORT", NULL);
+        chaz_ConfWriter_add_def("IMPORT", NULL);
+    }
+
+    chaz_ConfWriter_end_module();
+}
+
+
+
+/***************************************************************************/
+
 #line 17 "src/Charmonizer/Probe/UnusedVars.c"
 /* #include "Charmonizer/Core/ConfWriter.h" */
 /* #include "Charmonizer/Core/Util.h" */
@@ -5672,12 +6092,18 @@ int main(int argc, const char **argv) {
         S_add_compiler_flags(&args);
     }
 
+    /* Define stdint types in charmony.h. */
+    chaz_ConfWriter_append_conf("#define CHY_EMPLOY_INTEGERTYPES\n\n");
+
     /* Run probe modules. */
     chaz_BuildEnv_run();
     chaz_DirManip_run();
     chaz_Headers_run();
+    chaz_FuncMacro_run();
+    chaz_Booleans_run();
     chaz_Integers_run();
     chaz_Strings_run();
+    chaz_SymbolVisibility_run();
     chaz_UnusedVars_run();
 
     if (args.write_makefile) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/e7cdce42/clownfish/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/common/charmonizer.c b/clownfish/runtime/common/charmonizer.c
index d494373..0b9bbaf 100644
--- a/clownfish/runtime/common/charmonizer.c
+++ b/clownfish/runtime/common/charmonizer.c
@@ -2456,6 +2456,7 @@ typedef struct chaz_ConfElem {
 /* Static vars. */
 static struct {
     FILE          *fh;
+    char          *MODULE_NAME;
     chaz_ConfElem *defs;
     size_t         def_cap;
     size_t         def_count;
@@ -2553,18 +2554,17 @@ chaz_ConfWriterC_vappend_conf(const char *fmt, va_list args) {
 
 static int
 chaz_ConfWriterC_sym_is_uppercase(const char *sym) {
-    unsigned i;
-    for (i = 0; sym[i] != 0; i++) {
-        if (!isupper(sym[i])) {
-            if (islower(sym[i])) {
-                return false;
-            }
-            else if (sym[i] != '_') {
-                return true;
-            }
-        }
+    return isupper(sym[0]);
+}
+
+static char*
+chaz_ConfWriterC_uppercase_string(const char *src) {
+    char *retval = chaz_Util_strdup(src);
+    size_t i;
+    for (i = 0; retval[i]; ++i) {
+        retval[i] = toupper(retval[i]);
     }
-    return true;
+    return retval;
 }
 
 static void
@@ -2599,9 +2599,10 @@ chaz_ConfWriterC_add_global_def(const char *sym, const char *value) {
 
 static void
 chaz_ConfWriterC_append_global_def_to_conf(const char *sym,
-        const char *value) {
+                                           const char *value) {
     char *name_end = strchr(sym, '(');
     if (name_end == NULL) {
+        if (strcmp(sym, value) == 0) { return; }
         fprintf(chaz_ConfWriterC.fh, "#ifndef %s\n", sym);
     }
     else {
@@ -2643,7 +2644,8 @@ chaz_ConfWriterC_add_global_typedef(const char *type, const char *alias) {
 
 static void
 chaz_ConfWriterC_append_global_typedef_to_conf(const char *type,
-        const char *alias) {
+                                               const char *alias) {
+    if (strcmp(type, alias) == 0) { return; }
     fprintf(chaz_ConfWriterC.fh, "typedef %s %s;\n", type, alias);
 }
 
@@ -2672,32 +2674,37 @@ chaz_ConfWriterC_append_local_include_to_conf(const char *header) {
 static void
 chaz_ConfWriterC_start_module(const char *module_name) {
     fprintf(chaz_ConfWriterC.fh, "\n/* %s */\n", module_name);
+    chaz_ConfWriterC.MODULE_NAME
+        = chaz_ConfWriterC_uppercase_string(module_name);
 }
 
 static void
 chaz_ConfWriterC_end_module(void) {
+    size_t num_globals = 0;
     size_t i;
     chaz_ConfElem *defs = chaz_ConfWriterC.defs;
     for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
         switch (defs[i].type) {
+            case CHAZ_CONFELEM_GLOBAL_DEF:
+                ++num_globals;
+            /* fall through */
             case CHAZ_CONFELEM_DEF:
                 chaz_ConfWriterC_append_def_to_conf(defs[i].str1,
                                                     defs[i].str2);
                 break;
-            case CHAZ_CONFELEM_GLOBAL_DEF:
-                chaz_ConfWriterC_append_global_def_to_conf(defs[i].str1,
-                                                           defs[i].str2);
-                break;
+            case CHAZ_CONFELEM_GLOBAL_TYPEDEF: {
+                ++num_globals;
+                char *sym = chaz_ConfWriterC_uppercase_string(defs[i].str1);
+                chaz_ConfWriterC_append_def_to_conf(sym, defs[i].str2);
+                free(sym);
+            }
+            /* fall through */
             case CHAZ_CONFELEM_TYPEDEF:
                 chaz_ConfWriterC_append_typedef_to_conf(defs[i].str2,
                                                         defs[i].str1);
                 break;
-            case CHAZ_CONFELEM_GLOBAL_TYPEDEF:
-                chaz_ConfWriterC_append_global_typedef_to_conf(defs[i].str2,
-                                                               defs[i].str1);
-                break;
             case CHAZ_CONFELEM_SYS_INCLUDE:
-                chaz_ConfWriterC_append_sys_include_to_conf(defs[i].str1);
+                ++num_globals;
                 break;
             case CHAZ_CONFELEM_LOCAL_INCLUDE:
                 chaz_ConfWriterC_append_local_include_to_conf(defs[i].str1);
@@ -2715,7 +2722,7 @@ chaz_ConfWriterC_end_module(void) {
     );
     for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
         switch (defs[i].type) {
-            case CHAZ_CONFELEM_DEF: 
+            case CHAZ_CONFELEM_DEF:
             case CHAZ_CONFELEM_TYPEDEF:
                 {
                     const char *sym = defs[i].str1;
@@ -2742,8 +2749,41 @@ chaz_ConfWriterC_end_module(void) {
     }
 
     fprintf(chaz_ConfWriterC.fh, "#endif /* USE_SHORT_NAMES */\n");
+
+    /* Write out global definitions and system includes. */
+    if (num_globals) {
+        fprintf(chaz_ConfWriterC.fh, "\n#ifdef CHY_EMPLOY_%s\n\n",
+                chaz_ConfWriterC.MODULE_NAME);
+        for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
+            switch (defs[i].type) {
+                case CHAZ_CONFELEM_GLOBAL_DEF:
+                    chaz_ConfWriterC_append_global_def_to_conf(defs[i].str1,
+                                                               defs[i].str2);
+                    break;
+                case CHAZ_CONFELEM_GLOBAL_TYPEDEF:
+                    chaz_ConfWriterC_append_global_typedef_to_conf(
+                            defs[i].str2, defs[i].str1);
+                    break;
+                case CHAZ_CONFELEM_SYS_INCLUDE:
+                    chaz_ConfWriterC_append_sys_include_to_conf(defs[i].str1);
+                    break;
+                case CHAZ_CONFELEM_DEF:
+                case CHAZ_CONFELEM_TYPEDEF:
+                case CHAZ_CONFELEM_LOCAL_INCLUDE:
+                    /* no-op */
+                    break;
+                default:
+                    chaz_Util_die("Internal error: bad element type %d",
+                                  (int)defs[i].type);
+            }
+        }
+        fprintf(chaz_ConfWriterC.fh, "\n#endif /* EMPLOY_%s */\n",
+                chaz_ConfWriterC.MODULE_NAME);
+    }
+
     fprintf(chaz_ConfWriterC.fh, "\n");
 
+    free(chaz_ConfWriterC.MODULE_NAME);
     chaz_ConfWriterC_clear_def_list();
 }
 
@@ -4806,7 +4846,7 @@ chaz_Booleans_run(void) {
     }
     else {
         chaz_ConfWriter_append_conf(
-            "#ifndef __cplusplus\n"
+            "#if (defined(CHY_EMPLOY_BOOLEANS) && !defined(__cplusplus))\n"
             "  typedef int bool;\n"
             "  #ifndef true\n"
             "    #define true 1\n"
@@ -5053,14 +5093,35 @@ chaz_Floats_run(void) {
     chaz_ConfWriter_start_module("Floats");
 
     chaz_ConfWriter_append_conf(
-        "typedef union { uint32_t i; float f; } chy_floatu32;\n"
-        "typedef union { uint64_t i; double d; } chy_floatu64;\n"
-        "static const chy_floatu32 chy_f32inf    = {UINT32_C(0x7f800000)};\n"
-        "static const chy_floatu32 chy_f32neginf = {UINT32_C(0xff800000)};\n"
-        "static const chy_floatu32 chy_f32nan    = {UINT32_C(0x7fc00000)};\n"
-        "static const chy_floatu64 chy_f64inf    = {UINT64_C(0x7ff0000000000000)};\n"
-        "static const chy_floatu64 chy_f64neginf = {UINT64_C(0xfff0000000000000)};\n"
-        "static const chy_floatu64 chy_f64nan    = {UINT64_C(0x7ff8000000000000)};\n"
+        "typedef union { unsigned char c[4]; float f; } chy_floatu32;\n"
+        "typedef union { unsigned char c[8]; double d; } chy_floatu64;\n"
+        "#ifdef CHY_BIG_END\n"
+        "static const chy_floatu32 chy_f32inf\n"
+        "    = { { 0x7F, 0x80, 0, 0 } };\n"
+        "static const chy_floatu32 chy_f32neginf\n"
+        "    = { { 0xFF, 0x80, 0, 0 } };\n"
+        "static const chy_floatu32 chy_f32nan\n"
+        "    = { { 0x7F, 0xC0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64inf\n"
+        "    = { { 0x7F, 0xF0, 0, 0, 0, 0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64neginf\n"
+        "    = { { 0xFF, 0xF0, 0, 0, 0, 0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64nan\n"
+        "    = { { 0x7F, 0xF8, 0, 0, 0, 0, 0, 0 } };\n"
+        "#else /* BIG_END */\n"
+        "static const chy_floatu32 chy_f32inf\n"
+        "    = { { 0, 0, 0x80, 0x7F } };\n"
+        "static const chy_floatu32 chy_f32neginf\n"
+        "    = { { 0, 0, 0x80, 0xFF } };\n"
+        "static const chy_floatu32 chy_f32nan\n"
+        "    = { { 0, 0, 0xC0, 0x7F } };\n"
+        "static const chy_floatu64 chy_f64inf\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF0, 0x7F } };\n"
+        "static const chy_floatu64 chy_f64neginf\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF0, 0xFF } };\n"
+        "static const chy_floatu64 chy_f64nan\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF8, 0x7F } };\n"
+        "#endif /* BIG_END */\n"
     );
     chaz_ConfWriter_add_def("F32_INF", "(chy_f32inf.f)");
     chaz_ConfWriter_add_def("F32_NEGINF", "(chy_f32neginf.f)");
@@ -5517,7 +5578,7 @@ static const char chaz_Integers_u64_to_double_code[] =
     CHAZ_QUOTE(  #include <stdio.h>                        )
     CHAZ_QUOTE(  int main()                                )
     CHAZ_QUOTE(  {                                         )
-    CHAZ_QUOTE(      unsigned __int64 int_num = 0;         )
+    CHAZ_QUOTE(      unsigned %s int_num = 0;              )
     CHAZ_QUOTE(      double float_num;                     )
     CHAZ_QUOTE(      float_num = (double)int_num;          )
     CHAZ_QUOTE(      printf("%%f\n", float_num);           )
@@ -5674,13 +5735,6 @@ chaz_Integers_run(void) {
         }
     }
 
-    /* Determine whether conversion of unsigned __int64 to double works */
-    if (has___int64) {
-        if (!chaz_CC_test_compile(chaz_Integers_u64_to_double_code)) {
-            can_convert_u64_to_double = false;
-        }
-    }
-
     /* Write out some conditional defines. */
     if (has_inttypes) {
         chaz_ConfWriter_add_def("HAS_INTTYPES_H", NULL);
@@ -5729,92 +5783,179 @@ chaz_Integers_run(void) {
         chaz_ConfWriter_add_def("HAS_INT64_T", NULL);
     }
 
-    /* Write typedefs, maximums/minimums and literals macros. */
-    if (has_inttypes) {
-        chaz_ConfWriter_add_sys_include("inttypes.h");
+    /* Create macro for promoting pointers to integers. */
+    if (has_64) {
+        if (sizeof_ptr == 8) {
+            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
+                                    "((int64_t)(uint64_t)(ptr))");
+        }
+        else {
+            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
+                                    "((int64_t)(uint32_t)(ptr))");
+        }
     }
-    else {
-        if (has_stdint) {
-            chaz_ConfWriter_add_sys_include("stdint.h");
+
+    /* Create macro for converting uint64_t to double. */
+    if (has_64) {
+        /*
+         * Determine whether unsigned 64-bit integers can be converted to
+         * double. Older MSVC versions don't support this conversion.
+         */
+        sprintf(code_buf, chaz_Integers_u64_to_double_code, i64_t_type);
+        output = chaz_CC_capture_output(code_buf, &output_len);
+        if (output != NULL) {
+            chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)", "((double)(num))");
+            free(output);
         }
         else {
-            /* We support only the following subset of stdint.h
-             *   int8_t
-             *   int16_t
-             *   int32_t
-             *   int64_t
-             *   uint8_t
-             *   uint16_t
-             *   uint32_t
-             *   uint64_t
-             *   INT8_MAX
-             *   INT16_MAX
-             *   INT32_MAX
-             *   INT64_MAX
-             *   INT8_MIN
-             *   INT16_MIN
-             *   INT32_MIN
-             *   INT64_MIN
-             *   UINT8_MAX
-             *   UINT16_MAX
-             *   UINT32_MAX
-             *   UINT64_MAX
-             *   SIZE_MAX
-             *   INT32_C
-             *   INT64_C
-             *   UINT32_C
-             *   UINT64_C
-             */
-            if (has_8) {
-                chaz_ConfWriter_add_global_typedef("signed char", "int8_t");
-                chaz_ConfWriter_add_global_typedef("unsigned char", "uint8_t");
-                chaz_ConfWriter_add_global_def("INT8_MAX", "127");
-                chaz_ConfWriter_add_global_def("INT8_MIN", "-128");
-                chaz_ConfWriter_add_global_def("UINT8_MAX", "255");
-            }
-            if (has_16) {
-                chaz_ConfWriter_add_global_typedef("signed short", "int16_t");
-                chaz_ConfWriter_add_global_typedef("unsigned short",
-                                                   "uint16_t");
-                chaz_ConfWriter_add_global_def("INT16_MAX", "32767");
-                chaz_ConfWriter_add_global_def("INT16_MIN", "-32768");
-                chaz_ConfWriter_add_global_def("UINT16_MAX", "65535");
-            }
-            if (has_32) {
-                chaz_ConfWriter_add_global_typedef(i32_t_type, "int32_t");
-                sprintf(scratch, "unsigned %s", i32_t_type);
-                chaz_ConfWriter_add_global_typedef(scratch, "uint32_t");
-                chaz_ConfWriter_add_global_def("INT32_MAX", "2147483647");
-                chaz_ConfWriter_add_global_def("INT32_MIN", "(-INT32_MAX-1)");
-                chaz_ConfWriter_add_global_def("UINT32_MAX", "4294967295U");
-                if (strcmp(i32_t_postfix, "") == 0) {
-                    chaz_ConfWriter_add_global_def("INT32_C(n)", "n");
-                }
-                else {
-                    sprintf(scratch, "n##%s", i32_t_postfix);
-                    chaz_ConfWriter_add_global_def("INT32_C(n)", scratch);
-                }
-                sprintf(scratch, "n##%s", u32_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT32_C(n)", scratch);
+            chaz_ConfWriter_add_def(
+                "U64_TO_DOUBLE(num)",
+                "((num) & UINT64_C(0x8000000000000000) ? "
+                "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
+                "9223372036854775808.0 : "
+                "(double)(int64_t)(num))");
+        }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer typedefs. */
+
+    chaz_ConfWriter_start_module("IntegerTypes");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   int8_t
+         *   int16_t
+         *   int32_t
+         *   int64_t
+         *   uint8_t
+         *   uint16_t
+         *   uint32_t
+         *   uint64_t
+         */
+        if (has_8) {
+            chaz_ConfWriter_add_global_typedef("signed char", "int8_t");
+            chaz_ConfWriter_add_global_typedef("unsigned char", "uint8_t");
+        }
+        if (has_16) {
+            chaz_ConfWriter_add_global_typedef("signed short", "int16_t");
+            chaz_ConfWriter_add_global_typedef("unsigned short", "uint16_t");
+        }
+        if (has_32) {
+            chaz_ConfWriter_add_global_typedef(i32_t_type, "int32_t");
+            sprintf(scratch, "unsigned %s", i32_t_type);
+            chaz_ConfWriter_add_global_typedef(scratch, "uint32_t");
+        }
+        if (has_64) {
+            chaz_ConfWriter_add_global_typedef(i64_t_type, "int64_t");
+            sprintf(scratch, "unsigned %s", i64_t_type);
+            chaz_ConfWriter_add_global_typedef(scratch, "uint64_t");
+        }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer limits. */
+
+    chaz_ConfWriter_start_module("IntegerLimits");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   INT8_MAX
+         *   INT16_MAX
+         *   INT32_MAX
+         *   INT64_MAX
+         *   INT8_MIN
+         *   INT16_MIN
+         *   INT32_MIN
+         *   INT64_MIN
+         *   UINT8_MAX
+         *   UINT16_MAX
+         *   UINT32_MAX
+         *   UINT64_MAX
+         *   SIZE_MAX
+         */
+        if (has_8) {
+            chaz_ConfWriter_add_global_def("INT8_MAX", "127");
+            chaz_ConfWriter_add_global_def("INT8_MIN", "-128");
+            chaz_ConfWriter_add_global_def("UINT8_MAX", "255");
+        }
+        if (has_16) {
+            chaz_ConfWriter_add_global_def("INT16_MAX", "32767");
+            chaz_ConfWriter_add_global_def("INT16_MIN", "-32768");
+            chaz_ConfWriter_add_global_def("UINT16_MAX", "65535");
+        }
+        if (has_32) {
+            chaz_ConfWriter_add_global_def("INT32_MAX", "2147483647");
+            chaz_ConfWriter_add_global_def("INT32_MIN", "(-INT32_MAX-1)");
+            chaz_ConfWriter_add_global_def("UINT32_MAX", "4294967295U");
+        }
+        if (has_64) {
+            sprintf(scratch, "9223372036854775807%s", i64_t_postfix);
+            chaz_ConfWriter_add_global_def("INT64_MAX", scratch);
+            chaz_ConfWriter_add_global_def("INT64_MIN", "(-INT64_MAX-1)");
+            sprintf(scratch, "18446744073709551615%s", u64_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT64_MAX", scratch);
+        }
+        chaz_ConfWriter_add_global_def("SIZE_MAX", "((size_t)-1)");
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer literals. */
+
+    chaz_ConfWriter_start_module("IntegerLiterals");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   INT32_C
+         *   INT64_C
+         *   UINT32_C
+         *   UINT64_C
+         */
+        if (has_32) {
+            if (strcmp(i32_t_postfix, "") == 0) {
+                chaz_ConfWriter_add_global_def("INT32_C(n)", "n");
             }
-            if (has_64) {
-                chaz_ConfWriter_add_global_typedef(i64_t_type, "int64_t");
-                sprintf(scratch, "unsigned %s", i64_t_type);
-                chaz_ConfWriter_add_global_typedef(scratch, "uint64_t");
-                sprintf(scratch, "9223372036854775807%s", i64_t_postfix);
-                chaz_ConfWriter_add_global_def("INT64_MAX", scratch);
-                chaz_ConfWriter_add_global_def("INT64_MIN", "(-INT64_MAX-1)");
-                sprintf(scratch, "18446744073709551615%s", u64_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT64_MAX", scratch);
-                sprintf(scratch, "n##%s", i64_t_postfix);
-                chaz_ConfWriter_add_global_def("INT64_C(n)", scratch);
-                sprintf(scratch, "n##%s", u64_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT64_C(n)", scratch);
+            else {
+                sprintf(scratch, "n##%s", i32_t_postfix);
+                chaz_ConfWriter_add_global_def("INT32_C(n)", scratch);
             }
-            chaz_ConfWriter_add_global_def("SIZE_MAX", "((size_t)-1)");
+            sprintf(scratch, "n##%s", u32_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT32_C(n)", scratch);
+        }
+        if (has_64) {
+            sprintf(scratch, "n##%s", i64_t_postfix);
+            chaz_ConfWriter_add_global_def("INT64_C(n)", scratch);
+            sprintf(scratch, "n##%s", u64_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT64_C(n)", scratch);
         }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer format strings. */
 
-        /* Create the PRId64 and PRIu64 printf macros. */
+    chaz_ConfWriter_start_module("IntegerFormatStrings");
+
+    if (has_inttypes) {
+        chaz_ConfWriter_add_sys_include("inttypes.h");
+    }
+    else {
+        /* We support only the following subset of inttypes.h
+         *   PRId64
+         *   PRIu64
+         */
         if (has_64) {
             int i;
             const char *options[] = {
@@ -5853,32 +5994,6 @@ chaz_Integers_run(void) {
         }
     }
 
-    /* Create macro for promoting pointers to integers. */
-    if (has_64) {
-        if (sizeof_ptr == 8) {
-            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
-                                    "((int64_t)(uint64_t)(ptr))");
-        }
-        else {
-            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
-                                    "((int64_t)(uint32_t)(ptr))");
-        }
-    }
-
-    /* Create macro for converting uint64_t to double. */
-    if (can_convert_u64_to_double) {
-        chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)",
-                                "((double)(num))");
-    }
-    else {
-        chaz_ConfWriter_add_def(
-            "U64_TO_DOUBLE(num)",
-            "((num) & UINT64_C(0x8000000000000000) ? "
-            "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
-            "9223372036854775808.0 : "
-            "(double)(int64_t)(num))");
-    }
-
     chaz_ConfWriter_end_module();
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/e7cdce42/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/common/charmonizer.c b/common/charmonizer.c
index e065c93..d3d0048 100644
--- a/common/charmonizer.c
+++ b/common/charmonizer.c
@@ -2456,6 +2456,7 @@ typedef struct chaz_ConfElem {
 /* Static vars. */
 static struct {
     FILE          *fh;
+    char          *MODULE_NAME;
     chaz_ConfElem *defs;
     size_t         def_cap;
     size_t         def_count;
@@ -2553,18 +2554,17 @@ chaz_ConfWriterC_vappend_conf(const char *fmt, va_list args) {
 
 static int
 chaz_ConfWriterC_sym_is_uppercase(const char *sym) {
-    unsigned i;
-    for (i = 0; sym[i] != 0; i++) {
-        if (!isupper(sym[i])) {
-            if (islower(sym[i])) {
-                return false;
-            }
-            else if (sym[i] != '_') {
-                return true;
-            }
-        }
+    return isupper(sym[0]);
+}
+
+static char*
+chaz_ConfWriterC_uppercase_string(const char *src) {
+    char *retval = chaz_Util_strdup(src);
+    size_t i;
+    for (i = 0; retval[i]; ++i) {
+        retval[i] = toupper(retval[i]);
     }
-    return true;
+    return retval;
 }
 
 static void
@@ -2599,9 +2599,10 @@ chaz_ConfWriterC_add_global_def(const char *sym, const char *value) {
 
 static void
 chaz_ConfWriterC_append_global_def_to_conf(const char *sym,
-        const char *value) {
+                                           const char *value) {
     char *name_end = strchr(sym, '(');
     if (name_end == NULL) {
+        if (strcmp(sym, value) == 0) { return; }
         fprintf(chaz_ConfWriterC.fh, "#ifndef %s\n", sym);
     }
     else {
@@ -2643,7 +2644,8 @@ chaz_ConfWriterC_add_global_typedef(const char *type, const char *alias) {
 
 static void
 chaz_ConfWriterC_append_global_typedef_to_conf(const char *type,
-        const char *alias) {
+                                               const char *alias) {
+    if (strcmp(type, alias) == 0) { return; }
     fprintf(chaz_ConfWriterC.fh, "typedef %s %s;\n", type, alias);
 }
 
@@ -2672,32 +2674,37 @@ chaz_ConfWriterC_append_local_include_to_conf(const char *header) {
 static void
 chaz_ConfWriterC_start_module(const char *module_name) {
     fprintf(chaz_ConfWriterC.fh, "\n/* %s */\n", module_name);
+    chaz_ConfWriterC.MODULE_NAME
+        = chaz_ConfWriterC_uppercase_string(module_name);
 }
 
 static void
 chaz_ConfWriterC_end_module(void) {
+    size_t num_globals = 0;
     size_t i;
     chaz_ConfElem *defs = chaz_ConfWriterC.defs;
     for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
         switch (defs[i].type) {
+            case CHAZ_CONFELEM_GLOBAL_DEF:
+                ++num_globals;
+            /* fall through */
             case CHAZ_CONFELEM_DEF:
                 chaz_ConfWriterC_append_def_to_conf(defs[i].str1,
                                                     defs[i].str2);
                 break;
-            case CHAZ_CONFELEM_GLOBAL_DEF:
-                chaz_ConfWriterC_append_global_def_to_conf(defs[i].str1,
-                                                           defs[i].str2);
-                break;
+            case CHAZ_CONFELEM_GLOBAL_TYPEDEF: {
+                ++num_globals;
+                char *sym = chaz_ConfWriterC_uppercase_string(defs[i].str1);
+                chaz_ConfWriterC_append_def_to_conf(sym, defs[i].str2);
+                free(sym);
+            }
+            /* fall through */
             case CHAZ_CONFELEM_TYPEDEF:
                 chaz_ConfWriterC_append_typedef_to_conf(defs[i].str2,
                                                         defs[i].str1);
                 break;
-            case CHAZ_CONFELEM_GLOBAL_TYPEDEF:
-                chaz_ConfWriterC_append_global_typedef_to_conf(defs[i].str2,
-                                                               defs[i].str1);
-                break;
             case CHAZ_CONFELEM_SYS_INCLUDE:
-                chaz_ConfWriterC_append_sys_include_to_conf(defs[i].str1);
+                ++num_globals;
                 break;
             case CHAZ_CONFELEM_LOCAL_INCLUDE:
                 chaz_ConfWriterC_append_local_include_to_conf(defs[i].str1);
@@ -2715,7 +2722,7 @@ chaz_ConfWriterC_end_module(void) {
     );
     for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
         switch (defs[i].type) {
-            case CHAZ_CONFELEM_DEF: 
+            case CHAZ_CONFELEM_DEF:
             case CHAZ_CONFELEM_TYPEDEF:
                 {
                     const char *sym = defs[i].str1;
@@ -2742,8 +2749,41 @@ chaz_ConfWriterC_end_module(void) {
     }
 
     fprintf(chaz_ConfWriterC.fh, "#endif /* USE_SHORT_NAMES */\n");
+
+    /* Write out global definitions and system includes. */
+    if (num_globals) {
+        fprintf(chaz_ConfWriterC.fh, "\n#ifdef CHY_EMPLOY_%s\n\n",
+                chaz_ConfWriterC.MODULE_NAME);
+        for (i = 0; i < chaz_ConfWriterC.def_count; i++) {
+            switch (defs[i].type) {
+                case CHAZ_CONFELEM_GLOBAL_DEF:
+                    chaz_ConfWriterC_append_global_def_to_conf(defs[i].str1,
+                                                               defs[i].str2);
+                    break;
+                case CHAZ_CONFELEM_GLOBAL_TYPEDEF:
+                    chaz_ConfWriterC_append_global_typedef_to_conf(
+                            defs[i].str2, defs[i].str1);
+                    break;
+                case CHAZ_CONFELEM_SYS_INCLUDE:
+                    chaz_ConfWriterC_append_sys_include_to_conf(defs[i].str1);
+                    break;
+                case CHAZ_CONFELEM_DEF:
+                case CHAZ_CONFELEM_TYPEDEF:
+                case CHAZ_CONFELEM_LOCAL_INCLUDE:
+                    /* no-op */
+                    break;
+                default:
+                    chaz_Util_die("Internal error: bad element type %d",
+                                  (int)defs[i].type);
+            }
+        }
+        fprintf(chaz_ConfWriterC.fh, "\n#endif /* EMPLOY_%s */\n",
+                chaz_ConfWriterC.MODULE_NAME);
+    }
+
     fprintf(chaz_ConfWriterC.fh, "\n");
 
+    free(chaz_ConfWriterC.MODULE_NAME);
     chaz_ConfWriterC_clear_def_list();
 }
 
@@ -4806,7 +4846,7 @@ chaz_Booleans_run(void) {
     }
     else {
         chaz_ConfWriter_append_conf(
-            "#ifndef __cplusplus\n"
+            "#if (defined(CHY_EMPLOY_BOOLEANS) && !defined(__cplusplus))\n"
             "  typedef int bool;\n"
             "  #ifndef true\n"
             "    #define true 1\n"
@@ -5053,14 +5093,35 @@ chaz_Floats_run(void) {
     chaz_ConfWriter_start_module("Floats");
 
     chaz_ConfWriter_append_conf(
-        "typedef union { uint32_t i; float f; } chy_floatu32;\n"
-        "typedef union { uint64_t i; double d; } chy_floatu64;\n"
-        "static const chy_floatu32 chy_f32inf    = {UINT32_C(0x7f800000)};\n"
-        "static const chy_floatu32 chy_f32neginf = {UINT32_C(0xff800000)};\n"
-        "static const chy_floatu32 chy_f32nan    = {UINT32_C(0x7fc00000)};\n"
-        "static const chy_floatu64 chy_f64inf    = {UINT64_C(0x7ff0000000000000)};\n"
-        "static const chy_floatu64 chy_f64neginf = {UINT64_C(0xfff0000000000000)};\n"
-        "static const chy_floatu64 chy_f64nan    = {UINT64_C(0x7ff8000000000000)};\n"
+        "typedef union { unsigned char c[4]; float f; } chy_floatu32;\n"
+        "typedef union { unsigned char c[8]; double d; } chy_floatu64;\n"
+        "#ifdef CHY_BIG_END\n"
+        "static const chy_floatu32 chy_f32inf\n"
+        "    = { { 0x7F, 0x80, 0, 0 } };\n"
+        "static const chy_floatu32 chy_f32neginf\n"
+        "    = { { 0xFF, 0x80, 0, 0 } };\n"
+        "static const chy_floatu32 chy_f32nan\n"
+        "    = { { 0x7F, 0xC0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64inf\n"
+        "    = { { 0x7F, 0xF0, 0, 0, 0, 0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64neginf\n"
+        "    = { { 0xFF, 0xF0, 0, 0, 0, 0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64nan\n"
+        "    = { { 0x7F, 0xF8, 0, 0, 0, 0, 0, 0 } };\n"
+        "#else /* BIG_END */\n"
+        "static const chy_floatu32 chy_f32inf\n"
+        "    = { { 0, 0, 0x80, 0x7F } };\n"
+        "static const chy_floatu32 chy_f32neginf\n"
+        "    = { { 0, 0, 0x80, 0xFF } };\n"
+        "static const chy_floatu32 chy_f32nan\n"
+        "    = { { 0, 0, 0xC0, 0x7F } };\n"
+        "static const chy_floatu64 chy_f64inf\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF0, 0x7F } };\n"
+        "static const chy_floatu64 chy_f64neginf\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF0, 0xFF } };\n"
+        "static const chy_floatu64 chy_f64nan\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF8, 0x7F } };\n"
+        "#endif /* BIG_END */\n"
     );
     chaz_ConfWriter_add_def("F32_INF", "(chy_f32inf.f)");
     chaz_ConfWriter_add_def("F32_NEGINF", "(chy_f32neginf.f)");
@@ -5517,7 +5578,7 @@ static const char chaz_Integers_u64_to_double_code[] =
     CHAZ_QUOTE(  #include <stdio.h>                        )
     CHAZ_QUOTE(  int main()                                )
     CHAZ_QUOTE(  {                                         )
-    CHAZ_QUOTE(      unsigned __int64 int_num = 0;         )
+    CHAZ_QUOTE(      unsigned %s int_num = 0;              )
     CHAZ_QUOTE(      double float_num;                     )
     CHAZ_QUOTE(      float_num = (double)int_num;          )
     CHAZ_QUOTE(      printf("%%f\n", float_num);           )
@@ -5674,13 +5735,6 @@ chaz_Integers_run(void) {
         }
     }
 
-    /* Determine whether conversion of unsigned __int64 to double works */
-    if (has___int64) {
-        if (!chaz_CC_test_compile(chaz_Integers_u64_to_double_code)) {
-            can_convert_u64_to_double = false;
-        }
-    }
-
     /* Write out some conditional defines. */
     if (has_inttypes) {
         chaz_ConfWriter_add_def("HAS_INTTYPES_H", NULL);
@@ -5729,92 +5783,179 @@ chaz_Integers_run(void) {
         chaz_ConfWriter_add_def("HAS_INT64_T", NULL);
     }
 
-    /* Write typedefs, maximums/minimums and literals macros. */
-    if (has_inttypes) {
-        chaz_ConfWriter_add_sys_include("inttypes.h");
+    /* Create macro for promoting pointers to integers. */
+    if (has_64) {
+        if (sizeof_ptr == 8) {
+            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
+                                    "((int64_t)(uint64_t)(ptr))");
+        }
+        else {
+            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
+                                    "((int64_t)(uint32_t)(ptr))");
+        }
     }
-    else {
-        if (has_stdint) {
-            chaz_ConfWriter_add_sys_include("stdint.h");
+
+    /* Create macro for converting uint64_t to double. */
+    if (has_64) {
+        /*
+         * Determine whether unsigned 64-bit integers can be converted to
+         * double. Older MSVC versions don't support this conversion.
+         */
+        sprintf(code_buf, chaz_Integers_u64_to_double_code, i64_t_type);
+        output = chaz_CC_capture_output(code_buf, &output_len);
+        if (output != NULL) {
+            chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)", "((double)(num))");
+            free(output);
         }
         else {
-            /* We support only the following subset of stdint.h
-             *   int8_t
-             *   int16_t
-             *   int32_t
-             *   int64_t
-             *   uint8_t
-             *   uint16_t
-             *   uint32_t
-             *   uint64_t
-             *   INT8_MAX
-             *   INT16_MAX
-             *   INT32_MAX
-             *   INT64_MAX
-             *   INT8_MIN
-             *   INT16_MIN
-             *   INT32_MIN
-             *   INT64_MIN
-             *   UINT8_MAX
-             *   UINT16_MAX
-             *   UINT32_MAX
-             *   UINT64_MAX
-             *   SIZE_MAX
-             *   INT32_C
-             *   INT64_C
-             *   UINT32_C
-             *   UINT64_C
-             */
-            if (has_8) {
-                chaz_ConfWriter_add_global_typedef("signed char", "int8_t");
-                chaz_ConfWriter_add_global_typedef("unsigned char", "uint8_t");
-                chaz_ConfWriter_add_global_def("INT8_MAX", "127");
-                chaz_ConfWriter_add_global_def("INT8_MIN", "-128");
-                chaz_ConfWriter_add_global_def("UINT8_MAX", "255");
-            }
-            if (has_16) {
-                chaz_ConfWriter_add_global_typedef("signed short", "int16_t");
-                chaz_ConfWriter_add_global_typedef("unsigned short",
-                                                   "uint16_t");
-                chaz_ConfWriter_add_global_def("INT16_MAX", "32767");
-                chaz_ConfWriter_add_global_def("INT16_MIN", "-32768");
-                chaz_ConfWriter_add_global_def("UINT16_MAX", "65535");
-            }
-            if (has_32) {
-                chaz_ConfWriter_add_global_typedef(i32_t_type, "int32_t");
-                sprintf(scratch, "unsigned %s", i32_t_type);
-                chaz_ConfWriter_add_global_typedef(scratch, "uint32_t");
-                chaz_ConfWriter_add_global_def("INT32_MAX", "2147483647");
-                chaz_ConfWriter_add_global_def("INT32_MIN", "(-INT32_MAX-1)");
-                chaz_ConfWriter_add_global_def("UINT32_MAX", "4294967295U");
-                if (strcmp(i32_t_postfix, "") == 0) {
-                    chaz_ConfWriter_add_global_def("INT32_C(n)", "n");
-                }
-                else {
-                    sprintf(scratch, "n##%s", i32_t_postfix);
-                    chaz_ConfWriter_add_global_def("INT32_C(n)", scratch);
-                }
-                sprintf(scratch, "n##%s", u32_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT32_C(n)", scratch);
+            chaz_ConfWriter_add_def(
+                "U64_TO_DOUBLE(num)",
+                "((num) & UINT64_C(0x8000000000000000) ? "
+                "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
+                "9223372036854775808.0 : "
+                "(double)(int64_t)(num))");
+        }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer typedefs. */
+
+    chaz_ConfWriter_start_module("IntegerTypes");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   int8_t
+         *   int16_t
+         *   int32_t
+         *   int64_t
+         *   uint8_t
+         *   uint16_t
+         *   uint32_t
+         *   uint64_t
+         */
+        if (has_8) {
+            chaz_ConfWriter_add_global_typedef("signed char", "int8_t");
+            chaz_ConfWriter_add_global_typedef("unsigned char", "uint8_t");
+        }
+        if (has_16) {
+            chaz_ConfWriter_add_global_typedef("signed short", "int16_t");
+            chaz_ConfWriter_add_global_typedef("unsigned short", "uint16_t");
+        }
+        if (has_32) {
+            chaz_ConfWriter_add_global_typedef(i32_t_type, "int32_t");
+            sprintf(scratch, "unsigned %s", i32_t_type);
+            chaz_ConfWriter_add_global_typedef(scratch, "uint32_t");
+        }
+        if (has_64) {
+            chaz_ConfWriter_add_global_typedef(i64_t_type, "int64_t");
+            sprintf(scratch, "unsigned %s", i64_t_type);
+            chaz_ConfWriter_add_global_typedef(scratch, "uint64_t");
+        }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer limits. */
+
+    chaz_ConfWriter_start_module("IntegerLimits");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   INT8_MAX
+         *   INT16_MAX
+         *   INT32_MAX
+         *   INT64_MAX
+         *   INT8_MIN
+         *   INT16_MIN
+         *   INT32_MIN
+         *   INT64_MIN
+         *   UINT8_MAX
+         *   UINT16_MAX
+         *   UINT32_MAX
+         *   UINT64_MAX
+         *   SIZE_MAX
+         */
+        if (has_8) {
+            chaz_ConfWriter_add_global_def("INT8_MAX", "127");
+            chaz_ConfWriter_add_global_def("INT8_MIN", "-128");
+            chaz_ConfWriter_add_global_def("UINT8_MAX", "255");
+        }
+        if (has_16) {
+            chaz_ConfWriter_add_global_def("INT16_MAX", "32767");
+            chaz_ConfWriter_add_global_def("INT16_MIN", "-32768");
+            chaz_ConfWriter_add_global_def("UINT16_MAX", "65535");
+        }
+        if (has_32) {
+            chaz_ConfWriter_add_global_def("INT32_MAX", "2147483647");
+            chaz_ConfWriter_add_global_def("INT32_MIN", "(-INT32_MAX-1)");
+            chaz_ConfWriter_add_global_def("UINT32_MAX", "4294967295U");
+        }
+        if (has_64) {
+            sprintf(scratch, "9223372036854775807%s", i64_t_postfix);
+            chaz_ConfWriter_add_global_def("INT64_MAX", scratch);
+            chaz_ConfWriter_add_global_def("INT64_MIN", "(-INT64_MAX-1)");
+            sprintf(scratch, "18446744073709551615%s", u64_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT64_MAX", scratch);
+        }
+        chaz_ConfWriter_add_global_def("SIZE_MAX", "((size_t)-1)");
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer literals. */
+
+    chaz_ConfWriter_start_module("IntegerLiterals");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   INT32_C
+         *   INT64_C
+         *   UINT32_C
+         *   UINT64_C
+         */
+        if (has_32) {
+            if (strcmp(i32_t_postfix, "") == 0) {
+                chaz_ConfWriter_add_global_def("INT32_C(n)", "n");
             }
-            if (has_64) {
-                chaz_ConfWriter_add_global_typedef(i64_t_type, "int64_t");
-                sprintf(scratch, "unsigned %s", i64_t_type);
-                chaz_ConfWriter_add_global_typedef(scratch, "uint64_t");
-                sprintf(scratch, "9223372036854775807%s", i64_t_postfix);
-                chaz_ConfWriter_add_global_def("INT64_MAX", scratch);
-                chaz_ConfWriter_add_global_def("INT64_MIN", "(-INT64_MAX-1)");
-                sprintf(scratch, "18446744073709551615%s", u64_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT64_MAX", scratch);
-                sprintf(scratch, "n##%s", i64_t_postfix);
-                chaz_ConfWriter_add_global_def("INT64_C(n)", scratch);
-                sprintf(scratch, "n##%s", u64_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT64_C(n)", scratch);
+            else {
+                sprintf(scratch, "n##%s", i32_t_postfix);
+                chaz_ConfWriter_add_global_def("INT32_C(n)", scratch);
             }
-            chaz_ConfWriter_add_global_def("SIZE_MAX", "((size_t)-1)");
+            sprintf(scratch, "n##%s", u32_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT32_C(n)", scratch);
         }
+        if (has_64) {
+            sprintf(scratch, "n##%s", i64_t_postfix);
+            chaz_ConfWriter_add_global_def("INT64_C(n)", scratch);
+            sprintf(scratch, "n##%s", u64_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT64_C(n)", scratch);
+        }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer format strings. */
 
-        /* Create the PRId64 and PRIu64 printf macros. */
+    chaz_ConfWriter_start_module("IntegerFormatStrings");
+
+    if (has_inttypes) {
+        chaz_ConfWriter_add_sys_include("inttypes.h");
+    }
+    else {
+        /* We support only the following subset of inttypes.h
+         *   PRId64
+         *   PRIu64
+         */
         if (has_64) {
             int i;
             const char *options[] = {
@@ -5853,32 +5994,6 @@ chaz_Integers_run(void) {
         }
     }
 
-    /* Create macro for promoting pointers to integers. */
-    if (has_64) {
-        if (sizeof_ptr == 8) {
-            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
-                                    "((int64_t)(uint64_t)(ptr))");
-        }
-        else {
-            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
-                                    "((int64_t)(uint32_t)(ptr))");
-        }
-    }
-
-    /* Create macro for converting uint64_t to double. */
-    if (can_convert_u64_to_double) {
-        chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)",
-                                "((double)(num))");
-    }
-    else {
-        chaz_ConfWriter_add_def(
-            "U64_TO_DOUBLE(num)",
-            "((num) & UINT64_C(0x8000000000000000) ? "
-            "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
-            "9223372036854775808.0 : "
-            "(double)(int64_t)(num))");
-    }
-
     chaz_ConfWriter_end_module();
 }
 
@@ -7023,6 +7138,13 @@ int main(int argc, const char **argv) {
         }
     }
 
+    /* Employ integer features but don't define stdint types in charmony.h. */
+    chaz_ConfWriter_append_conf(
+        "#define CHY_EMPLOY_INTEGERLIMITS\n"
+        "#define CHY_EMPLOY_INTEGERLITERALS\n"
+        "#define CHY_EMPLOY_INTEGERFORMATSTRINGS\n\n"
+    );
+
     /* Run probe modules. */
     chaz_BuildEnv_run();
     chaz_DirManip_run();


[lucy-commits] [02/15] git commit: refs/heads/install-c-library - Include stdarg.h unconditionally

Posted by nw...@apache.org.
Include stdarg.h unconditionally

It's part of C89.


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

Branch: refs/heads/install-c-library
Commit: 35d8cc931dcda2c3581318a9ffac7fcb9e4dba09
Parents: f2fc230
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 02:02:22 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 13:12:47 2013 +0200

----------------------------------------------------------------------
 charmonizer/charmonize.c                  |    5 -----
 clownfish/compiler/src/CFCBindCore.c      |    1 +
 clownfish/runtime/common/charmonizer.c    |    5 -----
 clownfish/runtime/common/charmonizer.main |    5 -----
 common/charmonizer.c                      |    5 -----
 common/charmonizer.main                   |    5 -----
 6 files changed, 1 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/35d8cc93/charmonizer/charmonize.c
----------------------------------------------------------------------
diff --git a/charmonizer/charmonize.c b/charmonizer/charmonize.c
index 8c32c5d..b31ea6e 100644
--- a/charmonizer/charmonize.c
+++ b/charmonizer/charmonize.c
@@ -140,11 +140,6 @@ int main(int argc, char **argv) {
         "#endif\n\n"
     );
     chaz_ConfWriter_append_conf(
-        "#ifdef CHY_HAS_STDARG_H\n"
-        "  #include <stdarg.h>\n"
-        "#endif\n\n"
-    );
-    chaz_ConfWriter_append_conf(
         "#ifdef CHY_HAS_ALLOCA_H\n"
         "  #include <alloca.h>\n"
         "#elif defined(CHY_HAS_MALLOC_H)\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/35d8cc93/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index eff20eb..2959349 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -157,6 +157,7 @@ S_write_parcel_h(CFCBindCore *self) {
         "extern \"C\" {\n"
         "#endif\n"
         "\n"
+        "#include <stdarg.h>\n"
         "#include <stddef.h>\n"
         "#include \"charmony.h\"\n"
         "#include \"hostdefs.h\"\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/35d8cc93/clownfish/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/common/charmonizer.c b/clownfish/runtime/common/charmonizer.c
index f5fc0ab..d494373 100644
--- a/clownfish/runtime/common/charmonizer.c
+++ b/clownfish/runtime/common/charmonizer.c
@@ -6725,11 +6725,6 @@ int main(int argc, const char **argv) {
         "#endif\n\n"
     );
     chaz_ConfWriter_append_conf(
-        "#ifdef CHY_HAS_STDARG_H\n"
-        "  #include <stdarg.h>\n"
-        "#endif\n\n"
-    );
-    chaz_ConfWriter_append_conf(
         "#ifdef CHY_HAS_ALLOCA_H\n"
         "  #include <alloca.h>\n"
         "#elif defined(CHY_HAS_MALLOC_H)\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/35d8cc93/clownfish/runtime/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/clownfish/runtime/common/charmonizer.main b/clownfish/runtime/common/charmonizer.main
index 4c72ebe..850c7c3 100644
--- a/clownfish/runtime/common/charmonizer.main
+++ b/clownfish/runtime/common/charmonizer.main
@@ -128,11 +128,6 @@ int main(int argc, const char **argv) {
         "#endif\n\n"
     );
     chaz_ConfWriter_append_conf(
-        "#ifdef CHY_HAS_STDARG_H\n"
-        "  #include <stdarg.h>\n"
-        "#endif\n\n"
-    );
-    chaz_ConfWriter_append_conf(
         "#ifdef CHY_HAS_ALLOCA_H\n"
         "  #include <alloca.h>\n"
         "#elif defined(CHY_HAS_MALLOC_H)\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/35d8cc93/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/common/charmonizer.c b/common/charmonizer.c
index 3b51644..e065c93 100644
--- a/common/charmonizer.c
+++ b/common/charmonizer.c
@@ -7046,11 +7046,6 @@ int main(int argc, const char **argv) {
         "#endif\n\n"
     );
     chaz_ConfWriter_append_conf(
-        "#ifdef CHY_HAS_STDARG_H\n"
-        "  #include <stdarg.h>\n"
-        "#endif\n\n"
-    );
-    chaz_ConfWriter_append_conf(
         "#ifdef CHY_HAS_ALLOCA_H\n"
         "  #include <alloca.h>\n"
         "#elif defined(CHY_HAS_MALLOC_H)\n"

http://git-wip-us.apache.org/repos/asf/lucy/blob/35d8cc93/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/common/charmonizer.main b/common/charmonizer.main
index f0cad62..e357203 100644
--- a/common/charmonizer.main
+++ b/common/charmonizer.main
@@ -449,11 +449,6 @@ int main(int argc, const char **argv) {
         "#endif\n\n"
     );
     chaz_ConfWriter_append_conf(
-        "#ifdef CHY_HAS_STDARG_H\n"
-        "  #include <stdarg.h>\n"
-        "#endif\n\n"
-    );
-    chaz_ConfWriter_append_conf(
         "#ifdef CHY_HAS_ALLOCA_H\n"
         "  #include <alloca.h>\n"
         "#elif defined(CHY_HAS_MALLOC_H)\n"


[lucy-commits] [06/15] git commit: refs/heads/install-c-library - Split up Charmonizer integer modules

Posted by nw...@apache.org.
Split up Charmonizer integer modules

This will allow us to create a charmony.h which doesn't define the
stdint types.


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

Branch: refs/heads/install-c-library
Commit: 92dbd8a4a5f41378143abb82d899adc212496970
Parents: 4d15081
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 18:57:18 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 19:07:36 2013 +0200

----------------------------------------------------------------------
 charmonizer/src/Charmonizer/Probe/Integers.c |  280 ++++++++++++---------
 1 files changed, 167 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/92dbd8a4/charmonizer/src/Charmonizer/Probe/Integers.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe/Integers.c b/charmonizer/src/Charmonizer/Probe/Integers.c
index a326eed..3f44097 100644
--- a/charmonizer/src/Charmonizer/Probe/Integers.c
+++ b/charmonizer/src/Charmonizer/Probe/Integers.c
@@ -61,7 +61,7 @@ static const char chaz_Integers_u64_to_double_code[] =
     CHAZ_QUOTE(  #include <stdio.h>                        )
     CHAZ_QUOTE(  int main()                                )
     CHAZ_QUOTE(  {                                         )
-    CHAZ_QUOTE(      unsigned __int64 int_num = 0;         )
+    CHAZ_QUOTE(      unsigned %s int_num = 0;              )
     CHAZ_QUOTE(      double float_num;                     )
     CHAZ_QUOTE(      float_num = (double)int_num;          )
     CHAZ_QUOTE(      printf("%%f\n", float_num);           )
@@ -218,13 +218,6 @@ chaz_Integers_run(void) {
         }
     }
 
-    /* Determine whether conversion of unsigned __int64 to double works */
-    if (has___int64) {
-        if (!chaz_CC_test_compile(chaz_Integers_u64_to_double_code)) {
-            can_convert_u64_to_double = false;
-        }
-    }
-
     /* Write out some conditional defines. */
     if (has_inttypes) {
         chaz_ConfWriter_add_def("HAS_INTTYPES_H", NULL);
@@ -273,92 +266,179 @@ chaz_Integers_run(void) {
         chaz_ConfWriter_add_def("HAS_INT64_T", NULL);
     }
 
-    /* Write typedefs, maximums/minimums and literals macros. */
-    if (has_inttypes) {
-        chaz_ConfWriter_add_sys_include("inttypes.h");
+    /* Create macro for promoting pointers to integers. */
+    if (has_64) {
+        if (sizeof_ptr == 8) {
+            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
+                                    "((int64_t)(uint64_t)(ptr))");
+        }
+        else {
+            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
+                                    "((int64_t)(uint32_t)(ptr))");
+        }
     }
-    else {
-        if (has_stdint) {
-            chaz_ConfWriter_add_sys_include("stdint.h");
+
+    /* Create macro for converting uint64_t to double. */
+    if (has_64) {
+        /*
+         * Determine whether unsigned 64-bit integers can be converted to
+         * double. Older MSVC versions don't support this conversion.
+         */
+        sprintf(code_buf, chaz_Integers_u64_to_double_code, i64_t_type);
+        output = chaz_CC_capture_output(code_buf, &output_len);
+        if (output != NULL) {
+            chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)", "((double)(num))");
+            free(output);
         }
         else {
-            /* We support only the following subset of stdint.h
-             *   int8_t
-             *   int16_t
-             *   int32_t
-             *   int64_t
-             *   uint8_t
-             *   uint16_t
-             *   uint32_t
-             *   uint64_t
-             *   INT8_MAX
-             *   INT16_MAX
-             *   INT32_MAX
-             *   INT64_MAX
-             *   INT8_MIN
-             *   INT16_MIN
-             *   INT32_MIN
-             *   INT64_MIN
-             *   UINT8_MAX
-             *   UINT16_MAX
-             *   UINT32_MAX
-             *   UINT64_MAX
-             *   SIZE_MAX
-             *   INT32_C
-             *   INT64_C
-             *   UINT32_C
-             *   UINT64_C
-             */
-            if (has_8) {
-                chaz_ConfWriter_add_global_typedef("signed char", "int8_t");
-                chaz_ConfWriter_add_global_typedef("unsigned char", "uint8_t");
-                chaz_ConfWriter_add_global_def("INT8_MAX", "127");
-                chaz_ConfWriter_add_global_def("INT8_MIN", "-128");
-                chaz_ConfWriter_add_global_def("UINT8_MAX", "255");
-            }
-            if (has_16) {
-                chaz_ConfWriter_add_global_typedef("signed short", "int16_t");
-                chaz_ConfWriter_add_global_typedef("unsigned short",
-                                                   "uint16_t");
-                chaz_ConfWriter_add_global_def("INT16_MAX", "32767");
-                chaz_ConfWriter_add_global_def("INT16_MIN", "-32768");
-                chaz_ConfWriter_add_global_def("UINT16_MAX", "65535");
-            }
-            if (has_32) {
-                chaz_ConfWriter_add_global_typedef(i32_t_type, "int32_t");
-                sprintf(scratch, "unsigned %s", i32_t_type);
-                chaz_ConfWriter_add_global_typedef(scratch, "uint32_t");
-                chaz_ConfWriter_add_global_def("INT32_MAX", "2147483647");
-                chaz_ConfWriter_add_global_def("INT32_MIN", "(-INT32_MAX-1)");
-                chaz_ConfWriter_add_global_def("UINT32_MAX", "4294967295U");
-                if (strcmp(i32_t_postfix, "") == 0) {
-                    chaz_ConfWriter_add_global_def("INT32_C(n)", "n");
-                }
-                else {
-                    sprintf(scratch, "n##%s", i32_t_postfix);
-                    chaz_ConfWriter_add_global_def("INT32_C(n)", scratch);
-                }
-                sprintf(scratch, "n##%s", u32_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT32_C(n)", scratch);
+            chaz_ConfWriter_add_def(
+                "U64_TO_DOUBLE(num)",
+                "((num) & UINT64_C(0x8000000000000000) ? "
+                "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
+                "9223372036854775808.0 : "
+                "(double)(int64_t)(num))");
+        }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer typedefs. */
+
+    chaz_ConfWriter_start_module("IntegerTypes");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   int8_t
+         *   int16_t
+         *   int32_t
+         *   int64_t
+         *   uint8_t
+         *   uint16_t
+         *   uint32_t
+         *   uint64_t
+         */
+        if (has_8) {
+            chaz_ConfWriter_add_global_typedef("signed char", "int8_t");
+            chaz_ConfWriter_add_global_typedef("unsigned char", "uint8_t");
+        }
+        if (has_16) {
+            chaz_ConfWriter_add_global_typedef("signed short", "int16_t");
+            chaz_ConfWriter_add_global_typedef("unsigned short", "uint16_t");
+        }
+        if (has_32) {
+            chaz_ConfWriter_add_global_typedef(i32_t_type, "int32_t");
+            sprintf(scratch, "unsigned %s", i32_t_type);
+            chaz_ConfWriter_add_global_typedef(scratch, "uint32_t");
+        }
+        if (has_64) {
+            chaz_ConfWriter_add_global_typedef(i64_t_type, "int64_t");
+            sprintf(scratch, "unsigned %s", i64_t_type);
+            chaz_ConfWriter_add_global_typedef(scratch, "uint64_t");
+        }
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer limits. */
+
+    chaz_ConfWriter_start_module("IntegerLimits");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   INT8_MAX
+         *   INT16_MAX
+         *   INT32_MAX
+         *   INT64_MAX
+         *   INT8_MIN
+         *   INT16_MIN
+         *   INT32_MIN
+         *   INT64_MIN
+         *   UINT8_MAX
+         *   UINT16_MAX
+         *   UINT32_MAX
+         *   UINT64_MAX
+         *   SIZE_MAX
+         */
+        if (has_8) {
+            chaz_ConfWriter_add_global_def("INT8_MAX", "127");
+            chaz_ConfWriter_add_global_def("INT8_MIN", "-128");
+            chaz_ConfWriter_add_global_def("UINT8_MAX", "255");
+        }
+        if (has_16) {
+            chaz_ConfWriter_add_global_def("INT16_MAX", "32767");
+            chaz_ConfWriter_add_global_def("INT16_MIN", "-32768");
+            chaz_ConfWriter_add_global_def("UINT16_MAX", "65535");
+        }
+        if (has_32) {
+            chaz_ConfWriter_add_global_def("INT32_MAX", "2147483647");
+            chaz_ConfWriter_add_global_def("INT32_MIN", "(-INT32_MAX-1)");
+            chaz_ConfWriter_add_global_def("UINT32_MAX", "4294967295U");
+        }
+        if (has_64) {
+            sprintf(scratch, "9223372036854775807%s", i64_t_postfix);
+            chaz_ConfWriter_add_global_def("INT64_MAX", scratch);
+            chaz_ConfWriter_add_global_def("INT64_MIN", "(-INT64_MAX-1)");
+            sprintf(scratch, "18446744073709551615%s", u64_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT64_MAX", scratch);
+        }
+        chaz_ConfWriter_add_global_def("SIZE_MAX", "((size_t)-1)");
+    }
+
+    chaz_ConfWriter_end_module();
+
+    /* Integer literals. */
+
+    chaz_ConfWriter_start_module("IntegerLiterals");
+
+    if (has_stdint) {
+        chaz_ConfWriter_add_sys_include("stdint.h");
+    }
+    else {
+        /* We support only the following subset of stdint.h
+         *   INT32_C
+         *   INT64_C
+         *   UINT32_C
+         *   UINT64_C
+         */
+        if (has_32) {
+            if (strcmp(i32_t_postfix, "") == 0) {
+                chaz_ConfWriter_add_global_def("INT32_C(n)", "n");
             }
-            if (has_64) {
-                chaz_ConfWriter_add_global_typedef(i64_t_type, "int64_t");
-                sprintf(scratch, "unsigned %s", i64_t_type);
-                chaz_ConfWriter_add_global_typedef(scratch, "uint64_t");
-                sprintf(scratch, "9223372036854775807%s", i64_t_postfix);
-                chaz_ConfWriter_add_global_def("INT64_MAX", scratch);
-                chaz_ConfWriter_add_global_def("INT64_MIN", "(-INT64_MAX-1)");
-                sprintf(scratch, "18446744073709551615%s", u64_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT64_MAX", scratch);
-                sprintf(scratch, "n##%s", i64_t_postfix);
-                chaz_ConfWriter_add_global_def("INT64_C(n)", scratch);
-                sprintf(scratch, "n##%s", u64_t_postfix);
-                chaz_ConfWriter_add_global_def("UINT64_C(n)", scratch);
+            else {
+                sprintf(scratch, "n##%s", i32_t_postfix);
+                chaz_ConfWriter_add_global_def("INT32_C(n)", scratch);
             }
-            chaz_ConfWriter_add_global_def("SIZE_MAX", "((size_t)-1)");
+            sprintf(scratch, "n##%s", u32_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT32_C(n)", scratch);
+        }
+        if (has_64) {
+            sprintf(scratch, "n##%s", i64_t_postfix);
+            chaz_ConfWriter_add_global_def("INT64_C(n)", scratch);
+            sprintf(scratch, "n##%s", u64_t_postfix);
+            chaz_ConfWriter_add_global_def("UINT64_C(n)", scratch);
         }
+    }
+
+    chaz_ConfWriter_end_module();
 
-        /* Create the PRId64 and PRIu64 printf macros. */
+    /* Integer format strings. */
+
+    chaz_ConfWriter_start_module("IntegerFormatStrings");
+
+    if (has_inttypes) {
+        chaz_ConfWriter_add_sys_include("inttypes.h");
+    }
+    else {
+        /* We support only the following subset of inttypes.h
+         *   PRId64
+         *   PRIu64
+         */
         if (has_64) {
             int i;
             const char *options[] = {
@@ -397,32 +477,6 @@ chaz_Integers_run(void) {
         }
     }
 
-    /* Create macro for promoting pointers to integers. */
-    if (has_64) {
-        if (sizeof_ptr == 8) {
-            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
-                                    "((int64_t)(uint64_t)(ptr))");
-        }
-        else {
-            chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
-                                    "((int64_t)(uint32_t)(ptr))");
-        }
-    }
-
-    /* Create macro for converting uint64_t to double. */
-    if (can_convert_u64_to_double) {
-        chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)",
-                                "((double)(num))");
-    }
-    else {
-        chaz_ConfWriter_add_def(
-            "U64_TO_DOUBLE(num)",
-            "((num) & UINT64_C(0x8000000000000000) ? "
-            "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
-            "9223372036854775808.0 : "
-            "(double)(int64_t)(num))");
-    }
-
     chaz_ConfWriter_end_module();
 }
 


[lucy-commits] [05/15] git commit: refs/heads/install-c-library - Don't use stdint types in Charmonizer::Probe::Floats

Posted by nw...@apache.org.
Don't use stdint types in Charmonizer::Probe::Floats

Use a char array to hold the floating point representations of special
values. This is needed for the upcoming changes that add the ability to
create a charmony.h which doesn't define the stdint types.


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

Branch: refs/heads/install-c-library
Commit: 4d15081723a18710f4c5685f9f9aa621c1107759
Parents: 35d8cc9
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 17:14:46 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 17:19:51 2013 +0200

----------------------------------------------------------------------
 charmonizer/src/Charmonizer/Probe/Floats.c |   37 ++++++++++++++++++-----
 1 files changed, 29 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/4d150817/charmonizer/src/Charmonizer/Probe/Floats.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe/Floats.c b/charmonizer/src/Charmonizer/Probe/Floats.c
index b78ec00..6c3969d 100644
--- a/charmonizer/src/Charmonizer/Probe/Floats.c
+++ b/charmonizer/src/Charmonizer/Probe/Floats.c
@@ -27,14 +27,35 @@ chaz_Floats_run(void) {
     chaz_ConfWriter_start_module("Floats");
 
     chaz_ConfWriter_append_conf(
-        "typedef union { uint32_t i; float f; } chy_floatu32;\n"
-        "typedef union { uint64_t i; double d; } chy_floatu64;\n"
-        "static const chy_floatu32 chy_f32inf    = {UINT32_C(0x7f800000)};\n"
-        "static const chy_floatu32 chy_f32neginf = {UINT32_C(0xff800000)};\n"
-        "static const chy_floatu32 chy_f32nan    = {UINT32_C(0x7fc00000)};\n"
-        "static const chy_floatu64 chy_f64inf    = {UINT64_C(0x7ff0000000000000)};\n"
-        "static const chy_floatu64 chy_f64neginf = {UINT64_C(0xfff0000000000000)};\n"
-        "static const chy_floatu64 chy_f64nan    = {UINT64_C(0x7ff8000000000000)};\n"
+        "typedef union { unsigned char c[4]; float f; } chy_floatu32;\n"
+        "typedef union { unsigned char c[8]; double d; } chy_floatu64;\n"
+        "#ifdef CHY_BIG_END\n"
+        "static const chy_floatu32 chy_f32inf\n"
+        "    = { { 0x7F, 0x80, 0, 0 } };\n"
+        "static const chy_floatu32 chy_f32neginf\n"
+        "    = { { 0xFF, 0x80, 0, 0 } };\n"
+        "static const chy_floatu32 chy_f32nan\n"
+        "    = { { 0x7F, 0xC0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64inf\n"
+        "    = { { 0x7F, 0xF0, 0, 0, 0, 0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64neginf\n"
+        "    = { { 0xFF, 0xF0, 0, 0, 0, 0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64nan\n"
+        "    = { { 0x7F, 0xF8, 0, 0, 0, 0, 0, 0 } };\n"
+        "#else /* BIG_END */\n"
+        "static const chy_floatu32 chy_f32inf\n"
+        "    = { { 0, 0, 0x80, 0x7F } };\n"
+        "static const chy_floatu32 chy_f32neginf\n"
+        "    = { { 0, 0, 0x80, 0xFF } };\n"
+        "static const chy_floatu32 chy_f32nan\n"
+        "    = { { 0, 0, 0xC0, 0x7F } };\n"
+        "static const chy_floatu64 chy_f64inf\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF0, 0x7F } };\n"
+        "static const chy_floatu64 chy_f64neginf\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF0, 0xFF } };\n"
+        "static const chy_floatu64 chy_f64nan\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF8, 0x7F } };\n"
+        "#endif /* BIG_END */\n"
     );
     chaz_ConfWriter_add_def("F32_INF", "(chy_f32inf.f)");
     chaz_ConfWriter_add_def("F32_NEGINF", "(chy_f32neginf.f)");


[lucy-commits] [13/15] git commit: refs/heads/install-c-library - Preliminary installation script

Posted by nw...@apache.org.
Preliminary installation script

Might be merged into Makefile later.


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

Branch: refs/heads/install-c-library
Commit: 174f42b2c9a889dcc3fed82ba8ec99ab4e511768
Parents: a70454f
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri May 17 21:00:41 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 19:27:44 2013 +0200

----------------------------------------------------------------------
 c/install.sh |   76 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/174f42b2/c/install.sh
----------------------------------------------------------------------
diff --git a/c/install.sh b/c/install.sh
new file mode 100755
index 0000000..53e11c4
--- /dev/null
+++ b/c/install.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+set -e
+
+version=0.3.0
+major_version=0.3
+
+function usage()
+{
+    echo "Usage: install.sh --prefix path"
+}
+
+while [ -n "${1+set}" ]; do
+    case "$1" in
+        -h|--help|-\?)
+            usage
+            exit
+            ;;
+        --prefix)
+            if [ -z "${2+set}" ]; then
+                echo "--prefix requires an argument."
+                exit 1
+            fi
+            prefix=$2
+            shift 2
+            ;;
+        *)
+            echo "Invalid option: '$1'" 1>&2
+            usage
+            exit 1
+            ;;
+    esac
+done
+
+if [ -z "$prefix" ]; then
+    echo "No prefix specified."
+    usage
+    exit 1
+fi
+
+case $(uname) in
+    Darwin*)
+        lib_file=liblucy.$version.dylib
+        if [ ! -f $lib_file ]; then
+            echo "$lib_file not found. Did you run make?"
+            exit 1
+        fi
+        mkdir -p $prefix/lib
+        cp $lib_file $prefix/lib
+        install_name=$prefix/lib/liblucy.$major_version.dylib
+        ln -sf $lib_file $install_name
+        ln -sf $lib_file $prefix/lib/liblucy.dylib
+        install_name_tool -id $install_name $prefix/lib/$lib_file
+        ;;
+    *)
+        lib_file=liblucy.so.$version
+        if [ ! -f $lib_file ]; then
+            echo "$lib_file not found. Did you run make?"
+            exit 1
+        fi
+        mkdir -p $prefix/lib
+        cp $lib_file $prefix/lib
+        soname=liblucy.so.$major_version
+        ln -sf $lib_file $prefix/lib/$soname
+        ln -sf $soname $prefix/lib/liblucy.so
+        ;;
+esac
+
+mkdir -p $prefix/include
+cp autogen/include/cfish_hostdefs.h $prefix/include
+cp autogen/include/lucy_parcel.h $prefix/include
+cp -R autogen/include/Clownfish $prefix/include
+cp -R autogen/include/Lucy $prefix/include
+cp -R autogen/include/LucyX $prefix/include
+
+cp -R autogen/man $prefix
+


[lucy-commits] [15/15] git commit: refs/heads/install-c-library - Sample program using the C library

Posted by nw...@apache.org.
Sample program using the C library


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

Branch: refs/heads/install-c-library
Commit: 27018f3bad5155fba446c3083d86f2cf641eb5ab
Parents: acb55b7
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 21:19:19 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 21:19:19 2013 +0200

----------------------------------------------------------------------
 c/sample/getting_started.c |  189 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 189 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/27018f3b/c/sample/getting_started.c
----------------------------------------------------------------------
diff --git a/c/sample/getting_started.c b/c/sample/getting_started.c
new file mode 100644
index 0000000..0f1f637
--- /dev/null
+++ b/c/sample/getting_started.c
@@ -0,0 +1,189 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Sample program to get started with the Apache Lucy C library.
+ *
+ * Creates an index with a few documents and conducts a few searches.
+ *
+ * If $PREFIX points to your installation directory, it can be compiled with:
+ *
+ *     c99 \
+ *         getting_started.c \
+ *         -I $PREFIX/include -L $PREFIX/lib -l lucy \
+ *         -o getting_started
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#define LUCY_USE_SHORT_NAMES
+#include "Clownfish/CharBuf.h"
+#include "Lucy/Analysis/EasyAnalyzer.h"
+#include "Lucy/Document/Doc.h"
+#include "Lucy/Document/HitDoc.h"
+#include "Lucy/Index/Indexer.h"
+#include "Lucy/Plan/FullTextType.h"
+#include "Lucy/Plan/Schema.h"
+#include "Lucy/Search/Hits.h"
+#include "Lucy/Search/IndexSearcher.h"
+
+static Schema*
+S_create_schema();
+
+static void
+S_index_documents(Schema *schema, CharBuf *folder);
+
+static void
+S_add_document(Indexer *indexer, const char *title, const char *content);
+
+static void
+S_search(IndexSearcher *searcher, const char *query);
+
+int
+main() {
+    // Initialize the library.
+    lucy_bootstrap_parcel();
+
+    Schema  *schema = S_create_schema();
+    CharBuf *folder = CB_newf("lucy_index");
+
+    S_index_documents(schema, folder);
+
+    IndexSearcher *searcher = IxSearcher_new((Obj*)folder);
+
+    S_search(searcher, "ullamco");
+    S_search(searcher, "ut OR laborum");
+    S_search(searcher, "\"fugiat nulla\"");
+
+    DECREF(schema);
+    DECREF(folder);
+    DECREF(searcher);
+    return 0;
+}
+
+static Schema*
+S_create_schema() {
+    // Create a new schema.
+    Schema *schema = Schema_new();
+
+    // Create an analyzer.
+    CharBuf      *language = CB_newf("en");
+    EasyAnalyzer *analyzer = EasyAnalyzer_new(language);
+
+    // Specify fields.
+
+    FullTextType *type = FullTextType_new((Analyzer*)analyzer);
+
+    {
+        CharBuf *field_cb = CB_newf("title");
+        Schema_Spec_Field(schema, field_cb, (FieldType*)type);
+        DECREF(field_cb);
+    }
+
+    {
+        CharBuf *field_cb = CB_newf("content");
+        Schema_Spec_Field(schema, field_cb, (FieldType*)type);
+        DECREF(field_cb);
+    }
+
+    DECREF(language);
+    DECREF(analyzer);
+    DECREF(type);
+    return schema;
+}
+
+static void
+S_index_documents(Schema *schema, CharBuf *folder) {
+    Indexer *indexer = Indexer_new(schema, (Obj*)folder, NULL,
+                                   Indexer_CREATE | Indexer_TRUNCATE);
+
+    S_add_document(indexer, "Lorem ipsum",
+        "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do"
+        " eiusmod tempor incididunt ut labore et dolore magna aliqua."
+    );
+    S_add_document(indexer, "Ut enim",
+        "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris"
+        " nisi ut aliquip ex ea commodo consequat."
+    );
+    S_add_document(indexer, "Duis aute",
+        "Duis aute irure dolor in reprehenderit in voluptate velit essei"
+        " cillum dolore eu fugiat nulla pariatur."
+    );
+    S_add_document(indexer, "Excepteur sint",
+        "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui"
+        " officia deserunt mollit anim id est laborum."
+    );
+
+    Indexer_Commit(indexer);
+}
+
+static void
+S_add_document(Indexer *indexer, const char *title, const char *content) {
+    Doc *doc = Doc_new(NULL, 0);
+
+    {
+        // Store 'title' field   
+        CharBuf *field_cb = CB_newf("title");
+        CharBuf *value_cb = CB_new_from_utf8(title, strlen(title));
+        Doc_Store(doc, field_cb, (Obj*)value_cb);
+        DECREF(field_cb);
+        DECREF(value_cb);
+    }
+
+    {
+        // Store 'content' field   
+        CharBuf *field_cb = CB_newf("content");
+        CharBuf *value_cb = CB_new_from_utf8(content, strlen(content));
+        Doc_Store(doc, field_cb, (Obj*)value_cb);
+        DECREF(field_cb);
+        DECREF(value_cb);
+    }
+
+    Indexer_Add_Doc(indexer, doc, 1.0);
+
+    DECREF(doc);
+}
+
+static void
+S_search(IndexSearcher *searcher, const char *query) {
+    printf("Searching for: %s\n", query);
+
+    // Execute search query.
+    CharBuf *query_cb = CB_new_from_utf8(query, strlen(query));
+    Hits    *hits     = IxSearcher_Hits(searcher, (Obj*)query_cb, 0, 10, NULL);
+
+    CharBuf *field_cb = CB_newf("title");
+    HitDoc  *hit;
+    int i = 1;
+
+    // Loop over search results.
+    while (NULL != (hit = Hits_Next(hits))) {
+        CharBuf *value_cb = (CharBuf*)HitDoc_Extract(hit, field_cb, NULL);
+
+        printf("Result %d: %s\n", i, CB_Get_Ptr8(value_cb));
+
+        DECREF(hit);
+        i++;
+    }
+
+    printf("\n");
+
+    DECREF(query_cb);
+    DECREF(hits);
+    DECREF(field_cb);
+}
+


[lucy-commits] [10/15] git commit: refs/heads/install-c-library - Switch from CHY_{IM|EX}PORT to CFISH_{IM|EX}PORT

Posted by nw...@apache.org.
Switch from CHY_{IM|EX}PORT to CFISH_{IM|EX}PORT


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

Branch: refs/heads/install-c-library
Commit: 4d99bca18fa605e73ad263d3d85599ba9a728663
Parents: 7c9638e
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 12:41:04 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat May 18 19:15:56 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCBindCore.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/4d99bca1/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index 392a5ff..cd2aed8 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -180,9 +180,9 @@ S_write_parcel_h(CFCBindCore *self) {
         "#include \"hostdefs.h\"\n"
         "\n"
         "#ifdef CFP_LUCY\n"
-        "  #define LUCY_VISIBLE CHY_EXPORT\n"
+        "  #define LUCY_VISIBLE CFISH_EXPORT\n"
         "#else\n"
-        "  #define LUCY_VISIBLE CHY_IMPORT\n"
+        "  #define LUCY_VISIBLE CFISH_IMPORT\n"
         "#endif\n"
         "\n"
         "%s\n"