pmed / v8pp

Bind C++ functions and classes into V8 JavaScript engine
http://pmed.github.io/v8pp/
Other
886 stars 118 forks source link

Is there a way to forward FunctionCallbackInfo to template<class... Args> #179

Closed greergan closed 2 years ago

greergan commented 2 years ago

Hello and thank you for this library. Is there a way to transform

void _notice(const v8::FunctionCallbackInfo<v8::Value> &args) {
    notice(args);
}

To use the following function call

template<class... Args>
void notice(Args... args) {
    _base_log_info* log_info = new _base_log_info("NOTICE", args...);
    log_info->request.data = (void*) log_info;
    log_info->priority = LOG_NOTICE;
    log_info->options = log_info->options | LOG_PERROR;
    uv_queue_work(log_loop, &log_info->request, write_syslog, done_write_syslog);
 }

Thank you very much for your answer.

pmed commented 2 years ago

Hi,

One possible way could be to convert the v8::FunctionCallbackInfo<v8::Value> arguments to a tuple, and to store it inside of the _base_log_info

greergan commented 2 years ago

Thank you.