unit uPSI_JavascriptObject;
{
This file has been generated by UnitParser v0.7, written by M. Knight
and updated by NP. v/d Spek and George Birbilis.
Source Code from Carlo Kok has been used to implement various sections of
UnitParser. Components of ROPS are used in the construction of UnitParser,
code implementing the class wrapper is taken from Carlo Kok's conv utility

}
interface



uses
   SysUtils
  ,Classes
  ,uPSComponent
  ,uPSRuntime
  ,uPSCompiler
  ;

type
(*----------------------------------------------------------------------------*)
  TPSImport_JavascriptObject = class(TPSPlugin)
  public
    procedure CompileImport1(CompExec: TPSScript); override;
    procedure ExecImport1(CompExec: TPSScript; const ri: TPSRuntimeClassImporter); override;
  end;


{ compile-time registration functions }
procedure SIRegister_TJSObject(CL: TPSPascalCompiler);
procedure SIRegister_JavascriptObject(CL: TPSPascalCompiler);

{ run-time registration functions }
procedure RIRegister_TJSObject(CL: TPSRuntimeClassImporter);
procedure RIRegister_JavascriptObject(CL: TPSRuntimeClassImporter);

procedure Register;

implementation


uses
   Windows
  ,Messages
  ,Variants
  ,ActiveX
  ,ComObj
  ,MSHTML
  ,JavascriptObject
  ;


procedure Register;
begin
  RegisterComponents('Pascal Script', [TPSImport_JavascriptObject]);
end;

(* === compile-time registration functions === *)
(*----------------------------------------------------------------------------*)
procedure SIRegister_TJSObject(CL: TPSPascalCompiler);
begin
  //with RegClassS(CL,'TObject', 'TJSObject') do
  with CL.AddClassN(CL.FindClass('TObject'),'TJSObject') do
  begin
    RegisterProperty('Name', 'string', iptrw);
    RegisterProperty('ActualJSPoint', 'Variant', iptrw);
    RegisterMethod('Function GetObject( PropertyNameStr : string) : TJSObject');
    RegisterMethod('Function GetString( PropertyNameStr : string) : string');
    RegisterMethod('Procedure SetValue( PropertyName : string; Value : string)');
  end;
end;

(*----------------------------------------------------------------------------*)
procedure SIRegister_JavascriptObject(CL: TPSPascalCompiler);
begin
  //CL.AddTypeS('PJSObject', '^TJSObject // will not work');
  SIRegister_TJSObject(CL);
end;

(* === run-time registration functions === *)
(*----------------------------------------------------------------------------*)
procedure TJSObjectActualJSPoint_W(Self: TJSObject; const T: Variant);
begin Self.ActualJSPoint := T; end;

(*----------------------------------------------------------------------------*)
procedure TJSObjectActualJSPoint_R(Self: TJSObject; var T: Variant);
begin T := Self.ActualJSPoint; end;

(*----------------------------------------------------------------------------*)
procedure TJSObjectName_W(Self: TJSObject; const T: string);
begin Self.Name := T; end;

(*----------------------------------------------------------------------------*)
procedure TJSObjectName_R(Self: TJSObject; var T: string);
begin T := Self.Name; end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_TJSObject(CL: TPSRuntimeClassImporter);
begin
  with CL.Add(TJSObject) do
  begin
    RegisterPropertyHelper(@TJSObjectName_R,@TJSObjectName_W,'Name');
    RegisterPropertyHelper(@TJSObjectActualJSPoint_R,@TJSObjectActualJSPoint_W,'ActualJSPoint');
    RegisterMethod(@TJSObject.GetObject, 'GetObject');
    RegisterMethod(@TJSObject.GetString, 'GetString');
    RegisterMethod(@TJSObject.SetValue, 'SetValue');
  end;
end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_JavascriptObject(CL: TPSRuntimeClassImporter);
begin
  RIRegister_TJSObject(CL);
end;



{ TPSImport_JavascriptObject }
(*----------------------------------------------------------------------------*)
procedure TPSImport_JavascriptObject.CompileImport1(CompExec: TPSScript);
begin
  SIRegister_JavascriptObject(CompExec.Comp);
end;
(*----------------------------------------------------------------------------*)
procedure TPSImport_JavascriptObject.ExecImport1(CompExec: TPSScript; const ri: TPSRuntimeClassImporter);
begin
  RIRegister_JavascriptObject(ri);
end;
(*----------------------------------------------------------------------------*)


end.
