aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lbaselib.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lbaselib.js b/src/lbaselib.js
index f405a7d..012f5c3 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -98,7 +98,7 @@ const luaB_type = function(L) {
const pairsmeta = function(L, method, iszero, iter) {
lauxlib.luaL_checkany(L, 1);
- if (lauxlib.luaL_getmetafield(L, 1, method).ttisnil()) { /* no metamethod? */
+ if (lauxlib.luaL_getmetafield(L, 1, method) === CT.LUA_TNIL) { /* no metamethod? */
lapi.lua_pushcfunction(L, iter); /* will return generator, */
lapi.lua_pushvalue(L, 1); /* state, */
if (iszero) lapi.lua_pushinteger(L, 0); /* and initial value */
@@ -121,6 +121,10 @@ const luaB_next = function(L) {
}
};
+const luaB_pairs = function(L) {
+ return pairsmeta(L, "__pairs", 0, luaB_next);
+};
+
/*
** Traversal function for 'ipairs'
*/
@@ -256,6 +260,7 @@ const base_funcs = {
"tonumber": luaB_tonumber,
"getmetatable": luaB_getmetatable,
"next": luaB_next,
+ "pairs": luaB_pairs,
"ipairs": luaB_ipairs,
"select": luaB_select,
"setmetatable": luaB_setmetatable,