| 701 | } |
| 702 | |
| 703 | JavaObject javaResultFromPlatformResult(JavaEnv env, const Valdi::PlatformResult& platformResult) { |
| 704 | if (platformResult) { |
| 705 | if (platformResult.value().isNullOrUndefined()) { |
| 706 | // Success with no values are represented as null objects to avoid JNI calls in the good cases. |
| 707 | return JavaObject(env); |
| 708 | } |
| 709 | |
| 710 | auto convertedValue = toJavaObject(env, platformResult.value()); |
| 711 | return JavaEnv::getCache().getValdiResultSuccessMethod().call( |
| 712 | JavaEnv::getCache().getValdiResultClass().getClass(), convertedValue); |
| 713 | } else { |
| 714 | auto convertedError = toJavaObject(env, platformResult.error().getMessage()); |
| 715 | return JavaEnv::getCache().getValdiResultFailureMethod().call( |
| 716 | JavaEnv::getCache().getValdiResultClass().getClass(), convertedError); |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | ValdiContext fromValdiContextUserData(const Valdi::SharedValdiObject& userData) { |
| 721 | return typedJavaObjectFromValdiObject<ValdiContext>(userData, false); |
no test coverage detected