Improve LuaObjcBridge

This commit is contained in:
halx99 2022-03-25 10:35:18 +08:00
parent 2469df48c6
commit fad7ac3258
1 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,6 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2022 Bytedance Inc.
https://adxeproject.github.io/ https://adxeproject.github.io/
@ -43,7 +44,17 @@ static void luaTableToObjcDictionary(lua_State* L, NSMutableDictionary* dict, NS
lua_pushnil(L); lua_pushnil(L);
while (lua_next(L, -2)) while (lua_next(L, -2))
{ {
NSString* key2 = [NSString stringWithCString:lua_tostring(L, -2) encoding:NSUTF8StringEncoding]; NSString* key2 = nil;
int keyType = lua_type(L, -2);
if (keyType == LUA_TSTRING)
key2 = [NSString stringWithCString:lua_tostring(L, -2) encoding:NSUTF8StringEncoding];
else if (keyType == LUA_TNUMBER)
key2 = [[NSNumber numberWithInt:lua_tonumber(L, -2)] stringValue];
else
{
lua_pop(L, 1);
continue;
}
switch (lua_type(L, -1)) switch (lua_type(L, -1))
{ {