Signed-off-by: Dalibor Marković <dalibor31@gmail.com>
This commit is contained in:
Dalibor Marković 2024-03-31 20:49:04 +02:00
commit 9d0de424e8
Signed by: Dasko
GPG Key ID: B130BB104C2CA3A9
1109 changed files with 289361 additions and 0 deletions

69
.gitignore vendored Normal file
View File

@ -0,0 +1,69 @@
# Uncomment these types if you want even more clean repository. But be careful.
# It can make harm to an existing project source. Read explanations below.
#
# Resource files are binaries containing manifest, project icon and version info.
# They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files.
#*.res
#
# Type library file (binary). In old Delphi versions it should be stored.
# Since Delphi 2009 it is produced from .ridl file and can safely be ignored.
#*.tlb
#
# Diagram Portfolio file. Used by the diagram editor up to Delphi 7.
# Uncomment this if you are not using diagrams or use newer Delphi version.
#*.ddp
#
# Visual LiveBindings file. Added in Delphi XE2.
# Uncomment this if you are not using LiveBindings Designer.
#*.vlb
#
# Deployment Manager configuration file for your project. Added in Delphi XE2.
# Uncomment this if it is not mobile development and you do not use remote debug feature.
#*.deployproj
#
# C++ object files produced when C/C++ Output file generation is configured.
# Uncomment this if you are not using external objects (zlib library for example).
#*.obj
#
# Delphi compiler-generated binaries (safe to delete)
*.exe
*.dll
*.bpl
*.bpi
*.dcp
*.so
*.apk
*.drc
*.map
*.dres
*.rsm
*.tds
*.dcu
*.lib
*.a
*.o
*.ocx
# Delphi autogenerated files (duplicated info)
*.cfg
*.hpp
*Resource.rc
# Delphi local files (user-specific info)
*.local
*.identcache
*.projdata
*.tvsconfig
*.dsk
# Delphi history and backups
__history/
__recovery/
*.~*
# Castalia statistics file (since XE7 Castalia is distributed with Delphi)
*.stat
# Boss dependency manager vendor folder https://github.com/HashLoad/boss
modules/

View File

@ -0,0 +1,50 @@
{$I PaxCompiler.def}
unit IMPORT_ActiveX;
interface
{$IFDEF MACOS}
procedure Register_ActiveX;
implementation
procedure Register_ActiveX;
begin
end;
end.
{$ENDIF}
uses
{$IFDEF DPULSAR}
Winapi.ActiveX,
System.Win.ComObj,
{$ELSE}
ActiveX,
ComObj,
{$ENDIF}
PAXCOMP_OLE,
PAXCOMP_CONSTANTS,
PAXCOMP_BASESYMBOL_TABLE,
PaxRegister,
PaxCompiler;
procedure Register_ActiveX;
implementation
procedure Register_ActiveX;
begin
CoInitialize(nil);
RegisterHeader(0, 'function CreateOleObject(const ClassName: string): IDispatch;',
@CreateOleObject);
RegisterHeader(0, 'function GetActiveOleObject(const ClassName: string): IDispatch;',
@GetActiveOleObject);
RegisterRoutine(0, _strGetOLEProperty, _typeVOID, @ _GetOLEProperty, _ccSTDCALL);
RegisterRoutine(0, _strSetOLEProperty, _typeVOID, @ _SetOLEProperty, _ccSTDCALL);
GetOlePropProc := _GetOLEProperty;
PutOlePropProc := _SetOLEProperty;
end;
end.

View File

@ -0,0 +1,26 @@
unit IMPORT_COMMON;
interface
uses
IMPORT_ActiveX,
IMPORT_Variants,
IMPORT_SysUtils,
IMPORT_Classes,
IMPORT_Controls,
IMPORT_StdCtrls,
IMPORT_Forms,
IMPORT_Menus,
IMPORT_Dialogs;
implementation
begin
Register_ActiveX;
Register_Variants;
Register_SysUtils;
Register_Classes;
Register_Controls;
Register_StdCtrls;
Register_Forms;
Register_Menus;
Register_Dialogs;
end.

View File

@ -0,0 +1,774 @@
unit IMPORT_Classes;
interface
uses
Classes,
SysUtils,
PaxRegister,
PaxCompiler;
procedure Register_Classes;
implementation
// TList -----------------------------------------------------------------------
function TList_GetCapacity(Self: TList): Integer;
begin
result := Self.Capacity;
end;
procedure TList_SetCapacity(Self: TList; Value: Integer);
begin
Self.Capacity := Value;
end;
function TList_GetCount(Self: TList): Integer;
begin
result := Self.Count;
end;
function TList_GetItem(Self: TList; I: Integer): Pointer;
begin
result := Self.Items[I];
end;
procedure TList_SetItem(Self: TList; I: Integer; Value: Pointer);
begin
Self.Items[I] := Value;
end;
{
function TList_GetList(Self: TList): PPointerList;
begin
result := Self.List;
end;
}
// TBits -----------------------------------------------------------------------
function TBits_GetBit(Self: TBits; I: Integer): Boolean;
begin
result := Self.Bits[I];
end;
procedure TBits_SetBit(Self: TBits; I: Integer; Value: Boolean);
begin
Self.Bits[I] := Value;
end;
function TBits_GetSize(Self: TBits): Integer;
begin
result := Self.Size;
end;
// TCollectionItem -------------------------------------------------------------
function TCollectionItem_GetCollection(Self: TCollectionItem): TCollection;
begin
result := Self.Collection;
end;
procedure TCollectionItem_SetCollection(Self: TCollectionItem; Value: TCollection);
begin
Self.Collection := Value;
end;
function TCollectionItem_GetID(Self: TCollectionItem): Integer;
begin
result := Self.ID;
end;
function TCollectionItem_GetIndex(Self: TCollectionItem): Integer;
begin
result := Self.Index;
end;
procedure TCollectionItem_SetIndex(Self: TCollectionItem; Value: Integer);
begin
Self.Index := Value;
end;
function TCollectionItem_GetDisplayName(Self: TCollectionItem): String;
begin
result := Self.DisplayName;
end;
procedure TCollectionItem_SetDisplayName(Self: TCollectionItem; const Value: String);
begin
Self.DisplayName := Value;
end;
// TCollection -----------------------------------------------------------------
function TCollection_GetCount(Self: TCollection): Integer;
begin
result := Self.Count;
end;
function TCollection_GetItemClass(Self: TCollection): TCollectionItemClass;
begin
result := Self.ItemClass;
end;
function TCollection_GetItem(Self: TCollection; I: Integer): TCollectionItem;
begin
result := Self.Items[I];
end;
procedure TCollection_SetItem(Self: TCollection; I: Integer; Value: TCollectionItem);
begin
Self.Items[I] := Value;
end;
// TStrings --------------------------------------------------------------------
function TStrings_GetCapacity(Self: TStrings): Integer;
begin
result := Self.Capacity;
end;
procedure TStrings_SetCapacity(Self: TStrings; Value: Integer);
begin
Self.Capacity := Value;
end;
function TStrings_GetCommaText(Self: TStrings): String;
begin
result := Self.CommaText;
end;
procedure TStrings_SetCommaText(Self: TStrings; const Value: String);
begin
Self.CommaText := Value;
end;
function TStrings_GetCount(Self: TStrings): Integer;
begin
result := Self.Count;
end;
function TStrings_GetName(Self: TStrings; I: Integer): String;
begin
result := Self.Names[I];
end;
function TStrings_GetObject(Self: TStrings; I: Integer): TObject;
begin
result := Self.Objects[I];
end;
procedure TStrings_SetObject(Self: TStrings; I: Integer; Value: TObject);
begin
Self.Objects[I] := Value;
end;
function TStrings_GetValue(Self: TStrings; const I: String): String;
begin
result := Self.Values[I];
end;
procedure TStrings_SetValue(Self: TStrings; const I: String; const Value: String);
begin
Self.Values[I] := Value;
end;
function TStrings_GetString(Self: TStrings; I: Integer): String;
begin
result := Self.Strings[I];
end;
procedure TStrings_SetString(Self: TStrings; I: Integer; const Value: String);
begin
Self.Strings[I] := Value;
end;
function TStrings_GetText(Self: TStrings): String;
begin
result := Self.Text;
end;
procedure TStrings_SetText(Self: TStrings; const Value: String);
begin
Self.Text := Value;
end;
{
procedure TStrings_Clear(Self: TStrings);
begin
self.Clear;
end;
}
// TStringList -----------------------------------------------------------------
function TStringList_GetDuplicates(Self: TStringList): TDuplicates;
begin
result := Self.Duplicates;
end;
procedure TStringList_SetDuplicates(Self: TStringList; Value: TDuplicates);
begin
Self.Duplicates := Value;
end;
function TStringList_GetSorted(Self: TStringList): Boolean;
begin
result := Self.Sorted;
end;
procedure TStringList_SetSorted(Self: TStringList; Value: Boolean);
begin
Self.Sorted := Value;
end;
// TStream ---------------------------------------------------------------------
function TStream_GetPosition(Self: TStream): Integer;
begin
result := Self.Position;
end;
procedure TStream_SetPosition(Self: TStream; Value: Integer);
begin
Self.Position := Value;
end;
function TStream_GetSize(Self: TStream): Longint;
begin
result := Self.Size;
end;
procedure TStream_SetSize(Self: TStream; Value: Longint);
begin
Self.Size := Value;
end;
// TStream ---------------------------------------------------------------------
function THandleStream_GetHandle(Self: THandleStream): Integer;
begin
result := Self.Handle;
end;
// TCustomMemoryStream ---------------------------------------------------------
function TCustomMemoryStream_GetMemory(Self: TCustomMemoryStream): Pointer;
begin
result := Self.Memory;
end;
// TParser ---------------------------------------------------------------------
function TParser_GetFloatType(Self: TParser): Char;
begin
result := Self.FloatType;
end;
function TParser_GetSourceLine(Self: TParser): Integer;
begin
result := Self.SourceLine;
end;
function TParser_GetToken(Self: TParser): Char;
begin
result := Self.Token;
end;
// TComponent ------------------------------------------------------------------
function TComponent_GetComponent(Self: TComponent; I: Integer): TComponent;
begin
result := Self.Components[I];
end;
function TComponent_GetComponentCount(Self: TComponent): Integer;
begin
result := Self.ComponentCount;
end;
function TComponent_GetComponentIndex(Self: TComponent): Integer;
begin
result := Self.ComponentIndex;
end;
procedure TComponent_SetComponentIndex(Self: TComponent; Value: Integer);
begin
Self.ComponentIndex := Value;
end;
function TComponent_GetComponentState(Self: TComponent): TComponentState;
begin
result := Self.ComponentState;
end;
function TComponent_GetComponentStyle(Self: TComponent): TComponentStyle;
begin
result := Self.ComponentStyle;
end;
function TComponent_GetDesignInfo(Self: TComponent): Integer;
begin
result := Self.DesignInfo;
end;
procedure TComponent_SetDesignInfo(Self: TComponent; Value: Integer);
begin
Self.DesignInfo := Value;
end;
function TComponent_GetOwner(Self: TComponent): TComponent;
begin
result := Self.Owner;
end;
//------------------------------------------------------------------------------
function TStringStream_GetDataString(Self: TStringStream): String;
begin
result := Self.DataString;
end;
procedure Register_Classes;
var
H, G, J: Integer;
begin
H := RegisterNamespace(0, 'Classes');
{ Maximum TList size }
RegisterConstant(H, 'MaxListSize', MaxListSize);
{ TStream seek origins }
RegisterConstant(H, 'soFromBeginning', soFromBeginning);
RegisterConstant(H, 'soFromCurrent', soFromCurrent);
RegisterConstant(H, 'soFromEnd', soFromEnd);
{ TFileStream create mode }
RegisterConstant(H, 'fmCreate', fmCreate);
{ TParser special tokens }
RegisterConstant(H, 'toEOF', toEOF);
RegisterConstant(H, 'toSymbol', toSymbol);
RegisterConstant(H, 'toString', toString);
RegisterConstant(H, 'toInteger', toInteger);
RegisterConstant(H, 'toFloat', toFloat);
RegisterConstant(H, 'toWString', toWString);
{ Text alignment types }
J := RegisterRTTIType(H, TypeInfo(TAlignment));
// RegisterRTTIType(H, TypeInfo(TLeftRight));
RegisterSubrangeType(H, 'TLeftRight', J,
Ord(taLeftJustify), Ord(taRightJustify));
RegisterRTTIType(H, TypeInfo(TBiDiMode));
{ Types used by standard events }
RegisterRTTIType(H, TypeInfo(TShiftState));
RegisterRTTIType(H, TypeInfo(THelpContext));
{ Duplicate management }
RegisterRTTIType(H, TypeInfo(TDuplicates));
RegisterClassType(H, TComponent);
RegisterClassType(H, TStream);
RegisterClassType(H, TFiler);
RegisterClassType(H, TReader);
RegisterClassType(H, TWriter);
// TList -----------------------------------------------------------------------
G := RegisterArrayType(H, 'TPointerList',
RegisterSubrangeType(H, '', _typeINTEGER, 0, MaxListSize - 1),
_typePOINTER);
RegisterPointerType(H, 'PPointerList', G);
G := RegisterHeader(H, 'function __TListSortCompare(Item1, Item2: Pointer): Integer;', nil);
RegisterProceduralType(H, 'TListSortCompare', G);
RegisterRTTIType(H, TypeInfo(TListNotification));
G := RegisterClassType(H, TList);
RegisterHeader(G, 'constructor Create;', @TList.Create);
RegisterHeader(G, 'function Add(Item: Pointer): Integer;', @TList.Add);
RegisterHeader(G, 'procedure Clear; virtual;', @TList.Clear);
RegisterHeader(G, 'procedure Delete(Index: Integer);', @TList.Delete);
RegisterHeader(G, 'procedure Exchange(Index1, Index2: Integer);', @TList.Exchange);
RegisterHeader(G, 'function Expand: TList;', @TList.Expand);
RegisterHeader(G, 'function Extract(Item: Pointer): Pointer;', @TList.Extract);
RegisterHeader(G, 'function First: Pointer;', @TList.First);
RegisterHeader(G, 'function IndexOf(Item: Pointer): Integer;', @TList.IndexOf);
RegisterHeader(G, 'procedure Insert(Index: Integer; Item: Pointer);', @TList.Insert);
RegisterHeader(G, 'function Last: Pointer;', @TList.Last);
RegisterHeader(G, 'procedure Move(CurIndex, NewIndex: Integer);', @TList.Move);
RegisterHeader(G, 'function Remove(Item: Pointer): Integer;', @TList.Remove);
RegisterHeader(G, 'procedure Pack;', @TList.Pack);
RegisterHeader(G, 'procedure Sort(Compare: TListSortCompare);', @TList.Sort);
RegisterFakeHeader(G, 'function _GetCapacity: Integer;', @TList_GetCapacity);
RegisterFakeHeader(G, 'procedure _SetCapacity(Value: Integer);', @TList_SetCapacity);
RegisterProperty(G, 'property Capacity: Integer read _GetCapacity write _SetCapacity;');
RegisterFakeHeader(G, 'function _GetCount: Integer;', @TList_GetCount);
RegisterProperty(G, 'property Count: Integer read _GetCount;');
RegisterFakeHeader(G, 'function _GetItem(I: Integer): Pointer;', @TList_GetItem);
RegisterFakeHeader(G, 'procedure _SetItem(I: Integer; Value: Pointer);', @TList_SetItem);
RegisterProperty(G, 'property Items[Index: Integer]: Pointer read _GetItem write _SetItem; default;');
// RegisterHeader(G, 'function _GetList: PPointerList;', @TList_GetList);
// RegisterProperty(G, 'property List: PPointerList read _GetList;');
// TBits -----------------------------------------------------------------------
G := RegisterClassType(H, TBits);
RegisterHeader(G, 'constructor Create;', @TBits.Create);
RegisterHeader(G, 'function OpenBit: Integer;', @TBits.OpenBit);
RegisterFakeHeader(G, 'function _GetBit(I: Integer): Boolean;', @TBits_GetBit);
RegisterFakeHeader(G, 'procedure _SetBit(I: Integer; Value: Boolean);', @TBits_SetBit);
RegisterProperty(G, 'property Bits[Index: Integer]: Boolean read _GetBit write _SetBit; default;');
RegisterFakeHeader(G, 'function _GetSize: Integer;', @TBits_GetSize);
RegisterProperty(G, 'property Size: Integer read _GetSize;');
// TPersistent -----------------------------------------------------------------
G := RegisterClassType(H, TPersistent);
RegisterClassReferenceType(H, 'TPersistentClass', G);
RegisterHeader(G, 'constructor Create;', @TPersistent.Create);
RegisterHeader(G, 'procedure Assign(Source: TPersistent); virtual;', @TPersistent.Assign);
RegisterHeader(G, 'function GetNamePath: string; dynamic;', @TPersistent.GetNamePath);
// TCollectionItem -------------------------------------------------------------
RegisterClassType(H, TCollection);
G := RegisterClassType(H, TCollectionItem);
RegisterClassReferenceType(H, 'TCollectionItemClass', G);
RegisterHeader(G, 'constructor Create(Collection: TCollection); virtual;', @TCollectionItem.Create);
RegisterHeader(G, 'function GetNamePath: string; override;', @TCollectionItem.GetNamePath);
RegisterFakeHeader(G, 'function _GetCollection: TCollection;', @TCollectionItem_GetCollection);
RegisterFakeHeader(G, 'procedure _SetCollection(Value: TCollection);', @TCollectionItem_SetCollection);
RegisterProperty(G, 'property Collection: TCollection read _GetCollection write _SetCollection;');
RegisterFakeHeader(G, 'function _GetID: Integer;', @TCollectionItem_GetID);
RegisterProperty(G, 'property ID: Integer read _GetID;');
RegisterFakeHeader(G, 'function _GetIndex: Integer;', @TCollectionItem_GetIndex);
RegisterFakeHeader(G, 'procedure _SetIndex(Value: Integer);', @TCollectionItem_SetIndex);
RegisterProperty(G, 'property Index: Integer read _GetIndex write _SetIndex;');
RegisterFakeHeader(G, 'function _GetDisplayName: String;', @TCollectionItem_GetDisplayName);
RegisterFakeHeader(G, 'procedure _SetDisplayName(const Value: String);', @TCollectionItem_SetDisplayName);
RegisterProperty(G, 'property DisplayName: string read _GetDisplayName write _SetDisplayName;');
// TCollection -----------------------------------------------------------------
G := RegisterClassType(H, TCollection);
RegisterHeader(G, 'constructor Create(ItemClass: TCollectionItemClass);', @TCollection.Create);
RegisterHeader(G, 'function Add: TCollectionItem;', @TCollection.Add);
RegisterHeader(G, 'procedure Assign(Source: TPersistent); override;', @TCollection.Assign);
RegisterHeader(G, 'procedure BeginUpdate; virtual;', @TCollection.BeginUpdate);
RegisterHeader(G, 'procedure Clear;', @TCollection.Clear);
RegisterHeader(G, 'procedure Delete(Index: Integer);', @TCollection.Delete);
RegisterHeader(G, 'procedure EndUpdate; virtual;', @TCollection.EndUpdate);
RegisterHeader(G, 'function FindItemID(ID: Integer): TCollectionItem;', @TCollection.FindItemId);
RegisterHeader(G, 'function GetNamePath: string; override;', @TCollection.GetNamePath);
RegisterHeader(G, 'function Insert(Index: Integer): TCollectionItem;', @TCollection.Insert);
RegisterFakeHeader(G, 'function _GetCount: Integer;', @TCollection_GetCount);
RegisterProperty(G, 'property Count: Integer read _GetCount;');
RegisterFakeHeader(G, 'function _GetItemClass: TCollectionItemClass;',
@TCollection_GetItemClass);
RegisterProperty(G, 'property ItemClass: TCollectionItemClass read _GetItemClass;');
RegisterFakeHeader(G, 'function _GetItem(I: Integer): TCollectionItem;', @TCollection_GetItem);
RegisterFakeHeader(G, 'procedure _SetItem(I: Integer; Value: TCollectionItem);', @TCollection_SetItem);
RegisterProperty(G, 'property Items[Index: Integer]: TCollectionItem read _GetItem write _SetItem;');
// TStrings --------------------------------------------------------------------
G := RegisterClassType(H, TStrings);
RegisterHeader(G, 'constructor Create;', @TStrings.Create);
RegisterHeader(G, 'function Get(Index: Integer): string; virtual; abstract;', nil);
RegisterHeader(G, 'function GetCount: Integer; virtual; abstract;', nil);
RegisterHeader(G, 'function Add(const S: string): Integer; virtual;', @TStrings.Add);
RegisterHeader(G, 'function AddObject(const S: string; AObject: TObject): Integer; virtual;', @TStrings.AddObject);
RegisterHeader(G, 'procedure Append(const S: string);', @TStrings.Append);
RegisterHeader(G, 'procedure AddStrings(Strings: TStrings); virtual;', @TStrings.AddStrings);
RegisterHeader(G, 'procedure Assign(Source: TPersistent); override;', @TStrings.Assign);
RegisterHeader(G, 'procedure BeginUpdate;', @TStrings.BeginUpdate);
RegisterHeader(G, 'procedure Clear; virtual; abstract;', nil);
RegisterHeader(G, 'procedure Delete(Index: Integer); virtual; abstract;', nil);
RegisterHeader(G, 'procedure EndUpdate;', @TStrings.EndUpdate);
RegisterHeader(G, 'function Equals(Strings: TStrings): Boolean;', @TStrings.Equals);
RegisterHeader(G, 'procedure Exchange(Index1, Index2: Integer); virtual;', @TStrings.Exchange);
RegisterHeader(G, 'function GetText: PChar; virtual;', @TStrings.GetText);
RegisterHeader(G, 'function IndexOf(const S: string): Integer; virtual;', @TStrings.IndexOf);
RegisterHeader(G, 'function IndexOfName(const Name: string): Integer;', @TStrings.IndexOfName);
RegisterHeader(G, 'function IndexOfObject(AObject: TObject): Integer;', @TStrings.IndexOfObject);
RegisterHeader(G, 'procedure Insert(Index: Integer; const S: string); virtual; abstract;', nil);
RegisterHeader(G, 'procedure InsertObject(Index: Integer; const S: string; AObject: TObject);', @TStrings.InsertObject);
RegisterHeader(G, 'procedure LoadFromFile(const FileName: string); virtual;', @TStrings.LoadFromFile);
RegisterHeader(G, 'procedure LoadFromStream(Stream: TStream); virtual;', @TStrings.LoadFromStream);
RegisterHeader(G, 'procedure Move(CurIndex, NewIndex: Integer); virtual;', @TStrings.Move);
RegisterHeader(G, 'procedure SaveToFile(const FileName: string); virtual;', @TStrings.SaveToFile);
RegisterHeader(G, 'procedure SaveToStream(Stream: TStream); virtual;', @TStrings.SaveToStream);
RegisterHeader(G, 'procedure SetText(Text: PChar); virtual;', @TStrings.SetText);
RegisterFakeHeader(G, 'function _GetCapacity: Integer;', @TStrings_GetCapacity);
RegisterFakeHeader(G, 'procedure _SetCapacity(Value: Integer);', @TStrings_SetCapacity);
RegisterProperty(G, 'property Capacity: Integer read _GetCapacity write _SetCapacity;');
RegisterFakeHeader(G, 'function _GetCommaText: String;', @TStrings_GetCommaText);
RegisterFakeHeader(G, 'procedure _SetCommaText(const Value: String);', @TStrings_SetCommaText);
RegisterProperty(G, 'property CommaText: string read _GetCommaText write _SetCommaText;');
RegisterFakeHeader(G, 'function _GetCount: Integer;', @TStrings_GetCount);
RegisterProperty(G, 'property Count: Integer read _GetCount;');
RegisterFakeHeader(G, 'function _GetName(I: Integer): String;', @TStrings_GetName);
RegisterProperty(G, 'property Names[Index: Integer]: string read _GetName;');
RegisterFakeHeader(G, 'function GetObjects(I: Integer): TObject;', @TStrings_GetObject);
RegisterFakeHeader(G, 'procedure SetObjects(I: Integer; Value: TObject);', @TStrings_SetObject);
RegisterProperty(G, 'property Objects[Index: Integer]: TObject read GetObjects write SetObjects;');
RegisterFakeHeader(G, 'function _GetValue(const I: String): String;', @TStrings_GetValue);
RegisterFakeHeader(G, 'procedure _SetValue(const I: String; const Value: String);', @TStrings_GetValue);
RegisterProperty(G, 'property Values[const Name: string]: string read _GetValue write _SetValue;');
RegisterFakeHeader(G, 'function _GetString(I: Integer): String;', @TStrings_GetString);
RegisterFakeHeader(G, 'procedure _SetString(I: Integer; const Value: String);', @TStrings_SetString);
RegisterProperty(G, 'property Strings[Index: Integer]: string read _GetString write _SetString; default;');
RegisterFakeHeader(G, 'function _GetText: String;', @TStrings_GetText);
RegisterFakeHeader(G, 'procedure _SetText(const Value: String);', @TStrings_SetText);
RegisterProperty(G, 'property Text: string read _GetText write _SetText;');
// TStringList -----------------------------------------------------------------
G := RegisterClassType(H, TStringList);
RegisterProceduralType(H, 'TStringListSortCompare', RegisterHeader(H, 'function __TStringListSortCompare(List: TStringList; Index1, Index2: Integer): Integer;', nil));
RegisterHeader(G, 'constructor Create;', @TStringList.Create);
RegisterHeader(G, 'function Add(const S: string): Integer; override;', @TStringList.Add);
RegisterHeader(G, 'procedure Clear; override;', @TStringList.Clear);
RegisterHeader(G, 'procedure Delete(Index: Integer); override;', @TStringList.Delete);
RegisterHeader(G, 'procedure Exchange(Index1, Index2: Integer); override;', @TStringList.Exchange);
RegisterHeader(G, 'function Find(const S: string; var Index: Integer): Boolean; virtual;', @TStringList.Find);
RegisterHeader(G, 'function IndexOf(const S: string): Integer; override;', @TStringList.IndexOf);
RegisterHeader(G, 'procedure Insert(Index: Integer; const S: string); override;', @TStringList.Insert);
RegisterHeader(G, 'procedure Sort; virtual;', @TStringList.Sort);
RegisterHeader(G, 'procedure CustomSort(Compare: TStringListSortCompare); virtual;', @TStringList.CustomSort);
RegisterFakeHeader(G, 'function _GetDuplicates: TDuplicates;', @TStringList_GetDuplicates);
RegisterFakeHeader(G, 'procedure _SetDuplicates(Value: TDuplicates);', @TStringList_SetDuplicates);
RegisterProperty(G, 'property Duplicates: TDuplicates read _GetDuplicates write _SetDuplicates;');
RegisterFakeHeader(G, 'function _GetSorted: Boolean;', @TStringList_GetSorted);
RegisterFakeHeader(G, 'procedure _SetSorted(Value: Boolean);', @TStringList_SetSorted);
RegisterProperty(G, 'property Sorted: Boolean read _GetSorted write _SetSorted;');
// TStream ---------------------------------------------------------------------
G := RegisterClassType(H, TStream);
RegisterHeader(G, 'constructor Create;', @TStream.Create);
RegisterHeader(G, 'function Read(var Buffer; Count: Longint): Longint; virtual; abstract;', nil);
RegisterHeader(G, 'function Write(const Buffer; Count: Longint): Longint; virtual; abstract;', nil);
RegisterHeader(G, 'function Seek(Offset: Longint; Origin: Word): Longint; virtual; abstract;', nil);
RegisterHeader(G, 'procedure ReadBuffer(var Buffer; Count: Longint);', @TStream.ReadBuffer);
RegisterHeader(G, 'procedure WriteBuffer(const Buffer; Count: Longint);', @TStream.WriteBuffer);
RegisterHeader(G, 'function CopyFrom(Source: TStream; Count: Longint): Longint;', @TStream.CopyFrom);
RegisterHeader(G, 'function ReadComponent(Instance: TComponent): TComponent;', @TStream.ReadComponent);
RegisterHeader(G, 'function ReadComponentRes(Instance: TComponent): TComponent;', @TStream.ReadComponentRes);
RegisterHeader(G, 'procedure WriteComponent(Instance: TComponent);', @TStream.WriteComponent);
RegisterHeader(G, 'procedure WriteResourceHeader(const ResName: string; out FixupInfo: Integer);', @TStream.WriteResourceHeader);
RegisterHeader(G, 'procedure FixupResourceHeader(FixupInfo: Integer);', @TStream.FixupResourceHeader);
RegisterHeader(G, 'procedure ReadResHeader;', @TStream.ReadResHeader);
RegisterFakeHeader(G, 'function _GetPosition: Integer;', @TStream_GetPosition);
RegisterFakeHeader(G, 'procedure _SetPosition(Value: Integer);', @TStream_SetPosition);
RegisterProperty(G, 'property Position: Longint read _GetPosition write _SetPosition;');
RegisterFakeHeader(G, 'function _GetSize: Longint;', @TStream_GetSize);
RegisterFakeHeader(G, 'procedure _SetSize(Value: Longint);', @TStream_SetSize);
RegisterProperty(G, 'property Size: Longint read _GetSize write _SetSize;');
// THandleStream ---------------------------------------------------------------
G := RegisterClassType(H, THandleStream);
RegisterHeader(G, 'constructor Create(AHandle: Integer);', @THandleStream.Create);
RegisterHeader(G, 'function Read(var Buffer; Count: Longint): Longint; override;', @THandleStream.Read);
RegisterHeader(G, 'function Write(const Buffer; Count: Longint): Longint; override;', @THandleStream.Write);
RegisterHeader(G, 'function Seek(Offset: Longint; Origin: Word): Longint; override;', @THandleStream.Seek);
RegisterFakeHeader(G, 'function _GetHandle: Integer;', @THandleStream_GetHandle);
RegisterProperty(G, 'property Handle: Integer read _GetHandle;');
// TFileStream -----------------------------------------------------------------
G := RegisterClassType(H, TFileStream);
RegisterHeader(G, 'constructor Create(const FileName: string; Mode: Word);', @TFileStream.Create);
// TCustomMemoryStream ---------------------------------------------------------
G := RegisterClassType(H, TCustomMemoryStream);
RegisterHeader(G, 'constructor Create;', @TCustomMemoryStream.Create);
RegisterHeader(G, 'function Read(var Buffer; Count: Longint): Longint; override;', @TCustomMemoryStream.Read);
RegisterHeader(G, 'function Seek(Offset: Longint; Origin: Word): Longint; override;', @TCustomMemoryStream.Seek);
RegisterHeader(G, 'procedure SaveToStream(Stream: TStream);', @TCustomMemoryStream.SaveToStream);
RegisterHeader(G, 'procedure SaveToFile(const FileName: string);', @TCustomMemoryStream.SaveToFile);
RegisterFakeHeader(G, 'function _GetMemory: Pointer;', @TCustomMemoryStream_GetMemory);
RegisterProperty(G, 'property Memory: Pointer read _GetMemory;');
// TMemoryStream ---------------------------------------------------------------
G := RegisterClassType(H, TMemoryStream);
RegisterHeader(G, 'constructor Create;', @TMemoryStream.Create);
RegisterHeader(G, 'procedure Clear;', @TMemoryStream.Clear);
RegisterHeader(G, 'procedure LoadFromStream(Stream: TStream);', @TMemoryStream.LoadFromStream);
RegisterHeader(G, 'procedure LoadFromFile(const FileName: string);', @TMemoryStream.LoadFromFile);
RegisterHeader(G, 'procedure SetSize(NewSize: Longint); override;', @TMemoryStream.SetSize);
RegisterHeader(G, 'function Write(const Buffer; Count: Longint): Longint; override;', @TMemoryStream.Write);
// TStringStream ---------------------------------------------------------------
G := RegisterClassType(H, TStringStream);
RegisterHeader(G, 'constructor Create(const AString: string); overload;', @TStringStream.Create);
RegisterHeader(G, 'function Read(var Buffer; Count: Longint): Longint; override;', @TStringStream.Read);
RegisterHeader(G, 'function ReadString(Count: Longint): string;', @TStringStream.ReadString);
RegisterHeader(G, 'function Seek(Offset: Longint; Origin: Word): Longint; override;', @TStringStream.Seek);
RegisterHeader(G, 'function Write(const Buffer; Count: Longint): Longint; override;', @TStringStream.Write);
RegisterHeader(G, 'procedure WriteString(const AString: string);', @TStringStream.WriteString);
RegisterFakeHeader(G, 'function _GetDataString: String;', @TStringStream_GetDataString);
RegisterProperty(G, 'property DataString: string read _GetDataString;');
// TResourceStream -------------------------------------------------------------
G := RegisterClassType(H, TResourceStream);
RegisterHeader(G, 'constructor Create(Instance: THandle; const ResName: string; ResType: PChar);', @TResourceStream.Create);
RegisterHeader(G, 'constructor CreateFromID(Instance: THandle; ResID: Integer; ResType: PChar);', @TResourceStream.CreateFromID);
RegisterHeader(G, 'function Write(const Buffer; Count: Longint): Longint; override;', @TResourceStream.Write);
// TParser ---------------------------------------------------------------------
G := RegisterClassType(H, TParser);
RegisterHeader(G, 'constructor Create(Stream: TStream);', @TParser.Create);
RegisterHeader(G, 'procedure CheckToken(T: Char);', @TParser.CheckToken);
RegisterHeader(G, 'procedure CheckTokenSymbol(const S: string);', @TParser.CheckTokenSymbol);
RegisterHeader(G, 'procedure Error(const Ident: string);', @TParser.Error);
RegisterHeader(G, 'procedure ErrorStr(const Message: string);', @TParser.ErrorStr);
RegisterHeader(G, 'procedure HexToBinary(Stream: TStream);', @TParser.HexToBinary);
RegisterHeader(G, 'function NextToken: Char;', @TParser.NextToken);
RegisterHeader(G, 'function SourcePos: Longint;', @TParser.SourcePos);
RegisterHeader(G, 'function TokenComponentIdent: string;', @TParser.TokenComponentIdent);
RegisterHeader(G, 'function TokenFloat: Extended;', @TParser.TokenFloat);
RegisterHeader(G, 'function TokenString: string;', @TParser.TokenString);
RegisterHeader(G, 'function TokenSymbolIs(const S: string): Boolean;', @TParser.TokenSymbolIs);
RegisterFakeHeader(G, 'function _GetFloatType: Char;', @TParser_GetFloatType);
RegisterProperty(G, 'property FloatType: Char read _GetFloatType;');
RegisterFakeHeader(G, 'function _GetSourceLine: Integer;', @TParser_GetSourceLine);
RegisterProperty(G, 'property SourceLine: Integer read _GetSourceLine;');
RegisterFakeHeader(G, 'function _GetToken: Char;', @TParser_GetToken);
RegisterProperty(G, 'property Token: Char read _GetToken;');
// TComponent ------------------------------------------------------------------
RegisterClassType(H, TBasicAction);
RegisterRTTIType(H, TypeInfo(TComponentState));
RegisterRTTIType(H, TypeInfo(TComponentStyle));
G := RegisterClassType(H, TComponent);
RegisterHeader(G, 'constructor Create(AOwner: TComponent); virtual;', @TComponent.Create);
RegisterHeader(G, 'procedure BeforeDestruction; override;', @TComponent.BeforeDestruction);
RegisterHeader(G, 'procedure DestroyComponents;', @TComponent.DestroyComponents);
RegisterHeader(G, 'procedure Destroying;', @TComponent.Destroying);
RegisterHeader(G, 'function ExecuteAction(Action: TBasicAction): Boolean; dynamic;', @TComponent.ExecuteAction);
RegisterHeader(G, 'function FindComponent(const AName: string): TComponent;', @TComponent.FindComponent);
RegisterHeader(G, 'procedure FreeNotification(AComponent: TComponent);', @TComponent.FreeNotification);
RegisterHeader(G, 'procedure RemoveFreeNotification(AComponent: TComponent);', @TComponent.RemoveFreeNotification);
RegisterHeader(G, 'procedure FreeOnRelease;', @TComponent.FreeOnRelease);
RegisterHeader(G, 'function GetParentComponent: TComponent; dynamic;', @TComponent.GetParentComponent);
RegisterHeader(G, 'function GetNamePath: string; override;', @TComponent.GetNamePath);
RegisterHeader(G, 'function HasParent: Boolean; dynamic;', @TComponent.HasParent);
RegisterHeader(G, 'procedure InsertComponent(AComponent: TComponent);', @TComponent.InsertComponent);
RegisterHeader(G, 'procedure RemoveComponent(AComponent: TComponent);', @TComponent.RemoveComponent);
RegisterHeader(G, 'function SafeCallException(ExceptObject: TObject; ExceptAddr: Pointer): HResult; override;', @TComponent.SafeCallException);
RegisterHeader(G, 'function UpdateAction(Action: TBasicAction): Boolean; dynamic;', @TComponent.UpdateAction);
RegisterFakeHeader(G, 'function _GetComponent(I: Integer): TComponent;', @TComponent_GetComponent);
RegisterProperty(G, 'property Components[Index: Integer]: TComponent read _GetComponent;');
RegisterFakeHeader(G, 'function _GetComponentCount: Integer;', @TComponent_GetComponentCount);
RegisterProperty(G, 'property ComponentCount: Integer read _GetComponentCount;');
RegisterFakeHeader(G, 'function _GetComponentIndex: Integer;', @TComponent_GetComponentIndex);
RegisterFakeHeader(G, 'procedure _SetComponentIndex(Value: Integer);', @TComponent_SetComponentIndex);
RegisterProperty(G, 'property ComponentIndex: Integer read _GetComponentIndex write _SetComponentIndex;');
RegisterFakeHeader(G, 'function _GetComponentState: TComponentState;', @TComponent_GetComponentState);
RegisterProperty(G, 'property ComponentState: TComponentState read _GetComponentState;');
RegisterFakeHeader(G, 'function _GetComponentStyle: TComponentStyle;', @TComponent_GetComponentStyle);
RegisterProperty(G, 'property ComponentStyle: TComponentStyle read _GetComponentStyle;');
RegisterFakeHeader(G, 'function _GetDesignInfo: Integer;', @TComponent_GetDesignInfo);
RegisterFakeHeader(G, 'procedure _SetDesignInfo(Value: Integer);', @TComponent_SetDesignInfo);
RegisterProperty(G, 'property DesignInfo: Longint read _GetDesignInfo write _SetDesignInfo;');
RegisterFakeHeader(G, 'function _GetOwner: TComponent;', @TComponent_GetOwner);
RegisterProperty(G, 'property Owner: TComponent read _GetOwner;');
{ Point and rectangle constructors }
RegisterHeader(H, 'function Point(AX, AY: Integer): TPoint;', @Point);
RegisterHeader(H, 'function Rect(ALeft, ATop, ARight, ABottom: Integer): TRect;', @Rect);
RegisterHeader(H, 'function Bounds(ALeft, ATop, AWidth, AHeight: Integer): TRect;', @Bounds);
{ Class registration routines }
RegisterHeader(H, 'procedure RegisterClass(AClass: TPersistentClass);', @RegisterClass);
RegisterHeader(H, 'procedure UnRegisterClass(AClass: TPersistentClass);', @UnRegisterClass);
RegisterHeader(H, 'function FindClass(const ClassName: string): TPersistentClass;', @FindClass);
RegisterHeader(H, 'function GetClass(const AClassName: string): TPersistentClass;', @GetClass);
RegisterRTTIType(H, TypeInfo(TOperation));
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,244 @@
{$I PaxCompiler.def}
unit IMPORT_Dialogs;
interface
uses
SysUtils,
Classes,
{$IFDEF DPULSAR}
Winapi.Windows,
Winapi.Messages,
Winapi.CommDlg,
Vcl.Printers,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.StdCtrls,
Vcl.Dialogs,
{$ELSE}
CommDlg,
Windows,
Messages,
Printers,
Graphics,
Controls,
Forms,
StdCtrls,
Dialogs,
{$ENDIF}
Variants,
PaxRegister,
PaxCompiler;
procedure Register_Dialogs;
implementation
function TOpenDialog_GetFileEditStyle(Self:TOpenDialog):TFileEditStyle;
begin
result := Self.FileEditStyle;
end;
procedure TOpenDialog_PutFileEditStyle(Self:TOpenDialog;const Value: TFileEditStyle);
begin
Self.FileEditStyle := Value;
end;
function TFindDialog_GetLeft(Self:TFindDialog):Integer;
begin
result := Self.Left;
end;
procedure TFindDialog_PutLeft(Self:TFindDialog;const Value: Integer);
begin
Self.Left := Value;
end;
function TFindDialog_GetPosition(Self:TFindDialog):TPoint;
begin
result := Self.Position;
end;
procedure TFindDialog_PutPosition(Self:TFindDialog;const Value: TPoint);
begin
Self.Position := Value;
end;
function TFindDialog_GetTop(Self:TFindDialog):Integer;
begin
result := Self.Top;
end;
procedure TFindDialog_PutTop(Self:TFindDialog;const Value: Integer);
begin
Self.Top := Value;
end;
procedure Register_Dialogs;
var G, H: Integer;
begin
H := RegisterNamespace(0, 'Dialogs');
RegisterConstant(H, 'MaxCustomColors', 16);
// Begin of class TCommonDialog
G := RegisterClassType(H, TCommonDialog);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCommonDialog.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TCommonDialog.Destroy);
RegisterHeader(G,
'procedure DefaultHandler(var Message); override;',
@TCommonDialog.DefaultHandler);
// End of class TCommonDialog
RegisterRTTIType(H, TypeInfo(TOpenOption));
RegisterRTTIType(H, TypeInfo(TOpenOptions));
RegisterRTTIType(H, TypeInfo(TOpenOptionEx));
RegisterRTTIType(H, TypeInfo(TOpenOptionsEx));
RegisterRTTIType(H, TypeInfo(TFileEditStyle));
// Begin of class TOpenDialog
G := RegisterClassType(H, TOpenDialog);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TOpenDialog.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TOpenDialog.Destroy);
RegisterHeader(G,
'function Execute: Boolean; override;',
@TOpenDialog.Execute);
RegisterFakeHeader(G,
'function TOpenDialog_GetFileEditStyle:TFileEditStyle;',
@TOpenDialog_GetFileEditStyle);
RegisterFakeHeader(G,
'procedure TOpenDialog_PutFileEditStyle(const Value: TFileEditStyle);',
@TOpenDialog_PutFileEditStyle);
RegisterProperty(G,
'property FileEditStyle:TFileEditStyle read TOpenDialog_GetFileEditStyle write TOpenDialog_PutFileEditStyle;');
// End of class TOpenDialog
// Begin of class TSaveDialog
G := RegisterClassType(H, TSaveDialog);
RegisterHeader(G,
'function Execute: Boolean; override;',
@TSaveDialog.Execute);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TSaveDialog.Create);
// End of class TSaveDialog
RegisterRTTIType(H, TypeInfo(TColorDialogOption));
RegisterRTTIType(H, TypeInfo(TColorDialogOptions));
// Begin of class TColorDialog
G := RegisterClassType(H, TColorDialog);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TColorDialog.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TColorDialog.Destroy);
RegisterHeader(G,
'function Execute: Boolean; override;',
@TColorDialog.Execute);
// End of class TColorDialog
RegisterRTTIType(H, TypeInfo(TFontDialogOption));
RegisterRTTIType(H, TypeInfo(TFontDialogOptions));
RegisterRTTIType(H, TypeInfo(TFontDialogDevice));
// Begin of class TFontDialog
G := RegisterClassType(H, TFontDialog);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TFontDialog.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TFontDialog.Destroy);
RegisterHeader(G,
'function Execute: Boolean; override;',
@TFontDialog.Execute);
// End of class TFontDialog
// Begin of class TPrinterSetupDialog
G := RegisterClassType(H, TPrinterSetupDialog);
RegisterHeader(G,
'function Execute: Boolean; override;',
@TPrinterSetupDialog.Execute);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TPrinterSetupDialog.Create);
// End of class TPrinterSetupDialog
RegisterRTTIType(H, TypeInfo(TPrintRange));
RegisterRTTIType(H, TypeInfo(TPrintDialogOption));
RegisterRTTIType(H, TypeInfo(TPrintDialogOptions));
// Begin of class TPrintDialog
G := RegisterClassType(H, TPrintDialog);
RegisterHeader(G,
'function Execute: Boolean; override;',
@TPrintDialog.Execute);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TPrintDialog.Create);
// End of class TPrintDialog
RegisterRTTIType(H, TypeInfo(TPageSetupDialogOption));
RegisterRTTIType(H, TypeInfo(TPageSetupDialogOptions));
RegisterRTTIType(H, TypeInfo(TPrinterKind));
RegisterRTTIType(H, TypeInfo(TPageType));
RegisterRTTIType(H, TypeInfo(TPageMeasureUnits));
// Begin of class TPageSetupDialog
G := RegisterClassType(H, TPageSetupDialog);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TPageSetupDialog.Create);
RegisterHeader(G,
'function Execute: Boolean; override;',
@TPageSetupDialog.Execute);
RegisterHeader(G,
'function GetDefaults: Boolean;',
@TPageSetupDialog.GetDefaults);
// End of class TPageSetupDialog
RegisterRTTIType(H, TypeInfo(TFindOption));
RegisterRTTIType(H, TypeInfo(TFindOptions));
// Begin of class TFindDialog
G := RegisterClassType(H, TFindDialog);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TFindDialog.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TFindDialog.Destroy);
RegisterHeader(G,
'procedure CloseDialog;',
@TFindDialog.CloseDialog);
RegisterHeader(G,
'function Execute: Boolean; override;',
@TFindDialog.Execute);
RegisterFakeHeader(G,
'function TFindDialog_GetLeft:Integer;',
@TFindDialog_GetLeft);
RegisterFakeHeader(G,
'procedure TFindDialog_PutLeft(const Value: Integer);',
@TFindDialog_PutLeft);
RegisterProperty(G,
'property Left:Integer read TFindDialog_GetLeft write TFindDialog_PutLeft;');
RegisterFakeHeader(G,
'function TFindDialog_GetPosition:TPoint;',
@TFindDialog_GetPosition);
RegisterFakeHeader(G,
'procedure TFindDialog_PutPosition(const Value: TPoint);',
@TFindDialog_PutPosition);
RegisterProperty(G,
'property Position:TPoint read TFindDialog_GetPosition write TFindDialog_PutPosition;');
RegisterFakeHeader(G,
'function TFindDialog_GetTop:Integer;',
@TFindDialog_GetTop);
RegisterFakeHeader(G,
'procedure TFindDialog_PutTop(const Value: Integer);',
@TFindDialog_PutTop);
RegisterProperty(G,
'property Top:Integer read TFindDialog_GetTop write TFindDialog_PutTop;');
// End of class TFindDialog
// Begin of class TReplaceDialog
G := RegisterClassType(H, TReplaceDialog);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TReplaceDialog.Create);
// End of class TReplaceDialog
RegisterRTTIType(H, TypeInfo(TMsgDlgType));
RegisterRTTIType(H, TypeInfo(TMsgDlgBtn));
RegisterRTTIType(H, TypeInfo(TMsgDlgButtons));
RegisterHeader(H, 'function MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;', @MessageDlg);
RegisterHeader(H, 'function MessageDlgPos(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer): Integer;', @MessageDlgPos);
RegisterHeader(H, 'function MessageDlgPosHelp(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer; const HelpFileName: string): Integer;', @MessageDlgPosHelp);
RegisterHeader(H, 'procedure ShowMessage(const Msg: string);', @ShowMessage);
RegisterHeader(H, 'procedure ShowMessageFmt(const Msg: string; Params: array of const);', @ShowMessageFmt);
RegisterHeader(H, 'procedure ShowMessagePos(const Msg: string; X, Y: Integer);', @ShowMessagePos);
RegisterHeader(H, 'function InputBox(const ACaption, APrompt, ADefault: string): string;', @InputBox);
RegisterHeader(H, 'function InputQuery(const ACaption, APrompt: string; var Value: string): Boolean;', @InputQuery);
RegisterHeader(H, 'function PromptForFileName(var AFileName: string; const AFilter: string = ''''; const ADefaultExt: string = ''''; const ATitle: string = ''''; const AInitialDir: string = ''''; SaveDialog: Boolean = False): Boolean;', @PromptForFileName);
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,356 @@
{$I PaxCompiler.def}
unit IMPORT_Menus;
interface
uses
SysUtils,
Classes,
Contnrs,
{$IFDEF DPULSAR}
Winapi.Windows,
Winapi.Messages,
Vcl.Graphics,
Vcl.ImgList,
Vcl.ActnList,
Vcl.Menus,
{$ELSE}
Windows,
Messages,
Graphics,
ImgList,
ActnList,
Menus,
{$ENDIF}
Variants,
PaxRegister,
PaxCompiler;
procedure Register_Menus;
implementation
procedure TMenuItem_Add1(Self: TMenuItem;Item: TMenuItem);
begin
Self.Add(Item);
end;
procedure TMenuItem_Add2(Self: TMenuItem;const AItems: array of TMenuItem);
begin
Self.Add(AItems);
end;
function TMenuItem_GetCommand(Self:TMenuItem):Word;
begin
result := Self.Command;
end;
function TMenuItem_GetCount(Self:TMenuItem):Integer;
begin
result := Self.Count;
end;
function TMenuItem_GetItems(Self:TMenuItem;Index: Integer):TMenuItem;
begin
result := Self.Items[Index];
end;
function TMenuItem_GetMenuIndex(Self:TMenuItem):Integer;
begin
result := Self.MenuIndex;
end;
procedure TMenuItem_PutMenuIndex(Self:TMenuItem;const Value: Integer);
begin
Self.MenuIndex := Value;
end;
function TMenuItem_GetParent(Self:TMenuItem):TMenuItem;
begin
result := Self.Parent;
end;
procedure TMenu_ParentBiDiModeChanged3(Self: TMenu);
begin
Self.ParentBiDiModeChanged();
end;
procedure TMenu_ParentBiDiModeChanged4(Self: TMenu;AControl: TObject);
begin
Self.ParentBiDiModeChanged(AControl);
end;
function TMenu_GetAutoHotkeys(Self:TMenu):TMenuAutoFlag;
begin
result := Self.AutoHotkeys;
end;
procedure TMenu_PutAutoHotkeys(Self:TMenu;const Value: TMenuAutoFlag);
begin
Self.AutoHotkeys := Value;
end;
function TMenu_GetAutoLineReduction(Self:TMenu):TMenuAutoFlag;
begin
result := Self.AutoLineReduction;
end;
procedure TMenu_PutAutoLineReduction(Self:TMenu;const Value: TMenuAutoFlag);
begin
Self.AutoLineReduction := Value;
end;
function TMenu_GetOwnerDraw(Self:TMenu):Boolean;
begin
result := Self.OwnerDraw;
end;
procedure TMenu_PutOwnerDraw(Self:TMenu;const Value: Boolean);
begin
Self.OwnerDraw := Value;
end;
function TMenu_GetParentBiDiMode(Self:TMenu):Boolean;
begin
result := Self.ParentBiDiMode;
end;
procedure TMenu_PutParentBiDiMode(Self:TMenu;const Value: Boolean);
begin
Self.ParentBiDiMode := Value;
end;
function TPopupMenu_GetPopupComponent(Self:TPopupMenu):TComponent;
begin
result := Self.PopupComponent;
end;
procedure TPopupMenu_PutPopupComponent(Self:TPopupMenu;const Value: TComponent);
begin
Self.PopupComponent := Value;
end;
function TPopupMenu_GetPopupPoint(Self:TPopupMenu):TPoint;
begin
result := Self.PopupPoint;
end;
procedure Register_Menus;
var G, H: Integer;
begin
H := RegisterNamespace(0, 'Menus');
// Begin of class TMenuItem
G := RegisterClassType(H, TMenuItem);
// End of class TMenuItem
// Begin of class EMenuError
G := RegisterClassType(H, EMenuError);
// End of class EMenuError
// Begin of class TMenu
G := RegisterClassType(H, TMenu);
// End of class TMenu
RegisterRTTIType(H, TypeInfo(TMenuBreak));
RegisterRTTIType(H, TypeInfo(TMenuItemAutoFlag));
RegisterRTTIType(H, TypeInfo(TMenuAutoFlag));
// Begin of class TMenuActionLink
G := RegisterClassType(H, TMenuActionLink);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); virtual;',
@TMenuActionLink.Create);
// End of class TMenuActionLink
RegisterClassReferenceType(H, 'TMenuActionLinkClass');
// Begin of class TMenuItem
G := RegisterClassType(H, TMenuItem);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TMenuItem.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TMenuItem.Destroy);
RegisterHeader(G,
'procedure InitiateAction; virtual;',
@TMenuItem.InitiateAction);
RegisterHeader(G,
'procedure Insert(Index: Integer; Item: TMenuItem);',
@TMenuItem.Insert);
RegisterHeader(G,
'procedure Delete(Index: Integer);',
@TMenuItem.Delete);
RegisterHeader(G,
'procedure Clear;',
@TMenuItem.Clear);
RegisterHeader(G,
'procedure Click; virtual;',
@TMenuItem.Click);
RegisterHeader(G,
'function Find(ACaption: string): TMenuItem;',
@TMenuItem.Find);
RegisterHeader(G,
'function IndexOf(Item: TMenuItem): Integer;',
@TMenuItem.IndexOf);
RegisterHeader(G,
'function IsLine: Boolean;',
@TMenuItem.IsLine);
RegisterHeader(G,
'function GetParentComponent: TComponent; override;',
@TMenuItem.GetParentComponent);
RegisterHeader(G,
'function GetParentMenu: TMenu;',
@TMenuItem.GetParentMenu);
RegisterHeader(G,
'function HasParent: Boolean; override;',
@TMenuItem.HasParent);
RegisterHeader(G,
'function NewTopLine: Integer;',
@TMenuItem.NewTopLine);
RegisterHeader(G,
'function NewBottomLine: Integer;',
@TMenuItem.NewBottomLine);
RegisterHeader(G,
'function InsertNewLineBefore(AItem: TMenuItem): Integer;',
@TMenuItem.InsertNewLineBefore);
RegisterHeader(G,
'function InsertNewLineAfter(AItem: TMenuItem): Integer;',
@TMenuItem.InsertNewLineAfter);
RegisterHeader(G, 'procedure Add(Item: TMenuItem); overload;', @TMenuItem_Add1);
RegisterHeader(G, 'procedure Add(const AItems: array of TMenuItem); overload;', @TMenuItem_Add2);
RegisterHeader(G,
'procedure Remove(Item: TMenuItem);',
@TMenuItem.Remove);
RegisterHeader(G,
'function RethinkHotkeys: Boolean;',
@TMenuItem.RethinkHotkeys);
RegisterHeader(G,
'function RethinkLines: Boolean;',
@TMenuItem.RethinkLines);
RegisterFakeHeader(G,
'function TMenuItem_GetCommand:Word;',
@TMenuItem_GetCommand);
RegisterProperty(G,
'property Command:Word read TMenuItem_GetCommand;');
RegisterFakeHeader(G,
'function TMenuItem_GetCount:Integer;',
@TMenuItem_GetCount);
RegisterProperty(G,
'property Count:Integer read TMenuItem_GetCount;');
RegisterFakeHeader(G,
'function TMenuItem_GetItems(Index: Integer):TMenuItem;',
@TMenuItem_GetItems);
RegisterProperty(G,
'property Items[Index: Integer]:TMenuItem read TMenuItem_GetItems;default;');
RegisterFakeHeader(G,
'function TMenuItem_GetMenuIndex:Integer;',
@TMenuItem_GetMenuIndex);
RegisterFakeHeader(G,
'procedure TMenuItem_PutMenuIndex(const Value: Integer);',
@TMenuItem_PutMenuIndex);
RegisterProperty(G,
'property MenuIndex:Integer read TMenuItem_GetMenuIndex write TMenuItem_PutMenuIndex;');
RegisterFakeHeader(G,
'function TMenuItem_GetParent:TMenuItem;',
@TMenuItem_GetParent);
RegisterProperty(G,
'property Parent:TMenuItem read TMenuItem_GetParent;');
// End of class TMenuItem
RegisterRTTIType(H, TypeInfo(TFindItemKind));
// Begin of class TMenu
G := RegisterClassType(H, TMenu);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TMenu.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TMenu.Destroy);
RegisterHeader(G,
'function DispatchCommand(ACommand: Word): Boolean;',
@TMenu.DispatchCommand);
RegisterHeader(G,
'function FindItem(Value: Integer; Kind: TFindItemKind): TMenuItem;',
@TMenu.FindItem);
RegisterHeader(G,
'function IsRightToLeft: Boolean;',
@TMenu.IsRightToLeft);
RegisterHeader(G, 'procedure ParentBiDiModeChanged; overload;', @TMenu_ParentBiDiModeChanged3);
RegisterHeader(G, 'procedure ParentBiDiModeChanged(AControl: TObject); overload;', @TMenu_ParentBiDiModeChanged4);
RegisterFakeHeader(G,
'function TMenu_GetAutoHotkeys:TMenuAutoFlag;',
@TMenu_GetAutoHotkeys);
RegisterFakeHeader(G,
'procedure TMenu_PutAutoHotkeys(const Value: TMenuAutoFlag);',
@TMenu_PutAutoHotkeys);
RegisterProperty(G,
'property AutoHotkeys:TMenuAutoFlag read TMenu_GetAutoHotkeys write TMenu_PutAutoHotkeys;');
RegisterFakeHeader(G,
'function TMenu_GetAutoLineReduction:TMenuAutoFlag;',
@TMenu_GetAutoLineReduction);
RegisterFakeHeader(G,
'procedure TMenu_PutAutoLineReduction(const Value: TMenuAutoFlag);',
@TMenu_PutAutoLineReduction);
RegisterProperty(G,
'property AutoLineReduction:TMenuAutoFlag read TMenu_GetAutoLineReduction write TMenu_PutAutoLineReduction;');
RegisterFakeHeader(G,
'function TMenu_GetOwnerDraw:Boolean;',
@TMenu_GetOwnerDraw);
RegisterFakeHeader(G,
'procedure TMenu_PutOwnerDraw(const Value: Boolean);',
@TMenu_PutOwnerDraw);
RegisterProperty(G,
'property OwnerDraw:Boolean read TMenu_GetOwnerDraw write TMenu_PutOwnerDraw;');
RegisterFakeHeader(G,
'function TMenu_GetParentBiDiMode:Boolean;',
@TMenu_GetParentBiDiMode);
RegisterFakeHeader(G,
'procedure TMenu_PutParentBiDiMode(const Value: Boolean);',
@TMenu_PutParentBiDiMode);
RegisterProperty(G,
'property ParentBiDiMode:Boolean read TMenu_GetParentBiDiMode write TMenu_PutParentBiDiMode;');
// End of class TMenu
// Begin of class TMainMenu
G := RegisterClassType(H, TMainMenu);
RegisterHeader(G,
'procedure Merge(Menu: TMainMenu);',
@TMainMenu.Merge);
RegisterHeader(G,
'procedure Unmerge(Menu: TMainMenu);',
@TMainMenu.Unmerge);
RegisterHeader(G,
'constructor Create(Owner: TComponent);',
@TMainMenu.Create);
// End of class TMainMenu
RegisterRTTIType(H, TypeInfo(TPopupAlignment));
RegisterRTTIType(H, TypeInfo(TTrackButton));
RegisterRTTIType(H, TypeInfo(TMenuAnimations));
RegisterRTTIType(H, TypeInfo(TMenuAnimation));
// Begin of class TPopupMenu
G := RegisterClassType(H, TPopupMenu);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TPopupMenu.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TPopupMenu.Destroy);
RegisterHeader(G,
'procedure Popup(X, Y: Integer); virtual;',
@TPopupMenu.Popup);
RegisterFakeHeader(G,
'function TPopupMenu_GetPopupComponent:TComponent;',
@TPopupMenu_GetPopupComponent);
RegisterFakeHeader(G,
'procedure TPopupMenu_PutPopupComponent(const Value: TComponent);',
@TPopupMenu_PutPopupComponent);
RegisterProperty(G,
'property PopupComponent:TComponent read TPopupMenu_GetPopupComponent write TPopupMenu_PutPopupComponent;');
RegisterFakeHeader(G,
'function TPopupMenu_GetPopupPoint:TPoint;',
@TPopupMenu_GetPopupPoint);
RegisterProperty(G,
'property PopupPoint:TPoint read TPopupMenu_GetPopupPoint;');
// End of class TPopupMenu
// Begin of class TPopupList
G := RegisterClassType(H, TPopupList);
RegisterHeader(G,
'procedure Add(Popup: TPopupMenu);',
@TPopupList.Add);
RegisterHeader(G,
'procedure Remove(Popup: TPopupMenu);',
@TPopupList.Remove);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); virtual;',
@TPopupList.Create);
// End of class TPopupList
// Begin of class TMenuItemStack
G := RegisterClassType(H, TMenuItemStack);
RegisterHeader(G,
'procedure ClearItem(AItem: TMenuItem);',
@TMenuItemStack.ClearItem);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); virtual;',
@TMenuItemStack.Create);
// End of class TMenuItemStack
RegisterVariable(H, 'PopupList: TPopupList;',@PopupList);
RegisterVariable(H, 'ShortCutItems: TMenuItemStack;',@ShortCutItems);
RegisterHeader(H, 'function NewMenu(Owner: TComponent; const AName: string; const Items: array of TMenuItem): TMainMenu;', @NewMenu);
RegisterHeader(H, 'function NewPopupMenu(Owner: TComponent; const AName: string; Alignment: TPopupAlignment; AutoPopup: Boolean; const Items: array of TMenuItem): TPopupMenu;', @NewPopupMenu);
RegisterHeader(H, 'function NewLine: TMenuItem;', @NewLine);
RegisterConstant(H, 'cHotkeyPrefix', '&');
RegisterConstant(H, 'cLineCaption', '-');
RegisterConstant(H, 'cDialogSuffix', '...');
RegisterHeader(H, 'function StripHotkey(const Text: string): string;', @StripHotkey);
RegisterHeader(H, 'function GetHotkey(const Text: string): string;', @GetHotkey);
RegisterHeader(H, 'function AnsiSameCaption(const Text1, Text2: string): Boolean;', @AnsiSameCaption);
end;
end.

View File

@ -0,0 +1,641 @@
{$I PaxCompiler.def}
unit IMPORT_StdCtrls;
interface
uses
SysUtils,
Classes,
{$IFDEF DPULSAR}
Winapi.Messages,
Winapi.Windows,
Vcl.Controls,
Vcl.Forms,
Vcl.Menus,
Vcl.Graphics,
Vcl.StdCtrls,
{$ELSE}
Messages,
Windows,
Controls,
Forms,
Menus,
Graphics,
StdCtrls,
{$ENDIF}
Variants,
PaxRegister,
PaxCompiler;
procedure Register_StdCtrls;
implementation
type
TMemoStrings = class(TStrings)
private
Memo: TCustomMemo;
public
// procedure Clear; override;
end;
// procedure TMemoStrings.Clear;
// begin
// Memo.Clear;
// end;
procedure TMemoStrings_Clear(Self: TMemoStrings); // fake method
begin
Self.Memo.Clear;
end;
type
TListBoxStrings = class(TStrings)
private
ListBox: TCustomListBox;
public
// procedure Clear; override;
end;
// procedure TListBoxStrings.Clear;
// begin
// ListBox.Clear;
// end;
procedure TListBoxStrings_Clear(Self: TListBoxStrings); // fake method
begin
Self.ListBox.Clear;
end;
function TCustomEdit_GetCanUndo(Self:TCustomEdit):Boolean;
begin
result := Self.CanUndo;
end;
function TCustomEdit_GetModified(Self:TCustomEdit):Boolean;
begin
result := Self.Modified;
end;
procedure TCustomEdit_PutModified(Self:TCustomEdit;const Value: Boolean);
begin
Self.Modified := Value;
end;
function TCustomEdit_GetSelLength(Self:TCustomEdit):Integer;
begin
result := Self.SelLength;
end;
procedure TCustomEdit_PutSelLength(Self:TCustomEdit;const Value: Integer);
begin
Self.SelLength := Value;
end;
function TCustomEdit_GetSelStart(Self:TCustomEdit):Integer;
begin
result := Self.SelStart;
end;
procedure TCustomEdit_PutSelStart(Self:TCustomEdit;const Value: Integer);
begin
Self.SelStart := Value;
end;
function TCustomEdit_GetSelText(Self:TCustomEdit):string;
begin
result := Self.SelText;
end;
procedure TCustomEdit_PutSelText(Self:TCustomEdit;const Value: string);
begin
Self.SelText := Value;
end;
function TCustomMemo_GetCaretPos(Self:TCustomMemo):TPoint;
begin
result := Self.CaretPos;
end;
procedure TCustomMemo_PutCaretPos(Self:TCustomMemo;const Value: TPoint);
begin
Self.CaretPos := Value;
end;
function TCustomCombo_GetDroppedDown(Self:TCustomCombo):Boolean;
begin
result := Self.DroppedDown;
end;
procedure TCustomCombo_PutDroppedDown(Self:TCustomCombo;const Value: Boolean);
begin
Self.DroppedDown := Value;
end;
function TCustomCombo_GetSelLength(Self:TCustomCombo):Integer;
begin
result := Self.SelLength;
end;
procedure TCustomCombo_PutSelLength(Self:TCustomCombo;const Value: Integer);
begin
Self.SelLength := Value;
end;
function TCustomCombo_GetSelStart(Self:TCustomCombo):Integer;
begin
result := Self.SelStart;
end;
procedure TCustomCombo_PutSelStart(Self:TCustomCombo;const Value: Integer);
begin
Self.SelStart := Value;
end;
function TCustomComboBox_GetAutoComplete(Self:TCustomComboBox):Boolean;
begin
result := Self.AutoComplete;
end;
procedure TCustomComboBox_PutAutoComplete(Self:TCustomComboBox;const Value: Boolean);
begin
Self.AutoComplete := Value;
end;
function TCustomComboBox_GetAutoCloseUp(Self:TCustomComboBox):Boolean;
begin
result := Self.AutoCloseUp;
end;
procedure TCustomComboBox_PutAutoCloseUp(Self:TCustomComboBox;const Value: Boolean);
begin
Self.AutoCloseUp := Value;
end;
function TCustomComboBox_GetAutoDropDown(Self:TCustomComboBox):Boolean;
begin
result := Self.AutoDropDown;
end;
procedure TCustomComboBox_PutAutoDropDown(Self:TCustomComboBox;const Value: Boolean);
begin
Self.AutoDropDown := Value;
end;
function TCustomComboBox_GetCharCase(Self:TCustomComboBox):TEditCharCase;
begin
result := Self.CharCase;
end;
procedure TCustomComboBox_PutCharCase(Self:TCustomComboBox;const Value: TEditCharCase);
begin
Self.CharCase := Value;
end;
function TCustomComboBox_GetSelText(Self:TCustomComboBox):string;
begin
result := Self.SelText;
end;
procedure TCustomComboBox_PutSelText(Self:TCustomComboBox;const Value: string);
begin
Self.SelText := Value;
end;
function TCustomListBox_GetAutoComplete(Self:TCustomListBox):Boolean;
begin
result := Self.AutoComplete;
end;
procedure TCustomListBox_PutAutoComplete(Self:TCustomListBox;const Value: Boolean);
begin
Self.AutoComplete := Value;
end;
function TCustomListBox_GetCount(Self:TCustomListBox):Integer;
begin
result := Self.Count;
end;
procedure TCustomListBox_PutCount(Self:TCustomListBox;const Value: Integer);
begin
Self.Count := Value;
end;
function TCustomListBox_GetSelected(Self:TCustomListBox;Index: Integer):Boolean;
begin
result := Self.Selected[Index];
end;
procedure TCustomListBox_PutSelected(Self:TCustomListBox;Index: Integer;const Value: Boolean);
begin
Self.Selected[Index] := Value;
end;
function TCustomListBox_GetScrollWidth(Self:TCustomListBox):Integer;
begin
result := Self.ScrollWidth;
end;
procedure TCustomListBox_PutScrollWidth(Self:TCustomListBox;const Value: Integer);
begin
Self.ScrollWidth := Value;
end;
function TCustomListBox_GetTopIndex(Self:TCustomListBox):Integer;
begin
result := Self.TopIndex;
end;
procedure TCustomListBox_PutTopIndex(Self:TCustomListBox;const Value: Integer);
begin
Self.TopIndex := Value;
end;
procedure Register_StdCtrls;
var G, H: Integer;
begin
H := RegisterNamespace(0, 'StdCtrls');
// Begin of class TCustomGroupBox
G := RegisterClassType(H, TCustomGroupBox);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCustomGroupBox.Create);
// End of class TCustomGroupBox
// Begin of class TGroupBox
G := RegisterClassType(H, TGroupBox);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TGroupBox.Create);
// End of class TGroupBox
RegisterRTTIType(H, TypeInfo(TTextLayout));
// Begin of class TCustomLabel
G := RegisterClassType(H, TCustomLabel);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCustomLabel.Create);
// End of class TCustomLabel
// Begin of class TLabel
G := RegisterClassType(H, TLabel);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TLabel.Create);
// End of class TLabel
RegisterRTTIType(H, TypeInfo(TEditCharCase));
// Begin of class TCustomEdit
G := RegisterClassType(H, TCustomEdit);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCustomEdit.Create);
RegisterHeader(G,
'procedure Clear; virtual;',
@TCustomEdit.Clear);
RegisterHeader(G,
'procedure ClearSelection;',
@TCustomEdit.ClearSelection);
RegisterHeader(G,
'procedure CopyToClipboard;',
@TCustomEdit.CopyToClipboard);
RegisterHeader(G,
'procedure CutToClipboard;',
@TCustomEdit.CutToClipboard);
RegisterHeader(G,
'procedure DefaultHandler(var Message); override;',
@TCustomEdit.DefaultHandler);
RegisterHeader(G,
'procedure PasteFromClipboard;',
@TCustomEdit.PasteFromClipboard);
RegisterHeader(G,
'procedure Undo;',
@TCustomEdit.Undo);
RegisterHeader(G,
'procedure ClearUndo;',
@TCustomEdit.ClearUndo);
RegisterHeader(G,
'function GetSelTextBuf(Buffer: PChar; BufSize: Integer): Integer; virtual;',
@TCustomEdit.GetSelTextBuf);
RegisterHeader(G,
'procedure SelectAll;',
@TCustomEdit.SelectAll);
RegisterHeader(G,
'procedure SetSelTextBuf(Buffer: PChar);',
@TCustomEdit.SetSelTextBuf);
RegisterFakeHeader(G,
'function TCustomEdit_GetCanUndo:Boolean;',
@TCustomEdit_GetCanUndo);
RegisterProperty(G,
'property CanUndo:Boolean read TCustomEdit_GetCanUndo;');
RegisterFakeHeader(G,
'function TCustomEdit_GetModified:Boolean;',
@TCustomEdit_GetModified);
RegisterFakeHeader(G,
'procedure TCustomEdit_PutModified(const Value: Boolean);',
@TCustomEdit_PutModified);
RegisterProperty(G,
'property Modified:Boolean read TCustomEdit_GetModified write TCustomEdit_PutModified;');
RegisterFakeHeader(G,
'function TCustomEdit_GetSelLength:Integer;',
@TCustomEdit_GetSelLength);
RegisterFakeHeader(G,
'procedure TCustomEdit_PutSelLength(const Value: Integer);',
@TCustomEdit_PutSelLength);
RegisterProperty(G,
'property SelLength:Integer read TCustomEdit_GetSelLength write TCustomEdit_PutSelLength;');
RegisterFakeHeader(G,
'function TCustomEdit_GetSelStart:Integer;',
@TCustomEdit_GetSelStart);
RegisterFakeHeader(G,
'procedure TCustomEdit_PutSelStart(const Value: Integer);',
@TCustomEdit_PutSelStart);
RegisterProperty(G,
'property SelStart:Integer read TCustomEdit_GetSelStart write TCustomEdit_PutSelStart;');
RegisterFakeHeader(G,
'function TCustomEdit_GetSelText:string;',
@TCustomEdit_GetSelText);
RegisterFakeHeader(G,
'procedure TCustomEdit_PutSelText(const Value: string);',
@TCustomEdit_PutSelText);
RegisterProperty(G,
'property SelText:string read TCustomEdit_GetSelText write TCustomEdit_PutSelText;');
// End of class TCustomEdit
// Begin of class TEdit
G := RegisterClassType(H, TEdit);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TEdit.Create);
// End of class TEdit
RegisterRTTIType(H, TypeInfo(TScrollStyle));
// Begin of class TCustomMemo
G := RegisterClassType(H, TCustomMemo);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCustomMemo.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TCustomMemo.Destroy);
RegisterFakeHeader(G,
'function TCustomMemo_GetCaretPos:TPoint;',
@TCustomMemo_GetCaretPos);
RegisterFakeHeader(G,
'procedure TCustomMemo_PutCaretPos(const Value: TPoint);',
@TCustomMemo_PutCaretPos);
RegisterProperty(G,
'property CaretPos:TPoint read TCustomMemo_GetCaretPos write TCustomMemo_PutCaretPos;');
// End of class TCustomMemo
// Begin of class TMemo
G := RegisterClassType(H, TMemo);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TMemo.Create);
// End of class TMemo
// Begin of class TCustomCombo
G := RegisterClassType(H, TCustomCombo);
// End of class TCustomCombo
// Begin of class TCustomComboBoxStrings
G := RegisterClassType(H, TCustomComboBoxStrings);
RegisterHeader(G,
'procedure Clear; override;',
@TCustomComboBoxStrings.Clear);
RegisterHeader(G,
'procedure Delete(Index: Integer); override;',
@TCustomComboBoxStrings.Delete);
RegisterHeader(G,
'function IndexOf(const S: string): Integer; override;',
@TCustomComboBoxStrings.IndexOf);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); virtual;',
@TCustomComboBoxStrings.Create);
// End of class TCustomComboBoxStrings
RegisterClassReferenceType(H, 'TCustomComboBoxStringsClass');
// Begin of class TCustomCombo
G := RegisterClassType(H, TCustomCombo);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCustomCombo.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TCustomCombo.Destroy);
RegisterHeader(G,
'procedure AddItem(Item: String; AObject: TObject); override;',
@TCustomCombo.AddItem);
RegisterHeader(G,
'procedure Clear; override;',
@TCustomCombo.Clear);
RegisterHeader(G,
'procedure ClearSelection; override;',
@TCustomCombo.ClearSelection);
RegisterHeader(G,
'procedure CopySelection(Destination: TCustomListControl); override;',
@TCustomCombo.CopySelection);
RegisterHeader(G,
'procedure DeleteSelected; override;',
@TCustomCombo.DeleteSelected);
RegisterHeader(G,
'function Focused: Boolean; override;',
@TCustomCombo.Focused);
RegisterHeader(G,
'procedure SelectAll; override;',
@TCustomCombo.SelectAll);
RegisterFakeHeader(G,
'function TCustomCombo_GetDroppedDown:Boolean;',
@TCustomCombo_GetDroppedDown);
RegisterFakeHeader(G,
'procedure TCustomCombo_PutDroppedDown(const Value: Boolean);',
@TCustomCombo_PutDroppedDown);
RegisterProperty(G,
'property DroppedDown:Boolean read TCustomCombo_GetDroppedDown write TCustomCombo_PutDroppedDown;');
RegisterFakeHeader(G,
'function TCustomCombo_GetSelLength:Integer;',
@TCustomCombo_GetSelLength);
RegisterFakeHeader(G,
'procedure TCustomCombo_PutSelLength(const Value: Integer);',
@TCustomCombo_PutSelLength);
RegisterProperty(G,
'property SelLength:Integer read TCustomCombo_GetSelLength write TCustomCombo_PutSelLength;');
RegisterFakeHeader(G,
'function TCustomCombo_GetSelStart:Integer;',
@TCustomCombo_GetSelStart);
RegisterFakeHeader(G,
'procedure TCustomCombo_PutSelStart(const Value: Integer);',
@TCustomCombo_PutSelStart);
RegisterProperty(G,
'property SelStart:Integer read TCustomCombo_GetSelStart write TCustomCombo_PutSelStart;');
// End of class TCustomCombo
RegisterRTTIType(H, TypeInfo(TComboBoxStyle));
// Begin of class TCustomComboBox
G := RegisterClassType(H, TCustomComboBox);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCustomComboBox.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TCustomComboBox.Destroy);
RegisterFakeHeader(G,
'function TCustomComboBox_GetAutoComplete:Boolean;',
@TCustomComboBox_GetAutoComplete);
RegisterFakeHeader(G,
'procedure TCustomComboBox_PutAutoComplete(const Value: Boolean);',
@TCustomComboBox_PutAutoComplete);
RegisterProperty(G,
'property AutoComplete:Boolean read TCustomComboBox_GetAutoComplete write TCustomComboBox_PutAutoComplete;');
RegisterFakeHeader(G,
'function TCustomComboBox_GetAutoCloseUp:Boolean;',
@TCustomComboBox_GetAutoCloseUp);
RegisterFakeHeader(G,
'procedure TCustomComboBox_PutAutoCloseUp(const Value: Boolean);',
@TCustomComboBox_PutAutoCloseUp);
RegisterProperty(G,
'property AutoCloseUp:Boolean read TCustomComboBox_GetAutoCloseUp write TCustomComboBox_PutAutoCloseUp;');
RegisterFakeHeader(G,
'function TCustomComboBox_GetAutoDropDown:Boolean;',
@TCustomComboBox_GetAutoDropDown);
RegisterFakeHeader(G,
'procedure TCustomComboBox_PutAutoDropDown(const Value: Boolean);',
@TCustomComboBox_PutAutoDropDown);
RegisterProperty(G,
'property AutoDropDown:Boolean read TCustomComboBox_GetAutoDropDown write TCustomComboBox_PutAutoDropDown;');
RegisterFakeHeader(G,
'function TCustomComboBox_GetCharCase:TEditCharCase;',
@TCustomComboBox_GetCharCase);
RegisterFakeHeader(G,
'procedure TCustomComboBox_PutCharCase(const Value: TEditCharCase);',
@TCustomComboBox_PutCharCase);
RegisterProperty(G,
'property CharCase:TEditCharCase read TCustomComboBox_GetCharCase write TCustomComboBox_PutCharCase;');
RegisterFakeHeader(G,
'function TCustomComboBox_GetSelText:string;',
@TCustomComboBox_GetSelText);
RegisterFakeHeader(G,
'procedure TCustomComboBox_PutSelText(const Value: string);',
@TCustomComboBox_PutSelText);
RegisterProperty(G,
'property SelText:string read TCustomComboBox_GetSelText write TCustomComboBox_PutSelText;');
// End of class TCustomComboBox
// Begin of class TComboBox
G := RegisterClassType(H, TComboBox);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TComboBox.Create);
// End of class TComboBox
// Begin of class TButtonControl
G := RegisterClassType(H, TButtonControl);
// End of class TButtonControl
// Begin of class TButtonActionLink
G := RegisterClassType(H, TButtonActionLink);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); virtual;',
@TButtonActionLink.Create);
// End of class TButtonActionLink
RegisterClassReferenceType(H, 'TButtonActionLinkClass');
// Begin of class TButtonControl
G := RegisterClassType(H, TButtonControl);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TButtonControl.Create);
// End of class TButtonControl
// Begin of class TButton
G := RegisterClassType(H, TButton);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TButton.Create);
RegisterHeader(G,
'procedure Click; override;',
@TButton.Click);
RegisterHeader(G,
'function UseRightToLeftAlignment: Boolean; override;',
@TButton.UseRightToLeftAlignment);
// End of class TButton
RegisterRTTIType(H, TypeInfo(TCheckBoxState));
// Begin of class TCustomCheckBox
G := RegisterClassType(H, TCustomCheckBox);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCustomCheckBox.Create);
// End of class TCustomCheckBox
// Begin of class TCheckBox
G := RegisterClassType(H, TCheckBox);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCheckBox.Create);
// End of class TCheckBox
// Begin of class TRadioButton
G := RegisterClassType(H, TRadioButton);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TRadioButton.Create);
// End of class TRadioButton
RegisterRTTIType(H, TypeInfo(TListBoxStyle));
// Begin of class TCustomListBox
G := RegisterClassType(H, TCustomListBox);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCustomListBox.Create);
RegisterHeader(G,
'destructor Destroy; override;',
@TCustomListBox.Destroy);
RegisterHeader(G,
'procedure AddItem(Item: String; AObject: TObject); override;',
@TCustomListBox.AddItem);
RegisterHeader(G,
'procedure Clear; override;',
@TCustomListBox.Clear);
RegisterHeader(G,
'procedure ClearSelection; override;',
@TCustomListBox.ClearSelection);
RegisterHeader(G,
'procedure CopySelection(Destination: TCustomListControl); override;',
@TCustomListBox.CopySelection);
RegisterHeader(G,
'procedure DeleteSelected; override;',
@TCustomListBox.DeleteSelected);
RegisterHeader(G,
'function ItemAtPos(Pos: TPoint; Existing: Boolean): Integer;',
@TCustomListBox.ItemAtPos);
RegisterHeader(G,
'function ItemRect(Index: Integer): TRect;',
@TCustomListBox.ItemRect);
RegisterHeader(G,
'procedure SelectAll; override;',
@TCustomListBox.SelectAll);
RegisterFakeHeader(G,
'function TCustomListBox_GetAutoComplete:Boolean;',
@TCustomListBox_GetAutoComplete);
RegisterFakeHeader(G,
'procedure TCustomListBox_PutAutoComplete(const Value: Boolean);',
@TCustomListBox_PutAutoComplete);
RegisterProperty(G,
'property AutoComplete:Boolean read TCustomListBox_GetAutoComplete write TCustomListBox_PutAutoComplete;');
RegisterFakeHeader(G,
'function TCustomListBox_GetCount:Integer;',
@TCustomListBox_GetCount);
RegisterFakeHeader(G,
'procedure TCustomListBox_PutCount(const Value: Integer);',
@TCustomListBox_PutCount);
RegisterProperty(G,
'property Count:Integer read TCustomListBox_GetCount write TCustomListBox_PutCount;');
RegisterFakeHeader(G,
'function TCustomListBox_GetSelected(Index: Integer):Boolean;',
@TCustomListBox_GetSelected);
RegisterFakeHeader(G,
'procedure TCustomListBox_PutSelected(Index: Integer;const Value: Boolean);',
@TCustomListBox_PutSelected);
RegisterProperty(G,
'property Selected[Index: Integer]:Boolean read TCustomListBox_GetSelected write TCustomListBox_PutSelected;');
RegisterFakeHeader(G,
'function TCustomListBox_GetScrollWidth:Integer;',
@TCustomListBox_GetScrollWidth);
RegisterFakeHeader(G,
'procedure TCustomListBox_PutScrollWidth(const Value: Integer);',
@TCustomListBox_PutScrollWidth);
RegisterProperty(G,
'property ScrollWidth:Integer read TCustomListBox_GetScrollWidth write TCustomListBox_PutScrollWidth;');
RegisterFakeHeader(G,
'function TCustomListBox_GetTopIndex:Integer;',
@TCustomListBox_GetTopIndex);
RegisterFakeHeader(G,
'procedure TCustomListBox_PutTopIndex(const Value: Integer);',
@TCustomListBox_PutTopIndex);
RegisterProperty(G,
'property TopIndex:Integer read TCustomListBox_GetTopIndex write TCustomListBox_PutTopIndex;');
// End of class TCustomListBox
// Begin of class TListBox
G := RegisterClassType(H, TListBox);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TListBox.Create);
// End of class TListBox
RegisterRTTIType(H, TypeInfo(TScrollCode));
// Begin of class TScrollBar
G := RegisterClassType(H, TScrollBar);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TScrollBar.Create);
RegisterHeader(G,
'procedure SetParams(APosition, AMin, AMax: Integer);',
@TScrollBar.SetParams);
// End of class TScrollBar
RegisterRTTIType(H, TypeInfo(TStaticBorderStyle));
// Begin of class TCustomStaticText
G := RegisterClassType(H, TCustomStaticText);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TCustomStaticText.Create);
// End of class TCustomStaticText
// Begin of class TStaticText
G := RegisterClassType(H, TStaticText);
RegisterHeader(G,
'constructor Create(AOwner: TComponent); override;',
@TStaticText.Create);
// End of class TStaticText
G := RegisterClassType(H, TMemoStrings);
RegisterHeader(G, 'procedure Clear; override;', @TMemoStrings_Clear);
G := RegisterClassType(H, TListBoxStrings);
RegisterHeader(G, 'procedure Clear; override;', @TListBoxStrings_Clear);
end;
end.

View File

@ -0,0 +1,375 @@
unit IMPORT_SysUtils;
interface
uses
SysUtils,
PaxRegister,
PaxCompiler;
procedure Register_SysUtils;
implementation
function _Format(const S: string; const Args: array of const): string;
begin
result := Format(S, Args);
end;
// Exception -------------------------------------------------------------------
function Exception_GetMessage(Self: Exception): String;
begin
result := Self.Message;
end;
procedure Exception_SetMessage(Self: Exception; const Value: String);
begin
Self.Message := Value;
end;
function Exception_GetHelpContext(Self: Exception): Integer;
begin
result := Self.HelpContext;
end;
procedure Exception_SetHelpContext(Self: Exception; Value: Integer);
begin
Self.HelpContext := Value;
end;
procedure Register_SysUtils;
var
H, G: Integer;
begin
H := RegisterNamespace(0, 'SysUtils');
RegisterRTTIType(H, TypeInfo(TReplaceFlags));
G := RegisterRecordType(H, 'TTimeStamp');
RegisterRecordTypeField(G, 'Time', _typeINTEGER);
RegisterRecordTypeField(G, 'Date', _typeINTEGER);
G := RegisterRecordType(H, 'TSystemTime');
RegisterRecordTypeField(G, 'wYear', _typeWORD);
RegisterRecordTypeField(G, 'wMonth', _typeWORD);
RegisterRecordTypeField(G, 'wDayOfWeek', _typeWORD);
RegisterRecordTypeField(G, 'wDay', _typeWORD);
RegisterRecordTypeField(G, 'wHour', _typeWORD);
RegisterRecordTypeField(G, 'wMinute', _typeWORD);
RegisterRecordTypeField(G, 'wSecond', _typeWORD);
RegisterRecordTypeField(G, 'wMilliSecond', _typeWORD);
{ File open modes }
RegisterConstant(H, 'fmOpenRead', fmOpenRead);
RegisterConstant(H, 'fmOpenWrite', fmOpenWrite);
RegisterConstant(H, 'fmOpenReadWrite', fmOpenReadWrite);
RegisterConstant(H, 'fmShareExclusive', fmShareExclusive);
RegisterConstant(H, 'fmShareDenyWrite', fmShareDenyWrite);
RegisterConstant(H, 'fmShareDenyNone', fmShareDenyNone);
{$IFNDEF MACOS}
RegisterConstant(H, 'fmShareCompat', fmShareCompat);
RegisterConstant(H, 'fmShareDenyRead', fmShareDenyRead);
{$ENDIF}
{ File attribute constants }
RegisterConstant(H, 'faReadOnly', faReadOnly);
RegisterConstant(H, 'faHidden', faHidden);
RegisterConstant(H, 'faSysFile', faSysFile);
RegisterConstant(H, 'faVolumeID', faVolumeID);
RegisterConstant(H, 'faDirectory', faDirectory);
RegisterConstant(H, 'faArchive', faArchive);
RegisterConstant(H, 'faAnyFile', faAnyFile);
{ File mode magic numbers }
RegisterConstant(H, 'fmClosed', fmClosed);
RegisterConstant(H, 'fmInput', fmInput);
RegisterConstant(H, 'fmOutput', fmOutput);
RegisterConstant(H, 'fmInOut', fmInOut);
{ Seconds and milliseconds per day }
RegisterConstant(H, 'SecsPerDay', SecsPerDay);
RegisterConstant(H, 'MSecsPerDay', MSecsPerDay);
{ Days between 1/1/0001 and 12/31/1899 }
RegisterConstant(H, 'DateDelta', DateDelta);
RegisterHeader(H, 'function UpperCase(const S: string): string;', @UpperCase);
RegisterHeader(H, 'function LowerCase(const S: string): string;', @LowerCase);
RegisterHeader(H, 'function CompareStr(const S1, S2: string): Integer;', @CompareStr);
RegisterHeader(H, 'function CompareMem(P1, P2: Pointer; Length: Integer): Boolean;', @CompareMem);
RegisterHeader(H, 'function CompareText(const S1, S2: string): Integer;', @CompareText);
RegisterHeader(H, 'function SameText(const S1, S2: string): Boolean;', @SameText);
RegisterHeader(H, 'function AnsiUpperCase(const S: string): string;', @AnsiUpperCase);
RegisterHeader(H, 'function AnsiLowerCase(const S: string): string;', @AnsiLowerCase);
RegisterHeader(H, 'function AnsiCompareStr(const S1, S2: string): Integer;', @AnsiCompareStr);
RegisterHeader(H, 'function AnsiSameStr(const S1, S2: string): Boolean;', @AnsiSameStr);
RegisterHeader(H, 'function AnsiCompareText(const S1, S2: string): Integer;', @AnsiCompareText);
RegisterHeader(H, 'function AnsiSameText(const S1, S2: string): Boolean;', @AnsiSameText);
RegisterHeader(H, 'function AnsiStrComp(S1, S2: PChar): Integer;', @AnsiStrComp);
RegisterHeader(H, 'function AnsiStrIComp(S1, S2: PChar): Integer;', @AnsiStrIComp);
RegisterHeader(H, 'function AnsiStrLComp(S1, S2: PChar; MaxLen: Cardinal): Integer;', @AnsiStrLComp);
RegisterHeader(H, 'function AnsiStrLIComp(S1, S2: PChar; MaxLen: Cardinal): Integer;', @AnsiStrLIComp);
RegisterHeader(H, 'function AnsiStrLower(Str: PChar): PChar;', @AnsiStrLower);
RegisterHeader(H, 'function AnsiStrUpper(Str: PChar): PChar;', @AnsiStrUpper);
RegisterHeader(H, 'function AnsiLastChar(const S: string): PChar;', @AnsiLastChar);
RegisterHeader(H, 'function AnsiStrLastChar(P: PChar): PChar;', @AnsiStrLastChar);
RegisterHeader(H, 'function Trim(const S: string): string;', @Trim);
RegisterHeader(H, 'function TrimLeft(const S: string): string;', @TrimLeft);
RegisterHeader(H, 'function TrimRight(const S: string): string;', @TrimRight);
RegisterHeader(H, 'function QuotedStr(const S: string): string;', @QuotedStr);
RegisterHeader(H, 'function AnsiQuotedStr(const S: string; Quote: Char): string;', @AnsiQuotedStr);
RegisterHeader(H, 'function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;', @AnsiExtractQuotedStr);
RegisterHeader(H, 'function AdjustLineBreaks(const S: string): string;', @AdjustLineBreaks);
RegisterHeader(H, 'function IsValidIdent(const Ident: string): Boolean;', @IsValidIdent);
RegisterHeader(H, 'function IntToStr(Value: Integer): string;', @IntToStr);
RegisterHeader(H, 'function IntToHex(Value: Integer; Digits: Integer): string;', @IntToHex);
RegisterHeader(H, 'function StrToInt(const S: string): Integer;', @StrToInt);
RegisterHeader(H, 'function StrToIntDef(const S: string; Default: Integer): Integer;', @StrToIntDef);
RegisterHeader(H, 'function LoadStr(Ident: Integer): string;', @LoadStr);
RegisterHeader(H, 'function FileOpen(const FileName: string; Mode: LongWord): Integer;', @FileOpen);
RegisterHeader(H, 'function FileCreate(const FileName: string): Integer;', @FileCreate);
RegisterHeader(H, 'function FileRead(Handle: Integer; var Buffer; Count: LongWord): Integer;', @FileRead);
RegisterHeader(H, 'function FileWrite(Handle: Integer; const Buffer; Count: LongWord): Integer;', @FileWrite);
RegisterHeader(H, 'function FileSeek(Handle, Offset, Origin: Integer): Integer;', @FileSeek);
RegisterHeader(H, 'procedure FileClose(Handle: Integer);', @FileClose);
RegisterHeader(H, 'function FileAge(const FileName: string): Integer;', @FileAge);
RegisterHeader(H, 'function FileExists(const FileName: string): Boolean;', @FileExists);
RegisterHeader(H, 'function FileGetDate(Handle: Integer): Integer;', @FileGetDate);
RegisterHeader(H, 'function FileSetDate(Handle: Integer; Age: Integer): Integer;', @FileSetDate);
RegisterHeader(H, 'function FileGetAttr(const FileName: string): Integer;', @FileGetAttr);
RegisterHeader(H, 'function DeleteFile(const FileName: string): Boolean;', @DeleteFile);
RegisterHeader(H, 'function RenameFile(const OldName, NewName: string): Boolean;', @RenameFile);
RegisterHeader(H, 'function ChangeFileExt(const FileName, Extension: string): string;', @ChangeFileExt);
RegisterHeader(H, 'function ExtractFilePath(const FileName: string): string;', @ExtractFilePath);
RegisterHeader(H, 'function ExtractFileDir(const FileName: string): string;', @ExtractFileDir);
RegisterHeader(H, 'function ExtractFileDrive(const FileName: string): string;', @ExtractFileDrive);
RegisterHeader(H, 'function ExtractFileName(const FileName: string): string;', @ExtractFileName);
RegisterHeader(H, 'function ExtractFileExt(const FileName: string): string;', @ExtractFileExt);
RegisterHeader(H, 'function ExpandFileName(const FileName: string): string;', @ExpandFileName);
RegisterHeader(H, 'function ExpandUNCFileName(const FileName: string): string;', @ExpandUNCFileName);
RegisterHeader(H, 'function ExtractRelativePath(const BaseName, DestName: string): string;', @ExtractRelativePath);
RegisterHeader(H, 'function FileSearch(const Name, DirList: string): string;', @FileSearch);
RegisterHeader(H, 'function GetCurrentDir: string;', @GetCurrentDir);
RegisterHeader(H, 'function SetCurrentDir(const Dir: string): Boolean;', @SetCurrentDir);
RegisterHeader(H, 'function CreateDir(const Dir: string): Boolean;', @CreateDir);
RegisterHeader(H, 'function RemoveDir(const Dir: string): Boolean;', @RemoveDir);
RegisterHeader(H, 'function StrLen(const Str: PChar): Cardinal;', @StrLen);
RegisterHeader(H, 'function StrEnd(const Str: PChar): PChar;', @StrEnd);
RegisterHeader(H, 'function StrMove(Dest: PChar; const Source: PChar; Count: Cardinal): PChar;', @StrMove);
RegisterHeader(H, 'function StrCopy(Dest: PChar; const Source: PChar): PChar;', @StrCopy);
RegisterHeader(H, 'function StrECopy(Dest:PChar; const Source: PChar): PChar;', @StrECopy);
RegisterHeader(H, 'function StrLCopy(Dest: PChar; const Source: PChar; MaxLen: Cardinal): PChar;', @StrLCopy);
RegisterHeader(H, 'function StrPCopy(Dest: PChar; const Source: string): PChar;', @StrPCopy);
RegisterHeader(H, 'function StrPLCopy(Dest: PChar; const Source: string; MaxLen: Cardinal): PChar;', @StrPLCopy);
RegisterHeader(H, 'function StrCat(Dest: PChar; const Source: PChar): PChar;', @StrCat);
RegisterHeader(H, 'function StrLCat(Dest: PChar; const Source: PChar; MaxLen: Cardinal): PChar;', @StrLCat);
RegisterHeader(H, 'function StrComp(const Str1, Str2: PChar): Integer;', @StrComp);
RegisterHeader(H, 'function StrIComp(const Str1, Str2: PChar): Integer;', @StrIComp);
RegisterHeader(H, 'function StrLComp(const Str1, Str2: PChar; MaxLen: Cardinal): Integer;', @StrLComp);
RegisterHeader(H, 'function StrLIComp(const Str1, Str2: PChar; MaxLen: Cardinal): Integer;', @StrLIComp);
RegisterHeader(H, 'function StrScan(const Str: PChar; Chr: Char): PChar;', @StrScan);
RegisterHeader(H, 'function StrRScan(const Str: PChar; Chr: Char): PChar;', @StrRScan);
RegisterHeader(H, 'function StrPos(const Str1, Str2: PChar): PChar;', @StrPos);
RegisterHeader(H, 'function StrUpper(Str: PChar): PChar;', @StrUpper);
RegisterHeader(H, 'function StrLower(Str: PChar): PChar;', @StrLower);
RegisterHeader(H, 'function StrPas(const Str: PChar): string;', @StrPas);
RegisterHeader(H, 'function StrAlloc(Size: Cardinal): PChar;', @StrAlloc);
RegisterHeader(H, 'function StrBufSize(const Str: PChar): Cardinal;', @StrBufSize);
RegisterHeader(H, 'function StrNew(const Str: PChar): PChar;', @StrNew);
RegisterHeader(H, 'procedure StrDispose(Str: PChar);', @StrDispose);
RegisterHeader(H, 'function FloatToStr(Value: Extended): string;', @FloatToStr);
RegisterHeader(H, 'function FormatFloat(const Format: string; Value: Extended): string;', @FormatFloat);
RegisterHeader(H, 'function StrToFloat(const S: string): Extended;', @StrToFloat);
RegisterHeader(H, 'function DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;', @DateTimeToTimeStamp);
RegisterHeader(H, 'function TimeStampToDateTime(const TimeStamp: TTimeStamp): TDateTime;', @TimeStampToDateTime);
RegisterHeader(H, 'function EncodeDate(Year, Month, Day: Word): TDateTime;', @EncodeDate);
RegisterHeader(H, 'function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime;', @EncodeTime);
RegisterHeader(H, 'procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);', @DecodeDate);
RegisterHeader(H, 'procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word);', @DecodeTime);
RegisterHeader(H, 'function DayOfWeek(Date: TDateTime): Integer;', @DayOfWeek);
RegisterHeader(H, 'function Date: TDateTime;', @Date);
RegisterHeader(H, 'function Time: TDateTime;', @Time);
RegisterHeader(H, 'function Now: TDateTime;', @Now);
RegisterHeader(H, 'function IncMonth(const Date: TDateTime; NumberOfMonths: Integer): TDateTime;', @IncMonth);
RegisterHeader(H, 'procedure ReplaceTime(var DateTime: TDateTime; const NewTime: TDateTime);', @ReplaceTime);
RegisterHeader(H, 'procedure ReplaceDate(var DateTime: TDateTime; const NewDate: TDateTime);', @ReplaceDate);
RegisterHeader(H, 'function IsLeapYear(Year: Word): Boolean;', @IsLeapYear);
RegisterHeader(H, 'function DateToStr(Date: TDateTime): string;', @DateToStr);
RegisterHeader(H, 'function TimeToStr(Time: TDateTime): string;', @TimeToStr);
RegisterHeader(H, 'function DateTimeToStr(DateTime: TDateTime): string;', @DateTimeToStr);
RegisterHeader(H, 'function StrToDate(const S: string): TDateTime;', @StrToDate);
RegisterHeader(H, 'function StrToTime(const S: string): TDateTime;', @StrToTime);
RegisterHeader(H, 'function StrToDateTime(const S: string): TDateTime;', @StrToDateTime);
RegisterHeader(H, 'function FormatDateTime(const Format: string; DateTime: TDateTime): string;', @FormatDateTime);
RegisterHeader(H, 'procedure GetFormatSettings;', @GetFormatSettings);
RegisterHeader(H, 'function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;', @StringReplace);
RegisterHeader(H, 'procedure FreeAndNil(var Obj);', @FreeAndNil);
RegisterHeader(H, 'function Format(const S: string; const Args: array of const): string;',
@_Format);
{$IFNDEF MACOS}
RegisterHeader(H, 'function ExtractShortPathName(const FileName: string): string;', @ExtractShortPathName);
RegisterHeader(H, 'function FileSetAttr(const FileName: string; Attr: Integer): Integer;', @FileSetAttr);
RegisterHeader(H, 'procedure DateTimeToSystemTime(DateTime: TDateTime; var SystemTime: TSystemTime);', @DateTimeToSystemTime);
RegisterHeader(H, 'function SystemTimeToDateTime(const SystemTime: TSystemTime): TDateTime;', @SystemTimeToDateTime);
{$ENDIF}
// Exception -------------------------------------------------------------------
G := RegisterClassType(H, Exception);
RegisterClassReferenceType(H, 'ExceptClass', G);
RegisterHeader(G, 'constructor Create(const Msg: string);', @Exception.Create);
RegisterHeader(G, 'function _GetMessage: String;', @Exception_GetMessage);
RegisterHeader(G, 'procedure _SetMessage(const Value: String);', @Exception_SetMessage);
RegisterProperty(G, 'property Message: string read _GetMessage write _SetMessage;');
RegisterHeader(G, 'function _GetHelpContext: Integer;', @Exception_GetHelpContext);
RegisterHeader(G, 'procedure _SetHelpContext(Value: Integer);', @Exception_SetHelpContext);
RegisterProperty(G, 'property HelpContext: Integer read _GetHelpContext write _SetHelpContext;');
// EAbort ----------------------------------------------------------------------
G := RegisterClassType(H, EAbort);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EAbort.Create);
// EOutOfMemory ----------------------------------------------------------------
G := RegisterClassType(H, EOutOfMemory);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EOutOfMemory.Create);
// EInOutError -----------------------------------------------------------------
G := RegisterClassType(H, EInOutError);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EInOutError.Create);
RegisterClassTypeField(G, 'ErrorCode', _typeINTEGER, Integer(@EInOutError(nil).ErrorCode));
// EExternal -------------------------------------------------------------------
G := RegisterClassType(H, EExternal);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EExternal.Create);
// EExternalException ----------------------------------------------------------
G := RegisterClassType(H, EExternalException);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EExternalException.Create);
// EIntError -------------------------------------------------------------------
G := RegisterClassType(H, EIntError);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EIntError.Create);
// EDivByZero ------------------------------------------------------------------
G := RegisterClassType(H, EDivByZero);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EDivByZero.Create);
// ERangeError -----------------------------------------------------------------
G := RegisterClassType(H, ERangeError);
RegisterHeader(G, 'constructor Create(const Msg: string);', @ERangeError.Create);
// EIntOverflow ----------------------------------------------------------------
G := RegisterClassType(H, EIntOverflow);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EIntOverflow.Create);
// EMathError ------------------------------------------------------------------
G := RegisterClassType(H, EMathError);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EMathError.Create);
// EInvalidOp ------------------------------------------------------------------
G := RegisterClassType(H, EInvalidOp);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EInvalidOp.Create);
// EZeroDivide -----------------------------------------------------------------
G := RegisterClassType(H, EZeroDivide);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EZeroDivide.Create);
// EOverflow -------------------------------------------------------------------
G := RegisterClassType(H, EOverflow);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EOverflow.Create);
// EUnderflow ------------------------------------------------------------------
G := RegisterClassType(H, EUnderflow);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EUnderflow.Create);
// EInvalidPointer -------------------------------------------------------------
G := RegisterClassType(H, EInvalidPointer);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EInvalidPointer.Create);
// EInvalidCast ----------------------------------------------------------------
G := RegisterClassType(H, EInvalidCast);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EInvalidCast.Create);
// EConvertError ---------------------------------------------------------------
G := RegisterClassType(H, EConvertError);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EConvertError.Create);
// EAccessViolation ---------------------------------------------------------------
G := RegisterClassType(H, EAccessViolation);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EAccessViolation.Create);
// EPrivilege ------------------------------------------------------------------
G := RegisterClassType(H, EPrivilege);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EPrivilege.Create);
// EStackOverflow ------------------------------------------------------------------
G := RegisterClassType(H, EStackOverflow);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EStackOverflow.Create);
// EControlC -------------------------------------------------------------------
G := RegisterClassType(H, EControlC);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EControlC.Create);
// EVariantError ---------------------------------------------------------------
G := RegisterClassType(H, EVariantError);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EVariantError.Create);
// EPropReadOnly ---------------------------------------------------------------
G := RegisterClassType(H, EPropReadOnly);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EPropReadOnly.Create);
// EPropWriteOnly --------------------------------------------------------------
G := RegisterClassType(H, EPropWriteOnly);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EPropWriteOnly.Create);
// EAssertionFailed ------------------------------------------------------------
G := RegisterClassType(H, EAssertionFailed);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EAssertionFailed.Create);
// EAbstractError --------------------------------------------------------------
G := RegisterClassType(H, EAbstractError);
RegisterHeader(G, 'constructor Create(const Msg: string);', @EAbstractError.Create);
end;
end.

View File

@ -0,0 +1,116 @@
{$I PaxCompiler.def}
unit IMPORT_Variants;
interface
uses
{$IFDEF VARIANTS}
Variants,
{$ENDIF}
SysUtils,
PaxRegister,
PaxCompiler;
procedure Register_Variants;
implementation
procedure _VarArrayRedim(var A: Variant; HighBound: Integer);
begin
VarArrayRedim(A, HighBound);
end;
procedure _VarCast(var Dest: Variant; const Source: Variant; VarType: Integer);
begin
VarCast(Dest, Source, VarType);
end;
procedure _VarClear(var V : Variant);
begin
VarClear(V);
end;
procedure _VarCopy(var Dest: Variant; const Source: Variant);
begin
VarCopy(Dest, Source);
end;
procedure Register_Variants;
var
H: Integer;
begin
H := RegisterNamespace(0, 'Variants');
RegisterConstant(0, 'varEmpty', _typeWORD, varEmpty);
RegisterConstant(0, 'varNull', _typeWORD, varNull);
RegisterConstant(0, 'varSmallint', _typeWORD, varSmallInt);
RegisterConstant(0, 'varInteger', _typeWORD, varInteger);
RegisterConstant(0, 'varSingle', _typeWORD, varSingle);
RegisterConstant(0, 'varDouble', _typeWORD, varDouble);
RegisterConstant(0, 'varCurrency', _typeWORD, varCurrency);
RegisterConstant(0, 'varDate', _typeWORD, varDate);
RegisterConstant(0, 'varOleStr', _typeWORD, varOleStr);
RegisterConstant(0, 'varDispatch', _typeWORD, varDispatch);
RegisterConstant(0, 'varError', _typeWORD, varError);
RegisterConstant(0, 'varBoolean', _typeWORD, varBoolean);
RegisterConstant(0, 'varVariant', _typeWORD, varVariant);
RegisterConstant(0, 'varUnknown', _typeWORD, varUnknown);
{$IFDEF VARIANTS}
RegisterConstant(0, 'varShortInt', _typeWORD, varShortInt);
{$ENDIF}
RegisterConstant(0, 'varByte', _typeWORD, varByte);
{$IFDEF VARIANTS}
RegisterConstant(0, 'varWord', _typeWORD, varWord);
RegisterConstant(0, 'varLongWord', _typeWORD, varLongWord);
RegisterConstant(0, 'varInt64', _typeWORD, varInt64);
{$ENDIF}
RegisterConstant(0, 'varStrArg', _typeWORD, varStrArg);
RegisterConstant(0, 'varString', _typeWORD, varString);
RegisterConstant(0, 'varAny', _typeWORD, varAny);
RegisterHeader(H, 'function VarArrayCreate(const Bounds: array of Integer; VarType: Integer): Variant;',
@VarArrayCreate);
RegisterHeader(H, 'function VarArrayDimCount(const A: Variant): Integer;',
@VarArrayDimCount);
RegisterHeader(H, 'function VarArrayHighBound(const A: Variant; Dim: Integer): Integer;',
@VarArrayHighBound);
RegisterHeader(H, 'function VarArrayLock(var A: Variant): Pointer;',
@VarArrayLock);
RegisterHeader(H, 'function VarArrayLowBound(const A: Variant; Dim: Integer): Integer;',
@VarArrayLowBound);
RegisterHeader(H, 'function VarArrayOf(const Values: array of Variant): Variant;',
@VarArrayOf);
RegisterHeader(H, 'procedure VarArrayRedim(var A: Variant; HighBound: Integer);',
@_VarArrayRedim);
RegisterHeader(H, 'function VarArrayRef(const A: Variant): Variant;',
@VarArrayRef);
RegisterHeader(H, 'procedure VarArrayUnlock(var A: Variant);',
@VarArrayUnlock);
RegisterHeader(H, 'function VarAsType(const V: Variant; VarType: Integer): Variant;',
@VarAsType);
RegisterHeader(H, 'procedure VarCast(var Dest: Variant; const Source: Variant; VarType: Integer);',
@_VarCast);
RegisterHeader(H, 'procedure VarClear(var V : Variant);',
@_VarClear);
RegisterHeader(H, 'procedure VarCopy(var Dest: Variant; const Source: Variant);',
@_VarCopy);
RegisterHeader(H, 'function VarFromDateTime(DateTime: TDateTime): Variant;',
@VarFromDateTime);
RegisterHeader(H, 'function VarIsArray(const V: Variant): Boolean;',
@VarIsArray);
RegisterHeader(H, 'function VarIsEmpty(const V: Variant): Boolean;',
@VarIsEmpty);
RegisterHeader(H, 'function VarIsNull(const V: Variant): Boolean;',
@VarIsNull);
RegisterHeader(H, 'function VarToDateTime(const V: Variant): TDateTime;',
@VarToDateTime);
RegisterHeader(H, 'function VarToStr(const V: Variant): string;',
@VarToStr);
RegisterHeader(H, 'function VarType(const V: Variant): Integer;', @VarType);
RegisterVariable(0, 'EmptyParam', _typeOLEVARIANT, @ EmptyParam);
end;
initialization
Register_Variants;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,43 @@
object Form1: TForm1
Left = 277
Top = 120
Caption = 'Access to script-defined variables'
ClientHeight = 164
ClientWidth = 290
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 39
Top = 98
Width = 93
Height = 31
Caption = 'Run'
TabOrder = 0
OnClick = Button1Click
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 48
Top = 24
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 152
Top = 80
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 160
Top = 16
end
end

