-
Notifications
You must be signed in to change notification settings - Fork 123
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
Migration to N-API #189
base: master
Are you sure you want to change the base?
Migration to N-API #189
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! I'm glad you were able to address the test failures after our N-API workshop 👍
@@ -0,0 +1,18 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MrKashlakov I don't believe this file should be part of the commit. You should probably remove it.
@@ -15,7 +15,8 @@ | |||
*/ | |||
|
|||
#include "iconv.h" | |||
#include "nan.h" | |||
#include "napi.h" | |||
#include "uv.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MrKashlakov why do you need "uv.h"
?
@@ -15,7 +15,8 @@ | |||
*/ | |||
|
|||
#include "iconv.h" | |||
#include "nan.h" | |||
#include "napi.h" | |||
#include "uv.h" | |||
#include "node_buffer.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MrKashlakov I believe you can remove this include, because node-addon-api provides access to node::Buffer
via N-API.
Nan::New<FunctionTemplate>(Convert)->GetFunction()); | ||
Iconv::Init(env); | ||
exports.Set(Napi::String::New(env, "make"), | ||
Napi::Function::New(env, Make)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be indented so the Napi::...
is in the same column as the line above.
exports.Set(Napi::String::New(env, "make"), | ||
Napi::Function::New(env, Make)); | ||
exports.Set(Napi::String::New(env, "convert"), | ||
Napi::Function::New(env, Convert)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here wrt. indentation.
|
||
using namespace Napi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't actually need this line, because the code uses Napi::...
explicitly everywhere – which is good.
} | ||
|
||
// Forbid implicit copying. | ||
Iconv(const Iconv&); | ||
void operator=(const Iconv&); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new empty line is not needed.
@@ -6,7 +6,24 @@ | |||
'targets': [ | |||
{ | |||
'target_name': 'iconv', | |||
'include_dirs': ['<!(node -e "require(\'nan\')")'], | |||
'cflags!': [ '-fno-exceptions' ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original version of node-iconv made sure there were no CPP exceptions. Thus, we should maintain that choice. This means that cflags!
needs to be changed to cflags
.
'cflags!': [ '-fno-exceptions' ], | ||
'cflags_cc!': [ '-fno-exceptions' ], | ||
'xcode_settings': { | ||
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and this needs to be changed to 'NO'
.
@@ -6,7 +6,24 @@ | |||
'targets': [ | |||
{ | |||
'target_name': 'iconv', | |||
'include_dirs': ['<!(node -e "require(\'nan\')")'], | |||
'cflags!': [ '-fno-exceptions' ], | |||
'cflags_cc!': [ '-fno-exceptions' ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and cflags_cc!
needs to be changed to cflags_cc
.
@@ -18,7 +18,7 @@ | |||
"license": "ISC", | |||
"readmeFilename": "README.md", | |||
"dependencies": { | |||
"nan": "^2.11.1", | |||
"node-addon-api": "1.6.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be ^1.6.0
so that, when node-addon-api@1.7.0 comes out this package will start using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, left some comments but mostly LGTM. I'll second Gabriel's comments.
'cflags_cc!': [ '-fno-exceptions' ], | ||
'xcode_settings': { | ||
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', | ||
'CLANG_CXX_LIBRARY': 'libc++', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this? It's incompatible with Node.js v6.x. node-iconv can just inherit it from node's common.gypi.
'support' | ||
], | ||
'dependencies': [ | ||
"<!(node -p \"require('node-addon-api').gyp\")"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use single quotes for consistency?
}, | ||
'msvs_settings': { | ||
'VCCLCompilerTool': { 'ExceptionHandling': 1 }, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block should be removed.
Napi::ObjectWrap<Iconv>(info) { | ||
conv_ = info[0].As<Napi::External<iconv_t>>().Data(); | ||
} | ||
iconv_t conv_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation, and can you move conv_
back to its old place again? Cheers.
size_t input_size = info[3].IsNumber() ? info[3].As<Napi::Number>().Uint32Value() : static_cast<uint32_t>(0); | ||
char* output_buf = info[4].As<Napi::Buffer<char>>().Data(); | ||
size_t output_start = info[5].IsNumber() ? info[5].As<Napi::Number>().Uint32Value() : static_cast<uint32_t>(0); | ||
size_t output_size = info[6].IsNumber() ? info[6].As<Napi::Number>().Uint32Value() : static_cast<uint32_t>(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the ternaries? The JS layer always passes up numbers.
@bnoordhuis is this something you'd be able to review/consider landing? |
Just confirming you are waiting on responses to your comments and once they are addressed it might move forward as we are are talking about whether we need to find somebody else to take over the pr. @MrKashlakov are you going to be able to get back to this in order to address the comments. |
That's correct. This PR also needs a rebase now. |
Hi @MrKashlakov I hope that you have the time to finish this work, but in case if you are busy what do you think if I help you to accomplish at tasks requested in this PR? |
Hello!
I just did migration of this module to N-API. Please review this PR.
All tests passed!