Added Object:release. Calling it is the equivalent of removing all Lua-side references to an object and doing a full garbage collection cycle (thus deleting the object from memory if nothing else in LÖVE's code is referencing it).

Any attempt to call a method on the object after it has been released will result in an error. Object:release() returns true if it was successful, or false if not (if it has already been released previously).

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-10-06 21:59:01 -03:00
parent bfb00239fd
commit 37520bd18b
7 changed files with 69 additions and 9 deletions
@@ -72,6 +72,8 @@ local ffifuncs = ffi.cast("FFI_RandomGenerator *", ffifuncspointer)
-- Overwrite some regular love.math functions with FFI implementations.
function RandomGenerator:random(l, u)
-- TODO: This should ideally be handled inside ffifuncs.random
if self == nil then error("bad argument #1 to 'random' (RandomGenerator expected, got no value)", 2) end
local r = tonumber(ffifuncs.random(self))
return getrandom(r, l, u)
end