summaryrefslogtreecommitdiff
path: root/src/lbaselib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-20 11:26:28 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-20 11:29:35 +0100
commite0d4ffcc75a04b3ecc2cc08aea372d9621e5b6ac (patch)
treeb7681375fe8f42139d9eab5554704d3899a6a050 /src/lbaselib.js
parentb62bcdfa67d6b0359bf45930ab392953d69eb399 (diff)
downloadfengari-e0d4ffcc75a04b3ecc2cc08aea372d9621e5b6ac.tar.gz
fengari-e0d4ffcc75a04b3ecc2cc08aea372d9621e5b6ac.tar.bz2
fengari-e0d4ffcc75a04b3ecc2cc08aea372d9621e5b6ac.zip
rawequal
Diffstat (limited to 'src/lbaselib.js')
-rw-r--r--src/lbaselib.js22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/lbaselib.js b/src/lbaselib.js
index 12c28fe..62d25df 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -33,17 +33,17 @@ const luaB_tostring = function(L) {
lauxlib.luaL_checkany(L, 1);
lauxlib.luaL_tolstring(L, 1, null);
- return true;
+ return 1;
};
const luaB_getmetatable = function(L) {
lauxlib.luaL_checkany(L, 1);
if (!lapi.lua_getmetatable(L, 1)) {
lapi.lua_pushnil(L);
- return true; /* no metatable */
+ return 1; /* no metatable */
}
lauxlib.luaL_getmetafield(L, 1, "__metatable");
- return true; /* returns either __metatable field (if present) or metatable */
+ return 1; /* returns either __metatable field (if present) or metatable */
};
const luaB_setmetatable = function(L) {
@@ -54,7 +54,14 @@ const luaB_setmetatable = function(L) {
throw new Error("cannot change a protected metatable");
lapi.lua_settop(L, 2);
lapi.lua_setmetatable(L, 1);
- return true;
+ return 1;
+};
+
+const luaB_rawequal = function(L) {
+ lauxlib.luaL_checkany(L, 1);
+ lauxlib.luaL_checkany(L, 2);
+ lapi.lua_pushboolean(L, lapi.lua_rawequal(L, 1, 2));
+ return 1;
};
const base_funcs = {
@@ -62,6 +69,7 @@ const base_funcs = {
"tostring": luaB_tostring,
"getmetatable": luaB_getmetatable,
"setmetatable": luaB_setmetatable,
+ "rawequal": luaB_rawequal,
};
const luaopen_base = function(L) {
@@ -74,11 +82,7 @@ const luaopen_base = function(L) {
/* set global _VERSION */
lapi.lua_pushliteral(L, lua.LUA_VERSION);
lapi.lua_setfield(L, -2, "_VERSION");
- return true;
+ return 1;
};
-module.exports.luaB_tostring = luaB_tostring;
-module.exports.luaB_print = luaB_print;
-module.exports.luaB_getmetatable = luaB_getmetatable;
-module.exports.luaB_setmetatable = luaB_setmetatable;
module.exports.luaopen_base = luaopen_base;