lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r467236 - in /lucene/lucy/trunk/charmonizer: ./ src/ src/Charmonizer/Core/ src/Charmonizer/Modules/
Date Tue, 24 Oct 2006 04:18:58 GMT
Author: marvin
Date: Mon Oct 23 21:18:57 2006
New Revision: 467236

URL: http://svn.apache.org/viewvc?view=rev&rev=467236
Log:
Add facilities for writing _charm_test.h, which will be used for testing.

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

Modified: lucene/lucy/trunk/charmonizer/charmonize.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/charmonize.c?view=diff&rev=467236&r1=467235&r2=467236
==============================================================================
--- lucene/lucy/trunk/charmonizer/charmonize.c (original)
+++ lucene/lucy/trunk/charmonizer/charmonize.c Mon Oct 23 21:18:57 2006
@@ -87,6 +87,7 @@
     /* set up Charmonizer */
     chaz_init(os_name, cc_command, cc_flags);
     chaz_set_prefixes("LUCY_", "Lucy_", "lucy_", "lucy_");
+    chaz_write_charm_test_h();
 
     /* clean up */
     free(infile_str);

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer.charm?view=diff&rev=467236&r1=467235&r2=467236
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer.charm Mon Oct 23 21:18:57 2006
@@ -48,6 +48,10 @@
 {
     want_short_names = true;
 
+    if (want_charm_test_h)
+        die("chaz_set_prefixes must be called prior to "
+            "chaz_write_charm_test_h()");
+
     free(constant_prefix);
     free(macro_prefix);
     free(typedef_prefix);
@@ -67,6 +71,11 @@
 char*
 chaz_slurp_file(char* filepath, size_t *len_ptr) {
     return slurp_file(filepath, len_ptr);
+}
+
+chaz_write_charm_test_h()
+{
+    ModHand_write_charm_test_h();
 }
 
 /**

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer.harm?view=diff&rev=467236&r1=467235&r2=467236
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer.harm Mon Oct 23 21:18:57 2006
@@ -35,6 +35,12 @@
 char*
 chaz_slurp_file(char* filepath, size_t *len_ptr);
 
+/* In addition to the main output, write symbols without prefixes to the file
+ * _charm_test.h in the current working directory.  This file is needed for
+ * testing Charmonizer's output using the files in Charmonizer/Test.
+ */
+chaz_write_charm_test_h();
+
 #endif /* include guard */
 
 /**

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.charm?view=diff&rev=467236&r1=467235&r2=467236
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.charm Mon Oct 23 21:18:57
2006
@@ -29,6 +29,9 @@
 struct chaz_OperSys  *chaz_ModHand_os = NULL;
 struct chaz_Compiler *chaz_ModHand_compiler = NULL;
 chaz_bool_t chaz_ModHand_charm_run_available = false;
+FILE* chaz_ModHand_charm_test_h_fh = NULL;
+chaz_bool_t chaz_ModHand_want_charm_test_h = false;
+
 char *constant_prefix = NULL;
 char *macro_prefix    = NULL;
 char *typedef_prefix  = NULL;
@@ -160,6 +163,22 @@
     return captured_output;
 }
 
+void
+chaz_ModHand_append_conf(FILE *conf_fh, char *fmt, ...)
+{
+    va_list args;
+
+    va_start(args, fmt);
+    vfprintf(conf_fh, fmt, args);
+    va_end(args);
+
+    if (want_charm_test_h) {
+        va_start(args, fmt);
+        vfprintf(charm_test_h_fh, fmt, args);
+        va_end(args);
+    }
+}
+
 static void
 clean_up_try()
 {
@@ -169,28 +188,41 @@
 }
 
 void
-chaz_ModHand_shorten_constant(FILE *conf_fh, const char *symbol)
+chaz_ModHand_shorten_constant(FILE *conf_fh, const char *sym)
 {
-    fprintf(conf_fh, "# define %s %s%s\n", symbol, constant_prefix, symbol); 
+    append_conf(conf_fh, "# define %s %s%s\n", sym, constant_prefix, sym); 
 }
 
 void
-chaz_ModHand_shorten_macro(FILE *conf_fh, const char *symbol)
+chaz_ModHand_shorten_macro(FILE *conf_fh, const char *sym)
 {
-    fprintf(conf_fh, "# define %s %s%s\n", symbol, macro_prefix, symbol); 
+    append_conf(conf_fh, "# define %s %s%s\n", sym, macro_prefix, sym); 
 }
 
 void
-chaz_ModHand_shorten_typedef(FILE *conf_fh, const char *symbol)
+chaz_ModHand_shorten_typedef(FILE *conf_fh, const char *sym)
 {
-    fprintf(conf_fh, "# define %s %s%s\n", symbol, typedef_prefix, symbol); 
+    append_conf(conf_fh, "# define %s %s%s\n", sym, typedef_prefix, sym); 
 }
 
 void
-chaz_ModHand_shorten_function(FILE *conf_fh, const char *symbol)
+chaz_ModHand_shorten_function(FILE *conf_fh, const char *sym)
 {
-    fprintf(conf_fh, "# define %s %s%s\n", symbol, function_prefix, symbol); 
+    append_conf(conf_fh, "# define %s %s%s\n", sym, function_prefix, sym); 
 }
+
+void
+chaz_ModHand_write_charm_test_h()
+{
+    charm_test_h_fh = fopen("_charm_test.h", "w+");
+    if (charm_test_h_fh == NULL)
+        die("Couldn't open '_charm_test.h': %s", strerror(errno));
+
+    fprintf(charm_test_h_fh, "#define %sUSE_SHORT_NAMES\n", constant_prefix);
+
+    want_charm_test_h = true;
+}
+
 
 /**
  * Copyright 2006 The Apache Software Foundation

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.harm?view=diff&rev=467236&r1=467235&r2=467236
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.harm Mon Oct 23 21:18:57
2006
@@ -22,6 +22,8 @@
 extern struct chaz_OperSys  *chaz_ModHand_os;
 extern struct chaz_Compiler *chaz_ModHand_compiler;
 extern chaz_bool_t chaz_ModHand_charm_run_available;
+extern FILE* chaz_ModHand_charm_test_h_fh;
+extern chaz_bool_t chaz_ModHand_want_charm_test_h;
 
 extern char *chaz_ModHand_constant_prefix;
 extern char *chaz_ModHand_macro_prefix;
@@ -44,15 +46,22 @@
 chaz_ModHand_capture_output(char *source, size_t source_len, 
                             size_t *output_len);
 
+
+/* First print output to the user-supplied filehandle.  Then, write output to
+ * _charm_test.h, if indicated.
+ */
+void
+chaz_ModHand_append_conf(FILE *conf_fh, char *fmt, ...);
+
 /* Print bookends delimiting a short names block.
  */
 #define Chaz_ModHand_Start_Short_Names(conf_fh) \
-    fprintf(conf_fh, "\n#ifdef %sUSE_SHORT_NAMES\n", \
-        chaz_ModHand_constant_prefix)
+    append_conf(conf_fh, \
+        "\n#ifdef %sUSE_SHORT_NAMES\n", chaz_ModHand_constant_prefix)
 
 #define Chaz_ModHand_End_Short_Names(conf_fh) \
-    fprintf(conf_fh, "#endif /* %sUSE_SHORT_NAMES */\n", \
-        chaz_ModHand_constant_prefix)
+    append_conf(conf_fh, \
+        "#endif /* %sUSE_SHORT_NAMES */\n", chaz_ModHand_constant_prefix)
 
 /* Define a shortened version of a constant symbol (minus the prefix);
  */
@@ -74,20 +83,25 @@
 void
 chaz_ModHand_shorten_function(FILE *conf_fh, const char *symbol);
 
+/* Signal Charmonizer that it should write _charm_test.h.
+ */
+void
+chaz_ModHand_write_charm_test_h();
+
 /* Print a "chapter heading" when starting a module. 
  */
 #define Chaz_ModHand_Start_Run(filehandle, module_name) \
     do { \
-        fprintf(filehandle, "\n/* %s */\n", module_name); \
+        append_conf(filehandle, "\n/* %s */\n", module_name); \
         if (verbosity > 0) \
             printf("Running %s module...\n", module_name); \
     } while (0)
 
-
 /* Leave a little whitespace at the end of each module.
  */
 #define Chaz_ModHand_End_Run(filehandle) \
-    fprintf(filehandle, "\n")
+    append_conf(filehandle, "\n")
+
 
 #ifdef CHAZ_USE_SHORT_NAMES
 # define TRY_SOURCE_PATH        CHAZ_MOD_HAND_TRY_SOURCE_PATH
@@ -96,6 +110,8 @@
 # define os                     chaz_ModHand_os
 # define compiler               chaz_ModHand_compiler
 # define charm_run_available    chaz_ModHand_charm_run_available
+# define charm_test_h_fh        chaz_ModHand_charm_test_h_fh
+# define want_charm_test_h      chaz_ModHand_want_charm_test_h
 # define constant_prefix        chaz_ModHand_constant_prefix
 # define macro_prefix           chaz_ModHand_macro_prefix
 # define typedef_prefix         chaz_ModHand_typedef_prefix
@@ -106,12 +122,14 @@
 # define Start_Short_Names      Chaz_ModHand_Start_Short_Names
 # define End_Short_Names        Chaz_ModHand_End_Short_Names
 # define capture_output         chaz_ModHand_capture_output 
+# define append_conf            chaz_ModHand_append_conf
 # define shorten_constant       chaz_ModHand_shorten_constant
 # define shorten_macro          chaz_ModHand_shorten_macro
 # define shorten_typedef        chaz_ModHand_shorten_typedef
 # define shorten_function       chaz_ModHand_shorten_function
 # define Start_Run              Chaz_ModHand_Start_Run
 # define End_Run                Chaz_ModHand_End_Run
+# define ModHand_write_charm_test_h chaz_ModHand_write_charm_test_h
 #endif
 
 #endif /* H_CHAZ_CORE */

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/FuncMacro.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/FuncMacro.charm?view=diff&rev=467236&r1=467235&r2=467236
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/FuncMacro.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/FuncMacro.charm Mon Oct 23 21:18:57
2006
@@ -58,7 +58,7 @@
         char *macro_text = has_iso_funcmac 
             ? "__func__"
             : "__FUNCTION__";
-        fprintf(conf_fh, 
+        append_conf(conf_fh, 
             "#define %sHAS_FUNC_MACRO\n"
             "#define %sFunc_Macro %s\n",
             constant_prefix, macro_prefix, macro_text);
@@ -66,11 +66,11 @@
 
     /* write out specific defines */
     if (has_iso_funcmac) {
-       fprintf(conf_fh, "#define %sHAS_ISO_FUNC_MACRO\n",
+       append_conf(conf_fh, "#define %sHAS_ISO_FUNC_MACRO\n",
            constant_prefix);
     }
     if (has_gnuc_funcmac) {
-       fprintf(conf_fh, "#define %sHAS_GNUC_FUNC_MACRO\n",
+        append_conf(conf_fh, "#define %sHAS_GNUC_FUNC_MACRO\n",
            constant_prefix);
     }
 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/Integers.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/Integers.charm?view=diff&rev=467236&r1=467235&r2=467236
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/Integers.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/Integers.charm Mon Oct 23 21:18:57
2006
@@ -71,9 +71,9 @@
 
     /* document endian-ness */
     if (machine_is_big_endian())
-        fprintf(conf_fh, "#define %sBIG_ENDIAN\n", constant_prefix);
+        append_conf(conf_fh, "#define %sBIG_ENDIAN\n", constant_prefix);
     else 
-        fprintf(conf_fh, "#define %sLITTLE_ENDIAN\n", constant_prefix);
+        append_conf(conf_fh, "#define %sLITTLE_ENDIAN\n", constant_prefix);
 
     /* Record sizeof() for several common integer types. */
     output = capture_output(sizes_code, strlen(sizes_code), &output_len);
@@ -108,14 +108,14 @@
 
     /* write out some conditional defines */
     if (has_inttypes) {
-        fprintf(conf_fh, "#define %sHAS_INTTYPES_H\n", constant_prefix);
+        append_conf(conf_fh, "#define %sHAS_INTTYPES_H\n", constant_prefix);
     }
     if (has_long_long) {
-        fprintf(conf_fh, "#define %sHAS_LONG_LONG\n", constant_prefix);
+        append_conf(conf_fh, "#define %sHAS_LONG_LONG\n", constant_prefix);
     }
 
     /* write out sizes */
-    fprintf(conf_fh, 
+    append_conf(conf_fh, 
         "#define %sSIZEOF_CHAR %d\n"
         "#define %sSIZEOF_SHORT %d\n"
         "#define %sSIZEOF_INT %d\n"
@@ -128,15 +128,15 @@
         constant_prefix, sizeof_ptr
     );
     if (has_long_long) {
-        fprintf(conf_fh, "#define %sSIZEOF_LONG_LONG %d\n",
+        append_conf(conf_fh, "#define %sSIZEOF_LONG_LONG %d\n",
             constant_prefix, sizeof_long_long);
     }
 
     /* write typedefs */
-    fprintf(conf_fh, "typedef int %sbool_t;\n", typedef_prefix);
+    append_conf(conf_fh, "typedef int %sbool_t;\n", typedef_prefix);
     if (sizeof_char == 1) {
         has_8 = true;
-        fprintf(conf_fh,
+        append_conf(conf_fh,
             "typedef char %si8_t;\n"
             "typedef unsigned char %su8_t;\n",
             typedef_prefix, typedef_prefix
@@ -144,7 +144,7 @@
     }
     if (sizeof_short == 2) {
         has_16 = true;
-        fprintf(conf_fh,
+        append_conf(conf_fh,
             "typedef short %si16_t;\n"
             "typedef unsigned short %su16_t;\n",
             typedef_prefix, typedef_prefix
@@ -153,7 +153,7 @@
     if (sizeof_int == 4 || sizeof_long == 4) {
         char *type = sizeof_int == 4 ? "int" : "long";
         has_32 = true;
-        fprintf(conf_fh,
+        append_conf(conf_fh,
             "typedef %s %si32_t;\n"
             "typedef unsigned %s %su32_t;\n",
             type, typedef_prefix, 
@@ -191,7 +191,7 @@
 
         /* we have 64-bit ints, so add the typedef */
         has_64 = true;
-        fprintf(conf_fh,
+        append_conf(conf_fh,
             "typedef %s %si64_t;\n"
             "typedef unsigned %s %su64_t;\n",
             type, typedef_prefix, 
@@ -210,7 +210,7 @@
             if (   output_len != 0 
                 && strcmp(output, "18446744073709551615") == 0
             ) {
-                fprintf(conf_fh, 
+                append_conf(conf_fh, 
                     "#define I64P \"%sd\"\n"
                     "#define U64P \"%su\"\n",
                     options[i], options[i]
@@ -222,7 +222,7 @@
     }
 
     /* true and false */
-    fprintf(conf_fh,
+    append_conf(conf_fh,
         "#ifndef true\n"
         "# define true 1\n"
         "#endif\n"

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/LargeFiles.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/LargeFiles.charm?view=diff&rev=467236&r1=467235&r2=467236
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/LargeFiles.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/LargeFiles.charm Mon Oct 23 21:18:57
2006
@@ -94,7 +94,7 @@
     }
 
     if (success) {
-        fprintf(conf_fh, 
+        append_conf(conf_fh, 
             "#define %sFTell %s\n" 
             "#define %sFSeek %s\n",
             function_prefix, ftell_command,

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/UnusedVars.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/UnusedVars.charm?view=diff&rev=467236&r1=467235&r2=467236
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/UnusedVars.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/UnusedVars.charm Mon Oct 23 21:18:57
2006
@@ -12,7 +12,7 @@
 {
     Start_Run(conf_fh, "UnusedVars");
     
-    fprintf(conf_fh, 
+    append_conf(conf_fh, 
         "#define %sUnused_Var(x) ((void)x)\n"
         "#define %sUnreachable_Return(type) return (type)0\n",
         macro_prefix, macro_prefix 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/VariadicMacros.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/VariadicMacros.charm?view=diff&rev=467236&r1=467235&r2=467236
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/VariadicMacros.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Modules/VariadicMacros.charm Mon Oct 23
21:18:57 2006
@@ -45,8 +45,9 @@
     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", 
+        append_conf(conf_fh, "#define %sHAS_VARIADIC_MACROS\n", 
+            constant_prefix);
+        append_conf(conf_fh, "#define %sHAS_ISO_VARIADIC_MACROS\n", 
             constant_prefix);
     }
 
@@ -56,10 +57,10 @@
         if (has_varmacros == false) {
             has_varmacros = true;
             has_gnuc_varmacros = true;
-            fprintf(conf_fh, "#define %sHAS_VARIADIC_MACROS\n", 
+            append_conf(conf_fh, "#define %sHAS_VARIADIC_MACROS\n", 
                 constant_prefix);
         }
-        fprintf(conf_fh, "#define %sHAS_GNUC_VARIADIC_MACROS\n", 
+        append_conf(conf_fh, "#define %sHAS_GNUC_VARIADIC_MACROS\n", 
             constant_prefix);
     }
 



Mime
View raw message