Pascal samples. Script-defined interface types.


program Test;
type
  IMyInterface = interface(IUnknown)
  ['{E7AA427A-0F4D-4A96-A914-FAB1CA336337}']
    procedure P(X, Y: Integer); cdecl;
  end;
  TMyClass = class(TInterfacedObject, IMyInterface)
    procedure P(X, Y: Integer); cdecl;
    destructor Destroy; override;
  end;
procedure TMyClass.P(X, Y: Integer);
begin
  writeln(Self.ClassName);
  writeln(X, ' ', Y);
end;
destructor TMyClass.Destroy;
begin
  writeln('Done');
  inherited;
end;
var
  I: IMyInterface;
  X: TMyClass;
begin
  X := TMyClass.Create;
  I := X;
  I.P(3, 4);
end.


Copyright © 2006-2017 Alexander Baranovsky. All rights reserved.