• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Lua 与 C 交互(2)

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
1.new tbClass{}, Binding "FunName" to C function "thunk" and set it's closure with upvalue;
2.rigister metatable "Class", and set metatable __index to table"tbClass"
3.new pObj, new userdata to point it, and set this userdata's metatable then push it into stack.
4.call Obj:FunName()
5.because Obj associate tbClass by metatable, so will call tbClass[FunName], then call thunk, remember thunk have upvalue.
6.when we have userdata whitch have pObj,and have upvalue,then CallFun



1.new tbClass{},Encapsulation all Class Memeber as KLuaData. tbClass[FunName] = KLuaData.KLuaData push as userdata.
2.rigister metatable "Class", and set metatable __index to C Function "_LuaIndex"
3.push userdata who's restore pObj, and set metatable
4.Call a.FunName()
5.Call C Function _LuaIndex,in this can get pObj and KLuaData,switch kind of KLuaData,execute diff Op.
6.if KLuaData is FunData, then push pObj,and FunData, and CFun "_LuaDispatcher",then () will Call this Fun
7.CallFun


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
【游戏开发】在Lua中实现面向对象特性——模拟类、继承、多态 ...发布时间:2022-07-22
下一篇:
centos7安装Lua发布时间:2022-07-22
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap