blob: f717767a17510ff3827069d50c37d75cd3c8d33b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
"use strict";
const { lua_pop } = require('./lua.js');
const { luaL_requiref } = require('./lauxlib.js');
const lualib = require('./lualib.js');
const { to_luastring } = require("./fengaricore.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 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;
/* "require" functions from 'loadedlibs' and set results to global table */
for (let lib in loadedlibs) {
luaL_requiref(L, to_luastring(lib), loadedlibs[lib], 1);
lua_pop(L, 1); /* remove lib */
}
};
module.exports.luaL_openlibs = luaL_openlibs;
|