oth.get_root_callback
Returns the root callback while executing inside an OTH hook thread.
Syntax
oth.get_root_callback() -> function?Returns
| Type | Description |
|---|---|
function? | The root original callback, or nil outside a supported hook call |
Description
oth.get_root_callback inspects the original caller thread for the C closure currently dispatching an OTH hook. It takes no arguments and is meaningful only from inside the hook callback.
Example
local originalAbs
originalAbs = oth.hook(math.abs, function(value)
local root = oth.get_root_callback()
assert(root, "Expected an OTH hook thread")
return root(value)
end)
print(math.abs(-5)) -- 5Notes
- Returns nil outside an OTH hook thread or when the root callback cannot be resolved
Related Functions
oth.hook- Create a hookoth.unhook- Remove a hook