unit uIdFTP;

interface

uses Classes, IdFTP, Rubies;

var
  cIdFTP: Tvalue;

function ap_cIdFTP: Tvalue;
function ap_iIdFTP(real: TIdFTP; owner: Tvalue): Tvalue;
procedure Init_IdFTP;

implementation

uses
  SysUtils, uDefUtils, Pythia, IdHandle, uIndy, uIdTCPClient;

function ap_cIdFTP: Tvalue;
begin
  result := cIdFTP;
end;

procedure IdFTP_setup(obj: Tvalue; real: TIdFTP);
begin
end;

function IdFTP_event_handle(This, name: Tvalue): Tvalue; cdecl;
begin
  EventHandle(This, name, [Handle, PhiGetHandle]);
  result := Qnil;
end;

function IdFTP_alloc(This: Tvalue; real: TIdFTP): Tvalue;
begin
  result := ChildAlloc(This, real);
  IdFTP_setup(result, real);
end;

function ap_iIdFTP(real: TIdFTP; owner: Tvalue): Tvalue;
begin
  result := IdFTP_alloc(cIdFTP, real);
  ap_owner(result, owner);
end;

function ap_iIdFTP_v(var obj; owner: Tvalue): Tvalue;
begin
  result := ap_iIdFTP(TIdFTP(obj), owner);
end;

function IdFTP_allocate(This: Tvalue): Tvalue; cdecl;
var
  real: TIdFTP;
begin
  real := TIdFTP.Create(nil);
  result := CompoAlloc(This, real);
  IdFTP_setup(result, real);
end;

procedure Init_IdFTP;
begin
  cIdFTP := DefinePersistentClass(mIndy, TIdFTP, cIdTCPClient, ap_iIdFTP_v);
  rb_define_alloc_func(cIdFTP, @IdFTP_allocate);
  rb_define_method(cIdFTP, 'event_handle', @IdFTP_event_handle, 1);
end;

end.
