Changed love module to init all classes before anything else
This commit is contained in:
45
src/love.c
45
src/love.c
@@ -16,35 +16,16 @@ int l_love_getVersion(lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
/* Submodules */
|
||||
int luaopen_image(lua_State *L);
|
||||
int luaopen_quad(lua_State *L);
|
||||
int luaopen_font(lua_State *L);
|
||||
int luaopen_system(lua_State *L);
|
||||
int luaopen_graphics(lua_State *L);
|
||||
int luaopen_timer(lua_State *L);
|
||||
int luaopen_keyboard(lua_State *L);
|
||||
/* Classes */
|
||||
int luaopen_image(lua_State *L);
|
||||
int luaopen_quad(lua_State *L);
|
||||
int luaopen_font(lua_State *L);
|
||||
|
||||
int luaopen_love(lua_State *L) {
|
||||
int i;
|
||||
luaL_Reg reg[] = {
|
||||
{ "getVerson", l_love_getVersion },
|
||||
{ 0, 0 },
|
||||
};
|
||||
luaL_newlib(L, reg);
|
||||
/* Init submodules */
|
||||
struct { char *name; int (*fn)(lua_State *L); } mods[] = {
|
||||
{ "system", luaopen_system },
|
||||
{ "graphics", luaopen_graphics },
|
||||
{ "timer", luaopen_timer },
|
||||
{ "keyboard", luaopen_keyboard },
|
||||
{ 0 },
|
||||
};
|
||||
for (i = 0; mods[i].name; i++) {
|
||||
mods[i].fn(L);
|
||||
lua_setfield(L, -2, mods[i].name);
|
||||
}
|
||||
/* Init classes -- all the built in classes are inited here as to create the
|
||||
* metatables required by their constructors. Any new classes must also be
|
||||
* registered here before they will work. */
|
||||
@@ -58,5 +39,25 @@ int luaopen_love(lua_State *L) {
|
||||
classes[i](L);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
/* Init love module */
|
||||
luaL_Reg reg[] = {
|
||||
{ "getVerson", l_love_getVersion },
|
||||
{ 0, 0 },
|
||||
};
|
||||
luaL_newlib(L, reg);
|
||||
|
||||
/* Init submodules */
|
||||
struct { char *name; int (*fn)(lua_State *L); } mods[] = {
|
||||
{ "system", luaopen_system },
|
||||
{ "graphics", luaopen_graphics },
|
||||
{ "timer", luaopen_timer },
|
||||
{ "keyboard", luaopen_keyboard },
|
||||
{ 0 },
|
||||
};
|
||||
for (i = 0; mods[i].name; i++) {
|
||||
mods[i].fn(L);
|
||||
lua_setfield(L, -2, mods[i].name);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user