View Issue Details

IDProjectCategoryView StatusLast Update
0038361pas2jsrtlpublic2021-01-15 18:14
Reporterhenrique Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformPas2JsOSWindows 
Summary0038361: AsInstance RTTI Implementation
DescriptionI've attached the implementation of AsInstance in the RTTI unit.
TagsNo tags attached.
Fixed in Revision1061.
Attached Files

Activities

henrique

2021-01-15 12:40

reporter  

0001-Implementado-AsInstance.patch (2,501 bytes)   
From f294a2778193ef3a0bc4a2d2fdf9bb94560cb229 Mon Sep 17 00:00:00 2001
From: Henrique Gottardi Werlang <henriquewerlang@hotmail.com>
Date: Fri, 15 Jan 2021 08:19:47 -0300
Subject: [PATCH] Implementado AsInstance.

---
 packages/rtl/rtti.pas | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/packages/rtl/rtti.pas b/packages/rtl/rtti.pas
index 6dbf186..13d5233 100644
--- a/packages/rtl/rtti.pas
+++ b/packages/rtl/rtti.pas
@@ -67,6 +67,7 @@ type
   end;
 
   TRttiType = class;
+  TRttiInstanceType = class;
 
   { TRTTIContext }
 
@@ -199,11 +200,11 @@ type
     FAttributes: TCustomAttributeArray;
     FTypeInfo: TTypeInfo;
     //FMethods: specialize TArray<TRttiMethod>;
-    //function GetAsInstance: TRttiInstanceType;
+    function GetAsInstance: TRttiInstanceType;
   protected
     function GetName: string; override;
     //function GetHandle: Pointer; override;
-    function GetIsInstance: boolean; virtual;
+    function GetIsInstance: boolean;
     //function GetIsManaged: boolean; virtual;
     function GetIsOrdinal: boolean; virtual;
     function GetIsRecord: boolean; virtual;
@@ -234,7 +235,7 @@ type
     property IsRecord: boolean read GetIsRecord;
     property IsSet: boolean read GetIsSet;
     //property BaseType: TRttiType read GetBaseType;
-    //property AsInstance: TRttiInstanceType read GetAsInstance;
+    property AsInstance: TRttiInstanceType read GetAsInstance;
     property TypeKind: TTypeKind read GetTypeKind;
     //property TypeSize: integer read GetTypeSize;
   end;
@@ -274,7 +275,6 @@ type
     function GetMetaClassType: TClass;
   protected
     function GetAncestor: TRttiStructuredType; override;
-    function GetIsInstance: boolean; override;
   public
     constructor Create(ATypeInfo: PTypeInfo);
 
@@ -929,11 +929,6 @@ begin
   inherited Create(ATypeInfo);
 end;
 
-function TRttiInstanceType.GetIsInstance: boolean;
-begin
-  Result:=True;
-end;
-
 { TRttiInterfaceType }
 
 constructor TRttiInterfaceType.Create(ATypeInfo: PTypeInfo);
@@ -1218,7 +1213,7 @@ end;
 
 function TRttiType.GetIsInstance: boolean;
 begin
-  Result:=false;
+  Result:=Self is TRttiInstanceType;
 end;
 
 function TRttiType.GetIsOrdinal: boolean;
@@ -1241,6 +1236,11 @@ begin
   Result:=FTypeInfo.Kind;
 end;
 
+function TRttiType.GetAsInstance: TRttiInstanceType;
+begin
+  Result := Self as TRttiInstanceType;
+end;
+
 constructor TRttiType.Create(ATypeInfo: PTypeInfo);
 begin
   inherited Create();
-- 
2.30.0.windows.1

Mattias Gaertner

2021-01-15 18:14

manager   ~0128359

Applied.

Issue History

Date Modified Username Field Change
2021-01-15 12:40 henrique New Issue
2021-01-15 12:40 henrique File Added: 0001-Implementado-AsInstance.patch
2021-01-15 18:14 Mattias Gaertner Assigned To => Mattias Gaertner
2021-01-15 18:14 Mattias Gaertner Status new => resolved
2021-01-15 18:14 Mattias Gaertner Resolution open => fixed
2021-01-15 18:14 Mattias Gaertner Fixed in Revision => 1061.
2021-01-15 18:14 Mattias Gaertner Note Added: 0128359