Entity ENTITYput_superclass( Entity entity ) { #define ENTITYget_type(e) ((e)->u.entity->type) Linked_List l = ENTITYget_supertypes( entity ); EntityTag tag; if( ! LISTempty( l ) ) { Entity super = 0; if( multiple_inheritance ) { Linked_List list = 0; list = ENTITYget_supertypes( entity ); if( ! LISTempty( list ) ) { /* assign superclass to be the first one on the list of parents */ super = ( Entity )LISTpeek_first( list ); } } else { Entity ignore = 0; int super_cnt = 0; /* find the first parent that has attributes (in the parent or any of its ancestors). Make super point at that parent and print warnings for all the rest of the parents. DAS */ LISTdo( l, e, Entity ) /* if there's no super class yet, or if the entity super class [the variable] super is pointing at doesn't have any attributes: make super point at the current parent. As soon as the parent pointed to by super has attributes, stop assigning super and print ignore messages for the remaining parents. */ if( ( ! super ) || ( ! ENTITYhas_explicit_attributes( super ) ) ) { ignore = super; super = e; ++ super_cnt; } else { ignore = e; } if( ignore ) { printf( "WARNING: multiple inheritance not implemented.\n" ); printf( "\tin ENTITY %s\n\tSUPERTYPE %s IGNORED.\n\n", ENTITYget_name( entity ), ENTITYget_name( e ) ); } LISTod; } tag = ( EntityTag ) sc_malloc( sizeof( struct EntityTag_ ) ); tag -> superclass = super; TYPEput_clientData( ENTITYget_type( entity ), ( ClientData ) tag ); return super; }
const char * ENTITYget_CORBAname( Entity ent ) { static char newname [BUFSIZ]; strcpy( newname, ENTITYget_name( ent ) ); newname[0] = ToUpper( newname [0] ); return newname; }
/** * \sa SCOPEget_entities_superclass_order() */ void SCOPE_dfs( Dictionary symbols, Entity root, Linked_List result ) { Entity ent; if( ( ENTITYget_mark( root ) != ENTITY_MARK ) ) { ENTITYput_mark( root, ENTITY_MARK ); LISTdo( ENTITYget_supertypes( root ), super, Entity ) /* if super explicitly defined in scope, recurse. */ /* this chops out USEd and REFd entities */ if( ( ent = ( Entity )DICTlookup( symbols, ENTITYget_name( super ) ) ) != ENTITY_NULL ) { SCOPE_dfs( symbols, ent, result ); } LISTod LISTadd_last( result, ( Generic )root ); }
const char * ENTITYget_classname( Entity ent ) { const char * oldname = ENTITYget_name( ent ); return ( ClassName( oldname ) ); }