diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 92f291d84bc..1cac13eeb6b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,5 +9,5 @@ add_subdirectory(xrCore) #add_subdirectory(xrNetServer) #add_subdirectory(xrParticles) #add_subdirectory(xrPhysics) -#add_subdirectory(xrScriptEngine) +add_subdirectory(xrScriptEngine) #add_subdirectory(xrSound) diff --git a/src/Common/object_cloner.h b/src/Common/object_cloner.h index 8b099a1ae14..c29c6be4835 100644 --- a/src/Common/object_cloner.h +++ b/src/Common/object_cloner.h @@ -15,15 +15,15 @@ struct CCloner struct CHelper { template - IC static void clone(const T& _1, T& _2) + IC static void clone(std::enable_if_t _1, T& _2) { _2 = _1; } - template <> - IC static void clone(const T& _1, T& _2) + template + IC static void clone(std::enable_if_t _1, T& _2) { - _2 = new object_type_traits::remove_pointer::type(*_1); + _2 = new typename object_type_traits::remove_pointer::type(*_1); CCloner::clone(*_1, *_2); } }; @@ -34,8 +34,8 @@ struct CCloner template IC static void clone(const std::pair& _1, std::pair& _2) { - clone(const_cast::type&>(_1.first), - const_cast::type&>(_2.first)); + clone(const_cast::type&>(_1.first), + const_cast::type&>(_2.first)); clone(_1.second, _2.second); } @@ -43,9 +43,9 @@ struct CCloner IC static void clone(const svector& _1, svector& _2) { _2.resize(_1.size()); - svector::iterator J = _2.begin(); - svector::const_iterator I = _1.begin(); - svector::const_iterator E = _1.end(); + typename svector::iterator J = _2.begin(); + typename svector::const_iterator I = _1.begin(); + typename svector::const_iterator E = _1.end(); for (; I != E; ++I, ++J) clone(*I, *J); } @@ -64,7 +64,7 @@ struct CCloner for (; !_2.empty(); _2.pop()) { - std::queue::value_type t; + typename std::queue::value_type t; CCloner::clone(_2.front(), t); __2.push(t); } @@ -84,7 +84,7 @@ struct CCloner for (; !_2.empty(); _2.pop()) { - T1::value_type t; + typename T1::value_type t; CCloner::clone(_2.top(), t); __2.push(t); } @@ -104,7 +104,7 @@ struct CCloner for (; !_2.empty(); _2.pop()) { - T1::value_type t; + typename T1::value_type t; CCloner::clone(_2.top(), t); __2.push(t); } @@ -131,7 +131,7 @@ struct CCloner } template - IC static void add(T1& data, typename T2& value) + IC static void add(T1& data, T2& value) { data.insert(value); } @@ -140,11 +140,11 @@ struct CCloner IC static void clone(const T& _1, T& _2) { _2.clear(); - T::const_iterator I = _1.begin(); - T::const_iterator E = _1.end(); + typename T::const_iterator I = _1.begin(); + typename T::const_iterator E = _1.end(); for (; I != E; ++I) { - T::value_type t; + typename T::value_type t; CCloner::clone(*I, t); add(_2, t); } @@ -155,13 +155,13 @@ struct CCloner struct CHelper4 { template - IC static void clone(const T& _1, T& _2) + IC static void clone(std::enable_if_t _1, T& _2) { - CHelper::clone::value>(_1, _2); + CHelper::template clone::value>(_1, _2); } - template <> - IC static void clone(const T& _1, T& _2) + template + IC static void clone(std::enable_if_t _1, T& _2) { CHelper3::clone(_1, _2); } @@ -170,7 +170,7 @@ struct CCloner template IC static void clone(const T& _1, T& _2) { - CHelper4::clone::value>(_1, _2); + CHelper4::template clone::value>(_1, _2); } }; diff --git a/src/Common/object_comparer.h b/src/Common/object_comparer.h index da9ddb87130..57455832e67 100644 --- a/src/Common/object_comparer.h +++ b/src/Common/object_comparer.h @@ -18,13 +18,13 @@ struct CComparer struct CHelper { template - IC static bool compare(const T& a1, const T& a2, const P& p) + IC static bool compare(std::enable_if_t a1, const T& a2, const P& p) { return p(a1, a2); } - template <> - IC static bool compare(const T& a1, const T& a2, const P& p) + template + IC static bool compare(std::enable_if_t a1, const T& a2, const P& p) { return CComparer::compare(*a1, *a2, p); } @@ -119,8 +119,8 @@ struct CComparer if (a1.size() != a2.size()) return p(); - T::const_iterator I = a1.begin(), J = a2.begin(); - T::const_iterator E = a1.end(); + typename T::const_iterator I = a1.begin(), J = a2.begin(); + typename T::const_iterator E = a1.end(); for (; I != E; ++I, ++J) if (!CComparer::compare(*I, *J, p)) return false; @@ -132,13 +132,13 @@ struct CComparer struct CHelper4 { template - IC static bool compare(const T& a1, const T& a2, const P& p) + IC static bool compare(std::enable_if_t a1, const T& a2, const P& p) { - return CHelper::compare::value>(a1, a2, p); + return CHelper::template compare::value>(a1, a2, p); } - template <> - IC static bool compare(const T& a1, const T& a2, const P& p) + template + IC static bool compare(std::enable_if_t a1, const T& a2, const P& p) { return CHelper3::compare(a1, a2, p); } @@ -147,7 +147,7 @@ struct CComparer template IC static bool compare(const T& a1, const T& a2, const P& p) { - return CHelper4::compare::value>(a1, a2, p); + return CHelper4::template compare::value>(a1, a2, p); } }; diff --git a/src/Common/object_destroyer.h b/src/Common/object_destroyer.h index 9e3ccb4dd1d..ec31bc2d6e0 100644 --- a/src/Common/object_destroyer.h +++ b/src/Common/object_destroyer.h @@ -72,12 +72,12 @@ struct CDestroyer struct CHelper1 { template - static void delete_data(T&) + static void delete_data(std::enable_if_t) { } - template <> - static void delete_data(T& data) + template + static void delete_data(std::enable_if_t data) { data.destroy(); } @@ -87,13 +87,13 @@ struct CDestroyer struct CHelper2 { template - static void delete_data(T& data) + static void delete_data(std::enable_if_t data) { - CHelper1::delete_data::value>(data); + CHelper1::template delete_data::value>(data); } - template <> - static void delete_data(T& data) + template + static void delete_data(std::enable_if_t data) { if (data) CDestroyer::delete_data(*data); @@ -116,13 +116,13 @@ struct CDestroyer struct CHelper4 { template - static void delete_data(T& data) + static void delete_data(std::enable_if_t data) { - CHelper2::delete_data::value>(data); + CHelper2::template delete_data::value>(data); } - template <> - static void delete_data(T& data) + template + static void delete_data(std::enable_if_t data) { CHelper3::delete_data(data); } @@ -131,7 +131,7 @@ struct CDestroyer template static void delete_data(T& data) { - CHelper4::delete_data::value>(data); + CHelper4::template delete_data::value>(data); } }; diff --git a/src/Common/object_loader.h b/src/Common/object_loader.h index dfccf8148e6..db65a521367 100644 --- a/src/Common/object_loader.h +++ b/src/Common/object_loader.h @@ -18,14 +18,14 @@ struct CLoader struct CHelper1 { template - static void load_data(T& data, M& stream, const P& /*p*/) + static void load_data(std::enable_if_t data, M& stream, const P& /*p*/) { static_assert(!std::is_polymorphic::value, "Cannot load polymorphic classes as binary data."); stream.r(&data, sizeof(T)); } - template <> - static void load_data(T& data, M& stream, const P& /*p*/) + template + static void load_data(std::enable_if_t data, M& stream, const P& /*p*/) { T* data1 = const_cast(&data); data1->load(stream); @@ -36,13 +36,13 @@ struct CLoader struct CHelper { template - static void load_data(T& data, M& stream, const P& p) + static void load_data(std::enable_if_t data, M& stream, const P& p) { CHelper1::load_data::value>(data, stream, p); } - template <> - static void load_data(T& data, M& stream, const P& p) + template + static void load_data(std::enable_if_t data, M& stream, const P& p) { CLoader::load_data(*(data = new typename object_type_traits::remove_pointer::type()), stream, p); } @@ -76,14 +76,14 @@ struct CLoader template struct add_helper { - template - static void add(T1& data, T2& value) + template + static void add(std::enable_if_t data, T2& value) { data.push_back(value); } - template <> - static void add(T1& data, T2& value) + template + static void add(std::enable_if_t data, T2& value) { data.insert(value); } @@ -115,13 +115,13 @@ struct CLoader struct CHelper4 { template - static void load_data(T& data, M& stream, const P& p) + static void load_data(std::enable_if_t data, M& stream, const P& p) { CHelper::load_data::value>(data, stream, p); } - template <> - static void load_data(T& data, M& stream, const P& p) + template + static void load_data(std::enable_if_t data, M& stream, const P& p) { CHelper3::load_data(data, stream, p); } diff --git a/src/Common/object_saver.h b/src/Common/object_saver.h index c92f62e355e..3d24a071d7f 100644 --- a/src/Common/object_saver.h +++ b/src/Common/object_saver.h @@ -18,14 +18,14 @@ struct CSaver struct CHelper1 { template - IC static void save_data(const T& data, M& stream, const P& /*p*/) + IC static void save_data(std::enable_if_t, const T& data, M& stream, const P& /*p*/) { static_assert(!std::is_polymorphic::value, "Cannot save polymorphic classes as binary data."); stream.w(&data, sizeof(T)); } - template <> - IC static void save_data(const T& data, M& stream, const P& /*p*/) + template + IC static void save_data(std::enable_if_t, const T& data, M& stream, const P& /*p*/) { T* data1 = const_cast(&data); data1->save(stream); @@ -36,13 +36,13 @@ struct CSaver struct CHelper { template - IC static void save_data(const T& data, M& stream, const P& p) + IC static void save_data(std::enable_if_t, const T& data, M& stream, const P& p) { - CHelper1::save_data::value>(data, stream, p); + CHelper1::template save_data::value>(data, stream, p); } - template <> - IC static void save_data(const T& data, M& stream, const P& p) + template + IC static void save_data(std::enable_if_t, const T& data, M& stream, const P& p) { CSaver::save_data(*data, stream, p); } @@ -54,8 +54,8 @@ struct CSaver IC static void save_data(const T& data, M& stream, const P& p) { stream.w_u32((u32)data.size()); - T::const_iterator I = data.begin(); - T::const_iterator E = data.end(); + typename T::const_iterator I = data.begin(); + typename T::const_iterator E = data.end(); for (; I != E; ++I) if (p(data, *I)) CSaver::save_data(*I, stream, p); @@ -66,13 +66,13 @@ struct CSaver struct CHelper4 { template - IC static void save_data(const T& data, M& stream, const P& p) + IC static void save_data(std::enable_if_t data, M& stream, const P& p) { - CHelper::save_data::value>(data, stream, p); + CHelper::template save_data::value>(data, stream, p); } - template <> - IC static void save_data(const T& data, M& stream, const P& p) + template + IC static void save_data(std::enable_if_t data, M& stream, const P& p) { CHelper3::save_data(data, stream, p); } diff --git a/src/xrScriptEngine/CMakeLists.txt b/src/xrScriptEngine/CMakeLists.txt new file mode 100644 index 00000000000..dd0b6bce2e3 --- /dev/null +++ b/src/xrScriptEngine/CMakeLists.txt @@ -0,0 +1,15 @@ +project(xrScriptEngine) + +list(APPEND DIRS + "." + "LuaStudio" + ) + +add_dir("${DIRS}") + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/luabind ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include ) + +add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES}) + +set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") +target_link_libraries(${PROJECT_NAME} xrAPI xrCore luabind luajit) diff --git a/src/xrScriptEngine/LuaStudio/Backend/Backend.hpp b/src/xrScriptEngine/LuaStudio/Backend/Backend.hpp index 0b06f7a4614..917c71cbc94 100644 --- a/src/xrScriptEngine/LuaStudio/Backend/Backend.hpp +++ b/src/xrScriptEngine/LuaStudio/Backend/Backend.hpp @@ -30,17 +30,17 @@ enum icon_type icon_type_class_instance = unsigned int(4), icon_type_unknown = unsigned int(0), #else - icon_type_nil = unsigned int(0), - icon_type_boolean = unsigned int(1), - icon_type_number = unsigned int(2), - icon_type_string = unsigned int(3), - icon_type_table = unsigned int(4), - icon_type_function = unsigned int(5), - icon_type_coroutine = unsigned int(6), - icon_type_class = unsigned int(7), - icon_type_class_base = unsigned int(8), - icon_type_class_instance = unsigned int(9), - icon_type_unknown = unsigned int(10), + icon_type_nil = (unsigned int) (0), + icon_type_boolean = (unsigned int) (1), + icon_type_number = (unsigned int) (2), + icon_type_string = (unsigned int) (3), + icon_type_table = (unsigned int) (4), + icon_type_function = (unsigned int) (5), + icon_type_coroutine = (unsigned int) (6), + icon_type_class = (unsigned int) (7), + icon_type_class_base = (unsigned int) (8), + icon_type_class_instance = (unsigned int) (9), + icon_type_unknown = (unsigned int) (10), #endif }; diff --git a/src/xrScriptEngine/LuaStudio/Config.hpp b/src/xrScriptEngine/LuaStudio/Config.hpp index 74296d22938..0e7fa56d73a 100644 --- a/src/xrScriptEngine/LuaStudio/Config.hpp +++ b/src/xrScriptEngine/LuaStudio/Config.hpp @@ -10,6 +10,7 @@ #include "xrScriptEngine/LuaStudio/Defines.hpp" +#if !defined(LINUX) #if defined(WIN32) #define CS_PLATFORM_WINDOWS_32 #define CS_PLATFORM_ID @@ -20,6 +21,7 @@ #else // #elif defined(_XBOX) STATIC_CHECK(false, Unknown_Platform); #endif // #elif defined(_XBOX) +#endif #ifdef DEBUG #define CS_DEBUG_LIBRARIES diff --git a/src/xrScriptEngine/ScriptExporter.hpp b/src/xrScriptEngine/ScriptExporter.hpp index 6f2e306ea7d..ffc47fc7a18 100644 --- a/src/xrScriptEngine/ScriptExporter.hpp +++ b/src/xrScriptEngine/ScriptExporter.hpp @@ -1,5 +1,5 @@ #pragma once -#include "xrScriptEngine/xrScriptEngine.hpp" +#include "xrScriptEngine.hpp" struct lua_State; diff --git a/src/xrScriptEngine/mslotutils.h b/src/xrScriptEngine/mslotutils.h index 4fa5d667a83..7d4e89c6c6d 100644 --- a/src/xrScriptEngine/mslotutils.h +++ b/src/xrScriptEngine/mslotutils.h @@ -96,23 +96,29 @@ class CMailSlotMsg inline HANDLE CreateMailSlotByName(LPCSTR slotName) { +#if defined(WINDOWS) HANDLE hSlot = CreateMailslot(slotName, 0, // no maximum message size MAILSLOT_WAIT_FOREVER, // no time-out for operations (LPSECURITY_ATTRIBUTES)NULL); // no security attributes return hSlot; +#elif defined(LINUX) + return NULL; +#endif } inline BOOL CheckExisting(LPCSTR slotName) { HANDLE hFile; BOOL res; +#if defined(WINDOWS) hFile = CreateFile(slotName, GENERIC_WRITE, FILE_SHARE_READ, // required to write to a mailslot (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL); res = hFile != INVALID_HANDLE_VALUE; if (res) CloseHandle(hFile); +#endif return res; } @@ -121,6 +127,7 @@ inline BOOL SendMailslotMessage(LPCSTR slotName, CMailSlotMsg& msg) BOOL fResult; HANDLE hFile; DWORD cbWritten; +#if defined(WINDOWS) hFile = CreateFile(slotName, GENERIC_WRITE, FILE_SHARE_READ, // required to write to a mailslot (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL); @@ -131,6 +138,7 @@ inline BOOL SendMailslotMessage(LPCSTR slotName, CMailSlotMsg& msg) R_ASSERT(fResult); fResult = CloseHandle(hFile); R_ASSERT(fResult); +#endif return fResult; } @@ -138,6 +146,7 @@ inline BOOL CheckMailslotMessage(HANDLE hSlot, CMailSlotMsg& msg) { DWORD cbMessage, cMessage, cbRead; BOOL fResult; +#if defined(WINDOWS) HANDLE hEvent; OVERLAPPED ov; cbMessage = cMessage = cbRead = 0; @@ -163,5 +172,6 @@ inline BOOL CheckMailslotMessage(HANDLE hSlot, CMailSlotMsg& msg) msg.SetLen(cbRead); R_ASSERT(fResult); CloseHandle(hEvent); +#endif return fResult; } diff --git a/src/xrScriptEngine/pch.hpp b/src/xrScriptEngine/pch.hpp index 63f2fb6c647..c36ec378bbb 100644 --- a/src/xrScriptEngine/pch.hpp +++ b/src/xrScriptEngine/pch.hpp @@ -1,4 +1,6 @@ #pragma once #include "Common/Common.hpp" #include "xrScriptEngine.hpp" +#ifndef LINUX #include "xrCore/_std_extensions.h" +#endif diff --git a/src/xrScriptEngine/script_debugger.cpp b/src/xrScriptEngine/script_debugger.cpp index f1bba9523bb..ea0041e3ff3 100644 --- a/src/xrScriptEngine/script_debugger.cpp +++ b/src/xrScriptEngine/script_debugger.cpp @@ -121,11 +121,13 @@ CScriptDebugger::CScriptDebugger(CScriptEngine* scriptEngine) // m_pDebugger = this; m_nLevel = 0; m_mailSlot = CreateMailSlotByName(DEBUGGER_MAIL_SLOT); +#if defined(WINDOWS) if (m_mailSlot == INVALID_HANDLE_VALUE) { m_bIdePresent = false; return; } +#endif Connect(IDE_MAIL_SLOT); } @@ -148,7 +150,9 @@ CScriptDebugger::~CScriptDebugger() { if (Active()) _SendMessage(DMSG_CLOSE_CONNECTION, 0, 0); +#if defined(WINDOWS) CloseHandle(m_mailSlot); +#endif xr_delete(m_threads); xr_delete(m_callStack); xr_delete(m_lua); diff --git a/src/xrScriptEngine/script_debugger.hpp b/src/xrScriptEngine/script_debugger.hpp index 7123527c73f..38ff88c4b4f 100644 --- a/src/xrScriptEngine/script_debugger.hpp +++ b/src/xrScriptEngine/script_debugger.hpp @@ -3,7 +3,7 @@ #include "xrScriptEngine/xrScriptEngine.hpp" #include "script_lua_helper.hpp" #include "script_debugger_threads.hpp" -#include "script_CallStack.hpp" +#include "script_callStack.hpp" #include "script_debugger_messages.hpp" class CMailSlotMsg; diff --git a/src/xrScriptEngine/script_process.cpp b/src/xrScriptEngine/script_process.cpp index ad49c92b2ac..613078e5fd4 100644 --- a/src/xrScriptEngine/script_process.cpp +++ b/src/xrScriptEngine/script_process.cpp @@ -10,7 +10,7 @@ #include "script_engine.hpp" #include "script_process.hpp" #include "script_thread.hpp" -#include "common/object_broker.h" +#include "Common/object_broker.h" string4096 g_ca_stdout; // XXX: allocate dynamically for each CScriptEngine instance