TPaxCompiler Registration Routines


RegisterTypeDeclaration

Registeres set type, enumeration type, subrange type or shortstring type by its declaration.
function RegisterTypeDeclaration(LevelId: Integer;
const Declaration: String): integer;

Arguments

LevelId
Id of namespace.
Declaration
Declaration of type.

Example

RegisterTypeDeclaration(0, 'TString5 = String[5];');

RegisterInterfaceType

Registeres an interface type.
function RegisterInterfaceType(LevelId: Integer;
const TypeName: String; const GUID: TGUID): Integer;

Arguments

LevelId
Id of namespace.
TypeName
Name of interface type.
GUID
GUID of interface type.

RegisterSupportedInterface

Registeres supported interface type.
procedure RegisterSupportedInterface(TypeId: Integer;
const GUID: TGUID);

Arguments

TypeId
Id of an interface type.
GUID
GUID of supported interface type.

RegisterClassType

Registeres class type for paxCompiler.
function RegisterClassType(LevelId: Integer; const TypeName: String; AncestorId: Integer): Integer; overload;
function RegisterClassType(LevelId: Integer; C: TClass): Integer; overload;

Example

H_HostClass := RegisterClassType(0, THostClass);

RegisterClassReferenceType

Registeres class reference type for paxCompiler.
function RegisterClassReferenceType(LevelId: Integer; const TypeName: String; OriginClassId: Integer): Integer;

Example

H := RegisterNamespace(0, 'Classes');
G := RegisterClassType(H, TPersistent);
RegisterClassReferenceType(H, 'TPersistentClass', G);

RegisterClassTypeField

Registers field of class type for paxCompiler.
function RegisterClassTypeField(TypeId: Integer; const FieldName: String; FieldTypeID: Integer; FieldShift: Integer = -1): Integer;

Example

type
  THostClass = class(TComponent)
    Z: Integer;
  end;

.............................
H_HostClass := RegisterClassType(0, THostClass);
RegisterHeader(H_HostClass, 'constructor Create(AOwner: TComponent);', @THostClass.Create);
H_Z := RegisterClassTypeField(H_HostClass, 'Z', typeINTEGER, Integer(@THostClass(nil).Z));

RegisterProperty

Registeres public property for paxCompiler.
function RegisterProperty(LevelId: Integer; const PropName: String; PropTypeID, ReadId, WriteId: Integer;IsDefault: Boolean): Integer; overload;
function RegisterProperty(LevelId: Integer; const Header: String): Integer; overload;

Example

H_HostClass := RegisterClassType(0, THostClass);
RegisterHeader(H_HostClass, 'constructor Create(AOwner: TComponent);', @THostClass.Create);
H_GetItem := RegisterHeader(H_HostClass, 'function GetItem(I, J: Integer): Integer;', @THostClass.GetItem);
H_SetItem := RegisterHeader(H_HostClass, 'procedure SetItem(I, J: Integer; Value: Integer);', @THostClass.SetItem);
RegisterProperty(H_HostClass, 'property Items[I, J: Integer]: Integer read GetItem write SetItem; default;');

RegisterEnumType

Registeres enumeration type for paxCompiler.
function RegisterEnumType(LevelId: Integer; const TypeName: String; TypeBaseId: Integer = _typeINTEGER): Integer;

Example

H_TMyEnum := RegisterEnumType(0, 'TMyEnum');
RegisterEnumValue(H_TMyEnum, 'Green', 0);
RegisterEnumValue(H_TMyEnum, 'Red', 1);

RegisterEnumValue

Registeres a value of enumeration type.
function RegisterEnumValue(EnumTypeId: Integer; const FieldName: String; const Value: Integer): Integer;

Example

H_TMyEnum := RegisterEnumType(0, 'TMyEnum');
RegisterEnumValue(H_TMyEnum, 'Green', 0);
RegisterEnumValue(H_TMyEnum, 'Red', 1);

RegisterRTTIType

Registeres a Delphi type that has RTTI (Run time type information) for paxCompiler.
function RegisterRTTIType(LevelId: Integer; pti: PTypeInfo): Integer;

Example

RegisterRTTIType(TypeInfo(TMyEnum));

RegisterTypeAlias

Registeres type alias for paxCompiler.
function RegisterTypeAlias(LevelId:Integer;
const TypeName: String; OriginTypeId: Integer): Integer;

Example

RegisterTypeAlias(H, 'Longint', _typeINTEGER);

RegisterArrayType

Registeres array type for paxCompiler.
function RegisterArrayType(LevelId: Integer; const TypeName: String; RangeTypeId, ElemTypeId: Integer): Integer;

Arguments

LevelId
Id of namespace.
TypeName
Name of array type.
RangeTypeId
Id of ordinal type that specifies range of array.
ElemType
Id of type that specifies type of array element.

Example

H_Range := RegisterSubrangeType(0, 'MySubrangeType', _typeCHAR, ord('A'), ord('Z'));
H_TMyPoint := RegisterRecordType(0, 'TMyPoint');
RegisterRecordTypeField(H_TMyPoint, 'X', _typeINTEGER);
RegisterRecordTypeField(H_TMyPoint, 'Y', _typeINTEGER);
H_Array := RegisterArrayType(0, 'MyArray', H_Range, H_TMyPoint);

RegisterDynamicArrayType

Registeres dynamic array type for paxCompiler. Returns id of type.
function RegisterDynamicArrayType(LevelId: Integer;
const TypeName: String; ElemTypeId: Integer): Integer;

Arguments

LevelId
Id of namespace.
TypeName
Name of type.
ElemTypeId
Id of type of array element.

RegisterNamespace

Registeres a namespace for the paxCompiler.
function RegisterNamespace(LevelId: Integer; const NamespaceName: String): Integer;

Arguments

LevelId
Id of owner namespace.
NamespaceName
Name of namespace.

Example

id := RegisterNamespace(0, 'MyNamespace'); // 0 represents noname namespace
RegisterVariable(id, 'MyVar', _typeINTEGER, @MyVar);

RegisterRecordType

Registeres a record type.
function RegisterRecordType(LevelId: Integer; const TypeName: String): Integer;

Arguments

LevelId
Id of owner record type or id of namespace.
TypeName
Name of record type.

Example

H_TMyPoint := RegisterRecordType(0, 'TMyPoint');
RegisterRecordTypeField(H_TMyPoint, 'X', _typeINTEGER);
RegisterRecordTypeField(H_TMyPoint, 'Y', _typeINTEGER);

RegisterRoutine

Registeres header of function or procedure for paxCompiler.
function RegisterRoutine(LevelId: Integer; const Name: String; ResultTypeID: Integer; CallConvention: Integer): Integer;

Arguments

LevelId
Id of owner namespace.
Name
Name of procedure or function.
ResultTypeID
Id of result type.
CallConvention
_ccSTDCALL = 1 _ccREGISTER = 2

Example

H_IntToStr := RegisterRoutine(0, 'IntToStr', _typeSTRING, _ccREGISTER);
RegisterParameter(H_IntToStr, _typeINTEGER, _Unassigned);

RegisterMethod

Registeres method of Delphi class.
function RegisterMethod(LevelId: Integer; const MethodName: String; ResultTypeID: Integer; CallConvention: Integer; Address: Pointer = nil; IsShared: Boolean = false): Integer;

Arguments

LevelId
Id of class.
MethodName
Name of method.
ResultTypeID
Id of type of result.
CallConvention
Call convention.
IsShared
True, if it is static (shared) method.

Example

RegisterMethod(H_HostClass, 'MyMethod', _typeINTEGER, ccREGISTER, @THostClass.MyMethod, false);

RegisterConstructor

Registeres construcor of a Delphi class for paxCompiler.
function RegisterConstructor(LevelId: Integer; const SubName: String; Address: Pointer = nil): Integer;

Example

H := RegisterConstructor(H_HostClass, 'Create', @THostClass.Create);

RegisterParameter

Registeres parameter of a host-defined procedure of function.
function RegisterParameter(HSub: Integer; ParamTypeID: Integer; const DefaultValue: Variant; ByRef: Boolean = false): Integer;

Arguments

HSub
Id of routine.
ParamTypeId
Id of type of parameter.
DefaultValue
Default value of parameter.
ByRef
If 'true', this is the variable parameter, otherwise this is the value parameter.

Example

H_IntToStr := RegisterRoutine(0, 'IntToStr', _typeSTRING, _ccREGISTER);
RegisterParameter(H_IntToStr, _typeINTEGER, _Unassigned);

RegisterPointerType

Registeres a pointer type for paxCompiler.
function RegisterPointerType(LevelId: Integer;
const TypeName: String; OriginTypeId: Integer): Integer;

Arguments

LevelId
Id of namespace.
TypeName
Name of pointer type.
OriginTypeId
Id of origin type.

Example

H_TMyPoint := RegisterRecordType(0, 'TMyPoint');
RegisterRecordTypeField(H_TMyPoint, 'X', _typeINTEGER);
RegisterRecordTypeField(H_TMyPoint, 'Y', _typeINTEGER);
H_PMyPoint := RegisterPointerType(0, 'PMyPoint', H_TMyPoint);

RegisterProceduralType

Registeres a procedural type for paxCompiler.
function RegisterProceduralType(LevelId: Integer; const TypeName: String; SubId: Integer): Integer;

Arguments

LevelId
Id of namespace.
TypeName
Name of type.
SubId
Id of header of a subroutine.

Example

H_IntToStr := RegisterRoutine(0, 'IntToStr', _typeSTRING, _ccREGISTER);
RegisterParameter(H_IntToStr, _typeINTEGER, _Unassigned);
H_FuncType := RegisterProceduralType(0, 'TFuncType', H_IntToStr);

RegisterSetType

Registeres a set type for paxCompiler.
function RegisterSetType(LevelId: Integer; const TypeName: String; OriginTypeId: Integer): Integer;

Arguments

