MCPcopy Create free account
hub / github.com/antvis/F2Native / Execute

Method Execute

core/android/JavaF2Function.h:20–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 JavaF2Function(ScopedJavaGlobalRef<jobject> *_handle) : func::F2Function(), handle_(_handle) {}
19
20 const std::string Execute(const std::string &functionId, const std::string &param) override {
21 JNIEnv *env = GetJniEnvSafe();
22 if(nExecuteMethod_ == nullptr) {
23 jclass functionClass = env->GetObjectClass(handle_->obj());
24 nExecuteMethod_ = env->GetMethodID(functionClass, "nExecute", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
25 }
26
27 // double check nExecuteMethod_.
28 if(nExecuteMethod_ == nullptr || jni::HasException(env)) {
29 jni::ClearException(env);
30 F2_LOG_E("JavaF2Function", "Get nExecute Method failed. functionId: %s", functionId.data());
31 return "{}";
32 }
33
34 jstring jfunctionId = StringToJString(env, functionId);
35 jstring jparam = StringToJString(env, param);
36 jstring jrst = (jstring)env->CallObjectMethod(handle_->obj(), nExecuteMethod_, jfunctionId, jparam);
37
38 if(jni::HasException(env)) {
39 jni::ClearException(env);
40 F2_LOG_E("JavaF2Function", "execute nExecute Method failed. functionId: %s", functionId.data());
41 return "{}";
42 }
43
44 std::string result = JavaStringToString(env, jrst);
45 jni::ClearException(env);
46 return result;
47 }
48
49 ~JavaF2Function() override {
50 handle_->Reset();

Callers

nothing calls this directly

Calls 6

GetJniEnvSafeFunction · 0.85
HasExceptionFunction · 0.85
ClearExceptionFunction · 0.85
StringToJStringFunction · 0.85
JavaStringToStringFunction · 0.85
objMethod · 0.45

Tested by

no test coverage detected