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

{ compile-time registration functions }
procedure SIRegister_TSQLQuery(CL: TPSPascalCompiler);
procedure SIRegister_TSQLConnection(CL: TPSPascalCompiler);
procedure SIRegister(CL: TPSPascalCompiler);

{ run-time registration functions }
procedure RIRegister_TSQLQuery(CL: TPSRuntimeClassImporter);
procedure RIRegister_TSQLConnection(CL: TPSRuntimeClassImporter);
procedure RIRegister(CL: TPSRuntimeClassImporter);

function PSPluginCreate(): TPSPlugin; stdcall;


implementation


uses
   DB,
  FireDAC.Stan.Intf, FireDAC.Stan.Option,
  FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
  FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.VCLUI.Wait,
  FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt,
  FireDAC.Comp.DataSet, FireDAC.Comp.Client, SQLConnection;


function PSPluginCreate(): TPSPlugin; stdcall;
var
  Import: TPSDBExtensionImport;
begin
  Import:= TPSDBExtensionImport.Create(nil);
  Result := Import;
end;
(* === compile-time registration functions === *)
(*----------------------------------------------------------------------------*)
procedure SIRegister_TSQLQuery(CL: TPSPascalCompiler);
var
  psClass: TPSCompileTimeClass;
begin
  //with RegClassS(CL,'TObject', 'TSQLQuery') do
  psClass := CL.AddClassN(CL.FindClass('TObject'),'TSQLQuery');
  psClass.RegisterMethod('Constructor Create');
  psClass.RegisterMethod('Procedure Open');
  psClass.RegisterMethod('Procedure Close');
  psClass.RegisterMethod('Procedure Next');
  psClass.RegisterMethod('Procedure First');
  psClass.RegisterMethod('Procedure Last');
  psClass.RegisterMethod('Procedure Previous');
  psClass.RegisterMethod('Procedure Append');
  psClass.RegisterMethod('Procedure Edit');
  psClass.RegisterMethod('Procedure Post');
  psClass.RegisterMethod('procedure ExecSQL');
  psClass.RegisterMethod('Function Eof : boolean');
  psClass.RegisterMethod('Function FieldByNameAsBoolean( FieldName : string) : Boolean');
  psClass.RegisterMethod('Function FieldByNameAsDateTime( FieldName : string) : TDateTime');
  psClass.RegisterMethod('Function FieldByNameAsFloat( FieldName : string) : Double');
  psClass.RegisterMethod('Function FieldByNameAsInteger( FieldName : string) : Longint');
  psClass.RegisterMethod('Function FieldByNameAsString( FieldName : string) : string');
  psClass.RegisterProperty('Active', 'boolean', iptrw);
  psClass.RegisterProperty('SQL', 'TStrings', iptr);
  psClass.RegisterProperty('Connection', 'TSQLConnection', iptrw);
end;

(*----------------------------------------------------------------------------*)
procedure SIRegister_TSQLConnection(CL: TPSPascalCompiler);
begin
  //with RegClassS(CL,'TObject', 'TSQLConnection') do
  with CL.AddClassN(CL.FindClass('TObject'),'TSQLConnection') do
  begin
    RegisterMethod('Constructor Create');
    RegisterMethod('Procedure Open( )');
    RegisterMethod('Procedure Close( )');
    RegisterProperty('ProviderName', 'AnsiString', iptrw);
    RegisterProperty('UserName', 'AnsiString', iptrw);
    RegisterProperty('Password', 'AnsiString', iptrw);
    RegisterProperty('Server', 'AnsiString', iptrw);
    RegisterProperty('Database', 'AnsiString', iptrw);
    RegisterProperty('Connected', 'boolean', iptrw);
    RegisterProperty('Port', 'boolean', iptrw);
  end;
end;

(*----------------------------------------------------------------------------*)
procedure SIRegister(CL: TPSPascalCompiler);
begin
  SIRegister_TSQLConnection(CL);
  SIRegister_TSQLQuery(CL);
end;

(* === run-time registration functions === *)
(*----------------------------------------------------------------------------*)
procedure TSQLQueryConnection_W(Self: TSQLQuery; const T: TSQLConnection);
begin Self.Connection := T; end;

(*----------------------------------------------------------------------------*)
procedure TSQLQueryConnection_R(Self: TSQLQuery; var T: TSQLConnection);
begin T := Self.Connection; end;

(*----------------------------------------------------------------------------*)
procedure TSQLQuerySQL_R(Self: TSQLQuery; var T: TStrings);
begin T := Self.SQL; end;

(*----------------------------------------------------------------------------*)
procedure TSQLQueryActive_W(Self: TSQLQuery; const T: boolean);
begin Self.Active := T; end;

