lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r464383 - in /lucene/lucy/trunk/charmonizer: ./ src/ src/Charmonizer/
Date Mon, 16 Oct 2006 05:35:29 GMT
Author: marvin
Date: Sun Oct 15 22:35:28 2006
New Revision: 464383

URL: http://svn.apache.org/viewvc?view=rev&rev=464383
Log:
Localize functionality for dealing with short names to each module, rather
than glomming it on at the end of charmonize.c.

Modified:
    lucene/lucy/trunk/charmonizer/charmonize.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.harm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/FuncMacro.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/LargeFiles.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/UnusedVars.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/VariadicMacros.charm

Modified: lucene/lucy/trunk/charmonizer/charmonize.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/charmonize.c?view=diff&rev=464383&r1=464382&r2=464383
==============================================================================
--- lucene/lucy/trunk/charmonizer/charmonize.c (original)
+++ lucene/lucy/trunk/charmonizer/charmonize.c Sun Oct 15 22:35:28 2006
@@ -156,28 +156,7 @@
 static void
 finish_conf_file(FILE *conf_fh) 
 {
-    fprintf(conf_fh,
-        "/* conf end */\n"
-        "#ifdef LUCY_USE_SHORT_NAMES\n"
-        "# define bool_t                    lucy_bool_t\n"
-        "# define i8_t                      lucy_i8_t\n"
-        "# define u8_t                      lucy_u8_t\n"
-        "# define i16_t                     lucy_i16_t\n"
-        "# define u16_t                     lucy_u16_t\n"
-        "# define i32_t                     lucy_i32_t\n"
-        "# define u32_t                     lucy_u32_t\n"
-        "# define i64_t                     lucy_i64_t\n"
-        "# define u64_t                     lucy_u64_t\n"
-        "# define Unused_Var(x)             Lucy_Unused_Var(x)\n"
-        "# define Unreachable_Return(type)  Lucy_Unreachable_Return(type)\n"
-        "# define FSeek                     lucy_FSeek\n"
-        "# define FTell                     lucy_FTell\n"
-        "#endif\n"
-    );
-
-    fprintf(conf_fh, 
-        "\n\n#endif /* H_LUCY_CONF */\n\n"
-    );
+    fprintf(conf_fh, "\n\n#endif /* H_LUCY_CONF */\n\n");
 }
 
 void 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer.charm?view=diff&rev=464383&r1=464382&r2=464383
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer.charm Sun Oct 15 22:35:28 2006
@@ -41,6 +41,8 @@
 void
 chaz_set_prefixes(char *constant_pre, char *macro_pre, char* typedef_pre,  
                   char *function_pre) {
+    want_short_names = true;
+
     free(constant_prefix);
     free(macro_prefix);
     free(typedef_prefix);

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm?view=diff&rev=464383&r1=464382&r2=464383
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm Sun Oct 15 22:35:28 2006
@@ -13,6 +13,7 @@
 char *typedef_prefix  = NULL;
 char *function_prefix = NULL;
 int   verbosity       = 1;
+chaz_bool_t want_short_names = false;
 
 static char *command_buf = NULL;
 static size_t command_buf_len = 0;
@@ -107,6 +108,30 @@
     remove(TARGET_PATH);
 
     return captured_output;
+}
+
+void
+shorten_constant(FILE *conf_fh, const char *symbol)
+{
+    fprintf(conf_fh, "# define %s %s%s\n", symbol, constant_prefix, symbol); 
+}
+
+void
+shorten_macro(FILE *conf_fh, const char *symbol)
+{
+    fprintf(conf_fh, "# define %s %s%s\n", symbol, macro_prefix, symbol); 
+}
+
+void
+shorten_typedef(FILE *conf_fh, const char *symbol)
+{
+    fprintf(conf_fh, "# define %s %s%s\n", symbol, typedef_prefix, symbol); 
+}
+
+void
+shorten_function(FILE *conf_fh, const char *symbol)
+{
+    fprintf(conf_fh, "# define %s %s%s\n", symbol, function_prefix, symbol); 
 }
 
 char*

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.harm?view=diff&rev=464383&r1=464382&r2=464383
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.harm Sun Oct 15 22:35:28 2006
@@ -28,6 +28,7 @@
 extern char *chaz_Core_typedef_prefix;
 extern char *chaz_Core_function_prefix;
 extern int chaz_Core_verbosity;
