From 0d8377d6b48a91bae403199037b905a777785172 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Mon, 18 Jan 2016 15:29:16 -0800 Subject: [PATCH] - try to fix mac build --- source/g3d_viewer/main.cpp | 28 +++++++++---------- source/glest_game/main/main.cpp | 6 ++-- .../menu/menu_state_connected_game.h | 2 +- .../glest_game/menu/menu_state_custom_game.h | 2 +- source/glest_game/network/network_message.cpp | 2 +- source/glest_game/network/network_message.h | 2 +- source/glest_game/types/tech_tree.cpp | 2 +- source/glest_game/types/unit_type.cpp | 2 +- source/glest_game/types/unit_type.h | 2 +- source/glest_map_editor/main.cpp | 8 +++--- source/shared_lib/include/graphics/model.h | 2 +- .../platform/common/common_scoped_ptr.h | 13 ++++----- .../shared_lib/include/platform/sdl/thread.h | 4 +-- source/shared_lib/sources/graphics/model.cpp | 4 +-- .../sources/platform/sdl/thread.cpp | 8 +++--- 15 files changed, 42 insertions(+), 45 deletions(-) diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index c4a56499f..66f786938 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -450,7 +450,7 @@ MainWindow::MainWindow( std::pair > unitToLoad, DWORD dwDisposition; RegCreateKeyEx(HKEY_CURRENT_USER,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition); //Set the value. - unique_ptr wstr(Ansi2WideString(appPath.c_str())); + auto_ptr wstr(Ansi2WideString(appPath.c_str())); wstring launchApp = wstring(wstr.get()) + L" \"%1\""; DWORD len = (DWORD)launchApp.length() + 1; @@ -849,7 +849,7 @@ void MainWindow::onMenuFileLoad(wxCommandEvent &event){ const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(fileDialog->GetPath()); file = tmp_buf; - unique_ptr wstr(Ansi2WideString(file.c_str())); + auto_ptr wstr(Ansi2WideString(file.c_str())); file = utf8_encode(wstr.get()); #else file = (const char*)wxFNCONV(fileDialog->GetPath().c_str()); @@ -884,7 +884,7 @@ void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){ #ifdef WIN32 const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(fileDialog->GetPath()); file = tmp_buf; - unique_ptr wstr(Ansi2WideString(file.c_str())); + auto_ptr wstr(Ansi2WideString(file.c_str())); file = utf8_encode(wstr.get()); #else file = (const char*)wxFNCONV(fileDialog->GetPath().c_str()); @@ -918,7 +918,7 @@ void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){ #ifdef WIN32 const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(fileDialog->GetPath()); file = tmp_buf; - unique_ptr wstr(Ansi2WideString(file.c_str())); + auto_ptr wstr(Ansi2WideString(file.c_str())); file = utf8_encode(wstr.get()); #else file = (const char*)wxFNCONV(fileDialog->GetPath().c_str()); @@ -953,7 +953,7 @@ void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){ const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(fileDialog->GetPath()); file = tmp_buf; - unique_ptr wstr(Ansi2WideString(file.c_str())); + auto_ptr wstr(Ansi2WideString(file.c_str())); file = utf8_encode(wstr.get()); #else file = (const char*)wxFNCONV(fileDialog->GetPath().c_str()); @@ -2158,7 +2158,7 @@ bool App::OnInit() { for(unsigned int i = 0; i < autoScreenShotParams.size(); ++i) { #ifdef WIN32 - unique_ptr wstr(Ansi2WideString(autoScreenShotParams[i].c_str())); + auto_ptr wstr(Ansi2WideString(autoScreenShotParams[i].c_str())); autoScreenShotParams[i] = utf8_encode(wstr.get()); #endif @@ -2203,14 +2203,14 @@ bool App::OnInit() { if(delimitedList.size() >= 2) { unitToLoad.first = delimitedList[0]; #ifdef WIN32 - unique_ptr wstr(Ansi2WideString(unitToLoad.first.c_str())); + auto_ptr wstr(Ansi2WideString(unitToLoad.first.c_str())); unitToLoad.first = utf8_encode(wstr.get()); #endif for(unsigned int i = 1; i < delimitedList.size(); ++i) { string value = delimitedList[i]; #ifdef WIN32 - unique_ptr wstr(Ansi2WideString(value.c_str())); + auto_ptr wstr(Ansi2WideString(value.c_str())); value = utf8_encode(wstr.get()); #endif @@ -2249,7 +2249,7 @@ bool App::OnInit() { string customPathValue = paramPartTokens[1]; modelPath = customPathValue; #ifdef WIN32 - unique_ptr wstr(Ansi2WideString(modelPath.c_str())); + auto_ptr wstr(Ansi2WideString(modelPath.c_str())); modelPath = utf8_encode(wstr.get()); #endif @@ -2279,7 +2279,7 @@ bool App::OnInit() { string customPathValue = paramPartTokens[1]; particlePath = customPathValue; #ifdef WIN32 - unique_ptr wstr(Ansi2WideString(particlePath.c_str())); + auto_ptr wstr(Ansi2WideString(particlePath.c_str())); particlePath = utf8_encode(wstr.get()); #endif } @@ -2307,7 +2307,7 @@ bool App::OnInit() { string customPathValue = paramPartTokens[1]; projectileParticlePath = customPathValue; #ifdef WIN32 - unique_ptr wstr(Ansi2WideString(projectileParticlePath.c_str())); + auto_ptr wstr(Ansi2WideString(projectileParticlePath.c_str())); projectileParticlePath = utf8_encode(wstr.get()); #endif } @@ -2335,7 +2335,7 @@ bool App::OnInit() { string customPathValue = paramPartTokens[1]; splashParticlePath = customPathValue; #ifdef WIN32 - unique_ptr wstr(Ansi2WideString(splashParticlePath.c_str())); + auto_ptr wstr(Ansi2WideString(splashParticlePath.c_str())); splashParticlePath = utf8_encode(wstr.get()); #endif } @@ -2494,7 +2494,7 @@ bool App::OnInit() { #ifdef WIN32 const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(argv[1])); modelPath = tmp_buf; - unique_ptr wstr(Ansi2WideString(modelPath.c_str())); + auto_ptr wstr(Ansi2WideString(modelPath.c_str())); modelPath = utf8_encode(wstr.get()); #else modelPath = wxFNCONV(argv[1]); @@ -2524,7 +2524,7 @@ bool App::OnInit() { const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(exe_path)); string appPath = tmp_buf; - unique_ptr wstr(Ansi2WideString(appPath.c_str())); + auto_ptr wstr(Ansi2WideString(appPath.c_str())); appPath = utf8_encode(wstr.get()); #else string appPath(wxFNCONV(exe_path)); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index a2f16f901..a08857d01 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -129,7 +129,7 @@ static string runtimeErrorMsg = ""; #endif #ifdef HAVE_GOOGLE_BREAKPAD -unique_ptr errorHandlerPtr; +auto_ptr errorHandlerPtr; #endif class NavtiveLanguageNameListCacheGenerator : public SimpleTaskCallbackInterface { @@ -5555,8 +5555,8 @@ int glestMain(int argc, char** argv) { preCacheThread->start(); } - unique_ptr lngCacheGen; - unique_ptr languageCacheGen; + auto_ptr lngCacheGen; + auto_ptr languageCacheGen; bool startNativeLanguageNamesPrecacheThread = config.getBool("PreCacheNativeLanguageNamesThread","true"); if(startNativeLanguageNamesPrecacheThread == true && diff --git a/source/glest_game/menu/menu_state_connected_game.h b/source/glest_game/menu/menu_state_connected_game.h index 137d741da..c6fd6efaf 100644 --- a/source/glest_game/menu/menu_state_connected_game.h +++ b/source/glest_game/menu/menu_state_connected_game.h @@ -243,7 +243,7 @@ private: bool launchingNewGame; bool isfirstSwitchingMapMessage; - unique_ptr techTree; + auto_ptr techTree; GameSettings originalGamesettings; bool validOriginalGameSettings; diff --git a/source/glest_game/menu/menu_state_custom_game.h b/source/glest_game/menu/menu_state_custom_game.h index 2668f552e..cf9a0db97 100644 --- a/source/glest_game/menu/menu_state_custom_game.h +++ b/source/glest_game/menu/menu_state_custom_game.h @@ -219,7 +219,7 @@ private: bool masterserverModeMinimalResources; int lastMasterServerSettingsUpdateCount; - unique_ptr techTree; + auto_ptr techTree; string gameUUID; diff --git a/source/glest_game/network/network_message.cpp b/source/glest_game/network/network_message.cpp index 1637cf1b3..dd4134014 100644 --- a/source/glest_game/network/network_message.cpp +++ b/source/glest_game/network/network_message.cpp @@ -35,7 +35,7 @@ namespace Glest{ namespace Game{ bool NetworkMessage::useOldProtocol = true; -unique_ptr NetworkMessage::mutexMessageStats(new Mutex(CODE_AT_LINE)); +auto_ptr NetworkMessage::mutexMessageStats(new Mutex(CODE_AT_LINE)); Chrono NetworkMessage::statsTimer; Chrono NetworkMessage::lastSend; Chrono NetworkMessage::lastRecv; diff --git a/source/glest_game/network/network_message.h b/source/glest_game/network/network_message.h index e06976a88..93db7e2d0 100644 --- a/source/glest_game/network/network_message.h +++ b/source/glest_game/network/network_message.h @@ -98,7 +98,7 @@ enum NetworkMessageStatisticType { class NetworkMessage { private: - static unique_ptr mutexMessageStats; + static auto_ptr mutexMessageStats; static Chrono statsTimer; static Chrono lastSend; static Chrono lastRecv; diff --git a/source/glest_game/types/tech_tree.cpp b/source/glest_game/types/tech_tree.cpp index 25a4f8c36..5db23f1fd 100644 --- a/source/glest_game/types/tech_tree.cpp +++ b/source/glest_game/types/tech_tree.cpp @@ -177,7 +177,7 @@ Checksum TechTree::loadTech(const string &techName, bool TechTree::exists(const string &techName, const vector &pathTechList) { bool techFound = false; - unique_ptr techTree(new TechTree(pathTechList)); + auto_ptr techTree(new TechTree(pathTechList)); string path = techTree->findPath(techName); if(path != "") { techFound = true; diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 3a4ad222c..776f13c1e 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -37,7 +37,7 @@ using namespace Shared::Util; namespace Glest{ namespace Game{ -unique_ptr UnitType::ctHarvestEmergencyReturnCommandType(new HarvestEmergencyReturnCommandType()); +auto_ptr UnitType::ctHarvestEmergencyReturnCommandType(new HarvestEmergencyReturnCommandType()); // =============================== // class Level // =============================== diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index e594ab18c..eca85e91a 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -234,7 +234,7 @@ private: UnitCountsInVictoryConditions countInVictoryConditions; - static unique_ptr ctHarvestEmergencyReturnCommandType; + static auto_ptr ctHarvestEmergencyReturnCommandType; public: //creation and loading diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp index 9b31ffdfd..ae05ba40f 100644 --- a/source/glest_map_editor/main.cpp +++ b/source/glest_map_editor/main.cpp @@ -690,7 +690,7 @@ void MainWindow::onMenuFileLoad(wxCommandEvent &event) { const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(fileDialog->GetPath())); currentFile = tmp_buf; - unique_ptr wstr(Ansi2WideString(currentFile.c_str())); + auto_ptr wstr(Ansi2WideString(currentFile.c_str())); currentFile = utf8_encode(wstr.get()); #else //currentFile = fileDialog->GetPath().ToAscii(); @@ -766,7 +766,7 @@ void MainWindow::onMenuFileSaveAs(wxCommandEvent &event) { const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(fd.GetPath())); currentFile = tmp_buf; - unique_ptr wstr(Ansi2WideString(currentFile.c_str())); + auto_ptr wstr(Ansi2WideString(currentFile.c_str())); currentFile = utf8_encode(wstr.get()); #else //currentFile = fd.GetPath().ToAscii(); @@ -1639,7 +1639,7 @@ bool App::OnInit() { fileparam = tmp_buf; #ifdef WIN32 - unique_ptr wstr(Ansi2WideString(fileparam.c_str())); + auto_ptr wstr(Ansi2WideString(fileparam.c_str())); fileparam = utf8_encode(wstr.get()); #endif @@ -1664,7 +1664,7 @@ bool App::OnInit() { const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(exe_path)); appPath = tmp_buf; - unique_ptr wstr(Ansi2WideString(appPath.c_str())); + auto_ptr wstr(Ansi2WideString(appPath.c_str())); appPath = utf8_encode(wstr.get()); #else appPath = wxFNCONV(exe_path); diff --git a/source/shared_lib/include/graphics/model.h b/source/shared_lib/include/graphics/model.h index dc8bc480a..962e04613 100644 --- a/source/shared_lib/include/graphics/model.h +++ b/source/shared_lib/include/graphics/model.h @@ -315,7 +315,7 @@ private: static vector > nextColorIDReuseList; - static unique_ptr pbo; + static auto_ptr pbo; void assign_color(); diff --git a/source/shared_lib/include/platform/common/common_scoped_ptr.h b/source/shared_lib/include/platform/common/common_scoped_ptr.h index d47247f5b..891465530 100644 --- a/source/shared_lib/include/platform/common/common_scoped_ptr.h +++ b/source/shared_lib/include/platform/common/common_scoped_ptr.h @@ -17,16 +17,13 @@ // ===================================================== // Hack for compilers that dont support cxx11's unique_ptr which replaces auto_ptr // ===================================================== -using namespace std; +//using namespace std; // C++11 -#if !defined(HAVE_CXX11) && !defined(__GXX_EXPERIMENTAL_CXX0X__) && (__cplusplus < 201103L) && (_MSC_VER < 1900) - #ifdef __APPLE__ - template - using unique_ptr = auto_ptr; - #else - #define unique_ptr auto_ptr - #endif +#if defined(HAVE_CXX11) || (__cplusplus >= 201103L) || (_MSC_VER >= 1900) + +#define auto_ptr std::unique_ptr + #endif #endif diff --git a/source/shared_lib/include/platform/sdl/thread.h b/source/shared_lib/include/platform/sdl/thread.h index 6f53c532a..1bf8ab4e6 100644 --- a/source/shared_lib/include/platform/sdl/thread.h +++ b/source/shared_lib/include/platform/sdl/thread.h @@ -70,7 +70,7 @@ public: private: SDL_Thread* thread; - //std::unique_ptr mutexthreadAccessor; + //std::auto_ptr mutexthreadAccessor; Mutex *mutexthreadAccessor; ThreadState currentState; bool threadObjectValid(); @@ -129,7 +129,7 @@ private: Shared::PlatformCommon::Chrono *chronoPerf; bool isStaticMutexListMutex; - static unique_ptr mutexMutexList; + static auto_ptr mutexMutexList; static vector mutexList; public: diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index 9e5d57174..347414604 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -1896,7 +1896,7 @@ const unsigned int BaseColorPickEntity::k = 43067; unsigned int BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k; unsigned char BaseColorPickEntity::nextColorID[COLOR_COMPONENTS] = { 1, 1, 1, 0 }; -unique_ptr BaseColorPickEntity::pbo; +auto_ptr BaseColorPickEntity::pbo; map BaseColorPickEntity::usedColorIDList; bool BaseColorPickEntity::trackColorUse = true; @@ -2128,7 +2128,7 @@ vector BaseColorPickEntity::getPickedList(int x,int y,int w,int h, pickedModels.reserve(rendererModels.size()); //printf("In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - static unique_ptr cachedPixels; + static auto_ptr cachedPixels; if(rendererModels.empty() == false) { if(PixelBufferWrapper::getIsPBOEnable() == true) { diff --git a/source/shared_lib/sources/platform/sdl/thread.cpp b/source/shared_lib/sources/platform/sdl/thread.cpp index e1caf2607..ebce5f84e 100644 --- a/source/shared_lib/sources/platform/sdl/thread.cpp +++ b/source/shared_lib/sources/platform/sdl/thread.cpp @@ -27,15 +27,15 @@ bool Thread::enableVerboseMode = false; Mutex Thread::mutexthreadList; vector Thread::threadList; -unique_ptr Mutex::mutexMutexList(new Mutex(CODE_AT_LINE)); +auto_ptr Mutex::mutexMutexList(new Mutex(CODE_AT_LINE)); vector Mutex::mutexList; class ThreadGarbageCollector; class Mutex; class MutexSafeWrapper; -static unique_ptr cleanupThread; -static unique_ptr cleanupThreadMutex(new Mutex(CODE_AT_LINE)); +static auto_ptr cleanupThread; +static auto_ptr cleanupThreadMutex(new Mutex(CODE_AT_LINE)); class ThreadGarbageCollector : public BaseThread { @@ -546,7 +546,7 @@ inline void Mutex::p() { // snprintf(szBuf,8095,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s] deleteownerId [%s] stack: %s",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,refCount,ownerId.c_str(),deleteownerId.c_str(),stack.c_str()); // throw megaglest_runtime_error(szBuf); // } -// std::unique_ptr chronoLockPerf; +// std::auto_ptr chronoLockPerf; // if(debugMutexLock == true) { // chronoLockPerf.reset(new Chrono()); // chronoLockPerf->start();