Skip to content

Commit 5a6b972

Browse files
davywmpictor
authored andcommitted
Moved type init code to type specific files.
1 parent 9e6b419 commit 5a6b972

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

src/exp2cxx/classes.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,9 +1270,6 @@ void MemberFunctionSign( Entity entity, Linked_List neededAttr, FILE * file ) {
12701270

12711271
/* print creation function for class */
12721272
fprintf( file, "inline %s * create_%s() {\n return new %s;\n}\n\n", entnm, entnm, entnm );
1273-
1274-
/* print init function for class */
1275-
fprintf( file, "void init_%s(Registry& reg);\n\n", entnm );
12761273
}
12771274

12781275
/**************************************************************//**
@@ -2285,7 +2282,7 @@ static bool listContainsVar( Linked_List l, Variable v ) {
22852282
}
22862283

22872284
void ENTITYPrint_h( const Entity entity, Linked_List neededAttr, Schema schema ) {
2288-
const char *name = ENTITYget_classname( entity );
2285+
char *name = ENTITYget_classname( entity );
22892286
char filename[MAX_LEN];
22902287
FILE *file = NULL;
22912288

@@ -2305,6 +2302,8 @@ void ENTITYPrint_h( const Entity entity, Linked_List neededAttr, Schema schema )
23052302
DataMemberPrint( entity, neededAttr, file );
23062303
MemberFunctionSign( entity, neededAttr, file );
23072304

2305+
fprintf( file, "void init_%s(Registry& reg);\n\n", name );
2306+
23082307
fprintf( file, "namespace %s {\n", SCHEMAget_name( schema ) );
23092308
ENTITYnames_print( entity, file );
23102309
fprintf( file, "}\n\n" );
@@ -2315,7 +2314,7 @@ void ENTITYPrint_h( const Entity entity, Linked_List neededAttr, Schema schema )
23152314
}
23162315

23172316
void ENTITYPrint_cc( const Entity entity, Linked_List neededAttr, Schema schema ) {
2318-
const char *name = ENTITYget_classname( entity );
2317+
char *name = ENTITYget_classname( entity );
23192318
char filename[MAX_LEN];
23202319
FILE *file = NULL;
23212320

@@ -2363,7 +2362,6 @@ void ENTITYPrint_cc( const Entity entity, Linked_List neededAttr, Schema schema
23632362
** Status: complete 1/15/91
23642363
******************************************************************/
23652364
void ENTITYPrint( Entity entity, FILES * files, Schema schema ) {
2366-
23672365
char * n = ENTITYget_name( entity );
23682366
Linked_List remaining = LISTcreate();
23692367

@@ -3218,7 +3216,7 @@ int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema ) {
32183216
}
32193217

32203218
void TYPEPrint_h( const Type type, Schema schema ) {
3221-
const char *name = TYPEget_ctype( type );
3219+
char *name = TYPEget_ctype( type );
32223220
char filename[MAX_LEN];
32233221
FILE *file = NULL;
32243222

@@ -3238,13 +3236,15 @@ void TYPEPrint_h( const Type type, Schema schema ) {
32383236
else if ( TYPEis_select( type ) )
32393237
TYPEselect_inc_print( type, file );
32403238

3239+
fprintf( file, "void init_%s(Registry& reg);\n\n", TYPEget_ctype( type )/*name*/ );
3240+
32413241
FILEclose(file);
32423242

32433243
DEBUG( "DONE TYPEPrint_h\n" );
32443244
}
32453245

32463246
void TYPEPrint_cc( const Type type, Schema schema ) {
3247-
const char *name = TYPEget_ctype( type );
3247+
char *name = TYPEget_ctype( type );
32483248
char filename[MAX_LEN];
32493249
FILE *file = NULL;
32503250

@@ -3268,16 +3268,22 @@ void TYPEPrint_cc( const Type type, Schema schema ) {
32683268
else if ( TYPEis_select( type ) )
32693269
TYPEselect_lib_print( type, file );
32703270

3271+
fprintf( file, "\nvoid init_%s( Registry& reg ) {\n", TYPEget_ctype( type ) );
3272+
TYPEprint_init( type, file, schema );
3273+
fprintf( file, "}\n\n" );
3274+
32713275
FILEclose(file);
32723276

32733277
DEBUG( "DONE TYPEPrint_cc\n" );
32743278
}
32753279

32763280
void TYPEPrint( const Type type, FILES *files, Schema schema ) {
3277-
const char *name = TYPEget_ctype( type );
3281+
char *name = TYPEget_ctype( type );
32783282

32793283
fprintf( files->inc, "#include \"type/%s.h\"\n", name);
32803284

3285+
fprintf( files->init, " init_%s( reg );\n", name );
3286+
32813287
TYPEPrint_h( type, schema );
32823288
TYPEPrint_cc( type, schema );
32833289
}
@@ -3401,21 +3407,21 @@ static void printEnumAggrCrBody( FILE * lib, const Type type ) {
34013407
fprintf( lib, " return new %s_agg( %s );\n}\n", n, tdnm );
34023408
}
34033409

3404-
void TYPEprint_init( const Type type, FILES * files, Schema schema ) {
3410+
void TYPEprint_init( const Type type, FILE * file, Schema schema ) {
34053411
char tdnm [BUFSIZ];
34063412
char typename_buf[MAX_LEN];
34073413

34083414
strncpy( tdnm, TYPEtd_name( type ), BUFSIZ );
34093415

34103416
if( isAggregateType( type ) ) {
3411-
AGGRprint_init( files->init, type, tdnm, type->symbol.name );
3417+
AGGRprint_init( file, type, tdnm, type->symbol.name );
34123418
}
34133419

34143420
/* fill in the TD's values in the SchemaInit function (it is already
34153421
declared with basic values) */
34163422

34173423
if( TYPEget_RefTypeVarNm( type, typename_buf, schema ) ) {
3418-
fprintf( files->init, " %s->ReferentType(%s);\n", tdnm, typename_buf );
3424+
fprintf( file, " %s->ReferentType(%s);\n", tdnm, typename_buf );
34193425
} else {
34203426
switch( TYPEget_body( type )->type ) {
34213427
case aggregate_: /* aggregate_ should not happen? DAS */
@@ -3424,9 +3430,9 @@ void TYPEprint_init( const Type type, FILES * files, Schema schema ) {
34243430
case set_:
34253431
case list_: {
34263432
if( isMultiDimAggregateType( type ) ) {
3427-
print_typechain( files->init, TYPEget_body( type )->base,
3433+
print_typechain( file, TYPEget_body( type )->base,
34283434
typename_buf, schema, type->symbol.name );
3429-
fprintf( files->init, " %s->ReferentType(%s);\n", tdnm,
3435+
fprintf( file, " %s->ReferentType(%s);\n", tdnm,
34303436
typename_buf );
34313437
}
34323438
break;
@@ -3439,17 +3445,17 @@ void TYPEprint_init( const Type type, FILES * files, Schema schema ) {
34393445
/* DAR - moved fn call below from TYPEselect_print to here to put all init
34403446
** info together. */
34413447
if( TYPEis_select( type ) ) {
3442-
TYPEselect_init_print( type, files->init );
3448+
TYPEselect_init_print( type, file );
34433449
}
34443450
#ifdef NEWDICT
34453451
/* DAS New SDAI Dictionary 5/95 */
34463452
/* insert the type into the schema descriptor */
3447-
fprintf( files->init,
3453+
fprintf( file,
34483454
" ((SDAIAGGRH(Set,DefinedTypeH))%s::schema->Types())->Add((DefinedTypeH)%s);\n",
34493455
SCHEMAget_name( schema ), tdnm );
34503456
#endif
34513457
/* insert into type dictionary */
3452-
fprintf( files->init, " reg.AddType (*%s);\n", tdnm );
3458+
fprintf( file, " reg.AddType (*%s);\n", tdnm );
34533459
}
34543460

34553461
/** print name, fundamental type, and description initialization function

src/exp2cxx/classes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void TYPEprint_definition( Type, FILES *, Schema );
114114
void TYPEprint_new( const Type, FILE *, Schema );
115115
void TYPEprint_typedefs( Type, FILE * );
116116
void TYPEprint_descriptions( const Type, FILES *, Schema );
117-
void TYPEprint_init( const Type type, FILES * files, Schema schema );
117+
void TYPEprint_init( const Type type, FILE * file, Schema schema );
118118
void AGGRprint_init( FILE * file, const Type t,
119119
const char * var_name, const char * aggr_name );
120120
void TYPEselect_init_print( const Type type, FILE* f );

src/exp2cxx/classes_wrapper.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void SCOPEPrint( Scope scope, FILES * files, Schema schema, ComplexCollect * col
196196
// Write the SdaixxxInit() fn (in .init.cc file):
197197
// Do the types:
198198
SCOPEdo_types( scope, t, de ) {
199-
TYPEprint_init( t, files, schema );
199+
// TYPEprint_init( t, files, schema );
200200
}
201201
SCOPEod;
202202
// (The entities are done as a part of ENTITYPrint() below.)
@@ -449,7 +449,7 @@ void SCHEMAprint( Schema schema, FILES * files, void * complexCol,
449449
fprintf( initfile, "#include <sc_memmgr.h>\n" );
450450
fprintf( files->init, "\n#include \"%sHelpers.h\"\n", schnm );
451451

452-
fprintf( initfile, "\nvoid %sInit (Registry& reg) {\n std::string str;\n", schnm );
452+
fprintf( initfile, "\nvoid %sInit (Registry& reg) {\n", schnm );
453453

454454
fprintf( createall, "// Schema: %s\n", schnm );
455455
fprintf( createall, " %s::schema = new Schema(\"%s\");\n",

0 commit comments

Comments
 (0)