unit Intf;
interface
uses
  SysUtils, Classes, Dialogs, PaxCompiler, PaxRegister;

type
  ITest = interface
  ['{E7AA427A-0F4D-4A96-A914-FAB1CA336337}']
    function GetProp: Integer; stdcall; //4
    function GetString: String;  //5
    property Prop: Integer read GetProp;
  end;

  TTest = class(TInterfacedObject, ITest)
  private
    fStr: String;
  public
    function GetProp: Integer; stdcall;
    constructor Create;
    destructor Destroy; override;
    function GetString: String;
    property Prop: Integer read GetProp;
  end;

function GetIntf: ITest; stdcall;

implementation

function GetIntf: ITest; stdcall;
begin
  result := TTest.Create;
end;

function TTest.GetProp: Integer; stdcall;
begin
  result := 123;
end;

constructor TTest.Create;
begin
  fStr := 'abc';
end;

destructor TTest.Destroy;
begin
  ShowMessage('Done');
  inherited;
end;

function TTest.GetString: String;
begin
  result := 'abc';
end;

var
  H_TTest, H_ITest: Integer;

initialization

  H_TTest := RegisterClassType(0, TTest);
  RegisterHeader(H_TTest, 'constructor Create;', @ TTest.Create);
  RegisterHeader(H_TTest, 'function GetProp: Integer; stdcall;', @ TTest.GetProp);

  H_ITest := RegisterInterfaceType(0, 'ITest', ITest);
  RegisterHeader(H_ITest, 'function GetProp: Integer; stdcall;', nil, 4);
  RegisterHeader(H_ITest, 'property Prop: Integer read GetProp;', nil);
  RegisterHeader(H_ITest, 'function GetString: String;', nil, 5);

  RegisterHeader(0, 'function GetIntf: ITest; stdcall;', @ GetIntf);
end.
