Merge remote-tracking branch 'NCommander/vs2015' into develop

develop
lethosor 2016-07-29 15:30:32 -04:00
commit 158f18106f
15 changed files with 481 additions and 247 deletions

@ -56,6 +56,15 @@ endif()
if(MSVC) if(MSVC)
# disable C4819 code-page warning # disable C4819 code-page warning
add_definitions( "/wd4819" ) add_definitions( "/wd4819" )
# Disable use of POSIX name warnings
add_definitions ( "/D_CRT_NONSTDC_NO_WARNINGS")
# supress C4503 - VC++ dislikes if a name is too long. If you get
# weird and mysterious linking errors, you can disable this, but you'll have to
# deal with a LOT of compiler noise over it
# see https://msdn.microsoft.com/en-us/library/074af4b6.aspx
add_definitions( "/wd4503")
endif() endif()
SET(DFHACK_BUILD_ARCH "32" CACHE STRING "Architecture to build ('32' or '64')") SET(DFHACK_BUILD_ARCH "32" CACHE STRING "Architecture to build ('32' or '64')")

@ -1,4 +1,4 @@
call "%VS100COMNTOOLS%vsvars32.bat" call "%VS140COMNTOOLS%vsvars32.bat"
cd VC2010 cd VC2015_32
msbuild /m /p:Platform=Win32 /p:Configuration=RelWithDebInfo ALL_BUILD.vcxproj msbuild /m /p:Platform=Win32 /p:Configuration=RelWithDebInfo ALL_BUILD.vcxproj
cd .. cd ..

@ -1,5 +1,5 @@
call "%VS100COMNTOOLS%vsvars32.bat" call "%VS140COMNTOOLS%vsvars32.bat"
cd VC2010 cd VC2015_32
msbuild /m /p:Platform=Win32 /p:Configuration=Release ALL_BUILD.vcxproj msbuild /m /p:Platform=Win32 /p:Configuration=Release ALL_BUILD.vcxproj
cd .. cd ..
pause pause

@ -1,9 +1,9 @@
@echo off @echo off
IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt
IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF
mkdir VC2010 mkdir VC2015_32
cd VC2010 cd VC2015_32
echo generating a build folder echo generating a build folder
rem for /f "delims=" %%a in ('DATE /T') do @set myvar=breakfast-%BUILD_NUMBER% rem for /f "delims=" %%a in ('DATE /T') do @set myvar=breakfast-%BUILD_NUMBER%
set myvar=breakfast-%BUILD_NUMBER% set myvar=breakfast-%BUILD_NUMBER%
cmake ..\.. -G"Visual Studio 10" -DDFHACK_RELEASE="%myvar%" -DCMAKE_INSTALL_PREFIX="%_DF_PATH%" -DBUILD_DEVEL=1 -DBUILD_DEV_PLUGINS=1 -DBUILD_DF2MC=1 -DBUILD_DFUSION=1 -DBUILD_STONESENSE=1 -DBUILD_SERVER=1 cmake ..\.. -G"Visual Studio 14" -DDFHACK_RELEASE="%myvar%" -DCMAKE_INSTALL_PREFIX="%_DF_PATH%" -DBUILD_DEVEL=1 -DBUILD_DEV_PLUGINS=1 -DBUILD_DF2MC=1 -DBUILD_DFUSION=1 -DBUILD_STONESENSE=1 -DBUILD_SERVER=1

@ -1,6 +1,6 @@
IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt
IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF
mkdir VC2010 mkdir VC2015_32
cd VC2010 cd VC2015_32
echo generating a build folder echo generating a build folder
cmake ..\.. -G"Visual Studio 10" -DCMAKE_INSTALL_PREFIX="%_DF_PATH%" -DBUILD_DEVEL=1 -DBUILD_DEV_PLUGINS=1 -DBUILD_DF2MC=1 -DBUILD_DFUSION=1 -DBUILD_STONESENSE=1 -DBUILD_SERVER=1 cmake ..\.. -G"Visual Studio 14" -DCMAKE_INSTALL_PREFIX="%_DF_PATH%" -DBUILD_DEVEL=1 -DBUILD_DEV_PLUGINS=1 -DBUILD_DF2MC=1 -DBUILD_DFUSION=1 -DBUILD_STONESENSE=1 -DBUILD_SERVER=1

@ -1,7 +1,7 @@
IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt
IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF
mkdir VC2010 mkdir VC2015_32
cd VC2010 cd VC2015_32
echo Pre-generating a build folder echo Pre-generating a build folder
cmake ..\.. -G"Visual Studio 10" -DCMAKE_INSTALL_PREFIX="%_DF_PATH%" cmake ..\.. -G"Visual Studio 14" -DCMAKE_INSTALL_PREFIX="%_DF_PATH%"
cmake-gui . cmake-gui .

@ -1,6 +1,6 @@
IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt
IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF
mkdir VC2010 mkdir VC2015_32
cd VC2010 cd VC2015_32
echo generating a build folder echo generating a build folder
cmake ..\.. -G"Visual Studio 10" -DCMAKE_INSTALL_PREFIX="%_DF_PATH%" -DBUILD_DEVEL=0 -DBUILD_DEV_PLUGINS=0 -DBUILD_DF2MC=0 -DBUILD_DFUSION=0 -DBUILD_STONESENSE=0 -DBUILD_SERVER=0 cmake ..\.. -G"Visual Studio 14" -DCMAKE_INSTALL_PREFIX="%_DF_PATH%" -DBUILD_DEVEL=0 -DBUILD_DEV_PLUGINS=0 -DBUILD_DF2MC=0 -DBUILD_DFUSION=0 -DBUILD_STONESENSE=0 -DBUILD_SERVER=0

@ -1,6 +1,6 @@
IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt
IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF
mkdir VC2010 mkdir VC2015_32
cd VC2010 cd VC2015_32
echo generating a build folder echo generating a build folder
cmake ..\.. -G"Visual Studio 10" -DCMAKE_INSTALL_PREFIX="%_DF_PATH%" -DBUILD_DEVEL=0 -DBUILD_DEV_PLUGINS=0 -DBUILD_DF2MC=1 -DBUILD_DFUSION=1 -DBUILD_STONESENSE=1 -DBUILD_SERVER=1 cmake ..\.. -G"Visual Studio 14" -DCMAKE_INSTALL_PREFIX="%_DF_PATH%" -DBUILD_DEVEL=0 -DBUILD_DEV_PLUGINS=0 -DBUILD_DF2MC=1 -DBUILD_DFUSION=1 -DBUILD_STONESENSE=1 -DBUILD_SERVER=1

@ -1,4 +1,4 @@
call "%VS100COMNTOOLS%vsvars32.bat" call "%VS140COMNTOOLS%vsvars32.bat"
cd VC2010 cd VC2015_32
msbuild /m /p:Platform=Win32 /p:Configuration=RelWithDebInfo INSTALL.vcxproj msbuild /m /p:Platform=Win32 /p:Configuration=RelWithDebInfo INSTALL.vcxproj
cd .. cd ..

@ -1,4 +1,4 @@
call "%VS100COMNTOOLS%vsvars32.bat" call "%VS140COMNTOOLS%vsvars32.bat"
cd VC2010 cd VC2015_32
msbuild /m /p:Platform=Win32 /p:Configuration=Release INSTALL.vcxproj msbuild /m /p:Platform=Win32 /p:Configuration=Release INSTALL.vcxproj
cd .. cd ..

@ -1,6 +1,6 @@
@echo off @echo off
call "%VS100COMNTOOLS%vsvars32.bat" call "%VS140COMNTOOLS%vsvars32.bat"
cd VC2010 cd VC2015_32
msbuild /m /p:Platform=Win32 /p:Configuration=RelWithDebInfo PACKAGE.vcxproj msbuild /m /p:Platform=Win32 /p:Configuration=RelWithDebInfo PACKAGE.vcxproj
cd .. cd ..
exit %ERRORLEVEL% exit %ERRORLEVEL%

