diff options
author | aunsane <aunsane@gmail.com> | 2018-06-06 00:34:46 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2018-06-06 00:35:01 +0300 |
commit | a7034dc19a8849bf82d2eb420b150ac54dc079d8 (patch) | |
tree | 75eb7818df9cc9d707bf2c5a010b31ae2340f971 /plugins/MirLua/src/utils.cpp | |
parent | 3c13c94d636ce2c38ca64bbe3febbad68296c661 (diff) |
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
Diffstat (limited to 'plugins/MirLua/src/utils.cpp')
-rw-r--r-- | plugins/MirLua/src/utils.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
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; +} |