535 lines
23 KiB
HTML
535 lines
23 KiB
HTML
|
<head>
|
||
|
<link rel=stylesheet type="text/css" href="styles.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<H3>
|
||
|
TPaxProgram Methods
|
||
|
</H3>
|
||
|
<hr>
|
||
|
<ul>
|
||
|
<li><a href="#TPaxProgram.CallClassMethod">CallClassMethod</a></li>
|
||
|
<li><a href="#TPaxProgram.CallMethod">CallMethod</a></li>
|
||
|
<li><a href="#TPaxProgram.CallRoutine">CallRoutine</a></li>
|
||
|
<li><a href="#TPaxProgram.Create">Create</a></li>
|
||
|
<li><a href="#TPaxProgram.Destroy">Destroy</a></li>
|
||
|
<li><a href="#TPaxProgram.DiscardPause">DiscardPause</a></li>
|
||
|
<li><a href="#TPaxProgram.GetAddress">GetAddress</a></li>
|
||
|
<li><a href="#TPaxProgram.GetImageSize">GetImageSize</a></li>
|
||
|
<li><a href="#TPaxProgram.GetTypeInfo">GetTypeInfo</a></li>
|
||
|
<li><a href="#TPaxProgram.IsPaused">IsPaused</a></li>
|
||
|
<li><a href="#TPaxProgram.IsRunning">IsRunning</a></li>
|
||
|
<li><a href="#TPaxProgram.LoadDFMFile">LoadDFMFile</a></li>
|
||
|
<li><a href="#TPaxProgram.LoadDFMStream">LoadDFMStream</a></li>
|
||
|
<li><a href="#TPaxProgram.LoadFromFile">LoadFromFile</a></li>
|
||
|
<li><a href="#TPaxProgram.LoadFromStream">LoadFromStream</a></li>
|
||
|
<li><a href="#TPaxProgram.Pause">Pause</a></li>
|
||
|
<li><a href="#TPaxProgram.Resume">Resume</a></li>
|
||
|
<li><a href="#TPaxProgram.Run">Run</a></li>
|
||
|
<li><a href="#TPaxProgram.SaveToFile">SaveToFile</a></li>
|
||
|
<li><a href="#TPaxProgram.SaveToStream">SaveToStream</a></li>
|
||
|
<li><a href="#TPaxProgram.SetAddress">SetAddress</a></li>
|
||
|
<li><a href="#TPaxProgram.SetEntryPoint">SetEntryPoint</a></li>
|
||
|
<li><a href="#TPaxProgram.CreateScriptObject">CreateScriptObject</a></li>
|
||
|
<li><a href="#TPaxProgram.DestroyScriptObject">DestroyScriptObject</a></li>
|
||
|
<li><a href="#TPaxProgram.MapGlobal">MapGlobal</a></li>
|
||
|
<li><a href="#TPaxProgram.MapLocal">MapLocal</a></li>
|
||
|
<li><a href="#TPaxProgram.RegisterNamespace">RegisterNamespace</a></li>
|
||
|
<li><a href="#TPaxProgram.RegisterClassType">RegisterClassType</a></li>
|
||
|
<li><a href="#TPaxProgram.RegisterMember">RegisterMember</a></li>
|
||
|
</ul>
|
||
|
<a name="TPaxProgram.CallClassMethod"><h3>TPaxProgram.CallClassMethod</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Allows you to call a shared method of a script-defined class.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> CallClassMethod(<font color="blue"><b>const</b></font> FullName: <font color="blue"><b>String</b></font>;
|
||
|
Instance: TClass; <font color="blue"><b>const</b></font> ParamList: <font color="blue"><b>array</b></font> <font color="blue"><b>of</b></font> OleVariant): OleVariant;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.CallMethod"><h3>TPaxProgram.CallMethod</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Allows you to invoke an instance method of a script-defined class.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> CallMethod(<font color="blue"><b>const</b></font> FullName: <font color="blue"><b>String</b></font>;
|
||
|
Instance: TObject; <font color="blue"><b>const</b></font> ParamList: <font color="blue"><b>array</b></font> <font color="blue"><b>of</b></font> OleVariant): OleVariant;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.CallRoutine"><h3>TPaxProgram.CallRoutine</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Allows you to invoke a script-defined routine.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> CallRoutine(<font color="blue"><b>const</b></font> FullName: <font color="blue"><b>String</b></font>;
|
||
|
<font color="blue"><b>const</b></font> ParamList: <font color="blue"><b>array</b></font> <font color="blue"><b>of</b></font> OleVariant): OleVariant;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.Create"><h3>TPaxProgram.Create</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Constructor of TPaxProgram class.
|
||
|
<pre>
|
||
|
<font color="blue"><b>constructor</b></font> Create(AOwner: TComponent); <font color="blue"><b>override</b></font>;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.Destroy"><h3>TPaxProgram.Destroy</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Destructor of TPaxProgram class.
|
||
|
<pre>
|
||
|
<font color="blue"><b>destructor</b></font> Destroy; <font color="blue"><b>override</b></font>;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.DiscardPause"><h3>TPaxProgram.DiscardPause</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Terminates a paused program.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> DiscardPause;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.GetAddress"><h3>TPaxProgram.GetAddress</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Returns address of a script-defined variable, procedure or function.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> GetAddress(Handle: Integer): Pointer;
|
||
|
<font color="blue"><b>function</b></font> GetAddress(<font color="blue"><b>const</b></font> FullName: <font color="blue"><b>String</b></font>): Pointer;
|
||
|
</pre>
|
||
|
<H4>
|
||
|
Arguments
|
||
|
</H4>
|
||
|
<blockquote>
|
||
|
<i>Handle</i>
|
||
|
<blockquote>
|
||
|
Id of a a script-defined variable, procedure or function.
|
||
|
</blockquote>
|
||
|
</blockquote>
|
||
|
<p>
|
||
|
<H4>
|
||
|
Example
|
||
|
</H4>
|
||
|
<pre>
|
||
|
// declare procedural type that conforms to a script-defined procedure
|
||
|
<font color="blue"><b>type</b></font>
|
||
|
TProcP = <font color="blue"><b>procedure</b></font> (X: Integer); <font color="blue"><b>stdcall</b></font>;
|
||
|
|
||
|
<font color="blue"><b>procedure</b></font> TForm1.Button1Click(Sender: TObject);
|
||
|
<font color="blue"><b>var</b></font>
|
||
|
H_Y, H_P: Integer;
|
||
|
I: Integer;
|
||
|
P: Pointer;
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
PaxCompiler1.Reset;
|
||
|
PaxCompiler1.RegisterLanguage(PaxPascalLanguage1);
|
||
|
|
||
|
H_Y := PaxCompiler1.RegisterVariable(0, <font color="Red">'Y'</font>, _typeINTEGER);
|
||
|
|
||
|
PaxCompiler1.AddModule(<font color="Red">'1'</font>, PaxPascalLanguage1.LanguageName);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'procedure P(X: Integer);'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'begin'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' Y := Y + X;'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'end;'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'begin'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'end.'</font>);
|
||
|
|
||
|
<font color="blue"><b>if</b></font> PaxCompiler1.Compile(PaxProgram1) <font color="blue"><b>then</b></font>
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
H_P := PaxCompiler1.GetHandle(0, <font color="Red">'P'</font>, true);
|
||
|
P := PaxProgram1.GetAddress(H_P); // get address of script-defind procedure
|
||
|
PaxProgram1.SetAddress(H_Y, @Y);
|
||
|
|
||
|
PaxProgram1.Init; // init procedure call
|
||
|
TProcP(P)(10); // call it
|
||
|
ShowMessage(IntToStr(Y));
|
||
|
<font color="blue"><b>end</b></font>
|
||
|
<font color="blue"><b>else</b></font>
|
||
|
<font color="blue"><b>for</b></font> I:=0 <font color="blue"><b>to</b></font> PaxCompiler1.ErrorCount <font color="blue"><b>do</b></font>
|
||
|
ShowMessage(PaxCompiler1.ErrorMessage[I]);
|
||
|
<font color="blue"><b>end</b></font>;
|
||
|
</pre>
|
||
|
</p>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.GetImageSize"><h3>TPaxProgram.GetImageSize</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Returns size of image of compiled program.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> GetImageSize: Integer;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.GetTypeInfo"><h3>TPaxProgram.GetTypeInfo</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Returns type information of a script-defined type.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> GetTypeInfo(<font color="blue"><b>const</b></font> FullTypeName: <font color="blue"><b>String</b></font>): PTypeInfo;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.IsPaused"><h3>TPaxProgram.IsPaused</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Returns 'true', if script is in the paused state.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> IsPaused: Boolean;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.IsRunning"><h3>TPaxProgram.IsRunning</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Returns 'true', if component runs a program.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> IsRunning: Boolean;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.LoadDFMFile"><h3>TPaxProgram.LoadDFMFile</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Binds an instance of script-defined class with dfm file.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> LoadDFMFile(Instance: TObject; <font color="blue"><b>const</b></font> FileName: <font color="blue"><b>String</b></font>);
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.LoadDFMStream"><h3>TPaxProgram.LoadDFMStream</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Binds an instance of a script-defined class with dfm stream.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> LoadDFMStream(Instance: TObject; S: TStream);
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.LoadFromFile"><h3>TPaxProgram.LoadFromFile</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Loads program from a file.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> LoadFromFile(<font color="blue"><b>const</b></font> Path: <font color="blue"><b>String</b></font>);
|
||
|
</pre>
|
||
|
<p>
|
||
|
<H4>
|
||
|
Example
|
||
|
</H4>
|
||
|
<pre>
|
||
|
<font color="blue"><b>var</b></font>
|
||
|
PaxProgram1: TPaxProgram;
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
<font color="blue"><b>if</b></font> FileExists(<font color="Red">'1.bin'</font>) <font color="blue"><b>then</b></font>
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
PaxProgram1 := TPaxProgram.Create(<font color="blue"><b>nil</b></font>);
|
||
|
<font color="blue"><b>try</b></font>
|
||
|
PaxProgram1.LoadFromFile(<font color="Red">'1.bin'</font>);
|
||
|
PaxProgram1.Run;
|
||
|
<font color="blue"><b>finally</b></font>
|
||
|
PaxProgram1.Free;
|
||
|
<font color="blue"><b>end</b></font>;
|
||
|
<font color="blue"><b>end</b></font>;
|
||
|
<font color="blue"><b>end</b></font>;
|
||
|
</pre>
|
||
|
</p>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.LoadFromStream"><h3>TPaxProgram.LoadFromStream</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Loads program from a stream.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> LoadFromStream(S: TStream);
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.Pause"><h3>TPaxProgram.Pause</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Pauses script.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> Pause;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.Resume"><h3>TPaxProgram.Resume</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Resumes a paused script.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> Resume;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.Run"><h3>TPaxProgram.Run</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Executes program.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> Run;
|
||
|
</pre>
|
||
|
<p>
|
||
|
<H4>
|
||
|
Example
|
||
|
</H4>
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> TForm1.Button1Click(Sender: TObject);
|
||
|
<font color="blue"><b>var</b></font>
|
||
|
H_ShowMessage: Integer;
|
||
|
I: Integer;
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
PaxCompiler1.Reset;
|
||
|
PaxCompiler1.RegisterLanguage(PaxPascalLanguage1);
|
||
|
|
||
|
// register routine <font color="Red">'ShowMessage'</font>
|
||
|
H_ShowMessage := PaxCompiler1.RegisterRoutine(0, <font color="Red">'ShowMessage'</font>, _typeVOID, _ccREGISTER);
|
||
|
PaxCompiler1.RegisterParameter(H_ShowMessage, _typeSTRING, _Unassigned);
|
||
|
|
||
|
PaxCompiler1.AddModule(<font color="Red">'1'</font>, PaxPascalLanguage1.LanguageName);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'begin'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' ShowMessage('</font><font color="Red">'Hello'</font><font color="Red">');'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'end.'</font>);
|
||
|
|
||
|
<font color="blue"><b>if</b></font> PaxCompiler1.Compile(PaxProgram1) <font color="blue"><b>then</b></font>
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
// set address of routine <font color="Red">'ShowMessage'</font>
|
||
|
PaxProgram1.SetAddress(H_ShowMessage, @ShowMessage);
|
||
|
PaxProgram1.Run;
|
||
|
<font color="blue"><b>end</b></font>
|
||
|
<font color="blue"><b>else</b></font>
|
||
|
<font color="blue"><b>for</b></font> I:=0 <font color="blue"><b>to</b></font> PaxCompiler1.ErrorCount - 1 <font color="blue"><b>do</b></font>
|
||
|
ShowMessage(PaxCompiler1.ErrorMessage[I]);
|
||
|
<font color="blue"><b>end</b></font>;
|
||
|
</pre>
|
||
|
</p>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.SaveToFile"><h3>TPaxProgram.SaveToFile</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Saves program to a binary file.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> SaveToFile(<font color="blue"><b>const</b></font> Path: <font color="blue"><b>String</b></font>);
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.SaveToStream"><h3>TPaxProgram.SaveToStream</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Saves program to a stream.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> SaveToStream(S: TStream);
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.SetAddress"><h3>TPaxProgram.SetAddress</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Sets address of a host-defined variable, procedure or function.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> SetAddress(Handle: Integer; P: Pointer);
|
||
|
</pre>
|
||
|
<H4>
|
||
|
Arguments
|
||
|
</H4>
|
||
|
<blockquote>
|
||
|
<i>Handle</i>
|
||
|
<blockquote>
|
||
|
Id of a host-defined variable, procedure or function.
|
||
|
</blockquote>
|
||
|
</blockquote>
|
||
|
<blockquote>
|
||
|
<i>P</i>
|
||
|
<blockquote>
|
||
|
Address
|
||
|
</blockquote>
|
||
|
</blockquote>
|
||
|
<p>
|
||
|
<H4>
|
||
|
Example
|
||
|
</H4>
|
||
|
<pre>
|
||
|
<font color="blue"><b>type</b></font>
|
||
|
TMyPoint = <font color="blue"><b>packed</b></font> <font color="blue"><b>record</b></font>
|
||
|
x, y: Integer;
|
||
|
<font color="blue"><b>end</b></font>;
|
||
|
|
||
|
<font color="blue"><b>procedure</b></font> TForm1.Button1Click(Sender: TObject);
|
||
|
<font color="blue"><b>var</b></font>
|
||
|
H_TMyPoint, H_MyPoint: Integer;
|
||
|
MyPoint: TMyPoint;
|
||
|
I: Integer;
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
MyPoint.X := 60;
|
||
|
MyPoint.Y := 23;
|
||
|
|
||
|
PaxCompiler1.Reset;
|
||
|
PaxCompiler1.RegisterLanguage(PaxPascalLanguage1);
|
||
|
|
||
|
// register host-defined type
|
||
|
H_TMyPoint := PaxCompiler1.RegisterRecordType(0, <font color="Red">'TMyPoint'</font>);
|
||
|
PaxCompiler1.RegisterRecordTypeField(H_TMyPoint, <font color="Red">'X'</font>, _typeINTEGER);
|
||
|
PaxCompiler1.RegisterRecordTypeField(H_TMyPoint, <font color="Red">'Y'</font>, _typeINTEGER);
|
||
|
|
||
|
// register host-defined variable
|
||
|
H_MyPoint := PaxCompiler1.RegisterVariable(0, <font color="Red">'MyPoint'</font>, H_TMyPoint);
|
||
|
|
||
|
PaxCompiler1.AddModule(<font color="Red">'1'</font>, PaxPascalLanguage1.LanguageName);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'begin'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' MyPoint.Y := 8;'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'end.'</font>);
|
||
|
|
||
|
<font color="blue"><b>if</b></font> PaxCompiler1.Compile(PaxProgram1) <font color="blue"><b>then</b></font>
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
PaxProgram1.SetAddress(H_MyPoint, @MyPoint);
|
||
|
PaxProgram1.Run;
|
||
|
|
||
|
ShowMessage(IntToStr(MyPoint.Y));
|
||
|
<font color="blue"><b>end</b></font>
|
||
|
<font color="blue"><b>else</b></font>
|
||
|
<font color="blue"><b>for</b></font> I:=0 <font color="blue"><b>to</b></font> PaxCompiler1.ErrorCount <font color="blue"><b>do</b></font>
|
||
|
ShowMessage(PaxCompiler1.ErrorMessage[I]);
|
||
|
<font color="blue"><b>end</b></font>;
|
||
|
</pre>
|
||
|
</p>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.SetEntryPoint"><h3>TPaxProgram.SetEntryPoint</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Assigns entry point to a program. Allows to call a script-defined function.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> SetEntryPoint(EntryPoint: TPaxInvoke);
|
||
|
</pre>
|
||
|
<p>
|
||
|
<H4>
|
||
|
Example
|
||
|
</H4>
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> TTest.Proc(<font color="blue"><b>const</b></font> S: <font color="blue"><b>String</b></font>);
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
ShowMessage(S);
|
||
|
<font color="blue"><b>end</b></font>;
|
||
|
|
||
|
<font color="blue"><b>procedure</b></font> TForm1.Button1Click(Sender: TObject);
|
||
|
|
||
|
<font color="blue"><b>procedure</b></font> Print(<font color="blue"><b>const</b></font> S: <font color="blue"><b>String</b></font>);
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
ShowMessage(S);
|
||
|
<font color="blue"><b>end</b></font>;
|
||
|
|
||
|
<font color="blue"><b>var</b></font>
|
||
|
H_MyFunc: Integer;
|
||
|
I: Integer;
|
||
|
P: Pointer;
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
{$O-}
|
||
|
PaxCompiler1.Reset;
|
||
|
PaxCompiler1.RegisterLanguage(PaxPascalLanguage1);
|
||
|
PaxCompiler1.RegisterHeader(0, <font color="Red">'procedure Print(const S: String);'</font>, @Print);
|
||
|
|
||
|
PaxCompiler1.AddModule(<font color="Red">'1'</font>, PaxPascalLanguage1.LanguageName);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'uses SysUtils;'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'function MyFunc(U, V: Integer): Currency; cdecl;'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'begin'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' try'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' result := U / V;'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' except'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' on E: Exception do'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' begin'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' print(E.Message);'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' result := 7;'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' end;'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">' end;'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'end;'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'begin'</font>);
|
||
|
PaxCompiler1.AddCode(<font color="Red">'1'</font>, <font color="Red">'end.'</font>);
|
||
|
|
||
|
<font color="blue"><b>if</b></font> PaxCompiler1.Compile(PaxProgram1) <font color="blue"><b>then</b></font>
|
||
|
<font color="blue"><b>begin</b></font>
|
||
|
H_MyFunc := PaxCompiler1.GetHandle(0, <font color="Red">'MyFunc'</font>, true);
|
||
|
|
||
|
P := PaxProgram1.GetAddress(H_MyFunc); // get address of script-defined function
|
||
|
|
||
|
PaxInvoke1.Address := P;
|
||
|
PaxInvoke1.This := <font color="blue"><b>nil</b></font>; // this is not a method, but global function.
|
||
|
PaxInvoke1.ClearArguments;
|
||
|
PaxInvoke1.AddArgAsInteger(8);
|
||
|
PaxInvoke1.AddArgAsInteger(2);
|
||
|
PaxInvoke1.SetResultAsCurrency;
|
||
|
PaxInvoke1.CallConv := _ccCDECL;
|
||
|
|
||
|
PaxProgram1.SetEntryPoint(PaxInvoke1);
|
||
|
PaxProgram1.Run;
|
||
|
|
||
|
ShowMessage(CurrToStr(Currency(PaxInvoke1.GetResultPtr^)));
|
||
|
<font color="blue"><b>end</b></font>
|
||
|
<font color="blue"><b>else</b></font>
|
||
|
<font color="blue"><b>for</b></font> I:=0 <font color="blue"><b>to</b></font> PaxCompiler1.ErrorCount <font color="blue"><b>do</b></font>
|
||
|
ShowMessage(PaxCompiler1.ErrorMessage[I]);
|
||
|
<font color="blue"><b>end</b></font>;
|
||
|
</pre>
|
||
|
</p>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.CreateScriptObject"><h3>TPaxProgram.CreateScriptObject</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Creates instace of script-defined class at run-time.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> CreateScriptObject(<font color="blue"><b>const</b></font> ScriptClassName: <font color="blue"><b>String</b></font>): TObject;
|
||
|
</pre>
|
||
|
<H4>
|
||
|
Arguments
|
||
|
</H4>
|
||
|
<blockquote>
|
||
|
<i>ScriptClassName</i>
|
||
|
<blockquote>
|
||
|
Name of a script-defined class.
|
||
|
</blockquote>
|
||
|
</blockquote>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.DestroyScriptObject"><h3>TPaxProgram.DestroyScriptObject</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Destroys object of a script-defined class at run-time.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> DestroyScriptObject(X: TObject);
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.MapGlobal"><h3>TPaxProgram.MapGlobal</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Forces OnMapTableNamespace, OnMapTableVarAddress, OnMapTableProcAddress, OnMapTableClassRef events for all members registered with global registration routines.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> MapGlobal;
|
||
|
</pre>
|
||
|
<p>
|
||
|
The events allows you to assign addresses and class references of imported host members. See ..\Demos\DemoLoadNamespace in a trial package for Delphi.
|
||
|
</p>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.MapLocal"><h3>TPaxProgram.MapLocal</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Forces OnMapTableNamespace, OnMapTableVarAddress, OnMapTableProcAddress, OnMapTableClassRef events for all members registered with TPaxCompiler registration methods.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> MapLocal;
|
||
|
</pre>
|
||
|
<p>
|
||
|
The events allows you to assign addresses and class references of imported host members. See ..\Demos\DemoLoadNamespace in a trial package for Delphi.
|
||
|
</p>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.RegisterNamespace"><h3>TPaxProgram.RegisterNamespace</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Registeres a namespace.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> RegisterNamespace(LevelId: Integer; <font color="blue"><b>const</b></font> Name: <font color="blue"><b>String</b></font>): Integer;
|
||
|
</pre>
|
||
|
<p>
|
||
|
This method is used together with RegisterClassType and RegisterAddress and allows you to assign addresses of host-defined members and class references of hos-defined classes to compiled script.
|
||
|
</p>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.RegisterClassType"><h3>TPaxProgram.RegisterClassType</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Registeres class type for compiled script.
|
||
|
<pre>
|
||
|
<font color="blue"><b>function</b></font> RegisterClassType(LevelId: Integer; C: TClass): Integer;
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
<a name="TPaxProgram.RegisterMember"><h3>TPaxProgram.RegisterMember</h3></a>
|
||
|
<!-------------------------------------------------------------------->
|
||
|
<blockquote>
|
||
|
Registeres address of host-defined member for compiled script.
|
||
|
<pre>
|
||
|
<font color="blue"><b>procedure</b></font> RegisterMember(LevelId: Integer; <font color="blue"><b>const</b></font> Name: <font color="blue"><b>String</b></font>; Address: Pointer);
|
||
|
</pre>
|
||
|
</blockquote>
|
||
|
</body>
|