mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-20 13:09:06 +02:00
* Added interfacedobject
This commit is contained in:
parent
d3e2e69826
commit
17ff9cfaf5
@ -186,6 +186,20 @@ type
|
|||||||
end;
|
end;
|
||||||
TPersistentClass = Class of TPersistent;
|
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;
|
TStrings = Class;
|
||||||
{ TStringsEnumerator class }
|
{ TStringsEnumerator class }
|
||||||
|
|
||||||
@ -579,6 +593,37 @@ implementation
|
|||||||
|
|
||||||
uses JS;
|
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 }
|
{ TComponentEnumerator }
|
||||||
|
|
||||||
constructor TComponentEnumerator.Create(AComponent: TComponent);
|
constructor TComponentEnumerator.Create(AComponent: TComponent);
|
||||||
|
Loading…
Reference in New Issue
Block a user