@@ -92,16 +92,25 @@ extern "C" {
9292 Local<Context> context = globalContext->Get (isolate);
9393 Context::Scope context_scope (context);
9494 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);
97106
98107 if (result.IsEmpty ()) {
99108 if (exception != nullptr ) {
100109 *exception = new Global<Value>(isolate, trycatch.Exception ());
101110 }
102111 return nullptr ;
103112 }
104- return new Global<Value>(isolate, result);
113+ return new Global<Value>(isolate, result. ToLocalChecked () );
105114 }
106115
107116 void disposeValue (void * pointer) {
@@ -113,15 +122,17 @@ extern "C" {
113122 return scoped->ToInteger ()->IntegerValue ();
114123 }
115124
116- int getUtf8StringLength (void * isolate, void * value) {
125+ int getUtf8StringLength (void * isolatePtr, void * value) {
126+ auto isolate = reinterpret_cast <Isolate*>(isolatePtr);
117127 GlobalValue scoped (isolate, value);
118- String::Utf8Value utf8 (*scoped);
128+ String::Utf8Value utf8 (isolate, *scoped);
119129 return utf8.length ();
120130 }
121131
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);
123134 GlobalValue scoped (isolate, value);
124- String::Utf8Value utf8 (*scoped);
135+ String::Utf8Value utf8 (isolate, *scoped);
125136 memcpy (buffer, *utf8, count);
126137 }
127138
0 commit comments