Keywords as basic scalar type

This commit is contained in:
Michael Schimmel
2025-10-31 21:15:08 +01:00
parent 8abec8e98f
commit 689dede600
9 changed files with 292 additions and 264 deletions
+38
View File
@@ -18,6 +18,18 @@ type
class operator Implicit(const Upvalue: TManaged<T>): T; overload;
end;
TGenericContainedObject<T: TInterfacedObject> = class(TObject, IInterface)
private
FController: TInterfacedObject;
protected
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
property Controller: TInterfacedObject read FController;
public
constructor Create(AController: TInterfacedObject);
end;
implementation
constructor TManaged<T>.TObj.Create(AValue: T);
@@ -42,4 +54,30 @@ begin
Result := (Upvalue.FIntf as TObj).FValue;
end;
constructor TGenericContainedObject<T>.Create(AController: TInterfacedObject);
begin
inherited Create;
FController := AController;
end;
{ TGenericContainedObject }
function TGenericContainedObject<T>.QueryInterface(const IID: TGUID; out Obj): HResult;
begin
if GetInterface(IID, Obj) then
Result := S_OK
else
Result := E_NOINTERFACE;
end;
function TGenericContainedObject<T>._AddRef: Integer;
begin
Result := IInterface(FController)._AddRef;
end;
function TGenericContainedObject<T>._Release: Integer;
begin
Result := IInterface(FController)._Release;
end;
end.