Browse Source

* RTL compileable with the FPC 3.0

git-svn-id: branches/maciej/smart_pointers@33381 -
maciej-izak 9 years ago
parent
commit
9263ef6dad
3 changed files with 35 additions and 0 deletions
  1. 4 0
      rtl/inc/objpas.inc
  2. 29 0
      rtl/inc/rtti.inc
  3. 2 0
      rtl/objpas/typinfo.pp

+ 4 - 0
rtl/inc/objpas.inc

@@ -327,9 +327,11 @@
 
       class function TObject.InitInstance(instance : pointer) : tobject; {$ifdef SYSTEMINLINE} inline; {$ENDIF}
 
+{$if FPC_FULLVERSION>30100}
         var
            vmt  : PVmt;
            temp : pointer;
+{$endif FPC_FULLVERSION>30100}
         begin
            { the size is saved at offset 0 }
            fillchar(instance^, InstanceSize, 0);
@@ -339,6 +341,7 @@
            if PVmt(self)^.vIntfTable <> @emptyintf then
              InitInterfacePointers(self,instance);
 
+{$if FPC_FULLVERSION>30100}
            { for record operators like initialize/finalize call int_initialize }
            vmt := PVmt(self);
            while vmt<>nil do
@@ -350,6 +353,7 @@
                  RecordRTTI(Instance,Temp,@int_initialize);
                vmt:= vmt^.vParent;
              end;
+{$endif FPC_FULLVERSION>30100}
 
            InitInstance:=TObject(Instance);
         end;

+ 29 - 0
rtl/inc/rtti.inc

@@ -45,11 +45,14 @@ type
 {$endif USE_PACKED}
   record
     Size: Longint;
+{$if FPC_FULLVERSION>30100}
     InitTable: Pointer;
+{$endif FPC_FULLVERSION>30100}
     Count: Longint;
     { Elements: array[count] of TRecordElement }
   end;
 
+{$if FPC_FULLVERSION>30100}
   TRTTIRecInitFiniOp=procedure(ARec: Pointer);
 
   PRTTIRecordOpVMT=^TRTTIRecordOpVMT;
@@ -74,6 +77,7 @@ type
     Count: Longint;
     { Elements: array[count] of TRecordElement }
   end;
+{$endif FPC_FULLVERSION>30100}
 
   PArrayInfo=^TArrayInfo;
   TArrayInfo=
@@ -104,6 +108,7 @@ begin
   result:=PRecordInfoFull(typeInfo)^.Size;
 end;
 
+{$if FPC_FULLVERSION>30100}
 function RTTIRecordOp(typeInfo: Pointer; var initrtti: Pointer): PRecordInfoInit; inline;
 begin
   { find init table and management operators }
@@ -119,6 +124,7 @@ begin
     result:=aligntoptr(initrtti+2+PByte(initrtti)[1]);
   end
 end;
+{$endif FPC_FULLVERSION>30100}
 
 function RTTISize(typeInfo: Pointer): SizeInt;
 begin
@@ -146,8 +152,13 @@ var
   i : longint;
 begin
   typeInfo:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
+{$if FPC_FULLVERSION>30100}
   Count:=PRecordInfoInit(typeInfo)^.Count;
   Inc(PRecordInfoInit(typeInfo));
+{$else FPC_FULLVERSION>30100}
+  Count:=PRecordInfoFull(typeInfo)^.Count;
+  Inc(PRecordInfoFull(typeInfo));
+{$endif FPC_FULLVERSION>30100}
   { Process elements }
   for i:=1 to count Do
     begin
@@ -207,6 +218,7 @@ begin
     tkObject,
 {$endif FPC_HAS_FEATURE_OBJECTS}
     tkRecord:
+{$if FPC_FULLVERSION>30100}
       { if possible try to use more optimal initrtti }
       with RTTIRecordOp(typeinfo, typeinfo)^ do
       begin
@@ -214,6 +226,9 @@ begin
         if Assigned(recordop) and Assigned(recordop^.Initialize) then
           recordop^.Initialize(data);
       end;
+{$else FPC_FULLVERSION>30100}
+      recordrtti(data,typeinfo,@int_initialize);
+{$endif FPC_FULLVERSION>30100}
 {$ifdef FPC_HAS_FEATURE_VARIANTS}
     tkVariant:
       variant_init(PVarData(Data)^);
@@ -243,6 +258,7 @@ begin
     tkObject,
 {$endif FPC_HAS_FEATURE_OBJECTS}
     tkRecord:
+{$if FPC_FULLVERSION>30100}
       { if possible try to use more optimal initrtti }
       with RTTIRecordOp(typeinfo, typeinfo)^ do
       begin
@@ -250,6 +266,9 @@ begin
           recordop^.Finalize(data);
         recordrtti(data,typeinfo,@int_finalize);
       end;
+{$else FPC_FULLVERSION>30100}
+      recordrtti(data,typeinfo,@int_finalize);
+{$endif FPC_FULLVERSION>30100}
     tkInterface:
       Intf_Decr_Ref(PPointer(Data)^);
 {$ifdef FPC_HAS_FEATURE_DYNARRAYS}
@@ -286,8 +305,10 @@ begin
 {$endif FPC_HAS_FEATURE_OBJECTS}
     tkrecord :
       begin
+{$if FPC_FULLVERSION>30100}
         { find init table }
         RTTIRecordOp(typeinfo, typeinfo);
+{$endif FPC_FULLVERSION>30100}
         recordrtti(data,typeinfo,@int_addref);
       end;
 {$ifdef FPC_HAS_FEATURE_DYNARRAYS}
@@ -361,13 +382,21 @@ begin
 {$endif FPC_HAS_FEATURE_OBJECTS}
     tkrecord:
       begin
+{$if FPC_FULLVERSION>30100}
         { find init table }
         RTTIRecordOp(typeinfo, typeinfo);
+{$endif FPC_FULLVERSION>30100}
         Temp:=aligntoptr(typeInfo+2+PByte(typeInfo)[1]);
 
+{$if FPC_FULLVERSION>30100}
         Result:=PRecordInfoInit(Temp)^.Size;
         Count:=PRecordInfoInit(Temp)^.Count;
         Inc(PRecordInfoInit(Temp));
+{$else FPC_FULLVERSION>30100}
+        Result:=PRecordInfoFull(Temp)^.Size;
+        Count:=PRecordInfoFull(Temp)^.Count;
+        Inc(PRecordInfoFull(Temp));
+{$endif FPC_FULLVERSION>30100}
         expectedoffset:=0;
         { Process elements with rtti }
         for i:=1 to count Do

+ 2 - 0
rtl/objpas/typinfo.pp

@@ -203,7 +203,9 @@ unit typinfo;
             tkRecord:
               (
                 RecSize: Integer;
+{$if FPC_FULLVERSION>30100}
                 RecInitTable: Pointer;
+{$endif FPC_FULLVERSION>30100}
                 ManagedFldCount: Integer;
                 {ManagedFields: array[1..ManagedFldCount] of TManagedField}
               );