summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-02 02:35:06 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-02 02:35:06 +1100
commit2de7580fb1109c5342de0088c174eec634594c00 (patch)
tree0f40ab7d3b28e1b7a41badbcf7ae4b564b812300 /src
parentc8d6c4323c62c38a4fad40642cd9db166caa910a (diff)
downloadfengari-2de7580fb1109c5342de0088c174eec634594c00.tar.gz
fengari-2de7580fb1109c5342de0088c174eec634594c00.tar.bz2
fengari-2de7580fb1109c5342de0088c174eec634594c00.zip
Export strings from lauxlib in lua string form (rather than as javascript string)
Diffstat (limited to 'src')
-rw-r--r--src/lauxlib.js10
-rw-r--r--src/loadlib.js8
2 files changed, 9 insertions, 9 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index 518190f..d976cee 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -3,12 +3,12 @@
const lua = require('./lua.js');
/* key, in the registry, for table of loaded modules */
-const LUA_LOADED_TABLE = "_LOADED";
+const LUA_LOADED_TABLE = lua.to_luastring("_LOADED");
/* key, in the registry, for table of preloaded loaders */
-const LUA_PRELOAD_TABLE = "_PRELOAD";
+const LUA_PRELOAD_TABLE = lua.to_luastring("_PRELOAD");
-const LUA_FILEHANDLE = lua.to_luastring("FILE*", true);
+const LUA_FILEHANDLE = lua.to_luastring("FILE*");
const LUAL_NUMSIZES = 4*16 + 8;
@@ -57,7 +57,7 @@ const findfield = function(L, objidx, level) {
const pushglobalfuncname = function(L, ar) {
let top = lua.lua_gettop(L);
lua.lua_getinfo(L, ['f'.charCodeAt(0)], ar); /* push function */
- lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring(LUA_LOADED_TABLE, true));
+ lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
if (findfield(L, top + 1, 2)) {
let name = lua.lua_tostring(L, -1);
if (name[0] === "_".charCodeAt(0) && name[1] === "G".charCodeAt(0) && name[2] === ".".charCodeAt(0)) { /* name start with '_G.'? */
@@ -513,7 +513,7 @@ const luaL_tolstring = function(L, idx) {
** Leaves resulting module on the top.
*/
const luaL_requiref = function(L, modname, openf, glb) {
- luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, lua.to_luastring(LUA_LOADED_TABLE));
+ luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
lua.lua_getfield(L, -1, modname); /* LOADED[modname] */
if (!lua.lua_toboolean(L, -1)) { /* package not already loaded? */
lua.lua_pop(L, 1); /* remove field */
diff --git a/src/loadlib.js b/src/loadlib.js
index 49f2715..dbd5c3c 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -366,7 +366,7 @@ const searcher_Croot = function(L) {
const searcher_preload = function(L) {
let name = lauxlib.luaL_checkstring(L, 1);
- lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring(lauxlib.LUA_PRELOAD_TABLE, true));
+ lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lauxlib.LUA_PRELOAD_TABLE);
if (lua.lua_getfield(L, -1, name) === lua.LUA_TNIL) /* not found? */
lua.lua_pushfstring(L, lua.to_luastring("\n\tno field package.preload['%s']"), name);
return 1;
@@ -411,7 +411,7 @@ const findloader_cont = function(L, status, ctx) {
const ll_require = function(L) {
let name = lauxlib.luaL_checkstring(L, 1);
lua.lua_settop(L, 1); /* LOADED table will be at index 2 */
- lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring(lauxlib.LUA_LOADED_TABLE, true));
+ lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lauxlib.LUA_LOADED_TABLE);
lua.lua_getfield(L, 2, name); /* LOADED[name] */
if (lua.lua_toboolean(L, -1)) /* is it there? */
return 1; /* package is already loaded */
@@ -486,10 +486,10 @@ const luaopen_package = function(L) {
lua.LUA_EXEC_DIR + "\n" + LUA_IGMARK + "\n");
lua.lua_setfield(L, -2, lua.to_luastring("config", true));
/* set field 'loaded' */
- lauxlib.luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, lua.to_luastring(lauxlib.LUA_LOADED_TABLE, true));
+ lauxlib.luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, lauxlib.LUA_LOADED_TABLE);
lua.lua_setfield(L, -2, lua.to_luastring("loaded", true));
/* set field 'preload' */
- lauxlib.luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, lua.to_luastring(lauxlib.LUA_PRELOAD_TABLE, true));
+ lauxlib.luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, lauxlib.LUA_PRELOAD_TABLE);
lua.lua_setfield(L, -2, lua.to_luastring("preload", true));
lua.lua_pushglobaltable(L);
lua.lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */