@@ -92,16 +92,25 @@ extern "C" {
92
92
Local<Context> context = globalContext->Get (isolate);
93
93
Context::Scope context_scope (context);
94
94
Local<String> source = String::NewFromUtf8 (isolate, scriptPtr);
95
- Local<Script> script = Script::Compile (source);
96
- Local<Value> result = script->Run ();
95
+ MaybeLocal<Script> maybeScript = Script::Compile (context, source);
96
+
97
+ if (maybeScript.IsEmpty ()) {
98
+ if (exception != nullptr ) {
99
+ *exception = new Global<Value>(isolate, trycatch.Exception ());
100
+ }
101
+ return nullptr ;
102
+ }
103
+
104
+ Local<Script> script = maybeScript.ToLocalChecked ();
105
+ MaybeLocal<Value> result = script->Run (context);
97
106
98
107
if (result.IsEmpty ()) {
99
108
if (exception != nullptr ) {
100
109
*exception = new Global<Value>(isolate, trycatch.Exception ());
101
110
}
102
111
return nullptr ;
103
112
}
104
- return new Global<Value>(isolate, result);
113
+ return new Global<Value>(isolate, result. ToLocalChecked () );
105
114
}
106
115
107
116
void disposeValue (void * pointer) {
@@ -113,15 +122,17 @@ extern "C" {
113
122
return scoped->ToInteger ()->IntegerValue ();
114
123
}
115
124
116
- int getUtf8StringLength (void * isolate, void * value) {
125
+ int getUtf8StringLength (void * isolatePtr, void * value) {
126
+ auto isolate = reinterpret_cast <Isolate*>(isolatePtr);
117
127
GlobalValue scoped (isolate, value);
118
- String::Utf8Value utf8 (*scoped);
128
+ String::Utf8Value utf8 (isolate, *scoped);
119
129
return utf8.length ();
120
130
}
121
131
122
- void copyUtf8String (void * isolate, void * value, void * buffer, int count) {
132
+ void copyUtf8String (void * isolatePtr, void * value, void * buffer, int count) {
133
+ auto isolate = reinterpret_cast <Isolate*>(isolatePtr);
123
134
GlobalValue scoped (isolate, value);
124
- String::Utf8Value utf8 (*scoped);
135
+ String::Utf8Value utf8 (isolate, *scoped);
125
136
memcpy (buffer, *utf8, count);
126
137
}
127
138
0 commit comments