alibaba/wax

wax 使用 bytecode 形式的脚本

guojie1689 opened this issue · 1 comments

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

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));
}