Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make it build on node v12.2.0 #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anton-kotenko
Copy link

No description provided.

Copy link

@ghaiklor ghaiklor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it is ok, but a lot of code that is not cross-platform in terms of V8.
You must use Nan to cover differences in API between different versions of V8.

@@ -7,26 +7,54 @@
using namespace v8;

void init(Local<Object> exports) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::HandleScope handle_scope(isolate);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nan has a helper for these purposes Nan::GetCurrentContext

Nan::New<FunctionTemplate>(verify)->GetFunction());
{
v8::Local<v8::Function> method;
Nan::New<FunctionTemplate>(verify)->GetFunction(context).ToLocal<v8::Function>(&method);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. ToLocal does not check if monad is empty or not. Better to use ToLocalChecked()
  2. It is a little bit stinky, to use lexical scopes for each set.

std::string cert_path = *String::Utf8Value(info[0]->ToString());
std::string ca_bundlestr = *String::Utf8Value(info[1]->ToString());
std::string cert_path = *String::Utf8Value(isolate, info[0]->ToString(isolate));
std::string ca_bundlestr = *String::Utf8Value(isolate, info[1]->ToString(isolate));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get V8 Isolate by Nan::GetCurrentContext()->GetIsolate()

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants