Core/Hotswap: Replace #ifdef conditions with comparisons of values defined in CompilerDefs.h

This commit is contained in:
Shauren
2017-04-15 17:15:28 +02:00
parent 65a266f1c9
commit 43510a258c

View File

@@ -63,10 +63,10 @@ ScriptReloadMgr* ScriptReloadMgr::instance()
namespace fs = boost::filesystem;
#ifdef _WIN32
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
#include <windows.h>
#define HOTSWAP_PLATFORM_REQUIRES_CACHING
#elif __APPLE__
#elif TRINITY_PLATFORM == TRINITY_PLATFORM_APPLE
#include <dlfcn.h>
#define HOTSWAP_PLATFORM_REQUIRES_CACHING
#else // Posix
@@ -82,7 +82,7 @@ namespace fs = boost::filesystem;
// Returns "" on Windows and "lib" on posix.
static char const* GetSharedLibraryPrefix()
{
#ifdef _WIN32
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
return "";
#else // Posix
return "lib";
@@ -92,16 +92,16 @@ static char const* GetSharedLibraryPrefix()
// Returns "dll" on Windows, "dylib" on OS X, and "so" on posix.
static char const* GetSharedLibraryExtension()
{
#ifdef _WIN32
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
return "dll";
#elif __APPLE__
#elif TRINITY_PLATFORM == TRINITY_PLATFORM_APPLE
return "dylib";
#else // Posix
return "so";
#endif
}
#ifdef _WIN32
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
typedef HMODULE HandleType;
#else // Posix
typedef void* HandleType;
@@ -130,7 +130,7 @@ public:
void operator() (HandleType handle) const
{
// Unload the associated shared library.
#ifdef _WIN32
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
bool success = (FreeLibrary(handle) != 0);
#else // Posix
bool success = (dlclose(handle) == 0);
@@ -240,7 +240,7 @@ private:
template<typename Fn>
static bool GetFunctionFromSharedLibrary(HandleType handle, std::string const& name, Fn& fn)
{
#ifdef _WIN32
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
fn = reinterpret_cast<Fn>(GetProcAddress(handle, name.c_str()));
#else // Posix
fn = reinterpret_cast<Fn>(dlsym(handle, name.c_str()));
@@ -259,7 +259,7 @@ Optional<std::shared_ptr<ScriptModule>>
return path;
}();
#ifdef _WIN32
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
HandleType handle = LoadLibrary(load_path.generic_string().c_str());
#else // Posix
HandleType handle = dlopen(load_path.generic_string().c_str(), RTLD_LAZY);
@@ -403,7 +403,7 @@ static std::string CalculateScriptModuleProjectName(std::string const& module)
/// could block the rebuild of new shared libraries.
static bool IsDebuggerBlockingRebuild()
{
#ifdef _WIN32
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
if (IsDebuggerPresent())
return true;
#endif
@@ -1343,7 +1343,7 @@ private:
auto current_path = fs::current_path();
#ifndef _WIN32
#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
// The worldserver location is ${CMAKE_INSTALL_PREFIX}/bin
// on all other platforms then windows
current_path = current_path.parent_path();