Browse Source

+ add TRttiNamedObject.Handle property of which the getter needs to be overridden in each sub class

git-svn-id: trunk@37401 -
svenbarth 7 years ago
parent
commit
5c85e94919
1 changed files with 14 additions and 0 deletions
  1. 14 0
      packages/rtl-objpas/src/inc/rtti.pp

+ 14 - 0
packages/rtl-objpas/src/inc/rtti.pp

@@ -163,8 +163,10 @@ type
   TRttiNamedObject = class(TRttiObject)
   protected
     function GetName: string; virtual;
+    function GetHandle: Pointer; virtual; abstract;
   public
     property Name: string read GetName;
+    property Handle: Pointer read GetHandle;
   end;
 
   { TRttiType }
@@ -178,6 +180,7 @@ type
   protected
     FTypeData: PTypeData;
     function GetName: string; override;
+    function GetHandle: Pointer; override;
     function GetIsInstance: boolean; virtual;
     function GetIsManaged: boolean; virtual;
     function GetIsOrdinal: boolean; virtual;
@@ -270,6 +273,7 @@ type
   protected
     function GetVisibility: TMemberVisibility; override;
     function GetName: string; override;
+    function GetHandle: Pointer; override;
   public
     constructor create(AParent: TRttiType; APropInfo: PPropInfo);
     function GetValue(Instance: pointer): TValue;
@@ -1616,6 +1620,11 @@ begin
   Result:=FPropInfo^.Name;
 end;
 
+function TRttiProperty.GetHandle: Pointer;
+begin
+  Result := FPropInfo;
+end;
+
 constructor TRttiProperty.create(AParent: TRttiType; APropInfo: PPropInfo);
 begin
   inherited create(AParent);
@@ -1821,6 +1830,11 @@ begin
   Result:=FTypeInfo^.Name;
 end;
 
+function TRttiType.GetHandle: Pointer;
+begin
+  Result := FTypeInfo;
+end;
+
 constructor TRttiType.create(ATypeInfo: PTypeInfo);
 begin
   inherited create();