Add :release to all objects;

This commit is contained in:
bjorn 2019-11-11 18:42:11 -08:00
parent 13136482b9
commit 9ac34ff190
1 changed files with 5 additions and 0 deletions

View File

@ -23,6 +23,7 @@ static int luax_meta__gc(lua_State* L) {
destructorFn* destructor = (destructorFn*) lua_tocfunction(L, -1);
if (destructor) {
_lovrRelease(p->object, destructor);
p->object = NULL;
}
}
return 0;
@ -70,6 +71,10 @@ void _luax_registertype(lua_State* L, const char* name, const luaL_Reg* function
luaL_register(L, NULL, functions);
}
// :release function
lua_pushcfunction(L, luax_meta__gc);
lua_setfield(L, -2, "release");
// Pop metatable
lua_pop(L, 1);
}