Luabind Disclaimer

I'm currently having problems using Luabind to interact with the Lua AI script with a C ++ game.

I call the update function inside the loop (once per frame), and this function extracts information from C ++ functions registered in Luabind.

My problem is this: After a variable of unpredictable time, an assertion error occurs in Luabind that causes an interrupt. The error always occurs in / usr / include / luabind / wrapper _base.hpp: 124 when descending inside Lua.

Do you have any ideas on what can be done? For my tests, the called functions in C ++ and LUA are always the same.

More about the problem:

Content arround statement that is not executed in wrapper_base.hpp

typedef typename boost::mpl::if_<boost::is_void<R>, luabind::detail::proxy_member_void_caller<boost::tuples::tuple<BOOST_PP_ENUM(BOOST_PP_ITERATION(), LUABIND_TUPLE_PARAMS, _)> >
, luabind::detail::proxy_member_caller<R, boost::tuples::tuple<BOOST_PP_ENUM(BOOST_PP_ITERATION(), LUABIND_TUPLE_PARAMS, _)> > >::type proxy_type;

// Comments removed

lua_State* L = m_self.state();
m_self.get(L);
assert(!lua_isnil(L, -1));
detail::do_call_member_selection(L, name);

if (lua_isnil(L, -1))
  {
    lua_pop(L, 1);
    throw std::runtime_error("Attempt to call nonexistent function");
  }

// push the self reference as the first parameter
m_self.get(L);

// now the function and self objects
// are on the stack. These will both
// be popped by pcall
return proxy_type(L, args);

Exact error

bomberman: /usr/include/luabind/wrapper_base.hpp:124: typename boost::mpl::if_<boost::is_void<T>, luabind::detail::proxy_member_void_caller<boost::tuples::tuple<boost::tuples::null_type,       boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >, luabind::detail::proxy_member_caller<R, boost::tuples::tuple<boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >::type luabind::wrap_base::call(const char*, luabind::detail::type_<Derived>*) const [with R = void]:
Assertion `!(lua_type(L, (-1)) == 0)' failed.
Aborted (core dumped)
+3
2

. Lua, , Lua , , ++ - . - , - Lua ++, .

, lua , ++ . , luabind:: object ++, , ++, . :

class LuaC : public BaseC, public luabind::wrap_base {
    private:
        luabind::object _self; //retain a reference to the Lua part of this object so it doesn't get gc'd
    public:
        void setSelf(luabind::object nSelf) { _self=nSelf; }
};
//expose LuaC including the method setSelf
// ...

(BaseC - ++, )

Lua , LuaC, setSelf self

c = LuaC()
c:setSelf(self)

, LuaC, (.. setSelf ). LuaBind , .

, , : Luabind, , shared_ptr s, Lua shared_ptr, ++, . Lua , , Lua , ++ .

+3

, . , ++ .

, , . , .

+1

All Articles