Returning tables of objects from C++, adopt policy
Using luabind, I create a table of objects from C++
luabind::object create_table(lua_State *L)
{
luabind::object result = luabind::newtable(L);
int index = 1;
for ( ... ) {
lua_Object *o = new lua_Object( ... );
result[ index ++ ] = o;
}
return result;
}
I register the function as
module(L)
[
def("create_table", &create_table)
]
and lua_Object as
class_<lua_Object> reg("Object");
reg
.def(constructor<float,float>())
;
module(L) [ reg ];
How can I tell luabind to take ownership of the objects stored in the table ( new lua_Object( ... ) )? What would be a work around?
Thanks -
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Replace
with
On a side note, don't you have to register
create_table
withraw(_1)
policy?