get_wrapped_original
Returns the wrapped lclosure from a newcclosure.
function get_wrapped_original(func: function): functionSynopsis
How it works
When
newcclosure(f) wraps a Luau function, it stores the original LClosure as an internal upvalueUpvalueA variable captured from an enclosing scope. When a function references a local variable from an outer function, that variable becomes an upvalue — stored in an UpVal struct that persists even after the outer function returns. of the wrapper CClosure. get_wrapped_original extracts and returns this stored reference. Errors if the input is not a newcclosure-created wrapper.Use case
Useful for debugging and anti-tamper checks — you can verify that a newcclosure wrapper still points to the expected original function, or extract the original for direct invocation bypassing the C wrapper overhead.
Usage
Retrieve original
function a()
print("Hello World!")
end
local b = newcclosure(a)
local c = get_wrapped_original(b)
print(a == c) "cc">--> trueParameters
func function The newcclosure to get the lclosure from.
Returns
function The original lclosure wrapped inside the newcclosure.