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); } } } } }
private Sio.SData format_map(IntPtr L, int index, NParam o) { Sio.SMapWriter pmap = new Sio.SMapWriter(); Sio.SData data = new Sio.SData(pmap); if (LuaAPI.lua_istable(L, index) && o.DType == ParamType.ptype_object) { NStruct ps = NStructManager.GetInstance().Find(o.TypeName); if (ps != null) { LuaAPI.lua_pushnil(L); while (LuaAPI.lua_next(L, index) != 0) { if (LuaAPI.lua_isstring(L, -2)) { NParam findparam = ps.Get(LuaAPI.lua_tostring(L, -2)); if (findparam != null) { pmap.write(findparam.Id, format_data(findparam, L, LuaAPI.lua_gettop(L), true)); } } LuaAPI.lua_pop(L, 1); } } } return(data); }
private void push_list(SDataBuff data, NParam o, IntPtr L) { Sio.SListReader plist = data.listReader; LuaAPI.lua_newtable(L); int top_index = LuaAPI.lua_gettop(L); int luaindex = 0; if (plist != null && o.Container == ParamContainer.pparam_container_list) { Sio.SDataBuff d = new Sio.SDataBuff(); while (plist.Next(d)) { push_data(d, L, o); LuaAPI.xlua_rawseti(L, top_index, ++luaindex); } } }
private Sio.SData format_List(IntPtr L, int index, NParam o) { Sio.SListWriter pl = new Sio.SListWriter(); Sio.SData d = new Sio.SData(pl); if (LuaAPI.lua_istable(L, index)) { int indexsize = (int)LuaAPI.xlua_objlen(L, index); for (int list_index = 1; list_index <= indexsize; ++list_index) { LuaAPI.xlua_rawgeti(L, index, list_index); Sio.SData td = format_data(o, L, LuaAPI.lua_gettop(L), false); pl.add(td); LuaAPI.lua_pop(L, 1); } } return(d); }
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; } }
private void push_to_lua(NParam o, MemoryStream ms, IntPtr L) { Sio.SDataBuff data = new Sio.SDataBuff(); data.UnSerializ(ms); push_data(data, L, o); }
private Sio.SData format_data(NParam o, RealStatePtr L, int index, bool checklist) { if (checklist == true && o.Container == ParamContainer.pparam_container_list) { return(format_List(L, index, o)); } else { switch (o.DType) { case ParamType.ptype_bool: { bool ans = LuaAPI.lua_toboolean(L, index); if (LuaAPI.lua_isboolean(L, index)) { ans = LuaAPI.lua_toboolean(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_char: case ParamType.ptype_uchar: { byte ans = 0; if (LuaAPI.lua_isnumber(L, index)) { ans = (byte)LuaAPI.xlua_tointeger(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_ushort: { UInt16 ans = 0; if (LuaAPI.lua_isnumber(L, index)) { ans = (UInt16)LuaAPI.xlua_tointeger(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_short: { Int16 ans = 0; if (LuaAPI.lua_isnumber(L, index)) { ans = (Int16)LuaAPI.xlua_tointeger(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_int: { int ans = 0; if (LuaAPI.lua_isnumber(L, index)) { ans = (int)LuaAPI.xlua_tointeger(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_uint: { uint ans = 0; if (LuaAPI.lua_isnumber(L, index)) { ans = (uint)LuaAPI.xlua_tointeger(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_float: { float ans = 0.0f; if (LuaAPI.lua_isnumber(L, index)) { ans = (float)LuaAPI.xlua_tointeger(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_double: { double ans = 0.0; if (LuaAPI.lua_isnumber(L, index)) { ans = (double)LuaAPI.xlua_tointeger(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_long: { long ans = 0; if (LuaAPI.lua_isint64(L, index)) { ans = LuaAPI.lua_toint64(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_ulong: { ulong ans = 0; if (LuaAPI.lua_isint64(L, index)) { ans = LuaAPI.lua_touint64(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_string: { string ans = string.Empty; if (LuaAPI.lua_isstring(L, index)) { ans = LuaAPI.lua_tostring(L, index); } return(new Sio.SData(ans)); } case ParamType.ptype_object: { return(format_map(L, index, o)); } default: break; } } return(null); }