mooa

Lua + lubev + sandboxing
git clone https://code.literati.org/mooa.git
Log | Files | Refs | README | LICENSE

commit c5db0f2aa0f97b1118876bd46582b9ad68b7bf54
parent 4f889169ade576de6fc1b7d25036bdec881fdb97
Author: Sean Lynch <seanl@literati.org>
Date:   Tue, 23 Feb 2016 22:49:46 -0800

Load SDL module

Diffstat:
Mmooa.c | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/mooa.c b/mooa.c @@ -86,6 +86,7 @@ static void mooa_state_makesafe(lua_State *L) { } lua_rawseti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); + lua_pop(L, 1); } @@ -126,6 +127,13 @@ static int mooa_panic(lua_State *L) { } +static void mooa_require(lua_State *L, const char *module) { + lua_getglobal(L, "require"); + lua_pushstring(L, module); + lua_call(L, 1, 0); +} + + static lua_State *mooa_state_new(void) { lua_State *L; @@ -137,8 +145,18 @@ static lua_State *mooa_state_new(void) { mooa_task_init_state(L); + lua_newtable(L); + lua_setfield(L, LUA_REGISTRYINDEX, "mooa_packages"); + luaL_requiref(L, "base", luaopen_base, 0); luaL_requiref(L, "package", luaopen_package, 1); + + mooa_require(L, "SDL"); + mooa_require(L, "SDL.image"); + mooa_require(L, "SDL.mixer"); + mooa_require(L, "SDL.net"); + mooa_require(L, "SDL.ttf"); + mooa_state_makesafe(L); luaL_requiref(L, LUA_BITLIBNAME, luaopen_bit32, 1); @@ -176,6 +194,7 @@ int main(void) { "gettid", "getuid", "mmap", + "munmap", "read", "recvfrom", "rt_sigaction",