Exemple #1
0
    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);
                    }
                }
            }
        }
    }
Exemple #2
0
    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);
    }