changeset 12396:8bf38ad5c253 draft

(svn r16827) -Codechange: make OSX specific files include stdafx.h always as the first file. Also unify OSX specific stuff into osx_stdafx.h and remove unused includes.
author rubidium <rubidium@openttd.org>
date Tue, 14 Jul 2009 16:43:45 +0000
parents c2eb8db929f0
children c401355932e2
files src/music/qtmidi.cpp src/os/macosx/macos.mm src/os/macosx/osx_stdafx.h src/sound/cocoa_s.cpp src/video/cocoa/cocoa_v.mm src/video/cocoa/event.mm src/video/cocoa/fullscreen.mm src/video/cocoa/wnd_quartz.mm src/video/cocoa/wnd_quickdraw.mm
diffstat 9 files changed, 99 insertions(+), 175 deletions(-) [+]
line wrap: on
line diff
--- a/src/music/qtmidi.cpp
+++ b/src/music/qtmidi.cpp
@@ -21,35 +21,15 @@
 
 #ifndef NO_QUICKTIME
 
-#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
-#include <AvailabilityMacros.h>
-
-/*
- * OpenTTD includes.
- */
-#define  WindowClass OSX_WindowClass
-#include <QuickTime/QuickTime.h>
-#undef   WindowClass
-
 #include "../stdafx.h"
 #include "qtmidi.h"
+#include "../debug.h"
 
-/*
- * System includes. We need to workaround with some defines because there's
- * stuff already defined in QuickTime headers.
- */
-#define  OTTD_Random OSX_OTTD_Random
-#undef   OTTD_Random
-#undef   WindowClass
-#undef   SL_ERROR
-#undef   bool
-
-#include <assert.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-/* we need to include debug.h after CoreServices because defining DEBUG will break CoreServices in OSX 10.2 */
-#include "../debug.h"
+#define Rect  OTTDRect
+#define Point OTTDPoint
+#include <QuickTime/QuickTime.h>
+#undef Rect
+#undef Point
 
 static FMusicDriver_QtMidi iFMusicDriver_QtMidi;
 
--- a/src/os/macosx/macos.mm
+++ b/src/os/macosx/macos.mm
@@ -1,17 +1,19 @@
 /* $Id$ */
 
-#include <AvailabilityMacros.h>
+#include "../../stdafx.h"
+#include "../../core/bitmath_func.hpp"
+#include "../../rev.h"
 
+#define Rect  OTTDRect
+#define Point OTTDPoint
 #include <AppKit/AppKit.h>
+#undef Rect
+#undef Point
 
 #include <mach/mach.h>
 #include <mach/mach_host.h>
 #include <mach/host_info.h>
 #include <mach/machine.h>
-#include <stdio.h>
-#include "../../stdafx.h"
-#include "../../core/bitmath_func.hpp"
-#include "../../rev.h"
 
 #ifndef CPU_SUBTYPE_POWERPC_970
 #define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
--- a/src/os/macosx/osx_stdafx.h
+++ b/src/os/macosx/osx_stdafx.h
@@ -20,15 +20,27 @@
 #	error "Compiling 64 bits without _SQ64 set! (or vice versa)"
 #endif
 
+#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_3
+#include <AvailabilityMacros.h>
+
+/* Name conflict */
+#define Rect        OTTDRect
+#define Point       OTTDPoint
+#define WindowClass OTTDWindowClass
+
 #include <CoreServices/CoreServices.h>
 
+#undef Rect
+#undef Point
+#undef WindowClass
+
 /* remove the variables that CoreServices defines, but we define ourselves too */
 #undef bool
 #undef false
 #undef true
 
 /* Name conflict */
-#define GetTime		OTTD_GetTime
+#define GetTime OTTD_GetTime
 
 #define SL_ERROR OSX_SL_ERROR
 
--- a/src/sound/cocoa_s.cpp
+++ b/src/sound/cocoa_s.cpp
@@ -10,27 +10,18 @@
 
 #ifdef WITH_COCOA
 
-#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
-#include <AvailabilityMacros.h>
-
-#include <AudioUnit/AudioUnit.h>
-
-/* Name conflict */
-#define Rect        OTTDRect
-#define Point       OTTDPoint
-#define WindowClass OTTDWindowClass
-
 #include "../stdafx.h"
 #include "../debug.h"
 #include "../driver.h"
 #include "../mixer.h"
 #include "../core/endian_type.hpp"
