mirror of
https://github.com/love2d/love.git
synced 2026-08-20 20:49:54 +02:00
Properly export love modules to lua, package.loaded is correct now
This commit is contained in:
@@ -187,10 +187,11 @@ namespace love
|
|||||||
for (const lua_CFunction * t = m.types; *t != 0; t++)
|
for (const lua_CFunction * t = m.types; *t != 0; t++)
|
||||||
(*t)(L);
|
(*t)(L);
|
||||||
|
|
||||||
lua_setfield(L, -2, m.name); // love.graphics = table
|
lua_pushvalue(L, -1);
|
||||||
lua_pop(L, 1); // love
|
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)
|
int luax_preload(lua_State * L, lua_CFunction f, const char * name)
|
||||||
|
|||||||
+1
-3
@@ -125,8 +125,6 @@ extern "C" LOVE_EXPORT int luaopen_love(lua_State * L)
|
|||||||
|
|
||||||
lua_setfield(L, -2, "_version_compat");
|
lua_setfield(L, -2, "_version_compat");
|
||||||
|
|
||||||
lua_pop(L, 1); // love
|
|
||||||
|
|
||||||
#ifdef LOVE_BUILD_STANDALONE
|
#ifdef LOVE_BUILD_STANDALONE
|
||||||
|
|
||||||
// Preload module loaders.
|
// Preload module loaders.
|
||||||
@@ -139,7 +137,7 @@ extern "C" LOVE_EXPORT int luaopen_love(lua_State * L)
|
|||||||
|
|
||||||
#endif // LOVE_BUILD_STANDALONE
|
#endif // LOVE_BUILD_STANDALONE
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK
|
#ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK
|
||||||
|
|||||||
@@ -327,12 +327,12 @@ namespace audio
|
|||||||
w.functions = functions;
|
w.functions = functions;
|
||||||
w.types = types;
|
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)
|
if (luaL_loadbuffer(L, (const char *)audio_lua, sizeof(audio_lua), "audio.lua") == 0)
|
||||||
lua_call(L, 0, 0);
|
lua_call(L, 0, 0);
|
||||||
|
|
||||||
return 0;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // audio
|
} // audio
|
||||||
|
|||||||
@@ -1300,12 +1300,12 @@ namespace opengl
|
|||||||
w.functions = functions;
|
w.functions = functions;
|
||||||
w.types = types;
|
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)
|
if (luaL_loadbuffer(L, (const char *)graphics_lua, sizeof(graphics_lua), "graphics.lua") == 0)
|
||||||
lua_call(L, 0, 0);
|
lua_call(L, 0, 0);
|
||||||
|
|
||||||
return 0;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // opengl
|
} // opengl
|
||||||
|
|||||||
Reference in New Issue
Block a user