소스 검색

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

git-svn-id: trunk@37420 -
svenbarth 7 년 전
부모
커밋
1ae344394a
1개의 변경된 파일35개의 추가작업 그리고 0개의 파일을 삭제
  1. 35 0
      rtl/objpas/typinfo.pp

+ 35 - 0
rtl/objpas/typinfo.pp

@@ -426,6 +426,26 @@ unit typinfo;
         { PropertyTable: TPropData }
         { PropertyTable: TPropData }
       end;
       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;
       PTypeData = ^TTypeData;
       TTypeData =
       TTypeData =
 {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
 {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
@@ -2851,6 +2871,21 @@ begin
   Result := aligntoptr(PropertyTable^.Tail);
   Result := aligntoptr(PropertyTable^.Tail);
 end;
 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 }
 { TTypeData }
 
 
 function TTypeData.GetBaseType: PTypeInfo;
 function TTypeData.GetBaseType: PTypeInfo;