View File

@ -0,0 +1,58 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxCompiler, PaxInterpreter, PaxBasicLanguage, PaxRunner;
type
TForm1 = class(TForm)
PaxCompiler1: TPaxCompiler;
Button1: TButton;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
P: Pointer;
I: Integer;
begin
{$O-}
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.RegisterHeader(0, 'procedure ShowMessage(const Msg: string);', @ShowMessage);
PaxCompiler1.RegisterHeader(0, 'function IntToStr(Value: Integer): string;', @IntToStr);
PaxCompiler1.AddModule('1', PaxBasicLanguage1.LanguageName);
PaxCompiler1.AddCode('1', 'Dim X As Integer');
PaxCompiler1.AddCode('1', 'ShowMessage("script:" + IntToStr(x))');
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
P := PaxInterpreter1.GetAddress('x');
Integer(P^) := 5; // change script-defind variable
PaxInterpreter1.Run; // the first run
ShowMessage('host:' + IntToStr(Integer(P^))); // show script-defined var
Integer(P^) := 30; // change script-defind variable
PaxInterpreter1.Run; // the second run
end
else
for I:=0 to PaxCompiler1.ErrorCount do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,61 @@
object Form1: TForm1
Left = 338
Top = 183
Width = 397
Height = 222
Caption = 'Bind DFM file'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 8
Top = 24
Width = 75
Height = 25
Caption = 'Run Script'
TabOrder = 0
OnClick = Button1Click
end
object Memo1: TMemo
Left = 120
Top = 24
Width = 233
Height = 137
Lines.Strings = (
'Imports Unit2'
''
'Form2 = New TForm2(null)'
'Try'
' Form2.ShowModal'
'Finally'
' Form2.Free'
'End Try'
'')
TabOrder = 1
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 24
Top = 72
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 16
Top = 128
end
object PaxInterpreter1: TPaxInterpreter
Console = False
OnCreateObject = PaxInterpreter1CreateObject
Left = 64
Top = 120
end
end

View File

@ -0,0 +1,65 @@
{$O-}
unit Unit1;
interface
uses
TypInfo,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PaxInterpreter, PaxCompiler, StdCtrls, PaxBasicLanguage, PaxRunner;
type
TForm1 = class(TForm)
Button1: TButton;
PaxCompiler1: TPaxCompiler;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure PaxInterpreter1CreateObject(Sender: TPaxRunner;
Instance: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
IMPORT_Common;
procedure TForm1.Button1Click(Sender: TObject);
begin
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', 'Basic');
PaxCompiler1.AddCode('1', Memo1.Lines.Text);
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxInterpreter1.Run;
end
else
ShowMessage(PaxCompiler1.ErrorMessage[0]);
end;
procedure TForm1.PaxInterpreter1CreateObject(Sender: TPaxRunner;
Instance: TObject);
var
pti: PTypeInfo;
ptd: PTypeData;
begin
if Instance is TForm then
begin
pti := Instance.ClassInfo;
ptd := GetTypeData(pti);
Sender.LoadDFMFile(Instance, ptd^.UnitName + '.dfm');
end;
end;
end.

View File

@ -0,0 +1,27 @@
Module Unit2
Imports SysUtils, Variants, Classes, Controls, Forms, Dialogs, StdCtrls
Class TForm2
Inherits TForm
Published Button1 As TButton
Published Sub Button1Click(Sender As TObject)
ShowMessage("Hello")
End Sub
Published Sub FormCreate(Sender As TObject)
ShowMessage("Created")
End Sub
End Class
Dim Form2 As TForm2
End Module

View File

@ -0,0 +1,26 @@
object Form2: TForm2
Left = 30
Top = 30
Caption = 'Form2'
ClientHeight = 216
ClientWidth = 426
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 50
Top = 88
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
end

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,146 @@
object Form1: TForm1
Left = 192
Top = 114
Width = 544
Height = 416
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 24
Top = 8
Width = 52
Height = 24
Caption = 'Script:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object Label2: TLabel
Left = 24
Top = 232
Width = 61
Height = 24
Caption = 'Output:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object Label3: TLabel
Left = 288
Top = 48
Width = 182
Height = 24
Caption = 'Add breakpoint at line'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object Memo1: TMemo
Left = 32
Top = 64
Width = 185
Height = 177
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = []
Lines.Strings = (
' print("A") // line 0'
' print("B") // line 1'
' print("C") // line 2'
' print("D") // line 3'
' print("E") // line 4'
'')
ParentFont = False
TabOrder = 0
end
object Memo2: TMemo
Left = 16
Top = 262
Width = 185
Height = 169
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = []
Lines.Strings = (
'')
ParentFont = False
TabOrder = 1
end
object Edit1: TEdit
Left = 480
Top = 48
Width = 41
Height = 33
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 2
Text = '2'
end
object Button1: TButton
Left = 304
Top = 192
Width = 153
Height = 49
Caption = 'Run script'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 3
OnClick = Button1Click
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 312
Top = 304
end
object PaxCompilerDebugger1: TPaxCompilerDebugger
Left = 432
Top = 304
end
object PaxCompilerExplorer1: TPaxCompilerExplorer
Left = 472
Top = 304
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 344
Top = 368
end
object PaxInterpreter1: TPaxInterpreter
Console = False
OnPrintEvent = PaxInterpreter1PrintEvent
Left = 312
Top = 232
end
end

View File

@ -0,0 +1,83 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxInterpreter, PaxCompiler, PaxCompilerDebugger,
PaxRegister,
PaxCompilerExplorer, PaxBasicLanguage, PaxRunner;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Button1: TButton;
PaxCompiler1: TPaxCompiler;
PaxCompilerDebugger1: TPaxCompilerDebugger;
PaxCompilerExplorer1: TPaxCompilerExplorer;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
procedure PaxInterpreter1PrintEvent(Sender: TPaxRunner; const Text: string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
Breakpoint: Integer;
begin
Memo2.Lines.Clear;
Breakpoint := StrToInt(Edit1.Text);
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', PaxBasicLanguage1.LanguageName);
PaxCompiler1.AddCode('1', Memo1.Lines.Text);
PaxCompiler1.DebugMode := true;
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxCompilerExplorer1.RegisterCompiler(PaxCompiler1);
PaxCompilerDebugger1.RegisterCompiler(PaxCompiler1, PaxInterpreter1);
if PaxCompilerExplorer1.IsExecutableLine('1', Breakpoint) then
PaxCompilerDebugger1.AddBreakpoint('1', Breakpoint);
PaxCompilerDebugger1.Run;
while PaxCompilerDebugger1.IsPaused do
begin
ShowMessage('Program has been paused at breakpoint: ' +
IntToStr(PaxCompilerDebugger1.SourceLineNumber));
PaxInterpreter1.Run;
end;
end
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
procedure TForm1.PaxInterpreter1PrintEvent(Sender: TPaxRunner;
const Text: string);
begin
Form1.Memo2.Lines.Add(Text);
end;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,48 @@
object Form1: TForm1
Left = 192
Top = 114
Caption = 'Call routine demo'
ClientHeight = 116
ClientWidth = 220
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 49
Top = 89
Width = 149
Height = 30
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Call '
TabOrder = 0
OnClick = Button1Click
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 32
Top = 16
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 160
Top = 48
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 88
Top = 8
end
end

View File

@ -0,0 +1,67 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxCompiler, PaxInterpreter, PaxRegister, PaxBasicLanguage,
PaxRunner;
type
TForm1 = class(TForm)
PaxCompiler1: TPaxCompiler;
Button1: TButton;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
Y: Integer;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
H_Y: Integer;
I: Integer;
begin
{$O-}
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
H_Y := PaxCompiler1.RegisterVariable(0, 'Y', _typeINTEGER, @Y);
PaxCompiler1.AddModule('1', PaxBasicLanguage1.LanguageName);
PaxCompiler1.AddCode('1', 'Sub P(X As Integer)');
PaxCompiler1.AddCode('1', ' Y = Y + X');
PaxCompiler1.AddCode('1', 'End Sub');
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxInterpreter1.RunInitialization;
PaxInterpreter1.CallRoutine('P', [10]); // call it
ShowMessage(IntToStr(Y));
PaxInterpreter1.CallRoutine('P', [20]); // call it
ShowMessage(IntToStr(Y));
end
else
for I:=0 to PaxCompiler1.ErrorCount do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Y := 0;
end;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form3};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm3, Form3);
Application.Run;
end.

View File

@ -0,0 +1,54 @@
object Form3: TForm3
Left = 0
Top = 0
Width = 701
Height = 194
Caption = 'Code completion demo'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -10
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 12
object Button1: TButton
Left = 18
Top = 12
Width = 56
Height = 19
Caption = 'Create'
TabOrder = 0
OnClick = Button1Click
end
object Memo1: TMemo
Left = 156
Top = 6
Width = 463
Height = 143
TabOrder = 1
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 24
Top = 56
end
object PaxCompilerExplorer1: TPaxCompilerExplorer
Left = 64
Top = 88
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 104
Top = 64
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 80
Top = 152
end
end

View File

@ -0,0 +1,57 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PaxCompiler, StdCtrls, PaxCompilerExplorer, PaxInterpreter,
PaxBasicLanguage, PaxRunner;
type
TForm3 = class(TForm)
Button1: TButton;
PaxCompiler1: TPaxCompiler;
PaxCompilerExplorer1: TPaxCompilerExplorer;
Memo1: TMemo;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var
L: TStringList;
begin
L := TStringList.Create;
try
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', 'Basic');
PaxCompiler1.AddCodeFromFile('1', 'script1.txt');
if PaxCompiler1.CodeCompletion('1', 3, 5, Memo1.Lines, PaxBasicLanguage1) then
// PaxCompiler1.AddCodeFromFile('1', 'script2.txt');
// if PaxCompiler1.CodeCompletion('1', 1, 3, Memo1.Lines, PaxBasicLanguage1) then
begin
//ok
end
else
ShowMessage(PaxCompiler1.ErrorMessage[0]);
finally
L.Free;
end;
end;
end.

View File

@ -0,0 +1,6 @@
' x = 3, y = 5
Class SomeClass
Public Z As TObject
End Class
Dim X As SomeClass = New SomeClass
X.Z.

View File

@ -0,0 +1,4 @@
' x = 1, y = 3
Sub P(X As Integer, Y As Integer)
End Sub
P(

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,97 @@
object Form1: TForm1
Left = 192
Top = 114
Caption = 'Code explorer demo'
ClientHeight = 446
ClientWidth = 688
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 405
Width = 688
Height = 41
Align = alBottom
TabOrder = 0
object Button1: TButton
Left = 24
Top = 8
Width = 105
Height = 25
Caption = 'Compile'
TabOrder = 0
OnClick = Button1Click
end
end
object Memo1: TMemo
Left = 0
Top = 0
Width = 345
Height = 405
Align = alLeft
Lines.Strings = (
'Imports Classes'
''
'Structure MyPoint'
' X As Double'
' Y As Double'
'End Structure'
''
'Class SomeClass'
' Public P As Integer'
' Public Q As Integer'
''
' Function MyClassFunc(X As Integer, Y As Integer) As Integer'
' End Function'
''
' Property MyProp As Integer'
' Get'
' return P'
' End Get'
' End Property'
'End Class'
''
'Dim L As Double'
'Const W = "abc"'
''
'Enum MyEnum'
' one'
' two'
' three'
'End Enum'
''
'')
TabOrder = 1
end
object TreeView1: TTreeView
Left = 345
Top = 0
Width = 343
Height = 405
Align = alClient
Indent = 19
TabOrder = 2
OnDblClick = TreeView1DblClick
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 224
Top = 413
end
object PaxCompilerExplorer1: TPaxCompilerExplorer
Left = 304
Top = 413
end
object PaxBasicLanguage1: TPaxBasicLanguage
Left = 384
Top = 16
end
end

View File

@ -0,0 +1,247 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PaxCompilerExplorer, PaxCompiler, StdCtrls, ExtCtrls, ComCtrls,
IMPORT_Classes, PaxBasicLanguage;
type
TForm1 = class(TForm)
Panel1: TPanel;
Memo1: TMemo;
Button1: TButton;
PaxCompiler1: TPaxCompiler;
PaxCompilerExplorer1: TPaxCompilerExplorer;
TreeView1: TTreeView;
PaxBasicLanguage1: TPaxBasicLanguage;
procedure Button1Click(Sender: TObject);
procedure TreeView1DblClick(Sender: TObject);
private
{ Private declarations }
L: TList;
public
{ Public declarations }
procedure BuildTree;
procedure EnumProc(Id: Integer;
Host: Boolean;
Kind: TPaxMemberKind;
Data: Pointer);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', 'Basic');
PaxCompiler1.AddCode('1', Memo1.Lines.Text);
if PaxCompiler1.Compile then
begin
PaxCompilerExplorer1.RegisterCompiler(PaxCompiler1);
BuildTree;
end
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
procedure TForm1.BuildTree;
var
N, N2: TTreeNode;
I: Integer;
begin
L := TList.Create;
try
TreeView1.Items.Clear;
N := TreeView1.Items.Add(nil, 'Used namespaces');
L.Add(N);
PaxCompilerExplorer1.EnumMembers(0, true, pmkNamespace, EnumProc, N);
PaxCompilerExplorer1.EnumMembers(0, false, pmkNamespace, EnumProc, N);
N := TreeView1.Items.Add(nil, 'Noname namespace');
N2 := TreeView1.Items.AddChild(N, 'Types');
L.Add(N2);
PaxCompilerExplorer1.EnumMembers(0, false, pmkType, EnumProc, N2);
N2 := TreeView1.Items.AddChild(N, 'Procedures');
L.Add(N2);
PaxCompilerExplorer1.EnumMembers(0, false, pmkProcedure, EnumProc, N2);
N2 := TreeView1.Items.AddChild(N, 'Functions');
L.Add(N2);
PaxCompilerExplorer1.EnumMembers(0, false, pmkFunction, EnumProc, N2);
N2 := TreeView1.Items.AddChild(N, 'Constants');
L.Add(N2);
PaxCompilerExplorer1.EnumMembers(0, false, pmkConst, EnumProc, N2);
N2 := TreeView1.Items.AddChild(N, 'Variables');
L.Add(N2);
PaxCompilerExplorer1.EnumMembers(0, false, pmkVar, EnumProc, N2);
finally
for I := L.Count - 1 downto 0 do
begin
N2 := TTreeNode(L[I]);
if N2.Count = 0 then
N2.Delete;
end;
L.Free;
end;
end;
procedure TForm1.EnumProc(Id: Integer;
Host: Boolean;
Kind: TPaxMemberKind;
Data: Pointer);
var
N, N2, N3: TTreeNode;
Name: String;
TypeName: String;
begin
N := TTreeNode(Data);
Name := PaxCompilerExplorer1.Names[Id];
TypeName := PaxCompilerExplorer1.TypeNames[Id];
with TreeView1.Items do
case Kind of
pmkProcedure, pmkFunction, pmkConstructor, pmkDestructor:
begin
N2 := AddChildObject(N, Name, TObject(Id));
N3 := AddChild(N2, 'Parameters');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkParam, EnumProc, N3);
N3 := AddChild(N2, 'Local variables');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkVar, EnumProc, N3);
N3 := AddChild(N2, 'Local constants');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkConst, EnumProc, N3);
N3 := AddChild(N2, 'Local types');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkType, EnumProc, N3);
N3 := TreeView1.Items.AddChild(N2, 'Nested procedures');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, false, pmkProcedure, EnumProc, N3);
N3 := TreeView1.Items.AddChild(N2, 'Nested functions');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, false, pmkFunction, EnumProc, N3);
end;
pmkParam: AddChildObject(N, Name + ' As ' + TypeName, TObject(Id));
pmkVar: AddChildObject(N, Name + ' As ' + TypeName, TObject(Id));
pmkConst: AddChildObject(N, Name + ' As ' + TypeName, TObject(Id));
pmkField: AddChildObject(N, Name + ' As ' + TypeName, TObject(Id));
pmkProperty: AddChildObject(N, Name + ' As ' + TypeName, TObject(Id));
pmkType:
begin
N2 := AddChildObject(N, Name, TObject(Id));
if PaxCompilerExplorer1.IsRecordType(Id) then
begin
N3 := AddChild(N2, 'Fields');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkField, EnumProc, N3);
end
else if PaxCompilerExplorer1.IsClassType(Id) then
begin
N3 := AddChild(N2, 'Fields');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkField, EnumProc, N3);
N3 := AddChild(N2, 'Properties');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkProperty, EnumProc, N3);
N3 := TreeView1.Items.AddChild(N2, 'Constructors');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, false, pmkConstructor, EnumProc, N3);
N3 := TreeView1.Items.AddChild(N2, 'Destructor');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, false, pmkDestructor, EnumProc, N3);
N3 := TreeView1.Items.AddChild(N2, 'Class procedures');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, false, pmkProcedure, EnumProc, N3);
N3 := TreeView1.Items.AddChild(N2, 'Class functions');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, false, pmkFunction, EnumProc, N3);
end;
end;
pmkNamespace:
begin
N2 := AddChildObject(N, Name, TObject(Id));
N3 := AddChild(N2, 'Constants');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkConst, EnumProc, N3);
N3 := AddChild(N2, 'Variables');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkVar, EnumProc, N3);
N3 := AddChild(N2, 'Procedures');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkProcedure, EnumProc, N3);
N3 := AddChild(N2, 'Types');
L.Add(N3);
PaxCompilerExplorer1.EnumMembers(Id, Host, pmkType, EnumProc, N3);
end;
end;
end;
procedure TForm1.TreeView1DblClick(Sender: TObject);
var
N: TTreeNode;
Id, Position: Integer;
S: String;
begin
N := TTreeView(Sender).Selected;
if N = nil then
Exit;
Id := Integer(N.Data);
if Id = 0 then
Exit;
S := PaxCompilerExplorer1.Names[Id];
Position := PaxCompilerExplorer1.Positions[Id];
if Id <> 0 then
with Memo1 do
begin
SetFocus;
SelStart := Position;
SelLength := Length(S);
end;
end;
initialization
Register_Classes;
end.

View File

@ -0,0 +1,15 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.Run;
end.

View File

@ -0,0 +1,185 @@
object Form1: TForm1
Left = 209
Top = 111
Width = 618
Height = 619
Caption = 'DebugDemo'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCloseQuery = FormCloseQuery
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 24
Top = 8
Width = 52
Height = 24
Caption = 'Script:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object Label2: TLabel
Left = 24
Top = 320
Width = 54
Height = 24
Caption = 'Trace:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object Memo1: TMemo
Left = 16
Top = 40
Width = 362
Height = 273
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
Lines.Strings = (
'Function Fact(N As Integer) As Integer'
' If N = 1 Then'
' Return 1'
' Else'
' Return N * Fact(N - 1)'
' End If'
'End Function'
'Dim SS As Integer'
'SS = Fact(3)'
'print SS'
'')
ParentFont = False
TabOrder = 0
end
object Memo2: TMemo
Left = 16
Top = 352
Width = 417
Height = 217
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
Lines.Strings = (
'')
ParentFont = False
TabOrder = 1
end
object Button1: TButton
Left = 392
Top = 25
Width = 193
Height = 49
Caption = 'Compile'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 2
OnClick = Button1Click
end
object Button2: TButton
Left = 392
Top = 89
Width = 193
Height = 49
Caption = 'Run'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 3
OnClick = Button2Click
end
object Button3: TButton
Left = 392
Top = 155
Width = 193
Height = 49
Caption = 'Trace Into'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 4
OnClick = Button3Click
end
object Button4: TButton
Left = 392
Top = 220
Width = 193
Height = 50
Caption = 'Step Over'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 5
OnClick = Button4Click
end
object Button5: TButton
Left = 392
Top = 275
Width = 193
Height = 48
Caption = 'Run to Cursor'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 6
OnClick = Button5Click
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 184
Top = 320
end
object PaxCompilerDebugger1: TPaxCompilerDebugger
Left = 312
Top = 320
end
object PaxCompilerExplorer1: TPaxCompilerExplorer
Left = 352
Top = 320
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 224
Top = 320
end
object PaxInterpreter1: TPaxInterpreter
Console = False
OnPauseUpdated = PaxInterpreter1PauseUpdated
Left = 304
Top = 240
end
end

View File

@ -0,0 +1,350 @@
{$O-}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxInterpreter, PaxCompiler, PaxCompilerDebugger,
PaxRegister,
PaxCompilerExplorer, PaxBasicLanguage, PaxRunner;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
PaxCompiler1: TPaxCompiler;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
PaxCompilerDebugger1: TPaxCompilerDebugger;
PaxCompilerExplorer1: TPaxCompilerExplorer;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure PaxInterpreter1PrintEvent(Sender: TPaxInterpreter; const Text: string);
procedure PaxInterpreter1PauseUpdated(Sender: TPaxRunner;
const ModuleName: string; SourceLineNumber: Integer);
private
{ Private declarations }
ResumeRequest: Boolean;
CloseRequest: Boolean;
procedure UpdateDebugInfo;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', PaxBasicLanguage1.LanguageName);
PaxCompiler1.AddCode('1', Memo1.Lines.Text);
PaxCompiler1.DebugMode := true;
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
ShowMessage('Script has been successfully recompiled.');
PaxCompilerExplorer1.RegisterCompiler(PaxCompiler1);
PaxCompilerDebugger1.RegisterCompiler(PaxCompiler1, PaxInterpreter1);
end
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if not PaxCompilerDebugger1.Valid then
begin
ShowMessage('You have to compile script. Press "Compile" button.');
Exit;
end;
PaxCompilerDebugger1.RunMode := _rmRUN;
if PaxCompilerDebugger1.IsPaused then
ResumeRequest := true
else
PaxCompilerDebugger1.Run;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if not PaxCompilerDebugger1.Valid then
begin
ShowMessage('You have to compile script. Press "Compile" button.');
Exit;
end;
PaxCompilerDebugger1.RunMode := _rmTRACE_INTO;
if PaxCompilerDebugger1.IsPaused then
ResumeRequest := true
else
PaxCompilerDebugger1.Run;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if not PaxCompilerDebugger1.Valid then
begin
ShowMessage('You have to compile script. Press "Compile" button.');
Exit;
end;
PaxCompilerDebugger1.RunMode := _rmSTEP_OVER;
if PaxCompilerDebugger1.IsPaused then
ResumeRequest := true
else
PaxCompilerDebugger1.Run;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if not PaxCompilerDebugger1.Valid then
begin
ShowMessage('You have to compile script. Press "Compile" button.');
Exit;
end;
Form2.ShowModal;
PaxCompilerDebugger1.RunMode := _rmRUN_TO_CURSOR;
if PaxCompilerDebugger1.IsPaused then
ResumeRequest := true
else
PaxCompilerDebugger1.Run;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := true;
CloseRequest := true;
end;
procedure TForm1.PaxInterpreter1PauseUpdated(Sender: TPaxRunner;
const ModuleName: string; SourceLineNumber: Integer);
begin
UpdateDebugInfo;
ResumeRequest := false;
repeat
Application.ProcessMessages;
if ResumeRequest then
Break;
if CloseRequest then
Abort;
until false;
end;
procedure TForm1.PaxInterpreter1PrintEvent(Sender: TPaxInterpreter; const Text: string);
begin
ShowMessage(Text);
end;
procedure TForm1.UpdateDebugInfo;
procedure AddFields(StackFrameNumber, Id: Integer);
var
I, K: Integer;
OwnerName, S: String;
begin
K := PaxCompilerExplorer1.GetFieldCount(Id);
if K = 0 then
Exit;
OwnerName := PaxCompilerExplorer1.Names[Id];
if PaxCompilerDebugger1.GetValueAsString(Id) = 'nil' then
Exit;
for I:=0 to K - 1 do
begin
S := OwnerName + '.' + PaxCompilerExplorer1.GetFieldName(Id, I);
S := ' ' + S + '=' + PaxCompilerDebugger1.GetFieldValueAsString(
StackFrameNumber, Id, I);
Memo2.Lines.Add(S);
end;
end;
procedure AddPublishedProps(StackFrameNumber, Id: Integer);
var
I, K: Integer;
OwnerName, S: String;
begin
K := PaxCompilerExplorer1.GetPublishedPropCount(Id);
if K = 0 then
Exit;
OwnerName := PaxCompilerExplorer1.Names[Id];
if PaxCompilerDebugger1.GetValueAsString(Id) = 'nil' then
Exit;
for I:=0 to K - 1 do
begin
S := OwnerName + '.' + PaxCompilerExplorer1.GetPublishedPropName(Id, I);
S := ' ' + S + '=' + PaxCompilerDebugger1.GetPublishedPropValueAsString(
StackFrameNumber, Id, I);
Memo2.Lines.Add(S);
end;
end;
procedure AddArrayElements(StackFrameNumber, Id: Integer);
var
I, K1, K2: Integer;
OwnerName, S: String;
begin
if not PaxCompilerExplorer1.HasArrayType(Id) then
Exit;
K1 := PaxCompilerExplorer1.GetArrayLowBound(Id);
K2 := PaxCompilerExplorer1.GetArrayHighBound(Id);
OwnerName := PaxCompilerExplorer1.Names[Id];
for I:=K1 to K2 do
begin
S := OwnerName + '[' + IntToStr(I) + ']';
S := ' ' + S + '=' + PaxCompilerDebugger1.GetArrayItemValueAsString(
StackFrameNumber, Id, I);
Memo2.Lines.Add(S);
end;
end;
procedure AddDynArrayElements(StackFrameNumber, Id: Integer);
var
I, L: Integer;
OwnerName, S: String;
begin
if not PaxCompilerExplorer1.HasDynArrayType(Id) then
Exit;
L := PaxCompilerDebugger1.GetDynArrayLength(StackFrameNumber, Id);
OwnerName := PaxCompilerExplorer1.Names[Id];
for I:=0 to L - 1 do
begin
S := OwnerName + '[' + IntToStr(I) + ']';
S := ' ' + S + '=' + PaxCompilerDebugger1.GetDynArrayItemValueAsString(
StackFrameNumber, Id, I);
Memo2.Lines.Add(S);
end;
end;
var
SourceLineNumber: Integer;
ModuleName: String;
StackFrameNumber, J, K, SubId, Id: Integer;
S, V: String;
CallStackLineNumber: Integer;
CallStackModuleName: String;
begin
Memo2.Lines.Clear;
if PaxCompilerDebugger1.IsPaused then
begin
ModuleName := PaxCompilerDebugger1.ModuleName;
SourceLineNumber := PaxCompilerDebugger1.SourceLineNumber;
if SourceLineNumber >= PaxCompiler1.Modules[ModuleName].Count then
Exit;
Memo2.Lines.Add('Paused at line ' + IntTosTr(SourceLineNumber));
Memo2.Lines.Add(PaxCompiler1.Modules[ModuleName][SourceLineNumber]);
Memo2.Lines.Add('------------------------------------------------------');
if PaxCompilerDebugger1.CallStackCount > 0 then
begin
Memo2.Lines.Add('Call stack:');
for StackFrameNumber:=0 to PaxCompilerDebugger1.CallStackCount - 1 do
begin
SubId := PaxCompilerDebugger1.CallStack[StackFrameNumber];
S := '(';
K := PaxCompilerExplorer1.GetParamCount(SubId);
for J:=0 to K - 1 do
begin
Id := PaxCompilerExplorer1.GetParamId(SubId, J);
V := PaxCompilerDebugger1.GetValueAsString(StackFrameNumber, Id);
S := S + V;
if J < K - 1 then
S := S + ',';
end;
S := PaxCompilerExplorer1.Names[SubId] + S + ')';
CallStackLineNumber := PaxCompilerDebugger1.CallStackLineNumber[StackFrameNumber];
CallStackModuleName := PaxCompilerDebugger1.CallStackModuleName[StackFrameNumber];
S := S + '; // ' + PaxCompiler1.Modules[CallStackModuleName][CallStackLineNumber];
Memo2.Lines.Add(S);
end;
Memo2.Lines.Add('------------------------------------------------------');
Memo2.Lines.Add('Local scope:');
StackFrameNumber := PaxCompilerDebugger1.CallStackCount - 1;
SubId := PaxCompilerDebugger1.CallStack[StackFrameNumber];
K := PaxCompilerExplorer1.GetLocalCount(SubId);
for J:=0 to K - 1 do
begin
Id := PaxCompilerExplorer1.GetLocalId(SubId, J);
V := PaxCompilerDebugger1.GetValueAsString(StackFrameNumber, Id);
S := PaxCompilerExplorer1.Names[Id] + '=' + V;
Memo2.Lines.Add(S);
if Pos('X', S) > 0 then
begin
PaxCompilerDebugger1.PutValue(StackFrameNumber, Id, 258);
V := PaxCompilerDebugger1.GetValueAsString(StackFrameNumber, Id);
S := PaxCompilerExplorer1.Names[Id] + '=' + V;
S := S + ' // modified';
Memo2.Lines.Add(S);
end;
AddFields(StackFrameNumber, Id);
AddPublishedProps(StackFrameNumber, Id);
AddArrayElements(StackFrameNumber, Id);
AddDynArrayElements(StackFrameNumber, Id);
end;
Memo2.Lines.Add('------------------------------------------------------');
end;
Memo2.Lines.Add('Global scope:');
K := PaxCompilerExplorer1.GetGlobalCount(0);
for J:=0 to K - 1 do
begin
Id := PaxCompilerExplorer1.GetGlobalId(0, J);
V := PaxCompilerDebugger1.GetValueAsString(Id);
S := PaxCompilerExplorer1.Names[Id] + '=' + V;
Memo2.Lines.Add(S);
AddFields(0, Id);
AddPublishedProps(0, Id);
AddArrayElements(0, Id);
AddDynArrayElements(0, Id);
end;
Memo2.Lines.Add('------------------------------------------------------');
end
else
Memo2.Lines.Add('Finished');
Memo2.SelStart := 0;
Memo2.SelLength := 0;
end;
end.

