From 74c103ddc16e7148cc92c307e898a400044976a6 Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 2 Aug 2016 18:10:06 +0800 Subject: [PATCH] Fixed types in all GetInterface functions Move lib_t type to Scripts/Types.hpp --- apps/openmw-mp/Script/LangLua/LangLua.cpp | 4 ++-- apps/openmw-mp/Script/LangLua/LangLua.hpp | 2 +- apps/openmw-mp/Script/LangNative/LangNative.cpp | 4 ++-- apps/openmw-mp/Script/LangNative/LangNative.hpp | 4 ++-- apps/openmw-mp/Script/LangPawn/LangPAWN.cpp | 4 ++-- apps/openmw-mp/Script/LangPawn/LangPAWN.hpp | 2 +- apps/openmw-mp/Script/Language.hpp | 2 +- apps/openmw-mp/Script/SystemInterface.hpp | 7 ++----- apps/openmw-mp/Script/Types.hpp | 10 ++++++++++ 9 files changed, 23 insertions(+), 16 deletions(-) diff --git a/apps/openmw-mp/Script/LangLua/LangLua.cpp b/apps/openmw-mp/Script/LangLua/LangLua.cpp index e38333e60..7d8a10a6f 100644 --- a/apps/openmw-mp/Script/LangLua/LangLua.cpp +++ b/apps/openmw-mp/Script/LangLua/LangLua.cpp @@ -9,9 +9,9 @@ using namespace std; -void *LangLua::GetInterface() +lib_t LangLua::GetInterface() { - return lua; + return reinterpret_cast(lua); } LangLua::LangLua(lua_State *lua) diff --git a/apps/openmw-mp/Script/LangLua/LangLua.hpp b/apps/openmw-mp/Script/LangLua/LangLua.hpp index 66bb41a9a..04e7d4046 100644 --- a/apps/openmw-mp/Script/LangLua/LangLua.hpp +++ b/apps/openmw-mp/Script/LangLua/LangLua.hpp @@ -31,7 +31,7 @@ private: using IndicesFor = build_indices; public: - virtual void *GetInterface() override; + virtual lib_t GetInterface() override; template static LuaFuctionData* functions(indices); lua_State *lua; diff --git a/apps/openmw-mp/Script/LangNative/LangNative.cpp b/apps/openmw-mp/Script/LangNative/LangNative.cpp index 7639c53ea..01706b396 100644 --- a/apps/openmw-mp/Script/LangNative/LangNative.cpp +++ b/apps/openmw-mp/Script/LangNative/LangNative.cpp @@ -14,7 +14,7 @@ using namespace std; template -bool SetScript(SystemInterface<>::lib_t lib, const char *name, R value) +bool SetScript(lib_t lib, const char *name, R value) { SystemInterface result(lib, name); @@ -85,7 +85,7 @@ boost::any LangNative::Call(const char *name, const char *argl, const std::vecto } -void *LangNative::GetInterface() +lib_t LangNative::GetInterface() { return lib; } diff --git a/apps/openmw-mp/Script/LangNative/LangNative.hpp b/apps/openmw-mp/Script/LangNative/LangNative.hpp index 1eac6b680..bc1346ca1 100644 --- a/apps/openmw-mp/Script/LangNative/LangNative.hpp +++ b/apps/openmw-mp/Script/LangNative/LangNative.hpp @@ -11,9 +11,9 @@ class LangNative : public Language { - SystemInterface<>::lib_t lib; + lib_t lib; public: - virtual void *GetInterface() override; + virtual lib_t GetInterface() override; LangNative(); ~LangNative(); virtual void LoadProgram(const char *filename) override; diff --git a/apps/openmw-mp/Script/LangPawn/LangPAWN.cpp b/apps/openmw-mp/Script/LangPawn/LangPAWN.cpp index 0de562fd8..f80d72532 100644 --- a/apps/openmw-mp/Script/LangPawn/LangPAWN.cpp +++ b/apps/openmw-mp/Script/LangPawn/LangPAWN.cpp @@ -434,9 +434,9 @@ inline AMX_NATIVE_INFO *LangPAWN::functions(indices) } -void *LangPAWN::GetInterface() +lib_t LangPAWN::GetInterface() { - return amx; + return reinterpret_cast(amx); } LangPAWN::LangPAWN() diff --git a/apps/openmw-mp/Script/LangPawn/LangPAWN.hpp b/apps/openmw-mp/Script/LangPawn/LangPAWN.hpp index fb7b6206f..396970ad1 100644 --- a/apps/openmw-mp/Script/LangPawn/LangPAWN.hpp +++ b/apps/openmw-mp/Script/LangPawn/LangPAWN.hpp @@ -21,7 +21,7 @@ private: using IndicesFor = build_indices; public: - virtual void *GetInterface() override; + virtual lib_t GetInterface() override; template static AMX_NATIVE_INFO* functions(indices); diff --git a/apps/openmw-mp/Script/Language.hpp b/apps/openmw-mp/Script/Language.hpp index 5e7690667..1bc90b26e 100644 --- a/apps/openmw-mp/Script/Language.hpp +++ b/apps/openmw-mp/Script/Language.hpp @@ -20,7 +20,7 @@ public: virtual boost::any Call(const char* name, const char* argl, int buf, ...) = 0; virtual boost::any Call(const char* name, const char* argl, const std::vector& args) = 0; - virtual void * GetInterface() = 0; + virtual lib_t GetInterface() = 0; }; diff --git a/apps/openmw-mp/Script/SystemInterface.hpp b/apps/openmw-mp/Script/SystemInterface.hpp index 52ef9a72d..61f5daafb 100644 --- a/apps/openmw-mp/Script/SystemInterface.hpp +++ b/apps/openmw-mp/Script/SystemInterface.hpp @@ -11,14 +11,11 @@ #include #endif +#include "Types.hpp" + template struct SystemInterface { -#ifdef _WIN32 - typedef HMODULE lib_t; -#else - typedef void* lib_t; -#endif union { diff --git a/apps/openmw-mp/Script/Types.hpp b/apps/openmw-mp/Script/Types.hpp index 2cd9a8995..f9db358db 100644 --- a/apps/openmw-mp/Script/Types.hpp +++ b/apps/openmw-mp/Script/Types.hpp @@ -12,6 +12,16 @@ #include #include +#ifdef _WIN32 +#include +#endif + +#ifdef _WIN32 +typedef HMODULE lib_t; +#else +typedef void* lib_t; +#endif + template struct sizeof_void { enum { value = sizeof(T) }; }; template<> struct sizeof_void { enum { value = 0 }; };