Pārlūkot izejas kodu

Fix compilation of WinCE. Change the fixed UNICODE define of WinCE to FPC_OS_UNICODE, so that it won't be undefined when changing the mode/string type and that the usage of a UNICODE API is independant of the mode.

Also adjusted all Windows (Win32/64/CE) units to define a "UNICODE" if "FPC_OS_UNICODE" is defined (except the Jedi units).
Also the common RTL units that checked for UNICODE now check for FPC_OS_UNICODE.

git-svn-id: trunk@24420 -
svenbarth 12 gadi atpakaļ
vecāks
revīzija
930b76e8fb

+ 1 - 1
compiler/systems/i_nativent.pas

@@ -42,7 +42,7 @@ unit i_nativent;
                             tf_dwarf_only_local_labels];
             cpu          : cpu_i386;
             unit_env     : 'NTUNITS';
-            extradefines : 'NATIVENT,UNICODE';
+            extradefines : 'NATIVENT,FPC_OS_UNICODE';
             exeext       : '.exe';
             defext       : '.def';
             scriptext    : '.bat';

+ 2 - 2
compiler/systems/i_win.pas

@@ -174,7 +174,7 @@ unit i_win;
                             tf_safecall_exceptions,tf_no_backquote_support];
             cpu          : cpu_arm;
             unit_env     : '';
-            extradefines : 'UNDER_CE;WINDOWS;UNICODE';
+            extradefines : 'UNDER_CE;WINDOWS;FPC_OS_UNICODE';
             exeext       : '.exe';
             defext       : '.def';
             scriptext    : '.bat';
@@ -239,7 +239,7 @@ unit i_win;
                             tf_safecall_exceptions,tf_no_backquote_support];
             cpu          : cpu_i386;
             unit_env     : '';
-            extradefines : 'UNDER_CE;WINDOWS;UNICODE';
+            extradefines : 'UNDER_CE;WINDOWS;FPC_OS_UNICODE';
             exeext       : '.exe';
             defext       : '.def';
             scriptext    : '.bat';

+ 1 - 1
packages/fcl-base/src/fileinfo.pp

@@ -202,7 +202,7 @@ var
   Stream: TResourceStream;
 begin
   FreeResources;
-  Stream := TResourceStream.CreateFromID(Instance, 1, {$ifdef UNICODE}PWideChar{$else}PChar{$endif}(RT_VERSION));
+  Stream := TResourceStream.CreateFromID(Instance, 1, {$ifdef FPC_OS_UNICODE}PWideChar{$else}PChar{$endif}(RT_VERSION));
   try
     FVersionInfo:=TVersionResource.Create;
     FVersionInfo.SetCustomRawDataStream(Stream);

+ 3 - 0
packages/regexpr/src/regexpr.pas

@@ -83,6 +83,9 @@ interface
 
 // ======== Define options for TRegExpr engine
 {.$DEFINE UniCode} // Unicode support
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
 {$DEFINE RegExpPCodeDump} // p-code dumping (see Dump method)
 {$IFNDEF FPC} // the option is not supported in FreePascal
  {$DEFINE reRealExceptionAddr} // exceptions will point to appropriate source line, not to Error procedure

+ 5 - 1
packages/winceunits/src/cpl.pp

@@ -52,6 +52,10 @@
 
 unit cpl;
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 uses Windows;
@@ -244,4 +248,4 @@ const
 
 implementation
 
-end.
+end.

+ 5 - 1
packages/winceunits/src/imm.pp

@@ -25,6 +25,10 @@ unit imm;
 
 {$CALLING cdecl}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 uses Windows;
@@ -1381,4 +1385,4 @@ function ImmGetKeyboardLayout(dwThreadId:DWORD):HKL; external ImmDLL name 'ImmGe
 
 implementation
 
-end.
+end.

+ 4 - 0
packages/winceunits/src/mmsystem.pp

@@ -32,6 +32,10 @@ unit mmsystem;
 
 {$CALLING cdecl}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 uses Windows, mmreg;

+ 4 - 0
packages/winceunits/src/wininet.pp

@@ -34,6 +34,10 @@ unit wininet;
 
 {$CALLING cdecl}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 uses Windows;

+ 4 - 0
packages/winunits-base/src/commctrl.pp

@@ -43,6 +43,10 @@ Unit CommCtrl;
 Interface
 
 {$Mode ObjFPC}
+
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
 Uses Windows,CTypes,ActiveX;
 
 // --------------------

+ 4 - 0
packages/winunits-base/src/commdlg.pp

@@ -20,6 +20,10 @@ interface
 {$ifndef Win64}
   {$packrecords 1}
 {$endif}
+
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
 uses windows;
 
 Type

+ 5 - 1
packages/winunits-base/src/imagehlp.pp

@@ -29,6 +29,10 @@ Uses Windows;
  {$define imagehlp64}
 {$endif}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 Const 
      IMAGE_SEPARATION    = 64*1024;  	
      DBHHEADER_DEBUGDIRS = $1;     
@@ -1599,4 +1603,4 @@ begin
     p64^.SystemRangeStart := p32^.SystemRangeStart;
 end;
  
-end.
+end.

+ 4 - 0
packages/winunits-base/src/imm.pas

@@ -19,6 +19,10 @@ uses
 
 {$PACKRECORDS C}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 // IME_Codes
 // bit field for conversion mode
 const

+ 4 - 0
packages/winunits-base/src/mmsystem.pp

@@ -11,6 +11,10 @@ Unit mmsystem;
   {$smartlink on}
 {$endif}
 {$MODE DELPHI}
+
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
 interface
 uses
  windows;

+ 4 - 0
packages/winunits-base/src/multimon.pp

@@ -30,6 +30,10 @@ unit MultiMon;
 
 {$mode objfpc}{$H+}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 uses

+ 4 - 0
packages/winunits-base/src/richedit.pp

@@ -4,6 +4,10 @@ unit richedit;
 {$mode objfpc}
 {$calling stdcall}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 uses Messages, Windows;

+ 4 - 0
packages/winunits-base/src/shellapi.pp

@@ -22,6 +22,10 @@
 {$calling stdcall}
 {$mode objfpc}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 Unit ShellApi;
 
 //+-------------------------------------------------------------------------

+ 5 - 1
packages/winunits-base/src/wininet.pp

@@ -16,6 +16,10 @@ unit wininet;
 {$smartlink on}
 {$endif}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 Uses Windows;
@@ -2774,4 +2778,4 @@ implementation
       result:=(gtype and GOPHER_TYPE_GOPHER_PLUS)=0;
     end;  
 
-end.
+end.

+ 1 - 1
rtl/inc/resh.inc

@@ -8,7 +8,7 @@ type
   TFPResourceHandle = PtrUInt;
   TFPResourceHMODULE = PtrUInt;
   TFPResourceHGLOBAL = PtrUInt;
-{$ifdef UNICODE}
+{$ifdef FPC_OS_UNICODE}
   {roozbeh : maybe it shoud be moved after ifndef mswindows,as there is one declared in wince,base.inc}
   MAKEINTRESOURCE = pwidechar;
 {$else}

+ 2 - 2
rtl/objpas/classes/classesh.inc

@@ -998,7 +998,7 @@ type
 
 { TResourceStream }
 
-{$ifdef UNICODE}
+{$ifdef FPC_OS_UNICODE}
   TResourceStream = class(TCustomMemoryStream)
   private
     Res: TFPResourceHandle;
@@ -1020,7 +1020,7 @@ type
     constructor CreateFromID(Instance: TFPResourceHMODULE; ResID: Integer; ResType: PChar);
     destructor Destroy; override;
   end;
-{$endif UNICODE}
+{$endif FPC_OS_UNICODE}
 
 { TStreamAdapter }
 

+ 3 - 3
rtl/objpas/classes/streams.inc

@@ -872,7 +872,7 @@ end;
 {*                             TResourceStream                              *}
 {****************************************************************************}
 
-{$ifdef UNICODE}
+{$ifdef FPC_OS_UNICODE}
 procedure TResourceStream.Initialize(Instance: TFPResourceHMODULE; Name, ResType: PWideChar; NameIsID: Boolean);
   begin
     Res:=FindResource(Instance, Name, ResType);
@@ -900,7 +900,7 @@ constructor TResourceStream.CreateFromID(Instance: TFPResourceHMODULE; ResID: In
     inherited create;
     Initialize(Instance,PWideChar(ResID),ResType,True);
   end;
-{$else UNICODE}
+{$else FPC_OS_UNICODE}
 
 procedure TResourceStream.Initialize(Instance: TFPResourceHMODULE; Name, ResType: PChar; NameIsID: Boolean);
   begin
@@ -929,7 +929,7 @@ constructor TResourceStream.CreateFromID(Instance: TFPResourceHMODULE; ResID: In
     inherited create;
     Initialize(Instance,pchar(PtrInt(ResID)),ResType,True);
   end;
-{$endif UNICODE}
+{$endif FPC_OS_UNICODE}
 
 
 destructor TResourceStream.Destroy;

+ 3 - 3
rtl/win/sysos.inc

@@ -120,15 +120,15 @@ type
    UINT  = cardinal;
    BOOL  = longbool;
 //   WCHAR = word;
-{$ifdef UNICODE}
+{$ifdef FPC_OS_UNICODE}
    LPTCH   = ^word;
    LPTSTR  = ^word;
    LPCTSTR = ^word;
-{$else UNICODE}
+{$else FPC_OS_UNICODE}
    LPTCH   = ^char;
    LPTSTR  = ^char;
    LPCTSTR = ^char;
-{$endif UNICODE}
+{$endif FPC_OS_UNICODE}
    LPWSTR  = ^wchar;
    PVOID   = pointer;
    LPVOID  = pointer;

+ 4 - 0
rtl/win/winsock2.pp

@@ -14,6 +14,10 @@ unit WinSock2;
 {$smartlink on}
 {$endif}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 Uses Windows;

+ 4 - 0
rtl/win32/windows.pp

@@ -25,6 +25,10 @@ unit windows;
 {$inline on}
 {$calling stdcall}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 {$define read_interface}

+ 4 - 0
rtl/win64/windows.pp

@@ -25,6 +25,10 @@ unit windows;
 {$inline on}
 {$calling stdcall}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 {$define read_interface}

+ 0 - 2
rtl/wince/classes.pp

@@ -13,8 +13,6 @@
 
  **********************************************************************}
 
-{$define UNICODE}  //ce is unicode only, needed here for classes.inc
-
 {$mode objfpc}
 
 { determine the type of the resource/form file }

+ 4 - 0
rtl/wince/windows.pp

@@ -28,6 +28,10 @@ unit windows;
 { convention is cdecl for WinCE API}
 {$calling cdecl}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 

+ 3 - 0
rtl/wince/winsock.pp

@@ -19,6 +19,9 @@ unit winsock;
 { convention is cdecl for WinCE API}
 {$calling cdecl}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
 
 {remaining functions exported from ws2.dll and not used yet = to do,
 

+ 4 - 0
rtl/wince/winsock2.pp

@@ -18,6 +18,10 @@ unit WinSock2;
 { convention is cdecl for WinCE API}
 {$calling cdecl}
 
+{$ifdef FPC_OS_UNICODE}
+  {$define UNICODE}
+{$endif}
+
 interface
 
 Uses Windows;