Class Metaobjects


 o Public Members (cont.)



Member Metaobjects


 o Public Members (cont.)



TemplateClass Metaobjects

TemplateClass metaobjects represent template classes. It is a subclass of Class.

The metaclass for any template class must be TemplateClass or its subclass.


 o Public Members


C functions

Class metaobjects can be used for translating C functions.

If the compiler encounters a C function declaration, it calls TranslateMemberFunction() on the Class metaobject for C functions. The Member metaobject representing the C function is passed to that member function as an argument. All C functions are handled by a single Class metaobject.

If the compiler encounters a C function call, then it calls TranslateFunctionCall() on the Class metaobject for C functions.

To translate C functions, first define the class for the metaobject handling C functions. Then, call this member function:

This member function must be called just after the compiler has started. For more information about when it should be called, see the description of Class::ChangeDefaultMetaclass().



Representation of Types

TypeInfo metaobjects represent types.


 o Public Members (cont.)

The example program shown below prints the name and all the arguments of the given template type. Suppose that a variable tinfo is a TypeInfo metaobject representing a template type:

TypeInfo t;
tinfo.FullTypeName()->Display();
int i = 0;
while (tinfo.NthTemplateArgument(i++, t))
    t.FullTypeName()->Display();



Representation of Environments

Environment metaobjects represent bindings between names and types.


 o Public Members (cont.)



Shigeru Chiba
Copyright © 2000-2001 Shigeru Chiba. All rights reserved.