Răsfoiți Sursa

Switch properties to use the indirect type information without breaking backwards compatiblity. :)

compiler/ncgrtti.pas, TRTTIWriter:
  * published_properties_write_rtti_data: use the indirect reference, not the direct one
rtl/objpas/typinfo.pp:
  * to allow compilation with both 2.6.x and 2.7.1 and too avoid too many ifdefs at least in the declarations we define a macro TypeInfoPtr which is either PTypeInfo (2.6.x) or PPTypeInfo (2.7.1 and newer)
  * TPropInfo: rename PropType to PropTypeRef and change type to TypeInfoPtr
  + TPropInfo: add a new property PropType which returns a PTypeInfo out of the PropTypeRef depending on the compiler version

git-svn-id: branches/svenbarth/packages@28264 -
svenbarth 11 ani în urmă
părinte
comite
3670ef015d
2 a modificat fișierele cu 20 adăugiri și 2 ștergeri
  1. 1 1
      compiler/ncgrtti.pas
  2. 19 1
      rtl/objpas/typinfo.pp

+ 1 - 1
compiler/ncgrtti.pas

@@ -389,7 +389,7 @@ implementation
                   proctypesinfo:=$40
                 else
                   proctypesinfo:=0;
-                write_rtti_reference(tpropertysym(sym).propdef,fullrtti);
+                write_rtti_reference(tpropertysym(sym).propdef,fullrtti,true);
                 writeaccessproc(palt_read,0,0);
                 writeaccessproc(palt_write,2,0);
                 { is it stored ? }

+ 19 - 1
rtl/objpas/typinfo.pp

@@ -23,6 +23,7 @@ unit typinfo;
 {$MODE objfpc}
 {$MODESWITCH AdvancedRecords}
 {$inline on}
+{$macro on}
 {$h+}
 
   uses SysUtils;
@@ -113,6 +114,12 @@ unit typinfo;
       PTypeInfo = ^TTypeInfo;
       PPTypeInfo = ^PTypeInfo;
 
+{$ifdef ver2_6}
+{$define TypeInfoPtr := PTypeInfo}
+{$else}
+{$define TypeInfoPtr := PPTypeInfo}
+{$endif}
+
 {$PACKRECORDS C}
       // members of TTypeData
       TArrayTypeData =
@@ -278,7 +285,10 @@ unit typinfo;
 
       PPropInfo = ^TPropInfo;
       TPropInfo = packed record
-        PropType : PTypeInfo;
+      private
+        function GetPropType: PTypeInfo; inline;
+      public
+        PropTypeRef : TypeInfoPtr;
         GetProc : CodePointer;
         SetProc : CodePointer;
         StoredProc : CodePointer;
@@ -294,6 +304,7 @@ unit typinfo;
         PropProcs : Byte;
 
         Name : ShortString;
+        property PropType: PTypeInfo read GetPropType;
       end;
 
       TProcInfoProc = Procedure(PropInfo : PPropInfo) of object;
@@ -2061,4 +2072,11 @@ begin
     end;
 end;
 
+{ TPropInfo }
+
+function TPropInfo.GetPropType: PTypeInfo;
+begin
+  Result := PropTypeRef{$ifndef ver2_6}^{$endif};
+end;
+
 end.