Bindings generator真是个坑货

bindings-generator自动生成的代码,在通过tolua_cclass注册的时候,析构函数竟然都是nullptr。这样在lua里创建的c++对象,在lua里被释放的时候,会调用tolua_default_collect这个坑函数。
搜一下cocos2d-x的代码,发现只要tolua_cclass注册的时候析构函数不为nullptr竟然都是manual的代码。
本来以为官方推出了个傻瓜点的工具,用了之后发现你要是不懂点lua绑定c++的原理那你就别想出坑了。

通过搜索bindings-generator代码,找到了是ini文件中的参数script_control_cpp控制是否自己管理内存

Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are ‘yes’ or ‘no’.

script_control_cpp = yes