6.2.3 Structure of TypeAccess Type Data

The classes used in storing type information in the TypeAccess system are all defined in the `ta/typea.h' header file. Basically, there are a set of Space objects, which all derive from a basic form of the List object (defined in `ta/ta_list.h', which represent type spaces, member spaces, method spaces, etc. These are just containers of objects. The spaces are: TypeSpace, MemberSpace, MethodSpace, EnumSpace, TokenSpace. Note that they contain functions for finding, printing, and generally manipulating the objects they contain.

There are corresponding TypeDef, MemberDef, MethodDef, and EnumDef objects which hold specific information about the corresponding aspect of type information. The TypeDef contains the following fields:

String name
Holds the name of the type.
String desc
A description which is obtained from the user's comment following the declaration of the type.
uint size
The size of the object in bytes.
int ptr
The number of pointers this type is from a basic non-pointer type.
bool ref
True if this is a reference type.
bool internal
True if this type information was automatically or internally generated. This typically refers to pointer and reference types which were created when the scanner encountered their use in arguments or members of other classes that were being scanned.
bool formal
True for basic level objects like TA_class and TA_template which are are formal parents (par_formal) of types that users declare. These provide a way of determining some basic features of the type. Formal type objects are declared and installed automatically by the type scanning system.
bool pre_parsed
True if this type was registered as previously parsed by the type scanning system (i.e., it encountered an `extern TypeDef TA_xxx' for this type, where xxx is the name of the type). These types don't get included in the list of types for this directory. This makes it possible to do type scanning on a complex set of nested libraries.
String_PArray inh_opts
These are the options (comment directives) that are inherited by this type (i.e., those declared with a ## instead of a #).
String_PArray opts
These are all of the options (comment directives) for this type, including inherited and non-inherited ones.
String_PArray lists
A list of the #LIST_xxx values declared for this type.
TypeSpace parents
A list of parents of this type. There are multiple parents for multiple-inheritance class types, and for internal types which are the combination of basic types, such as unsigned long, etc.
int_PArray par_off
A list of offsets from the start of memory occupied by this class where the parent object begins. These are used for multiply inherited class types. They are in a one-to-one correspondence with the parents entries.
TypeSpace par_formal
A list of the formal parents of this type, including TA_class, etc.
TypeSpace par_cache
A special cache of frequently-queried type parents. Currently if a type derives from taBase, then TA_taBase shows up here (because a lot of the TypeAccess code checks if something is derived from the basic type-aware type taBase).
TypeSpace children
A list of all the types that are derived from this one.
void** instance
A pointer to a pointer of an instance of this type, if it is kept. The GetInstance function should be used to get the actual instance pointer.
TokenSpace tokens
A list of the actual instances or tokens of this type that have been created by the user (the TAI_xxx instance object is not registered here). These are not kept if the type does not record tokens (see the #NO_TOKENS comment directive, section 6.3.1 Object Directives).
taivType* iv
A pointer to an object which defines how a token of this type appears in a GUI edit dialog. There is a "bidding" procedure which assigns these objects, allowing for the user to add new specialized representations which out-bid the standard ones. This bidding takes place when the gui stuff is initialized, and the results are stored here.
taivEdit* ive
This is like the iv pointer, except it is the object which is used to generate the entire edit dialog for this object. It also is the result of a bidding procedure.
taBase_Group* defaults
These are pointers to different TypeDefault objects for this type. Each TypeDefault object is for a different scope where these types can be created (i.e., a different Project in the PDP++ software).
EnumSpace enum_vals
Contains the enum objects contained within a given enum declaration.
TypeSpace sub_types
These are the sub-types declared with a typedef, enum, or as part of a template instantiation within a class object.
MemberSpace members
These are the members of a class object.
MethodSpace methods
These are the methods of a class object.
TypeSpace templ_pars
These are the template parameters for template objects. In the template itself, they are the formal parameters (i.e., T), but in the template instance they point to the actual types with which the template was instantiated.

The most important functions on the TypeDef object are as follows:

bool HasOption(const char* op)
Checks to see if the given option (comment directive) (don't include the #) is present on this type.
String OptionAfter(const char* op)
Returns the portion of the option (comment directive) after the given part. This is used for things like #MENU_ON_xxx to obtain the xxx part. If option is not present, an empty string is returned.
InheritsFrom(TypeDef* tp)
Checks if this type inherits from the given one (versions that take a string and a reference to a TypeDef are also defined). Inheritance is defined only for classes, not for a pointer to a given class, for example. Thus, both the argument and the type this is called on must be non-pointer, non-reference types.
DerivesFrom(TypeDef* tp)
Simply checks if the given type appears anywhere in the list of parents for this type. Thus, a pointer to a class derives from that class, but it does not inherit from it.
String GetValStr(void* base, void* par=NULL, MemberDef* memb_def=NULL)
Uses the type-scanned information to obtain a string representation of the value of an instance of this type. base is a pointer to the start of a token of this type, and par and member_def can be passed if it is known that this token is in a parent class at a particular member def. This and the following function are used widely, including for saving and loading of objects, etc.
SetValStr(const char* val, void* base, void* par=NULL, MemberDef* memb_def=NULL)
Takes a string representation of a type instance, and sets the value of the token accordingly (it is the inverse of GetValStr).
CopyFromSameType(void* trg_base, void* src_base, MemberDef* memb_def=NULL)
Uses the type-scanned information to copy from one type instance to the next. Any class objects that are members are copied using that object's copy operator if one is defined (this is only known for derivatives of the taBase base class).
Dump_Save(ostream& strm, void* base, void* par=NULL, int indent=0)
This will save the given type object to a file. Files are saved in an ASCII format, and are capable of saving pointers to other objects when these objects derive from the taBase object. Special code is present for dealing with groups of objects stored in the taList or taGroup classes. See section 6.2.5 The Dump-file Format for Saving/Loading for more details.
Dump_Load(istream& strm, void* base, void* par=NULL)
This will load a file saved by the Dump_Save command.

The other Def objects are fairly straightforward. Each includes a name and desc field, and a list of opts (comment directives) and lists. Also, each contains an iv field which represents the item in the GUI edit dialog, and is the result of a bidding process (see the iv field in the TypeDef object above). They all have the HasOption and OptionAfter functions plus a number of other useful functions (see the `ta/typea.h' for details).

MemberDef objects contain the following additional fields. Note that derived classes contain links (not copies) of the members and methods they inherit from their parent, except when the class has multiple parents, in which case copies are made for the derived class because the offset information will no longer be the same for the derived class.

TypeDef* type
The type of the member.
ta_memb_ptr off
The address or offset of this member relative to the start of the memory allocated for the class in which this member was declared.
int base_off
The offset to add to the base address (address of the start of the class object) to obtain the start of the class this member was declared in. This is for members of parents of multiply-inherited derived classes.
bool is_static
True if the member was declared static. Thus, it can be accessed without a this pointer. The addr field contains its absolute address.
void* addr
The absolute address (not relative to the class object) of a static member.
bool fun_ptr
True if the member is actually a pointer to a function.

The MethodDef object contains the following additional variables:

TypeDef* type
The type of the method.
bool is_static
True if the method was declared static.
ta_void_fun addr
The address of a static method. Non-static methods do not have their addresses recorded. Methods are called via the stubp function, if the -css option was used during scanning.
int fun_overld
The number of times this function was overloaded (i.e., a function of the same name was declared in the class or its parents). TypeAccess does not perform name mangling on functions, so only one instance of a given method is recorded. It is the last one that the scanner encounters that is kept.
int fun_argc
The number of arguments for this function.
int fun_argd
The index where the arguments start having default values. Thus, the function can be called with a variable number of arguments from fun_argd to fun_argc.
TypeSpace arg_types
These are the types of the arguments.
String_PArray arg_names
These are the names of the arguements (in one-to-one correspondence with the types).
css_fun_stub_ptr stubp
A pointer to a "stub" function which calls this method using cssEl objects as arguments. This function is defined in the `xxx_TA.cc' file if the -css argument is given to `maketa'. The cssEl objects have conversion functions for most types of arguments, so that the function is called by casting the arguments into the types expected by the function. Pointers to class objects are handled by cssTA objects which have a pointer and a corresponding TypeDef pointer, so they know what kind of object they point to, making conversion type-safe. These stubs return a cssEl object. They also take a void* for the this object. These stubs are used both by CSS and to call methods from the edit dialogs from menus and buttons.