-
Notifications
You must be signed in to change notification settings - Fork 457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Porting FunctionTemplate to N-API #92
Comments
Templates are a V8-specific concept. There is no equivalent in N-API. Just create a
|
That is a very common pattern everywhere in native module authoring. It's definitely not clear how to port something like https://github.com/mcollina/native-hdr-histogram/blob/master/hdr_histogram_wrap.cc#L12-L28.
The |
FunctionTemplate is definitely something that we make fairly extensive use of within core so it's likely going to need to be something N-API supports at some point. Having a |
Currently I was able to port it to: Napi::Function tpl = Napi::Function::New(env, HdrHistogramWrap::New, "HdrHistogram"); Not sure if it's correct, but I was able to move on to the next build error. |
This is where we need a conversion guide. The code you linked is defining a class with a bunch of methods. For that, you should definitely use |
We've converted a lot of code so far (which has used |
Maybe not. There's a common pattern where a |
Ok, then yeah, I think a conversion guide is definitely needed :-) It appears the case is covered, it's just not immediately clear how. Great work and thank you for the patience as we feel our way around |
@mcollina just following up to see if there is still an open question here or you have the info you needed to do the conversion. |
I think we can close this issue. We have the guide at https://github.com/nodejs/node-addon-api/tree/master/tools. |
How do I port
FunctionTemplate
to N-API?This is the best I could do be
But it still did not work.
The text was updated successfully, but these errors were encountered: