@@ -51,8 +51,12 @@ void GZNode::Init(Local<Object> exports)
51
51
{
52
52
Isolate* isolate = exports->GetIsolate ();
53
53
// Prepare constructor template
54
+ Local<String> class_name = String::NewFromUtf8 (isolate, " GZNode" ,
55
+ NewStringType::kInternalized ).ToLocalChecked ();
56
+
54
57
Local<FunctionTemplate> tpl = FunctionTemplate::New (isolate, New);
55
- tpl->SetClassName (String::NewFromUtf8 (isolate, " GZNode" ));
58
+
59
+ tpl->SetClassName (class_name);
56
60
tpl->InstanceTemplate ()->SetInternalFieldCount (1 );
57
61
// Prototype
58
62
NODE_SET_PROTOTYPE_METHOD (tpl, " loadMaterialScripts" , LoadMaterialScripts);
@@ -80,8 +84,8 @@ void GZNode::Init(Local<Object> exports)
80
84
NODE_SET_PROTOTYPE_METHOD (tpl, " getMaterialScriptsMessage" ,
81
85
GetMaterialScriptsMessage);
82
86
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 ( );
85
89
}
86
90
87
91
// ///////////////////////////////////////////////
@@ -116,7 +120,7 @@ void GZNode::LoadMaterialScripts(const FunctionCallbackInfo<Value>& args)
116
120
117
121
GZNode* obj = ObjectWrap::Unwrap<GZNode>(args.This ());
118
122
119
- String::Utf8Value path (args[0 ]-> ToString () );
123
+ String::Utf8Value path (isolate, args[0 ]);
120
124
obj->gzIface ->LoadMaterialScripts (std::string (*path));
121
125
122
126
return ;
@@ -125,8 +129,10 @@ void GZNode::LoadMaterialScripts(const FunctionCallbackInfo<Value>& args)
125
129
// ///////////////////////////////////////////////
126
130
void GZNode::SetConnected (const FunctionCallbackInfo<Value>& args)
127
131
{
132
+ Isolate* isolate = args.GetIsolate ();
133
+
128
134
GZNode *obj = ObjectWrap::Unwrap<GZNode>(args.This ());
129
- bool value = args[0 ]->BooleanValue ();
135
+ bool value = args[0 ]->BooleanValue (isolate );
130
136
obj->gzIface ->SetConnected (value);
131
137
132
138
return ;
@@ -160,7 +166,7 @@ void GZNode::GetMaterialScriptsMessage(const FunctionCallbackInfo<Value>& args)
160
166
return ;
161
167
}
162
168
163
- String::Utf8Value path (args[0 ]-> ToString () );
169
+ String::Utf8Value path (isolate, args[0 ]);
164
170
165
171
OgreMaterialParser materialParser;
166
172
materialParser.Load (std::string (*path));
@@ -258,7 +264,7 @@ void GZNode::Request(const FunctionCallbackInfo<Value>& args)
258
264
259
265
GZNode* obj = ObjectWrap::Unwrap<GZNode>(args.This ());
260
266
261
- String::Utf8Value request (args[0 ]-> ToString () );
267
+ String::Utf8Value request (isolate, args[0 ]);
262
268
obj->gzIface ->PushRequest (std::string (*request));
263
269
264
270
return ;
0 commit comments