Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lua+wax在ios上的应用 白 衣.

Similar presentations


Presentation on theme: "Lua+wax在ios上的应用 白 衣."— Presentation transcript:

1 Lua+wax在ios上的应用 白 衣

2 主要内容 1. Lua是什么 2. wax是什么 3. 我对wax做的一些扩展 4. Lua和wax在ios上的一些限制

3 关于Lua 一种嵌入式脚本编程语言。C语言实现。巴西。开源 1. 脚本语言 解释执行,有自己语法、指令集以及虚拟机 2. 嵌入式
API设计都是围绕这点 3. 小且快 4. 应用案例 pc : 魔兽世界 phone : 愤怒的小鸟

4 Lua基本概念 数据类型:nil number string boolean
function table userdata coroutine function closure (闭包) metatable (元表) Lua栈

5 关于wax 开源框架 用lua来写native的iphone app
2. Bridge between Objective-C and Lua 3. Using Objective-C runtime

6 why wax 1. 自动GC。 没有release retain 2. 少写一些代码。
2. 少写一些代码。 没有头文件 没有static type array dictionary 3. 暴露所有的native类到lua。 UIKit Foundation等 还有你自己的Objective-C代码 4. 提供HTTP库 json库 xml库等扩展库 5. Lua支持强大的闭包 6. Lua自带正则匹配库

7 wax架构图

8 一些code waxClass{"MyController", UIViewController} function init()
-- to call a method on super, simply use self.super self.super:initWithNibName_bundle("MyControllerView.xib", nil) return self end function viewDidLoad() -- Do all your other stuff here

9 wax改进1 增加wax_bind 绑定native创建的类和要对应的脚本
将native创建的类,封装成userdata,并将脚本中的函数注册给native的类 缺点: native的函数不能复用

10 wax改进2 luabridge端上增加 callNativeMethod方法 后来遇到另一个问题:

11 wax改进后的一些code waxbind.lua: waxBind() function viewDidLoad(self)
self:waxCallNative('viewDidLoad'); print('viewDidLoad called from lua.'); end ViewController.m: wax_bind([[[NSBundle mainBundle] resourcePath] cStringUsingEncoding:NSUTF8StringEncoding], cStringUsingEncoding:NSUTF8StringEncoding], self);

12 脚本的安全性 加密 脚本二进制化 改luac

13 Lua+wax的限制 苹果公司审核的担忧。 代码上的限制:
1. 2. getter和setter函数名,不能有下划线 工程上的限制: 1. 修改自由,版本不好控制 2. 开发工程师要掌握两门语言。 3. 目前没找到debug工具,要log调试

14 参考资料 Lua PIL : http://www.lua.org/pil/contents.html Wax

15 谢谢!!


Download ppt "Lua+wax在ios上的应用 白 衣."

Similar presentations


Ads by Google