diff options
author | aunsane <aunsane@gmail.com> | 2017-10-10 21:55:12 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-10-10 21:55:26 +0300 |
commit | 39e461bb614d75a6f23511a016afaeb3aba35f1a (patch) | |
tree | b61e3b3571bec7cb072abf91b512d0c398ee9195 /plugins/MirLua/Modules/m_json/src/main.cpp | |
parent | d3387c7307fa3f883e77c17e443874b3a085ded5 (diff) |
MirLua:
- m_json moved into base plugin
- added m_http module
-version bump
Diffstat (limited to 'plugins/MirLua/Modules/m_json/src/main.cpp')
-rw-r--r-- | plugins/MirLua/Modules/m_json/src/main.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/plugins/MirLua/Modules/m_json/src/main.cpp b/plugins/MirLua/Modules/m_json/src/main.cpp deleted file mode 100644 index 3774442d7f..0000000000 --- a/plugins/MirLua/Modules/m_json/src/main.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "stdafx.h"
-
-static int lua_Decode(lua_State *L)
-{
- const char *string = luaL_checkstring(L, 1);
-
- JSONNode *node = json_parse(string);
- new (L) JSON(node);
- luaL_setmetatable(L, MT_JSON);
-
- return 1;
-}
-
-static int lua_Encode(lua_State *L)
-{
- switch (lua_type(L, 1))
- {
- case LUA_TNIL:
- lua_pushliteral(L, "null");
- break;
- case LUA_TBOOLEAN:
- lua_pushstring(L, lua_toboolean(L, 1) ? "true" : "false");
- break;
- case LUA_TNUMBER:
- {
- if (lua_isinteger(L, 1)) {
- lua_pushfstring(L, "%I", lua_tointeger(L, 1));
- break;
- }
- char decpoint = lua_getlocaledecpoint();
- if (decpoint != '.') {
- char p[2] = { decpoint };
- luaL_gsub(L, lua_tostring(L, 1), p, ".");
- }
- else
- lua_pushfstring(L, "%f", lua_tonumber(L, 1));
- break;
- }
- case LUA_TSTRING:
- lua_pushfstring(L, "\"%s\"", lua_tostring(L, 1));
- break;
- case LUA_TTABLE:
- {
- JSONNode node;
- lua_pushnil(L);
- lua_pushvalue(L, 1);
- lua2json(L, node);
- lua_pop(L, 2);
- lua_pushstring(L, node.write().c_str());
- break;
- }
- case LUA_TUSERDATA:
- {
- JSONNode &node = *((JSON*)luaL_checkudata(L, 1, MT_JSON))->node;
- lua_pushstring(L, node.write().c_str());
- break;
- }
- case LUA_TLIGHTUSERDATA:
- if (lua_touserdata(L, 1) == NULL)
- {
- lua_pushliteral(L, "null");
- break;
- }
- default:
- luaL_argerror(L, 1, luaL_typename(L, 1));
- }
-
- return 1;
-}
-
-static const luaL_Reg methods[] =
-{
- { "Decode", lua_Decode },
- { "Encode", lua_Encode },
-
- { NULL, NULL }
-};
-
-extern "C" LUAMOD_API int luaopen_m_json(lua_State *L)
-{
- luaL_newlib(L, methods);
-
- luaL_newmetatable(L, MT_JSON);
- luaL_setfuncs(L, jsonApi, 0);
- lua_pop(L, 1);
-
- return 1;
-}
\ No newline at end of file |