public class EvalFunctionWrapper<ReturnType> implements Invocable<ReturnType>
Internal wrapper for functions created via eval().
The wrapper implements the reflective Invocable<R> contract because the evaluated function's parameter signature is discovered at runtime. Ordinary callbacks should use a structural function type such as (Int) -> Int.
import klyn.reflection
f = eval("""def twice(x as Int) as Int:
return x * 2
""")
assert f is Invocable<Int>
print(f(21)) # 42| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | namename as String |
No summary. |
| public readonly property | parameterCountparameterCount as ULong |
No summary. |
| public readonly property | returnTypereturnType as String |
No summary. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | EvalFunctionWrapperEvalFunctionWrapper(name as String,
parameterCount as ULong,
returnTypeName as String,
functionPointer as Object) |
Creates a typed wrapper over a function produced by eval(). |
| Modifier and Type | Member | Description |
|---|---|---|
| public | invoke | Invokes the function with dynamic arguments. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | operator ()(args as Object[]) as ReturnType throws Exception | Operator call - enables f(args) syntax. |