(*----------------------------------------------------------------------------*)
procedure TSQLQueryActive_R(Self: TSQLQuery; var T: boolean);
begin T := Self.Active; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionConnected_W(Self: TSQLConnection; const T: boolean);
begin Self.Connected := T; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionConnected_R(Self: TSQLConnection; var T: boolean);
begin T := Self.Connected; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionDatabase_W(Self: TSQLConnection; const T: AnsiString);
begin Self.Database := T; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionDatabase_R(Self: TSQLConnection; var T: AnsiString);
begin T := Self.Database; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionServer_W(Self: TSQLConnection; const T: AnsiString);
begin Self.Server := T; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionServer_R(Self: TSQLConnection; var T: AnsiString);
begin T := Self.Server; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionPassword_W(Self: TSQLConnection; const T: AnsiString);
begin Self.Password := T; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionPassword_R(Self: TSQLConnection; var T: AnsiString);
begin T := Self.Password; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionUserName_W(Self: TSQLConnection; const T: AnsiString);
begin Self.UserName := T; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionUserName_R(Self: TSQLConnection; var T: AnsiString);
begin T := Self.UserName; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionProviderName_W(Self: TSQLConnection; const T: AnsiString);
begin Self.ProviderName := T; end;

(*----------------------------------------------------------------------------*)
procedure TSQLConnectionProviderName_R(Self: TSQLConnection; var T: AnsiString);
begin T := Self.ProviderName; end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_TSQLQuery(CL: TPSRuntimeClassImporter);
var
  psClass : TPSRuntimeClass;
begin
  psClass := CL.Add(TSQLQuery);
  psClass.RegisterConstructor(@TSQLQuery.Create, 'Create');
  psClass.RegisterMethod(@TSQLQuery.Open, 'Open');
  psClass.RegisterMethod(@TSQLQuery.Close, 'Close');
  psClass.RegisterMethod(@TSQLQuery.Next, 'Next');
  psClass.RegisterMethod(@TSQLQuery.First, 'First');
  psClass.RegisterMethod(@TSQLQuery.Last, 'Last');
  psClass.RegisterMethod(@TSQLQuery.Previous, 'Previous');
  psClass.RegisterMethod(@TSQLQuery.Append, 'Append');
  psClass.RegisterMethod(@TSQLQuery.Edit, 'Edit');
  psClass.RegisterMethod(@TSQLQuery.Post, 'Post');
  psClass.RegisterMethod(@TSQLQuery.ExecSQL, 'ExecSQL');
  psClass.RegisterMethod(@TSQLQuery.Eof, 'Eof');
  psClass.RegisterMethod(@TSQLQuery.FieldByNameAsBoolean, 'FieldByNameAsBoolean');
  psClass.RegisterMethod(@TSQLQuery.FieldByNameAsDateTime, 'FieldByNameAsDateTime');
  psClass.RegisterMethod(@TSQLQuery.FieldByNameAsFloat, 'FieldByNameAsFloat');
  psClass.RegisterMethod(@TSQLQuery.FieldByNameAsInteger, 'FieldByNameAsInteger');
  psClass.RegisterMethod(@TSQLQuery.FieldByNameAsString, 'FieldByNameAsString');
  psClass.RegisterPropertyHelper(@TSQLQueryActive_R,@TSQLQueryActive_W,'Active');
  psClass.RegisterPropertyHelper(@TSQLQuerySQL_R,nil,'SQL');
  psClass.RegisterPropertyHelper(@TSQLQueryConnection_R,@TSQLQueryConnection_W,'Connection');

end;

(*----------------------------------------------------------------------------*)
procedure RIRegister_TSQLConnection(CL: TPSRuntimeClassImporter);
var
  psClass : TPSRuntimeClass;
begin
  psClass := CL.Add(TSQLConnection);
  psClass.RegisterConstructor(@TSQLConnection.Create, 'Create');
  psClass.RegisterMethod(@TSQLConnection.Open, 'Open');
  psClass.RegisterMethod(@TSQLConnection.Close, 'Close');
  psClass.RegisterPropertyHelper(@TSQLConnectionProviderName_R,@TSQLConnectionProviderName_W,'ProviderName');
  psClass.RegisterPropertyHelper(@TSQLConnectionUserName_R,@TSQLConnectionUserName_W,'UserName');
  psClass.RegisterPropertyHelper(@TSQLConnectionPassword_R,@TSQLConnectionPassword_W,'Password');
  psClass.RegisterPropertyHelper(@TSQLConnectionServer_R,@TSQLConnectionServer_W,'Server');
  psClass.RegisterPropertyHelper(@TSQLConnectionDatabase_R,@TSQLConnectionDatabase_W,'Database');
  psClass.RegisterPropertyHelper(@TSQLConnectionConnected_R,@TSQLConnectionConnected_W,'Connected');
  psClass.RegisterPropertyHelper(@TSQLConnectionPort_R,@TSQLConnectionPort_W,'Port');
end;

(*----------------------------------------------------------------------------*)
procedure RIRegister(CL: TPSRuntimeClassImporter);
begin
  RIRegister_TSQLConnection(CL);
  RIRegister_TSQLQuery(CL);
end;

{ TPSImport_SQLConnection }
(*----------------------------------------------------------------------------*)
procedure TPSDBExtensionImport.CompileImport1(CompExec: TPSScript);
begin
  SIRegister(CompExec.Comp);
end;
(*----------------------------------------------------------------------------*)
procedure TPSDBExtensionImport.ExecImport1(CompExec: TPSScript; const ri: TPSRuntimeClassImporter);
begin
  RIRegister(ri);
end;
(*----------------------------------------------------------------------------*)




end.
