Functions & hooks
Closures, callable identity, function hooks and prototype hooks.
These calls inspect closures and replace function behavior.
- Keep the callable original returned by a hook if your replacement needs to delegate.
- Restore the target when finished.
See changing a function temporarily before using lower-level prototype hooks.
Functions
| Function | Purpose |
|---|---|
| iscclosure | Checks whether a function is a C closure. |
| islclosure | Checks whether a function is a Lua closure. |
| isexecutorclosure | Checks whether Acedia created a function. |
| isnewcclosure | Checks whether a function is an executor C wrapper. |
| getfunctionhash | Computes a content hash for a Lua function. |
| newcclosure | Wraps a function in an executor C closure. |
| newlclosure | Creates a Lua closure that forwards to another function. |
| clonefunction | Creates a separate closure with the original function's behavior. |
| checkcaller | Reports whether the current call is attributed to executor code. |
| isourthread | Checks whether a thread belongs to executor code. |
| comparefunctions | Checks whether two functions are the same closure or forward to the same root. |
| setstackhidden | Controls whether a stack level appears in supported stack reports. |
| hookfunction | Replaces a function's behavior and returns a callable copy of its previous behavior. |
| restorefunction | Restores a function or registered metamethod hook. |
| isfunctionhooked | Checks whether a function has a recorded function or metamethod hook. |
| hookmetamethod | Replaces a function-valued metamethod and returns its original implementation. |
| hookproto | Redirects existing closures sharing a Lua prototype to a replacement function. |
| restoreproto | Restores closures affected by a recorded prototype hook. |
| isprotohooked | Checks whether a function uses a recorded hooked prototype. |
| oth.hook | Installs an off-thread hook for a C function. |
| oth.unhook | Removes the most recently matching off-thread hook. |
| oth.get_root_callback | Returns the original callback of the active off-thread hook. |
| oth.is_hook_thread | Checks whether an off-thread hook callback is active. |
| oth.get_original_thread | Returns the caller thread of the active off-thread hook. |
