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 int LuaUsing(IntPtr l) { try { LuaDLL.luaL_checktype(l, 1, LuaTypes.LUA_TSTRING); string str = LuaDLL.lua_tostring(l, 1); string[] ns = str.Split('.'); LuaDLL.lua_pushglobaltable(l); for (int n = 0; n < ns.Length; n++) { LuaDLL.lua_getfield(l, -1, ns[n]); if (!LuaDLL.lua_istable(l, -1)) { return(LuaObject.error(l, "expect {0} is type table", ns)); } LuaDLL.lua_remove(l, -2); } LuaDLL.lua_pushnil(l); while (LuaDLL.lua_next(l, -2) != 0) { string key = LuaDLL.lua_tostring(l, -2); LuaDLL.lua_getglobal(l, key); if (!LuaDLL.lua_isnil(l, -1)) { LuaDLL.lua_pop(l, 1); return(LuaObject.error(l, "{0} had existed, import can't overload it.", key)); } LuaDLL.lua_pop(l, 1); LuaDLL.lua_setglobal(l, key); } LuaDLL.lua_pop(l, 1); LuaObject.pushValue(l, true); return(1); } catch (Exception e) { return(LuaObject.error(l, e)); } }