@@ -276,6 +276,9 @@ class JSCRuntime : public jsi::Runtime {
276276#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0
277277#define _JSC_FAST_IS_ARRAY
278278#endif
279+ #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0
280+ #define _JSC_NO_ARRAY_BUFFERS
281+ #endif
279282#endif
280283#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
281284#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_11
@@ -284,6 +287,9 @@ class JSCRuntime : public jsi::Runtime {
284287// we understand why.
285288#define _JSC_FAST_IS_ARRAY
286289#endif
290+ #if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12
291+ #define _JSC_NO_ARRAY_BUFFERS
292+ #endif
287293#endif
288294
289295// JSStringRef utilities
@@ -922,24 +928,30 @@ bool JSCRuntime::isArray(const jsi::Object &obj) const {
922928#endif
923929}
924930
925- bool JSCRuntime::isArrayBuffer (const jsi::Object & /* obj*/ ) const {
926- // TODO: T23270523 - This would fail on builds that use our custom JSC
927- // auto typedArrayType = JSValueGetTypedArrayType(ctx_, objectRef(obj),
928- // nullptr); return typedArrayType == kJSTypedArrayTypeArrayBuffer;
931+ bool JSCRuntime::isArrayBuffer (const jsi::Object &obj) const {
932+ #if defined(_JSC_NO_ARRAY_BUFFERS)
929933 throw std::runtime_error (" Unsupported" );
934+ #else
935+ auto typedArrayType = JSValueGetTypedArrayType (ctx_, objectRef (obj), nullptr );
936+ return typedArrayType == kJSTypedArrayTypeArrayBuffer ;
937+ #endif
930938}
931939
932- uint8_t *JSCRuntime::data (const jsi::ArrayBuffer & /* obj*/ ) {
933- // TODO: T23270523 - This would fail on builds that use our custom JSC
934- // return static_cast<uint8_t*>(
935- // JSObjectGetArrayBufferBytesPtr(ctx_, objectRef(obj), nullptr));
940+ uint8_t *JSCRuntime::data (const jsi::ArrayBuffer &obj) {
941+ #if defined(_JSC_NO_ARRAY_BUFFERS)
936942 throw std::runtime_error (" Unsupported" );
943+ #else
944+ return static_cast <uint8_t *>(
945+ JSObjectGetArrayBufferBytesPtr (ctx_, objectRef (obj), nullptr ));
946+ #endif
937947}
938948
939- size_t JSCRuntime::size (const jsi::ArrayBuffer & /* obj*/ ) {
940- // TODO: T23270523 - This would fail on builds that use our custom JSC
941- // return JSObjectGetArrayBufferByteLength(ctx_, objectRef(obj), nullptr);
949+ size_t JSCRuntime::size (const jsi::ArrayBuffer &obj) {
950+ #if defined(_JSC_NO_ARRAY_BUFFERS)
942951 throw std::runtime_error (" Unsupported" );
952+ #else
953+ return JSObjectGetArrayBufferByteLength (ctx_, objectRef (obj), nullptr );
954+ #endif
943955}
944956
945957bool JSCRuntime::isFunction (const jsi::Object &obj) const {
0 commit comments