-
 #include "cocoa_s.h"
 
-#undef WindowClass
+#define Rect        OTTDRect
+#define Point       OTTDPoint
+#include <AudioUnit/AudioUnit.h>
+#undef Rect
 #undef Point
-#undef Rect
 
 static FSoundDriver_Cocoa iFSoundDriver_Cocoa;
 
--- a/src/video/cocoa/cocoa_v.mm
+++ b/src/video/cocoa/cocoa_v.mm
@@ -8,13 +8,25 @@
 
 #ifdef WITH_COCOA
 
-#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
-#include <AvailabilityMacros.h>
+#include "../../stdafx.h"
 
+#define Rect  OTTDRect
+#define Point OTTDPoint
 #import <Cocoa/Cocoa.h>
-#import <sys/time.h> /* gettimeofday */
+#undef Rect
+#undef Point
+
+#include "../../openttd.h"
+#include "../../debug.h"
+#include "../../variables.h"
+#include "../../core/geometry_type.hpp"
+#include "cocoa_v.h"
+#include "../../blitter/factory.hpp"
+#include "../../fileio_func.h"
+#include "../../gfx_func.h"
+#include "../../functions.h"
+
 #import <sys/param.h> /* for MAXPATHLEN */
-#import <unistd.h>
 
 /**
  * Important notice regarding all modifications!!!!!!!
@@ -43,28 +55,6 @@
 #endif
 
 
-/* Defined in stdbool.h */
-#ifndef __cplusplus
-# ifndef __BEOS__
-#  undef bool
-#  undef false
-#  undef true
-# endif
-#endif
-
-
-#include "../../stdafx.h"
-#include "../../openttd.h"
-#include "../../debug.h"
-#include "../../variables.h"
-#include "../../core/geometry_type.hpp"
-#include "cocoa_v.h"
-#include "../../blitter/factory.hpp"
-#include "../../fileio_func.h"
-#include "../../gfx_func.h"
-#include "../../functions.h"
-
-
 @interface OTTDMain : NSObject
 @end
 
--- a/src/video/cocoa/event.mm
+++ b/src/video/cocoa/event.mm
@@ -8,34 +8,14 @@
 
 #ifdef WITH_COCOA
 
-#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
-#include <AvailabilityMacros.h>
-
-#import <Cocoa/Cocoa.h>
-#import <sys/time.h> /* gettimeofday */
-#import <sys/param.h> /* for MAXPATHLEN */
-#import <unistd.h>
+#include "../../stdafx.h"
 
-/**
- * Important notice regarding all modifications!!!!!!!
- * There are certain limitations because the file is objective C++.
- * gdb has limitations.
- * C++ and objective C code can't be joined in all cases (classes stuff).
- * Read http://developer.apple.com/releasenotes/Cocoa/Objective-C++.html for more information.
- */
-
+#define Rect  OTTDRect
+#define Point OTTDPoint
+#import <Cocoa/Cocoa.h>
+#undef Rect
+#undef Point
 
-/* Defined in stdbool.h */
-#ifndef __cplusplus
-# ifndef __BEOS__
-#  undef bool
-#  undef false
-#  undef true
-# endif
-#endif
-
-
-#include "../../stdafx.h"
 #include "../../openttd.h"
 #include "../../debug.h"
 #include "../../os/macosx/splash.h"
@@ -50,6 +30,16 @@
 #include "../../core/random_func.hpp"
 #include "../../texteff.hpp"
 
+#import <sys/time.h> /* gettimeofday */
+
+/**
+ * Important notice regarding all modifications!!!!!!!
+ * There are certain limitations because the file is objective C++.
+ * gdb has limitations.
+ * C++ and objective C code can't be joined in all cases (classes stuff).
+ * Read http://developer.apple.com/releasenotes/Cocoa/Objective-C++.html for more information.
+ */
+
 
 /* Right Mouse Button Emulation enum */
 enum {
--- a/src/video/cocoa/fullscreen.mm
+++ b/src/video/cocoa/fullscreen.mm
@@ -8,13 +8,18 @@
 
 #ifdef WITH_COCOA
 
-#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
-#include <AvailabilityMacros.h>
+#include "../../stdafx.h"
 
+#define Rect  OTTDRect
+#define Point OTTDPoint
 #import <Cocoa/Cocoa.h>
-#import <sys/time.h> /* gettimeofday */
-#import <sys/param.h> /* for MAXPATHLEN */
-#import <unistd.h>
+#undef Rect
+#undef Point
+
+#include "../../debug.h"
+#include "../../core/geometry_type.hpp"
+#include "cocoa_v.h"
+#include "../../gfx_func.h"
 
 /**
  * Important notice regarding all modifications!!!!!!!
@@ -29,24 +34,6 @@
 extern "C" void ShowMenuBar();
 extern "C" void HideMenuBar();
 
-/* Defined in stdbool.h */
-#ifndef __cplusplus
-# ifndef __BEOS__
-#  undef bool
-#  undef false
-#  undef true
-# endif
-#endif
-
-
-#include "../../stdafx.h"
-#include "../../debug.h"
-#include "../../core/geometry_type.hpp"
-#include "cocoa_v.h"
-#include "../../gfx_func.h"
-
-#undef Rect
-
 
 /* Structure for rez switch gamma fades
  * We can hide the monitor flicker by setting the gamma tables to 0
--- a/src/video/cocoa/wnd_quartz.mm
+++ b/src/video/cocoa/wnd_quartz.mm
@@ -9,14 +9,23 @@
 #ifdef WITH_COCOA
 #ifdef ENABLE_COCOA_QUARTZ
 
-#include <AvailabilityMacros.h>
+#include "../../stdafx.h"
 
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
 
+#define Rect  OTTDRect
+#define Point OTTDPoint
 #import <Cocoa/Cocoa.h>
-#import <sys/time.h> /* gettimeofday */
-#import <sys/param.h> /* for MAXPATHLEN */
-#import <unistd.h>
+#undef Rect
+#undef Point
+
+#include "../../debug.h"
+#include "../../rev.h"
+#include "../../core/geometry_type.hpp"
+#include "cocoa_v.h"
+#include "../../core/math_func.hpp"
+#include "../../gfx_func.h"
+#include "../../functions.h"
 
 /**
  * Important notice regarding all modifications!!!!!!!
@@ -26,29 +35,6 @@
  * Read http://developer.apple.com/releasenotes/Cocoa/Objective-C++.html for more information.
  */
 
-
-/* Defined in stdbool.h */
-#ifndef __cplusplus
-# ifndef __BEOS__
-#  undef bool
-#  undef false
-#  undef true
-# endif
-#endif
-
-
-#include "../../stdafx.h"
-#include "../../debug.h"
-#include "../../rev.h"
-#include "../../core/geometry_type.hpp"
-#include "cocoa_v.h"
-#include "../../core/math_func.hpp"
-#include "../../gfx_func.h"
-#include "../../functions.h"
-
-#undef Rect
-
-
 class WindowQuartzSubdriver;
 
 
--- a/src/video/cocoa/wnd_quickdraw.mm
+++ b/src/video/cocoa/wnd_quickdraw.mm
@@ -9,14 +9,22 @@
 #ifdef WITH_COCOA
 #ifdef ENABLE_COCOA_QUICKDRAW
 
-#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
-#define MAC_OS_X_VERSION_MAX_ALLOWED     MAC_OS_X_VERSION_10_3
-#include <AvailabilityMacros.h>
+#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_3
+#include "../../stdafx.h"
 
+#define Rect  OTTDRect
+#define Point OTTDPoint
 #import <Cocoa/Cocoa.h>
-#import <sys/time.h> /* gettimeofday */
-#import <sys/param.h> /* for MAXPATHLEN */
-#import <unistd.h>
+#undef Rect
+#undef Point
+
+#include "../../debug.h"
+#include "../../rev.h"
+#include "../../core/geometry_type.hpp"
+#include "cocoa_v.h"
+#include "../../core/math_func.hpp"
+#include "../../gfx_func.h"
+#include "../../functions.h"
 
 /**
  * Important notice regarding all modifications!!!!!!!
@@ -27,28 +35,6 @@
  */
 
 
-/* Defined in stdbool.h */
-#ifndef __cplusplus
-# ifndef __BEOS__
-#  undef bool
-#  undef false
-#  undef true
-# endif
-#endif
-
-
-#include "../../stdafx.h"
-#include "../../debug.h"
-#include "../../rev.h"
-#include "../../core/geometry_type.hpp"
-#include "cocoa_v.h"
-#include "../../core/math_func.hpp"
-#include "../../gfx_func.h"
-#include "../../functions.h"
-
-#undef Rect
-
-
 class WindowQuickdrawSubdriver;