hookproto
Redirects existing closures sharing a Lua prototype to a replacement function.
Unlike hookfunction, this operates on existing closures sharing that prototype. It returns no original-function handle.
The target may also be a prototype handle from debug.getproto. That form additionally patches the slot the owning prototype holds the child in, so closures created after the hook pick it up too. A live closure only reaches the closures that already exist.
hookproto(target: function, replacement: function): ()Parameters
| Parameter | Type | Description |
|---|---|---|
target | function | Lua function whose prototype is targeted, or a debug.getproto handle. |
replacement | function | Replacement callback. |
Errors: A C function has no prototype. Hooking an already recorded prototype raises an error.
