@@ -16,6 +16,7 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7.
1616
1717#include <sc_memmgr.h>
1818#include <stdlib.h>
19+ #include <stdbool.h>
1920#include <assert.h>
2021#include <sc_mkdir.h>
2122#include "classes.h"
@@ -1015,7 +1016,7 @@ void ENTITYPrint_h( const Entity entity, FILE * header, Linked_List neededAttr,
10151016 DEBUG ( "DONE ENTITYPrint_h\n" );
10161017}
10171018
1018- void ENTITYPrint_cc ( const Entity entity , FILE * header , FILE * impl , Linked_List neededAttr , Schema schema ) {
1019+ void ENTITYPrint_cc ( const Entity entity , FILE * header , FILE * impl , Linked_List neededAttr , Schema schema , bool externMap ) {
10191020 const char * name = ENTITYget_classname ( entity );
10201021
10211022 DEBUG ( "Entering ENTITYPrint_cc for %s\n" , name );
@@ -1033,6 +1034,7 @@ void ENTITYPrint_cc( const Entity entity, FILE * header, FILE * impl, Linked_Lis
10331034
10341035 fprintf ( impl , "void init_%s( Registry& reg ) {\n" , name );
10351036 fprintf ( impl , " std::string str;\n\n" );
1037+ ENTITYprint_descriptors ( entity , impl , schema , externMap );
10361038 ENTITYincode_print ( entity , header , impl , schema );
10371039 fprintf ( impl , "}\n\n" );
10381040
@@ -1153,7 +1155,7 @@ void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap )
11531155 fprintf ( files -> unity .entity .impl , "#include \"%s\"\n" , names .impl );
11541156
11551157 ENTITYPrint_h ( entity , hdr , remaining , schema );
1156- ENTITYPrint_cc ( entity , hdr , impl , remaining , schema );
1158+ ENTITYPrint_cc ( entity , hdr , impl , remaining , schema , externMap );
11571159 FILEclose ( hdr );
11581160 FILEclose ( impl );
11591161
@@ -1191,32 +1193,30 @@ void ENTITYPrint( Entity entity, FILES * files, Schema schema, bool externMap )
11911193 * \p schema the current schema
11921194 * \p externMap true if entity must be instantiated with external mapping (see Part 21, sect 11.2.5.1).
11931195 */
1194- void ENTITYprint_new ( Entity entity , FILES * files , Schema schema , int externMap ) {
1195- const char * n ;
1196+ void ENTITYprint_descriptors ( Entity entity , FILE * create , Schema schema , bool externMap ) {
11961197 Linked_List wheres ;
11971198 char * whereRule , * whereRule_formatted = NULL ;
11981199 size_t whereRule_formatted_size = 0 ;
11991200 char * ptr , * ptr2 ;
12001201 char * uniqRule , * uniqRule_formatted ;
12011202 Linked_List uniqs ;
12021203
1203- fprintf ( files -> create , " %s::%s%s = new EntityDescriptor(\n " ,
1204+ fprintf ( create , " %s::%s%s = new EntityDescriptor(\n " ,
12041205 SCHEMAget_name ( schema ), ENT_PREFIX , ENTITYget_name ( entity ) );
1205- fprintf ( files -> create , " \"%s\", %s::schema, %s, " ,
1206+ fprintf ( create , " \"%s\", %s::schema, %s, " ,
12061207 PrettyTmpName ( ENTITYget_name ( entity ) ),
12071208 SCHEMAget_name ( schema ), ( ENTITYget_abstract ( entity ) ? "LTrue" : "LFalse" ) );
1208- fprintf ( files -> create , "%s,\n " , externMap ? "LTrue" :
1209- "LFalse" );
1209+ fprintf ( create , "%s,\n " , externMap ? "LTrue" : "LFalse" );
12101210
1211- fprintf ( files -> create , " (Creator) create_%s );\n" ,
1211+ fprintf ( create , " (Creator) create_%s );\n" ,
12121212 ENTITYget_classname ( entity ) );
12131213 /* add the entity to the Schema dictionary entry */
1214- fprintf ( files -> create , " %s::schema->AddEntity(%s::%s%s);\n" , SCHEMAget_name ( schema ), SCHEMAget_name ( schema ), ENT_PREFIX , ENTITYget_name ( entity ) );
1214+ fprintf ( create , " %s::schema->AddEntity(%s::%s%s);\n" , SCHEMAget_name ( schema ), SCHEMAget_name ( schema ), ENT_PREFIX , ENTITYget_name ( entity ) );
12151215
12161216 wheres = TYPEget_where ( entity );
12171217
12181218 if ( wheres ) {
1219- fprintf ( files -> create ,
1219+ fprintf ( create ,
12201220 " %s::%s%s->_where_rules = new Where_rule__list;\n" ,
12211221 SCHEMAget_name ( schema ), ENT_PREFIX , ENTITYget_name ( entity ) );
12221222
@@ -1300,8 +1300,8 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap
13001300 * ptr = '\0' ;
13011301 strcat ( ptr , ");\\n" );
13021302 }
1303- fprintf ( files -> create , " wr = new Where_rule(\"%s\");\n" , whereRule_formatted );
1304- fprintf ( files -> create , " %s::%s%s->_where_rules->Append(wr);\n" ,
1303+ fprintf ( create , " wr = new Where_rule(\"%s\");\n" , whereRule_formatted );
1304+ fprintf ( create , " %s::%s%s->_where_rules->Append(wr);\n" ,
13051305 SCHEMAget_name ( schema ), ENT_PREFIX , ENTITYget_name ( entity ) );
13061306
13071307 sc_free ( whereRule );
@@ -1312,7 +1312,7 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap
13121312 uniqs = entity -> u .entity -> unique ;
13131313
13141314 if ( uniqs ) {
1315- fprintf ( files -> create ,
1315+ fprintf ( create ,
13161316 " %s::%s%s->_uniqueness_rules = new Uniqueness_rule__set;\n" ,
13171317 SCHEMAget_name ( schema ), ENT_PREFIX , ENTITYget_name ( entity ) );
13181318
@@ -1325,38 +1325,43 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap
13251325
13261326 LISTdo ( uniqs , list , Linked_List ) {
13271327 int i = 0 ;
1328- fprintf ( files -> create , " ur = new Uniqueness_rule(\"" );
1328+ fprintf ( create , " ur = new Uniqueness_rule(\"" );
13291329 LISTdo_n ( list , e , Expression , b ) {
13301330 i ++ ;
13311331 if ( i == 1 ) {
13321332 /* print label if present */
13331333 if ( e ) {
1334- fprintf ( files -> create , "%s : " , StrToUpper ( ( ( Symbol * )e )-> name ) );
1334+ fprintf ( create , "%s : " , StrToUpper ( ( ( Symbol * )e )-> name ) );
13351335 }
13361336 } else {
13371337 if ( i > 2 ) {
1338- fprintf ( files -> create , ", " );
1338+ fprintf ( create , ", " );
13391339 }
13401340 uniqRule = EXPRto_string ( e );
1341- fprintf ( files -> create , "%s" , uniqRule );
1341+ fprintf ( create , "%s" , uniqRule );
13421342 sc_free ( uniqRule );
13431343 }
13441344 } LISTod
1345- fprintf ( files -> create , ";\\n \");\n " );
1346- fprintf ( files -> create , " %s::%s%s->_uniqueness_rules->Append(ur);\n" ,
1345+ fprintf ( create , ";\\n\");\n" );
1346+ fprintf ( create , " %s::%s%s->_uniqueness_rules->Append(ur);\n" ,
13471347 SCHEMAget_name ( schema ), ENT_PREFIX , ENTITYget_name ( entity ) );
13481348 } LISTod
13491349 }
13501350
13511351 if ( whereRule_formatted_size > 0 ) {
13521352 sc_free ( whereRule_formatted );
13531353 }
1354+ }
13541355
1355- n = ENTITYget_classname ( entity );
1356- fprintf ( files -> classes , "\nclass %s;\n" , n );
1357- fprintf ( files -> classes , "typedef %s * %sH;\n" , n , n );
1358- fprintf ( files -> classes , "typedef %s * %s_ptr;\n" , n , n );
1359- fprintf ( files -> classes , "typedef %s_ptr %s_var;\n" , n , n );
1360- fprintf ( files -> classes , "#define %s__set SDAI_DAObject__set\n" , n );
1361- fprintf ( files -> classes , "#define %s__set_var SDAI_DAObject__set_var\n" , n );
1356+ /** print in classes file: class forward prototype, class typedefs
1357+ * split out of ENTITYprint_new, which is now ENTITYprint_descriptors
1358+ */
1359+ void ENTITYprint_classes ( Entity entity , FILE * classes ) {
1360+ const char * n = ENTITYget_classname ( entity );
1361+ fprintf ( classes , "\nclass %s;\n" , n );
1362+ fprintf ( classes , "typedef %s * %sH;\n" , n , n );
1363+ fprintf ( classes , "typedef %s * %s_ptr;\n" , n , n );
1364+ fprintf ( classes , "typedef %s_ptr %s_var;\n" , n , n );
1365+ fprintf ( classes , "#define %s__set SDAI_DAObject__set\n" , n );
1366+ fprintf ( classes , "#define %s__set_var SDAI_DAObject__set_var\n" , n );
13621367}
0 commit comments