Title

Page 228

Reflection

New type information metaobjects can be initialized with two functions, one for instantiating type-info objects and one for creating extTypeInf o objects. void newTypeId (char* typeName) ; void newTypeInf o (char* typeName, bool builtIn, bool pointer);

The newTypeInf o ( ) function also calculates and sets the size of a type. The function delete ~ n of( ) deletes all available information about a type, but only if no other class of the system contains a reference to an object of that type. void deleteInfo(char* typeName);

We define four functions for adding new or modifying existing type information. The functions addBase ( ) and dele teBase ( ) respectively add and remove base class information, while the functions addData ( ) and deleteData 0 respectively add and delete data member information. void addBase(char* typeName, char* baseName); void addData(char* typeName, char* memberType,char* memberName); void deleteBase(char* typeName, char* baseName); void deleteData (char* typeName, char* memberName) ;

Before executing changes, all functions perform consistency checks. For example, to set base class information, corresponding type-in•’o and e x t ~ y p ~e n ofobjects must be available. Two functions support modification of the 'object creator' metaobject. void addcreationcode (char* typeName) ; void deleteCreationCode(char* typeName);

Internally, the metaobject protocol needs functions for calculating type sizes and offsets of base classes and data members. These functions are compiler-dependent and must therefore be changed when using a different compiler. One way to support changing these functions is provided by the Strategy pattern [GHJV95].To maintain type-info and extTypeInfo objects, the metaobject protocol maintains two maps, tMap and eMap. These maps offer functions to add, remove and find elements.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.