Explorar o código

+ add data record for easier access to a class' data

git-svn-id: trunk@37420 -
svenbarth %!s(int64=7) %!d(string=hai) anos
pai
achega
1ae344394a
Modificáronse 1 ficheiros con 35 adicións e 0 borrados
  1. 35 0
      rtl/objpas/typinfo.pp

+ 35 - 0
rtl/objpas/typinfo.pp

@@ -426,6 +426,26 @@ unit typinfo;
         { PropertyTable: TPropData }
       end;
 
+      PClassData = ^TClassData;
+      TClassData =
+      {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
+      packed
+      {$endif FPC_REQUIRES_PROPER_ALIGNMENT}
+      record
+      private
+        function GetUnitName: ShortString; inline;
+        function GetPropertyTable: PPropData; inline;
+      public
+        ClassType : TClass;
+        Parent : PPTypeInfo;
+        PropCount : SmallInt;
+        property UnitName: ShortString read GetUnitName;
+        property PropertyTable: PPropData read GetPropertyTable;
+      private
+        UnitNameField : ShortString;
+        { PropertyTable: TPropData }
+      end;
+
       PTypeData = ^TTypeData;
       TTypeData =
 {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
@@ -2851,6 +2871,21 @@ begin
   Result := aligntoptr(PropertyTable^.Tail);
 end;
 
+{ TClassData }
+
+function TClassData.GetUnitName: ShortString;
+begin
+  Result := UnitNameField;
+end;
+
+function TClassData.GetPropertyTable: PPropData;
+var
+  p: PByte;
+begin
+  p := PByte(@UnitNameField[0]) + SizeOf(UnitNameField[0]) + Length(UnitNameField);
+  Result := AlignTypeData(p);
+end;
+
 { TTypeData }
 
 function TTypeData.GetBaseType: PTypeInfo;