Conversation
gabrielschulhof
left a comment
There was a problem hiding this comment.
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.
@MrKashlakov I don't believe this file should be part of the commit. You should probably remove it.
| #include "iconv.h" | ||
| #include "nan.h" | ||
| #include "napi.h" | ||
| #include "uv.h" |
There was a problem hiding this comment.
@MrKashlakov why do you need "uv.h"?
| #include "nan.h" | ||
| #include "napi.h" | ||
| #include "uv.h" | ||
| #include "node_buffer.h" |
There was a problem hiding this comment.
@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.
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)); |
| using v8::String; | ||
| using v8::Value; | ||
|
|
||
| using namespace Napi; |
There was a problem hiding this comment.
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.
This new empty line is not needed.
| { | ||
| 'target_name': 'iconv', | ||
| 'include_dirs': ['<!(node -e "require(\'nan\')")'], | ||
| 'cflags!': [ '-fno-exceptions' ], |
There was a problem hiding this comment.
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.
... and this needs to be changed to 'NO'.
| 'target_name': 'iconv', | ||
| 'include_dirs': ['<!(node -e "require(\'nan\')")'], | ||
| 'cflags!': [ '-fno-exceptions' ], | ||
| 'cflags_cc!': [ '-fno-exceptions' ], |
There was a problem hiding this comment.
... and cflags_cc! needs to be changed to cflags_cc.
| "readmeFilename": "README.md", | ||
| "dependencies": { | ||
| "nan": "^2.11.1", | ||
| "node-addon-api": "1.6.0", |
There was a problem hiding this comment.
This should be ^1.6.0 so that, when node-addon-api@1.7.0 comes out this package will start using it.
bnoordhuis
left a comment
There was a problem hiding this comment.
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.
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.
Can you use single quotes for consistency?
| }, | ||
| 'msvs_settings': { | ||
| 'VCCLCompilerTool': { 'ExceptionHandling': 1 }, | ||
| }, |
There was a problem hiding this comment.
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.
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.
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!