mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-23 06:49:26 +02:00
* Added interfacedobject
This commit is contained in:
parent
d3e2e69826
commit
17ff9cfaf5
@ -186,6 +186,20 @@ type
|
||||
end;
|
||||
TPersistentClass = Class of TPersistent;
|
||||
|
||||
{ TInterfacedPersistent }
|
||||
|
||||
TInterfacedPersistent = class(TPersistent, IInterface)
|
||||
private
|
||||
FOwnerInterface: IInterface;
|
||||
protected
|
||||
function _AddRef: Integer;
|
||||
function _Release: Integer;
|
||||
public
|
||||
function QueryInterface(const IID: TGUID; out Obj): integer; virtual;
|
||||
procedure AfterConstruction; override;
|
||||
end;
|
||||
|
||||
|
||||
TStrings = Class;
|
||||
{ TStringsEnumerator class }
|
||||
|
||||
@ -579,6 +593,37 @@ implementation
|
||||
|
||||
uses JS;
|
||||
|
||||
{ TInterfacedPersistent }
|
||||
|
||||
function TInterfacedPersistent._AddRef: Integer;
|
||||
begin
|
||||
Result:=-1;
|
||||
if Assigned(FOwnerInterface) then
|
||||
Result:=FOwnerInterface._AddRef;
|
||||
end;
|
||||
|
||||
function TInterfacedPersistent._Release: Integer;
|
||||
|
||||
begin
|
||||
Result:=-1;
|
||||
if Assigned(FOwnerInterface) then
|
||||
Result:=FOwnerInterface._Release;
|
||||
end;
|
||||
|
||||
function TInterfacedPersistent.QueryInterface(const IID: TGUID; out Obj): integer;
|
||||
begin
|
||||
Result:=E_NOINTERFACE;
|
||||
if GetInterface(IID, Obj) then
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
procedure TInterfacedPersistent.AfterConstruction;
|
||||
begin
|
||||
inherited AfterConstruction;
|
||||
if (GetOwner<>nil) then
|
||||
GetOwner.GetInterface(IInterface, FOwnerInterface);
|
||||
end;
|
||||
|
||||
{ TComponentEnumerator }
|
||||
|
||||
constructor TComponentEnumerator.Create(AComponent: TComponent);
|
||||
|
Loading…
Reference in New Issue
Block a user