LevelId
Id of namespace.
TypeName
Name of set type.
OriginTypeId
Id of origin type.

Example

RegisterSetType(0, 'TMySet', _typeCHAR);

RegisterSubrangeType

Registeres a subrange type for the paxCompiler.
function RegisterSubrangeType(LevelId: Integer; const TypeName: String; TypeBaseId: Integer; const B1, B2: Integer): Integer;

Arguments

LevelId
Id of namespace.
TypeName
Name of subrange type.
TypeBaseId
Id of base type.
B1
Low bound.
B2
High bound.

Example

RegisterSubrangeType(0, 'MySubrangeType', _typeCHAR, ord('A'), ord('Z'));

RegisterConstant

Registeres a constant for paxCompiler.
function RegisterConstant(LevelId: Integer; const ConstName: String; typeID: Integer; const Value: Variant): Integer; overload;

function RegisterConstant(LevelId: Integer; const ConstName: String; const Value: Variant): Integer; overload;

Example

RegisterConstant(H, 'fmOpenRead', fmOpenRead);

RegisterVariable

Registeres a host-defined variable for paxCompiler.
function RegisterVariable(LevelId: Integer; const Name: String; TypeId: Integer; Address: Pointer = nil): Integer;

Arguments

LevelId
Id of namespace
Name
Name of variable.
TypeId
Id of variables's type.
Address
Optional. Address of variable.

Example

H_MyVar := RegisterVariable(0, 'MyVar', _typeSINGLE);

RegisterHeader

Registeres header of host-defined procedure, function, constructor or method for paxCompiler.
function RegisterHeader(LevelId: Integer; const Header: String; Address: Pointer = nil;
MethodIndex: Integer = 0): Integer;

Example 1

RegisterHeader(H, 'function UpperCase(const S: string): string;', @UpperCase);

Example 2

RegisterHeader(H_TList, 'function Add(Item: Pointer): Integer;', @TList.Add);

Example 3

RegisterHeader(H_TList, 'constructor Create;', @TList.Create);

ForbidPublishedProperty

The ForbidPublishedProperty does not allow to use a published property of a host-defined type in scripts.
procedure ForbidPublishedProperty(C: TClass; const PropName: String);

ForbidAllPublishedProperties

The ForbidAllPublishedProperties does not allow to use published properties of a host-defined type in scripts.
procedure ForbidAllPublishedProperties(C: TClass);

LookupTypeId

Returns Id of type.
function LookupTypeId(const TypeName: String): Integer;

Arguments

TypeName
Name of type.

LookupNamespace

Returns Id of namespace.
function LookupNamespace(LevelId: Integer; const NamespaceName: String; CaseSensitive: Boolean): Integer;

RegisterUsingNameSpace

Includes namespace into scope of type lookup.
procedure RegisterUsingNameSpace(const aNameSpaceName: String); overload;

UnregisterUsingNameSpace

Removes namespace from the scope of type lookup.
procedure UnregisterUsingNameSpace(const aNameSpaceName: String); overload;

UnregisterUsingNameSpaces

Removes all namespaces from the scope of type lookup. (These namespaces could be included by RegisterUsingNamespace routine).
procedure UnregisterUsingNameSpaces;

RegisterAlignment

Registeres default alignment.
procedure RegisterAlignment(value: Integer);

Arguments

value
1, 2, 4 or 8.

SetVisibility

Sets up visibility of the host-defined class member.
procedure SetVisibility(C: TClass; const MemberName: String; value: Integer);

Arguments

value
0 - public, 1 - protected, 2 - private.

SaveNamespaceToStream

Saves host-defined namespace (unit) to a stream.
procedure SaveNamespaceToStream(const NamespaceName: String; S: TStream);

Arguments

NamespaceName
Name of namespace.

See ..\Demos\DemoLoadNamespace in a trial package for Delphi.

Example

SaveNamespaceToStream('SysUtils', Stream);

SaveNamespaceToFile

Saves a precompiled host-defined namespace (unit) to file.
procedure SaveNamespaceToFile(const NamespaceName: String; const FileName: String);

See ..\Demos\DemoLoadNamespace in a trial package for Delphi.

Example

SaveNamespaceToFile('SysUtils', 'SysUtils.bin');

LoadNamespaceFromStream

Loads a precompiled host-defined namespace (unit) from stream.
procedure LoadNamespaceFromStream(S: TStream);

See ..\Demos\DemoLoadNamespace in a trial package for Delphi.

Example

LoadNamespaceFromStream('SysUtils', Stream);

LoadNamespaceFromFile

Loads a precompiled host-defined namespace from file.
procedure LoadNamespaceFromFile(const FileName: String);

See ..\Demos\DemoLoadNamespace in a trial package for Delphi.

Example

LoadNamespaceFromFile('SysUtils', 'SysUtils.bin');

EndOfRegistration

Notifies paxCompiler that process of registration host-defined types has been finished.
procedure EndOfRegistration;

The routine forces paxCompiler to perform type checking in all imported members.


Copyright © 2006-2017 Alexander Baranovsky. All rights reserved.