You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
607 B

/*===
duk_get_c_function == my_func: 1
index 3 -> NULL: 1
index DUK_INVALID_INDEX -> NULL: 1
===*/
int my_func(duk_context *ctx) {
return 0;
}
void test(duk_context *ctx) {
duk_c_function funcptr;
duk_push_c_function(ctx, my_func, 1 /*nargs*/);
funcptr = duk_get_c_function(ctx, -1);
printf("duk_get_c_function == my_func: %d\n", (funcptr == my_func ? 1 : 0));
funcptr = duk_get_c_function(ctx, 3);
printf("index 3 -> NULL: %d\n", (funcptr == NULL ? 1 : 0));
funcptr = duk_get_c_function(ctx, DUK_INVALID_INDEX);
printf("index DUK_INVALID_INDEX -> NULL: %d\n", (funcptr == NULL ? 1 : 0));
}