unit uPSI_XCollection;
{
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_XCollection = class(TPSPlugin)
  protected
    procedure CompileImport1(CompExec: TPSScript); override;
    procedure ExecImport1(CompExec: TPSScript; const ri: TPSRuntimeClassImporter); override;
  end;
 
 
{ compile-time registration functions }
procedure SIRegister_TGLXCollection(CL: TPSPascalCompiler);
procedure SIRegister_TGLXCollectionItem(CL: TPSPascalCompiler);
procedure SIRegister_EFilerException(CL: TPSPascalCompiler);
procedure SIRegister_XCollection(CL: TPSPascalCompiler);

{ run-time registration functions }
procedure RIRegister_XCollection_Routines(S: TPSExec);
procedure RIRegister_TGLXCollection(CL: TPSRuntimeClassImporter);
procedure RIRegister_TGLXCollectionItem(CL: TPSRuntimeClassImporter);
procedure RIRegister_EFilerException(CL: TPSRuntimeClassImporter);
procedure RIRegister_XCollection(CL: TPSRuntimeClassImporter);

procedure Register;

implementation


uses
   XCollection
  ;
 
 
procedure Register;
begin
  RegisterComponents('GLS ROPS', [TPSImport_XCollection]);
end;

(* === compile-time registration functions === *)
(*----------------------------------------------------------------------------*)
procedure SIRegister_TGLXCollection(CL: TPSPascalCompiler);
begin
  //with RegClassS(CL,'TPersistent', 'TGLXCollection') do
  with CL.AddClassN(CL.FindClass('TPersistent'),'TGLXCollection') do
  begin
    RegisterMethod('Constructor Create( aOwner : TPersistent)');
    RegisterMethod('Procedure Loaded');
    RegisterProperty('Owner', 'TPersistent', iptrw);
    RegisterMethod('Function ItemsClass : TGLXCollectionItemClass');
    RegisterProperty('Items', 'TGLXCollectionItem Integer', iptr);
    SetDefaultPropery('Items');
    RegisterProperty('Count', 'Integer', iptr);
    RegisterMethod('Function Add( anItem : TGLXCollectionItem) : Integer');
    RegisterMethod('Function GetOrCreate( anItem : TGLXCollectionItemClass) : TGLXCollectionItem');
    RegisterMethod('Procedure Delete( index : Integer)');
    RegisterMethod('Procedure Remove( anItem : TGLXCollectionItem)');
    RegisterMethod('Procedure Clear');
    RegisterMethod('Function IndexOf( anItem : TGLXCollectionItem) : Integer');
    RegisterMethod('Function IndexOfClass( aClass : TGLXCollectionItemClass) : Integer');
    RegisterMethod('Function GetByClass( aClass : TGLXCollectionItemClass) : TGLXCollectionItem');
    RegisterMethod('Function IndexOfName( const aName : String) : Integer');
    RegisterMethod('Function CanAdd( aClass : TGLXCollectionItemClass) : Boolean');
  end;
end;

(*----------------------------------------------------------------------------*)
procedure SIRegister_TGLXCollectionItem(CL: TPSPascalCompiler);
begin
  //with RegClassS(CL,'TPersistent', 'TGLXCollectionItem') do
  with CL.AddClassN(CL.FindClass('TPersistent'),'TGLXCollectionItem') do
  begin
    RegisterMethod('Constructor Create( aOwner : TGLXCollection)');
    RegisterProperty('Owner', 'TGLXCollection', iptr);
    RegisterMethod('Procedure MoveUp');
    RegisterMethod('Procedure MoveDown');
    RegisterMethod('Function Index : Integer');
    RegisterMethod('Function FriendlyName : String');
    RegisterMethod('Function FriendlyDescription : String');
    RegisterMethod('Function ItemCategory : String');
    RegisterMethod('Function UniqueItem : Boolean');
    RegisterMethod('Function CanAddTo( collection : TGLXCollection) : Boolean');
    RegisterProperty('Name', 'String', iptrw);
  end;
end;

(*----------------------------------------------------------------------------*)
procedure SIRegister_EFilerException(CL: TPSPascalCompiler);
begin
  //with RegClassS(CL,'Exception', 'EFilerException') do
  with CL.AddClassN(CL.FindClass('Exception'),'EFilerException') do
  begin
  end;
end;

(*----------------------------------------------------------------------------*)
procedure SIRegister_XCollection(CL: TPSPascalCompiler);
begin
  CL.AddClassN(CL.FindClass('TOBJECT'),'TGLXCollection');
  SIRegister_EFilerException(CL);
  SIRegister_TGLXCollectionItem(CL);
  //CL.AddTypeS('TGLXCollectionItemClass', 'class of TGLXCollectionItem');
  SIRegister_TGLXCollection(CL);
 CL.AddConstantN('cUnknownArchiveVersion','String').SetString( 'Unknown archive version : ');
 CL.AddDelphiFunction('Procedure RegisterXCollectionDestroyEvent( notifyEvent : TNotifyEvent)');
 CL.AddDelphiFunction('Procedure DeRegisterXCollectionDestroyEvent( notifyEvent : TNotifyEvent)');
{
 CL.AddDelphiFunction('Procedure RegisterXCollectionItemClass( aClass : TGLXCollectionItemClass)');
 CL.AddDelphiFunction('Procedure UnregisterXCollectionItemClass( aClass : TGLXCollectionItemClass)');
 CL.AddDelphiFunction('Function FindXCollectionItemClass( const className : String) : TGLXCollectionItemClass');
 CL.AddDelphiFunction('Function GetXCollectionItemClassesList( baseClass : TGLXCollectionItemClass) : TList');
}
end;

(* === run-time registration functions === *)
(*----------------------------------------------------------------------------*)
procedure TGLXCollectionCount_R(Self: TGLXCollection; var T: Integer);
begin T := Self.Count; end;

(*----------------------------------------------------------------------------*)
procedure TGLXCollectionItems_R(Self: TGLXCollection; var T: TGLXCollectionItem; const t1: Integer);
begin T := Self.Items[t1]; end;

(*----------------------------------------------------------------------------*)
procedure TGLXCollectionOwner_W(Self: TGLXCollection; const T: TPersistent);
begin Self.Owner := T; end;

(*----------------------------------------------------------------------------*)
procedure TGLXCollectionOwner_R(Self: TGLXCollection; var T: TPersistent);
begin T := Self.Owner; end;

(*----------------------------------------------------------------------------*)
procedure TGLXCollectionItemName_W(Self: TGLXCollectionItem; const T: String);
begin Self.Name := T; end;

(*----------------------------------------------------------------------------*)
procedure TGLXCollectionItemName_R(Self: TGLXCollectionItem; var T: String);
begin T := Self.Name; end;

(*----------------------------------------------------------------------------*)
procedure TGLXCollectionItemOwner_R(Self: TGLXCollectionItem; var T: TGLXCollection);
begin T := Self.Owner; end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_XCollection_Routines(S: TPSExec);
begin
 S.RegisterDelphiFunction(@RegisterXCollectionDestroyEvent, 'RegisterXCollectionDestroyEvent', cdRegister);
 S.RegisterDelphiFunction(@DeRegisterXCollectionDestroyEvent, 'DeRegisterXCollectionDestroyEvent', cdRegister);
{
 S.RegisterDelphiFunction(@RegisterXCollectionItemClass, 'RegisterXCollectionItemClass', cdRegister);
 S.RegisterDelphiFunction(@UnregisterXCollectionItemClass, 'UnregisterXCollectionItemClass', cdRegister);
 S.RegisterDelphiFunction(@FindXCollectionItemClass, 'FindXCollectionItemClass', cdRegister);
 S.RegisterDelphiFunction(@GetXCollectionItemClassesList, 'GetXCollectionItemClassesList', cdRegister);
}
end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_TGLXCollection(CL: TPSRuntimeClassImporter);
begin
  with CL.Add(TGLXCollection) do
  begin
    RegisterVirtualConstructor(@TGLXCollection.Create, 'Create');
    RegisterMethod(@TGLXCollection.Loaded, 'Loaded');
    RegisterPropertyHelper(@TGLXCollectionOwner_R,@TGLXCollectionOwner_W,'Owner');
    RegisterVirtualMethod(@TGLXCollection.ItemsClass, 'ItemsClass');
    RegisterPropertyHelper(@TGLXCollectionItems_R,nil,'Items');
    RegisterPropertyHelper(@TGLXCollectionCount_R,nil,'Count');
    RegisterMethod(@TGLXCollection.Add, 'Add');
    RegisterMethod(@TGLXCollection.GetOrCreate, 'GetOrCreate');
    RegisterMethod(@TGLXCollection.Delete, 'Delete');
    RegisterMethod(@TGLXCollection.Remove, 'Remove');
    RegisterMethod(@TGLXCollection.Clear, 'Clear');
    RegisterMethod(@TGLXCollection.IndexOf, 'IndexOf');
    RegisterMethod(@TGLXCollection.IndexOfClass, 'IndexOfClass');
    RegisterMethod(@TGLXCollection.GetByClass, 'GetByClass');
    RegisterMethod(@TGLXCollection.IndexOfName, 'IndexOfName');
    RegisterVirtualMethod(@TGLXCollection.CanAdd, 'CanAdd');
  end;
end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_TGLXCollectionItem(CL: TPSRuntimeClassImporter);
begin
  with CL.Add(TGLXCollectionItem) do
  begin
    RegisterVirtualConstructor(@TGLXCollectionItem.Create, 'Create');
    RegisterPropertyHelper(@TGLXCollectionItemOwner_R,nil,'Owner');
    RegisterMethod(@TGLXCollectionItem.MoveUp, 'MoveUp');
    RegisterMethod(@TGLXCollectionItem.MoveDown, 'MoveDown');
    RegisterMethod(@TGLXCollectionItem.Index, 'Index');
//    RegisterVirtualAbstractMethod(@TGLXCollectionItem, @!.FriendlyName, 'FriendlyName');
    RegisterVirtualMethod(@TGLXCollectionItem.FriendlyDescription, 'FriendlyDescription');
    RegisterVirtualMethod(@TGLXCollectionItem.ItemCategory, 'ItemCategory');
    RegisterVirtualMethod(@TGLXCollectionItem.UniqueItem, 'UniqueItem');
    RegisterVirtualMethod(@TGLXCollectionItem.CanAddTo, 'CanAddTo');
    RegisterPropertyHelper(@TGLXCollectionItemName_R,@TGLXCollectionItemName_W,'Name');
  end;
end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_EFilerException(CL: TPSRuntimeClassImporter);
begin
  with CL.Add(EFilerException) do
  begin
  end;
end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_XCollection(CL: TPSRuntimeClassImporter);
begin
  with CL.Add(TGLXCollection) do
  RIRegister_EFilerException(CL);
  RIRegister_TGLXCollectionItem(CL);
  RIRegister_TGLXCollection(CL);
end;

 
 
{ TPSImport_XCollection }
(*----------------------------------------------------------------------------*)
procedure TPSImport_XCollection.CompileImport1(CompExec: TPSScript);
begin
  SIRegister_XCollection(CompExec.Comp);
end;
(*----------------------------------------------------------------------------*)
procedure TPSImport_XCollection.ExecImport1(CompExec: TPSScript; const ri: TPSRuntimeClassImporter);
begin
  RIRegister_XCollection(ri);
  RIRegister_XCollection_Routines(CompExec.Exec); // comment it if no routines
end;
(*----------------------------------------------------------------------------*)
 
 
end.
