unit uIdTCPConnection;

interface

uses Classes, Rubies;

var
  cIdTCPConnection: Tvalue;

function ap_cIdTCPConnection: Tvalue;
procedure Init_IdTCPConnection;

implementation

uses
  SysUtils, uDefUtils, Pythia, IdTCPConnection, IdHandle, uIndy, uIdComponent;

function ap_cIdTCPConnection: Tvalue;
begin
  result := cIdTCPConnection;
end;

procedure IdTCPConnection_setup(obj: Tvalue; real: TIdTCPConnection);
begin
  ap_set_child_attr_module(obj);
end;

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

function IdTCPConnection_connected(This: Tvalue): Tvalue; cdecl;
var
  real: TIdTCPConnection;
begin
  real := ap_data_get_struct(This);
  result := ap_bool(real.Connected);
end;

procedure Init_IdTCPConnection;
begin
  cIdTCPConnection := rb_define_class_under(mIndy, 'IdTCPConnection', cIdComponent);
  DefineProp(cIdTCPConnection, TIdTCPConnection);
  rb_define_method(cIdTCPConnection, 'event_handle', @IdTCPConnection_event_handle, 1);
  rb_define_method(cIdTCPConnection, 'connected', @IdTCPConnection_connected, 0);
end;

end.
