summaryrefslogtreecommitdiff
path: root/plugins/MirLua/Modules/JSON/src/json.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-02-03 12:03:36 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-02-03 12:03:36 +0000
commitac0ca480f5a8598648004b9bd0205a3d7c12e48a (patch)
tree11dd8eae469d874ded966426cf668b7a6e174e7f /plugins/MirLua/Modules/JSON/src/json.cpp
parenteb552097af8e812ff119b92770bd9d7c30a0a696 (diff)
MirLua: json encoding support
git-svn-id: http://svn.miranda-ng.org/main/trunk@16218 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/Modules/JSON/src/json.cpp')
-rw-r--r--plugins/MirLua/Modules/JSON/src/json.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/MirLua/Modules/JSON/src/json.cpp b/plugins/MirLua/Modules/JSON/src/json.cpp
index edfa04fb83..c8680c753c 100644
--- a/plugins/MirLua/Modules/JSON/src/json.cpp
+++ b/plugins/MirLua/Modules/JSON/src/json.cpp
@@ -3,16 +3,21 @@
static int lua_decode(lua_State *L)
{
const char *string = luaL_checkstring(L, 1);
- MT *udata = (MT*)lua_newuserdata(L, sizeof(MT));
- udata->node = json_parse(string);
- udata->bDelete = true;
+ new (L) MT(json_parse(string));
luaL_setmetatable(L, MT_JSON);
return 1;
}
+int json__call(lua_State *L);
+static int lua_encode(lua_State *L)
+{
+ return json__call(L);
+}
+
static const luaL_Reg methods[] =
{
{ "decode", lua_decode },
+ { "encode", lua_encode },
{ NULL, NULL }
};