Type information for TypeAccess is scanned from the header files using a
program called `maketa', which looks for class
and
typedef
definitions, and records what it finds. It operates on
all the header files in a given directory at the same time, and it
produces three output files: `xxx_TA_type.h', `xxx_TA_inst.h',
and `xxx_TA.cc', where xxx is given by a "project name" argument.
The first file contains a list of extern
declarations of
instances of the TypeDef type, which is the basic object that
records information about types. Each type that was defined with a
class
or typedef
, or ones that are modifications of basic
types, such as reference or pointer types, are given their own
TypeDef object, which is named with the name of the type with a
leading TA_
prefix. Thus, a class named MyClass would have
corresponding TypeDef object named TA_MyClass, which can be used
directly in programs to obtain type information about the MyClass
object. a Pointers have a _ptr
suffix, and references have a
_ref
suffix. Template instances are represented by replacing the
angle brackets with underbars. The `xxx_TA_type.h' file must be
included in any header files which reference their own type information.
The `xxx_TA_inst.h' file contains declarations of "instance"
objects, which are pointers to a token of each of the classes for which
type information is available. These instances are named TAI_
with the rest the same as the corresponding TA_
name. The
-instances
argument to `maketa' determines if instances are
made, and this can be overridden with the #NO_INSTANCE
and
#INSTANCE
comment directives (see section 17.3 Standard TypeAccess Comment Directives). The
TypeDef object can use an instance object of one of the type-aware
base classes to make a new token of that object given only the name of
the type to be created. This gives the system the power to create and
delete objects at will, which is necessary for the file saving and
loading system to work.
Finally, the `xxx_TA.cc' file contains the actual definitions of
all the type information. It must be compiled and linked in with the
project, and its ta_Init_xxx
function must be called at the start
of the execution of the program before any type information is used.
Note that while `maketa' does process complexities like
template
and multiply inherited classes properly, it does not
deal with multiple versions of the same function which differ only in
argument type in the same way that C++ does. Instead, the scanner just
keeps the last version of a given method defined on the class. This
makes the type information compatible with the limitations of CSS
in this respect, since it does not know how to use argument types to
select the proper function to be called (see section 7.3.1 Differences Between CSS and C++). This
limitation greatly simplifies the way that functions are called by CSS.
It is recommended that you create methods which have some hint as to
what kinds of arguments they expect, in order to get around this
limitation. The taList and taGroup classes, for example,
contain both overloaded and specific versions of the Find
function, so the C++ programmer can call Find
with any of a
number of different argument types, while the CSS programmer can use
the FindName
or FindType
versions of the function.