| 610 | } |
| 611 | |
| 612 | jobjectArray |
| 613 | CallbackHandlers::GetMethodOverrides(JEnv &env, const Local<Object> &implementationObject) { |
| 614 | if (implementationObject.IsEmpty()) { |
| 615 | return CallbackHandlers::GetJavaStringArray(env, 0); |
| 616 | } |
| 617 | |
| 618 | vector<jstring> methodNames; |
| 619 | auto isolate = implementationObject->GetIsolate(); |
| 620 | auto context = implementationObject->CreationContext(); |
| 621 | auto propNames = implementationObject->GetOwnPropertyNames(context).ToLocalChecked(); |
| 622 | for (int i = 0; i < propNames->Length(); i++) { |
| 623 | auto name = propNames->Get(context, i).ToLocalChecked().As<String>(); |
| 624 | if (name->StringEquals(V8StringConstants::GetSuper(isolate))) { |
| 625 | continue; |
| 626 | } |
| 627 | |
| 628 | auto method = implementationObject->Get(context, name).ToLocalChecked(); |
| 629 | |
| 630 | bool methodFound = !method.IsEmpty() && method->IsFunction(); |
| 631 | |
| 632 | if (methodFound) { |
| 633 | String::Utf8Value stringValue(isolate, name); |
| 634 | jstring value = env.NewStringUTF(*stringValue); |
| 635 | methodNames.push_back(value); |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | int methodCount = methodNames.size(); |
| 640 | |
| 641 | jobjectArray methodOverrides = CallbackHandlers::GetJavaStringArray(env, methodCount); |
| 642 | for (int i = 0; i < methodCount; i++) { |
| 643 | env.SetObjectArrayElement(methodOverrides, i, methodNames[i]); |
| 644 | } |
| 645 | |
| 646 | for (int i = 0; i < methodCount; i++) { |
| 647 | env.DeleteLocalRef(methodNames[i]); |
| 648 | } |
| 649 | |
| 650 | return methodOverrides; |
| 651 | } |
| 652 | |
| 653 | void CallbackHandlers::RunOnMainThreadCallback(const FunctionCallbackInfo<v8::Value> &args) { |
| 654 | assert(args[0]->IsFunction()); |
nothing calls this directly
no test coverage detected