mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-16 13:29:09 +02:00
rtl: TRttiClassRefType for tkClassRef, issue 38571, from henrique
This commit is contained in:
parent
17df322ecd
commit
01992a59d5
@ -342,6 +342,20 @@ type
|
|||||||
property RecordTypeInfo: TTypeInfoRecord read GetRecordTypeInfo;
|
property RecordTypeInfo: TTypeInfoRecord read GetRecordTypeInfo;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TRttiClassRefType }
|
||||||
|
TRttiClassRefType = class(TRttiType)
|
||||||
|
private
|
||||||
|
function GetClassRefTypeInfo: TTypeInfoClassRef;
|
||||||
|
function GetInstanceType: TRttiInstanceType;
|
||||||
|
function GetMetaclassType: TClass;
|
||||||
|
public
|
||||||
|
constructor Create(ATypeInfo: PTypeInfo);
|
||||||
|
|
||||||
|
property ClassRefTypeInfo: TTypeInfoClassRef read GetClassRefTypeInfo;
|
||||||
|
property InstanceType: TRttiInstanceType read GetInstanceType;
|
||||||
|
property MetaclassType: TClass read GetMetaclassType;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TRttiOrdinalType }
|
{ TRttiOrdinalType }
|
||||||
|
|
||||||
TRttiOrdinalType = class(TRttiType)
|
TRttiOrdinalType = class(TRttiType)
|
||||||
@ -1089,6 +1103,31 @@ begin
|
|||||||
inherited Create(ATypeInfo);
|
inherited Create(ATypeInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TRttiClassRefType }
|
||||||
|
|
||||||
|
constructor TRttiClassRefType.Create(ATypeInfo: PTypeInfo);
|
||||||
|
begin
|
||||||
|
if not (TTypeInfo(ATypeInfo) is TTypeInfoClassRef) then
|
||||||
|
raise EInvalidCast.Create('');
|
||||||
|
|
||||||
|
inherited Create(ATypeInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TRttiClassRefType.GetClassRefTypeInfo: TTypeInfoClassRef;
|
||||||
|
begin
|
||||||
|
Result := TTypeInfoClassRef(FTypeInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TRttiClassRefType.GetInstanceType: TRttiInstanceType;
|
||||||
|
begin
|
||||||
|
Result := GRttiContext.GetType(ClassRefTypeInfo.InstanceType) as TRttiInstanceType;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TRttiClassRefType.GetMetaclassType: TClass;
|
||||||
|
begin
|
||||||
|
Result := InstanceType.MetaClassType;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TRTTIContext }
|
{ TRTTIContext }
|
||||||
|
|
||||||
class constructor TRTTIContext.Init;
|
class constructor TRTTIContext.Init;
|
||||||
@ -1131,7 +1170,7 @@ var
|
|||||||
TRttiDynamicArrayType, // tkDynArray
|
TRttiDynamicArrayType, // tkDynArray
|
||||||
TRttiRecordType, // tkRecord
|
TRttiRecordType, // tkRecord
|
||||||
TRttiInstanceType, // tkClass
|
TRttiInstanceType, // tkClass
|
||||||
TRttiType, // tkClassRef
|
TRttiClassRefType, // tkClassRef
|
||||||
TRttiType, // tkPointer
|
TRttiType, // tkPointer
|
||||||
TRttiType, // tkJSValue
|
TRttiType, // tkJSValue
|
||||||
TRttiType, // tkRefToProcVar
|
TRttiType, // tkRefToProcVar
|
||||||
|
Loading…
Reference in New Issue
Block a user