1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-03 20:49:41 +00:00

Fixed types in all GetInterface functions

Move lib_t type to Scripts/Types.hpp
This commit is contained in:
Koncord 2016-08-02 18:10:06 +08:00
parent e513c3676d
commit 74c103ddc1
9 changed files with 23 additions and 16 deletions

View file

@ -9,9 +9,9 @@
using namespace std; using namespace std;
void *LangLua::GetInterface() lib_t LangLua::GetInterface()
{ {
return lua; return reinterpret_cast<lib_t>(lua);
} }
LangLua::LangLua(lua_State *lua) LangLua::LangLua(lua_State *lua)

View file

@ -31,7 +31,7 @@ private:
using IndicesFor = build_indices<N>; using IndicesFor = build_indices<N>;
public: public:
virtual void *GetInterface() override; virtual lib_t GetInterface() override;
template<std::size_t... Indices> template<std::size_t... Indices>
static LuaFuctionData* functions(indices<Indices...>); static LuaFuctionData* functions(indices<Indices...>);
lua_State *lua; lua_State *lua;

View file

@ -14,7 +14,7 @@
using namespace std; using namespace std;
template<typename R> template<typename R>
bool SetScript(SystemInterface<>::lib_t lib, const char *name, R value) bool SetScript(lib_t lib, const char *name, R value)
{ {
SystemInterface<R *> result(lib, name); SystemInterface<R *> 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; return lib;
} }

View file

@ -11,9 +11,9 @@
class LangNative : public Language class LangNative : public Language
{ {
SystemInterface<>::lib_t lib; lib_t lib;
public: public:
virtual void *GetInterface() override; virtual lib_t GetInterface() override;
LangNative(); LangNative();
~LangNative(); ~LangNative();
virtual void LoadProgram(const char *filename) override; virtual void LoadProgram(const char *filename) override;

View file

@ -434,9 +434,9 @@ inline AMX_NATIVE_INFO *LangPAWN::functions(indices<Indices...>)
} }
void *LangPAWN::GetInterface() lib_t LangPAWN::GetInterface()
{ {
return amx; return reinterpret_cast<lib_t>(amx);
} }
LangPAWN::LangPAWN() LangPAWN::LangPAWN()

View file

@ -21,7 +21,7 @@ private:
using IndicesFor = build_indices<N>; using IndicesFor = build_indices<N>;
public: public:
virtual void *GetInterface() override; virtual lib_t GetInterface() override;
template<std::size_t... Indices> template<std::size_t... Indices>
static AMX_NATIVE_INFO* functions(indices<Indices...>); static AMX_NATIVE_INFO* functions(indices<Indices...>);

View file

@ -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, int buf, ...) = 0;
virtual boost::any Call(const char* name, const char* argl, const std::vector<boost::any>& args) = 0; virtual boost::any Call(const char* name, const char* argl, const std::vector<boost::any>& args) = 0;
virtual void * GetInterface() = 0; virtual lib_t GetInterface() = 0;
}; };

View file

@ -11,14 +11,11 @@
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
#include "Types.hpp"
template<typename R = void*> template<typename R = void*>
struct SystemInterface struct SystemInterface
{ {
#ifdef _WIN32
typedef HMODULE lib_t;
#else
typedef void* lib_t;
#endif
union union
{ {

View file

@ -12,6 +12,16 @@
#include <RakNetTypes.h> #include <RakNetTypes.h>
#include <Utils.hpp> #include <Utils.hpp>
#ifdef _WIN32
#include <winsock2.h>
#endif
#ifdef _WIN32
typedef HMODULE lib_t;
#else
typedef void* lib_t;
#endif
template<typename T> struct sizeof_void { enum { value = sizeof(T) }; }; template<typename T> struct sizeof_void { enum { value = sizeof(T) }; };
template<> struct sizeof_void<void> { enum { value = 0 }; }; template<> struct sizeof_void<void> { enum { value = 0 }; };