aboutsummaryrefslogtreecommitdiff
path: root/src/lbaselib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-22 14:19:19 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-22 14:19:19 +0100
commiteb9ad22e7538a25ef565e93c842eef48dba2469e (patch)
treec6ac06713b5e5b45cf0f5d0c3010163f2e6e5309 /src/lbaselib.js
parentb31cc0420e77d34465e4cf7d7ab75df7755b44d6 (diff)
downloadfengari-eb9ad22e7538a25ef565e93c842eef48dba2469e.tar.gz
fengari-eb9ad22e7538a25ef565e93c842eef48dba2469e.tar.bz2
fengari-eb9ad22e7538a25ef565e93c842eef48dba2469e.zip
lua_rawlen, rawlen
Diffstat (limited to 'src/lbaselib.js')
-rw-r--r--src/lbaselib.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lbaselib.js b/src/lbaselib.js
index fa0349b..2eacaaf 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -65,6 +65,13 @@ const luaB_rawequal = function(L) {
return 1;
};
+const luaB_rawlen = function(L) {
+ let t = lapi.lua_type(L, 1);
+ lauxlib.luaL_argcheck(L, t === CT.LUA_TTABLE || t === CT.LUA_TSTRING, 1, "table or string expected");
+ lapi.lua_pushinteger(L, lapi.lua_rawlen(L, 1));
+ return 1;
+};
+
const luaB_rawget = function(L) {
lauxlib.luaL_checktype(L, 1, CT.LUA_TTABLE);
lauxlib.luaL_checkany(L, 2);
@@ -241,6 +248,7 @@ const base_funcs = {
"select": luaB_select,
"setmetatable": luaB_setmetatable,
"rawequal": luaB_rawequal,
+ "rawlen": luaB_rawlen,
"rawset": luaB_rawset,
"rawget": luaB_rawget,
"type": luaB_type,