@@ -291,29 +291,10 @@ class JSCRuntime : public jsi::Runtime {
291291 } while (0 )
292292
293293#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
294- // This takes care of watch and tvos (due to backwards compatibility in
295- // Availability.h
296- #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0
297- #define _JSC_FAST_IS_ARRAY
298- #endif
299- #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0
300- #define _JSC_NO_ARRAY_BUFFERS
301- #endif
302294#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160400
303295#define _JSC_HAS_INSPECTABLE
304296#endif
305297#endif
306- #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
307- #if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_11
308- // Only one of these should be set for a build. If somehow that's not
309- // true, this will be a compile-time error and it can be resolved when
310- // we understand why.
311- #define _JSC_FAST_IS_ARRAY
312- #endif
313- #if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12
314- #define _JSC_NO_ARRAY_BUFFERS
315- #endif
316- #endif
317298
318299// JSStringRef utilities
319300namespace {
@@ -361,18 +342,6 @@ JSStringRef getFunctionString() {
361342 static JSStringRef func = JSStringCreateWithUTF8CString (" Function" );
362343 return func;
363344}
364-
365- #if !defined(_JSC_FAST_IS_ARRAY)
366- JSStringRef getArrayString () {
367- static JSStringRef array = JSStringCreateWithUTF8CString (" Array" );
368- return array;
369- }
370-
371- JSStringRef getIsArrayString () {
372- static JSStringRef isArray = JSStringCreateWithUTF8CString (" isArray" );
373- return isArray;
374- }
375- #endif
376345} // namespace
377346
378347// std::string utility
@@ -988,55 +957,21 @@ void JSCRuntime::setPropertyValue(
988957}
989958
990959bool JSCRuntime::isArray (const jsi::Object& obj) const {
991- #if !defined(_JSC_FAST_IS_ARRAY)
992- JSObjectRef global = JSContextGetGlobalObject (ctx_);
993- JSStringRef arrayString = getArrayString ();
994- JSValueRef exc = nullptr ;
995- JSValueRef arrayCtorValue =
996- JSObjectGetProperty (ctx_, global, arrayString, &exc);
997- JSC_ASSERT (exc);
998- JSObjectRef arrayCtor = JSValueToObject (ctx_, arrayCtorValue, &exc);
999- JSC_ASSERT (exc);
1000- JSStringRef isArrayString = getIsArrayString ();
1001- JSValueRef isArrayValue =
1002- JSObjectGetProperty (ctx_, arrayCtor, isArrayString, &exc);
1003- JSC_ASSERT (exc);
1004- JSObjectRef isArray = JSValueToObject (ctx_, isArrayValue, &exc);
1005- JSC_ASSERT (exc);
1006- JSValueRef arg = objectRef (obj);
1007- JSValueRef result =
1008- JSObjectCallAsFunction (ctx_, isArray, nullptr , 1 , &arg, &exc);
1009- JSC_ASSERT (exc);
1010- return JSValueToBoolean (ctx_, result);
1011- #else
1012960 return JSValueIsArray (ctx_, objectRef (obj));
1013- #endif
1014961}
1015962
1016963bool JSCRuntime::isArrayBuffer (const jsi::Object& obj) const {
1017- #if defined(_JSC_NO_ARRAY_BUFFERS)
1018- throw std::runtime_error (" Unsupported" );
1019- #else
1020964 auto typedArrayType = JSValueGetTypedArrayType (ctx_, objectRef (obj), nullptr );
1021965 return typedArrayType == kJSTypedArrayTypeArrayBuffer ;
1022- #endif
1023966}
1024967
1025968uint8_t * JSCRuntime::data (const jsi::ArrayBuffer& obj) {
1026- #if defined(_JSC_NO_ARRAY_BUFFERS)
1027- throw std::runtime_error (" Unsupported" );
1028- #else
1029969 return static_cast <uint8_t *>(
1030970 JSObjectGetArrayBufferBytesPtr (ctx_, objectRef (obj), nullptr ));
1031- #endif
1032971}
1033972
1034973size_t JSCRuntime::size (const jsi::ArrayBuffer& obj) {
1035- #if defined(_JSC_NO_ARRAY_BUFFERS)
1036- throw std::runtime_error (" Unsupported" );
1037- #else
1038974 return JSObjectGetArrayBufferByteLength (ctx_, objectRef (obj), nullptr );
1039- #endif
1040975}
1041976
1042977bool JSCRuntime::isFunction (const jsi::Object& obj) const {
0 commit comments