diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/debug.h | 8 | ||||
-rw-r--r-- | src/gfx.h | 13 | ||||
-rw-r--r-- | src/hal.h | 8 | ||||
-rw-r--r-- | src/md5.h | 9 | ||||
-rw-r--r-- | src/os/macosx/macos.h | 12 | ||||
-rw-r--r-- | src/os/macosx/macos.mm (renamed from src/os/macosx/macos.m) | 0 | ||||
-rw-r--r-- | src/unix.cpp | 6 | ||||
-rw-r--r-- | src/video/cocoa_v.h | 15 | ||||
-rw-r--r-- | src/video/cocoa_v.mm (renamed from src/video/cocoa_v.m) | 57 |
9 files changed, 42 insertions, 86 deletions
diff --git a/src/debug.h b/src/debug.h index 0e58dfdce..47d7855f9 100644 --- a/src/debug.h +++ b/src/debug.h @@ -3,10 +3,6 @@ #ifndef DEBUG_H #define DEBUG_H -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - /* Debugging messages policy: * These should be the severities used for direct DEBUG() calls * maximum debugging level should be 10 if really deep, deep @@ -111,8 +107,4 @@ const char *GetDebugString(void); }\ } -#ifdef __cplusplus -} -#endif //__cplusplus - #endif /* DEBUG_H */ @@ -3,11 +3,6 @@ #ifndef GFX_H #define GFX_H -/* !!! Note that the first part of this file if enclosed in extern "C" due to cocoa/obj-C !!! */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ enum WindowKeyCodes { WKC_SHIFT = 0x8000, @@ -175,10 +170,6 @@ void HandleExitGameRequest(void); void GameSizeChanged(void); void UndrawMouseCursor(void); -#ifdef __cplusplus -}; //extern "C" -/* Following part is only for C++ */ - #include "helpers.hpp" typedef enum FontSizes { @@ -245,7 +236,7 @@ void ScreenSizeChanged(void); void UndrawMouseCursor(void); bool ChangeResInGame(int w, int h); void SortResolutions(int count); -extern "C" void ToggleFullScreen(bool fs); +void ToggleFullScreen(bool fs); /* gfx.c */ #define ASCII_LETTERSTART 32 @@ -301,6 +292,4 @@ typedef enum StringColorFlags { extern bool _dbg_screen_rect; #endif -#endif /* __cplusplus */ - #endif /* GFX_H */ @@ -3,10 +3,6 @@ #ifndef HAL_H #define HAL_H -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - typedef struct { const char *(*start)(const char * const *parm); void (*stop)(void); @@ -46,8 +42,4 @@ enum DriverType { MUSIC_DRIVER = 2, }; -#ifdef __cplusplus -} // extern "C" -#endif //__cplusplus - #endif /* HAL_H */ @@ -72,11 +72,6 @@ typedef struct md5_state_s { md5_byte_t buf[64]; /* accumulate block */ } md5_state_t; -#ifdef __cplusplus -extern "C" -{ -#endif - /* Initialize the algorithm. */ void md5_init(md5_state_t *pms); @@ -86,8 +81,4 @@ void md5_append(md5_state_t *pms, const void *data, size_t nbytes); /* Finish the message and return the digest. */ void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); -#ifdef __cplusplus -} /* end extern "C" */ -#endif - #endif /* MD5_INCLUDED */ diff --git a/src/os/macosx/macos.h b/src/os/macosx/macos.h index ba33ce602..b8a6cd511 100644 --- a/src/os/macosx/macos.h +++ b/src/os/macosx/macos.h @@ -11,15 +11,9 @@ * the function then adds text that tells the user to update and then report the bug if it's present in the newest version * It also quits in a nice way since we call it when we know something happened that will crash OpenTTD (like a needed pointer turns out to be NULL or similar) */ -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel ); - void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression ); - void ShowMacErrorDialog(const char *error); -#ifdef __cplusplus -} -#endif //__cplusplus +void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel ); +void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression ); +void ShowMacErrorDialog(const char *error); // Since MacOS X users will never see an assert unless they started the game from a terminal // we're using a custom assert(e) macro. diff --git a/src/os/macosx/macos.m b/src/os/macosx/macos.mm index 33f296325..33f296325 100644 --- a/src/os/macosx/macos.m +++ b/src/os/macosx/macos.mm diff --git a/src/unix.cpp b/src/unix.cpp index fa49eca4d..cee8082d9 100644 --- a/src/unix.cpp +++ b/src/unix.cpp @@ -127,9 +127,9 @@ void ShowOSErrorBox(const char *buf) } #ifdef WITH_COCOA -extern "C" void cocoaSetWorkingDirectory(void); -extern "C" void cocoaSetupAutoreleasePool(void); -extern "C" void cocoaReleaseAutoreleasePool(void); +void cocoaSetWorkingDirectory(void); +void cocoaSetupAutoreleasePool(void); +void cocoaReleaseAutoreleasePool(void); #endif int CDECL main(int argc, char* argv[]) diff --git a/src/video/cocoa_v.h b/src/video/cocoa_v.h index 42e55bcca..1512a0b64 100644 --- a/src/video/cocoa_v.h +++ b/src/video/cocoa_v.h @@ -5,22 +5,9 @@ #include "../hal.h" -#ifndef __cplusplus -/* Really ugly workaround - * It should be solved right as soon as possible */ -typedef uint32 SpriteID; -#endif //__cplusplus - +#include "../openttd.h" #include "../gfx.h" -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - extern const HalVideoDriver _cocoa_video_driver; -#ifdef __cplusplus -} // extern "C" -#endif //__cplusplus - #endif diff --git a/src/video/cocoa_v.m b/src/video/cocoa_v.mm index f476c905c..aaa9475ef 100644 --- a/src/video/cocoa_v.m +++ b/src/video/cocoa_v.mm @@ -13,19 +13,28 @@ #import <sys/param.h> /* for MAXPATHLEN */ #import <unistd.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. + */ + + /* Portions of CPS.h */ typedef struct CPSProcessSerNum { UInt32 lo; UInt32 hi; } CPSProcessSerNum; -extern OSErr CPSGetCurrentProcess(CPSProcessSerNum* psn); -extern OSErr CPSEnableForegroundOperation(CPSProcessSerNum* psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); -extern OSErr CPSSetFrontProcess(CPSProcessSerNum* psn); +extern "C" OSErr CPSGetCurrentProcess(CPSProcessSerNum* psn); +extern "C" OSErr CPSEnableForegroundOperation(CPSProcessSerNum* psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); +extern "C" OSErr CPSSetFrontProcess(CPSProcessSerNum* psn); /* From Menus.h (according to Xcode Developer Documentation) */ -extern void ShowMenuBar(void); -extern void HideMenuBar(void); +extern "C" void ShowMenuBar(void); +extern "C" void HideMenuBar(void); /* Disables a warning. This is needed since the method exists but has been dropped from the header, supposedly as of 10.4. */ #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) @@ -353,7 +362,7 @@ static void QZ_DoUnsidedModifiers(unsigned int newMods) const int mapping[] = { QZ_CAPSLOCK, QZ_LSHIFT, QZ_LCTRL, QZ_LALT, QZ_LMETA }; int i; - int bit; + unsigned int bit; if (_cocoa_video_data.current_mods == newMods) return; @@ -817,7 +826,7 @@ static void QZ_SetPortAlphaOpaque(void) newViewFrame = [ _cocoa_video_data.qdview frame ]; /* Update the pixels and pitch */ - thePort = [ _cocoa_video_data.qdview qdPort ]; + thePort = (OpaqueGrafPtr*) [ _cocoa_video_data.qdview qdPort ]; LockPortBits(thePort); _cocoa_video_data.realpixels = GetPixBaseAddr(GetPortPixMap(thePort)); @@ -1083,7 +1092,7 @@ static void QZ_DrawWindow(void) QZ_DrawResizeIcon(); /* Flush the dirty region */ - QDFlushPortBuffer([ _cocoa_video_data.qdview qdPort ], dirty); + QDFlushPortBuffer( (OpaqueGrafPtr*) [ _cocoa_video_data.qdview qdPort ], dirty); DisposeRgn(dirty); DisposeRgn(temp); @@ -1163,10 +1172,12 @@ static const char* QZ_SetVideoWindowed(uint width, uint height) [ _cocoa_video_data.window makeKeyAndOrderFront:nil ]; } - LockPortBits([ _cocoa_video_data.qdview qdPort ]); - _cocoa_video_data.realpixels = GetPixBaseAddr(GetPortPixMap([ _cocoa_video_data.qdview qdPort ])); - _cocoa_video_data.pitch = GetPixRowBytes(GetPortPixMap([ _cocoa_video_data.qdview qdPort ])); - UnlockPortBits([ _cocoa_video_data.qdview qdPort ]); + CGrafPtr thePort = (OpaqueGrafPtr*) [ _cocoa_video_data.qdview qdPort ]; + + LockPortBits(thePort); + _cocoa_video_data.realpixels = GetPixBaseAddr(GetPortPixMap(thePort)); + _cocoa_video_data.pitch = GetPixRowBytes(GetPortPixMap(thePort)); + UnlockPortBits(thePort); /* _cocoa_video_data.realpixels now points to the window's pixels * We want it to point to the *view's* pixels @@ -1294,17 +1305,17 @@ static const char* QZ_SetVideoFullScreen(int width, int height) /* If the mode wasn't an exact match, check if it has the right bpp, and update width and height */ if (!exact_match) { - number = CFDictionaryGetValue (_cocoa_video_data.mode, kCGDisplayBitsPerPixel); + number = (const __CFNumber*) CFDictionaryGetValue(_cocoa_video_data.mode, kCGDisplayBitsPerPixel); CFNumberGetValue(number, kCFNumberSInt32Type, &bpp); if (bpp != 8) { errstr = "Failed to find display resolution"; goto ERR_NO_MATCH; } - number = CFDictionaryGetValue(_cocoa_video_data.mode, kCGDisplayWidth); + number = (const __CFNumber*)CFDictionaryGetValue(_cocoa_video_data.mode, kCGDisplayWidth); CFNumberGetValue(number, kCFNumberSInt32Type, &width); - number = CFDictionaryGetValue(_cocoa_video_data.mode, kCGDisplayHeight); + number = (const __CFNumber*)CFDictionaryGetValue(_cocoa_video_data.mode, kCGDisplayHeight); CFNumberGetValue(number, kCFNumberSInt32Type, &height); } @@ -1412,7 +1423,7 @@ static void QZ_WaitForVerticalBlank(void) double adjustment; CFNumberRef refreshRateCFNumber; - refreshRateCFNumber = CFDictionaryGetValue(_cocoa_video_data.mode, kCGDisplayRefreshRate); + refreshRateCFNumber = (const __CFNumber*)CFDictionaryGetValue(_cocoa_video_data.mode, kCGDisplayRefreshRate); if (refreshRateCFNumber == NULL) return; if (CFNumberGetValue(refreshRateCFNumber, kCFNumberDoubleType, &refreshRate) == 0) @@ -1487,17 +1498,17 @@ static int QZ_ListFullscreenModes(OTTDPoint* mode_list, int max_modes) bool hasMode; uint16 width, height; - onemode = CFArrayGetValueAtIndex(_cocoa_video_data.mode_list, i); - number = CFDictionaryGetValue(onemode, kCGDisplayBitsPerPixel); + onemode = (const __CFDictionary*)CFArrayGetValueAtIndex(_cocoa_video_data.mode_list, i); + number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayBitsPerPixel); CFNumberGetValue (number, kCFNumberSInt32Type, &bpp); if (bpp != 8) continue; - number = CFDictionaryGetValue(onemode, kCGDisplayWidth); + number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayWidth); CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue); width = (uint16)intvalue; - number = CFDictionaryGetValue(onemode, kCGDisplayHeight); + number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayHeight); CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue); height = (uint16)intvalue; @@ -1713,17 +1724,17 @@ static void QZ_VideoInit(void) /* Gather some information that is useful to know about the display */ /* Maybe this should be moved to QZ_SetVideoMode, in case this is changed after startup */ CFNumberGetValue( - CFDictionaryGetValue(_cocoa_video_data.save_mode, kCGDisplayBitsPerPixel), + (const __CFNumber*)CFDictionaryGetValue(_cocoa_video_data.save_mode, kCGDisplayBitsPerPixel), kCFNumberSInt32Type, &_cocoa_video_data.device_bpp ); CFNumberGetValue( - CFDictionaryGetValue(_cocoa_video_data.save_mode, kCGDisplayWidth), + (const __CFNumber*)CFDictionaryGetValue(_cocoa_video_data.save_mode, kCGDisplayWidth), kCFNumberSInt32Type, &_cocoa_video_data.device_width ); CFNumberGetValue( - CFDictionaryGetValue(_cocoa_video_data.save_mode, kCGDisplayHeight), + (const __CFNumber*)CFDictionaryGetValue(_cocoa_video_data.save_mode, kCGDisplayHeight), kCFNumberSInt32Type, &_cocoa_video_data.device_height ); |