summaryrefslogtreecommitdiff
path: root/src/linit.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/linit.js')
-rw-r--r--src/linit.js64
1 files changed, 35 insertions, 29 deletions
diff --git a/src/linit.js b/src/linit.js
index 97cbfc9..8f461a4 100644
--- a/src/linit.js
+++ b/src/linit.js
@@ -1,38 +1,44 @@
"use strict";
-const lua = require('./lua.js');
-const lauxlib = require('./lauxlib.js');
-const lbaselib = require('./lbaselib.js');
-const lcorolib = require('./lcorolib.js');
-const lmathlib = require('./lmathlib.js');
-const lstrlib = require('./lstrlib.js');
-const ltablib = require('./ltablib.js');
-const lutf8lib = require('./lutf8lib.js');
-const ldblib = require('./ldblib.js');
-const loslib = require('./loslib.js');
-const loadlib = require('./loadlib.js');
-const lualib = require('./lualib.js');
+const { lua_pop } = require('./lua.js');
+const { luaL_requiref } = require('./lauxlib.js');
+const { to_luastring } = require("./fengaricore.js");
-const luaL_openlibs = function(L) {
- const loadedlibs = {
- [lualib.LUA_LOADLIBNAME]: loadlib.luaopen_package,
- [lualib.LUA_COLIBNAME]: lcorolib.luaopen_coroutine,
- [lualib.LUA_DBLIBNAME]: ldblib.luaopen_debug,
- [lualib.LUA_MATHLIBNAME]: lmathlib.luaopen_math,
- [lualib.LUA_OSLIBNAME]: loslib.luaopen_os,
- [lualib.LUA_STRLIBNAME]: lstrlib.luaopen_string,
- [lualib.LUA_TABLIBNAME]: ltablib.luaopen_table,
- [lualib.LUA_UTF8LIBNAME]: lutf8lib.luaopen_utf8,
- "_G": lbaselib.luaopen_base
- };
-
- if (typeof process !== "undefined") loadedlibs[lualib.LUA_IOLIBNAME] = require('./liolib.js').luaopen_io;
+const loadedlibs = {};
+/* export before requiring lualib.js */
+const luaL_openlibs = function(L) {
/* "require" functions from 'loadedlibs' and set results to global table */
for (let lib in loadedlibs) {
- lauxlib.luaL_requiref(L, lua.to_luastring(lib), loadedlibs[lib], 1);
- lua.lua_pop(L, 1); /* remove lib */
+ luaL_requiref(L, to_luastring(lib), loadedlibs[lib], 1);
+ lua_pop(L, 1); /* remove lib */
}
};
-
module.exports.luaL_openlibs = luaL_openlibs;
+
+const lualib = require('./lualib.js');
+const { luaopen_base } = require('./lbaselib.js');
+const { luaopen_coroutine } = require('./lcorolib.js');
+const { luaopen_debug } = require('./ldblib.js');
+const { luaopen_math } = require('./lmathlib.js');
+const { luaopen_package } = require('./loadlib.js');
+const { luaopen_os } = require('./loslib.js');
+const { luaopen_string } = require('./lstrlib.js');
+const { luaopen_table } = require('./ltablib.js');
+const { luaopen_utf8 } = require('./lutf8lib.js');
+
+loadedlibs["_G"] = luaopen_base,
+loadedlibs[lualib.LUA_LOADLIBNAME] = luaopen_package;
+loadedlibs[lualib.LUA_COLIBNAME] = luaopen_coroutine;
+loadedlibs[lualib.LUA_TABLIBNAME] = luaopen_table;
+loadedlibs[lualib.LUA_OSLIBNAME] = luaopen_os;
+loadedlibs[lualib.LUA_STRLIBNAME] = luaopen_string;
+loadedlibs[lualib.LUA_MATHLIBNAME] = luaopen_math;
+loadedlibs[lualib.LUA_UTF8LIBNAME] = luaopen_utf8;
+loadedlibs[lualib.LUA_DBLIBNAME] = luaopen_debug;
+if (typeof process !== "undefined")
+ loadedlibs[lualib.LUA_IOLIBNAME] = require('./liolib.js').luaopen_io;
+
+/* Extension: fengari library */
+const { luaopen_fengari } = require('./fengarilib.js');
+loadedlibs[lualib.LUA_FENGARILIBNAME] = luaopen_fengari;