previous chapter contents page top page next chapter

Class

April 5, 1992
last updated September 30, 1993

Defined in Class.Def 
Inherits from AbstractClass

Class Description

When you create an object, the new object's structure is determined by a template that defines how all objects of its class should be formed. This template that describes a class is an object itself. These template objects describe classes, and so are members of class Class.

Although there are a few methods that are generally useful to all programmers, most of the methods of this class are useful only for developers of system programs such as ObjectMaker. Most programmers can safely ignore most of the details of class Class.


WARNING! Some of the methods previously described in this chapter are now defined in class AbstractClass. Because class Class inherits from class AbstractClass, all these methods are available anyway. These descriptions have been moved to a new AbstractClass chapter.


Remember that if the documentation and the software (especially the definition files) disagree, always trust the software.

Using a Class Object

Class Class is a direct descendant of class AbstractClass. Class Class defines many fields that are used to specify details of the objects of the classes they represent, including the number of fields and methods defined by the class and information about its superclasses.

Unless you're creating a highly specialized tool or are extremely curious, you'll never create a class object in your packages, nor will you define one in an instance definition file. Instead, ObjectMaker will create class objects for you when you use the "define class" syntax in your object definition file.

Programming Information

Instantiate: rarely
Subclass: rarely
Call its methods: rarely

Description of fields

Class Class defines the following fields:

Field Type Description
Inherited from Cited
citation Citation Citation for the class
Inherited from AbstractClass
telescriptName ClassName The class's telescript name
number Unsigned Index into class table
implSuperCount Unsigned Number of superclasses providing implementation
implSuperOffset Unsigned Offset to table of implementation superclasses
methodCount Unsigned Number of methods defined for class
methodOffset Unsigned Offset to table of methods
classFlags Object Miscellaneous class flags
Defined by Class
globalList FieldList List of class's globals
fieldList FieldList List of class's fields
instanceSize UnsignedShort Size of an instance
interfaceCount UnsignedShort Number of interface ancestors
referenceMask Unsigned Shows which fields are objects
copyReferenceMask Unsigned Shows which fields are copiable
totalCopyReferences Unsigned Number of copy references
globalData Globals Class's global data
instanceList InstanceList List of all instances of class
patchPlaces ObjectList List of all patch code objects
patchOffsets FixedList List of all patch code offsets

Method Descriptions

Object Management

Install

overrides Install

Call: rarely
Override: sometimes

Class_Install sets up the class variables for the class. You should override Install if you want your class to initialize any global variables when the system starts up. See Object_Install for more information.

Init

overrides Init
Call: rarely
Override: sometimes

When a new object is created, the system calls Init to allow the new object to set up its fields. The params parameter points to a structure that's declared like this:

typedef struct
{
ObjectID author;
ObjectID publisher;
} ClassInitParamsRec, *ClassInitParamsPtr;

Class_Init sets up fields of the new class object as follows:

Field initialized Initial value
instanceSize 0
totalCopyReferences 0

You should override Init if your class defines any fields that should be set up to initial values when a new object is created. See Object_Init for more information.

Memory Use

Stabilize

overrides Stabilize

Call: rarely
Override: sometimes

When a new object is created and initialized, the object goes through a period of instability while its initial values are set up. When this unstable period is over, the system calls Stabilize to notify an object that the system won't be making frequent changes to the object.

Class_Stabilize sets the object's instanceSize field and creates a list of the class's instances. You should override Stabilize if you want to provide a way for objects of your class to convert to a tighter form, as by removing unused or obsolete data.

See Object_Stabilize for more information.

Expand

operation Expand()

Call: rarely
Override: rarely

The system calls Expand to convert the object to a form that might occupy more space but allows faster modification. If you've overridden Stabilize to create a tight storage format, you probably also want to override Expand. Expand should convert objects of your class to a form that makes them easier to modify.

Operations and Methods

MakeGlobals

overrides MakeGlobals()

Call: rarely
Override: rarely

When the class object is created, the system calls MakeGlobals to allocate space for the class variables and initialize them to zero. MakeGlobals also sets up the class object's globalData field to point to the class variables.

Debugging and Testing

Validate

overrides Validate

Call: rarely
Override: sometimes

Class_Validate checks the following conditions and performs the following actions if the conditions are true:

Condition Action if true
Object has an instance list with a non-zero length Prints debug message: instance list does not have the
name that doesn't consist of the class name proper name
followed by " instances"
Instance list includes an object that's not an instance of the class Prints debug message: (instance) is not an instance of (class), but is in the instance list

Class_Validate calls its inherited implementation.

You should override Validate if you want objects of your class to perform any additional validity checking. See Object_Validate for more information.