unit fmMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  TFooObject = class(TObject)
  private
    aIntf : IInterface;
    A : array of Integer;
    iFileHandle: Integer;
  public
    Destructor Destroy;
    Constructor Create;
//    Destructor DTOR;
  end;

  PPTypeInfo = ^PTypeInfo;
  PTypeInfo = ^TTypeInfo;
  TTypeInfo = packed record
    Kind: Byte;
    Name: ShortString;
   {TypeData: TTypeData}
  end;

  TFieldInfo = packed record
    TypeInfo: PPTypeInfo;
    Offset: Cardinal;
  end;

  PFieldTable = ^TFieldTable;
  TFieldTable = packed record
    X: Word;
    Size: Cardinal;
    Count: Cardinal;
    Fields: array [0..0] of TFieldInfo;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  obj : TFooObject;
  InitTable: Pointer;
  FT: PFieldTable;
  aPtr : TClass;
begin
  obj := TFooObject.Create;
  try
    SetLength(obj.A, 1);
    obj.A[0] := 1;

    ShowMessage(obj.ClassName);
    ShowMessage(IntToStr(obj.A[0]));

//    aPtr := obj.ClassType;
//    InitTable := PPointer(Integer(aPtr^) + vmtInitTable)^;
//    FT := PFieldTable(Integer(InitTable) + Byte(PTypeInfo(InitTable).Name[0]));
//    ShowMessage(IntToStr(FT.Count));

  finally // wrap up
//    FreeAndNil(obj);
    obj.Free;
//    obj.DTOR;
  end;    // try/finally
end;

{ TFooObject }


destructor TFooObject.Destroy;
begin
  FileClose(iFileHandle);
  aIntf := nil;
  inherited;
end;


constructor TFooObject.Create;
begin
  iFileHandle := FileOpen('test.dat', fmCreate or fmOpenReadWrite);
end;

{
destructor TFooObject.DTOR;
begin
  FileClose(iFileHandle);
  inherited Destroy;
end;
}
end.
