The following declarations are used in the definition of the new automation features:
const
{ Parameter types }
apVoid = $00;
apSmallint = $02;
apInteger = $03;
apSingle = $04;
apDouble = $05;
apCurrency = $06;
apDateTime = $07;
apString = $08;
apWordBool = $0B;
apVariant = $0C;
apTypeMask = $7F;
apByRef = $80;
{ Automation entry flags }
afMethod = $00000001;
afPropGet = $00000002;
afPropSet = $00000004;
afVirtual = $00000008;
type
{ Automation entry parameter list }
PParamList = ^TParamList;
TParamList = record
ResType: Byte;
ParamCount: Byte;
ParamTypes: array[*] of Byte;
end;
{ Automation table entry }
TAutoEntry = record
DispID: Integer;
Name: PShortString;
Flags: Integer;
Params: PParamList;
Address: Pointer;
end;
{ Automation table layout }
TAutoTable = record
EntryCount: Integer;
Entries: array[*] of TAutoEntry;
end;
The compiler will support a new "automated" section which allows automated properties and methods to be declared.
The VMT is extended with a new automation table entry. The entry is NIL if the class has no "automated" section. Otherwise it points to a TAutoTable as defined above.
Only properties and methods can be declared in an "automated" section. Field declarations are not allowed. The visibility of an identifier declared in an "automated" section is the same as a "public" identifier.
All property types, parameter types, and function result types used in property and method declarations in an "automated" section must belong to the following set of types: Smallint, Integer, Single, Double, Currency, TDateTime, String, WordBool, and Variant.
Property declarations in an automated section can only include access specifiers ("read" and "write"). No other specifiers ("index", "stored", "default", "nodefault") are allowed. Access specifiers must list a method identifier (field identifiers are not allowed), and access methods must use register calling conventions. Array properties are supported, but property overrides (i.e. property declarations that don't include the property type) are not allowed.
Method declarations in an "automated" section must use register calling conventions. Methods can be virtual, but not dynamic. Method overrides are allowed in an "automated" section.
A property or method declaration may optionally specify a "dispid" directive. The "dispid" keyword must be followed by an integer constant expression which gives the dispatch ID of the property or method. If a "dispid" clause is not present, the compiler automatically picks a number that is one larger than the largest dispatch ID used by any property or method in the class and its ancestors. Specifying an already used dispatch ID in a "dispid" clause is an error.
For each non-override method declared in an "automated" section, the compiler generates one entry in the automation table. The afMethod flag is set in the Flags field to indicate that the entry represents a method.
For each property declared in an "automated" section, the compiler generates one or two entries in the automation table. The first entry (if present) describes the "read" method and has the afPropGet flag set in the Flags field. The second entry (if present) describes the "write" method and has the afPropPut flag set in the Flags field.
If an automation table entry describes a static method, the Address field contains the address of the method's entry point. If an automation table entry describes a virtual method, the afVirtual flag is set in the Flags field, and the Address field contains the v-table offset of the method.
The Name field of an automation table entry points to a ShortString that contains the identifier of the property or method.
The Params field of an automation table entry points to a TParamList
record that describes the function result and parameter types of the method.
For a procedure method, the ResType field contains apVoid. For a function
method, the ResType field contains the function result type. The ParamCount
field contains the number of parameters, and the ParamTypes array contains
the types of the parameters. The apByRef flag is set to indicate a "var"
parameter.