MCPcopy Create free account
hub / github.com/Snapchat/Valdi / javaResultFromPlatformResult

Function javaResultFromPlatformResult

valdi_core/src/valdi_core/jni/JavaUtils.cpp:703–718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

701 }
702
703 auto isSuccess = JavaEnv::getCache().getValdiResultIsSuccessMethod().call(javaResult);
704 if (isSuccess) {
705 auto successValue = JavaEnv::getCache().getValdiResultGetSuccessValueMethod().call(javaResult);
706 return toValue(env, successValue.stealLocalRef());
707 } else {
708 auto errorMessage = JavaEnv::getCache().getValdiResultGetErrorMessageMethod().call(javaResult);
709 return Valdi::Error(toInternedString(env, errorMessage));
710 }
711}
712
713JavaObject javaResultFromPlatformResult(JavaEnv env, const Valdi::PlatformResult& platformResult) {
714 if (platformResult) {
715 if (platformResult.value().isNullOrUndefined()) {
716 // Success with no values are represented as null objects to avoid JNI calls in the good cases.
717 return JavaObject(env);
718 }
719
720 auto convertedValue = toJavaObject(env, platformResult.value());
721 return JavaEnv::getCache().getValdiResultSuccessMethod().call(

Callers 1

fromCppMethod · 0.85

Calls 8

toJavaObjectFunction · 0.85
JavaObjectClass · 0.70
valueMethod · 0.65
callMethod · 0.65
getMessageMethod · 0.65
errorMethod · 0.65
isNullOrUndefinedMethod · 0.45
getClassMethod · 0.45

Tested by

no test coverage detected