[svn:parrot] r46934 - in trunk: compilers/imcc include/parrot src

plobsing at svn.parrot.org plobsing at svn.parrot.org
Mon May 24 02:07:30 UTC 2010


Author: plobsing
Date: Mon May 24 02:07:29 2010
New Revision: 46934
URL: https://trac.parrot.org/parrot/changeset/46934

Log:
wrap global const in a sub

Modified:
   trunk/compilers/imcc/main.c
   trunk/include/parrot/longopt.h
   trunk/src/longopt.c
   trunk/src/main.c

Modified: trunk/compilers/imcc/main.c
==============================================================================
--- trunk/compilers/imcc/main.c	Mon May 24 00:49:53 2010	(r46933)
+++ trunk/compilers/imcc/main.c	Mon May 24 02:07:29 2010	(r46934)
@@ -166,7 +166,7 @@
     /* default state: run pbc */
     SET_STATE_RUN_PBC(interp);
 
-    while (longopt_get(interp, argc, argv, Parrot_cmd_options, &opt) > 0) {
+    while (longopt_get(interp, argc, argv, Parrot_cmd_options(), &opt) > 0) {
         switch (opt.opt_id) {
           case 'd':
             if (opt.opt_arg && is_all_hex_digits(opt.opt_arg)) {

Modified: trunk/include/parrot/longopt.h
==============================================================================
--- trunk/include/parrot/longopt.h	Mon May 24 00:49:53 2010	(r46933)
+++ trunk/include/parrot/longopt.h	Mon May 24 02:07:29 2010	(r46934)
@@ -51,9 +51,6 @@
 #define OPT_RUNTIME_PREFIX 132
 #define OPT_HASH_SEED      133
 
-PARROT_DATA
-const struct longopt_opt_decl * const Parrot_cmd_options;
-
 /* HEADERIZER BEGIN: src/longopt.c */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
@@ -69,11 +66,17 @@
         __attribute__nonnull__(5)
         FUNC_MODIFIES(* info_buf);
 
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PARROT_CONST_FUNCTION
+const struct longopt_opt_decl * Parrot_cmd_options(void);
+
 #define ASSERT_ARGS_longopt_get __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(argv) \
     , PARROT_ASSERT_ARG(options) \
     , PARROT_ASSERT_ARG(info_buf))
+#define ASSERT_ARGS_Parrot_cmd_options __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/longopt.c */
 

Modified: trunk/src/longopt.c
==============================================================================
--- trunk/src/longopt.c	Mon May 24 00:49:53 2010	(r46933)
+++ trunk/src/longopt.c	Mon May 24 02:07:29 2010	(r46934)
@@ -62,39 +62,46 @@
 
 static char longopt_error_buffer[512];
 
-static const struct longopt_opt_decl cmd_options[] = {
-    { '.', '.', (OPTION_flags)0, { "--wait" } },
-    { 'D', 'D', OPTION_optional_FLAG, { "--parrot-debug" } },
-    { 'E', 'E', (OPTION_flags)0, { "--pre-process-only" } },
-    { 'G', 'G', (OPTION_flags)0, { "--no-gc" } },
-    { '\0', OPT_HASH_SEED, OPTION_required_FLAG, { "--hash-seed" } },
-    { 'I', 'I', OPTION_required_FLAG, { "--include" } },
-    { 'L', 'L', OPTION_required_FLAG, { "--library" } },
-    { 'O', 'O', OPTION_optional_FLAG, { "--optimize" } },
-    { 'R', 'R', OPTION_required_FLAG, { "--runcore" } },
-    { 'g', 'g', OPTION_required_FLAG, { "--gc" } },
-    { 'V', 'V', (OPTION_flags)0, { "--version" } },
-    { 'X', 'X', OPTION_required_FLAG, { "--dynext" } },
-    { '\0', OPT_DESTROY_FLAG, (OPTION_flags)0,
-                                 { "--leak-test", "--destroy-at-end" } },
-    { '\0', OPT_GC_DEBUG, (OPTION_flags)0, { "--gc-debug" } },
-    { 'a', 'a', (OPTION_flags)0, { "--pasm" } },
-    { 'c', 'c', (OPTION_flags)0, { "--pbc" } },
-    { 'd', 'd', OPTION_optional_FLAG, { "--imcc-debug" } },
-    { '\0', OPT_HELP_DEBUG, (OPTION_flags)0, { "--help-debug" } },
-    { 'h', 'h', (OPTION_flags)0, { "--help" } },
-    { 'o', 'o', OPTION_required_FLAG, { "--output" } },
-    { '\0', OPT_PBC_OUTPUT, (OPTION_flags)0, { "--output-pbc" } },
-    { 'r', 'r', (OPTION_flags)0, { "--run-pbc" } },
-    { '\0', OPT_RUNTIME_PREFIX, (OPTION_flags)0, { "--runtime-prefix" } },
-    { 't', 't', OPTION_optional_FLAG, { "--trace" } },
-    { 'v', 'v', (OPTION_flags)0, { "--verbose" } },
-    { 'w', 'w', (OPTION_flags)0, { "--warnings" } },
-    { 'y', 'y', (OPTION_flags)0, { "--yydebug" } },
-    { 0, 0, (OPTION_flags)0, { NULL } }
-};
 
-const struct longopt_opt_decl * const Parrot_cmd_options = cmd_options;
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PARROT_CONST_FUNCTION
+const struct longopt_opt_decl *
+Parrot_cmd_options(void)
+{
+    static const struct longopt_opt_decl cmd_options[] = {
+        { '.', '.', (OPTION_flags)0, { "--wait" } },
+        { 'D', 'D', OPTION_optional_FLAG, { "--parrot-debug" } },
+        { 'E', 'E', (OPTION_flags)0, { "--pre-process-only" } },
+        { 'G', 'G', (OPTION_flags)0, { "--no-gc" } },
+        { '\0', OPT_HASH_SEED, OPTION_required_FLAG, { "--hash-seed" } },
+        { 'I', 'I', OPTION_required_FLAG, { "--include" } },
+        { 'L', 'L', OPTION_required_FLAG, { "--library" } },
+        { 'O', 'O', OPTION_optional_FLAG, { "--optimize" } },
+        { 'R', 'R', OPTION_required_FLAG, { "--runcore" } },
+        { 'g', 'g', OPTION_required_FLAG, { "--gc" } },
+        { 'V', 'V', (OPTION_flags)0, { "--version" } },
+        { 'X', 'X', OPTION_required_FLAG, { "--dynext" } },
+        { '\0', OPT_DESTROY_FLAG, (OPTION_flags)0,
+                                     { "--leak-test", "--destroy-at-end" } },
+        { '\0', OPT_GC_DEBUG, (OPTION_flags)0, { "--gc-debug" } },
+        { 'a', 'a', (OPTION_flags)0, { "--pasm" } },
+        { 'c', 'c', (OPTION_flags)0, { "--pbc" } },
+        { 'd', 'd', OPTION_optional_FLAG, { "--imcc-debug" } },
+        { '\0', OPT_HELP_DEBUG, (OPTION_flags)0, { "--help-debug" } },
+        { 'h', 'h', (OPTION_flags)0, { "--help" } },
+        { 'o', 'o', OPTION_required_FLAG, { "--output" } },
+        { '\0', OPT_PBC_OUTPUT, (OPTION_flags)0, { "--output-pbc" } },
+        { 'r', 'r', (OPTION_flags)0, { "--run-pbc" } },
+        { '\0', OPT_RUNTIME_PREFIX, (OPTION_flags)0, { "--runtime-prefix" } },
+        { 't', 't', OPTION_optional_FLAG, { "--trace" } },
+        { 'v', 'v', (OPTION_flags)0, { "--verbose" } },
+        { 'w', 'w', (OPTION_flags)0, { "--warnings" } },
+        { 'y', 'y', (OPTION_flags)0, { "--yydebug" } },
+        { 0, 0, (OPTION_flags)0, { NULL } }
+    };
+    return cmd_options;
+}
 
 /*
 

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	Mon May 24 00:49:53 2010	(r46933)
+++ trunk/src/main.c	Mon May 24 02:07:29 2010	(r46934)
@@ -417,7 +417,7 @@
         exit(EXIT_SUCCESS);
     }
 
-    while ((status = longopt_get(interp, argc, argv, Parrot_cmd_options, &opt)) > 0) {
+    while ((status = longopt_get(interp, argc, argv, Parrot_cmd_options(), &opt)) > 0) {
         switch (opt.opt_id) {
           case 'R':
             if (STREQ(opt.opt_arg, "slow") || STREQ(opt.opt_arg, "bounds"))


More information about the parrot-commits mailing list