Browse Source

+ add methods to easily access a context token's AddObject() and GetByHandle() methods inside the Rtti unit

git-svn-id: trunk@37759 -
svenbarth 7 years ago
parent
commit
6c02433e1e
1 changed files with 17 additions and 0 deletions
  1. 17 0
      packages/rtl-objpas/src/inc/rtti.pp

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

@@ -41,6 +41,7 @@ uses
   typinfo;
 
 type
+  TRttiObject = class;
   TRttiType = class;
   TRttiProperty = class;
   TRttiInstanceType = class;
@@ -143,6 +144,8 @@ type
   TRttiContext = record
   private
     FContextToken: IInterface;
+    function GetByHandle(AHandle: Pointer): TRttiObject;
+    procedure AddObject(AObject: TRttiObject);
   public
     class function Create: TRttiContext; static;
     procedure  Free;
@@ -2350,6 +2353,20 @@ begin
   FContextToken := nil;
 end;
 
+function TRttiContext.GetByHandle(AHandle: Pointer): TRttiObject;
+begin
+  if not Assigned(FContextToken) then
+    FContextToken := TPoolToken.Create;
+  Result := (FContextToken as IPooltoken).RttiPool.GetByHandle(AHandle);
+end;
+
+procedure TRttiContext.AddObject(AObject: TRttiObject);
+begin
+  if not Assigned(FContextToken) then
+    FContextToken := TPoolToken.Create;
+  (FContextToken as IPooltoken).RttiPool.AddObject(AObject);
+end;
+
 function TRttiContext.GetType(ATypeInfo: PTypeInfo): TRttiType;
 begin
   if not assigned(FContextToken) then