|
word_t | croc_function_newWithEnv (CrocThread *t, const char *name, word_t maxParams, CrocNativeFunc func, uword_t numUpvals) |
|
word_t | croc_function_newScript (CrocThread *t, word_t funcdef) |
|
word_t | croc_function_newScriptWithEnv (CrocThread *t, word_t funcdef) |
|
word_t | croc_function_pushEnv (CrocThread *t, word_t func) |
|
void | croc_function_setEnv (CrocThread *t, word_t func) |
|
word_t | croc_function_pushDef (CrocThread *t, word_t func) |
|
uword_t | croc_function_getNumParams (CrocThread *t, word_t func) |
|
uword_t | croc_function_getMaxParams (CrocThread *t, word_t func) |
|
int | croc_function_isVararg (CrocThread *t, word_t func) |
|
uword_t | croc_function_getNumReturns (CrocThread *t, word_t func) |
|
uword_t | croc_function_getMaxReturns (CrocThread *t, word_t func) |
|
int | croc_function_isVarret (CrocThread *t, word_t func) |
|
int | croc_function_isNative (CrocThread *t, word_t func) |
|
Functions which operate on function closures.
Like croc_function_newWithEnv, except it uses the current environment namespace, so the only values it expects on the stack are any upvalues.
Creates and pushes a new native function closure, expecting the environment on top of the stack and any upvals below that.
The environment namespace and any upvals are popped and the function is pushed in their place.
- Parameters
-
name | is the name to give the function. |
maxParams | is the maximum allowable parameters (after the 'this' parameter), or -1 to make it variadic. |
func | is the native function itself. |
numUpvals | is how many upvalues will be associated with this closure. There must be this many values on the stack under the environment namespace on top. |
- Returns
- the stack index of the pushed value.
Creates and pushes a new script function closure from the function definition in slot funcdef
, and uses the current function environment (or the globals if there is none) as the closure's environment.
There is no way to create a script closure through the native API from a funcdef which has upvalues. Also, it is an error to create a closure with a different environment namespace than it was instantiated with initially.
- Returns
- the stack index of the pushed value.
Same as croc_function_newScript, but expects the environment namespace on top of the stack.
It will be popped and the function will be pushed in its place.
- Returns
- the stack index of the pushed value.
Pushes the environment namespace of the function at slot func
.
- Returns
- the stack index of the pushed value.
Sets the environment namespace of the native function closure at slot func
.
Expects the new environment on top of the stack, and pops it.
You cannot set the environment namespace of script closures.
Pushes the funcdef of the function closure at func
, or pushes null
if func
is a native function.
- Returns
- the stack index of the pushed value.
- Returns
- the number of non-variadic parameters that the function at
func
takes.
- Returns
- the maximum number of parameters that the function at
func
can be called with. For variadic functions, this will be an absurdly large number.
- Returns
- nonzero if the function at
func
is variadic.
- Returns
- the number of non-variadic values that the function at
func
returns.
- Returns
- the maximum number of values that the function at
func
can return. For variadic return functions, this will be an absurdly large number.
- Returns
- nonzero if the function at
func
has variadic returns.
- Returns
- nonzero if the function at
func
is native.