summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-02 15:06:46 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-02 15:07:12 +1000
commit5a28287e832a60133865386c8a034a5ca8b76bce (patch)
treee52fe69aae9488340c53f9f65c818661b1584507 /src
parent77480d0f313b12272fd594d1bade97c4a2b7c8df (diff)
downloadfengari-5a28287e832a60133865386c8a034a5ca8b76bce.tar.gz
fengari-5a28287e832a60133865386c8a034a5ca8b76bce.tar.bz2
fengari-5a28287e832a60133865386c8a034a5ca8b76bce.zip
src/lauxlib.js: Add luaL_dostring and luaL_dofile
Diffstat (limited to 'src')
-rw-r--r--src/lauxlib.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index 68e7c12..1921237 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -403,6 +403,10 @@ const luaL_loadstring = function(L, s) {
return luaL_loadbuffer(L, s, s.length, s);
};
+const luaL_dostring = function(L, s) {
+ return (luaL_loadstring(L, s) || lua.lua_pcall(L, 0, lua.LUA_MULTRET, 0));
+};
+
const luaL_getmetafield = function(L, obj, event) {
if (!lua.lua_getmetatable(L, obj))
return lua.LUA_TNIL;
@@ -699,6 +703,11 @@ if (typeof require === "function") {
return luaL_loadfilex(L, filename, null);
};
+ const luaL_dofile = function(L, filename) {
+ return (luaL_loadfile(L, filename) || lua.lua_pcall(L, 0, lua.LUA_MULTRET, 0));
+ };
+
+ module.exports.luaL_dofile = luaL_dofile;
module.exports.luaL_loadfilex = luaL_loadfilex;
module.exports.luaL_loadfile = luaL_loadfile;
}
@@ -729,6 +738,7 @@ module.exports.luaL_checkstack = luaL_checkstack;
module.exports.luaL_checkstring = luaL_checkstring;
module.exports.luaL_checktype = luaL_checktype;
module.exports.luaL_checkudata = luaL_checkudata;
+module.exports.luaL_dostring = luaL_dostring;
module.exports.luaL_error = luaL_error;
module.exports.luaL_execresult = luaL_execresult;
module.exports.luaL_fileresult = luaL_fileresult;