|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75890 - trunk/tools/build/v2/engine
From: steven_at_[hidden]
Date: 2011-12-11 00:11:28
Author: steven_watanabe
Date: 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
New Revision: 75890
URL: http://svn.boost.org/trac/boost/changeset/75890
Log:
Replace all calls to object_new with a literal with constants.
Text files modified:
trunk/tools/build/v2/engine/builtins.c | 10 +--
trunk/tools/build/v2/engine/class.c | 9 --
trunk/tools/build/v2/engine/compile.c | 4 -
trunk/tools/build/v2/engine/constants.c | 96 ++++++++++++++++++++++++++++++++++++++++
trunk/tools/build/v2/engine/constants.h | 32 +++++++++++++
trunk/tools/build/v2/engine/hcache.c | 8 --
trunk/tools/build/v2/engine/headers.c | 12 ----
trunk/tools/build/v2/engine/jam.c | 37 +++-----------
trunk/tools/build/v2/engine/make.c | 4 -
trunk/tools/build/v2/engine/make1.c | 16 +-----
trunk/tools/build/v2/engine/search.c | 15 +-----
trunk/tools/build/v2/engine/variable.c | 14 ++--
12 files changed, 163 insertions(+), 94 deletions(-)
Modified: trunk/tools/build/v2/engine/builtins.c
==============================================================================
--- trunk/tools/build/v2/engine/builtins.c (original)
+++ trunk/tools/build/v2/engine/builtins.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -858,11 +858,9 @@
else
{
/** No directory, just a pattern. */
- OBJECT * d = object_new( "." );
OBJECT * p = object_new( pattern );
- result = list_append( result, glob1( d, p ) );
+ result = list_append( result, glob1( constant_dot, p ) );
object_free( p );
- object_free( d );
}
}
@@ -1440,7 +1438,7 @@
last_update_now_status = status;
if ( status == 0 )
- return list_new( L0, object_new( "ok" ) );
+ return list_new( L0, object_copy( constant_ok ) );
else
return L0;
}
@@ -1653,7 +1651,7 @@
{
int expected_version = atoi( object_str( version->value ) );
if ( np->version == expected_version )
- return list_new( 0, object_new( "true" ) );
+ return list_new( 0, object_copy( constant_true ) );
}
return L0;
}
@@ -1697,7 +1695,7 @@
{
LIST * name = lol_get( frame->args, 0 );
return file_is_file( name->value ) == 1
- ? list_new( 0, object_new( "true" ) )
+ ? list_new( 0, object_copy( constant_true ) )
: L0 ;
}
Modified: trunk/tools/build/v2/engine/class.c
==============================================================================
--- trunk/tools/build/v2/engine/class.c (original)
+++ trunk/tools/build/v2/engine/class.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -118,8 +118,6 @@
OBJECT * * pp = &xname->value;
module_t * class_module = 0;
module_t * outer_module = frame->module;
- OBJECT * name_ = object_new( "__name__" );
- OBJECT * bases_ = object_new( "__bases__" );
if ( !classes )
classes = hashinit( sizeof( OBJECT * ), "classes" );
@@ -140,8 +138,8 @@
exit_module( outer_module );
enter_module( class_module );
- var_set( name_, xname, VAR_SET );
- var_set( bases_, bases, VAR_SET );
+ var_set( constant_name, xname, VAR_SET );
+ var_set( constant_bases, bases, VAR_SET );
exit_module( class_module );
enter_module( outer_module );
@@ -149,9 +147,6 @@
for ( ; bases; bases = bases->next )
import_base_rules( class_module, bases->value );
- object_free( bases_ );
- object_free( name_ );
-
return name;
}
Modified: trunk/tools/build/v2/engine/compile.c
==============================================================================
--- trunk/tools/build/v2/engine/compile.c (original)
+++ trunk/tools/build/v2/engine/compile.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -199,9 +199,7 @@
if ( !typecheck )
{
- OBJECT * str_typecheck = object_new( ".typecheck" );
- typecheck = bindmodule( str_typecheck );
- object_free( str_typecheck );
+ typecheck = bindmodule( constant_typecheck );
}
/* If the checking rule can not be found, also bail. */
Modified: trunk/tools/build/v2/engine/constants.c
==============================================================================
--- trunk/tools/build/v2/engine/constants.c (original)
+++ trunk/tools/build/v2/engine/constants.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -20,7 +20,39 @@
void constants_init( void )
{
constant_empty = object_new( "" );
+ constant_dot = object_new( "." );
+ constant_percent = object_new( "%" );
+ constant_plus = object_new( "+" );
+ constant_ok = object_new( "ok" );
+ constant_true = object_new( "true" );
+ constant_name = object_new( "__name__" );
+ constant_bases = object_new( "__bases__" );
+ constant_typecheck = object_new( ".typecheck" );
constant_builtin = object_new( "(builtin)" );
+ constant_HCACHEFILE = object_new( "HCACHEFILE" );
+ constant_HCACHEMAXAGE = object_new( "HCACHEMAXAGE" );
+ constant_HDRSCAN = object_new( "HDRSCAN" );
+ constant_HDRRULE = object_new( "HDRRULE" );
+ constant_BINDRULE = object_new( "BINDRULE" );
+ constant_LOCATE = object_new( "LOCATE" );
+ constant_SEARCH = object_new( "SEARCH" );
+ constant_JAM_SEMAPHORE = object_new( "JAM_SEMAPHORE" );
+ constant_TIMING_RULE = object_new( "__TIMING_RULE__" );
+ constant_ACTION_RULE = object_new( "__ACTION_RULE__" );
+ constant_JAMSHELL = object_new( "JAMSHELL" );
+ constant_TMPDIR = object_new( "TMPDIR" );
+ constant_TMPNAME = object_new( "TMPNAME" );
+ constant_TMPFILE = object_new( "TMPFILE" );
+ constant_STDOUT = object_new( "STDOUT" );
+ constant_STDERR = object_new( "STDERR" );
+ constant_JAMDATE = object_new( "JAMDATE" );
+ constant_JAM_VERSION = object_new( "JAM_VERSION" );
+ constant_JAMUNAME = object_new( "JAMUNAME" );
+ constant_ENVIRON = object_new( ".ENVIRON" );
+ constant_ARGV = object_new( "ARGV" );
+ constant_all = object_new( "all" );
+ constant_PARALLELISM = object_new( "PARALLELISM" );
+ constant_KEEP_GOING = object_new( "KEEP_GOING" );
constant_other = object_new( "[OTHER]" );
constant_total = object_new( "[TOTAL]" );
constant_FILE_DIRSCAN = object_new( "FILE_DIRSCAN" );
@@ -42,7 +74,39 @@
void constants_done( void )
{
object_free( constant_empty );
+ object_free( constant_dot );
+ object_free( constant_percent );
+ object_free( constant_plus );
+ object_free( constant_ok );
+ object_free( constant_true );
+ object_free( constant_name );
+ object_free( constant_bases );
+ object_free( constant_typecheck );
object_free( constant_builtin );
+ object_free( constant_HCACHEFILE );
+ object_free( constant_HCACHEMAXAGE );
+ object_free( constant_HDRSCAN );
+ object_free( constant_HDRRULE );
+ object_free( constant_BINDRULE );
+ object_free( constant_LOCATE );
+ object_free( constant_SEARCH );
+ object_free( constant_JAM_SEMAPHORE );
+ object_free( constant_TIMING_RULE );
+ object_free( constant_ACTION_RULE );
+ object_free( constant_JAMSHELL );
+ object_free( constant_TMPDIR );
+ object_free( constant_TMPNAME );
+ object_free( constant_TMPFILE );
+ object_free( constant_STDOUT );
+ object_free( constant_STDERR );
+ object_free( constant_JAMDATE );
+ object_free( constant_JAM_VERSION );
+ object_free( constant_JAMUNAME );
+ object_free( constant_ENVIRON );
+ object_free( constant_ARGV );
+ object_free( constant_all );
+ object_free( constant_PARALLELISM );
+ object_free( constant_KEEP_GOING );
object_free( constant_other );
object_free( constant_total );
object_free( constant_FILE_DIRSCAN );
@@ -62,7 +126,39 @@
}
OBJECT * constant_empty;
+OBJECT * constant_dot;
+OBJECT * constant_percent;
+OBJECT * constant_plus;
+OBJECT * constant_ok;
+OBJECT * constant_true;
+OBJECT * constant_name;
+OBJECT * constant_bases;
+OBJECT * constant_typecheck;
OBJECT * constant_builtin;
+OBJECT * constant_HCACHEFILE;
+OBJECT * constant_HCACHEMAXAGE;
+OBJECT * constant_HDRSCAN;
+OBJECT * constant_HDRRULE;
+OBJECT * constant_BINDRULE;
+OBJECT * constant_LOCATE;
+OBJECT * constant_SEARCH;
+OBJECT * constant_JAM_SEMAPHORE;
+OBJECT * constant_TIMING_RULE;
+OBJECT * constant_ACTION_RULE;
+OBJECT * constant_JAMSHELL;
+OBJECT * constant_TMPDIR;
+OBJECT * constant_TMPNAME;
+OBJECT * constant_TMPFILE;
+OBJECT * constant_STDOUT;
+OBJECT * constant_STDERR;
+OBJECT * constant_JAMDATE;
+OBJECT * constant_JAM_VERSION;
+OBJECT * constant_JAMUNAME;
+OBJECT * constant_ENVIRON;
+OBJECT * constant_ARGV;
+OBJECT * constant_all;
+OBJECT * constant_PARALLELISM;
+OBJECT * constant_KEEP_GOING;
OBJECT * constant_other;
OBJECT * constant_total;
OBJECT * constant_FILE_DIRSCAN;
Modified: trunk/tools/build/v2/engine/constants.h
==============================================================================
--- trunk/tools/build/v2/engine/constants.h (original)
+++ trunk/tools/build/v2/engine/constants.h 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -17,7 +17,39 @@
void constants_done( void );
extern OBJECT * constant_empty; /* "" */
+extern OBJECT * constant_dot; /* "." */
+extern OBJECT * constant_percent; /* "%" */
+extern OBJECT * constant_plus; /* "+" */
+extern OBJECT * constant_ok; /* "ok" */
+extern OBJECT * constant_true; /* "true" */
+extern OBJECT * constant_name; /* "__name__" */
+extern OBJECT * constant_bases; /* "__bases__" */
+extern OBJECT * constant_typecheck; /* ".typecheck" */
extern OBJECT * constant_builtin; /* "(builtin)" */
+extern OBJECT * constant_HCACHEFILE; /* "HCACHEFILE" */
+extern OBJECT * constant_HCACHEMAXAGE; /* "HCACHEMAXAGE" */
+extern OBJECT * constant_HDRSCAN; /* "HDRSCAN" */
+extern OBJECT * constant_HDRRULE; /* "HDRRULE" */
+extern OBJECT * constant_BINDRULE; /* "BINDRULE" */
+extern OBJECT * constant_LOCATE; /* "LOCATE" */
+extern OBJECT * constant_SEARCH; /* "SEARCH" */
+extern OBJECT * constant_JAM_SEMAPHORE; /* "JAM_SEMAPHORE" */
+extern OBJECT * constant_TIMING_RULE; /* "__TIMING_RULE__" */
+extern OBJECT * constant_ACTION_RULE; /* "__ACTION_RULE__" */
+extern OBJECT * constant_JAMSHELL; /* "JAMSHELL" */
+extern OBJECT * constant_TMPDIR; /* "TMPDIR" */
+extern OBJECT * constant_TMPNAME; /* "TMPNAME" */
+extern OBJECT * constant_TMPFILE; /* "TMPFILE" */
+extern OBJECT * constant_STDOUT; /* "STDOUT" */
+extern OBJECT * constant_STDERR; /* "STDERR" */
+extern OBJECT * constant_JAMDATE; /* "JAMDATE" */
+extern OBJECT * constant_JAM_VERSION; /* "JAM_VERSION" */
+extern OBJECT * constant_JAMUNAME; /* "JAMUNAME" */
+extern OBJECT * constant_ENVIRON; /* ".ENVIRON" */
+extern OBJECT * constant_ARGV; /* "ARGV" */
+extern OBJECT * constant_all; /* "all" */
+extern OBJECT * constant_PARALLELISM; /* "PARALLELISM" */
+extern OBJECT * constant_KEEP_GOING; /* "KEEP_GOING" */
extern OBJECT * constant_other; /* "[OTHER]" */
extern OBJECT * constant_total; /* "[TOTAL]" */
extern OBJECT * constant_FILE_DIRSCAN; /* "FILE_DIRSCAN" */
Modified: trunk/tools/build/v2/engine/hcache.c
==============================================================================
--- trunk/tools/build/v2/engine/hcache.c (original)
+++ trunk/tools/build/v2/engine/hcache.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -75,9 +75,7 @@
static OBJECT * name = 0;
if ( !name )
{
- OBJECT * hcachename = object_new( "HCACHEFILE" );
- LIST * hcachevar = var_get( hcachename );
- object_free( hcachename );
+ LIST * hcachevar = var_get( constant_HCACHEFILE );
if ( hcachevar )
{
@@ -108,9 +106,7 @@
static int cache_maxage( void )
{
int age = 100;
- OBJECT * hcacheage = object_new( "HCACHEMAXAGE" );
- LIST * var = var_get( hcacheage );
- object_free( hcacheage );
+ LIST * var = var_get( constant_HCACHEMAXAGE );
if ( var )
{
age = atoi( object_str( var->value ) );
Modified: trunk/tools/build/v2/engine/headers.c
==============================================================================
--- trunk/tools/build/v2/engine/headers.c (original)
+++ trunk/tools/build/v2/engine/headers.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -65,19 +65,11 @@
#endif
regexp * re[ MAXINC ];
int rec = 0;
- OBJECT * hdrscan_str;
- OBJECT * hdrrule_str;
- hdrscan_str = object_new( "HDRSCAN" );
- hdrscan = var_get( hdrscan_str );
- object_free( hdrscan_str );
- if ( !hdrscan )
+ if ( !( hdrscan = var_get( constant_HDRSCAN ) ) )
return;
- hdrrule_str = object_new( "HDRRULE" );
- hdrrule = var_get( hdrrule_str );
- object_free( hdrrule_str );
- if ( !hdrrule )
+ if ( !( hdrrule = var_get( constant_HDRRULE ) ) )
return;
if ( DEBUG_HEADER )
Modified: trunk/tools/build/v2/engine/jam.c
==============================================================================
--- trunk/tools/build/v2/engine/jam.c (original)
+++ trunk/tools/build/v2/engine/jam.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -228,7 +228,6 @@
int arg_c = argc;
char * * arg_v = argv;
char const * progname = argv[0];
- OBJECT * varname;
module_t * environ_module;
saved_argv0 = argv[0];
@@ -386,19 +385,15 @@
#endif
/* Set JAMDATE. */
- varname = object_new( "JAMDATE" );
- var_set( varname, list_new( L0, outf_time(time(0)) ), VAR_SET );
- object_free( varname );
+ var_set( constant_JAMDATE, list_new( L0, outf_time(time(0)) ), VAR_SET );
/* Set JAM_VERSION. */
- varname = object_new( "JAM_VERSION" );
- var_set( varname,
+ var_set( constant_JAM_VERSION,
list_new( list_new( list_new( L0,
object_new( VERSION_MAJOR_SYM ) ),
object_new( VERSION_MINOR_SYM ) ),
object_new( VERSION_PATCH_SYM ) ),
VAR_SET );
- object_free( varname );
/* Set JAMUNAME. */
#ifdef unix
@@ -407,8 +402,7 @@
if ( uname( &u ) >= 0 )
{
- varname = object_new( "JAMUNAME" );
- var_set( varname,
+ var_set( constant_JAMUNAME,
list_new(
list_new(
list_new(
@@ -419,7 +413,6 @@
object_new( u.release ) ),
object_new( u.version ) ),
object_new( u.machine ) ), VAR_SET );
- object_free( varname );
}
}
#endif /* unix */
@@ -431,9 +424,7 @@
*/
var_defines( use_environ, 1 );
- varname = object_new( ".ENVIRON" );
- environ_module = bindmodule( varname );
- object_free( varname );
+ environ_module = bindmodule( constant_ENVIRON );
/* Then into .ENVIRON, without splitting. */
enter_module( environ_module );
var_defines( use_environ, 0 );
@@ -460,12 +451,10 @@
/* Set the ARGV to reflect the complete list of arguments of invocation.
*/
- varname = object_new( "ARGV" );
for ( n = 0; n < arg_c; ++n )
{
- var_set( varname, list_new( L0, object_new( arg_v[n] ) ), VAR_APPEND );
+ var_set( constant_ARGV, list_new( L0, object_new( arg_v[n] ) ), VAR_APPEND );
}
- object_free( varname );
/* Initialize built-in rules. */
load_builtins();
@@ -489,9 +478,7 @@
if (!targets_to_update())
{
- OBJECT * target = object_new( "all" );
- mark_target_for_updating( target );
- object_free( target );
+ mark_target_for_updating( constant_all );
}
/* Parse ruleset. */
@@ -507,9 +494,7 @@
if ( !n )
{
- OBJECT * filename = object_new( "+" );
- parse_file( filename, frame );
- object_free( filename );
+ parse_file( constant_plus, frame );
}
}
@@ -538,9 +523,7 @@
options. */
{
LIST *p = L0;
- varname = object_new( "PARALLELISM" );
- p = var_get ( varname );
- object_free( varname );
+ p = var_get ( constant_PARALLELISM );
if ( p )
{
int j = atoi( object_str( p->value ) );
@@ -558,9 +541,7 @@
/* KEEP_GOING overrides -q option. */
{
LIST *p = L0;
- varname = object_new( "KEEP_GOING" );
- p = var_get( varname );
- object_free(varname);
+ p = var_get( constant_KEEP_GOING );
if ( p )
{
int v = atoi( object_str( p->value ) );
Modified: trunk/tools/build/v2/engine/make.c
==============================================================================
--- trunk/tools/build/v2/engine/make.c (original)
+++ trunk/tools/build/v2/engine/make.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -314,9 +314,7 @@
#ifdef OPT_SEMAPHORE
{
- OBJECT * jam_semaphore = object_new( "JAM_SEMAPHORE" );
- LIST * var = var_get( jam_semaphore );
- object_free( jam_semaphore );
+ LIST * var = var_get( constant_JAM_SEMAPHORE );
if ( var )
{
TARGET * semaphore = bindtarget( var->value );
Modified: trunk/tools/build/v2/engine/make1.c
==============================================================================
--- trunk/tools/build/v2/engine/make1.c (original)
+++ trunk/tools/build/v2/engine/make1.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -671,13 +671,10 @@
static void call_timing_rule( TARGET * target, timing_info * time )
{
LIST * timing_rule;
- OBJECT * varname;
- varname = object_new( "__TIMING_RULE__" );
pushsettings( target->settings );
- timing_rule = var_get( varname );
+ timing_rule = var_get( constant_TIMING_RULE );
popsettings( target->settings );
- object_free( varname );
if ( timing_rule )
{
@@ -725,13 +722,10 @@
)
{
LIST * action_rule;
- OBJECT * varname;
- varname = object_new( "__ACTION_RULE__" );
pushsettings( target->settings );
- action_rule = var_get( varname );
+ action_rule = var_get( constant_ACTION_RULE );
popsettings( target->settings );
- object_free( varname );
if ( action_rule )
{
@@ -986,9 +980,7 @@
swap_settings( &settings_module, &settings_target, rule->module, t );
if ( !shell )
{
- OBJECT * varname = object_new( "JAMSHELL" );
- shell = var_get( varname ); /* shell is per-target */
- object_free( varname );
+ shell = var_get( constant_JAMSHELL ); /* shell is per-target */
}
/* If we had 'actions xxx bind vars' we bind the vars now. */
@@ -1044,7 +1036,7 @@
/* Tell the user what didn't fit. */
cmd = cmd_new( rule, list_copy( L0, nt ),
list_sublist( ns, start, chunk ),
- list_new( L0, object_new( "%" ) ) );
+ list_new( L0, object_copy( constant_percent ) ) );
fputs( cmd->buf->value, stdout );
exit( EXITBAD );
}
Modified: trunk/tools/build/v2/engine/search.c
==============================================================================
--- trunk/tools/build/v2/engine/search.c (original)
+++ trunk/tools/build/v2/engine/search.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -39,9 +39,7 @@
OBJECT * boundname_
)
{
- OBJECT * varname = object_new( "BINDRULE" );
- LIST * bind_rule = var_get( varname );
- object_free( varname );
+ LIST * bind_rule = var_get( constant_BINDRULE );
if ( bind_rule )
{
OBJECT * target = object_copy( target_ );
@@ -103,7 +101,6 @@
/* Will be set to 1 if target location is specified via LOCATE. */
int explicitly_located = 0;
OBJECT * boundname = 0;
- OBJECT * varname;
if ( another_target )
*another_target = 0;
@@ -120,10 +117,7 @@
f->f_grist.ptr = 0;
f->f_grist.len = 0;
- varname = object_new( "LOCATE" );
- varlist = var_get( varname );
- object_free( varname );
- if ( varlist )
+ if ( ( varlist = var_get( constant_LOCATE ) ) )
{
OBJECT * key;
f->f_root.ptr = object_str( varlist->value );
@@ -141,10 +135,7 @@
object_free( key );
found = 1;
}
- else if ( ( varname = object_new( "SEARCH" ),
- varlist = var_get( varname ),
- object_free( varname ),
- varlist ) )
+ else if ( varlist = var_get( constant_SEARCH ) )
{
while ( varlist )
{
Modified: trunk/tools/build/v2/engine/variable.c
==============================================================================
--- trunk/tools/build/v2/engine/variable.c (original)
+++ trunk/tools/build/v2/engine/variable.c 2011-12-11 00:11:26 EST (Sun, 11 Dec 2011)
@@ -188,30 +188,30 @@
LIST * result = 0;
#ifdef OPT_AT_FILES
/* Some "fixed" variables... */
- if ( strcmp( "TMPDIR", object_str( symbol ) ) == 0 )
+ if ( object_equal( symbol, constant_TMPDIR ) )
{
list_free( saved_var );
result = saved_var = list_new( L0, object_new( path_tmpdir() ) );
}
- else if ( strcmp( "TMPNAME", object_str( symbol ) ) == 0 )
+ else if ( object_equal( symbol, constant_TMPNAME ) )
{
list_free( saved_var );
result = saved_var = list_new( L0, path_tmpnam() );
}
- else if ( strcmp( "TMPFILE", object_str( symbol ) ) == 0 )
+ else if ( object_equal( symbol, constant_TMPFILE ) )
{
list_free( saved_var );
result = saved_var = list_new( L0, path_tmpfile() );
}
- else if ( strcmp( "STDOUT", object_str( symbol ) ) == 0 )
+ else if ( object_equal( symbol, constant_STDOUT ) )
{
list_free( saved_var );
- result = saved_var = list_new( L0, object_new( "STDOUT" ) );
+ result = saved_var = list_new( L0, object_copy( constant_STDOUT ) );
}
- else if ( strcmp( "STDERR", object_str( symbol ) ) == 0 )
+ else if ( object_equal( symbol, constant_STDERR ) )
{
list_free( saved_var );
- result = saved_var = list_new( L0, object_new( "STDERR" ) );
+ result = saved_var = list_new( L0, object_copy( constant_STDERR ) );
}
else
#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk