From 50323a75a96cfa095c1f968dd001b0f7107a722b Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 21 May 2017 22:48:29 +1000 Subject: src/lbaselib.js: Implement argument checking in collectgarbage --- src/lbaselib.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/lbaselib.js') diff --git a/src/lbaselib.js b/src/lbaselib.js index 8f0827e..bffe5a6 100644 --- a/src/lbaselib.js +++ b/src/lbaselib.js @@ -85,6 +85,15 @@ const luaB_rawset = function(L) { return 1; }; +const opts = ["stop", "restart", "collect", +"count", "step", "setpause", "setstepmul", +"isrunning"].map((e) => lua.to_luastring(e)); +const luaB_collectgarbage = function(L) { + lauxlib.luaL_checkoption(L, 1, lua.to_luastring("collect"), opts); + lauxlib.luaL_checkinteger(L, 2); + lauxlib.luaL_error(L, lua.to_luastring("lua_gc not implemented")); +}; + const luaB_type = function(L) { let t = lua.lua_type(L, 1); lauxlib.luaL_argcheck(L, t !== lua.LUA_TNONE, 1, lua.to_luastring("value expected", true)); @@ -308,8 +317,8 @@ const luaB_load = function(L) { }; const base_funcs = { - "collectgarbage": function () { return 0; }, "assert": luaB_assert, + "collectgarbage": luaB_collectgarbage, "error": luaB_error, "getmetatable": luaB_getmetatable, "ipairs": luaB_ipairs, -- cgit v1.2.3-54-g00ecf