summaryrefslogtreecommitdiff
path: root/plugins/MirLua
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-08-06 18:13:02 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-08-06 18:13:02 +0000
commitcff4544d6fe2864212e93c6653ef2e8e8cbd38c5 (patch)
treea4949e0d54ac6878cc973bc8da9b3475a8bdecd2 /plugins/MirLua
parent5238b6e3b28bd493228a507929bbd0ce7e209ca3 (diff)
MirLua: fixed m_json.Encode
git-svn-id: http://svn.miranda-ng.org/main/trunk@17164 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua')
-rw-r--r--plugins/MirLua/Modules/m_json/m_json.vcxproj2
-rw-r--r--plugins/MirLua/Modules/m_json/src/main.cpp8
-rw-r--r--plugins/MirLua/Modules/m_json/src/metatable.cpp8
3 files changed, 8 insertions, 10 deletions
diff --git a/plugins/MirLua/Modules/m_json/m_json.vcxproj b/plugins/MirLua/Modules/m_json/m_json.vcxproj
index 538ed63f5c..a16b5b743e 100644
--- a/plugins/MirLua/Modules/m_json/m_json.vcxproj
+++ b/plugins/MirLua/Modules/m_json/m_json.vcxproj
@@ -20,7 +20,7 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>m_json</ProjectName>
- <ProjectGuid>{8A645067-7F45-4E65-AAFC-AFDA81C29A1D}</ProjectGuid>
+ <ProjectGuid>{99712BCA-F86F-4214-967D-1298DF0F4A13}</ProjectGuid>
</PropertyGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(ProjectDir)..\module.props" />
diff --git a/plugins/MirLua/Modules/m_json/src/main.cpp b/plugins/MirLua/Modules/m_json/src/main.cpp
index fe987d36f3..c26f350f63 100644
--- a/plugins/MirLua/Modules/m_json/src/main.cpp
+++ b/plugins/MirLua/Modules/m_json/src/main.cpp
@@ -17,11 +17,9 @@ static int lua_Encode(lua_State *L)
JSONNode *node = json_new(JSON_NODE);
lua_pushnil(L);
- while (lua_next(L, 1) != 0)
- {
- lua2json(L, *node);
- lua_pop(L, 1);
- }
+ lua_pushvalue(L, 1);
+ lua2json(L, *node);
+ lua_pop(L, 2);
JSON *mt = new (L) JSON(node);
luaL_setmetatable(L, MT_JSON);
diff --git a/plugins/MirLua/Modules/m_json/src/metatable.cpp b/plugins/MirLua/Modules/m_json/src/metatable.cpp
index b7b1c37f24..5ea9697d69 100644
--- a/plugins/MirLua/Modules/m_json/src/metatable.cpp
+++ b/plugins/MirLua/Modules/m_json/src/metatable.cpp
@@ -2,8 +2,6 @@
void lua2json(lua_State *L, JSONNode &node)
{
- const char *name = lua_tostring(L, -2);
-
switch (lua_type(L, -1))
{
case LUA_TNIL:
@@ -21,8 +19,6 @@ void lua2json(lua_State *L, JSONNode &node)
case LUA_TTABLE:
{
node.cast(JSON_NODE);
- if (name)
- node.set_name(name);
lua_pushnil(L);
while (lua_next(L, -2) != 0)
@@ -35,6 +31,10 @@ void lua2json(lua_State *L, JSONNode &node)
}
}
}
+
+ const char *name = lua_tostring(L, -2);
+ if (name)
+ node.set_name(name);
}
static int json__index(lua_State *L)