aboutsummaryrefslogtreecommitdiff
path: root/src/mpack/lmpack.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-02-10 20:51:36 +0100
committerGitHub <noreply@github.com>2023-02-10 20:51:36 +0100
commitb8ad1bfe8bc23ed5ffbfe43df5fda3501f1d2802 (patch)
treeea341bee19c2202cbe94ccefb2afeba953af713e /src/mpack/lmpack.c
parent4c64cbe99f2616a1d1126257da8d40773f4adba1 (diff)
parent0837980db4958baca96449869d31120f349f3500 (diff)
downloadrneovim-b8ad1bfe8bc23ed5ffbfe43df5fda3501f1d2802.tar.gz
rneovim-b8ad1bfe8bc23ed5ffbfe43df5fda3501f1d2802.tar.bz2
rneovim-b8ad1bfe8bc23ed5ffbfe43df5fda3501f1d2802.zip
Merge pull request #22077 from bfredl/neolua_client
refactor(tests): integrate lua-client into core and use core for functionaltests
Diffstat (limited to 'src/mpack/lmpack.c')
-rw-r--r--src/mpack/lmpack.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mpack/lmpack.c b/src/mpack/lmpack.c
index 53d7092a0c..957bac37cc 100644
--- a/src/mpack/lmpack.c
+++ b/src/mpack/lmpack.c
@@ -644,7 +644,13 @@ static void lmpack_unparse_enter(mpack_parser_t *parser, mpack_node_t *node)
mpack_node_t *n;
int has_meta = lua_getmetatable(L, -1);
- if (packer->ext != LUA_NOREF && has_meta) {
+ int has_mtdict = false;
+ if (has_meta && packer->mtdict != LUA_NOREF) {
+ lmpack_geti(L, packer->reg, packer->mtdict); // [table, metatable, mtdict]
+ has_mtdict = lua_rawequal(L, -1, -2);
+ lua_pop(L, 1); // [table, metatable];
+ }
+ if (packer->ext != LUA_NOREF && has_meta && !has_mtdict) {
/* check if there's a handler for this metatable */
lmpack_geti(L, packer->reg, packer->ext);
lua_pushvalue(L, -2);
@@ -701,14 +707,7 @@ static void lmpack_unparse_enter(mpack_parser_t *parser, mpack_node_t *node)
}
}
- int is_array = 1;
if (has_meta) {
- // stack: [table, metatable]
- if (packer->mtdict != LUA_NOREF) {
- lmpack_geti(L, packer->reg, packer->mtdict); // [table, metatable, mtdict]
- is_array = !lua_rawequal(L, -1, -2);
- lua_pop(L, 1); // [table, metatable];
- }
lua_pop(L, 1); // [table]
}
@@ -726,6 +725,7 @@ static void lmpack_unparse_enter(mpack_parser_t *parser, mpack_node_t *node)
lua_pop(L, 1);
}
+ int is_array = !has_mtdict;
len = lmpack_objlen(L, &is_array);
if (is_array) {
node->tok = mpack_pack_array(len);