Is there a way to convert from 'v8::Local' to 'void (int)'. I have a v8 function and I'm trying to pass it into signal on windows.
v8::Local<v8::Function> function;
function = v8::Local<v8::Function>::Cast(args[1]);
(void)signal(SIGINT, function);
I'm unsure of the best way to work on this. The definition for signal is:
_ACRTIMP _crt_signal_t __cdecl signal(_In_ int _Signal, _In_opt_ _crt_signal_t _Function);
But it seems _In_opt_ _crt_signal_t is equivalent to void(int)
Edit: I've attempted to do what jmrk suggested. I understand how to make it v8 persistent, but I'm confused on how to wrap it. I've tried using the below wrapper, but it doesn't work.
struct c_api_interface { void (*func_js)(v8::Persistent<v8::Function>);};
template<typename Fn, Fn fn, typename... Args>
typename std::result_of<Fn(Args...)>::type
wrapper(Args... args) {
return fn(std::forward<Args>(args)...);
}
#define WRAPIT(FUNC) wrapper<decltype(&FUNC), &FUNC>
v8::Local<v8::Function> function;
function = v8::Local<v8::Function>::Cast(args[1]);
v8::Persistent<v8::Function> value(isolate, function );
c_api_interface my_interface;
my_interface.func_js = WRAPIT(value);
(void)signal(SIGINT, my_interface.func_js);