I want to call duk_push_c_function()
with a lambda defined in C++, a bit like this:
SomeObjType parameter;
// store stuff in 'parameter'
auto myLambda = [parameter](duk_context* ctx) {
// do stuff with parameter
return (duk_ret_t)1;
}
duk_push_c_function(ctx, myLambda , 1);
My problem is that this won't compile because myLambda
is not a C function:
error C2664: 'duk_idx_t duk_push_c_function(duk_context *,duk_c_function,duk_idx_t)': cannot convert argument 2 from 'MyObjectName::<lambda_07f401c134676d14b7ddd718ad05fbe6>' to 'duk_c_function'
Is there a nice way of passing a nameless function with parameters into duktape?