mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Add support for lua 5.4 to-be-closed variables
Automatically call object:release() when an object is used as a to-be-closed variable. Since both release and __gc already handle multiple calls, this just works. Theoretically extra actions could be added to some objects, like File calling File:close(), but it already does that in its destructor, so that should be unnecessary.
This commit is contained in:
@@ -547,6 +547,10 @@ int luax_register_type(lua_State *L, love::Type *type, ...)
|
||||
lua_pushcfunction(L, w__release);
|
||||
lua_setfield(L, -2, "release");
|
||||
|
||||
// Add __close for lua 5.4 (just calls release)
|
||||
lua_pushcfunction(L, w__release);
|
||||
lua_setfield(L, -2, "__close");
|
||||
|
||||
va_list fs;
|
||||
va_start(fs, type);
|
||||
for (const luaL_Reg *f = va_arg(fs, const luaL_Reg *); f; f = va_arg(fs, const luaL_Reg *))
|
||||
|
||||
Reference in New Issue
Block a user