unit IMP_System;
interface
uses
  Variants,
  BASE_SYS,
  BASE_EXTERN,
  PaxScripter;
procedure RegisterIMP_System;
implementation
procedure TObject_Free(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
TObject(Self).Free();
end;
procedure TObject_CleanupInstance(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
TObject(Self).CleanupInstance();
end;
procedure TObject_ClassNameIs(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
   result.AsBoolean := TObject(Self).ClassNameIs(Params[0].AsString);
end;
procedure TObject_ClassInfo(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
   result.AsPointer := TObject(Self).ClassInfo();
end;
procedure TObject_InstanceSize(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
   result.PValue^ := TObject(Self).InstanceSize();
end;
procedure TObject_AfterConstruction(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
TObject(Self).AfterConstruction();
end;
procedure TObject_BeforeDestruction(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
TObject(Self).BeforeDestruction();
end;
procedure TObject_FreeInstance(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
TObject(Self).FreeInstance();
end;
procedure TInterfacedObject_AfterConstruction(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
TInterfacedObject(Self).AfterConstruction();
end;
procedure TInterfacedObject_BeforeDestruction(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
TInterfacedObject(Self).BeforeDestruction();
end;
function TInterfacedObject__GetRefCount(Self:TInterfacedObject):Integer;
begin
  result := Self.RefCount;
end;
function TAggregatedObject__GetController(Self:TAggregatedObject):IInterface;
begin
  result := Self.Controller;
end;
procedure RegisterIMP_System;
var H: Integer;
begin
  H := -1;//RegisterNamespace('System', -1);
  RegisterConstant('varEmpty', $0000, H);
  RegisterConstant('varNull', $0001, H);
  RegisterConstant('varSmallint', $0002, H);
  RegisterConstant('varInteger', $0003, H);
  RegisterConstant('varSingle', $0004, H);
  RegisterConstant('varDouble', $0005, H);
  RegisterConstant('varCurrency', $0006, H);
  RegisterConstant('varDate', $0007, H);
  RegisterConstant('varOleStr', $0008, H);
  RegisterConstant('varDispatch', $0009, H);
  RegisterConstant('varError', $000A, H);
  RegisterConstant('varBoolean', $000B, H);
  RegisterConstant('varVariant', $000C, H);
  RegisterConstant('varUnknown', $000D, H);
  RegisterConstant('varShortInt', $0010, H);
  RegisterConstant('varByte', $0011, H);
  RegisterConstant('varWord', $0012, H);
  RegisterConstant('varLongWord', $0013, H);
  RegisterConstant('varInt64', $0014, H);
  RegisterConstant('varStrArg', $0048, H);
  RegisterConstant('varString', $0100, H);
  RegisterConstant('varAny', $0101, H);
  RegisterConstant('varTypeMask', $0FFF, H);
  RegisterConstant('varArray', $2000, H);
  RegisterConstant('varByRef', $4000, H);
  RegisterConstant('vtInteger', 0, H);
  RegisterConstant('vtBoolean', 1, H);
  RegisterConstant('vtChar', 2, H);
  RegisterConstant('vtExtended', 3, H);
  RegisterConstant('vtString', 4, H);
  RegisterConstant('vtPointer', 5, H);
  RegisterConstant('vtPChar', 6, H);
  RegisterConstant('vtObject', 7, H);
  RegisterConstant('vtClass', 8, H);
  RegisterConstant('vtWideChar', 9, H);
  RegisterConstant('vtPWideChar', 10, H);
  RegisterConstant('vtAnsiString', 11, H);
  RegisterConstant('vtCurrency', 12, H);
  RegisterConstant('vtVariant', 13, H);
  RegisterConstant('vtInterface', 14, H);
  RegisterConstant('vtWideString', 15, H);
  RegisterConstant('vtInt64', 16, H);
  RegisterTypeAlias('HRESULT','Longint');
  // Begin of class TObject
  RegisterClassType(TObject, H);
  RegisterMethod(TObject,
       'constructor Create;',
       @TObject.Create);
  RegisterStdMethodEx(TObject,'Free',TObject_Free,0,[typeVARIANT]);
  RegisterMethod(TObject,
       'function InitInstance(Instance: Pointer): TObject;',
       @TObject.InitInstance);
  RegisterStdMethodEx(TObject,'CleanupInstance',TObject_CleanupInstance,0,[typeVARIANT]);
  RegisterMethod(TObject,
       'function ClassType: TClass;',
       @TObject.ClassType);
  RegisterMethod(TObject,
       'function ClassName: ShortString;',
       @TObject.ClassName);
  RegisterStdMethodEx(TObject,'ClassNameIs',TObject_ClassNameIs,1,[typeSTRING,typeBOOLEAN]);
  RegisterMethod(TObject,
       'function ClassParent: TClass;',
       @TObject.ClassParent);
  RegisterStdMethodEx(TObject,'ClassInfo',TObject_ClassInfo,0,[typePOINTER]);
  RegisterStdMethod(TObject,'InstanceSize',TObject_InstanceSize,0);
  RegisterMethod(TObject,
       'function InheritsFrom(AClass: TClass): Boolean;',
       @TObject.InheritsFrom);
  RegisterMethod(TObject,
       'function MethodAddress(const Name: ShortString): Pointer;',
       @TObject.MethodAddress);
  RegisterMethod(TObject,
       'function MethodName(Address: Pointer): ShortString;',
       @TObject.MethodName);
  RegisterMethod(TObject,
       'function FieldAddress(const Name: ShortString): Pointer;',
       @TObject.FieldAddress);
  RegisterMethod(TObject,
       'function GetInterface(const IID: TGUID; out Obj): Boolean;',
       @TObject.GetInterface);
  RegisterMethod(TObject,
       'function GetInterfaceEntry(const IID: TGUID): PInterfaceEntry;',
       @TObject.GetInterfaceEntry);
  RegisterMethod(TObject,
       'function GetInterfaceTable: PInterfaceTable;',
       @TObject.GetInterfaceTable);
  RegisterMethod(TObject,
       'function SafeCallException(ExceptObject: TObject;      ExceptAddr: Pointer): HResult; virtual;',
       @TObject.SafeCallException);
  RegisterStdMethodEx(TObject,'AfterConstruction',TObject_AfterConstruction,0,[typeVARIANT]);
  RegisterStdMethodEx(TObject,'BeforeDestruction',TObject_BeforeDestruction,0,[typeVARIANT]);
  RegisterMethod(TObject,
       'procedure Dispatch(var Message); virtual;',
       @TObject.Dispatch);
  RegisterMethod(TObject,
       'procedure DefaultHandler(var Message); virtual;',
       @TObject.DefaultHandler);
  RegisterMethod(TObject,
       'function NewInstance: TObject; virtual;',
       @TObject.NewInstance);
  RegisterStdMethodEx(TObject,'FreeInstance',TObject_FreeInstance,0,[typeVARIANT]);
  RegisterMethod(TObject,
       'destructor Destroy; virtual;',
       @TObject.Destroy);
  // End of class TObject
  RegisterConstant('S_OK', 0, H);
  RegisterConstant('S_FALSE', $00000001, H);
  // Begin of interface IInterface
  RegisterInterfaceType('IInterface',IInterface,'IUnknown',IUnknown,H);
  RegisterInterfaceMethod(IInterface,
       'function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;');
  // End of interface IInterface
  RegisterTypeAlias('IUnknown','IInterface');
  // Begin of interface IDispatch
  RegisterInterfaceType('IDispatch',IDispatch,'IUnknown',IUnknown,H);
  RegisterInterfaceMethod(IDispatch,
       'function GetTypeInfoCount(out Count: Integer): HResult; stdcall;');
  RegisterInterfaceMethod(IDispatch,
       'function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;');
  RegisterInterfaceMethod(IDispatch,
       'function GetIDsOfNames(const IID: TGUID; Names: Pointer;      NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;');
  RegisterInterfaceMethod(IDispatch,
       'function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;      Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;');
  // End of interface IDispatch
  // Begin of class TInterfacedObject
  RegisterClassType(TInterfacedObject, H);
  RegisterStdMethodEx(TInterfacedObject,'AfterConstruction',TInterfacedObject_AfterConstruction,0,[typeVARIANT]);
  RegisterStdMethodEx(TInterfacedObject,'BeforeDestruction',TInterfacedObject_BeforeDestruction,0,[typeVARIANT]);
  RegisterMethod(TInterfacedObject,
       'function NewInstance: TObject; override;',
       @TInterfacedObject.NewInstance);
  RegisterMethod(TInterfacedObject,
       'function TInterfacedObject__GetRefCount(Self:TInterfacedObject):Integer;',
       @TInterfacedObject__GetRefCount, true);
  RegisterProperty(TInterfacedObject,
       'property RefCount:Integer read TInterfacedObject__GetRefCount;');
  // CONSTRUCTOR IS NOT FOUND!!!
  // End of class TInterfacedObject
  // Begin of class TAggregatedObject
  RegisterClassType(TAggregatedObject, H);
  RegisterMethod(TAggregatedObject,
       'constructor Create(const Controller: IInterface);',
       @TAggregatedObject.Create);
  RegisterMethod(TAggregatedObject,
       'function TAggregatedObject__GetController(Self:TAggregatedObject):IInterface;',
       @TAggregatedObject__GetController, true);
  RegisterProperty(TAggregatedObject,
       'property Controller:IInterface read TAggregatedObject__GetController;');
  // End of class TAggregatedObject
  // Begin of class TContainedObject
  RegisterClassType(TContainedObject, H);
  // CONSTRUCTOR IS NOT FOUND!!!
  // End of class TContainedObject
  // Begin of class TClassHelperBase
  RegisterClassType(TClassHelperBase, H);
  // CONSTRUCTOR IS NOT FOUND!!!
  // End of class TClassHelperBase
  RegisterTypeAlias('PString','PAnsiString');
  RegisterTypeAlias('UCS2Char','WideChar');
  RegisterTypeAlias('PUCS2Char','PWideChar');
  RegisterTypeAlias('UCS4Char','LongWord');
  RegisterTypeAlias('UTF8String','string');
  RegisterTypeAlias('PPAnsiChar','PPChar');
  RegisterTypeAlias('TDateTime','Double');
  RegisterTypeAlias('THandle','LongWord');
  RegisterTypeAlias('TVarType','Word');
  RegisterTypeAlias('TVarOp','Integer');
  RegisterConstant('opAdd', 0, H);
  RegisterConstant('opSubtract', 1, H);
  RegisterConstant('opMultiply', 2, H);
  RegisterConstant('opDivide', 3, H);
  RegisterConstant('opIntDivide', 4, H);
  RegisterConstant('opModulus', 5, H);
  RegisterConstant('opShiftLeft', 6, H);
  RegisterConstant('opShiftRight', 7, H);
  RegisterConstant('opAnd', 8, H);
  RegisterConstant('opOr', 9, H);
  RegisterConstant('opXor', 10, H);
  RegisterConstant('opCompare', 11, H);
  RegisterConstant('opNegate', 12, H);
  RegisterConstant('opNot', 13, H);
  RegisterConstant('opCmpEQ', 14, H);
  RegisterConstant('opCmpNE', 15, H);
  RegisterConstant('opCmpLT', 16, H);
  RegisterConstant('opCmpLE', 17, H);
  RegisterConstant('opCmpGT', 18, H);
  RegisterConstant('opCmpGE', 19, H);
  RegisterConstant('NumSmallBlockTypes', 55, H);
end;
initialization
  RegisterIMP_System;
end.
