unit uPSI_djson;
{
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_djson = class(TPSPlugin)
  public
    procedure CompileImport1(CompExec: TPSScript); override;
    procedure ExecImport1(CompExec: TPSScript; const ri: TPSRuntimeClassImporter); override;
  end;


{ compile-time registration functions }
procedure SIRegister_TdJSON(CL: TPSPascalCompiler);
procedure SIRegister_TdJSONListItems(CL: TPSPascalCompiler);
procedure SIRegister_TdJSONItems(CL: TPSPascalCompiler);
procedure SIRegister_djson(CL: TPSPascalCompiler);

{ run-time registration functions }
procedure RIRegister_djson_Routines(S: TPSExec);
procedure RIRegister_TdJSON(CL: TPSRuntimeClassImporter);
procedure RIRegister_TdJSONListItems(CL: TPSRuntimeClassImporter);
procedure RIRegister_TdJSONItems(CL: TPSRuntimeClassImporter);
procedure RIRegister_djson(CL: TPSRuntimeClassImporter);


implementation


uses
   djson
  ;


(* === compile-time registration functions === *)
(*----------------------------------------------------------------------------*)
procedure SIRegister_TdJSON(CL: TPSPascalCompiler);
begin
  //with RegClassS(CL,'TObject', 'TdJSON') do
  with CL.AddClassN(CL.FindClass('TObject'),'TdJSON') do
  begin
    RegisterMethod('Constructor Create( AParent : TdJSON)');
    RegisterMethod('Function Parse( const AJSON : string) : TdJSON');
    RegisterProperty('Parent', 'TdJSON', iptr);
    RegisterProperty('IsList', 'boolean', iptr);
    RegisterProperty('IsDict', 'boolean', iptr);
    RegisterProperty('IsNull', 'boolean', iptr);
    RegisterProperty('Items', 'TdJSONItems', iptr);
    RegisterProperty('ListItems', 'TdJSONListItems', iptr);
    RegisterProperty('Value', 'Variant', iptr);
    RegisterProperty('AsString', 'string', iptr);
    RegisterProperty('AsInteger', 'integer', iptr);
    RegisterProperty('AsBoolean', 'boolean', iptr);
    RegisterProperty('AsInt64', 'int64', iptr);
    RegisterProperty('AsDouble', 'double', iptr);
    RegisterProperty('AsDateTime', 'TDateTime', iptr);
    RegisterProperty('JSONByNameOrIndex', 'TdJSON variant', iptr);
    SetDefaultPropery('JSONByNameOrIndex');
    RegisterProperty('_', 'TdJSON variant', iptr);
  end;
end;

(*----------------------------------------------------------------------------*)
procedure SIRegister_TdJSONListItems(CL: TPSPascalCompiler);
begin
  //with RegClassS(CL,'TObject', 'TdJSONListItems') do
  with CL.AddClassN(CL.FindClass('TObject'),'TdJSONListItems') do
  begin
    RegisterMethod('Constructor Create');
  end;
end;

(*----------------------------------------------------------------------------*)
procedure SIRegister_TdJSONItems(CL: TPSPascalCompiler);
begin
  //with RegClassS(CL,'TObject', 'TdJSONItems') do
  with CL.AddClassN(CL.FindClass('TObject'),'TdJSONItems') do
  begin
    RegisterMethod('Constructor Create');
  end;
end;

(*----------------------------------------------------------------------------*)
procedure SIRegister_djson(CL: TPSPascalCompiler);
begin
  CL.AddClassN(CL.FindClass('TOBJECT'),'TdJSON');
  SIRegister_TdJSONItems(CL);
  SIRegister_TdJSONListItems(CL);
  SIRegister_TdJSON(CL);
  CL.AddClassN(CL.FindClass('TOBJECT'),'EJSONUnknownFieldOrIndex');
  CL.AddClassN(CL.FindClass('TOBJECT'),'EJSONParseError');
 CL.AddDelphiFunction('Procedure DebugStr( const msg : variant)');
end;

(* === run-time registration functions === *)
(*----------------------------------------------------------------------------*)
procedure TdJSON__R(Self: TdJSON; var T: TdJSON; const t1: variant);
begin T := Self._[t1]; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONJSONByNameOrIndex_R(Self: TdJSON; var T: TdJSON; const t1: variant);
begin T := Self.JSONByNameOrIndex[t1]; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONAsDateTime_R(Self: TdJSON; var T: TDateTime);
begin T := Self.AsDateTime; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONAsDouble_R(Self: TdJSON; var T: double);
begin T := Self.AsDouble; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONAsInt64_R(Self: TdJSON; var T: int64);
begin T := Self.AsInt64; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONAsBoolean_R(Self: TdJSON; var T: boolean);
begin T := Self.AsBoolean; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONAsInteger_R(Self: TdJSON; var T: integer);
begin T := Self.AsInteger; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONAsString_R(Self: TdJSON; var T: string);
begin T := Self.AsString; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONValue_R(Self: TdJSON; var T: Variant);
begin T := Self.Value; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONListItems_R(Self: TdJSON; var T: TdJSONListItems);
begin T := Self.ListItems; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONItems_R(Self: TdJSON; var T: TdJSONItems);
begin T := Self.Items; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONIsNull_R(Self: TdJSON; var T: boolean);
begin T := Self.IsNull; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONIsDict_R(Self: TdJSON; var T: boolean);
begin T := Self.IsDict; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONIsList_R(Self: TdJSON; var T: boolean);
begin T := Self.IsList; end;

(*----------------------------------------------------------------------------*)
procedure TdJSONParent_R(Self: TdJSON; var T: TdJSON);
begin T := Self.Parent; end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_djson_Routines(S: TPSExec);
begin
 S.RegisterDelphiFunction(@DebugStr, 'DebugStr', cdRegister);
end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_TdJSON(CL: TPSRuntimeClassImporter);
begin
  with CL.Add(TdJSON) do
  begin
    RegisterConstructor(@TdJSON.Create, 'Create');
    RegisterMethod(@TdJSON.Parse, 'Parse');
    RegisterPropertyHelper(@TdJSONParent_R,nil,'Parent');
    RegisterPropertyHelper(@TdJSONIsList_R,nil,'IsList');
    RegisterPropertyHelper(@TdJSONIsDict_R,nil,'IsDict');
    RegisterPropertyHelper(@TdJSONIsNull_R,nil,'IsNull');
    RegisterPropertyHelper(@TdJSONItems_R,nil,'Items');
    RegisterPropertyHelper(@TdJSONListItems_R,nil,'ListItems');
    RegisterPropertyHelper(@TdJSONValue_R,nil,'Value');
    RegisterPropertyHelper(@TdJSONAsString_R,nil,'AsString');
    RegisterPropertyHelper(@TdJSONAsInteger_R,nil,'AsInteger');
    RegisterPropertyHelper(@TdJSONAsBoolean_R,nil,'AsBoolean');
    RegisterPropertyHelper(@TdJSONAsInt64_R,nil,'AsInt64');
    RegisterPropertyHelper(@TdJSONAsDouble_R,nil,'AsDouble');
    RegisterPropertyHelper(@TdJSONAsDateTime_R,nil,'AsDateTime');
    RegisterPropertyHelper(@TdJSONJSONByNameOrIndex_R,nil,'JSONByNameOrIndex');
    RegisterPropertyHelper(@TdJSON__R,nil,'_');
  end;
end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_TdJSONListItems(CL: TPSRuntimeClassImporter);
begin
  with CL.Add(TdJSONListItems) do
  begin
    RegisterConstructor(@TdJSONListItems.Create, 'Create');
  end;
end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_TdJSONItems(CL: TPSRuntimeClassImporter);
begin
  with CL.Add(TdJSONItems) do
  begin
    RegisterConstructor(@TdJSONItems.Create, 'Create');
  end;
end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_djson(CL: TPSRuntimeClassImporter);
begin
  with CL.Add(TdJSON) do
  RIRegister_TdJSONItems(CL);
  RIRegister_TdJSONListItems(CL);
  RIRegister_TdJSON(CL);
  with CL.Add(EJSONUnknownFieldOrIndex) do
  with CL.Add(EJSONParseError) do
end;



{ TPSImport_djson }
(*----------------------------------------------------------------------------*)
procedure TPSImport_djson.CompileImport1(CompExec: TPSScript);
begin
  SIRegister_djson(CompExec.Comp);
end;
(*----------------------------------------------------------------------------*)
procedure TPSImport_djson.ExecImport1(CompExec: TPSScript; const ri: TPSRuntimeClassImporter);
begin
  RIRegister_djson(ri);
  RIRegister_djson_Routines(CompExec.Exec); // comment it if no routines
end;
(*----------------------------------------------------------------------------*)


end.
