[luabind] default_converter and luabind assignment
Brought to you by:
arvidn,
daniel_wallin
From: <Aru...@hi...> - 2014-01-08 17:56:05
|
Hi, I want to add support to a user type in luabind, so that I can assign c++ variables of the type to lua variables like so: struct UserType{..}; //and then do UserType u; luabind::globals(L)["UserTypeList"]["a"] = u; //equivalent to saying UserTypeList.a = u in Lua. I registered the class type via luabind::class_ and specialized the default_converter for the type : module(L)[ class_< UserType>("_ UserType")]; namespace luabind{ template<> struct default_converter< UserType> : native_converter_base< UserType> { //define compute_score, to and from functions. }; } But when I actually do the assignment, the converter code doesn't get called. I'm expecting the 'to' function in the converter to get called, since I'm assigning a custom type to a lua object, which doesn't happen. Is this the correct way to do this. Please let me know if you find any issues with this setup. Thanks arun. |