mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 21:10:37 +00:00
7345891f6b
Some userdata objects may need to support manual destruction in addition to automatic GC. For example, files, threads, GPU resources and objects with large external allocations. With Lua, a finalizer can be _generically_ called by invoking the __gc metamethod manually, but this is currently not possible with tagged userdata in Luau because it's not possible to query the destructor associated with an userdata. While it is possible to workaround this by duplicating the destructor table locally on client side (*), it's more convenient to deduplicate the data and get the destructor using the API instead. (*) Note: a separate destructor table for each VM may be required if the VMs use different set of tags. Implementation notes: 1. I first considered adding a typedef for lua_Destructor but unfortunately there are two kinds of destructors, one with and one without the lua_State* argument, so I decided against it at this point. Maybe it should be added later if the destructor API is unified (by dropping the Lua state pointer argument?). 2. For some reason the conformance test produced warning "qualifier applied to function type has no meaning; ignored" on VS2017 (possibly because the test framework does not like function pointers for some reason?). I silenced this by pulling out the test expressions from those CHECKs. |
||
---|---|---|
.. | ||
include | ||
src |