Skip to content

Commit

Permalink
[GZNode] Fix compilation errors w/ node 12
Browse files Browse the repository at this point in the history
Several API calls from V8 were deprecated in version 7.0
(that ships w/ node 12), this commit replaces then

Refs:

nodejs/node#23122

nodejs/node#23159

bcoin-org/bcrypto#7
  • Loading branch information
FelipeGdM committed Feb 1, 2021
1 parent d6c06c3 commit 2d38973
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions GZNode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ void GZNode::Init(Local<Object> exports)
{
Isolate* isolate = exports->GetIsolate();
// Prepare constructor template
Local<String> class_name = String::NewFromUtf8(isolate, "GZNode",
NewStringType::kInternalized).ToLocalChecked();

Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
tpl->SetClassName(String::NewFromUtf8(isolate, "GZNode"));

tpl->SetClassName(class_name);
tpl->InstanceTemplate()->SetInternalFieldCount(1);
// Prototype
NODE_SET_PROTOTYPE_METHOD(tpl, "loadMaterialScripts", LoadMaterialScripts);
Expand Down Expand Up @@ -80,8 +84,8 @@ void GZNode::Init(Local<Object> exports)
NODE_SET_PROTOTYPE_METHOD(tpl, "getMaterialScriptsMessage",
GetMaterialScriptsMessage);

exports->Set(String::NewFromUtf8(isolate, "GZNode"),
tpl->GetFunction());
Local<Context> context = isolate->GetCurrentContext();
exports->Set(context, class_name, tpl->GetFunction(context).ToLocalChecked()).Check();
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -116,7 +120,7 @@ void GZNode::LoadMaterialScripts(const FunctionCallbackInfo<Value>& args)

GZNode* obj = ObjectWrap::Unwrap<GZNode>(args.This());

String::Utf8Value path(args[0]->ToString());
String::Utf8Value path(isolate, args[0]);
obj->gzIface->LoadMaterialScripts(std::string(*path));

return;
Expand All @@ -125,8 +129,10 @@ void GZNode::LoadMaterialScripts(const FunctionCallbackInfo<Value>& args)
/////////////////////////////////////////////////
void GZNode::SetConnected(const FunctionCallbackInfo<Value>& args)
{
Isolate* isolate = args.GetIsolate();

GZNode *obj = ObjectWrap::Unwrap<GZNode>(args.This());
bool value = args[0]->BooleanValue();
bool value = args[0]->BooleanValue(isolate);
obj->gzIface->SetConnected(value);

return;
Expand Down Expand Up @@ -160,7 +166,7 @@ void GZNode::GetMaterialScriptsMessage(const FunctionCallbackInfo<Value>& args)
return;
}

String::Utf8Value path(args[0]->ToString());
String::Utf8Value path(isolate, args[0]);

OgreMaterialParser materialParser;
materialParser.Load(std::string(*path));
Expand Down Expand Up @@ -258,7 +264,7 @@ void GZNode::Request(const FunctionCallbackInfo<Value>& args)

GZNode* obj = ObjectWrap::Unwrap<GZNode>(args.This());

String::Utf8Value request(args[0]->ToString());
String::Utf8Value request(isolate, args[0]);
obj->gzIface->PushRequest(std::string(*request));

return;
Expand Down

0 comments on commit 2d38973

Please sign in to comment.