Singe now properly pre-loads embedded Lua C libraries.
This commit is contained in:
parent
405881f2d7
commit
aff5341801
2 changed files with 19 additions and 7 deletions
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
dofile("Singe/Framework.singe")
|
dofile("Singe/Framework.singe")
|
||||||
|
|
||||||
|
lfs = require("lfs")
|
||||||
|
|
||||||
|
|
||||||
function compareTitles(a, b)
|
function compareTitles(a, b)
|
||||||
return a.TITLE < b.TITLE
|
return a.TITLE < b.TITLE
|
||||||
|
|
|
@ -34,9 +34,9 @@
|
||||||
#include "thirdparty/manymouse/manymouse.h"
|
#include "thirdparty/manymouse/manymouse.h"
|
||||||
#include "thirdparty/luafilesystem/src/lfs.h"
|
#include "thirdparty/luafilesystem/src/lfs.h"
|
||||||
#include "thirdparty/luasocket/src/luasocket.h"
|
#include "thirdparty/luasocket/src/luasocket.h"
|
||||||
|
#include "thirdparty/luasocket/src/mime.h"
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include "thirdparty/luasocket/src/unixdgram.h"
|
#include "thirdparty/luasocket/src/unix.h"
|
||||||
#include "thirdparty/luasocket/src/unixstream.h"
|
|
||||||
// There is no serial.h, so fake it.
|
// There is no serial.h, so fake it.
|
||||||
LUASOCKET_API int luaopen_socket_serial(lua_State *L);
|
LUASOCKET_API int luaopen_socket_serial(lua_State *L);
|
||||||
#endif
|
#endif
|
||||||
|
@ -340,6 +340,7 @@ void callLua(const char *func, const char *sig, ...);
|
||||||
void channelFinished(int channel);
|
void channelFinished(int channel);
|
||||||
void luaDie(lua_State *L, char *method, char *fmt, ...);
|
void luaDie(lua_State *L, char *method, char *fmt, ...);
|
||||||
int32_t luaError(lua_State *L);
|
int32_t luaError(lua_State *L);
|
||||||
|
void luaPreload(lua_State *L, const char *name, lua_CFunction func);
|
||||||
void luaTrace(lua_State *L, char *method, char *fmt, ...);
|
void luaTrace(lua_State *L, char *method, char *fmt, ...);
|
||||||
void processKey(bool down, int keysym, int32_t scancode);
|
void processKey(bool down, int keysym, int32_t scancode);
|
||||||
void putPixel(int32_t x, int32_t y);
|
void putPixel(int32_t x, int32_t y);
|
||||||
|
@ -3213,6 +3214,14 @@ void luaStackDump(lua_State *L) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void luaPreload(lua_State *L, const char *name, lua_CFunction func) {
|
||||||
|
luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
|
||||||
|
lua_pushcfunction(L, func);
|
||||||
|
lua_setfield(L, -2, name);
|
||||||
|
lua_pop(L, 1); // remove PRELOAD table
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void luaTrace(lua_State *L, char *method, char *fmt, ...) {
|
void luaTrace(lua_State *L, char *method, char *fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
|
@ -4142,12 +4151,13 @@ void startControllers(void) {
|
||||||
void startLuaContext(lua_State *L) {
|
void startLuaContext(lua_State *L) {
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
lua_atpanic(L, luaError);
|
lua_atpanic(L, luaError);
|
||||||
luaopen_lfs(L);
|
|
||||||
luaopen_socket_core(L);
|
luaPreload(L, "lfs", luaopen_lfs);
|
||||||
|
luaPreload(L, "socket.core", luaopen_socket_core);
|
||||||
|
luaPreload(L, "mime.core", luaopen_mime_core);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
unixdgram_open(L);
|
luaPreload(L, "socket.unix", luaopen_socket_unix);
|
||||||
unixstream_open(L);
|
luaPreload(L, "socket.serial", luaopen_socket_serial);
|
||||||
luaopen_socket_serial(L);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue