From a7f38e82322377ebe116f28fbc63a15c9d8bd08a Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 23 Mar 2017 23:30:27 +1100 Subject: lualib: export various libraries --- src/lua.js | 1 - src/lualib.js | 56 ++++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/lua.js b/src/lua.js index d7bfa01..b1faccd 100644 --- a/src/lua.js +++ b/src/lua.js @@ -2,7 +2,6 @@ "use strict"; const assert = require('assert'); -const lualib = require('./lualib.js'); const luaconf = require('./luaconf.js'); /* mark for precompiled code ('Lua') */ diff --git a/src/lualib.js b/src/lualib.js index da9b290..83b1d0d 100644 --- a/src/lualib.js +++ b/src/lualib.js @@ -1,27 +1,47 @@ /*jshint esversion: 6 */ "use strict"; -const assert = require('assert'); +const lua = require("./lua.js"); + +const LUA_VERSUFFIX = "_" + lua.LUA_VERSION_MAJOR + "_" + lua.LUA_VERSION_MINOR; +module.exports.LUA_VERSUFFIX = LUA_VERSUFFIX; + +const LUA_COLIBNAME = "coroutine"; +module.exports.LUA_COLIBNAME = LUA_COLIBNAME; +module.exports[LUA_COLIBNAME] = require("./lcorolib.js").luaopen_coroutine; + +const LUA_TABLIBNAME = "table"; +module.exports.LUA_TABLIBNAME = LUA_TABLIBNAME; +module.exports[LUA_TABLIBNAME] = require("./ltablib.js").luaopen_table; + +const LUA_IOLIBNAME = "io"; +module.exports.LUA_IOLIBNAME = LUA_IOLIBNAME; +// module.exports[LUA_IOLIBNAME] = require("./liolib.js").luaopen_io; + +const LUA_OSLIBNAME = "os"; +module.exports.LUA_OSLIBNAME = LUA_OSLIBNAME; +// module.exports[LUA_OSLIBNAME] = require("./loslib.js").luaopen_os; + +const LUA_STRLIBNAME = "string"; +module.exports.LUA_STRLIBNAME = LUA_STRLIBNAME; +module.exports[LUA_STRLIBNAME] = require("./lstrlib.js").luaopen_string; -const LUA_COLIBNAME = "coroutine"; -const LUA_TABLIBNAME = "table"; -const LUA_IOLIBNAME = "io"; -const LUA_OSLIBNAME = "os"; -const LUA_STRLIBNAME = "string"; const LUA_UTF8LIBNAME = "utf8"; -const LUA_BITLIBNAME = "bit32"; +module.exports.LUA_UTF8LIBNAME = LUA_UTF8LIBNAME; +module.exports[LUA_UTF8LIBNAME] = require("./lutf8lib.js").luaopen_utf8; + +const LUA_BITLIBNAME = "bit32"; +module.exports.LUA_BITLIBNAME = LUA_BITLIBNAME; +// module.exports[LUA_BITLIBNAME] = require("./lbitlib.js").luaopen_bit32; + const LUA_MATHLIBNAME = "math"; -const LUA_DBLIBNAME = "debug"; -const LUA_LOADLIBNAME = "package"; +module.exports.LUA_MATHLIBNAME = LUA_MATHLIBNAME; +module.exports[LUA_MATHLIBNAME] = require("./lmathlib.js").luaopen_math; +const LUA_DBLIBNAME = "debug"; +module.exports.LUA_DBLIBNAME = LUA_DBLIBNAME; +module.exports[LUA_DBLIBNAME] = require("./ldebug.js").luaopen_debug; -module.exports.LUA_BITLIBNAME = LUA_BITLIBNAME; -module.exports.LUA_COLIBNAME = LUA_COLIBNAME; -module.exports.LUA_DBLIBNAME = LUA_DBLIBNAME; -module.exports.LUA_IOLIBNAME = LUA_IOLIBNAME; +const LUA_LOADLIBNAME = "package"; module.exports.LUA_LOADLIBNAME = LUA_LOADLIBNAME; -module.exports.LUA_MATHLIBNAME = LUA_MATHLIBNAME; -module.exports.LUA_OSLIBNAME = LUA_OSLIBNAME; -module.exports.LUA_STRLIBNAME = LUA_STRLIBNAME; -module.exports.LUA_TABLIBNAME = LUA_TABLIBNAME; -module.exports.LUA_UTF8LIBNAME = LUA_UTF8LIBNAME; \ No newline at end of file +// module.exports[LUA_LOADLIBNAME] = require("./loadlib.js").luaopen_package; -- cgit v1.2.3-70-g09d2