From a7034dc19a8849bf82d2eb420b150ac54dc079d8 Mon Sep 17 00:00:00 2001 From: aunsane Date: Wed, 6 Jun 2018 00:34:46 +0300 Subject: MirLua: - add new helper function luaM_isarray - fix print of decimal point m_json module - add __pairs metamethod support - simplify code m_http module - send function should create copy of request object to prevent side effects in async calls - fix lua functions call - fix memory leaks --- plugins/MirLua/src/utils.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'plugins/MirLua/src/utils.cpp') diff --git a/plugins/MirLua/src/utils.cpp b/plugins/MirLua/src/utils.cpp index 5704bfc786..c0c74a76fa 100644 --- a/plugins/MirLua/src/utils.cpp +++ b/plugins/MirLua/src/utils.cpp @@ -96,4 +96,17 @@ bool luaM_toboolean(lua_State *L, int idx) if (lua_isnumber(L, idx)) return lua_tonumber(L, idx) > 0; return lua_toboolean(L, idx) > 0; -} \ No newline at end of file +} + +bool luaM_isarray(lua_State *L, int idx) +{ + luaL_checktype(L, idx, LUA_TTABLE); + int i = 0; + for (lua_pushnil(L); lua_next(L, idx); lua_pop(L, 2)) { + if (lua_rawgeti(L, idx, ++i) == LUA_TNIL) { + lua_pop(L, 3); + return false; + } + } + return true; +} -- cgit v1.2.3