瀏覽代碼

+ introduced a private type TCodePtrList, which is the specialization
TFPGList<CodePointer> on archs/memory models where CodePointer is different
than Pointer. On archs/memory models where CodePointer = Pointer, TCodePtrList
is simply an alias of TList and the fgl unit isn't pulled in.
* the type of FindGlobalComponentList changed to TCodePtrList and the typecasts
from TFindGlobalComponent (procvar type) to Pointer changed to CodePointer.
This fixes compilation of unit classes in the i8086 medium memory model.

git-svn-id: trunk@25357 -

nickysn 12 年之前
父節點
當前提交
e342c11085
共有 2 個文件被更改,包括 26 次插入6 次删除
  1. 16 1
      rtl/msdos/classes.pp
  2. 10 5
      rtl/objpas/classes/classes.inc

+ 16 - 1
rtl/msdos/classes.pp

@@ -18,6 +18,14 @@
 { determine the type of the resource/form file }
 { determine the type of the resource/form file }
 {$define Win16Res}
 {$define Win16Res}
 
 
+{$if defined(FPC_MM_TINY) or defined(FPC_MM_SMALL) or defined(FPC_MM_LARGE) or defined(FPC_MM_HUGE)}
+  { CodePointer = Pointer; nothing to define }
+{$elseif defined(FPC_MM_MEDIUM) or defined(FPC_MM_COMPACT)}
+  {$define FPC_CODEPOINTER_DIFFERENT_THAN_POINTER}
+{$else}
+  {$fatal Unknown i8086 memory model.}
+{$endif}
+
 unit Classes;
 unit Classes;
 
 
 interface
 interface
@@ -26,7 +34,7 @@ uses
   typinfo,
   typinfo,
   rtlconsts,
   rtlconsts,
   types,
   types,
-{$ifdef FPC_TESTGENERICS}
+{$if defined(FPC_TESTGENERICS) or defined(FPC_CODEPOINTER_DIFFERENT_THAN_POINTER)}
   fgl,
   fgl,
 {$endif}
 {$endif}
   sysutils;
   sysutils;
@@ -35,6 +43,13 @@ uses
 
 
 implementation
 implementation
 
 
+type
+{$ifdef FPC_CODEPOINTER_DIFFERENT_THAN_POINTER}
+  TCodePtrList = specialize TFPGList<CodePointer>;
+{$else FPC_CODEPOINTER_DIFFERENT_THAN_POINTER}
+  TCodePtrList = TList;
+{$endif FPC_CODEPOINTER_DIFFERENT_THAN_POINTER}
+
 { OS - independent class implementations are in /inc directory. }
 { OS - independent class implementations are in /inc directory. }
 {$i classes.inc}
 {$i classes.inc}
 
 

+ 10 - 5
rtl/objpas/classes/classes.inc

@@ -881,23 +881,28 @@ Type
     AClass : TComponentClass;
     AClass : TComponentClass;
   end;
   end;
 
 
+{$ifndef i8086}
+type
+  TCodePtrList = TList;
+{$endif i8086}
+
 Var
 Var
   InitHandlerList : TList;
   InitHandlerList : TList;
-  FindGlobalComponentList : TList;
+  FindGlobalComponentList : TCodePtrList;
 
 
 procedure RegisterFindGlobalComponentProc(AFindGlobalComponent: TFindGlobalComponent);
 procedure RegisterFindGlobalComponentProc(AFindGlobalComponent: TFindGlobalComponent);
   begin
   begin
     if not(assigned(FindGlobalComponentList)) then
     if not(assigned(FindGlobalComponentList)) then
-      FindGlobalComponentList:=TList.Create;
-    if FindGlobalComponentList.IndexOf(Pointer(AFindGlobalComponent))<0 then
-      FindGlobalComponentList.Add(Pointer(AFindGlobalComponent));
+      FindGlobalComponentList:=TCodePtrList.Create;
+    if FindGlobalComponentList.IndexOf(CodePointer(AFindGlobalComponent))<0 then
+      FindGlobalComponentList.Add(CodePointer(AFindGlobalComponent));
   end;
   end;
 
 
 
 
 procedure UnregisterFindGlobalComponentProc(AFindGlobalComponent: TFindGlobalComponent);
 procedure UnregisterFindGlobalComponentProc(AFindGlobalComponent: TFindGlobalComponent);
   begin
   begin
     if assigned(FindGlobalComponentList) then
     if assigned(FindGlobalComponentList) then
-      FindGlobalComponentList.Remove(Pointer(AFindGlobalComponent));
+      FindGlobalComponentList.Remove(CodePointer(AFindGlobalComponent));
   end;
   end;