使用SWIG在Lua中实现和继承C ++类 [英] Implementing and inheriting from C++ classes in Lua using SWIG

查看:251
本文介绍了使用SWIG在Lua中实现和继承C ++类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 Lua SWIG ,并说一个IInterface类,以实现该接口,并在Lua中实例化它?

Would it be possible using Lua and SWIG and say an IInterface class, to implement that interface and instantiate it all within Lua? If so how would it be done?

推荐答案

通过保存指向lua状态的指针将表存储在c ++类中,为使用此API指定的表返回的引用:

Store the table in a c++ class by holding a pointer to the lua state, and the reference returned for the table as specified using this API:

http://www.lua.org/pil/27.3.2.html

然后当一个方法在包装类,将引用的对象推入堆栈,并执行必要的函数调用

Then when a method on the wrapper class is called, push the referenced object onto the stack and do the necessary function call

这篇关于使用SWIG在Lua中实现和继承C ++类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