Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76256 - in branches/quickbook-dev: . tools tools/build/v2/engine
From: dnljms_at_[hidden]
Date: 2012-01-01 09:23:41


Author: danieljames
Date: 2012-01-01 09:23:40 EST (Sun, 01 Jan 2012)
New Revision: 76256
URL: http://svn.boost.org/trac/boost/changeset/76256

Log:
Quickbook: Merge in rev. missed before
Properties modified:
   branches/quickbook-dev/ (props changed)
   branches/quickbook-dev/tools/ (props changed)
Text files modified:
   branches/quickbook-dev/tools/build/v2/engine/builtins.c | 60 ++++++++++++++++++++++------------
   branches/quickbook-dev/tools/build/v2/engine/compile.c | 15 +++++++-
   branches/quickbook-dev/tools/build/v2/engine/modules.c | 69 ++++++++++++++++-----------------------
   branches/quickbook-dev/tools/build/v2/engine/rules.c | 6 ++
   4 files changed, 85 insertions(+), 65 deletions(-)

Modified: branches/quickbook-dev/tools/build/v2/engine/builtins.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/builtins.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/builtins.c 2012-01-01 09:23:40 EST (Sun, 01 Jan 2012)
@@ -1043,10 +1043,18 @@
 }
 
 
-static void unknown_rule( FRAME * frame, const char * key, OBJECT * module_name, OBJECT * rule_name )
+static void unknown_rule( FRAME * frame, const char * key, module_t * module, OBJECT * rule_name )
 {
+ const char * module_name = module->name ? object_str( module->name ) : "";
     backtrace_line( frame->prev );
- printf( "%s error: rule \"%s\" unknown in module \"%s\"\n", key, object_str( rule_name ), object_str( module_name ) );
+ if ( module->name )
+ {
+ printf( "%s error: rule \"%s\" unknown in module \"%s.\"\n", key, object_str( rule_name ), object_str( module->name ) );
+ }
+ else
+ {
+ printf( "%s error: rule \"%s\" unknown in module \"\"\n", key, object_str( rule_name ) );
+ }
     backtrace( frame->prev );
     exit( 1 );
 }
@@ -1101,7 +1109,7 @@
 
         if ( !source_module->rules ||
             !hashcheck( source_module->rules, (HASHDATA * *)&r ) )
- unknown_rule( frame, "IMPORT", source_module->name, r_.name );
+ unknown_rule( frame, "IMPORT", source_module, r_.name );
 
         imported = import_rule( r, target_module, target_name->value );
         if ( localize )
@@ -1150,7 +1158,7 @@
         r_.name = rules->value;
 
         if ( !m->rules || !hashcheck( m->rules, (HASHDATA * *)&r ) )
- unknown_rule( frame, "EXPORT", m->name, r_.name );
+ unknown_rule( frame, "EXPORT", m, r_.name );
 
         r->exported = 1;
     }
@@ -1248,12 +1256,20 @@
         const char * file;
         int line;
         char buf[32];
+ string module_name[1];
         get_source_line( frame, &file, &line );
         sprintf( buf, "%d", line );
+ string_new( module_name );
+ if ( frame->module->name )
+ {
+ string_append( module_name, object_str( frame->module->name ) );
+ string_append( module_name, "." );
+ }
         result = list_new( result, object_new( file ) );
         result = list_new( result, object_new( buf ) );
- result = list_new( result, object_copy( frame->module->name ) );
+ result = list_new( result, object_new( module_name->value ) );
         result = list_new( result, object_new( frame->rulename ) );
+ string_free( module_name );
     }
     return result;
 }
@@ -1282,16 +1298,8 @@
 
     if ( frame->module == root_module() )
         return L0;
-
- {
- LIST * result;
- string name;
- string_copy( &name, object_str( frame->module->name ) );
- string_pop_back( &name );
- result = list_new( L0, object_new(name.value) );
- string_free( &name );
- return result;
- }
+ else
+ return list_new( L0, object_copy( frame->module->name ) );
 }
 
 
@@ -1586,7 +1594,7 @@
     else
     {
         backtrace_line( frame->prev );
- printf( "error: no native rule \"%s\" defined in module \"%s\"\n",
+ printf( "error: no native rule \"%s\" defined in module \"%s.\"\n",
                 object_str( n.name ), object_str( module->name ) );
         backtrace( frame->prev );
         exit( 1 );
@@ -2113,16 +2121,25 @@
         const char * file;
         int line;
         char buf[ 32 ];
+ string module_name[1];
 
         get_source_line( f, &file, &line );
         sprintf( buf, "%d", line );
+ string_new( module_name );
+ if ( f->module->name )
+ {
+ string_append( module_name, object_str( f->module->name ) );
+ string_append( module_name, "." );
+ }
 
         /* PyTuple_SetItem steals reference. */
         PyTuple_SetItem( tuple, 0, PyString_FromString( file ) );
         PyTuple_SetItem( tuple, 1, PyString_FromString( buf ) );
- PyTuple_SetItem( tuple, 2, PyString_FromString( object_str( f->module->name ) ) );
+ PyTuple_SetItem( tuple, 2, PyString_FromString( module_name->value ) );
         PyTuple_SetItem( tuple, 3, PyString_FromString( f->rulename ) );
 
+ string_free( module_name );
+
         PyList_Append( result, tuple );
         Py_DECREF( tuple );
     }
@@ -2131,11 +2148,10 @@
 
 PyObject * bjam_caller( PyObject * self, PyObject * args )
 {
- /* Module names in Jam end in dot. The CALLER builtin in jam
- language strips the dot, and we do the same here to make it
- easier to port Jam code to Python. */
- const char *s = object_str( frame_before_python_call->prev->module->name );
- return PyString_FromStringAndSize(s, strlen(s)-1);
+ const char * s = frame_before_python_call->prev->module->name ?
+ object_str( frame_before_python_call->prev->module->name ) :
+ "";
+ return PyString_FromString( s );
 }
 
 #endif /* #ifdef HAVE_PYTHON */

Modified: branches/quickbook-dev/tools/build/v2/engine/compile.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/compile.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/compile.c 2012-01-01 09:23:40 EST (Sun, 01 Jan 2012)
@@ -516,7 +516,11 @@
              && rule->procedure != 0 && !object_equal( rulename, function_rulename( rule->procedure ) ) )
         {
             char buf[256] = "";
- strncat( buf, object_str( rule->module->name ), sizeof( buf ) - 1 );
+ if ( rule->module->name )
+ {
+ strncat( buf, object_str( rule->module->name ), sizeof( buf ) - 1 );
+ strncat( buf, ".", sizeof( buf ) - 1 );
+ }
             strncat( buf, object_str( rule->name ), sizeof( buf ) - 1 );
             debug_compile( 1, buf, frame );
         }
@@ -548,7 +552,14 @@
     if ( !rule->actions && !rule->procedure )
     {
         backtrace_line( frame->prev );
- printf( "rule %s unknown in module %s\n", object_str( rule->name ), object_str( frame->module->name ) );
+ if ( frame->module->name )
+ {
+ printf( "rule %s unknown in module %s\n", object_str( rule->name ), object_str( frame->module->name ) );
+ }
+ else
+ {
+ printf( "rule %s unknown in module \n", object_str( rule->name ) );
+ }
         backtrace( frame->prev );
         exit( 1 );
     }

Modified: branches/quickbook-dev/tools/build/v2/engine/modules.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/modules.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/modules.c 2012-01-01 09:23:40 EST (Sun, 01 Jan 2012)
@@ -18,47 +18,42 @@
 #include <assert.h>
 
 static struct hash * module_hash = 0;
-
+static module_t root;
 
 module_t * bindmodule( OBJECT * name )
 {
- PROFILE_ENTER( BINDMODULE );
-
- string s;
- module_t m_;
- module_t * m = &m_;
-
- if ( !module_hash )
- module_hash = hashinit( sizeof( module_t ), "modules" );
 
- string_new( &s );
- if ( name )
+ if ( !name )
     {
- string_append( &s, object_str( name ) );
- string_push_back( &s, '.' );
- }
-
- m->name = name = object_new( s.value );
-
- if ( hashenter( module_hash, (HASHDATA * *)&m ) )
- {
- m->name = m->name;
- m->variables = 0;
- m->rules = 0;
- m->imported_modules = 0;
- m->class_module = 0;
- m->native_rules = 0;
- m->user_module = 0;
+ return &root;
     }
     else
     {
- object_free( name );
- }
- string_free( &s );
+ PROFILE_ENTER( BINDMODULE );
+
+ module_t m_;
+ module_t * m = &m_;
+
+ if ( !module_hash )
+ module_hash = hashinit( sizeof( module_t ), "modules" );
 
- PROFILE_EXIT( BINDMODULE );
+ m->name = name;
+
+ if ( hashenter( module_hash, (HASHDATA * *)&m ) )
+ {
+ m->name = object_copy( name );
+ m->variables = 0;
+ m->rules = 0;
+ m->imported_modules = 0;
+ m->class_module = 0;
+ m->native_rules = 0;
+ m->user_module = 0;
+ }
 
- return m;
+ PROFILE_EXIT( BINDMODULE );
+
+ return m;
+ }
 }
 
 /*
@@ -136,11 +131,7 @@
     module_t *m = (module_t *)xmodule;
 
     delete_module( m );
-
- if ( m->name )
- {
- object_free( m->name );
- }
+ object_free( m->name );
 }
 
 void modules_done()
@@ -148,14 +139,12 @@
     hashenumerate( module_hash, delete_module_, (void *)0 );
     hashdone( module_hash );
     module_hash = 0;
+ delete_module( &root );
 }
 
 module_t * root_module()
 {
- static module_t * root = 0;
- if ( !root )
- root = bindmodule( 0 );
- return root;
+ return &root;
 }
 
 

Modified: branches/quickbook-dev/tools/build/v2/engine/rules.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/rules.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/rules.c 2012-01-01 09:23:40 EST (Sun, 01 Jan 2012)
@@ -590,7 +590,11 @@
 
     {
         char name[4096] = "";
- strncat( name, object_str( r->module->name ), sizeof( name ) - 1 );
+ if ( r->module->name )
+ {
+ strncat( name, object_str( r->module->name ), sizeof( name ) - 1 );
+ strncat( name, ".", sizeof( name ) - 1 );
+ }
         strncat( name, object_str( r->name ), sizeof( name ) - 1 );
         return object_new( name );
     }


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