Re: [luabind] weak_ref issue patch
Brought to you by:
arvidn,
daniel_wallin
From: Christian <neu...@ya...> - 2013-07-23 10:20:29
|
On Tuesday 23 July 2013, at 12:00:29, Glen Fraser <hol...@gm...> wrote: > > The struct name "only_accepts_nonconst_pointers" is meant as an error > > message: adopt only works with non-const pointers (meaning that the > > adopted type must be both a pointer and a non-const one). > > Thanks, Christian -- I saw that, but I don't know how to fix it. Presumably > this is related to the fact that the object I'm trying to "adopt" is held > in a smart pointer (boost::shared_ptr). But I haven't declared the > smart_ptr as const anywhere… > > I declare my class binding like this: > > class_<Actor, Actor_wrapper, boost::shared_ptr<Actor> >("Actor") > .def(constructor<const string &>()) > .def("draw", &Actor::draw, &Actor_wrapper::default_draw) > ]; > > And the function I'm trying to call from C++ is like this: Sorry, I hit accidentaly sent my message before it was finished, here is the function: void bindLuaPart() { luabind::wrapped_self_t& wrapper = luabind::detail::wrap_access::ref(*this); if (wrapper.m_strong_ref.is_valid()) { LOG_W("Double call to wrap_Component::bindLuaPart"); return; } wrapper.get(wrapper.state()); wrapper.m_strong_ref.set(wrapper.state()); } This is highly dependent on implementation details though, but it works at least with the original luabind. |