Properly export love modules to lua, package.loaded is correct now

This commit is contained in:
Bart van Strien
2012-01-07 14:08:41 +01:00
parent 870973197c
commit e0b420c988
4 changed files with 9 additions and 10 deletions
+4 -3
View File
@@ -187,10 +187,11 @@ namespace love
for (const lua_CFunction * t = m.types; *t != 0; t++)
(*t)(L);
lua_setfield(L, -2, m.name); // love.graphics = table
lua_pop(L, 1); // love
lua_pushvalue(L, -1);
lua_setfield(L, -3, m.name); // love.graphics = table
lua_remove(L, -2); // love
return 0;
return 1;
}
int luax_preload(lua_State * L, lua_CFunction f, const char * name)
+1 -3
View File
@@ -125,8 +125,6 @@ extern "C" LOVE_EXPORT int luaopen_love(lua_State * L)
lua_setfield(L, -2, "_version_compat");
lua_pop(L, 1); // love
#ifdef LOVE_BUILD_STANDALONE
// Preload module loaders.
@@ -139,7 +137,7 @@ extern "C" LOVE_EXPORT int luaopen_love(lua_State * L)
#endif // LOVE_BUILD_STANDALONE
return 0;
return 1;
}
#ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK
+2 -2
View File
@@ -327,12 +327,12 @@ namespace audio
w.functions = functions;
w.types = types;
luax_register_module(L, w);
int n = luax_register_module(L, w);
if (luaL_loadbuffer(L, (const char *)audio_lua, sizeof(audio_lua), "audio.lua") == 0)
lua_call(L, 0, 0);
return 0;
return n;
}
} // audio
@@ -1300,12 +1300,12 @@ namespace opengl
w.functions = functions;
w.types = types;
luax_register_module(L, w);
int n = luax_register_module(L, w);
if (luaL_loadbuffer(L, (const char *)graphics_lua, sizeof(graphics_lua), "graphics.lua") == 0)
lua_call(L, 0, 0);
return 0;
return n;
}
} // opengl