Skip to content
Snippets Groups Projects
Commit 05d9001d authored by Luigi Scarso's avatar Luigi Scarso
Browse files

slightly better luastuff.w -- !!! WARNING: WORK IN PROGRESS !!!

parent 85bcb607
Branches
Tags
No related merge requests found
...@@ -83,7 +83,11 @@ static const char *getS(lua_State * L, void *ud, size_t * size) ...@@ -83,7 +83,11 @@ static const char *getS(lua_State * L, void *ud, size_t * size)
@ @c @ @c
#ifdef LuajitTeX #ifdef LuajitTeX
/* not used */ /* Luatex has its own memory allocator, LuajitTeX uses the */
/* standard one from the stock. We left this space as */
/* reference, but be careful: memory allocator is a key */
/* component in luajit, it's easy to get sub-optimal */
/* performances. */
#else #else
static void *my_luaalloc(void *ud, void *ptr, size_t osize, size_t nsize) static void *my_luaalloc(void *ud, void *ptr, size_t osize, size_t nsize)
{ {
...@@ -145,8 +149,9 @@ static const luaL_Reg lualibs[] = { ...@@ -145,8 +149,9 @@ static const luaL_Reg lualibs[] = {
{ "lpeg", luaopen_lpeg }, { "lpeg", luaopen_lpeg },
{ "bit32", luaopen_bit32 }, { "bit32", luaopen_bit32 },
#ifdef LuajitTeX #ifdef LuajitTeX
{ "bit", luaopen_bit }, /* bit is only in luajit, */
/* coroutine is loaded in a special way */ /* coroutine is loaded in a special way */
{ "bit", luaopen_bit },
#else #else
{ "coroutine", luaopen_coroutine }, { "coroutine", luaopen_coroutine },
#endif #endif
...@@ -158,8 +163,6 @@ static const luaL_Reg lualibs[] = { ...@@ -158,8 +163,6 @@ static const luaL_Reg lualibs[] = {
/* extra standard lua libraries */ /* extra standard lua libraries */
#ifdef LuajitTeX #ifdef LuajitTeX
{ "jit", luaopen_jit }, { "jit", luaopen_jit },
#else
{ "coroutine", luaopen_coroutine },
#endif #endif
{ "ffi", luaopen_ffi }, { "ffi", luaopen_ffi },
/* obsolete, undocumented and for oru own testing only */ /* obsolete, undocumented and for oru own testing only */
...@@ -179,7 +182,7 @@ static void do_openlibs(lua_State * L) ...@@ -179,7 +182,7 @@ static void do_openlibs(lua_State * L)
@ @c @ @c
#ifdef LuajitTeX #ifdef LuajitTeX
/* not used */ /* in luajit load_aux is not used.*/
#else #else
static int load_aux (lua_State *L, int status) { static int load_aux (lua_State *L, int status) {
if (status == 0) /* OK? */ if (status == 0) /* OK? */
...@@ -303,9 +306,7 @@ void luainterpreter(void) ...@@ -303,9 +306,7 @@ void luainterpreter(void)
*/ */
if (!nosocket_option) { if (!nosocket_option) {
/* todo: move this to common */ /* todo: move this to common */
lua_getglobal(L, "package"); lua_getglobal(L, "package");
lua_getfield(L, -1, "loaded"); lua_getfield(L, -1, "loaded");
if (!lua_istable(L, -1)) { if (!lua_istable(L, -1)) {
...@@ -328,7 +329,6 @@ void luainterpreter(void) ...@@ -328,7 +329,6 @@ void luainterpreter(void)
} }
/* zlib. slightly odd calling convention */ /* zlib. slightly odd calling convention */
luaopen_zlib(L); luaopen_zlib(L);
lua_setglobal(L, "zlib"); lua_setglobal(L, "zlib");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment