private void push_map(SDataBuff data, NParam o, IntPtr L) { SMapReader pmap = data.mapReader; LuaAPI.lua_newtable(L); if (pmap != null && o.DType == ParamType.ptype_object) { NStruct ps = NStructManager.GetInstance().Find(o.TypeName); if (ps != null) { SDataBuff k = new SDataBuff(); SDataBuff v = new SDataBuff(); while (pmap.Next(k, v)) { NParam p = ps.Get(k.intValue); if (p != null) { LuaAPI.lua_pushstring(L, p.Name); push_data(v, L, p); LuaAPI.xlua_psettable(L, -3); } } } } }
internal static int VMLoader(IntPtr L) { try { string filename = Lua.lua_tostring(L, 1); // LuaEnv self = ObjectTranslatorPool.Instance.Find(L).luaEnv; string real_file_path = filename; byte[] bytes = SGK.FileUtils.Load(ref real_file_path); if (bytes != null) { if (Lua.xluaL_loadbuffer(L, bytes, bytes.Length, "@" + real_file_path) != 0) { Lua.lua_pushstring(L, Lua.lua_tostring(L, -1)); return(1); // return Lua.luaL_error(L, String.Format("error loading module {0} from VMLoader, {1}", // Lua.lua_tostring(L, 1), Lua.lua_tostring(L, -1))); } return(1); } Lua.lua_pushstring(L, string.Format( "\n\tno such file '{0}' in VMLoader!", filename)); return(1); } catch (System.Exception e) { return(Lua.luaL_error(L, "c# exception in LoadFromCustomLoaders:" + e)); } }
private void push_data(Sio.SDataBuff data, IntPtr L, NParam o) { switch (data.type) { case SType.stype_bool: LuaAPI.lua_pushboolean(L, data.boolValue); break; case SType.stype_uchar: LuaAPI.xlua_pushuint(L, data.ucharValue); break; case SType.stype_char: LuaAPI.xlua_pushinteger(L, data.charValue); break; case SType.stype_short: LuaAPI.xlua_pushinteger(L, data.shortValue); break; case SType.stype_ushort: LuaAPI.xlua_pushuint(L, data.ushortValue); break; case SType.stype_int: LuaAPI.xlua_pushinteger(L, data.intValue); break; case SType.stype_uint: LuaAPI.xlua_pushuint(L, data.uintValue); break; case SType.stype_float: LuaAPI.lua_pushnumber(L, data.floatValue); break; case SType.stype_double: LuaAPI.lua_pushnumber(L, data.doubleValue); break; case SType.stype_long: LuaAPI.lua_pushint64(L, data.longValue); break; case SType.stype_string: LuaAPI.lua_pushstring(L, data.stringValue); break; case SType.stype_list: push_list(data, o, L); break; case SType.stype_map: push_map(data, o, L); break; default: Logger.LogError("push_data error!!!!!!!!!!!!!!! type:" + data.type.ToString()); break; } }