summaryrefslogtreecommitdiff
path: root/src/lbaselib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-22 17:32:28 +0100
committerBenoit Giannangeli <giann008@gmail.com>2017-02-22 21:15:40 +0100
commitfc911817a8401d0696407e91501f0ef65f05b711 (patch)
tree828ee9d2d6d02cfc7d0365ca1495f99b3158c5cd /src/lbaselib.js
parent4b764aa6a84289f04acde43108425c392d2e4806 (diff)
downloadfengari-fc911817a8401d0696407e91501f0ef65f05b711.tar.gz
fengari-fc911817a8401d0696407e91501f0ef65f05b711.tar.bz2
fengari-fc911817a8401d0696407e91501f0ef65f05b711.zip
use luaL_argerror/error instead of throwing
Diffstat (limited to 'src/lbaselib.js')
-rw-r--r--src/lbaselib.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lbaselib.js b/src/lbaselib.js
index 2eacaaf..f405a7d 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -110,6 +110,17 @@ const pairsmeta = function(L, method, iszero, iter) {
return 3;
};
+const luaB_next = function(L) {
+ lauxlib.luaL_checktype(L, 1, CT.LUA_TTABLE);
+ lapi.lua_settop(L, 2); /* create a 2nd argument if there isn't one */
+ if (lapi.lua_next(L, 1))
+ return 2;
+ else {
+ lapi.lua_pushnil(L);
+ return 1;
+ }
+};
+
/*
** Traversal function for 'ipairs'
*/
@@ -244,6 +255,7 @@ const base_funcs = {
"tostring": luaB_tostring,
"tonumber": luaB_tonumber,
"getmetatable": luaB_getmetatable,
+ "next": luaB_next,
"ipairs": luaB_ipairs,
"select": luaB_select,
"setmetatable": luaB_setmetatable,