~seanlynch/mooa

c5db0f2aa0f97b1118876bd46582b9ad68b7bf54 — Sean Lynch 8 years ago 4f88916
Load SDL module
1 files changed, 19 insertions(+), 0 deletions(-)

M mooa.c
M mooa.c => mooa.c +19 -0
@@ 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",