alibaba / wax

Wax is a framework that lets you write native iPhone apps in Lua.
http://github.com/probablycorey/wax
MIT License
1.84k stars 280 forks source link

wax 使用 bytecode 形式的脚本 #33

Closed guojie1689 closed 8 years ago

guojie1689 commented 8 years ago

请问在wax中如何使用bytecode的lua脚本呢? 支持哪种形式呢?

intheway commented 8 years ago

use lua bytecode in wax, follow these steps: 1: compile lua bytecode 32 cpu 2: compile lua bytecode 64 cpu

cd YOUR_PATH/wax/lib/build-scripts 
luac32 -s -o test.luac32 YOUR_PATH/test.lua 
luac64 -s -o test.luac64 YOUR_PATH/test.lua

3: judge cpu type, then run

NSData *data = nil;
if(sizeof(NSInteger) == 8){
    data = [NSData dataWithContentsOfFile:@"YOUR_PATH/test.luac64"];
}else{
    data = [NSData dataWithContentsOfFile:@"YOUR_PATH/test.luac32"];
}
int i = wax_runLuaByteCode(data, @"test.lua");
if(i){
    NSLog(@"error=%s", lua_tostring(wax_currentLuaState(), -1));
}