MCPcopy Create free account
hub / github.com/expo/expo / getArray

Method getArray

packages/expo-modules-core/android/src/main/cpp/JavaScriptValue.cpp:189–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189jni::local_ref<jni::JArrayClass<JavaScriptValue::javaobject>> JavaScriptValue::getArray() {
190 auto runtime = runtimeHolder.lock();
191 assert((runtime != nullptr) && "JS Runtime was used after deallocation");
192 auto &rawRuntime = runtime->get();
193 auto jsiContext = expo::getJSIContext(rawRuntime);
194
195 auto jsArray = jsValue
196 ->getObject(rawRuntime)
197 .asArray(rawRuntime);
198 size_t size = jsArray.size(rawRuntime);
199
200 auto result = jni::JArrayClass<JavaScriptValue::javaobject>::newArray(size);
201 for (size_t i = 0; i < size; i++) {
202 auto element = JavaScriptValue::newInstance(
203 jsiContext,
204 runtimeHolder,
205 std::make_shared<jsi::Value>(jsArray.getValueAtIndex(rawRuntime, i))
206 );
207
208 result->setElement(i, element.release());
209 }
210 return result;
211}
212
213jni::local_ref<jstring> JavaScriptValue::jniKind() {
214 auto result = kind();

Calls 8

getJSIContextFunction · 0.85
getMethod · 0.65
sizeMethod · 0.65
assertFunction · 0.50
lockMethod · 0.45
asArrayMethod · 0.45
getObjectMethod · 0.45
releaseMethod · 0.45