Skip to content

Commit 6d926df

Browse files
committed
[GZNode] Fix compilation errors w/ node 12
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
1 parent d58203c commit 6d926df

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

gzbridge/GZNode.cc

+13-7
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ void GZNode::Init(Local<Object> exports)
5151
{
5252
Isolate* isolate = exports->GetIsolate();
5353
// Prepare constructor template
54+
Local<String> class_name = String::NewFromUtf8(isolate, "GZNode",
55+
NewStringType::kInternalized).ToLocalChecked();
56+
5457
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
55-
tpl->SetClassName(String::NewFromUtf8(isolate, "GZNode"));
58+
59+
tpl->SetClassName(class_name);
5660
tpl->InstanceTemplate()->SetInternalFieldCount(1);
5761
// Prototype
5862
NODE_SET_PROTOTYPE_METHOD(tpl, "loadMaterialScripts", LoadMaterialScripts);
@@ -80,8 +84,8 @@ void GZNode::Init(Local<Object> exports)
8084
NODE_SET_PROTOTYPE_METHOD(tpl, "getMaterialScriptsMessage",
8185
GetMaterialScriptsMessage);
8286

83-
exports->Set(String::NewFromUtf8(isolate, "GZNode"),
84-
tpl->GetFunction());
87+
Local<Context> context = isolate->GetCurrentContext();
88+
exports->Set(context, class_name, tpl->GetFunction(context).ToLocalChecked()).Check();
8589
}
8690

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

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

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

122126
return;
@@ -125,8 +129,10 @@ void GZNode::LoadMaterialScripts(const FunctionCallbackInfo<Value>& args)
125129
/////////////////////////////////////////////////
126130
void GZNode::SetConnected(const FunctionCallbackInfo<Value>& args)
127131
{
132+
Isolate* isolate = args.GetIsolate();
133+
128134
GZNode *obj = ObjectWrap::Unwrap<GZNode>(args.This());
129-
bool value = args[0]->BooleanValue();
135+
bool value = args[0]->BooleanValue(isolate);
130136
obj->gzIface->SetConnected(value);
131137

132138
return;
@@ -160,7 +166,7 @@ void GZNode::GetMaterialScriptsMessage(const FunctionCallbackInfo<Value>& args)
160166
return;
161167
}
162168

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

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

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

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

264270
return;

0 commit comments

Comments
 (0)