MCPcopy Create free account
hub / github.com/NativeScript/android / GetMethodOverrides

Method GetMethodOverrides

test-app/runtime/src/main/cpp/CallbackHandlers.cpp:612–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610}
611
612jobjectArray
613CallbackHandlers::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
653void CallbackHandlers::RunOnMainThreadCallback(const FunctionCallbackInfo<v8::Value> &args) {
654 assert(args[0]->IsFunction());

Callers

nothing calls this directly

Calls 9

ToLocalCheckedMethod · 0.80
NewStringUTFMethod · 0.80
SetObjectArrayElementMethod · 0.80
DeleteLocalRefMethod · 0.80
IsEmptyMethod · 0.45
GetIsolateMethod · 0.45
LengthMethod · 0.45
GetMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected