Using the duktape javascript implementation, you can expose native C functions to javascript and implement them like this:
static duk_ret_t native_prime_check(duk_context *ctx) {
int arg1 = duk_require_int(ctx, 0);
int arg2 = duk_require_int(ctx, 1);
// do something.
return 0;
}
When exposing the native function we need to specify the number of arguments.
duk_push_c_function(ctx, native_prime_check, 2 /*nargs*/);
Please give an example of how to make a C function that takes a variable number of arguments and expose it to Javascript using duktape.