c++ comments

This commit is contained in:
Mark Pictor 2013-09-15 19:13:36 -04:00
parent 3b1cc8cc37
commit 8da49be459
5 changed files with 87 additions and 80 deletions

View file

@ -8,20 +8,20 @@
#include <vector>
extern "C" {
#endif //__cplusplus
#endif /* __cplusplus */
typedef struct {
Variable attr;
Entity creator, redefiner, deriver;
} orderedAttr;
///set the entity we're working on, init working variables
/**set the entity we're working on, init working variables */
extern SC_EXPRESS_EXPORT void orderedAttrsInit( Entity e );
///free memory
/**free memory */
extern SC_EXPRESS_EXPORT void orderedAttrsCleanup();
///get next attr; not thread safe (as if the rest of libexpress is)
/**get next attr; not thread safe (as if the rest of libexpress is) */
extern SC_EXPRESS_EXPORT const orderedAttr * nextAttr();
#ifdef __cplusplus
}
@ -29,4 +29,4 @@ extern SC_EXPRESS_EXPORT const orderedAttr * nextAttr();
typedef std::vector<orderedAttr * > oaList;
oaList getAttrList();
#endif //__cplusplus
#endif /* __cplusplus */

View file

@ -55,7 +55,7 @@ static int attr_count; /**< number each attr to avoid inter-entity clashes
ENTITYincode_print (Entity entity, FILES* files,Schema schema)
DAS
*/
static int type_count; ///< number each temporary type for same reason as \sa attr_count
static int type_count; /**< number each temporary type for same reason as \sa attr_count */
extern int any_duplicates_in_select( const Linked_List list );
extern int unique_types( const Linked_List list );
@ -111,7 +111,7 @@ void format_for_std_stringout( FILE * f, const char * orig_buf ) {
fprintf( f, "%s", s_begin );
while( *optr ) {
if( *optr == '\n' ) {
if( * ( optr + 1 ) == '\n' ) { // skip blank lines
if( * ( optr + 1 ) == '\n' ) { /* skip blank lines */
optr++;
continue;
}
@ -1157,7 +1157,7 @@ void DataMemberPrint( Entity entity, Linked_List neededAttr, FILE * file, Schema
}
LISTod;
// add attributes for parent attributes not inherited through C++ inheritance.
/* add attributes for parent attributes not inherited through C++ inheritance. */
if( multiple_inheritance ) {
LISTdo( neededAttr, attr, Variable ) {
DataMemberPrintAttr( entity, attr, file );
@ -1183,23 +1183,23 @@ static void collectAttributes( Linked_List curList, const Entity curEntity, enum
if( ! LISTempty( parent_list ) ) {
if( collect != FIRST_ONLY ) {
// collect attributes from parents and their supertypes
/* collect attributes from parents and their supertypes */
LISTdo( parent_list, e, Entity ) {
if( collect == ALL_BUT_FIRST ) {
// skip first and collect from the rest
/* skip first and collect from the rest */
collect = ALL;
} else {
// collect attributes of this parent and its supertypes
/* collect attributes of this parent and its supertypes */
collectAttributes( curList, e, ALL );
}
}
LISTod;
} else {
// collect attributes of only first parent and its supertypes
/* collect attributes of only first parent and its supertypes */
collectAttributes( curList, ( Entity ) LISTpeek_first( parent_list ), ALL );
}
}
// prepend this entity's attributes to the result list
/* prepend this entity's attributes to the result list */
LISTdo( ENTITYget_attributes( curEntity ), attr, Variable ) {
LISTadd_first( curList, ( Generic ) attr );
}
@ -1255,8 +1255,8 @@ void MemberFunctionSign( Entity entity, Linked_List neededAttr, FILE * file ) {
/* //////////////// */
if( multiple_inheritance ) {
// add the EXPRESS inherited attributes which are non
// inherited in C++
/* add the EXPRESS inherited attributes which are non */
/* inherited in C++ */
LISTdo( neededAttr, attr, Variable ) {
if( ! VARis_derived( attr ) && ! VARis_overrider( entity, attr ) ) {
ATTRsign_access_methods( attr, file );
@ -1492,7 +1492,7 @@ int get_attribute_number( Entity entity ) {
return -1;
}
/// initialize attributes in the constructor; used for two different constructors
/** initialize attributes in the constructor; used for two different constructors */
void initializeAttrs( Entity e, FILE* file ) {
const orderedAttr * oa;
orderedAttrsInit( e );
@ -1534,7 +1534,7 @@ void LIBstructor_print( Entity entity, FILE * file, Schema schema ) {
/* constructor definition */
//parent class initializer (if any) and '{' printed below
/* parent class initializer (if any) and '{' printed below */
fprintf( file, "%s::%s()", entnm, entnm );
/* ////MULTIPLE INHERITANCE//////// */
@ -1553,7 +1553,7 @@ void LIBstructor_print( Entity entity, FILE * file, Schema schema ) {
/* ignore the 1st parent */
const char * parent = ENTITYget_classname( e );
//parent class initializer
/* parent class initializer */
fprintf( file, ": %s() {\n", parent );
fprintf( file, " /* parent: %s */\n%s\n%s\n", parent,
" /* Ignore the first parent since it is */",
@ -1576,7 +1576,7 @@ void LIBstructor_print( Entity entity, FILE * file, Schema schema ) {
} LISTod;
} else { /* if entity has no supertypes, it's at top of hierarchy */
// no parent class constructor has been printed, so still need an opening brace
/* no parent class constructor has been printed, so still need an opening brace */
fprintf( file, " {\n" );
fprintf( file, " /* no SuperTypes */\n" );
}
@ -1599,12 +1599,12 @@ void LIBstructor_print( Entity entity, FILE * file, Schema schema ) {
if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) {
/* 1. create a new STEPattribute */
// if type is aggregate, the variable is a pointer and needs initialized
/* if type is aggregate, the variable is a pointer and needs initialized */
if( TYPEis_aggregate( t ) ) {
fprintf( file, " _%s = new %s;\n", attrnm, TYPEget_ctype( t ) );
}
fprintf( file, " %sa = new STEPattribute( * %s::%s%d%s%s, %s %s_%s );\n",
( first ? "STEPattribute * " : "" ), // first time through, declare 'a'
( first ? "STEPattribute * " : "" ), /* first time through, declare 'a' */
SCHEMAget_name( schema ),
ATTR_PREFIX, count,
( VARis_type_shifter( a ) ? "R" : "" ),
@ -1769,12 +1769,12 @@ void LIBstructor_print_w_args( Entity entity, FILE * file, Schema schema ) {
if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) {
/* 1. create a new STEPattribute */
// if type is aggregate, the variable is a pointer and needs initialized
/* if type is aggregate, the variable is a pointer and needs initialized */
if( TYPEis_aggregate( t ) ) {
fprintf( file, " _%s = new %s;\n", attrnm, TYPEget_ctype( t ) );
}
fprintf( file, " %sa = new STEPattribute( * %s::%s%d%s%s, %s %s_%s );\n",
( first ? "STEPattribute * " : "" ), // first time through, declare a
( first ? "STEPattribute * " : "" ), /* first time through, declare a */
SCHEMAget_name( schema ),
ATTR_PREFIX, count,
( VARis_type_shifter( a ) ? "R" : "" ),
@ -1864,7 +1864,7 @@ bool TYPEis_builtin( const Type t ) {
*/
void AGGRprint_init( FILES * files, const Type t, const char * var_name, const char * aggr_name ) {
if( !TYPEget_head( t ) ) {
//the code for lower and upper is almost identical
/* the code for lower and upper is almost identical */
if( TYPEget_body( t )->lower ) {
if( TYPEget_body( t )->lower->symbol.resolved ) {
if( TYPEget_body( t )->lower->type == Type_Funcall ) {
@ -1873,7 +1873,7 @@ void AGGRprint_init( FILES * files, const Type t, const char * var_name, const c
} else {
fprintf( files->init, " %s->SetBound1(%d);\n", var_name, TYPEget_body( t )->lower->u.integer );
}
} else { //resolved == 0 seems to mean that this is Type_Runtime
} else { /* resolved == 0 seems to mean that this is Type_Runtime */
assert( ( t->superscope ) && ( t->superscope->symbol.name ) && ( TYPEget_body( t )->lower->e.op2 ) &&
( TYPEget_body( t )->lower->e.op2->symbol.name ) );
fprintf( files->init, " %s->SetBound1FromMemberAccessor( &getBound1_%s__%s );\n", var_name,
@ -1892,7 +1892,7 @@ void AGGRprint_init( FILES * files, const Type t, const char * var_name, const c
} else {
fprintf( files->init, " %s->SetBound2(%d);\n", var_name, TYPEget_body( t )->upper->u.integer );
}
} else { //resolved == 0 seems to mean that this is Type_Runtime
} else { /* resolved == 0 seems to mean that this is Type_Runtime */
assert( ( t->superscope ) && ( t->superscope->symbol.name ) && ( TYPEget_body( t )->upper->e.op2 ) &&
( TYPEget_body( t )->upper->e.op2->symbol.name ) );
fprintf( files->init, " %s->SetBound2FromMemberAccessor( &getBound2_%s__%s );\n", var_name,
@ -2297,14 +2297,14 @@ void ENTITYPrint( Entity entity, FILES * files, Schema schema ) {
Linked_List existing = LISTcreate();
Linked_List required = LISTcreate();
// create list of attr inherited from the parents in C++
/* create list of attr inherited from the parents in C++ */
collectAttributes( existing, entity, FIRST_ONLY );
// create list of attr that have to be inherited in EXPRESS
/* create list of attr that have to be inherited in EXPRESS */
collectAttributes( required, entity, ALL_BUT_FIRST );
// build list of unique attr that are required but havn't been
// inherited
/* build list of unique attr that are required but havn't been */
/* inherited */
LISTdo( required, attr, Variable ) {
if( !listContainsVar( existing, attr ) &&
!listContainsVar( remaining, attr ) ) {
@ -2805,7 +2805,7 @@ void strcat_expr( Expression e, char * buf ) {
}
}
/// print t's bounds to end of buf
/** print t's bounds to end of buf */
void strcat_bounds( TypeBody b, char * buf ) {
if( !b->upper ) {
return;
@ -2956,22 +2956,24 @@ void Type_Description( const Type t, char * buf ) {
void TYPEprint_typedefs( Type t, FILE * classes ) {
char nm [BUFSIZ];
Type i;
bool aggrNot1d = true; //added so I can get rid of a goto
bool aggrNot1d = true; /* added so I can get rid of a goto */
/* Print the typedef statement (poss also a forward class def: */
if( TYPEis_enumeration( t ) ) {
/* For enums and sels (else clause below), we need forward decl's so
// that if we later come across a type which is an aggregate of one of
// them, we'll be able to process it. For selects, we also need a decl
// of the class itself, while for enum's we don't. Objects which con-
// tain an enum can't be generated until the enum is generated. (The
// same is basically true for the select, but a sel containing an ent
// containing a sel needs the forward decl (trust me ;-) ). */
that if we later come across a type which is an aggregate of one of
them, we'll be able to process it. For selects, we also need a decl
of the class itself, while for enum's we don't. Objects which con-
tain an enum can't be generated until the enum is generated. (The
same is basically true for the select, but a sel containing an ent
containing a sel needs the forward decl (trust me ;-) ).
*/
if( !TYPEget_head( t ) ) {
/* Only print this enum if it is an actual type and not a redefi-
// nition of another enum. (Those are printed at the end of the
// classes file - after all the actual enum's. They must be
// printed last since they depend on the others.) */
nition of another enum. (Those are printed at the end of the
classes file - after all the actual enum's. They must be
printed last since they depend on the others.)
*/
strncpy( nm, TYPEget_ctype( t ), BUFSIZ );
nm[BUFSIZ-1] = '\0';
fprintf( classes, "class %s_agg;\n", nm );
@ -2991,18 +2993,20 @@ void TYPEprint_typedefs( Type t, FILE * classes ) {
i = TYPEget_base_type( t );
if( TYPEis_enumeration( i ) || TYPEis_select( i ) ) {
/* One exceptional case - a 1d aggregate of an enum or select.
// We must wait till the enum/sel itself has been processed.
// To ensure this, we process all such 1d aggrs in a special
// loop at the end (in multpass.c). 2d aggrs (or higher), how-
// ever, can be processed now - they only require GenericAggr
// for their definition here. */
We must wait till the enum/sel itself has been processed.
To ensure this, we process all such 1d aggrs in a special
loop at the end (in multpass.c). 2d aggrs (or higher), how-
ever, can be processed now - they only require GenericAggr
for their definition here.
*/
aggrNot1d = false;
}
}
if( aggrNot1d ) {
/* At this point, we'll print typedefs for types which are redefined
// fundamental types and their aggregates, and for 2D aggregates(aggre-
// gates of aggregates) of enum's and selects. */
fundamental types and their aggregates, and for 2D aggregates(aggre-
gates of aggregates) of enum's and selects.
*/
strncpy( nm, ClassName( TYPEget_name( t ) ), BUFSIZ );
nm[BUFSIZ-1] = '\0';
fprintf( classes, "typedef %s %s;\n", TYPEget_ctype( t ), nm );
@ -3231,7 +3235,7 @@ static void printEnumCreateHdr( FILE * inc, const Type type ) {
fprintf( inc, " SDAI_Enum * create_%s ();\n", nm );
}
/// See header comment above by printEnumCreateHdr.
/** See header comment above by printEnumCreateHdr. */
static void printEnumCreateBody( FILE * lib, const Type type ) {
const char * nm = TYPEget_ctype( type );
char tdnm[BUFSIZ];
@ -3244,7 +3248,7 @@ static void printEnumCreateBody( FILE * lib, const Type type ) {
fprintf( lib, " return new %s( \"\", %s );\n}\n\n", nm, tdnm );
}
/// Similar to printEnumCreateHdr above for the enum aggregate.
/** Similar to printEnumCreateHdr above for the enum aggregate. */
static void printEnumAggrCrHdr( FILE * inc, const Type type ) {
const char * n = TYPEget_ctype( type );
/* const char *n = ClassName( TYPEget_name(type) ));*/

View file

@ -52,11 +52,11 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7.
#define TYPEtd_name(t) TypeDescriptorName (t)
typedef struct file_holder {
FILE * inc; ///< include file
FILE * lib; ///< library file
FILE * incall; ///< include file for collecting all include files
FILE * initall; ///< for registering all entities from all schemas
FILE * init; ///< contains function to initialize program to use schema's entities
FILE * inc; /**< include file */
FILE * lib; /**< library file */
FILE * incall; /**< include file for collecting all include files */
FILE * initall; /**< for registering all entities from all schemas */
FILE * init; /**< contains function to initialize program to use schema's entities */
FILE * create; /**< DAR - added - to create all schema & ent descriptors. In multiple
* interrelated schemas, must be done before attribute descriptors and
* sub-super links created.
@ -65,7 +65,7 @@ typedef struct file_holder {
* classes, so that all the .h files can refer any of the entity classes.
* Nec. if ent1 of schemaA has attribute ent2 from schemaB.
*/
FILE * names; ///< MAP Nov 2011 - header with namespace for entity and attr descriptors
FILE * names; /**< MAP Nov 2011 - header with namespace for entity and attr descriptors */
FILE * helpers; /**< MAP Mar 2012 - header with inline helper functions. Currently only used for
helper functions to find runtime aggregate bounds */
} File_holder, FILES;
@ -75,9 +75,9 @@ typedef struct file_holder {
*/
typedef struct EntityTag_ * EntityTag;
struct EntityTag_ {
unsigned int started : 1; ///< marks the beginning of processing
unsigned int complete : 1; ///< marks the end of processing
Entity superclass; ///< the entity being used as the supertype - with multiple inheritance only chose one
unsigned int started : 1; /**< marks the beginning of processing */
unsigned int complete : 1; /**< marks the end of processing */
Entity superclass; /**< the entity being used as the supertype - with multiple inheritance only chose one */
};
Entity ENTITYget_superclass( Entity entity );
@ -85,11 +85,11 @@ Entity ENTITYput_superclass( Entity entity );
int ENTITYhas_explicit_attributes( Entity e );
void ENTITYget_first_attribs( Entity entity, Linked_List result );
///these fields are used so that SELECT types are processed in order
/** these fields are used so that SELECT types are processed in order */
typedef struct SelectTag_ * SelectTag;
struct SelectTag_ {
unsigned int started : 1; ///< marks the beginning of processing
unsigned int complete : 1; ///< marks the end of processing
unsigned int started : 1; /**< marks the beginning of processing */
unsigned int complete : 1; /**< marks the end of processing */
};
const char * GetTypeDescriptorName( Type t );

View file

@ -291,7 +291,7 @@ static int checkTypes( Schema schema )
// processable. It checks for conditions which would
// make this true and sets values in type, schema, and
// unknowncnt accordingly. (See checkItem's commenting
// below.) It also return TRUE if i has made type un-
// below.) It also return TRUE if ii has made type un-
// processable. If so, we break - there's no point
// checking the other items of type any more. */
} else {

View file

@ -127,9 +127,9 @@ compareOrigTypes( Type a, Type b ) {
|| ( TYPEis_enumeration( t ) && TYPEis_enumeration( u ) ) ) ) {
return FALSE;
/* Only go further with 1D aggregates of sels or enums. Note that
// for 2D aggrs and higher we do not continue. These are all recog-
// nized to be the same type ("GenericAggregate") by TYPEget_ctype(),
// and do not have to be handled specially here. */
for 2D aggrs and higher we do not continue. These are all recog-
nized to be the same type ("GenericAggregate") by TYPEget_ctype(),
and do not have to be handled specially here. */
}
} else {
return FALSE;
@ -818,7 +818,7 @@ TYPEselect_lib_print_part_one( const Type type, FILE * f, Schema schema,
fprintf( f, " *logStream << \"DAVE ERR entering %s constructor.\" << std::endl;\n", n );
fprintf( f, " }\n#endif\n" );
//create objects for data member pointers. also in two more ctors below, and deleted in dtor which is printed at end of this function.
/* create objects for data member pointers. also in two more ctors below, and deleted in dtor which is printed at end of this function. */
LISTdo( dups, t, Type ) {
if( isAggregateType( t ) && t->u.type->body->base ) {
fprintf( f, " _%s = new %s;\n", SEL_ITEMget_dmname( t ), TYPEget_utype( t ) );
@ -926,9 +926,9 @@ TYPEselect_lib_print_part_one( const Type type, FILE * f, Schema schema,
}
LISTod;
//dtor
/* dtor */
fprintf( f, "%s::~%s()\n{\n", n, n );
//delete objects that data members point to
/* delete objects that data members point to */
LISTdo( dups, t, Type ) {
if( isAggregateType( t ) && t->u.type->body->base ) {
fprintf( f, " if( _%s ) {\n", SEL_ITEMget_dmname( t ) );
@ -1445,12 +1445,13 @@ TYPEselect_lib_part21( const Type type, FILE * f, Schema schema ) {
case select_:
fprintf( f, " _%s.STEPwrite (out, currSch);\n", dm );
/* Select type needs currSch passed too. A Select writes the name of its
// current choice when it writes itself out (e.g. "DATA(33.5)"). Since
// the current choice name may depend on our current schema (it may be a
// schema which USEs "DATA" and renames it to "VAL"), we pass currSch. */
current choice when it writes itself out (e.g. "DATA(33.5)"). Since
the current choice name may depend on our current schema (it may be a
schema which USEs "DATA" and renames it to "VAL"), we pass currSch.
*/
break;
// aggregate, array, bag, set, and list were above with string, binary, etc. moved them because they will be pointers
/* aggregate, array, bag, set, and list were above with string, binary, etc. moved them because they will be pointers */
case aggregate_:
case array_:
case bag_:
@ -1997,9 +1998,10 @@ TYPEselect_print( Type t, FILES * files, Schema schema ) {
/* Check if we're a renamed type, e.g., TYPE B (sel) = A. If so, if A has
// been defined, we process B differently (with a couple of typedef's -
// some are printed in files->classes rather than here). If A has not been
// defined, we must recurse. */
been defined, we process B differently (with a couple of typedef's -
some are printed in files->classes rather than here). If A has not been
defined, we must recurse.
*/
if( ( i = TYPEget_ancestor( t ) ) != NULL ) {
if( !TYPEget_clientData( i ) ) {
TYPEselect_print( i, files, schema );
@ -2009,10 +2011,11 @@ TYPEselect_print( Type t, FILES * files, Schema schema ) {
fprintf( inc, "typedef %s * %sH;\n", nm, nm );
fprintf( inc, "typedef %s_ptr * %s_var;\n", nm, nm );
/* Below are specialized create functions for the renamed sel type (both
// single and aggregate). The functions call the original sel's con-
// structor, passing the new sel's typedescriptor to create a hybrid
// entity - the original select pointing to a new typedesc. These fns
// give the user an easy way to create the renamed type properly. */
single and aggregate). The functions call the original sel's con-
structor, passing the new sel's typedescriptor to create a hybrid
entity - the original select pointing to a new typedesc. These fns
give the user an easy way to create the renamed type properly.
*/
fprintf( inc, "inline SDAI_Select *\ncreate_%s ()", nm );
fprintf( inc, " { return new %s( %s ); }\n\n", nm, tdnm );
fprintf( inc, "inline STEPaggregate *\ncreate_%s_agg ()", nm );