int luaopen_sdl(lua_State *L) { fps_ctrl* ctrl = (fps_ctrl*)lua_newuserdata(L, sizeof(fps_ctrl)); ctrl->init(); luaT_register(L, "sdl", sdllib); for (auto reg = sdllib_with_upvalue.begin(); reg->name; ++reg) { lua_pushvalue(L, -2); luaT_pushcclosure(L, reg->func, 1); lua_setfield(L, -2, reg->name); } load_extra(L, "audio", luaopen_sdl_audio); load_extra(L, "wm", luaopen_sdl_wm); return 1; }
int luaopen_sdl(lua_State *L) { fps_ctrl* ctrl = (fps_ctrl*)lua_newuserdata(L, sizeof(fps_ctrl)); ctrl->init(); luaT_register(L, "sdl", sdllib); const luaL_Reg *pUpvaluedFunctions = sdllib_with_upvalue; for(; pUpvaluedFunctions->name; ++pUpvaluedFunctions) { lua_pushvalue(L, -2); luaT_pushcclosure(L, pUpvaluedFunctions->func, 1); lua_setfield(L, -2, pUpvaluedFunctions->name); } load_extra(L, "audio", luaopen_sdl_audio); load_extra(L, "wm", luaopen_sdl_wm); return 1; }