View File

@ -0,0 +1,43 @@
object Form2: TForm2
Left = 551
Top = 252
Width = 384
Height = 345
Caption = 'Select line'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 270
Width = 376
Height = 41
Align = alBottom
TabOrder = 0
object Button1: TButton
Left = 8
Top = 8
Width = 75
Height = 25
Caption = 'Ok'
ModalResult = 1
TabOrder = 0
OnClick = Button1Click
end
end
object ListBox1: TListBox
Left = 0
Top = 0
Width = 376
Height = 270
Align = alClient
ItemHeight = 13
TabOrder = 1
end
end

View File

@ -0,0 +1,65 @@
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm2 = class(TForm)
Panel1: TPanel;
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function ShowModal: Integer; override;
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
function TForm2.ShowModal: Integer;
var
I: Integer;
S: String;
ch: Char;
begin
ListBox1.Items.Clear;
for I:=0 to Form1.Memo1.Lines.Count - 1 do
begin
if Form1.PaxCompilerExplorer1.IsExecutableLine('1', I) then
ch := '*'
else
ch := ' ';
S := Format('%3d ', [I]) + ch + ' ' + Form1.Memo1.Lines[I];
ListBox1.Items.Add(S);
end;
result := inherited ShowModal;
end;
procedure TForm2.Button1Click(Sender: TObject);
var
I: Integer;
begin
I := ListBox1.ItemIndex;
if Form1.PaxCompilerExplorer1.IsExecutableLine('1', I) then
Form1.PaxCompilerDebugger1.AddTempBreakpoint('1', I)
else
begin
ShowMessage(IntToStr(I) + ' is not executable line!');
ModalResult := mrCancel;
end;
end;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,43 @@
object Form1: TForm1
Left = 192
Top = 115
Caption = 'Eval Expression'
ClientHeight = 142
ClientWidth = 326
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 30
Top = 30
Width = 247
Height = 30
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Create compiled expression'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 30
Top = 79
Width = 247
Height = 31
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Evaluate expression'
TabOrder = 1
OnClick = Button2Click
end
end

View File

@ -0,0 +1,116 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxCompiler, PaxInterpreter, PaxRegister, PaxBasicLanguage;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
arr_x, arr_y: array[1..3] of Double;
h_norm, h_x, h_y: Integer;
buff: array[1..40960] of Byte;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function Norm(x, y: Double): Double;
begin
result := Sqrt(x * x + y * y);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
PaxCompiler1: TPaxCompiler;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
I: Integer;
begin
PaxCompiler1 := TPaxCompiler.Create(nil);
PaxBasicLanguage1 := TPaxBasicLanguage.Create(nil);
PaxInterpreter1 := TPaxInterpreter.Create(nil);
try
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
h_norm := PaxCompiler1.RegisterHeader(0, 'function Norm(x, y: Double): Double;');
h_x := PaxCompiler1.RegisterVariable(0, 'x', _typeDOUBLE);
h_y := PaxCompiler1.RegisterVariable(0, 'y', _typeDOUBLE);
if PaxCompiler1.CompileExpression('Norm(x, y)', PaxInterpreter1, 'Basic') then
begin
PaxInterpreter1.SaveToBuff(buff);
ShowMessage('Compiled expression has been created!');
end
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
finally
PaxCompiler1.Free;
PaxBasicLanguage1.Free;
PaxInterpreter1.Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
PaxInterpreter1: TPaxInterpreter;
ResValue: Double;
I: Integer;
begin
{$O-}
if h_x <> 0 then
begin
PaxInterpreter1 := TPaxInterpreter.Create(nil);
try
PaxInterpreter1.LoadFromBuff(buff);
PaxInterpreter1.SetAddress(h_norm, @norm);
for I:=1 to 3 do
begin
PaxInterpreter1.SetAddress(h_x, @arr_x[I]);
PaxInterpreter1.SetAddress(h_y, @arr_y[I]);
PaxInterpreter1.Run;
ResValue := Double(PaxInterpreter1.ResultPtr^);
ShowMessage(FloatToStr(ResValue));
end;
finally
PaxInterpreter1.Free;
end;
end
else
ShowMessage('Press the first button to create compiled script.');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
h_x := 0; h_y := 0; h_norm := 0;
arr_x[1] := 4.2; arr_y[1] := -5.2;
arr_x[2] := -0.4; arr_y[2] := 3.2;
arr_x[3] := 2.0; arr_y[3] := 3;
end;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,107 @@
object Form1: TForm1
Left = 19
Top = 116
Width = 918
Height = 523
Caption = 'Script-defined event handler demo'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 16
Top = 8
Width = 273
Height = 25
Caption = 'Create event handler for Button2.OnClick event'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 782
Top = 432
Width = 75
Height = 25
Caption = 'Button2'
TabOrder = 1
end
object Memo1: TMemo
Left = 16
Top = 40
Width = 601
Height = 433
Font.Charset = RUSSIAN_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Times New Roman'
Font.Style = []
Lines.Strings = (
'Class MyHandler'
' Sub Handle(Sender As TObject)'
' ShowMessage("Sender: " + Sender.ClassName)'
' End Sub'
' Sub Dispose(Sender As TObject)'
' Free'
' End Sub'
'End Class'
''
'Dim X As MyHandler = New MyHandler'
'Button2.OnClick = X.Handle'
'Form1.OnDestroy = X.Dispose'
'')
ParentFont = False
TabOrder = 2
end
object Button3: TButton
Left = 696
Top = 24
Width = 161
Height = 25
Caption = 'Remove event handler'
TabOrder = 3
OnClick = Button3Click
end
object Memo2: TMemo
Left = 696
Top = 72
Width = 161
Height = 73
Font.Charset = RUSSIAN_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Times New Roman'
Font.Style = []
Lines.Strings = (
'Button2.OnClick = null')
ParentFont = False
TabOrder = 4
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 760
Top = 248
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 760
Top = 312
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 536
Top = 304
end
object PaxInterpreter2: TPaxInterpreter
Console = False
Left = 576
Top = 304
end
end

View File

@ -0,0 +1,92 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PaxInterpreter, PaxCompiler, StdCtrls, PaxRegister, PaxBasicLanguage,
PaxRunner;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
PaxCompiler1: TPaxCompiler;
Button3: TButton;
Memo2: TMemo;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
PaxInterpreter2: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
H_TButton, H_TForm1: Integer;
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
if Assigned(Button2.OnClick) then
begin
ShowMessage('The event handler has been already created.');
Exit;
end;
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', 'Basic');
PaxCompiler1.AddCode('1', Memo1.Lines.Text);
PaxCompiler1.RegisterVariable(0, 'Button2', H_TButton, @Button2);
PaxCompiler1.RegisterVariable(0, 'Form1', H_TForm1, @Form1);
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxInterpreter1.Run;
ShowMessage('The event handler has been created. Click Button2.');
end
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
I: Integer;
begin
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', 'Basic');
PaxCompiler1.AddCode('1', Memo2.Lines.Text);
PaxCompiler1.RegisterVariable(0, 'Button2', H_TButton, @Button2);
if PaxCompiler1.Compile(PaxInterpreter2) then
begin
PaxInterpreter2.Run;
ShowMessage('The event handler has been removed.');
end
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
initialization
H_TButton := RegisterClassType(0, TButton);
H_TForm1 := RegisterClassType(0, TForm1);
RegisterHeader(0, 'procedure ShowMessage(const Msg: string);', @ShowMessage);
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,115 @@
object Form1: TForm1
Left = 192
Top = 114
Width = 889
Height = 607
Caption = 'Event handler demo'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 16
Top = 16
Width = 209
Height = 25
Caption = '1. Compile script'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 16
Top = 56
Width = 209
Height = 25
Caption = '2. Set up script-defined event handler'
TabOrder = 1
OnClick = Button2Click
end
object Button3: TButton
Left = 16
Top = 96
Width = 209
Height = 25
Caption = '3. Restore host-defined event handler'
TabOrder = 2
OnClick = Button3Click
end
object Memo1: TMemo
Left = 240
Top = 8
Width = 608
Height = 545
Font.Charset = RUSSIAN_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Times New Roman'
Font.Style = []
Lines.Strings = (
'Class MyHandler'
' Sub Handle(Sender As TObject)'
' ShowMessage("Script-defined handler. Sender: " + Sender.Clas' +
'sName)'
' End Sub'
' Sub Dispose(Sender As TObject)'
' Free'
' End Sub'
'End Class'
''
'Dim X As MyHandler'
'Dim E As TNotifyEvent'
''
'Sub SetHandler'
' E = ClickMe.OnClick'
' ClickMe.OnClick = X.Handle'
'End Sub'
''
'Sub RestoreHandler'
' ClickMe.OnClick = E'
'End Sub'
''
'X = New MyHandler'
'ClickMe.OnClick(X)'
'Form1.OnDestroy = X.Dispose'
'ShowMessage("The script was compiled and initialized successfull' +
'y.")'
''
'')
ParentFont = False
TabOrder = 3
end
object ClickMe: TButton
Left = 24
Top = 440
Width = 201
Height = 105
Caption = 'ClickMe'
TabOrder = 4
OnClick = ClickMeClick
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 632
Top = 64
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 648
Top = 304
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 512
Top = 248
end
end

View File

@ -0,0 +1,100 @@
{$O-}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxInterpreter, PaxCompiler, PaxRegister, PaxBasicLanguage,
PaxRunner;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Memo1: TMemo;
ClickMe: TButton;
PaxCompiler1: TPaxCompiler;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
procedure ClickMeClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
P_SetHandler: Pointer;
P_RestoreHandler: Pointer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
H_TButton, H_TForm1: Integer;
type
TProcP = procedure;
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
if PaxInterpreter1.DataSize > 0 then
begin
ShowMessage('Script is already compiled.');
Exit;
end;
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', 'Basic');
PaxCompiler1.AddCode('1', Memo1.Lines.Text);
PaxCompiler1.RegisterVariable(0, 'ClickMe', H_TButton, @ClickMe);
PaxCompiler1.RegisterVariable(0, 'Form1', H_TForm1, @Form1);
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
P_SetHandler := PaxInterpreter1.GetAddress('SetHandler');
P_RestoreHandler := PaxInterpreter1.GetAddress('RestoreHandler');
PaxInterpreter1.Run;
end
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
TProcP(P_SetHandler);
ShowMessage('ClickMe contains script-defined event handler now.');
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
TProcP(P_RestoreHandler);
ShowMessage('Host-defined handler is restored.');
end;
procedure TForm1.ClickMeClick(Sender: TObject);
begin
ShowMessage('Host-defined event handler. Sender: ' + Sender.ClassName);
end;
initialization
H_TButton := RegisterClassType(0, TButton);
H_TForm1 := RegisterClassType(0, TForm1);
RegisterHeader(0, 'procedure ShowMessage(const Msg: string);', @ShowMessage);
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,84 @@
object Form1: TForm1
Left = 192
Top = 114
Width = 721
Height = 602
Caption = 'Run-time error handling'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 24
Top = 16
Width = 161
Height = 25
Caption = 'Compile and Run'
TabOrder = 0
OnClick = Button1Click
end
object Memo1: TMemo
Left = 200
Top = 16
Width = 481
Height = 441
Lines.Strings = (
'Imports SysUtils'
''
'Sub ErrorProc'
'Dim I As Integer'
' I = 0'
' I = I \ I'
'End Sub'
''
'Sub TestFinally'
' Dim S As String = "abc"'
' Dim I As Integer'
' Try'
' ErrorProc'
' Finally'
' println S'
' End Try'
' Println "not executed"'
'End Sub'
''
'Try'
' TestFinally'
'Catch'
' println "ok"'
'End Try')
TabOrder = 1
end
object Memo2: TMemo
Left = 200
Top = 464
Width = 481
Height = 89
TabOrder = 2
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 64
Top = 112
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 112
Top = 240
end
object PaxInterpreter1: TPaxInterpreter
Console = False
OnException = PaxInterpreter1Exception
OnPrintEvent = PaxInterpreter1PrintEvent
Left = 136
Top = 168
end
end

View File

@ -0,0 +1,71 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PaxInterpreter, PaxCompiler, StdCtrls, PAXCOMP_STDLIB, PaxBasicLanguage,
PaxRunner;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
PaxCompiler1: TPaxCompiler;
Memo2: TMemo;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
procedure PaxInterpreter1PrintEvent(Sender: TPaxRunner; const Text: string);
procedure PaxInterpreter1Exception(Sender: TPaxRunner; E: Exception;
const ModuleName: string; SourceLineNumber: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
IMPORT_SysUtils;
procedure TForm1.Button1Click(Sender: TObject);
begin
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('main', 'Basic');
PaxCompiler1.AddCode('main', Memo1.Lines.Text);
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxInterpreter1.Run;
end
else
ShowMessage(PaxCompiler1.ErrorMessage[0]);
end;
procedure TForm1.PaxInterpreter1Exception(Sender: TPaxRunner; E: Exception;
const ModuleName: string; SourceLineNumber: Integer);
begin
Form1.Memo2.Text := Form1.Memo2.Text + #13#10 +
'Exception (' + E.Message +
') raised at line ' + IntToStr(SourceLineNumber) + ':' +
PaxCompiler1.Modules[ModuleName][SourceLineNumber] + #13#10;
end;
procedure TForm1.PaxInterpreter1PrintEvent(Sender: TPaxRunner;
const Text: string);
begin
Form1.Memo2.Text := Form1.Memo2.Text + Text;
end;
initialization
Register_SysUtils;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,47 @@
object Form1: TForm1
Left = 192
Top = 114
Caption = 'HelloApp'
ClientHeight = 164
ClientWidth = 290
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 39
Top = 98
Width = 93
Height = 31
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Say "Hello"'
TabOrder = 0
OnClick = Button1Click
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 48
Top = 24
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 152
Top = 72
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 184
Top = 24
end
end

View File

@ -0,0 +1,48 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxCompiler, PaxInterpreter, PaxBasicLanguage, PaxRunner;
type
TForm1 = class(TForm)
PaxCompiler1: TPaxCompiler;
Button1: TButton;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
I, H_TButton: Integer;
begin
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
H_TButton := PaxCompiler1.RegisterClassType(0, TButton);
PaxCompiler1.RegisterVariable(0, 'Button1', H_TButton, @Button1);
PaxCompiler1.AddModule('1', PaxBasicLanguage1.LanguageName);
PaxCompiler1.AddCode('1', 'Button1.Caption = "Hello"');
if PaxCompiler1.Compile(PaxInterpreter1) then
PaxInterpreter1.Run
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,84 @@
object Form1: TForm1
Left = 233
Top = 111
Width = 646
Height = 628
Caption = 'Inerit host class'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 40
Top = 32
Width = 113
Height = 25
Caption = 'Run script'
TabOrder = 0
OnClick = Button1Click
end
object Memo1: TMemo
Left = 192
Top = 8
Width = 401
Height = 569
Font.Charset = RUSSIAN_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Times New Roman'
Font.Style = []
Lines.Strings = (
'Imports Classes'
'Class MyForm'
' Inherits TForm'
' Private Button1 As TButton'
' Sub New(AOwner As TComponent)'
' MyBase.CreateNew(AOwner)'
' Top = 100'
' Left = 200'
' Caption = "Script-defined form MyForm"'
' Button1 = New TButton(Me)'
' Button1.Parent = Me'
' Button1.Top = 50'
' Button1.Left = 50'
' Button1.Caption = "Click me"'
' Button1.OnClick = Button1Click'
' End Sub'
''
' Sub Button1Click(Sender As TObject)'
' ShowMessage("Hello!")'
' ShowMessage("Sender: " + Sender.ClassName)'
' End Sub'
'End Class'
''
'Dim F As MyForm = New MyForm(null)'
'F.ShowModal'
'F.Free'
'')
ParentFont = False
TabOrder = 1
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 40
Top = 80
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 80
Top = 232
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 184
Top = 320
end
end

View File

@ -0,0 +1,101 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PaxInterpreter, PaxCompiler, StdCtrls, PaxRegister, PaxBasicLanguage,
PaxRunner;
type
TForm1 = class(TForm)
Button1: TButton;
PaxCompiler1: TPaxCompiler;
Memo1: TMemo;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
procedure PaxInterpreter1UnhandledException(Sender: TPaxInterpreter;
E: Exception; const ModuleName: String; SourceLineNumber: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
IMPORT_Classes;
var
H_TForm: Integer;
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', 'Basic');
PaxCompiler1.AddCode('1', Memo1.Lines.Text);
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxInterpreter1.Run;
end
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
procedure TForm1.PaxInterpreter1UnhandledException(Sender: TPaxInterpreter;
E: Exception; const ModuleName: String; SourceLineNumber: Integer);
begin
ShowMessage(
'Exception (' + E.Message +
') raised at line ' + IntToStr(SourceLineNumber) + ':' +
PaxCompiler1.Modules[ModuleName][SourceLineNumber]
);
end;
function TControl_GetParent(Self: TControl): TWinControl;
begin
result := Self.Parent;
end;
procedure TControl_SetParent(Self: TControl; Value: TWinControl);
begin
Self.Parent := Value;
end;
var
H: Integer;
initialization
Register_Classes;
H := RegisterClassType(0, TControl);
RegisterClassType(0, TWinControl);
RegisterHeader(H, 'function _GetParent: TWinControl;', @TControl_GetParent);
RegisterHeader(H, 'procedure _SetParent(Value: TWinControl);', @TControl_SetParent);
RegisterProperty(H, 'property Parent: TWinControl read _GetParent write _SetParent;');
H_TForm := RegisterClassType(0, TForm);
RegisterHeader(H_TForm, 'constructor CreateNew(AOwner: TComponent; Dummy: Integer = 0); override;',
@ TForm.CreateNew);
RegisterHeader(H_TForm, 'function ShowModal: Integer;', @TForm.ShowModal);
H := RegisterClassType(0, TButton);
RegisterHeader(H, 'constructor Create(AOwner: TComponent); override;',
@TButton.Create);
RegisterHeader(0, 'procedure ShowMessage(const Msg: string);', @ShowMessage);
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,43 @@
object Form1: TForm1
Left = 192
Top = 114
Caption = 'Load compiled script demo'
ClientHeight = 207
ClientWidth = 341
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 49
Top = 49
Width = 238
Height = 31
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Compile script. Save compile script.'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 49
Top = 118
Width = 238
Height = 31
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Load compiled script. Run script.'
TabOrder = 1
OnClick = Button2Click
end
end

View File

@ -0,0 +1,96 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxCompiler, PaxInterpreter, PaxRegister, PaxBasicLanguage;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
H_ShowMessage: Integer;
H_S: Integer;
S: AnsiString;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
PaxCompiler1: TPaxCompiler;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
begin
PaxCompiler1 := TPaxCompiler.Create(nil);
PaxBasicLanguage1 := TPaxBasicLanguage.Create(nil);
PaxInterpreter1 := TPaxInterpreter.Create(nil);
try
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
// register routine 'ShowMessage'
H_ShowMessage := PaxCompiler1.RegisterHeader(0, 'procedure ShowMessage(const Msg: string);');
// register variable 'S'
H_S := PaxCompiler1.RegisterVariable(0, 'S', _typeSTRING);
PaxCompiler1.AddModule('1', PaxBasicLanguage1.LanguageName);
PaxCompiler1.AddCode('1', 'ShowMessage(S)');
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxInterpreter1.SaveToFile('1.bin');
ShowMessage('Compiled script has been created!');
end
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
finally
PaxCompiler1.Free;
PaxBasicLanguage1.Free;
PaxInterpreter1.Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
PaxInterpreter1: TPaxInterpreter;
begin
if FileExists('1.bin') and (H_ShowMessage <> 0) and (H_S <> 0) then
begin
PaxInterpreter1 := TPaxInterpreter.Create(nil);
try
PaxInterpreter1.LoadFromFile('1.bin');
PaxInterpreter1.SetAddress(H_ShowMessage, @ShowMessage);
PaxInterpreter1.SetAddress(H_S, @S);
PaxInterpreter1.Run;
finally
PaxInterpreter1.Free;
end;
end
else
ShowMessage('Press the first button to create compiled script.');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
H_ShowMessage := 0;
H_S := 0;
S := 'Hello';
end;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,48 @@
object Form1: TForm1
Left = 192
Top = 114
Caption = 'OnUsedUnit event demo'
ClientHeight = 144
ClientWidth = 385
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 30
Top = 30
Width = 257
Height = 30
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Compile and Run'
TabOrder = 0
OnClick = Button1Click
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
OnUsedUnit = PaxCompiler1UsedUnit
DebugMode = False
Left = 24
Top = 80
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 176
Top = 80
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 264
Top = 80
end
end

View File

@ -0,0 +1,68 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PaxInterpreter, PaxCompiler, PaxRegister, StdCtrls, PaxBasicLanguage,
PaxRunner;
type
TForm1 = class(TForm)
Button1: TButton;
PaxCompiler1: TPaxCompiler;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
function PaxCompiler1UsedUnit(Sender: TPaxCompiler;
const UnitName: String; var SourceCode: String): Boolean;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('main', 'Basic');
PaxCompiler1.AddCode('main', 'Imports SomeUnit');
PaxCompiler1.AddCode('main', 'P()');
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxInterpreter1.Run;
end
else
ShowMessage(PaxCompiler1.ErrorMessage[0]);
end;
function TForm1.PaxCompiler1UsedUnit(Sender: TPaxCompiler;
const UnitName: String; var SourceCode: String): Boolean;
begin
if UnitName = 'SomeUnit' then
begin
result := true;
SourceCode :=
'Module SomeUnit' + #13#10 +
' Public Sub P' + #13#10 +
' ShowMessage("Hello")' + #13#10 +
' End Sub' + #13#10 +
'End Module' + #13#10;
end
else
result := false; // default processing
end;
initialization
RegisterHeader(0, 'procedure ShowMessage(const Msg: string);', @ShowMessage);
end.

View File

@ -0,0 +1,31 @@
Module MyModule
Imports Controls, StdCtrls, Forms, Dialogs
Class MyForm
Inherits TForm
Published Button1 As TButton
Sub Button1Click(Sender As TObject)
ShowMessage("Hello!")
End Sub
Sub New
MyBase.Create(null)
Caption = "My form created in Basic"
Button1 = New TButton(Me)
With Button1
.Parent = Me
.Caption = "Click Me"
.Name = "Button1"
.Left = 10
.Top = 20
.OnClick = Button1Click
End With
End Sub
End Class
End Module

View File

@ -0,0 +1,183 @@
program Project2;
{$APPTYPE CONSOLE}
uses
sysutils,
Classes,
TypInfo,
PAXCOMP_CONSTANTS,
PaxCompiler,
PaxCompilerExplorer,
PaxCompilerDebugger,
PaxBasicLanguage,
PaxInterpreter,
PaxRegister,
IMPORT_Common;
type
TMyHandler = class
private
L: TStringList;
public
constructor Create;
destructor Destroy; override;
procedure SaveToDisk;
function UsedUnitHandler(Sender: TPaxCompiler; const UnitName: String;
var SourceCode: String): Boolean;
function SavePCUCompilerHandler(Sender: TPaxCompiler; const UnitName: String): TStream;
function LoadPCUCompilerHandler(Sender: TPaxCompiler; const UnitName: String): TStream;
function LoadPCUProgramHandler(Sender: TPaxInterpreter; const UnitName: String): TStream;
end;
constructor TMyHandler.Create;
begin
inherited;
L := TStringList.Create;
end;
destructor TMyHandler.Destroy;
var
I: Integer;
begin
for I := 0 to L.Count - 1 do
L.Objects[I].Free;
L.Free;
inherited;
end;
procedure TMyHandler.SaveToDisk;
var
I: Integer;
Stream: TMemoryStream;
S: String;
begin
for I := 0 to L.Count - 1 do
begin
S := L[I];
Stream := TMemoryStream(L.Objects[I]);
Stream.Position := 0;
Stream.SaveToFile(S + '.PCU');
end;
end;
function TMyHandler.UsedUnitHandler(Sender: TPaxCompiler; const UnitName: String;
var SourceCode: String): Boolean;
var
L: TStringList;
begin
if CompareText(UnitName, 'MyModule') = 0 then
begin
L := TStringList.Create;
try
L.LoadFromFile('MyModule.txt'); // just to load it from somewhere
SourceCode := L.Text;
finally
L.Free;
end;
result := true;
end;
end;
function TMyHandler.SavePCUCompilerHandler(Sender: TPaxCompiler; const UnitName: String): TStream;
begin
result := TMemoryStream.Create;
L.AddObject(UnitName, result);
end;
function TMyHandler.LoadPCUCompilerHandler(Sender: TPaxCompiler; const UnitName: String): TStream;
var
I: Integer;
begin
result := nil;
for I := 0 to L.Count - 1 do
if CompareText(L[I], UnitName) = 0 then
begin
result := TStream(L.Objects[I]);
result.Position := 0;
Exit;
end;
end;
function TMyHandler.LoadPCUProgramHandler(Sender: TPaxInterpreter; const UnitName: String): TStream;
var
I: Integer;
begin
result := nil;
for I := 0 to L.Count - 1 do
if CompareText(L[I], UnitName) = 0 then
begin
result := TStream(L.Objects[I]);
result.Position := 0;
Exit;
end;
end;
var
MyHandler: TMyHandler;
var
PaxCompiler1: TPaxCompiler;
PaxInterpreter1: TPaxInterpreter;
PaxBasicLanguage1: TPaxBasicLanguage;
begin
// Build all units, save pcu-files and create compiled script
MyHandler := TMyHandler.Create;
try
PaxCompiler1 := TPaxCompiler.Create(nil);
PaxCompiler1.OnUsedUnit := MyHandler.UsedUnitHandler;
// PaxCompiler1.OnSavePCU := MyHandler.SavePCUCompilerHandler;
// PaxCompiler1.OnLoadPCU := MyHandler.LoadPCUCompilerHandler;
PaxInterpreter1 := TPaxInterpreter.Create(nil);
PaxBasicLanguage1 := TPaxBasicLanguage.Create(nil);
try
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', 'Basic');
PaxCompiler1.AddCodeFromFile('1', 'script.txt');
if PaxCompiler1.Compile(PaxInterpreter1, true, true) then
// build with run-time packages
begin
PaxInterpreter1.SaveToFile('script.bin');
// PaxInterpreter1.Run;
// writeln('Press any key...');
// Readln;
// Exit;
end
else
begin
writeln(PaxCompiler1.ErrorMessage[0]);
writeln(PaxCompiler1.ErrorLine[0]);
writeln('Press any key...');
Readln;
Exit;
end;
finally
PaxCompiler1.Free;
PaxInterpreter1.Free;
PaxBasicLanguage1.Free;
end;
// MyHandler.SaveToDisk;
// Use compiled units (pcu-files) at run-tme as run-time packages
PaxInterpreter1 := TPaxInterpreter.Create(nil);
try
// PaxInterpreter1.OnLoadPCU := MyHandler.LoadPCUProgramHandler;
PaxInterpreter1.LoadFromFile('script.bin');
PaxInterpreter1.Run;
finally
PaxInterpreter1.Free;
end;
finally
MyHandler.Free;
end;
writeln('Press any key...');
Readln;
end.

View File

@ -0,0 +1,9 @@
Imports Forms
Imports MyModule
Dim F As MyForm = New MyForm
Try
F.ShowModal
Finally
F.Free
End Try

View File

@ -0,0 +1,703 @@
unit IMPORT_TypInfo;
interface
procedure Register_TypInfo;
implementation
uses
Variants,
SysUtils,
TypInfo,
PaxRegister;
{
Result := RegisterEnumType (H, 'TTypeKind');
RegisterEnumValue (Result, 'tkUnknown', 0);
RegisterEnumValue (Result, 'tkInteger', 1);
RegisterEnumValue (Result, 'tkChar', 2);
RegisterEnumValue (Result, 'tkEnumeration', 3);
RegisterEnumValue (Result, 'tkFloat', 4);
RegisterEnumValue (Result, 'tkString', 5);
RegisterEnumValue (Result, 'tkSet', 6);
RegisterEnumValue (Result, 'tkClass', 7);
RegisterEnumValue (Result, 'tkMethod', 8);
RegisterEnumValue (Result, 'tkWChar', 9);
RegisterEnumValue (Result, 'tkLString', 10);
RegisterEnumValue (Result, 'tkWString', 11);
RegisterEnumValue (Result, 'tkVariant', 12);
RegisterEnumValue (Result, 'tkArray', 13);
RegisterEnumValue (Result, 'tkRecord', 14);
RegisterEnumValue (Result, 'tkInterface', 15);
RegisterEnumValue (Result, 'tkInt64', 16);
RegisterEnumValue (Result, 'tkDynArray', 17);
end;
//====================================================================
// TPublishableVariantType
//====================================================================
//--------------------------------------------------------------------
// RegisterClass_TPublishableVariantType
//--------------------------------------------------------------------
function RegisterClass_TPublishableVariantType (H: integer): integer;
begin
Result := RegisterClassType (H, TPublishableVariantType);
RegisterHeader (Result,
'function GetProperty (var Dest: TVarData; const V: TVarData; const Name: String): Boolean; override;',
@TPublishableVariantType.GetProperty);
RegisterHeader (Result,
'function SetProperty (const V: TVarData; const Name: String; const Value: TVarData): Boolean; override;',
@TPublishableVariantType.SetProperty);
end;
//--------------------------------------------------------------------
// RegisterSet_TTypeKinds
//--------------------------------------------------------------------
function RegisterSet_TTypeKinds (H: integer): integer;
begin
// Result := RegisterSetType (H, 'TTypeKinds', T);
end;
//--------------------------------------------------------------------
// RegisterEnumerated_TOrdType
//--------------------------------------------------------------------
function RegisterEnumerated_TOrdType (H: integer): integer;
begin
Result := RegisterEnumType (H, 'TOrdType');
RegisterEnumValue (Result, 'otSByte', 0);
RegisterEnumValue (Result, 'otUByte', 1);
RegisterEnumValue (Result, 'otSWord', 2);
RegisterEnumValue (Result, 'otUWord', 3);
RegisterEnumValue (Result, 'otSLong', 4);
RegisterEnumValue (Result, 'otULong', 5);
end;
//--------------------------------------------------------------------
// RegisterEnumerated_TFloatType
//--------------------------------------------------------------------
function RegisterEnumerated_TFloatType (H: integer): integer;
begin
Result := RegisterEnumType (H, 'TFloatType');
RegisterEnumValue (Result, 'ftSingle', 0);
RegisterEnumValue (Result, 'ftDouble', 1);
RegisterEnumValue (Result, 'ftExtended', 2);
RegisterEnumValue (Result, 'ftComp', 3);
RegisterEnumValue (Result, 'ftCurr', 4);
end;
//--------------------------------------------------------------------
// RegisterEnumerated_TMethodKind
//--------------------------------------------------------------------
function RegisterEnumerated_TMethodKind (H: integer): integer;
begin
Result := RegisterEnumType (H, 'TMethodKind');
RegisterEnumValue (Result, 'mkProcedure', 0);
RegisterEnumValue (Result, 'mkFunction', 1);
RegisterEnumValue (Result, 'mkConstructor', 2);
RegisterEnumValue (Result, 'mkDestructor', 3);
RegisterEnumValue (Result, 'mkClassProcedure', 4);
RegisterEnumValue (Result, 'mkClassFunction', 5);
RegisterEnumValue (Result, 'mkSafeProcedure', 6);
RegisterEnumValue (Result, 'mkSafeFunction', 7);
end;
//--------------------------------------------------------------------
// RegisterEnumerated_TParamFlag
//--------------------------------------------------------------------
function RegisterEnumerated_TParamFlag (H: integer): integer;
begin
Result := RegisterEnumType (H, 'TParamFlag');
RegisterEnumValue (Result, 'pfVar', 0);
RegisterEnumValue (Result, 'pfConst', 1);
RegisterEnumValue (Result, 'pfArray', 2);
RegisterEnumValue (Result, 'pfAddress', 3);
RegisterEnumValue (Result, 'pfReference', 4);
RegisterEnumValue (Result, 'pfOut', 5);
Result := RegisterSetType (H, 'TParamFlags', T);
end;
function RegisterSet_TParamFlagsBase (H: integer): integer;
var
T: integer;
begin
T := LookupTypeID ('TParamFlag');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: TParamFlag');
Result := RegisterSetType (H, 'TParamFlagsBase', T);
end;
//--------------------------------------------------------------------
// RegisterEnumerated_TIntfFlag
//--------------------------------------------------------------------
function RegisterEnumerated_TIntfFlag (H: integer): integer;
begin
Result := RegisterEnumType (H, 'TIntfFlag');
RegisterEnumValue (Result, 'ifHasGuid', 0);
RegisterEnumValue (Result, 'ifDispInterface', 1);
RegisterEnumValue (Result, 'ifDispatch', 2);
end;
//--------------------------------------------------------------------
// RegisterSet_TIntfFlags
//--------------------------------------------------------------------
function RegisterSet_TIntfFlags (H: integer): integer;
var
T: integer;
begin
T := LookupTypeID ('TIntfFlag');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: TIntfFlag');
Result := RegisterSetType (H, 'TIntfFlags', T);
end;
//--------------------------------------------------------------------
// RegisterSet_TIntfFlagsBase
//--------------------------------------------------------------------
function RegisterSet_TIntfFlagsBase (H: integer): integer;
var
T: integer;
begin
T := LookupTypeID ('TIntfFlag');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: TIntfFlag');
Result := RegisterSetType (H, 'TIntfFlagsBase', T);
end;
//--------------------------------------------------------------------
// RegisterPointer_PPTypeInfo
//--------------------------------------------------------------------
function RegisterPointer_PPTypeInfo (H: integer): integer;
var
T: Integer;
begin
T := LookupTypeID ('PTypeInfo');
if T = 0 then
T := RegisterSomeType (H, 'PTypeInfo');
Result := RegisterPointerType (H, 'PPTypeInfo', T);
end;
//--------------------------------------------------------------------
// RegisterPointer_PTypeInfo
//--------------------------------------------------------------------
function RegisterPointer_PTypeInfo (H: integer): integer;
var
T: Integer;
begin
T := LookupTypeID ('TTypeInfo');
if T = 0 then
T := RegisterSomeType (H, 'TTypeInfo');
Result := RegisterPointerType (H, 'PTypeInfo', T);
end;
//--------------------------------------------------------------------
// RegisterRecord_TTypeInfo
//--------------------------------------------------------------------
function RegisterRecord_TTypeInfo (H: integer): integer;
var
T: integer;
begin
Result := RegisterRecordType (H, 'TTypeInfo', False);
T := LookupTypeID ('TTypeKind');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: TTypeKind');
RegisterRecordTypeField (Result, 'Kind', T, 0);
T := _typeSHORTSTRING;
RegisterRecordTypeField (Result, 'Name', T, 0);
end;
//--------------------------------------------------------------------
// RegisterPointer_PTypeData
//--------------------------------------------------------------------
function RegisterPointer_PTypeData (H: integer): integer;
var
T: Integer;
begin
T := LookupTypeID ('TTypeData');
if T = 0 then
T := RegisterSomeType (H, 'TTypeData');
Result := RegisterPointerType (H, 'PTypeData', T);
end;
//--------------------------------------------------------------------
// RegisterArray_fake_ParamList_18
//--------------------------------------------------------------------
function RegisterArray_fake_ParamList_18 (H: integer): integer;
var
R,T: integer;
begin
R := RegisterTypeDeclaration (H, 'fake_ParamList_18_19 = 0..1023;');
T := _typeCHAR;
Result := RegisterArrayType (H, 'fake_ParamList_18', R, T, False);
end;
//--------------------------------------------------------------------
// RegisterRecord_TTypeData
//--------------------------------------------------------------------
function RegisterRecord_TTypeData (H: integer): integer;
var
T: integer;
begin
Result := RegisterRecordType (H, 'TTypeData', False);
T := LookupTypeID ('TOrdType');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: TOrdType');
RegisterVariantRecordTypeField (Result, 'OrdType', T, 02);
T := _typeINTEGER;
RegisterVariantRecordTypeField (Result, 'MinValue', T, 0102);
T := _typeINTEGER;
RegisterVariantRecordTypeField (Result, 'MaxValue', T, 0102);
T := LookupTypeID ('PPTypeInfo');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: PPTypeInfo');
RegisterVariantRecordTypeField (Result, 'BaseType', T, 020102);
T := LookupTypeID ('ShortStringBase');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: ShortStringBase');
RegisterVariantRecordTypeField (Result, 'NameList', T, 020102);
T := LookupTypeID ('ShortStringBase');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: ShortStringBase');
RegisterVariantRecordTypeField (Result, 'EnumUnitName', T, 020102);
T := LookupTypeID ('PPTypeInfo');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: PPTypeInfo');
RegisterVariantRecordTypeField (Result, 'CompType', T, 0202);
T := LookupTypeID ('TFloatType');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: TFloatType');
RegisterVariantRecordTypeField (Result, 'FloatType', T, 03);
T := _typeBYTE;
RegisterVariantRecordTypeField (Result, 'MaxLength', T, 04);
T := LookupTypeID ('TClass');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: TClass');
RegisterVariantRecordTypeField (Result, 'ClassType', T, 05);
T := LookupTypeID ('PPTypeInfo');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: PPTypeInfo');
RegisterVariantRecordTypeField (Result, 'ParentInfo', T, 05);
T := _typeSMALLINT;
RegisterVariantRecordTypeField (Result, 'PropCount', T, 05);
T := LookupTypeID ('ShortStringBase');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: ShortStringBase');
RegisterVariantRecordTypeField (Result, 'UnitName', T, 05);
T := LookupTypeID ('TMethodKind');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: TMethodKind');
RegisterVariantRecordTypeField (Result, 'MethodKind', T, 06);
T := _typeBYTE;
RegisterVariantRecordTypeField (Result, 'ParamCount', T, 06);
T := RegisterArray_fake_ParamList_18 (H);
RegisterVariantRecordTypeField (Result, 'ParamList', T, 06);
T := LookupTypeID ('PPTypeInfo');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: PPTypeInfo');
RegisterVariantRecordTypeField (Result, 'IntfParent', T, 07);
T := LookupTypeID ('TIntfFlagsBase');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: TIntfFlagsBase');
RegisterVariantRecordTypeField (Result, 'IntfFlags', T, 07);
T := LookupTypeID ('TGUID');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: TGUID');
RegisterVariantRecordTypeField (Result, 'Guid', T, 07);
T := LookupTypeID ('ShortStringBase');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: ShortStringBase');
RegisterVariantRecordTypeField (Result, 'IntfUnit', T, 07);
T := _typeINT64;
RegisterVariantRecordTypeField (Result, 'MinInt64Value', T, 08);
RegisterVariantRecordTypeField (Result, 'MaxInt64Value', T, 08);
T := _typeINTEGER;
RegisterVariantRecordTypeField (Result, 'elSize', T, 09);
T := LookupTypeID ('PPTypeInfo');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: PPTypeInfo');
RegisterVariantRecordTypeField (Result, 'elType', T, 09);
T := _typeINTEGER;
RegisterVariantRecordTypeField (Result, 'varType', T, 09);
T := LookupTypeID ('PPTypeInfo');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: PPTypeInfo');
RegisterVariantRecordTypeField (Result, 'elType2', T, 09);
T := LookupTypeID ('ShortStringBase');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: ShortStringBase');
RegisterVariantRecordTypeField (Result, 'DynUnitName', T, 09);
end;
//--------------------------------------------------------------------
// RegisterRecord_fake_PropList_31
//--------------------------------------------------------------------
function RegisterRecord_fake_PropList_31 (H: integer): integer;
var
T: integer;
begin
Result := RegisterRecordType (H, 'fake_PropList_31', False);
end;
//--------------------------------------------------------------------
// RegisterRecord_TPropData
//--------------------------------------------------------------------
function RegisterRecord_TPropData (H: integer): integer;
var
T: integer;
begin
Result := RegisterRecordType (H, 'TPropData', False);
T := _typeWORD;
RegisterRecordTypeField (Result, 'PropCount', T, 0);
T := RegisterRecord_fake_PropList_31 (H);
RegisterRecordTypeField (Result, 'PropList', T, 0);
end;
//--------------------------------------------------------------------
// RegisterPointer_PPropInfo
//--------------------------------------------------------------------
function RegisterPointer_PPropInfo (H: integer): integer;
var
T: Integer;
begin
T := LookupTypeID ('TPropInfo');
if T = 0 then
T := RegisterSomeType (H, 'TPropInfo');
Result := RegisterPointerType (H, 'PPropInfo', T);
end;
//--------------------------------------------------------------------
// RegisterRecord_TPropInfo
//--------------------------------------------------------------------
function RegisterRecord_TPropInfo (H: integer): integer;
var
T: integer;
begin
Result := RegisterRecordType (H, 'TPropInfo', False);
T := LookupTypeID ('PPTypeInfo');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: PPTypeInfo');
RegisterRecordTypeField (Result, 'PropType', T, 0);
T := _typePOINTER;
RegisterRecordTypeField (Result, 'GetProc', T, 0);
T := _typePOINTER;
RegisterRecordTypeField (Result, 'SetProc', T, 0);
T := _typePOINTER;
RegisterRecordTypeField (Result, 'StoredProc', T, 0);
T := _typeINTEGER;
RegisterRecordTypeField (Result, 'Index', T, 0);
T := _typeINTEGER;
RegisterRecordTypeField (Result, 'Default', T, 0);
T := _typeSMALLINT;
RegisterRecordTypeField (Result, 'NameIndex', T, 0);
T := _typeSHORTSTRING;
RegisterRecordTypeField (Result, 'Name', T, 0);
end;
//--------------------------------------------------------------------
// RegisterProcedural_TPropInfoProc
//--------------------------------------------------------------------
function RegisterProcedural_TPropInfoProc (H: integer): integer;
begin
Result := RegisterHeader (H, 'procedure fake_TPropInfoProc_40 (PropInfo: PPropInfo);', Nil);
Result := RegisterEventType (H, 'TPropInfoProc', Result);
end;
//--------------------------------------------------------------------
// RegisterPointer_PPropList
//--------------------------------------------------------------------
function RegisterPointer_PPropList (H: integer): integer;
var
T: Integer;
begin
T := LookupTypeID ('TPropList');
if T = 0 then
T := RegisterSomeType (H, 'TPropList');
Result := RegisterPointerType (H, 'PPropList', T);
end;
//--------------------------------------------------------------------
// RegisterArray_TPropList
//--------------------------------------------------------------------
function RegisterArray_TPropList (H: integer): integer;
var
R,T: integer;
begin
R := RegisterTypeDeclaration (H, 'fake_TPropList_41 = 0..16379;');
T := LookupTypeID ('PPropInfo');
if T = 0 then
Raise ENNPaxFormater.Create ('Invalid type name: PPropInfo');
Result := RegisterArrayType (H, 'TPropList', R, T, False);
end;
//====================================================================
// EPropertyError
//====================================================================
//--------------------------------------------------------------------
// RegisterClass_EPropertyError
//--------------------------------------------------------------------
function RegisterClass_EPropertyError (H: integer): integer;
begin
Result := RegisterClassType (H, EPropertyError);
end;
//====================================================================
// EPropertyConvertError
//====================================================================
//--------------------------------------------------------------------
// RegisterClass_EPropertyConvertError
//--------------------------------------------------------------------
function RegisterClass_EPropertyConvertError (H: integer): integer;
begin
Result := RegisterClassType (H, EPropertyConvertError);
end;
//--------------------------------------------------------------------
// RegisterArray_fake_BooleanIdents_42
//--------------------------------------------------------------------
function RegisterArray_fake_BooleanIdents_42 (H: integer): integer;
var
R,T: integer;
begin
R := _typeBOOLEAN;
T := RegisterTypeAlias (H, 'BooleanIdents', _typeSTRING);
Result := RegisterArrayType (H, 'fake_BooleanIdents_42', R, T, False);
end;
//--------------------------------------------------------------------
// DoRegisterVariable_BooleanIdents
//--------------------------------------------------------------------
function DoRegisterVariable_BooleanIdents (H: Integer): integer;
var
T: integer;
begin
T := RegisterArray_fake_BooleanIdents_42 (H);
result := RegisterVariable (H, 'BooleanIdents', T, @BooleanIdents);
end;
//--------------------------------------------------------------------
// RegisterNameSpace_TypInfo
//--------------------------------------------------------------------
procedure RegisterNameSpace_TypInfo;
begin
RegisterNameSpace (0, 'TypInfo');
end;
//--------------------------------------------------------------------
// Register_TypInfo
//--------------------------------------------------------------------
}
procedure Register_TypInfo;
var
H, G, A: integer;
begin
H := RegisterNamespace(0, 'TypInfo');
RegisterRTTIType(H, TypeInfo(TTypeKind));
RegisterRTTIType(H, TypeInfo(TTypeKinds));
RegisterRTTIType(H, TypeInfo(TOrdType));
RegisterRTTIType(H, TypeInfo(TFloatType));
RegisterRTTIType(H, TypeInfo(TMethodKind));
RegisterRTTIType(H, TypeInfo(TParamFlag));
RegisterRTTIType(H, TypeInfo(TParamFlags));
RegisterRTTIType(H, TypeInfo(TParamFlagsBase));
RegisterRTTIType(H, TypeInfo(TIntfFlag));
RegisterRTTIType(H, TypeInfo(TIntfFlags));
RegisterRTTIType(H, TypeInfo(TIntfFlagsBase));
G := RegisterRecordType(H, 'TTypeInfo');
RegisterRecordTypeField(G, 'Kind', RegisterRTTIType(H, TypeInfo(TTypeKind)));
RegisterRecordTypeField(G, 'Name', _typeSHORTSTRING);
G := RegisterPointerType(H, 'PTypeInfo', G);
G := RegisterPointerType(H, 'PPTypeInfo', G);
G := RegisterRecordType(H, 'TPropInfo');
RegisterRecordTypeField(G, 'PropType: PPtypeInfo', 0);
RegisterRecordTypeField(G, 'GetProc', _typePOINTER);
RegisterRecordTypeField(G, 'SetProc', _typePOINTER);
RegisterRecordTypeField(G, 'StoredProc', _typePOINTER);
RegisterRecordTypeField(G, 'Index', _typeINTEGER);
RegisterRecordTypeField(G, 'Default', _typeINTEGER);
RegisterRecordTypeField(G, 'NameIndex', _typeSMALLINT);
RegisterRecordTypeField(G, 'Name', _typeSHORTSTRING);
RegisterPointerType(H, 'PPropInfo', G);
G := RegisterRecordType(H, 'TPropData');
RegisterRecordTypeField(G, 'PropCount: Word;', 0);
A := RegisterArrayType(0, '', RegisterSubrangeType(0, '', _typeINTEGER, 0, 1023), _typeANSICHAR);
G := RegisterRecordType (H, 'TTypeData', False);
RegisterVariantRecordTypeField(G, 'OrdType: TOrdType', 02);
RegisterVariantRecordTypeField(G, 'MinValue', _typeINTEGER, 0102);
RegisterVariantRecordTypeField(G, 'MaxValue', _typeINTEGER, 0102);
RegisterVariantRecordTypeField(G, 'BaseType: PPTypeInfo', 020102);
RegisterVariantRecordTypeField(G, 'NameList: ShortString', 020102);
RegisterVariantRecordTypeField(G, 'EnumUnitName: ShortString', 020102);
RegisterVariantRecordTypeField(G, 'CompType: PPTypeInfo', 0202);
RegisterVariantRecordTypeField(G, 'FloatType: TFloatType', 03);
RegisterVariantRecordTypeField(G, 'MaxLength', _typeBYTE, 04);
RegisterVariantRecordTypeField(G, 'ClassType: TClass', 05);
RegisterVariantRecordTypeField(G, 'ParentInfo: PPTypeInfo', 05);
RegisterVariantRecordTypeField(G, 'PropCount', _typeSMALLINT, 05);
RegisterVariantRecordTypeField(G, 'UnitName', _typeSHORTSTRING, 05);
RegisterVariantRecordTypeField(G, 'MethodKind: TMethodKind', 06);
RegisterVariantRecordTypeField(G, 'ParamCount', _typeBYTE, 06);
RegisterVariantRecordTypeField(G, 'ParamList', A, 06);
RegisterVariantRecordTypeField(G, 'IntfParent: PPTypeInfo', 07);
RegisterVariantRecordTypeField(G, 'IntfFlags: TIntfFlagsBase', 07);
RegisterVariantRecordTypeField(G, 'Guid: TGUID', 07);
RegisterVariantRecordTypeField(G, 'IntfUnit', _typeSHORTSTRING, 07);
RegisterVariantRecordTypeField(G, 'MinInt64Value', _typeINT64, 08);
RegisterVariantRecordTypeField(G, 'MaxInt64Value', _typeINT64, 08);
RegisterVariantRecordTypeField(G, 'elSize', _typeINTEGER, 09);
RegisterVariantRecordTypeField(G, 'elType: PPTypeInfo', 09);
RegisterVariantRecordTypeField(G, 'varType', _typeINTEGER, 09);
RegisterVariantRecordTypeField(G, 'elType2: PPTypeInfo', 09);
RegisterVariantRecordTypeField(G, 'DynUnitName', _typeSHORTSTRING, 09);
RegisterHeader (H, 'function PropType (Instance: TObject; const PropName: String): TTypeKind; overload;', Nil);
RegisterHeader (H, 'function PropType (AClass: TClass; const PropName: String): TTypeKind; overload;', Nil);
RegisterHeader (H, 'function PropIsType (Instance: TObject; const PropName: String; TypeKind: TTypeKind): Boolean; overload;'
, Nil);
RegisterHeader (H, 'function PropIsType (AClass: TClass; const PropName: String; TypeKind: TTypeKind): Boolean; overload;',
Nil);
RegisterHeader (H, 'function IsStoredProp (Instance: TObject; const PropName: String): Boolean; overload;', Nil);
RegisterHeader (H, 'function IsPublishedProp (Instance: TObject; const PropName: String): Boolean; overload;', Nil);
RegisterHeader (H, 'function IsPublishedProp (AClass: TClass; const PropName: String): Boolean; overload;', Nil);
RegisterHeader (H, 'function GetOrdProp (Instance: TObject; const PropName: String): Longint; overload;', Nil);
RegisterHeader (H, 'procedure SetOrdProp (Instance: TObject; const PropName: String; Value: Longint); overload;', Nil);
RegisterHeader (H, 'function GetEnumProp (Instance: TObject; const PropName: String): String; overload;', Nil);
RegisterHeader (H, 'procedure SetEnumProp (Instance: TObject; const PropName: String; const Value: String); overload;', Nil);
RegisterHeader (H, 'function GetSetProp (Instance: TObject; const PropName: String; Brackets: Boolean = False): String; ' +
'overload;', Nil);
RegisterHeader (H, 'procedure SetSetProp (Instance: TObject; const PropName: String; const Value: String); overload;', Nil);
RegisterHeader (H, 'function GetObjectProp (Instance: TObject; const PropName: String; MinClass: TClass = nil): TObject; ' +
'overload;', Nil);
RegisterHeader (H, 'procedure SetObjectProp (Instance: TObject; const PropName: String; Value: TObject); overload;', Nil);
RegisterHeader (H, 'function GetObjectPropClass (Instance: TObject; const PropName: String): TClass; overload;', Nil);
RegisterHeader (H, 'function GetStrProp (Instance: TObject; const PropName: String): String; overload;', Nil);
RegisterHeader (H, 'procedure SetStrProp (Instance: TObject; const PropName: String; const Value: String); overload;', Nil);
RegisterHeader (H, 'function GetWideStrProp (Instance: TObject; const PropName: String): WideString; overload;', Nil);
RegisterHeader (H, 'procedure SetWideStrProp (Instance: TObject; const PropName: String; const Value: WideString); overload;'
, Nil);
RegisterHeader (H, 'function GetFloatProp (Instance: TObject; const PropName: String): Extended; overload;', Nil);
RegisterHeader (H, 'procedure SetFloatProp (Instance: TObject; const PropName: String; const Value: Extended); overload;',
Nil);
RegisterHeader (H, 'function GetVariantProp (Instance: TObject; const PropName: String): Variant; overload;', Nil);
RegisterHeader (H, 'procedure SetVariantProp (Instance: TObject; const PropName: String; const Value: Variant); overload;',
Nil);
RegisterHeader (H, 'function GetMethodProp (Instance: TObject; const PropName: String): TMethod; overload;', Nil);
RegisterHeader (H, 'procedure SetMethodProp (Instance: TObject; const PropName: String; const Value: TMethod); overload;',
Nil);
RegisterHeader (H, 'function GetInt64Prop (Instance: TObject; const PropName: String): Int64; overload;', Nil);
RegisterHeader (H, 'procedure SetInt64Prop (Instance: TObject; const PropName: String; const Value: Int64); overload;', Nil);
RegisterHeader (H, 'function GetInterfaceProp (Instance: TObject; const PropName: String): IInterface; overload;', Nil);
RegisterHeader (H, 'procedure SetInterfaceProp (Instance: TObject; const PropName: String; const Value: IInterface); overload;' +
'', Nil);
RegisterHeader (H, 'function GetPropValue (Instance: TObject; const PropName: String; PreferStrings: Boolean = True): Variant;' +
'', Nil);
RegisterHeader (H, 'procedure SetPropValue (Instance: TObject; const PropName: String; const Value: Variant);', Nil);
RegisterHeader (H, 'procedure FreeAndNilProperties (AObject: TObject);', Nil);
G := RegisterClassType(H, TPublishableVariantType);
RegisterHeader(G,
'function GetProperty (var Dest: TVarData; const V: TVarData; const Name: String): Boolean; override;',
@TPublishableVariantType.GetProperty);
RegisterHeader (G,
'function SetProperty (const V: TVarData; const Name: String; const Value: TVarData): Boolean; override;',
@TPublishableVariantType.SetProperty);
RegisterConstant (H, 'tkAny = [Low(TTypeKind)..High(TTypeKind)];');
RegisterConstant (H, 'tkMethods = [tkMethod];');
RegisterConstant (H, 'tkProperties = tkAny - tkMethods - [tkUnknown];');
RegisterTypeDeclaration (H, 'ShortStringBase = String [255];');
RegisterHeader (H, 'function GetTypeData (TypeInfo: PTypeInfo): PTypeData;', Nil);
RegisterHeader (H, 'function GetEnumName (TypeInfo: PTypeInfo; Value: Integer): String;', Nil);
RegisterHeader (H, 'function GetEnumValue (TypeInfo: PTypeInfo; const Name: String): Integer;', Nil);
RegisterHeader (H, 'function GetPropInfo (Instance: TObject; const PropName: String; AKinds: TTypeKinds = []): PPropInfo; ' +
'overload;', Nil);
RegisterHeader (H, 'function GetPropInfo (AClass: TClass; const PropName: String; AKinds: TTypeKinds = []): PPropInfo; ' +
'overload;', Nil);
RegisterHeader (H, 'function GetPropInfo (TypeInfo: PTypeInfo; const PropName: String): PPropInfo; overload;', Nil);
RegisterHeader (H, 'function GetPropInfo (TypeInfo: PTypeInfo; const PropName: String; AKinds: TTypeKinds): PPropInfo; ' +
'overload;', Nil);
RegisterHeader (H, 'procedure GetPropInfos (TypeInfo: PTypeInfo; PropList: PPropList);', Nil);
RegisterHeader (H, 'function GetPropList (TypeInfo: PTypeInfo; TypeKinds: TTypeKinds; PropList: PPropList; SortList: Boolean ' +
'= True): Integer; overload;', Nil);
RegisterHeader (H, 'function GetPropList (TypeInfo: PTypeInfo; out PropList: PPropList): Integer; overload;', Nil);
RegisterHeader (H, 'function GetPropList (AObject: TObject; out PropList: PPropList): Integer; overload;', Nil);
RegisterHeader (H, 'procedure SortPropList (PropList: PPropList; PropCount: Integer);', Nil);
RegisterHeader (H, 'function IsStoredProp (Instance: TObject; PropInfo: PPropInfo): Boolean; overload;', Nil);
RegisterHeader (H, 'function GetOrdProp (Instance: TObject; PropInfo: PPropInfo): Longint; overload;', Nil);
RegisterHeader (H, 'procedure SetOrdProp (Instance: TObject; PropInfo: PPropInfo; Value: Longint); overload;', Nil);
RegisterHeader (H, 'function GetEnumProp (Instance: TObject; PropInfo: PPropInfo): String; overload;', Nil);
RegisterHeader (H, 'procedure SetEnumProp (Instance: TObject; PropInfo: PPropInfo; const Value: String); overload;', Nil);
RegisterHeader (H, 'function GetSetProp (Instance: TObject; PropInfo: PPropInfo; Brackets: Boolean = False): String; overload;' +
'', Nil);
RegisterHeader (H, 'procedure SetSetProp (Instance: TObject; PropInfo: PPropInfo; const Value: String); overload;', Nil);
RegisterHeader (H, 'function GetObjectProp (Instance: TObject; PropInfo: PPropInfo; MinClass: TClass = nil): TObject; ' +
'overload;', Nil);
RegisterHeader (H, 'procedure SetObjectProp (Instance: TObject; PropInfo: PPropInfo; Value: TObject; ValidateClass: Boolean = ' +
'True); overload;', Nil);
RegisterHeader (H, 'function GetObjectPropClass (Instance: TObject; PropInfo: PPropInfo): TClass; overload;', Nil);
RegisterHeader (H, 'function GetObjectPropClass (PropInfo: PPropInfo): TClass; overload;', Nil);
RegisterHeader (H, 'function GetStrProp (Instance: TObject; PropInfo: PPropInfo): String; overload;', Nil);
RegisterHeader (H, 'procedure SetStrProp (Instance: TObject; PropInfo: PPropInfo; const Value: String); overload;', Nil);
RegisterHeader (H, 'function GetWideStrProp (Instance: TObject; PropInfo: PPropInfo): WideString; overload;', Nil);
RegisterHeader (H, 'procedure SetWideStrProp (Instance: TObject; PropInfo: PPropInfo; const Value: WideString); overload;',
Nil);
RegisterHeader (H, 'function GetFloatProp (Instance: TObject; PropInfo: PPropInfo): Extended; overload;', Nil);
RegisterHeader (H, 'procedure SetFloatProp (Instance: TObject; PropInfo: PPropInfo; const Value: Extended); overload;', Nil);
RegisterHeader (H, 'function GetVariantProp (Instance: TObject; PropInfo: PPropInfo): Variant; overload;', Nil);
RegisterHeader (H, 'procedure SetVariantProp (Instance: TObject; PropInfo: PPropInfo; const Value: Variant); overload;', Nil);
RegisterHeader (H, 'function GetMethodProp (Instance: TObject; PropInfo: PPropInfo): TMethod; overload;', Nil);
RegisterHeader (H, 'procedure SetMethodProp (Instance: TObject; PropInfo: PPropInfo; const Value: TMethod); overload;', Nil);
RegisterHeader (H, 'function GetInt64Prop (Instance: TObject; PropInfo: PPropInfo): Int64; overload;', Nil);
RegisterHeader (H, 'procedure SetInt64Prop (Instance: TObject; PropInfo: PPropInfo; const Value: Int64); overload;', Nil);
RegisterHeader (H, 'function GetInterfaceProp (Instance: TObject; PropInfo: PPropInfo): IInterface; overload;', Nil);
RegisterHeader (H, 'procedure SetInterfaceProp (Instance: TObject; PropInfo: PPropInfo; const Value: IInterface); overload;',
Nil);
RegisterVariable (H, 'DotSep:String;', @DotSep);
RegisterHeader (H, 'function SetToString (PropInfo: PPropInfo; Value: Integer; Brackets: Boolean = False): String;', Nil);
RegisterHeader (H, 'function StringToSet (PropInfo: PPropInfo; const Value: String): Integer;', Nil);
end;
end.

View File

@ -0,0 +1,187 @@
{$APPTYPE CONSOLE}
{$O-}
program Project1;
uses
PAXCOMP_CONSTANTS,
PAXCOMP_SYS,
TypInfo,
Classes,
SysUtils,
IMPORT_Classes,
PaxCompiler,
PaxInterpreter,
PaxRegister,
PaxBasicLanguage,
IMPORT_TypInfo in 'IMPORT_TypInfo.pas';
type
TTestClass = class
procedure DoTest;
procedure OnClickHandler(Sender: TObject);
procedure OnClickHandler2(Sender: TObject);
end;
var
PaxInterpreter1: TPaxInterpreter;
procedure TTestClass.OnClickHandler(Sender: TObject);
begin
writeln('Click');
end;
procedure TTestClass.OnClickHandler2(Sender: TObject);
begin
writeln('Click 2');
end;
procedure TTestClass.DoTest;
var
C: TClass;
P: Pointer;
pti: PTypeInfo;
ptd: PTypeData;
ppi: PPropInfo;
I: Integer;
Z, X: TObject;
S: String;
AMethod: TMethod;
begin
AMethod.Code := @ TTestClass.OnClickHandler;
AMethod.Data := Self;
P := PaxInterpreter1.GetAddress('AMyClass');
C := TClass(P^);
writeln(C.ClassName);
pti := C.ClassInfo;
writeln(pti^.Name);
ptd := GetTypeData(pti);
writeln(ptd^.ClassType.ClassName);
pti := ptd^.ParentInfo^;
writeln(pti^.Name);
writeln(ptd^.PropCount);
writeln(ptd^.UnitName);
ppi := GetPropInfo(C, 'X');
writeln(ppi^.Name);
pti := PaxInterpreter1.GetTypeInfo('IUnknown');
writeln(pti^.Name);
ptd := GetTypeData(pti);
writeln(ptd^.IntfUnit);
pti := PaxInterpreter1.GetTypeInfo('MyEnum');
writeln(pti^.Name);
ptd := GetTypeData(pti);
writeln(ptd^.BaseType^.Name);
// writeln(ptd^.EnumUnitName);
writeln(GetEnumName(pti, 2));
writeln(GetEnumValue(pti, 'three'));
pti := PaxInterpreter1.GetTypeInfo('Integer');
writeln(pti^.Name);
// work with instance
P := PaxInterpreter1.GetAddress('Z');
Z := TObject(P^);
writeln(Z.ClassName);
SetOrdProp(Z, 'X', 5);
I := GetOrdProp(Z, 'X');
writeln(I);
SetStrProp(Z, 'Y', 'abc');
S := GetStrProp(Z, 'Y');
writeln(S);
ppi := GetPropInfo(Z, 'Inter');
writeln(ppi^.Name);
P := Z.MethodAddress('MyProc');
asm
mov eax, z
mov edx, 10
mov ecx, 20
call P;
end;
P := Z.FieldAddress('Field2');
X := TObject(P^);
writeln(X.ClassName);
SetMethodProp(Z, 'OnClick', AMethod);
AMethod := GetMethodProp(Z, 'OnClick');
asm
call AMethod.Code;
end;
// RTTI of inherited class:
P := PaxInterpreter1.GetAddress('AMyClass2');
C := TClass(P^);
writeln(C.ClassName);
pti := C.ClassInfo;
writeln(pti^.Name);
ppi := GetPropInfo(C, 'X');
writeln(ppi^.Name);
// work with instance
P := PaxInterpreter1.GetAddress('W');
Z := TObject(P^);
writeln(Z.ClassName);
SetOrdProp(Z, 'X', 7);
I := GetOrdProp(Z, 'X');
writeln(I);
P := Z.MethodAddress('MyProc');
asm
mov eax, Z
mov edx, 2
mov edx, 3
call P
end;
P := Z.FieldAddress('Field2');
X := TObject(P^);
writeln(X.ClassName);
end;
var
PaxCompiler1: TPaxCompiler;
PaxBasicLanguage1: TPaxBasicLanguage;
H: Integer;
begin
Register_Classes;
Register_TypInfo;
RegisterRTTIType(0, TypeInfo(TNotifyEvent));
H := RegisterClassType(0, TTestClass);
RegisterHeader(H, 'procedure DoTest;',
@TTestClass.DoTest);
RegisterHeader(H, 'procedure OnClickHandler2(Sender: TObject);',
@TTestClass.OnClickHandler2);
PaxCompiler1 := TPaxCompiler.Create(nil);
PaxInterpreter1 := TPaxInterpreter.Create(nil);
PaxBasicLanguage1 := TPaxBasicLanguage.Create(nil);
try
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', 'Basic');
PaxCompiler1.AddCodeFromFile('1', 'script.txt');
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxInterpreter1.Run;
end
else
writeln(PaxCompiler1.ErrorMessage[0]);
finally
PaxCompiler1.Free;
PaxInterpreter1.Free;
PaxBasicLanguage1.Free;
end;
writeln('Press any key...');
Readln;
end.

View File

@ -0,0 +1,135 @@
Imports TypInfo, Classes, PascalNamespace
Enum MyEnum
one
two
three
End Enum
Class AMyClass
Inherits TComponent
Private FX As Integer
Private FY AS String
Private fStrings As TStringList
Private fOnClick As TNotifyEvent
Private fInter As IUnknown
Published Field As TObject
Published Field2 As TStringList
Function GetY As String
Return FY
End Function
Sub SetY(value AS String)
println "value=", value
FY = value
println "FY=", FY
End Sub
Sub New(AOwner As TComponent)
MyBase.Create(null)
Field = New TObject
Field2 = New TStringList
End Sub
Sub Finalize
Field.Free
Field2.Free
MyBase.Destroy
End Sub
Sub ScriptHandler(Sender As TObject)
println "***************", Sender.ClassName
ExitCode = 5
println ExitCode
End Sub
Published Property X As Integer
Get
Return FX
End Get
Set
println "value=", value
FX = value
println "FX=", FX
End Set
End Property
Published Property Y As String
Get
Return FY
End Get
Set
FY = value
End Set
End Property
Published Property Strings As TStringList
Get
Return fStrings
End Get
Set
fStrings = value
End Set
End Property
Published Property OnClick As TNotifyEvent
Get
Return fOnClick
End Get
Set
fOnClick = value
End Set
End Property
Published Property Inter As IUnknown
Get
Return fInter
End Get
Set
fInter = value
End Set
End Property
Published Sub MyProc(U As Integer, V As Integer)
println "MyProc:", X, Y
End Sub
End Class
Class AMyClass2
Inherits AMyClass
Sub New(AOwner As TComponent)
MyBase.New(null)
End Sub
End Class
Dim Z As AMyClass, W As AMyClass
Dim TestClass As TTestClass = New TTestClass()
Z = New AMyClass(null)
W = New AMyClass2(null)
W.X = 5
println W.X
W.Name = "yyyy"
println W.Name
TestClass.DoTest ' Z.OnClick was assigned at host side
If Assigned(Z.OnClick) Then
Z.OnClick(Z)
End If
Z.OnClick = TestClass.OnClickHandler2 ' direct assignment of host handler
Z.OnClick(null)
Z.OnClick = Z.ScriptHandler
Z.OnClick(W)
Z.Free
W.Free
TestClass.Free

View File

@ -0,0 +1,93 @@
{$APPTYPE CONSOLE}
{$O-}
program Project1;
uses
PAXCOMP_CONSTANTS,
PAXCOMP_SYS,
TypInfo,
Classes,
SysUtils,
PaxCompiler,
PaxInterpreter,
PaxBasicLanguage,
PaxRegister;
type
TTest = class(TComponent)
public
procedure Save;
end;
{ TTest }
procedure MyGetPropertyNames(aObject: TObject; aStringList: TStringList);
var
count : integer;
size : integer;
list : PPropList;
i : integer;
ppi: PPropInfo;
begin
aStringList.Clear;
count := GetPropList(PTypeInfo(aObject.ClassInfo), tkProperties, nil, false);
size := count * SizeOf(Pointer);
GetMem(list, size);
try
GetPropList(PTypeInfo(aObject.ClassInfo), tkProperties, list, false);
for i := 0 to count - 1 do
aStringList.Add(list^[i]^.Name);
finally
FreeMem(list, size);
end;
end;
type
TMyStringList = class(TStringList)
published
property Text;
end;
procedure TTest.Save;
var
list: TMyStringList;
begin
list := TMyStringList.Create;
try
MyGetPropertyNames(self, list);
writeln('Property Count = ', list.Count);
writeln('Properties are: ' + list.Text);
finally
list.free;
end;
end;
var
PaxInterpreter1: TPaxInterpreter;
PaxCompiler1: TPaxCompiler;
PaxBasicLanguage1: TPaxBasicLanguage;
H: Integer;
begin
H := RegisterClassType(0, TTest);
RegisterHeader(H, 'procedure Save;', @TTest.Save);
PaxCompiler1 := TPaxCompiler.Create(nil);
PaxInterpreter1 := TPaxInterpreter.Create(nil);
PaxBasicLanguage1 := TPaxBasicLanguage.Create(nil);
try
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
PaxCompiler1.AddModule('1', 'Basic');
PaxCompiler1.AddCodeFromFile('1', 'script.txt');
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxInterpreter1.Run;
end
else
writeln(PaxCompiler1.ErrorMessage[0]);
finally
PaxCompiler1.Free;
PaxInterpreter1.Free;
PaxBasicLanguage1.Free;
end;
writeln('Press any key...');
Readln;
end.

View File

@ -0,0 +1,37 @@
Class MyTestBase
Inherits TTest
End Class
Class MyTest
Inherits MyTestBase
Private FX As Integer
Private FY As String
Published Property X As Integer
Get
Return FX
End Get
Set
FX = value
End Set
End Property
Published Property Y As String
Get
Return FY
End Get
Set
FY = value
End Set
End Property
End Class
Dim t As MyTest = New MyTest
t.x = 10
t.y = "20"
t.Save
t.Free

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,47 @@
object Form1: TForm1
Left = 192
Top = 114
Caption = 'Register variable demo'
ClientHeight = 171
ClientWidth = 327
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 49
Top = 98
Width = 93
Height = 31
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Run'
TabOrder = 0
OnClick = Button1Click
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 32
Top = 16
end
object PaxBasicLanguage1: TPaxBasicLanguage
ExplicitOff = False
CompleteBooleanEval = False
UseFWArrays = True
Left = 80
Top = 16
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 160
Top = 96
end
end

View File

@ -0,0 +1,68 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxCompiler, PaxInterpreter, PaxRegister, PaxBasicLanguage,
PaxRunner;
type
TForm1 = class(TForm)
PaxCompiler1: TPaxCompiler;
Button1: TButton;
PaxBasicLanguage1: TPaxBasicLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
TMyPoint = packed record
x, y: Integer;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
H_TMyPoint, H_MyPoint: Integer;
MyPoint: TMyPoint;
I: Integer;
begin
MyPoint.X := 60;
MyPoint.Y := 23;
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxBasicLanguage1);
// register host-defined type
H_TMyPoint := PaxCompiler1.RegisterRecordType(0, 'TMyPoint');
PaxCompiler1.RegisterRecordTypeField(H_TMyPoint, 'X', _typeINTEGER);
PaxCompiler1.RegisterRecordTypeField(H_TMyPoint, 'Y', _typeINTEGER);
// register host-defined variable
H_MyPoint := PaxCompiler1.RegisterVariable(0, 'MyPoint', H_TMyPoint, @MyPoint);
PaxCompiler1.AddModule('1', PaxBasicLanguage1.LanguageName);
PaxCompiler1.AddCode('1', 'MyPoint.Y = 8');
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxInterpreter1.Run;
ShowMessage(IntToStr(MyPoint.Y));
end
else
for I:=0 to PaxCompiler1.ErrorCount do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,44 @@
object Form1: TForm1
Left = 277
Top = 120
Caption = 'Access to script-defined variables'
ClientHeight = 164
ClientWidth = 290
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 39
Top = 98
Width = 93
Height = 31
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Run'
TabOrder = 0
OnClick = Button1Click
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 48
Top = 24
end
object PaxJavaScriptLanguage1: TPaxJavaScriptLanguage
Left = 152
Top = 80
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 168
Top = 40
end
end

View File

@ -0,0 +1,58 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxCompiler, PaxInterpreter, PaxJavaScriptLanguage,
PaxRunner;
type
TForm1 = class(TForm)
PaxCompiler1: TPaxCompiler;
Button1: TButton;
PaxJavaScriptLanguage1: TPaxJavaScriptLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
P: Pointer;
I: Integer;
begin
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxJavaScriptLanguage1);
PaxCompiler1.RegisterHeader(0, 'procedure ShowMessage(const Msg: string);', @ShowMessage);
PaxCompiler1.RegisterHeader(0, 'function IntToStr(Value: Integer): string;', @IntToStr);
PaxCompiler1.AddModule('1', PaxJavaScriptLanguage1.LanguageName);
PaxCompiler1.AddCode('1', 'var x;');
PaxCompiler1.AddCode('1', 'ShowMessage("script:" + IntToStr(x));');
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
P := PaxInterpreter1.GetAddress('x');
Variant(P^) := 5; // change script-defind variable
PaxInterpreter1.Run; // the first run
ShowMessage('host:' + IntToStr(Variant(P^))); // show script-defined var
Variant(P^) := 30; // change script-defind variable
PaxInterpreter1.Run; // the second run
end
else
for I:=0 to PaxCompiler1.ErrorCount do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,135 @@
object Form1: TForm1
Left = 192
Top = 114
Caption = 'Form1'
ClientHeight = 329
ClientWidth = 761
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 120
TextHeight = 16
object Label1: TLabel
Left = 30
Top = 10
Width = 60
Height = 26
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Script:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -23
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object Label3: TLabel
Left = 354
Top = 59
Width = 206
Height = 26
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Add breakpoint at line'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -23
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object Memo1: TMemo
Left = 20
Top = 49
Width = 227
Height = 218
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -20
Font.Name = 'MS Sans Serif'
Font.Style = []
Lines.Strings = (
' print("A"); // line 0'
' print("B"); // line 1'
' print("C"); // line 2'
' print("D"); // line 3'
' print("E"); // line 4'
'')
ParentFont = False
TabOrder = 0
end
object Edit1: TEdit
Left = 591
Top = 59
Width = 50
Height = 32
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -20
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 1
Text = '2'
end
object Button1: TButton
Left = 390
Top = 158
Width = 188
Height = 60
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Run script'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -23
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 2
OnClick = Button1Click
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 296
Top = 192
end
object PaxCompilerDebugger1: TPaxCompilerDebugger
Left = 456
Top = 192
end
object PaxCompilerExplorer1: TPaxCompilerExplorer
Left = 520
Top = 200
end
object PaxJavaScriptLanguage1: TPaxJavaScriptLanguage
Left = 344
Top = 192
end
object PaxInterpreter1: TPaxInterpreter
Console = False
OnPrintEvent = PaxInterpreter1PrintEvent
Left = 320
Top = 112
end
end

View File

@ -0,0 +1,80 @@
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, PaxInterpreter, PaxCompiler, PaxCompilerDebugger,
PaxRegister,
PaxCompilerExplorer, PaxJavaScriptLanguage, PaxRunner;
type
TForm1 = class(TForm)
Memo1: TMemo;
Label1: TLabel;
Edit1: TEdit;
Label3: TLabel;
Button1: TButton;
PaxCompiler1: TPaxCompiler;
PaxCompilerDebugger1: TPaxCompilerDebugger;
PaxCompilerExplorer1: TPaxCompilerExplorer;
PaxJavaScriptLanguage1: TPaxJavaScriptLanguage;
PaxInterpreter1: TPaxInterpreter;
procedure Button1Click(Sender: TObject);
procedure PaxInterpreter1PrintEvent(Sender: TPaxRunner; const Text: string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
Breakpoint: Integer;
begin
Breakpoint := StrToInt(Edit1.Text);
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxJavaScriptLanguage1);
PaxCompiler1.AddModule('1', PaxJavaScriptLanguage1.LanguageName);
PaxCompiler1.AddCode('1', Memo1.Lines.Text);
PaxCompiler1.DebugMode := true;
if PaxCompiler1.Compile(PaxInterpreter1) then
begin
PaxCompilerExplorer1.RegisterCompiler(PaxCompiler1);
PaxCompilerDebugger1.RegisterCompiler(PaxCompiler1, PaxInterpreter1);
if PaxCompilerExplorer1.IsExecutableLine('1', Breakpoint) then
PaxCompilerDebugger1.AddBreakpoint('1', Breakpoint);
PaxCompilerDebugger1.Run;
while PaxCompilerDebugger1.IsPaused do
begin
ShowMessage('Program has been paused at breakpoint: ' +
IntToStr(PaxCompilerDebugger1.SourceLineNumber));
PaxInterpreter1.Run;
end;
end
else
for I:=0 to PaxCompiler1.ErrorCount - 1 do
ShowMessage(PaxCompiler1.ErrorMessage[I]);
end;
procedure TForm1.PaxInterpreter1PrintEvent(Sender: TPaxRunner;
const Text: string);
begin
ShowMessage(Text);
end;
end.

View File

@ -0,0 +1,13 @@
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,45 @@
object Form1: TForm1
Left = 192
Top = 114
Caption = 'Call routine demo'
ClientHeight = 146
ClientWidth = 283
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 120
TextHeight = 16
object Button1: TButton
Left = 49
Top = 89
Width = 149
Height = 30
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Call '
TabOrder = 0
OnClick = Button1Click
end
object PaxCompiler1: TPaxCompiler
Alignment = 1
DebugMode = False
Left = 32
Top = 16
end
object PaxJavaScriptLanguage1: TPaxJavaScriptLanguage
Left = 192
Top = 64
end
object PaxInterpreter1: TPaxInterpreter
Console = False
Left = 136
Top = 40
end
end

Some files were not shown because too many files have changed in this diff Show More