@@ -171,15 +171,15 @@ string CallbackHandlers::ResolveClassName(Isolate* isolate, jclass& clazz) {
171
171
return className;
172
172
}
173
173
174
- Local<Value> CallbackHandlers::GetArrayElement (Isolate* isolate , const Local<Object>& array,
174
+ Local<Value> CallbackHandlers::GetArrayElement (Local<Context> context , const Local<Object>& array,
175
175
uint32_t index, const string& arraySignature) {
176
- return arrayElementAccessor.GetArrayElement (isolate , array, index, arraySignature);
176
+ return arrayElementAccessor.GetArrayElement (context , array, index, arraySignature);
177
177
}
178
178
179
- void CallbackHandlers::SetArrayElement (Isolate* isolate , const Local<Object>& array, uint32_t index,
179
+ void CallbackHandlers::SetArrayElement (Local<Context> context , const Local<Object>& array, uint32_t index,
180
180
const string& arraySignature, Local<Value>& value) {
181
181
182
- arrayElementAccessor.SetArrayElement (isolate , array, index, arraySignature, value);
182
+ arrayElementAccessor.SetArrayElement (context , array, index, arraySignature, value);
183
183
}
184
184
185
185
Local<Value> CallbackHandlers::GetJavaField (Isolate* isolate, const Local<Object>& caller,
@@ -568,7 +568,7 @@ CallbackHandlers::GetImplementedInterfaces(JEnv& env, const Local<Object>& imple
568
568
569
569
vector<jstring> interfacesToImplement;
570
570
auto isolate = implementationObject->GetIsolate ();
571
- auto context = isolate-> GetCurrentContext ();
571
+ auto context = implementationObject-> CreationContext ();
572
572
auto propNames = implementationObject->GetOwnPropertyNames (context).ToLocalChecked ();
573
573
for (int i = 0 ; i < propNames->Length (); i++) {
574
574
auto name = propNames->Get (context, i).ToLocalChecked ().As <String>();
@@ -582,7 +582,6 @@ CallbackHandlers::GetImplementedInterfaces(JEnv& env, const Local<Object>& imple
582
582
if (arrNameC == " interfaces" ) {
583
583
auto interfacesArr = prop->ToObject (context).ToLocalChecked ();
584
584
585
- auto context = isolate->GetCurrentContext ();
586
585
int length = interfacesArr->Get (
587
586
context,
588
587
v8::String::NewFromUtf8 (isolate, " length" ).ToLocalChecked ()).ToLocalChecked ()->ToObject (context).ToLocalChecked ()->Uint32Value (
@@ -628,7 +627,7 @@ CallbackHandlers::GetMethodOverrides(JEnv& env, const Local<Object>& implementat
628
627
629
628
vector<jstring> methodNames;
630
629
auto isolate = implementationObject->GetIsolate ();
631
- auto context = isolate-> GetCurrentContext ();
630
+ auto context = implementationObject-> CreationContext ();
632
631
auto propNames = implementationObject->GetOwnPropertyNames (context).ToLocalChecked ();
633
632
for (int i = 0 ; i < propNames->Length (); i++) {
634
633
auto name = propNames->Get (context, i).ToLocalChecked ().As <String>();
@@ -833,7 +832,7 @@ Local<Value> CallbackHandlers::CallJSMethod(Isolate* isolate, JNIEnv* _env,
833
832
JEnv env (_env);
834
833
Local<Value> result;
835
834
836
- auto context = isolate-> GetCurrentContext ();
835
+ auto context = Runtime::GetRuntime ( isolate)-> GetContext ();
837
836
auto method = jsObject->Get (context, ArgConverter::ConvertToV8String (isolate, methodName)).ToLocalChecked ();
838
837
839
838
if (method.IsEmpty () || method->IsUndefined ()) {
@@ -848,16 +847,14 @@ Local<Value> CallbackHandlers::CallJSMethod(Isolate* isolate, JNIEnv* _env,
848
847
EscapableHandleScope handleScope (isolate);
849
848
850
849
auto jsMethod = method.As <Function>();
851
- auto jsArgs = ArgConverter::ConvertJavaArgsToJsArgs (isolate , args);
850
+ auto jsArgs = ArgConverter::ConvertJavaArgsToJsArgs (context , args);
852
851
int argc = jsArgs->Length ();
853
852
854
853
std::vector<Local<Value>> arguments (argc);
855
854
for (int i = 0 ; i < argc; i++) {
856
855
arguments[i] = jsArgs->Get (context, i).ToLocalChecked ();
857
856
}
858
857
859
- auto context = isolate->GetCurrentContext ();
860
-
861
858
TryCatch tc (isolate);
862
859
Local<Value> jsResult;
863
860
{
@@ -1160,12 +1157,11 @@ CallbackHandlers::WorkerObjectOnMessageCallback(Isolate* isolate, jint workerId,
1160
1157
1161
1158
if (!isEmpty && isFunction) {
1162
1159
auto msgString = ArgConverter::jstringToV8String (isolate, message).As <String>();
1163
- auto context = isolate->GetCurrentContext ();
1164
1160
Local<Value> msg;
1165
1161
JSON::Parse (context, msgString).ToLocal (&msg);
1166
1162
1167
1163
auto obj = Object::New (isolate);
1168
- obj->DefineOwnProperty (isolate-> GetCurrentContext () ,
1164
+ obj->DefineOwnProperty (context ,
1169
1165
ArgConverter::ConvertToV8String (isolate, " data" ), msg,
1170
1166
PropertyAttribute::ReadOnly);
1171
1167
Local<Value> args1[] = {obj};
@@ -1430,8 +1426,6 @@ CallbackHandlers::CallWorkerObjectOnErrorHandle(Isolate* isolate, jint workerId,
1430
1426
1431
1427
auto func = callback.As <Function>();
1432
1428
1433
- auto context = isolate->GetCurrentContext ();
1434
-
1435
1429
// Handle exceptions thrown in onmessage with the worker.onerror handler, if present
1436
1430
Local<Value> result;
1437
1431
func->Call (context, Undefined (isolate), 1 , args1).ToLocal (&result);
@@ -1490,9 +1484,6 @@ void CallbackHandlers::ClearWorkerPersistent(int workerId) {
1490
1484
}
1491
1485
1492
1486
void CallbackHandlers::TerminateWorkerThread (Isolate* isolate) {
1493
- auto context = isolate->GetCurrentContext ();
1494
- context->Exit ();
1495
-
1496
1487
isolate->TerminateExecution ();
1497
1488
}
1498
1489
0 commit comments