mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
love.filesystem is now loaded by default in threads (see issue #1040.)
This commit is contained in:
+14
-4
@@ -188,7 +188,7 @@ int luax_assert_nilerror(lua_State *L, int idx)
|
||||
|
||||
void luax_setfuncs(lua_State *L, const luaL_Reg *l)
|
||||
{
|
||||
if (l == 0)
|
||||
if (l == nullptr)
|
||||
return;
|
||||
|
||||
for (; l->name != nullptr; l++)
|
||||
@@ -198,6 +198,14 @@ void luax_setfuncs(lua_State *L, const luaL_Reg *l)
|
||||
}
|
||||
}
|
||||
|
||||
int luax_require(lua_State *L, const char *name)
|
||||
{
|
||||
lua_getglobal(L, "require");
|
||||
lua_pushstring(L, name);
|
||||
lua_call(L, 1, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int luax_register_module(lua_State *L, const WrappedModule &m)
|
||||
{
|
||||
// Put a reference to the C++ module in Lua.
|
||||
@@ -224,13 +232,15 @@ int luax_register_module(lua_State *L, const WrappedModule &m)
|
||||
lua_newtable(L);
|
||||
|
||||
// Register all the functions.
|
||||
if (m.functions != 0)
|
||||
if (m.functions != nullptr)
|
||||
luax_setfuncs(L, m.functions);
|
||||
|
||||
// Register types.
|
||||
if (m.types != 0)
|
||||
for (const lua_CFunction *t = m.types; *t != 0; t++)
|
||||
if (m.types != nullptr)
|
||||
{
|
||||
for (const lua_CFunction *t = m.types; *t != nullptr; t++)
|
||||
(*t)(L);
|
||||
}
|
||||
|
||||
lua_pushvalue(L, -1);
|
||||
lua_setfield(L, -3, m.name); // love.graphics = table
|
||||
|
||||
@@ -222,6 +222,13 @@ int luax_assert_nilerror(lua_State *L, int idx);
|
||||
**/
|
||||
void luax_setfuncs(lua_State *L, const luaL_Reg *l);
|
||||
|
||||
/**
|
||||
* Loads a Lua module using the 'require' function. Leaves the return result on
|
||||
* the stack.
|
||||
* @param name The name of the module to require.
|
||||
**/
|
||||
int luax_require(lua_State *L, const char *name);
|
||||
|
||||
/**
|
||||
* Register a module in the love table. The love table will be created if it does not exist.
|
||||
* NOTE: The module-object is expected to have a +1 reference count before calling
|
||||
|
||||
Reference in New Issue
Block a user