=proto int duk_push_c_function(duk_context *ctx, duk_c_function func, int nargs); =stack [ ... ] -> [ ... func! ] =summary
Push a new function object, associated with a C function, to the stack.
The function object is an Ecmascript function object; when called, func
will be called using the Duktape/C function interface. Returns non-negative index
(relative to stack bottom) of the pushed function.
The nargs
argument controls how the value stack looks like when
func
is entered:
nargs
is >= 0, it indicates the exact number of arguments the
function expects to see; extra arguments are discarded and missing arguments
are filled in with undefined
values. Upon entry to the function, value
stack top will always match nargs
.nargs
is set to DUK_VARARGS
, the value stack will contain
actual (variable) call arguments and the function needs to check actual argument
count with duk_get_top()
.