From 1c941a031b9382b3c98f00a0fcf39dc20c135a24 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 19 Dec 2014 22:34:38 +0100 Subject: [PATCH] [DEV] change some internal interface --- .gitignore | 1 + luaWrapper/luaWrapper.hpp | 105 ++++++++++++-------- luaWrapper/luaWrapperStd.cpp | 132 +++++++++++++++++++++++++ luaWrapper/luaWrapperUtil.hpp | 175 ++++++++------------------------- lutin_luaWrapper.py | 7 ++ sample/example2/LuaExample.cpp | 4 +- 6 files changed, 247 insertions(+), 177 deletions(-) create mode 100644 .gitignore create mode 100644 luaWrapper/luaWrapperStd.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/luaWrapper/luaWrapper.hpp b/luaWrapper/luaWrapper.hpp index 605f548..15819e0 100644 --- a/luaWrapper/luaWrapper.hpp +++ b/luaWrapper/luaWrapper.hpp @@ -37,6 +37,7 @@ // If you are linking against Lua compiled in C++, define LUAW_NO_EXTERN_C #include #include +#include #define LUAW_POSTCTOR_KEY "__postctor" #define LUAW_EXTENDS_KEY "__extends" @@ -59,12 +60,8 @@ inline int luaW_correctindex(lua_State* _L, int _index, int _correction) { * alternative option, you may select a different function when registering * your class. */ -template T* luaW_defaultallocator(lua_State*) { - return new T(); -} - -template void luaW_defaultdeallocator(lua_State*, T* _obj) { - delete _obj; +template std::shared_ptr luaW_defaultallocator(lua_State* _L) { + return std::make_shared(); } /** @@ -74,8 +71,8 @@ template void luaW_defaultdeallocator(lua_State*, T* _obj) { * are using shared_ptr you would need to push the address of the object the * shared_ptr represents, rather than the address of the shared_ptr itself. */ -template void luaW_defaultidentifier(lua_State* _L, T* _obj) { - lua_pushlightuserdata(_L, _obj); +template void luaW_defaultidentifier(lua_State* _L, std::shared_ptr _obj) { + lua_pushlightuserdata(_L, _obj.get()); } /** @@ -87,12 +84,12 @@ template void luaW_defaultidentifier(lua_State* _L, T* _obj) { * when and object is the type I want. This is only used internally. */ struct luaW_Userdata { - luaW_Userdata(void* vptr = NULL, luaW_Userdata (*udcast)(const luaW_Userdata&) = NULL) : + luaW_Userdata(std::shared_ptr vptr = NULL, luaW_Userdata (*udcast)(const luaW_Userdata&) = NULL) : data(vptr), cast(udcast) { // nothing to do ... } - void* data; + std::shared_ptr data; luaW_Userdata (*cast)(const luaW_Userdata&); }; @@ -103,18 +100,16 @@ struct luaW_Userdata { template class LuaWrapper { public: static const char* classname; - static void (*identifier)(lua_State*, T*); - static T* (*allocator)(lua_State*); - static void (*deallocator)(lua_State*, T*); + static void (*identifier)(lua_State*, std::shared_ptr); + static std::shared_ptr (*allocator)(lua_State*); static luaW_Userdata (*cast)(const luaW_Userdata&); static void (*postconstructorrecurse)(lua_State* _L, int numargs); private: LuaWrapper(); }; template const char* LuaWrapper::classname; -template void (*LuaWrapper::identifier)(lua_State*, T*); -template T* (*LuaWrapper::allocator)(lua_State*); -template void (*LuaWrapper::deallocator)(lua_State*, T*); +template void (*LuaWrapper::identifier)(lua_State*, std::shared_ptr); +template std::shared_ptr (*LuaWrapper::allocator)(lua_State*); template luaW_Userdata (*LuaWrapper::cast)(const luaW_Userdata&); template void (*LuaWrapper::postconstructorrecurse)(lua_State* _L, int _numargs); @@ -124,7 +119,7 @@ template void (*LuaWrapper::postconstructorrecurse)(lua_State* _ * internally. */ template luaW_Userdata luaW_cast(const luaW_Userdata& _obj) { - return luaW_Userdata(static_cast(static_cast(_obj.data)), LuaWrapper::cast); + return luaW_Userdata(static_cast(std::static_pointer_cast(_obj.data)), LuaWrapper::cast); } template void luaW_identify(lua_State* _L, T* _obj) { @@ -174,7 +169,7 @@ template bool luaW_is(lua_State *_L, int _index, bool _strict = fal * Converts the given acceptable index to a T*. That value must be of (or * convertable to) type T; otherwise, returns NULL. */ -template T* luaW_to(lua_State* _L, int _index, bool _strict = false) { +template std::shared_ptr luaW_to(lua_State* _L, int _index, bool _strict = false) { if (luaW_is(_L, _index, _strict)) { luaW_Userdata* pud = static_cast(lua_touserdata(_L, _index)); luaW_Userdata ud; @@ -183,7 +178,7 @@ template T* luaW_to(lua_State* _L, int _index, bool _strict = false ud = pud->cast(*pud); pud = &ud; } - return static_cast(pud->data); + return std::static_pointer_cast(pud->data); } return NULL; } @@ -194,8 +189,8 @@ template T* luaW_to(lua_State* _L, int _index, bool _strict = false * Converts the given acceptable index to a T*. That value must be of (or * convertable to) type T; otherwise, an error is raised. */ -template T* luaW_check(lua_State* _L, int _index, bool _strict = false) { - T* obj = NULL; +template std::shared_ptr luaW_check(lua_State* _L, int _index, bool _strict = false) { + std::shared_ptr obj; if (luaW_is(_L, _index, _strict)) { luaW_Userdata* pud = static_cast(lua_touserdata(_L, _index)); luaW_Userdata ud; @@ -203,7 +198,7 @@ template T* luaW_check(lua_State* _L, int _index, bool _strict = fa ud = pud->cast(*pud); pud = &ud; } - obj = (T*)pud->data; + obj = std::static_pointer_cast(pud->data); } else { const char *msg = lua_pushfstring(_L, "%s expected, got %s", LuaWrapper::classname, luaL_typename(_L, _index)); luaL_argerror(_L, _index, msg); @@ -211,7 +206,7 @@ template T* luaW_check(lua_State* _L, int _index, bool _strict = fa return obj; } -template T* luaW_opt(lua_State* _L, int _index, T* _fallback = NULL, bool _strict = false) { +template std::shared_ptr luaW_opt(lua_State* _L, int _index, std::shared_ptr _fallback = nullptr, bool _strict = false) { if (lua_isnil(_L, _index)) { return _fallback; } else { @@ -226,7 +221,7 @@ template T* luaW_opt(lua_State* _L, int _index, T* _fallback = NULL * the Lua environment, it will assign the existing storage table to it. * Otherwise, a new storage table will be created for it. */ -template void luaW_push(lua_State* _L, T* _obj) { +template void luaW_push(lua_State* _L, std::shared_ptr _obj) { if (_obj) { LuaWrapper::identifier(_L, _obj); // ... id luaW_wrapperfield(_L, LUAW_CACHE_KEY); // ... id cache @@ -262,7 +257,7 @@ template void luaW_push(lua_State* _L, T* _obj) { * Returns true if luaW_hold took hold of the object, and false if it was * already held */ -template bool luaW_hold(lua_State* _L, T* _obj) { +template bool luaW_hold(lua_State* _L, std::shared_ptr _obj) { luaW_wrapperfield(_L, LUAW_HOLDS_KEY); // ... holds LuaWrapper::identifier(_L, _obj); // ... holds id lua_pushvalue(_L, -1); // ... holds id id @@ -346,7 +341,7 @@ template void luaW_postconstructor(lua_State* _L, int _numargs) { */ template inline int luaW_new(lua_State* _L, int _numargs) { // ... args... - T* obj = LuaWrapper::allocator(_L); + std::shared_ptr obj = LuaWrapper::allocator(_L); luaW_push(_L, obj); // ... args... ud luaW_hold(_L, obj); lua_insert(_L, -1 - _numargs); // ... ud args... @@ -369,7 +364,7 @@ template int luaW_new(lua_State* _L) { */ template int luaW_index(lua_State* _L) { // obj key - T* obj = luaW_to(_L, 1); + std::shared_ptr obj = luaW_to(_L, 1); luaW_wrapperfield(_L, LUAW_STORAGE_KEY); // obj key storage LuaWrapper::identifier(_L, obj); // obj key storage id lua_gettable(_L, -2); // obj key storage store @@ -400,7 +395,7 @@ template int luaW_index(lua_State* _L) { */ template int luaW_newindex(lua_State* _L) { // obj key value - T* obj = luaW_check(_L, 1); + std::shared_ptr obj = luaW_check(_L, 1); luaW_wrapperfield(_L, LUAW_STORAGE_KEY); // obj key value storage LuaWrapper::identifier(_L, obj); // obj key value storage id lua_pushvalue(_L, -1); // obj key value storage id id @@ -428,13 +423,13 @@ template int luaW_newindex(lua_State* _L) { */ template int luaW_gc(lua_State* _L) { // obj - T* obj = luaW_to(_L, 1); + std::shared_ptr obj = luaW_to(_L, 1); LuaWrapper::identifier(_L, obj); // obj key value storage id luaW_wrapperfield(_L, LUAW_HOLDS_KEY); // obj id counts count holds lua_pushvalue(_L, 2); // obj id counts count holds id lua_gettable(_L, -2); // obj id counts count holds hold - if (lua_toboolean(_L, -1) && LuaWrapper::deallocator) { - LuaWrapper::deallocator(_L, obj); + if (lua_toboolean(_L, -1)) { + obj.reset(); } luaW_wrapperfield(_L, LUAW_STORAGE_KEY); // obj id counts count holds hold storage lua_pushvalue(_L, 2); // obj id counts count holds hold storage id @@ -531,14 +526,12 @@ template void luaW_setfuncs(lua_State* _L, const char* _classname, const luaL_Reg* _table, const luaL_Reg* _metatable, - T* (*_allocator)(lua_State*) = luaW_defaultallocator, - void (*_deallocator)(lua_State*, T*) = luaW_defaultdeallocator, - void (*_identifier)(lua_State*, T*) = luaW_defaultidentifier) { + std::shared_ptr (*_allocator)(lua_State*), + void (*_identifier)(lua_State*, std::shared_ptr)) { luaW_initialize(_L); LuaWrapper::classname = _classname; LuaWrapper::identifier = _identifier; LuaWrapper::allocator = _allocator; - LuaWrapper::deallocator = _deallocator; const luaL_Reg defaulttable[] = { { "new", luaW_new }, { NULL, NULL } @@ -575,15 +568,46 @@ template void luaW_setfuncs(lua_State* _L, luaW_registerfuncs(_L, defaultmetatable, _metatable); // ... T mt lua_setfield(_L, -2, "metatable"); // ... T } +template void luaW_setfuncs(lua_State* _L, + const char* _classname, + const luaL_Reg* _table, + const luaL_Reg* _metatable, + std::shared_ptr (*_allocator)(lua_State*)) { + luaW_setfuncs(_L, _classname, _table, _metatable, _allocator, luaW_defaultidentifier); +} +template void luaW_setfuncs(lua_State* _L, + const char* _classname, + const luaL_Reg* _table, + const luaL_Reg* _metatable) { + luaW_setfuncs(_L, _classname, _table, _metatable, luaW_defaultallocator, luaW_defaultidentifier); +} template void luaW_register(lua_State* _L, const char* _classname, const luaL_Reg* _table, const luaL_Reg* _metatable, - T* (*_allocator)(lua_State*) = luaW_defaultallocator, - void (*_deallocator)(lua_State*, T*) = luaW_defaultdeallocator, - void (*_identifier)(lua_State*, T*) = luaW_defaultidentifier) { - luaW_setfuncs(_L, _classname, _table, _metatable, _allocator, _deallocator, _identifier); // ... T + std::shared_ptr (*_allocator)(lua_State*), + void (*_identifier)(lua_State*, std::shared_ptr)) { + luaW_setfuncs(_L, _classname, _table, _metatable, _allocator, _identifier); // ... T + lua_pushvalue(_L, -1); // ... T T + lua_setglobal(_L, _classname); // ... T +} + +template void luaW_register(lua_State* _L, + const char* _classname, + const luaL_Reg* _table, + const luaL_Reg* _metatable, + std::shared_ptr (*_allocator)(lua_State*)) { + luaW_setfuncs(_L, _classname, _table, _metatable, _allocator, luaW_defaultidentifier); + lua_pushvalue(_L, -1); // ... T T + lua_setglobal(_L, _classname); // ... T +} + +template void luaW_register(lua_State* _L, + const char* _classname, + const luaL_Reg* _table, + const luaL_Reg* _metatable) { + luaW_setfuncs(_L, _classname, _table, _metatable, luaW_defaultallocator, luaW_defaultidentifier); // ... T lua_pushvalue(_L, -1); // ... T T lua_setglobal(_L, _classname); // ... T } @@ -641,3 +665,6 @@ template void luaW_extend(lua_State* _L) { } #endif + +#include +//#include diff --git a/luaWrapper/luaWrapperStd.cpp b/luaWrapper/luaWrapperStd.cpp new file mode 100644 index 0000000..a37f022 --- /dev/null +++ b/luaWrapper/luaWrapperStd.cpp @@ -0,0 +1,132 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ +#ifndef LUA_WRAPPER_STD_H__ +#define LUA_WRAPPER_STD_H__ + +#include + +#include +#include +#include + +/** + * LuaWrapper knows about primitive types like ints and floats, but it doesn't + * know about things like std::strings or other more complicated types. + * Sometimes, rather than register the type with LuaWrapper, it's easier to + * be able to convert it to and from Lua's primitive types, like strings or + * tables. + * + * To do this, you must write luaU_check, luaU_to and luaU_push functions for + * your type. You don't always need all three, it depends on if you're pushing + * objects to Lua, getting objects from Lua, or both. + * + * This example uses std::string, but if you have other custom string types it + * should be easy to write versions of those functions too + */ +template<> std::string luaU_check(lua_State* _L, int _index) { + return std::string(luaL_checkstring(_L, _index)); +} +template<> std::string luaU_to(lua_State* _L, int _index) { + return std::string(lua_tostring(_L, _index)); +} +template<> void luaU_push(lua_State* _L, const std::string& _val) { + lua_pushstring(_L, _val.c_str()); +} + +template<> bool luaU_check(lua_State* _L, int _index) { + return lua_toboolean(_L, _index) != 0; +} +template<> bool luaU_to(lua_State* _L, int _index) { + return lua_toboolean(_L, _index) != 0; +} +template<> void luaU_push(lua_State* _L, const bool& _value) { + lua_pushboolean(_L, _value); +} + +template<> const char* luaU_check(lua_State* _L, int _index) { + return luaL_checkstring(_L, _index); +} +template<> const char* luaU_to(lua_State* _L, int _index) { + return lua_tostring(_L, _index); +} +template<> void luaU_push(lua_State* _L, const char* const& _value) { + lua_pushstring(_L, _value); +} + +template<> const char* const luaU_check(lua_State* _L, int _index) { + return luaL_checkstring(_L, _index); +} +template<> const char* const luaU_to(lua_State* _L, int _index) { + return lua_tostring(_L, _index); +} +template<> void luaU_push(lua_State* _L, const char* const& _value) { + lua_pushstring(_L, _value); +} + +template<> unsigned int luaU_check(lua_State* _L, int _index) { + return static_cast(luaL_checkinteger(_L, _index)); +} +template<> unsigned int luaU_to(lua_State* _L, int _index) { + return static_cast(lua_tointeger(_L, _index)); +} +template<> void luaU_push(lua_State* _L, const unsigned int& _value) { + lua_pushinteger(_L, _value); +} + +template<> int luaU_check(lua_State* _L, int _index) { + return static_cast(luaL_checkinteger(_L, _index)); +} +template<> int luaU_to(lua_State* _L, int _index) { + return static_cast(lua_tointeger(_L, _index)); +} +template<> void luaU_push(lua_State* _L, const int& _value) { + lua_pushinteger(_L, _value); +} + +template<> unsigned char luaU_check(lua_State* _L, int _index) { + return static_cast(luaL_checkinteger(_L, _index)); +} +template<> unsigned char luaU_to(lua_State* _L, int _index) { + return static_cast(lua_tointeger(_L, _index)); +} +template<> void luaU_push(lua_State* _L, const unsigned char& _value) { + lua_pushinteger(_L, _value); +} + +template<> char luaU_check(lua_State* _L, int _index) { + return static_cast(luaL_checkinteger(_L, _index)); +} +template<> char luaU_to(lua_State* _L, int _index) { + return static_cast(lua_tointeger(_L, _index)); +} +template<> void luaU_push(lua_State* _L, const char& _value) { + lua_pushinteger(_L, _value); +} + +template<> float luaU_check(lua_State* _L, int _index) { + return static_cast(luaL_checknumber(_L, _index)); +} +template<> float luaU_to(lua_State* _L, int _index) { + return static_cast(lua_tonumber(_L, _index)); +} +template<> void luaU_push(lua_State* _L, const float& _value) { + lua_pushnumber(_L, _value); +} + +template<> double luaU_check(lua_State* _L, int _index) { + return static_cast(luaL_checknumber(_L, _index)); +} +template<> double luaU_to(lua_State* _L, int _index) { + return static_cast(lua_tonumber(_L, _index)); +} +template<> void luaU_push(lua_State* _L, const double& _value) { + lua_pushnumber(_L, _value); +} + + +#endif diff --git a/luaWrapper/luaWrapperUtil.hpp b/luaWrapper/luaWrapperUtil.hpp index eb767ad..0526835 100644 --- a/luaWrapper/luaWrapperUtil.hpp +++ b/luaWrapper/luaWrapperUtil.hpp @@ -41,155 +41,58 @@ template struct luaW_remove_cr { * LuaWrapper, especially with small objects. */ -template struct luaU_Impl { - static U luaU_check(lua_State* _L, int _index); - static U luaU_to(lua_State* _L, int _index); - static void luaU_push(lua_State* _L, const U& _value); -}; +template U luaU_check(lua_State* _L, int _index); +template U luaU_to(lua_State* _L, int _index); +template void luaU_push(lua_State* _L, const U& _value); +/* template U luaU_check(lua_State* _L, int _index) { - return luaU_Impl::luaU_check(_L, _index); + return implem_luaU_check(_L, _index); } template U luaU_to(lua_State* _L, int _index) { - return luaU_Impl::luaU_to(_L, _index); + return implem_luaU_to(_L, _index); } template void luaU_push(lua_State* _L, const U& _value) { - luaU_Impl::luaU_push(_L, _value); + implem_luaU_push(_L, _value); } +*/ -/** This is slightly different than the previous three functions in that you +/** + * This is slightly different than the previous three functions in that you * shouldn't need to write your own version of it, since it uses luaU_check * automatically. */ template U luaU_opt(lua_State* _L, int _index, const U& _fallback = U()) { - if (lua_isnil(_L, _index)) + if (lua_isnil(_L, _index)) { return _fallback; - else - return luaU_Impl::luaU_check(_L, _index); + } else { + return luaU_check(_L, _index); + } +} +/* +template T implem_luaU_check::value>::type>(lua_State* _L, int _index) { + return static_cast(luaL_checkinteger(_L, _index)); +} +template T implem_luaU_to::value>::type>(lua_State* _L, int _index) { + return static_cast(lua_tointeger(_L, _index)); +} +template void implem_luaU_push::value>::type>(lua_State* _L, const T& _value) { + lua_pushnumber(_L, static_cast(_value)); } -template<> struct luaU_Impl { - static bool luaU_check(lua_State* _L, int _index) { - return lua_toboolean(_L, _index) != 0; - } - static bool luaU_to(lua_State* _L, int _index) { - return lua_toboolean(_L, _index) != 0; - } - static void luaU_push(lua_State* _L, const bool& _value) { - lua_pushboolean(_L, _value); - } -}; - -template<> struct luaU_Impl { - static const char* luaU_check(lua_State* _L, int _index) { - return luaL_checkstring(_L, _index); - } - static const char* luaU_to(lua_State* _L, int _index) { - return lua_tostring(_L, _index); - } - static void luaU_push(lua_State* _L, const char* const& _value) { - lua_pushstring(_L, _value); - } -}; - -template<> struct luaU_Impl { - static unsigned int luaU_check(lua_State* _L, int _index) { - return static_cast(luaL_checkinteger(_L, _index)); - } - static unsigned int luaU_to(lua_State* _L, int _index) { - return static_cast(lua_tointeger(_L, _index)); - } - static void luaU_push(lua_State* _L, const unsigned int& _value) { - lua_pushinteger(_L, _value); - } -}; - -template<> struct luaU_Impl { - static int luaU_check(lua_State* _L, int _index) { - return static_cast(luaL_checkinteger(_L, _index)); - } - static int luaU_to(lua_State* _L, int _index) { - return static_cast(lua_tointeger(_L, _index)); - } - static void luaU_push(lua_State* _L, const int& _value) { - lua_pushinteger(_L, _value); - } -}; - -template<> struct luaU_Impl { - static unsigned char luaU_check(lua_State* _L, int _index) { - return static_cast(luaL_checkinteger(_L, _index)); - } - static unsigned char luaU_to(lua_State* _L, int _index) { - return static_cast(lua_tointeger(_L, _index)); - } - static void luaU_push(lua_State* _L, const unsigned char& _value) { - lua_pushinteger(_L, _value); - } -}; - -template<> struct luaU_Impl { - static char luaU_check(lua_State* _L, int _index) { - return static_cast(luaL_checkinteger(_L, _index)); - } - static char luaU_to(lua_State* _L, int _index) { - return static_cast(lua_tointeger(_L, _index)); - } - static void luaU_push(lua_State* _L, const char& _value) { - lua_pushinteger(_L, _value); - } -}; - -template<> struct luaU_Impl { - static float luaU_check(lua_State* _L, int _index) { - return static_cast(luaL_checknumber(_L, _index)); - } - static float luaU_to(lua_State* _L, int _index) { - return static_cast(lua_tonumber(_L, _index)); - } - static void luaU_push(lua_State* _L, const float& _value) { - lua_pushnumber(_L, _value); - } -}; - -template<> struct luaU_Impl { - static double luaU_check(lua_State* _L, int _index) { - return static_cast(luaL_checknumber(_L, _index)); - } - static double luaU_to(lua_State* _L, int _index) { - return static_cast(lua_tonumber(_L, _index)); - } - static void luaU_push(lua_State* _L, const double& _value) { - lua_pushnumber(_L, _value); - } -}; - -template struct luaU_Impl::value>::type> { - static T luaU_check(lua_State* _L, int _index) { - return static_cast(luaL_checkinteger(_L, _index)); - } - static T luaU_to(lua_State* _L, int _index) { - return static_cast(lua_tointeger(_L, _index)); - } - static void luaU_push(lua_State* _L, const T& _value) { - lua_pushnumber(_L, static_cast(_value)); - } -}; - -template struct luaU_Impl::value>::type> { - static T* luaU_check(lua_State* _L, int _index) { - return luaW_check(_L, _index); - } - static T* luaU_to(lua_State* _L, int _index) { - return luaW_to(_L, _index); - } - static void luaU_push(lua_State* _L, T*& _value) { - luaW_push (_L, _value); - } - static void luaU_push(lua_State* _L, T* _value) { - luaW_push (_L, _value); - } -}; +template T* implem_luaU_check::value>::type>(lua_State* _L, int _index) { + return luaW_check(_L, _index); +} +template T* implem_luaU_to::value>::type>(lua_State* _L, int _index) { + return luaW_to(_L, _index); +} +template void implem_luaU_push::value>::type>(lua_State* _L, T*& _value) { + luaW_push (_L, _value); +} +template void implem_luaU_push::value>::type>(lua_State* _L, T* _value) { + luaW_push (_L, _value); +} +*/ /** * These are just some functions I've always felt should exist @@ -590,7 +493,7 @@ template static int callImpl(lua_State* _L, luaU_IntPack) { - luaU_push(_L, (luaW_check(_L, 1)->*MemberFunc)(luaU_check::type>(_L, indices)...)); + luaU_push(_L, ((*luaW_check(_L, 1)).*MemberFunc)(luaU_check::type>(_L, indices)...)); return 1; } }; @@ -602,7 +505,7 @@ template struct luaU_Memb } private: template static int callImpl(lua_State* _L, luaU_IntPack) { - (luaW_check(_L, 1)->*MemberFunc)(luaU_check::type>(_L, indices)...); + ((*luaW_check(_L, 1)).*MemberFunc)(luaU_check::type>(_L, indices)...); return 0; } }; diff --git a/lutin_luaWrapper.py b/lutin_luaWrapper.py index 91958eb..84247de 100644 --- a/lutin_luaWrapper.py +++ b/lutin_luaWrapper.py @@ -13,6 +13,13 @@ def create(target): # name of the dependency myModule.add_module_depend('lua') + # add extra compilation flags : + myModule.add_extra_compile_flags() + # add the file to compile: + myModule.add_src_file([ + 'luaWrapper/luaWrapperStd.cpp' + ]) + myModule.add_export_path(tools.get_current_path(__file__)) # add the currrent module at the diff --git a/sample/example2/LuaExample.cpp b/sample/example2/LuaExample.cpp index be083aa..7d66495 100644 --- a/sample/example2/LuaExample.cpp +++ b/sample/example2/LuaExample.cpp @@ -132,9 +132,9 @@ static luaL_Reg Example_metatable[] = { { NULL, NULL } }; -int luaopen_Example(lua_State* L) +int luaopen_Example(lua_State* _L) { - luaW_register(L, "Example", NULL, Example_metatable); + luaW_register(_L, "Example", NULL, Example_metatable); return 1; }