+extern chaz_bool_t chaz_Core_want_short_names;
 
 /* Write the "_charm.h" file used by every probe.
  */
@@ -42,6 +43,35 @@
 char*
 chaz_Core_capture_output(char *source, size_t source_len, size_t *output_len);
 
+/* Print bookends delimiting a short names block.
+ */
+#define Start_Short_Names(conf_fh) \
+    fprintf(conf_fh, "\n#ifdef %sUSE_SHORT_NAMES\n", chaz_Core_constant_prefix)
+
+#define End_Short_Names(conf_fh) \
+    fprintf(conf_fh, "#endif /* %sUSE_SHORT_NAMES */\n", \
+        chaz_Core_constant_prefix)
+
+/* Define a shortened version of a constant symbol (minus the prefix);
+ */
+void
+chaz_Core_shorten_constant(FILE *conf_fh, const char *symbol);
+
+/* Define a shortened version of a macro symbol (minuse the prefix);
+ */
+void
+chaz_Core_shorten_macro(FILE *conf_fh, const char *symbol);
+
+/* Define a shortened version of a typedef symbol (minuse the prefix);
+ */
+void
+chaz_Core_shorten_typedef(FILE *conf_fh, const char *symbol);
+
+/* Define a shortened version of a function symbol (minuse the prefix);
+ */
+void
+chaz_Core_shorten_function(FILE *conf_fh, const char *symbol);
+
 /* Read an entire file into memory.
  */
 char* 
@@ -102,8 +132,13 @@
 # define typedef_prefix         chaz_Core_typedef_prefix
 # define function_prefix        chaz_Core_function_prefix
 # define verbosity              chaz_Core_verbosity
+# define want_short_names       chaz_Core_want_short_names
 # define write_charm_h          chaz_Core_write_charm_h
 # define capture_output         chaz_Core_capture_output 
+# define shorten_constant       chaz_Core_shorten_constant
+# define shorten_macro          chaz_Core_shorten_macro
+# define shorten_typedef        chaz_Core_shorten_typedef
+# define shorten_function       chaz_Core_shorten_function
 # define slurp_file             chaz_Core_slurp_file 
 # define flength                chaz_Core_flength 
 # define die                    chaz_Core_die 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/FuncMacro.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/FuncMacro.charm?view=diff&rev=464383&r1=464382&r2=464383
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/FuncMacro.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/FuncMacro.charm Sun Oct 15 22:35:28 2006
@@ -73,6 +73,19 @@
            constant_prefix);
     }
 
+    if (want_short_names) {
+        Start_Short_Names(conf_fh);
+        if (has_iso_funcmac) 
+            shorten_constant(conf_fh, "HAS_ISO_FUNC_MACRO");
+        if (has_gnuc_funcmac)
+            shorten_constant(conf_fh, "HAS_GNUC_FUNC_MACRO");
+        if (has_iso_funcmac || has_gnuc_funcmac) {
+            shorten_constant(conf_fh, "HAS_FUNC_MACRO");
+            shorten_macro(conf_fh, "Func_Macro");
+        }
+        End_Short_Names(conf_fh);
+    }
+
     End_Run(conf_fh);
 }
 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm?view=diff&rev=464383&r1=464382&r2=464383
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm Sun Oct 15 22:35:28 2006
@@ -164,9 +164,41 @@
         "#endif\n"
     );
 
+    if (want_short_names) {
+        Start_Short_Names(conf_fh);
+
+        shorten_constant(conf_fh, "SIZEOF_CHAR");
+        shorten_constant(conf_fh, "SIZEOF_SHORT");
+        shorten_constant(conf_fh, "SIZEOF_LONG");
+        shorten_constant(conf_fh, "SIZEOF_INT");
+        shorten_constant(conf_fh, "SIZEOF_PTR");
+
+        if (has_long_long) {
+            shorten_constant(conf_fh, "HAS_LONG_LONG");
+            shorten_constant(conf_fh, "SIZEOF_LONG_LONG");
+        }
+
+        if (has_inttypes)
+            shorten_constant(conf_fh, "HAS_INTTYPES_H");
+
+        shorten_typedef(conf_fh, "bool_t");
+        shorten_typedef(conf_fh, "i8_t");
+        shorten_typedef(conf_fh, "u8_t");
+        shorten_typedef(conf_fh, "i16_t");
+        shorten_typedef(conf_fh, "u16_t");
+        shorten_typedef(conf_fh, "i32_t");
+        shorten_typedef(conf_fh, "u32_t");
+
+        if (sizeof_long == 8 || sizeof_long_long == 8) {
+            shorten_typedef(conf_fh, "i64_t");
+            shorten_typedef(conf_fh, "u64_t");
+        } 
+
+        End_Short_Names(conf_fh);
+    }
+    
     End_Run(conf_fh);
 }
-
 
 /**
  * Copyright 2006 The Apache Software Foundation

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/LargeFiles.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/LargeFiles.charm?view=diff&rev=464383&r1=464382&r2=464383
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/LargeFiles.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/LargeFiles.charm Sun Oct 15 22:35:28 2006
@@ -100,6 +100,13 @@
             function_prefix, fseek_command
         );
     }
+
+    if (want_short_names && success) {
+        Start_Short_Names(conf_fh);
+        shorten_function(conf_fh, "FTell");
+        shorten_function(conf_fh, "FSeek");
+        End_Short_Names(conf_fh);
+    }
     
     End_Run(conf_fh);
 }

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/UnusedVars.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/UnusedVars.charm?view=diff&rev=464383&r1=464382&r2=464383
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/UnusedVars.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/UnusedVars.charm Sun Oct 15 22:35:28 2006
@@ -17,6 +17,13 @@
         macro_prefix, macro_prefix 
     );
 
+    if (want_short_names) {
+        Start_Short_Names(conf_fh);
+        shorten_macro(conf_fh, "Unused_Var");
+        shorten_macro(conf_fh, "Unreachable_Return");
+        End_Short_Names(conf_fh);
+    }
+
     End_Run(conf_fh);
 }
 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/VariadicMacros.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/VariadicMacros.charm?view=diff&rev=464383&r1=464382&r2=464383
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/VariadicMacros.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/VariadicMacros.charm Sun Oct 15 22:35:28
2006
@@ -34,6 +34,8 @@
     char *output;
     size_t output_len;
     chaz_bool_t has_varmacros      = false;
+    chaz_bool_t has_iso_varmacros  = false;
+    chaz_bool_t has_gnuc_varmacros = false;
 
     Start_Run(conf_fh, "VariadicMacros");
 
@@ -41,6 +43,7 @@
     output = capture_output(iso_code, strlen(iso_code), &output_len);
     if (output != NULL) {
         has_varmacros = true;
+        has_iso_varmacros = true;
         fprintf(conf_fh, "#define %sHAS_VARIADIC_MACROS\n", constant_prefix);
         fprintf(conf_fh, "#define %sHAS_ISO_VARIADIC_MACROS\n", 
             constant_prefix);
@@ -51,11 +54,23 @@
     if (output != NULL) {
         if (has_varmacros == false) {
             has_varmacros = true;
+            has_gnuc_varmacros = true;
             fprintf(conf_fh, "#define %sHAS_VARIADIC_MACROS\n", 
                 constant_prefix);
         }
         fprintf(conf_fh, "#define %sHAS_GNUC_VARIADIC_MACROS\n", 
             constant_prefix);
+    }
+
+    if (want_short_names) {
+        Start_Short_Names(conf_fh);
+        if (has_varmacros)
+            shorten_constant(conf_fh, "HAS_VARIADIC_MACROS");
+        if (has_iso_varmacros)
+            shorten_constant(conf_fh, "HAS_ISO_VARIADIC_MACROS");
+        if (has_gnuc_varmacros)
+            shorten_constant(conf_fh, "HAS_GNUC_VARIADIC_MACROS");
+        End_Short_Names(conf_fh);
     }
 
     End_Run(conf_fh);



Mime
View raw message