View Issue Details

IDProjectCategoryView StatusLast Update
0038571pas2jsrtlpublic2021-03-02 14:58
Reporterhenrique Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformPas2JsOSWindows 
Summary0038571: ClassRef RTTI Info
DescriptionI implemented the load of ClassRef information in RTTI.

Can be closed the change 0038457 I made the change here.
TagsNo tags attached.
Fixed in Revision1094.
Attached Files

Activities

henrique

2021-03-02 14:17

reporter  

0001-RTTI-Class-ref.patch (2,214 bytes)   
From 86c743b84df972227039b655b7e98543a90bfd27 Mon Sep 17 00:00:00 2001
From: Henrique Gottardi Werlang <henriquewerlang@hotmail.com>
Date: Tue, 2 Mar 2021 10:10:38 -0300
Subject: [PATCH] RTTI Class ref.

---
 packages/rtl/rtti.pas | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/packages/rtl/rtti.pas b/packages/rtl/rtti.pas
index 72d3714..219b626 100644
--- a/packages/rtl/rtti.pas
+++ b/packages/rtl/rtti.pas
@@ -342,6 +342,20 @@ type
     property RecordTypeInfo: TTypeInfoRecord read GetRecordTypeInfo;
   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 = class(TRttiType)
@@ -1089,6 +1103,31 @@ begin
   inherited Create(ATypeInfo);
 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 }
 
 class constructor TRTTIContext.Init;
@@ -1131,7 +1170,7 @@ var
     TRttiDynamicArrayType, // tkDynArray
     TRttiRecordType, // tkRecord
     TRttiInstanceType, // tkClass
-    TRttiType, // tkClassRef
+    TRttiClassRefType, // tkClassRef
     TRttiType, // tkPointer
     TRttiType, // tkJSValue
     TRttiType, // tkRefToProcVar
-- 
2.30.0.windows.1

0001-RTTI-Class-ref.patch (2,214 bytes)   

Mattias Gaertner

2021-03-02 14:58

manager   ~0129320

Thank You!

Issue History

Date Modified Username Field Change
2021-03-02 14:17 henrique New Issue
2021-03-02 14:17 henrique File Added: 0001-RTTI-Class-ref.patch
2021-03-02 14:29 Michael Van Canneyt Assigned To => Mattias Gaertner
2021-03-02 14:29 Michael Van Canneyt Status new => assigned
2021-03-02 14:58 Mattias Gaertner Status assigned => resolved
2021-03-02 14:58 Mattias Gaertner Resolution open => fixed
2021-03-02 14:58 Mattias Gaertner Fixed in Revision => 1094.
2021-03-02 14:58 Mattias Gaertner Note Added: 0129320