|
Replace the global next(), pairs() and ipairs() functions with a C++ function
that drills down through layers of setdtor() proxy objects and then forwards
the updated arguments to the original global function.
Add a Luau __iter() metamethod to setdtor() proxy objects that, like other
proxy metamethods, drills down to the underlying _target object. __iter()
recognizes the case of a _target table which itself has a __iter() metamethod.
Also add __idiv() metamethod to support integer division.
Add tests for proxy // division, next(proxy), next(proxy, key), pairs(proxy),
ipairs(proxy) and 'for k, v in proxy'. Also test the case where the table
wrapped in the proxy has an __iter() metamethod of its own.
|
|
`setdtor('description', object, function)` returns a proxy userdata object
referencing object and function. When the proxy is garbage-collected, or at
the end of the script, its destructor calls `function(object)`.
The original object may be retrieved as `proxy._target`, e.g. to pass it to
the `table` library. The proxy also has a metatable with metamethods
supporting arithmetic operations, string concatenation, length and table
indexing. For other operations, retrieve `proxy._target`. (But don't assign to
`proxy._target`. It will appear to work, in that subsequent references to
`proxy._target` will retrieve the replacement object -- however, the
destructor will still call `function(original object)`.)
Fix bugs in `lua_setfieldv()`, `lua_rawgetfield()` and `lua_rawsetfield()`.
Add C++ functions `lua_destroyuserdata()` to explicitly destroy a
`lua_emplace<T>()` userdata object, plus `lua_destroybounduserdata()`. The
latter can bind such a userdata object as an upvalue to pass to `LL.atexit()`.
Make `LL.help()` and `LL.leaphelp()` help text include the `LL.` prefix.
|