diff options
Diffstat (limited to 'libs/lua/LuaBridge')
-rw-r--r-- | libs/lua/LuaBridge/detail/CFunctions.h | 8 | ||||
-rw-r--r-- | libs/lua/LuaBridge/detail/Namespace.h | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/libs/lua/LuaBridge/detail/CFunctions.h b/libs/lua/LuaBridge/detail/CFunctions.h index b7636f8296..7300e9cb70 100644 --- a/libs/lua/LuaBridge/detail/CFunctions.h +++ b/libs/lua/LuaBridge/detail/CFunctions.h @@ -1167,7 +1167,7 @@ struct CFunc // generate an iterator template <class T, class C> - static int listIterHelper (lua_State *L, C * const t) + static int listIterHelper (lua_State *L, C const * const t) { if (!t) { return luaL_error (L, "invalid pointer to std::list<>/std::vector"); } typedef typename C::const_iterator IterType; @@ -1180,7 +1180,7 @@ struct CFunc template <class T, class C> static int listIter (lua_State *L) { - C * const t = Userdata::get <C> (L, 1, false); + C const * const t = Userdata::get <C> (L, 1, true); return listIterHelper<T, C> (L, t); } @@ -1284,7 +1284,7 @@ struct CFunc static int mapIter (lua_State *L) { typedef std::map<K, V> C; - C * const t = Userdata::get <C> (L, 1, false); + C const * const t = Userdata::get <C> (L, 1, true); if (!t) { return luaL_error (L, "invalid pointer to std::map"); } typedef typename C::const_iterator IterType; new (lua_newuserdata (L, sizeof (IterType*))) IterType (t->begin()); @@ -1378,7 +1378,7 @@ struct CFunc template <class T, class C> static int setIter (lua_State *L) { - C * const t = Userdata::get <C> (L, 1, false); + C const * const t = Userdata::get <C> (L, 1, true); if (!t) { return luaL_error (L, "invalid pointer to std::set"); } typedef typename C::const_iterator IterType; new (lua_newuserdata (L, sizeof (IterType*))) IterType (t->begin()); diff --git a/libs/lua/LuaBridge/detail/Namespace.h b/libs/lua/LuaBridge/detail/Namespace.h index e8c02283b5..a8e190da43 100644 --- a/libs/lua/LuaBridge/detail/Namespace.h +++ b/libs/lua/LuaBridge/detail/Namespace.h @@ -984,6 +984,8 @@ private: DATADOC ("Ext C Function", name, fp) assert (lua_istable (L, -1)); lua_pushcclosure (L, fp, 0); + lua_pushvalue (L, -1); + rawsetfield (L, -5, name); // const table rawsetfield (L, -3, name); // class table return *this; } @@ -1320,11 +1322,15 @@ private: set_shared_class (); assert (lua_istable (L, -1)); lua_pushcclosure (L, fp, 0); + lua_pushvalue (L, -1); + rawsetfield (L, -5, name); // const table rawsetfield (L, -3, name); // class table set_weak_class (); assert (lua_istable (L, -1)); lua_pushcclosure (L, fp, 0); + lua_pushvalue (L, -1); + rawsetfield (L, -5, name); // const table rawsetfield (L, -3, name); // class table return *this; |