Skip to content

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.

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants