| 2200 | auto javaEnv = ValdiAndroid::JavaEnv(); |
| 2201 | auto completionConverted = ValdiAndroid::toValue(javaEnv, ValdiAndroid::JavaEnv::newLocalRef(completion.get())); |
| 2202 | |
| 2203 | if (completionConverted.getFunction() == nullptr) { |
| 2204 | ValdiAndroid::throwJavaValdiException(env, "completion should be a function"); |
| 2205 | return; |
| 2206 | } |
| 2207 | |
| 2208 | runtime->getJavaScriptRuntime()->stopProfiling([=](const auto& result) { |
| 2209 | Valdi::Value content; |
| 2210 | Valdi::Value error; |
| 2211 | if (result) { |
| 2212 | Valdi::ValueArrayBuilder builder; |
| 2213 | for (auto const& item : result.value()) { |
| 2214 | builder.append(Valdi::Value(item)); |
| 2215 | } |
| 2216 | content = Valdi::Value(builder.build()); |
| 2217 | } else { |
| 2218 | content = Valdi::Value(Valdi::ValueArray::make(0)); |
| 2219 | error = Valdi::Value(result.error().toStringBox()); |
| 2220 | } |
| 2221 | (*completionConverted.getFunction())({content, error}); |
| 2222 | }); |
| 2223 | } |
nothing calls this directly
no test coverage detected