Re: [luabind] Using raw policy with the property command
Brought to you by:
arvidn,
daniel_wallin
From: Marcus S. <mar...@ho...> - 2008-11-18 11:38:50
|
I found a way of using the raw policy with a property, maybe not the "best" way of doing it but it works in detail/property.hpp add template<class R, class C, class T, class Policies> int get(R(C::*f)(lua_State *) const, T* obj, lua_State* L, Policies* policies) { return returns<R>::call(f, obj, L, policies); } template<class R, class T, class U, class Policies> int get(R(*f)(T, lua_State *), U* obj, lua_State* L, Policies* policies) { return returns<R>::call(f, obj, L, policies); } this will then enable std::string Class::GetName(lua_State *); .property("name", &Class::GetName, raw(_2)) and std::string GetName(lua_State *); .property("name", &GetName, raw(_1)) Marcus Speight Date: Mon, 22 Sep 2008 15:29:29 -0700From: dpo...@ar...To: lua...@li...Subject: [luabind] Using raw policy with the property command I want to use the raw policy with a property as follows: static luabind::object GetChildren(const MyClass *c, lua_State *L){ luabind::object result = luabind::newtable(L); … return result;} class_<MyClass>(“MyClass”) .property(“children”, &GetChildren, raw(_2)) Unfortunately this gives me a compiler error: 1>U:\External\Release\Luabind\luabind/detail/property.hpp(73) : error C2784: 'int luabind::detail::get(R (__cdecl *)(T),U *,lua_State *,Policies *)' : could not deduce template argument for 'R (__cdecl *)(T)' from 'luabind::adl::object (__cdecl *)(const MyClass *,lua_State *)' 1> U:\External\Release\Luabind\luabind/detail/property.hpp(57) : see declaration of 'luabind::detail::get' 1> U:\External\Release\Luabind\luabind/detail/property.hpp(69) : while compiling class template member function 'int luabind::detail::get_caller<T,F,Policies>::operator ()(lua_State *,int,F)' 1> with 1> [ 1> T=MyClass, 1> F=luabind::adl::object (__cdecl *)(const MyClass *,lua_State *), 1> Policies=luabind::detail::policy_cons<luabind::detail::raw_policy<2>,luabind::detail::null_type> 1> ] 1> U:\External\Release\Luabind\luabind/class.hpp(1186) : see reference to class template instantiation 'luabind::detail::get_caller<T,F,Policies>' being compiled 1> with 1> [ 1> T=MyClass, 1> F=luabind::adl::object (__cdecl *)(const MyClass *,lua_State *), 1> Policies=luabind::detail::policy_cons<luabind::detail::raw_policy<2>,luabind::detail::null_type> 1> ] 1> U:\External\Release\Luabind\luabind/class.hpp(919) : see reference to function template instantiation 'luabind::class_<T> &luabind::class_<T>::property_impl<luabind::adl::object(__cdecl *)(const MyClass *,lua_State *),MaybeSetter>(const char *,Getter,GetPolicies,boost::mpl::bool_<C_>)' being compiled 1> with 1> [ 1> T=MyClass, 1> MaybeSetter=luabind::detail::policy_cons<luabind::detail::raw_policy<2>,luabind::detail::null_type>, 1> Getter=luabind::adl::object (__cdecl *)(const MyClass *,lua_State *), 1> GetPolicies=luabind::detail::policy_cons<luabind::detail::raw_policy<2>,luabind::detail::null_type>, 1> C_=true 1> ] 1> .\LQS_ObjectWidget.cpp(219) : see reference to function template instantiation 'luabind::class_<T> &luabind::class_<T>::property<luabind::adl::object(__cdecl *)(const MyClass *,lua_State *),luabind::detail::policy_cons<H,luabind::detail::null_type>>(const char *,Getter,MaybeSetter)' being compiled 1> with 1> [ 1> T=MyClass, 1> H=luabind::detail::raw_policy<2>, 1> Getter=luabind::adl::object (__cdecl *)(const MyClass *,lua_State *), 1> MaybeSetter=luabind::detail::policy_cons<luabind::detail::raw_policy<2>,luabind::detail::null_type> 1> ] 1>U:\External\Release\Luabind\luabind/detail/property.hpp(73) : error C2784: 'int luabind::detail::get(R (__thiscall C::* )(void) const,T *,lua_State *,Policies *)' : could not deduce template argument for 'R (__thiscall C::* )(void) const' from 'luabind::adl::object (__cdecl *)(const MyClass *,lua_State *)' 1> U:\External\Release\Luabind\luabind/detail/property.hpp(51) : see declaration of 'luabind::detail::get' Any notion what might be causing this?Thanks, Dan. _________________________________________________________________ See the most popular videos on the web http://clk.atdmt.com/GBL/go/115454061/direct/01/ |