@ -1,5 +1,5 @@
@echo off @echo off
call "%VS100COMNTOOLS%vsvars32.bat" call "%VS140COMNTOOLS%vsvars32.bat"
cd VC2010 cd VC2015_32
msbuild /m /p:Platform=Win32 /p:Configuration=Release PACKAGE.vcxproj msbuild /m /p:Platform=Win32 /p:Configuration=Release PACKAGE.vcxproj
cd .. cd ..

@ -13,12 +13,14 @@ IF(CMAKE_COMPILER_IS_GNUCC)
#ENDIF() #ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
SET(HAVE_HASH_MAP 0) ENDIF()
SET(HASH_MAP_CLASS unordered_map)
#Check for all of the possible combinations of unordered_map and hash_map SET(HAVE_HASH_MAP 0)
SET(HASH_MAP_CLASS unordered_map)
FOREACH(header tr1/unordered_map unordered_map) #Check for all of the possible combinations of unordered_map and hash_map
FOREACH(header tr1/unordered_map unordered_map)
FOREACH(namespace std::tr1 std ) FOREACH(namespace std::tr1 std )
IF(HAVE_HASH_MAP EQUAL 0 AND NOT STL_HASH_OLD_GCC) IF(HAVE_HASH_MAP EQUAL 0 AND NOT STL_HASH_OLD_GCC)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/testHashMap.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/testHashMap.cpp") CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/testHashMap.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/testHashMap.cpp")
@ -39,8 +41,8 @@ IF(CMAKE_COMPILER_IS_GNUCC)
ENDIF() ENDIF()
ENDIF() ENDIF()
ENDFOREACH(namespace) ENDFOREACH(namespace)
ENDFOREACH(header) ENDFOREACH(header)
IF (HAVE_HASH_MAP EQUAL 0) IF (HAVE_HASH_MAP EQUAL 0)
SET(HASH_MAP_CLASS hash_map) SET(HASH_MAP_CLASS hash_map)
FOREACH(header ext/hash_map hash_map) FOREACH(header ext/hash_map hash_map)
FOREACH(namespace __gnu_cxx "" std stdext) FOREACH(namespace __gnu_cxx "" std stdext)
@ -59,22 +61,14 @@ IF(CMAKE_COMPILER_IS_GNUCC)
ENDIF() ENDIF()
ENDFOREACH() ENDFOREACH()
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
IF (HAVE_HASH_MAP EQUAL 0) IF (HAVE_HASH_MAP EQUAL 0)
MESSAGE(SEND_ERROR "Could not find a working hash map implementation. Please install GCC >= 4.4, and all necessary 32-bit C++ development libraries.") MESSAGE(SEND_ERROR "Could not find a working hash map implementation. Please install GCC >= 4.4, and all necessary 32-bit C++ development libraries.")
ENDIF() ENDIF()
IF(UNIX)
FIND_PACKAGE(Threads) FIND_PACKAGE(Threads)
ELSE()
SET(HASH_MAP_H <hash_map>)
SET(HASH_NAMESPACE std)
SET(HASH_SET_H <hash_set>)
SET(HAVE_HASH_MAP 1)
SET(HAVE_HASH_SET 1)
SET(HASH_MAP_CLASS hash_map)
SET(HASH_SET_CLASS hash_set)
ENDIF() ENDIF()
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h") CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h")

@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format // Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved. // Copyright 2008 Google Inc. All rights reserved.
// http://code.google.com/p/protobuf/ // https://developers.google.com/protocol-buffers/
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
@ -37,30 +37,152 @@
#include <string.h> #include <string.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include "config.h"
#if defined(HAVE_HASH_MAP) && defined(HAVE_HASH_SET) #define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
#include HASH_MAP_H #define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
#include HASH_SET_H
// Android
#if defined(__ANDROID__)
# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
// Use C++11 unordered_{map|set} if available.
#elif ((_LIBCPP_STD_VER >= 11) || \
(((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \
(__GLIBCXX__ > 20090421)))
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
// For XCode >= 4.6: the compiler is clang with libc++.
// For earlier XCode version: the compiler is gcc-4.2.1 with libstdc++.
// libc++ provides <unordered_map> and friends even in non C++11 mode,
// and it does not provide the tr1 library. Therefore the following macro
// checks against this special case.
// Note that we should not test the __APPLE_CC__ version number or the
// __clang__ macro, since the new compiler can still use -stdlib=libstdc++, in
// which case <unordered_map> is not compilable without -std=c++11
#elif defined(__APPLE_CC__)
# if __GNUC__ >= 4
# define GOOGLE_PROTOBUF_HAS_TR1
# else
// Not tested for gcc < 4... These setting can compile under 4.2.1 though.
# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx
# include <ext/hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <ext/hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# endif
// Version checks for gcc.
#elif defined(__GNUC__)
// For GCC 4.x+, use tr1::unordered_map/set; otherwise, follow the
// instructions from:
// https://gcc.gnu.org/onlinedocs/libstdc++/manual/backwards.html
# if __GNUC__ >= 4
# define GOOGLE_PROTOBUF_HAS_TR1
# elif __GNUC__ >= 3
# include <backward/hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <backward/hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# if __GNUC__ == 3 && __GNUC_MINOR__ == 0
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std // GCC 3.0
# else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx // GCC 3.1 and later
# endif
# else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE
# include <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# endif
// Version checks for MSC.
// Apparently Microsoft decided to move hash_map *back* to the std namespace in
// MSVC 2010:
// http://blogs.msdn.com/vcblog/archive/2009/05/25/stl-breaking-changes-in-visual-studio-2010-beta-1.aspx
// And.. they are moved back to stdext in MSVC 2013 (haven't checked 2012). That
// said, use unordered_map for MSVC 2010 and beyond is our safest bet.
#elif defined(_MSC_VER)
# if _MSC_VER >= 1600 // Since Visual Studio 2010
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
# define GOOGLE_PROTOBUF_HASH_COMPARE std::hash_compare
# elif _MSC_VER >= 1500 // Since Visual Studio 2008
# define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext
# include <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
# define GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE
# elif _MSC_VER >= 1310
# define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext
# include <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
# else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std
# include <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
# endif
// **ADD NEW COMPILERS SUPPORT HERE.**
// For other compilers, undefine the macro and fallback to use std::map, in
// google/protobuf/stubs/hash.h
#else #else
#define MISSING_HASH # undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
# undef GOOGLE_PROTOBUF_HAVE_HASH_SET
#endif
#if defined(GOOGLE_PROTOBUF_HAS_CXX11_HASH)
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std
# include <unordered_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map
# include <unordered_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
#elif defined(GOOGLE_PROTOBUF_HAS_TR1)
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std::tr1
# include <tr1/unordered_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map
# include <tr1/unordered_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
#endif
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START \
namespace google { \
namespace protobuf {
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END }}
#undef GOOGLE_PROTOBUF_HAS_CXX11_HASH
#undef GOOGLE_PROTOBUF_HAS_TR1
#if defined(GOOGLE_PROTOBUF_HAVE_HASH_MAP) && \
defined(GOOGLE_PROTOBUF_HAVE_HASH_SET)
#else
#define GOOGLE_PROTOBUF_MISSING_HASH
#include <map> #include <map>
#include <set> #include <set>
#endif #endif
namespace google { namespace google {
namespace protobuf { namespace protobuf {
#ifdef MISSING_HASH #ifdef GOOGLE_PROTOBUF_MISSING_HASH
#undef GOOGLE_PROTOBUF_MISSING_HASH
// This system doesn't have hash_map or hash_set. Emulate them using map and // This system doesn't have hash_map or hash_set. Emulate them using map and
// set. // set.
// Make hash<T> be the same as less<T>. Note that everywhere where custom // Make hash<T> be the same as less<T>. Note that everywhere where custom
// hash functions are defined in the protobuf code, they are also defined such // hash functions are defined in the protobuf code, they are also defined such
// that they can be used as "less" functions, which is required by MSVC anyway. // that they can be used as "less" functions, which is required by MSVC anyway.
template <typename Key> template <typename Key>
struct hash { struct hash {
// Dummy, just to make derivative hash functions compile. // Dummy, just to make derivative hash functions compile.
int operator()(const Key& key) { int operator()(const Key& key) {
GOOGLE_LOG(FATAL) << "Should never be called."; GOOGLE_LOG(FATAL) << "Should never be called.";
@ -70,11 +192,11 @@ struct hash {
inline bool operator()(const Key& a, const Key& b) const { inline bool operator()(const Key& a, const Key& b) const {
return a < b; return a < b;
} }
}; };
// Make sure char* is compared by value. // Make sure char* is compared by value.
template <> template <>
struct hash<const char*> { struct hash<const char*> {
// Dummy, just to make derivative hash functions compile. // Dummy, just to make derivative hash functions compile.
int operator()(const char* key) { int operator()(const char* key) {
GOOGLE_LOG(FATAL) << "Should never be called."; GOOGLE_LOG(FATAL) << "Should never be called.";
@ -84,71 +206,145 @@ struct hash<const char*> {
inline bool operator()(const char* a, const char* b) const { inline bool operator()(const char* a, const char* b) const {
return strcmp(a, b) < 0; return strcmp(a, b) < 0;
} }
}; };
template <typename Key, typename Data, template <typename Key, typename Data,
typename HashFcn = hash<Key>, typename HashFcn = hash<Key>,
typename EqualKey = int > typename EqualKey = std::equal_to<Key>,
class hash_map : public std::map<Key, Data, HashFcn> { typename Alloc = std::allocator< std::pair<const Key, Data> > >
}; class hash_map : public std::map<Key, Data, HashFcn, Alloc> {
typedef std::map<Key, Data, HashFcn, Alloc> BaseClass;
public:
hash_map(int a = 0, const HashFcn& b = HashFcn(),
const EqualKey& c = EqualKey(),
const Alloc& d = Alloc()) : BaseClass(b, d) {}
template <typename Key, HashFcn hash_function() const { return HashFcn(); }
};
template <typename Key,
typename HashFcn = hash<Key>, typename HashFcn = hash<Key>,
typename EqualKey = int > typename EqualKey = std::equal_to<Key> >
class hash_set : public std::set<Key, HashFcn> { class hash_set : public std::set<Key, HashFcn> {
}; public:
hash_set(int = 0) {}
HashFcn hash_function() const { return HashFcn(); }
};
#elif defined(_MSC_VER) && !defined(_STLPORT_VERSION) #elif defined(_MSC_VER) && !defined(_STLPORT_VERSION)
template <typename Key> template <typename Key>
struct hash : public HASH_NAMESPACE::hash_compare<Key> { struct hash : public GOOGLE_PROTOBUF_HASH_COMPARE<Key> {
}; };
// MSVC's hash_compare<const char*> hashes based on the string contents but // MSVC's hash_compare<const char*> hashes based on the string contents but
// compares based on the string pointer. WTF? // compares based on the string pointer. WTF?
class CstringLess { class CstringLess {
public: public:
inline bool operator()(const char* a, const char* b) const { inline bool operator()(const char* a, const char* b) const {
return strcmp(a, b) < 0; return strcmp(a, b) < 0;
} }
}; };
template <> template <>
struct hash<const char*> struct hash<const char*>
: public HASH_NAMESPACE::hash_compare<const char*, CstringLess> { : public GOOGLE_PROTOBUF_HASH_COMPARE<const char*, CstringLess> {};
};
#ifdef GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE
template <typename Key, typename HashFcn, typename EqualKey>
struct InternalHashCompare : public GOOGLE_PROTOBUF_HASH_COMPARE<Key> {
InternalHashCompare() {}
InternalHashCompare(HashFcn hashfcn, EqualKey equalkey)
: hashfcn_(hashfcn), equalkey_(equalkey) {}
size_t operator()(const Key& key) const { return hashfcn_(key); }
bool operator()(const Key& key1, const Key& key2) const {
return !equalkey_(key1, key2);
}
HashFcn hashfcn_;
EqualKey equalkey_;
};
template <typename Key, typename Data, template <typename Key, typename Data,
typename HashFcn = hash<Key>, typename HashFcn = hash<Key>,
typename EqualKey = int > typename EqualKey = std::equal_to<Key>,
class hash_map : public HASH_NAMESPACE::hash_map< typename Alloc = std::allocator< std::pair<const Key, Data> > >
Key, Data, HashFcn> { class hash_map
}; : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, InternalHashCompare<Key, HashFcn, EqualKey>, Alloc> {
typedef GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, InternalHashCompare<Key, HashFcn, EqualKey>, Alloc> BaseClass;
public:
hash_map(int a = 0, const HashFcn& b = HashFcn(),
const EqualKey& c = EqualKey(), const Alloc& d = Alloc())
: BaseClass(InternalHashCompare<Key, HashFcn, EqualKey>(b, c), d) {}
HashFcn hash_function() const { return HashFcn(); }
};
template <typename Key, typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key> >
class hash_set
: public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS<
Key, InternalHashCompare<Key, HashFcn, EqualKey> > {
public:
hash_set(int = 0) {}
template <typename Key, HashFcn hash_function() const { return HashFcn(); }
};
#else // GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE
template <typename Key, typename Data,
typename HashFcn = hash<Key>, typename HashFcn = hash<Key>,
typename EqualKey = int > typename EqualKey = std::equal_to<Key>,
class hash_set : public HASH_NAMESPACE::hash_set< typename Alloc = std::allocator< std::pair<const Key, Data> > >
Key, HashFcn> { class hash_map
}; : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, HashFcn, EqualKey, Alloc> {
typedef GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, HashFcn, EqualKey, Alloc> BaseClass;
#else public:
hash_map(int a = 0, const HashFcn& b = HashFcn(),
const EqualKey& c = EqualKey(),
const Alloc& d = Alloc()) : BaseClass(a, b, c, d) {}
HashFcn hash_function() const { return HashFcn(); }
};
template <typename Key, typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key> >
class hash_set
: public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS<
Key, HashFcn, EqualKey> {
public:
hash_set(int = 0) {}
HashFcn hash_function() const { return HashFcn(); }
};
#endif // GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE
#else // defined(_MSC_VER) && !defined(_STLPORT_VERSION)
template <typename Key> template <typename Key>
struct hash : public HASH_NAMESPACE::hash<Key> { struct hash : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash<Key> {
}; };
template <typename Key> template <typename Key>
struct hash<const Key*> { struct hash<const Key*> {
inline size_t operator()(const Key* key) const { inline size_t operator()(const Key* key) const {
return reinterpret_cast<size_t>(key); return reinterpret_cast<size_t>(key);
} }
}; };
// Unlike the old SGI version, the TR1 "hash" does not special-case char*. So, // Unlike the old SGI version, the TR1 "hash" does not special-case char*. So,
// we go ahead and provide our own implementation. // we go ahead and provide our own implementation.
template <> template <>
struct hash<const char*> { struct hash<const char*> {
inline size_t operator()(const char* str) const { inline size_t operator()(const char* str) const {
size_t result = 0; size_t result = 0;
for (; *str != '\0'; str++) { for (; *str != '\0'; str++) {
@ -156,39 +352,61 @@ struct hash<const char*> {
} }
return result; return result;
} }
}; };
template <typename Key, typename Data, template<>
typename HashFcn = hash<Key>, struct hash<bool> {
typename EqualKey = std::equal_to<Key> > size_t operator()(bool x) const {
class hash_map : public HASH_NAMESPACE::HASH_MAP_CLASS< return static_cast<size_t>(x);
Key, Data, HashFcn, EqualKey> { }
}; };
template <typename Key, template <typename Key, typename Data,
typename HashFcn = hash<Key>, typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key>,
typename Alloc = std::allocator< std::pair<const Key, Data> > >
class hash_map
: public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, HashFcn, EqualKey, Alloc> {
typedef GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, HashFcn, EqualKey, Alloc> BaseClass;
public:
hash_map(int a = 0, const HashFcn& b = HashFcn(),
const EqualKey& c = EqualKey(),
const Alloc& d = Alloc()) : BaseClass(a, b, c, d) {}
HashFcn hash_function() const { return HashFcn(); }
};
template <typename Key, typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key> > typename EqualKey = std::equal_to<Key> >
class hash_set : public HASH_NAMESPACE::HASH_SET_CLASS< class hash_set
: public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS<
Key, HashFcn, EqualKey> { Key, HashFcn, EqualKey> {
}; public:
hash_set(int = 0) {}
#endif HashFcn hash_function() const { return HashFcn(); }
};
#endif // !GOOGLE_PROTOBUF_MISSING_HASH
template <> template <>
struct hash<string> { struct hash<string> {
inline size_t operator()(const string& key) const { inline size_t operator()(const string& key) const {
return hash<const char*>()(key.c_str()); return hash<const char*>()(key.c_str());
} }
static const size_t bucket_size = 4; static const size_t bucket_size = 4;
static const size_t min_buckets = 8; static const size_t min_buckets = 8;
inline size_t operator()(const string& a, const string& b) const { inline bool operator()(const string& a, const string& b) const {
return a < b; return a < b;
} }
}; };
template <typename First, typename Second> template <typename First, typename Second>
struct hash<pair<First, Second> > { struct hash<pair<First, Second> > {
inline size_t operator()(const pair<First, Second>& key) const { inline size_t operator()(const pair<First, Second>& key) const {
size_t first_hash = hash<First>()(key.first); size_t first_hash = hash<First>()(key.first);
size_t second_hash = hash<Second>()(key.second); size_t second_hash = hash<Second>()(key.second);
@ -200,21 +418,21 @@ struct hash<pair<First, Second> > {
static const size_t bucket_size = 4; static const size_t bucket_size = 4;
static const size_t min_buckets = 8; static const size_t min_buckets = 8;
inline size_t operator()(const pair<First, Second>& a, inline bool operator()(const pair<First, Second>& a,
const pair<First, Second>& b) const { const pair<First, Second>& b) const {
return a < b; return a < b;
} }
}; };
// Used by GCC/SGI STL only. (Why isn't this provided by the standard // Used by GCC/SGI STL only. (Why isn't this provided by the standard
// library? :( ) // library? :( )
struct streq { struct streq {
inline bool operator()(const char* a, const char* b) const { inline bool operator()(const char* a, const char* b) const {
return strcmp(a, b) == 0; return strcmp(a, b) == 0;
} }
}; };
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google
#endif // GOOGLE_PROTOBUF_STUBS_HASH_H__ #endif // GOOGLE_PROTOBUF_STUBS_HASH_H__

@ -38,8 +38,21 @@ namespace DFHack
* our wrapper for the C++ exception. used to differentiate * our wrapper for the C++ exception. used to differentiate
* the whole array of DFHack exceptions from the rest * the whole array of DFHack exceptions from the rest
*/ */
#ifdef _MSC_VER
#pragma push
/**
* C4275 is - The warning officially is non dll-interface class 'std::exception' used as base for
* dll-interface class
*
* Basically, its saying that you might have an ABI problem if you mismatch compilers. We don't
* care since we build all of DFhack at once against whatever Toady is using
*/
#pragma warning(disable: 4275)
#endif
class DFHACK_EXPORT All : public std::exception{}; class DFHACK_EXPORT All : public std::exception{};
#ifdef _MSC_VER
#pragma pop
#endif
class DFHACK_EXPORT NullPointer : public All { class DFHACK_EXPORT NullPointer : public All {
const char *varname_; const char *varname_;
public: public: