Permalink
Browse files

add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c in…

…stead of some particularly lousy macros
  • Loading branch information...
1 parent 1a692e9 commit f68bf5661c783339ef3d3c7717a84ab0bf5b9588 @Whiteknight Whiteknight committed Nov 11, 2010
Showing with 35 additions and 11 deletions.
  1. +30 −1 src/embed/api.c
  2. +5 −10 src/main.c
View
@@ -83,7 +83,36 @@ Parrot_api_set_runcore(ARGIN(PMC *interp_pmc), Parrot_Run_core_t core, Parrot_Ui
PARROT_API
INTVAL
-Parrot_api_set_executable_name(ARGIN(PMC *interp_pmc), ARGIN(const char * name))
+Parrot_api_debug_flag(ARGMOD(PMC *interp_pmc), INTVAL flags, INTVAL set)
+{
+ ASSERT_ARGS(Parrot_api_debug_flag)
+ EMBED_API_CALLIN(interp_pmc, interp);
+ if (set)
+ interp->debug_flags |= flags;
+ else
+ interp->debug_flags &= ~flags;
+ EMBED_API_CALLOUT(interp_pmc, interp);
+}
+
+PARROT_API
+INTVAL
+Parrot_api_flag(ARGMOD(PMC *interp_pmc), INTVAL flags, INTVAL set)
+{
+ ASSERT_ARGS(Parrot_api_flag)
+ EMBED_API_CALLIN(interp_pmc, interp);
+ if (set) {
+ Interp_flags_SET(interp, flag);
+ if (flag & (PARROT_BOUNDS_FLAG | PARROT_PROFILE_FLAG))
+ Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
+ }
+ else
+ Interp_flags_CLEAR(interp, flag);
+ EMBED_API_CALLOUT(interp_pmc, interp);
+}
+
+PARROT_API
+INTVAL
+Parrot_api_set_executable_name(ARGMOD(PMC *interp_pmc), ARGIN(const char * name))
{
ASSERT_ARGS(Parrot_api_set_executable_name)
EMBED_API_CALLIN(interp_pmc, interp);
View
@@ -145,10 +145,6 @@ main(int argc, const char *argv[])
Parrot_api_destroy_interpreter(interp);
}
-#define SET_FLAG(flag) Parrot_set_flag(interp, (flag))
-#define SET_DEBUG(flag) Parrot_set_debug(interp, (flag))
-#define SET_TRACE(flag) Parrot_set_trace(interp, (flag))
-
/*
=item C<static int is_all_digits(const char *s)>
@@ -504,11 +500,10 @@ parseflags(PMC *interp,
*trace = PARROT_TRACE_OPS_FLAG;
break;
case 'D':
- if (opt.opt_arg && is_all_hex_digits(opt.opt_arg)) {
- SET_DEBUG(strtoul(opt.opt_arg, NULL, 16));
- }
+ if (opt.opt_arg && is_all_hex_digits(opt.opt_arg))
+ Parrot_api_debug_flag(interp, strtoul(opt.opt_arg, NULL, 16), 1);
else
- SET_DEBUG(PARROT_MEM_STAT_DEBUG_FLAG);
+ Parrot_api_debug_flag(interp, PARROT_MEM_STAT_DEBUG_FLAG, 1);
break;
case '.': /* Give Windows Parrot hackers an opportunity to
@@ -540,10 +535,10 @@ parseflags(PMC *interp,
"PARROT_GC_DEBUG is set but the binary was compiled "
"with DISABLE_GC_DEBUG.");
#endif
- SET_FLAG(PARROT_GC_DEBUG_FLAG);
+ Parrot_api_flag(interp, PARROT_GC_DEBUG_FLAG, 1);
break;
case OPT_DESTROY_FLAG:
- SET_FLAG(PARROT_DESTROY_FLAG);
+ Parrot_api_flag(interp PARROT_DESTROY_FLAG, 1);
break;
case 'I':
result = Parrot_api_add_include_search_path(interp, opt.opt_arg);

0 comments on commit f68bf56

Please sign in to comment.