iOS: fix add version judgment for JSTypedArray API

This commit is contained in:
pengfei.zhou 2022-07-15 16:02:22 +08:00 committed by osborn
parent 7a126531af
commit e6bdc3d819

View File

@ -123,6 +123,7 @@ static id containerValueToObject(JSGlobalContextRef context, JSContainerConverto
} }
JSObjectRef object = JSValueToObject(context, value, 0); JSObjectRef object = JSValueToObject(context, value, 0);
if (@available(iOS 10.0, *)) {
JSTypedArrayType type = JSValueGetTypedArrayType(context, value, NULL); JSTypedArrayType type = JSValueGetTypedArrayType(context, value, NULL);
if (type == kJSTypedArrayTypeArrayBuffer) { if (type == kJSTypedArrayTypeArrayBuffer) {
size_t size = JSObjectGetArrayBufferByteLength(context, object, NULL); size_t size = JSObjectGetArrayBufferByteLength(context, object, NULL);
@ -130,6 +131,7 @@ static id containerValueToObject(JSGlobalContextRef context, JSContainerConverto
id primitive = [[NSData alloc] initWithBytesNoCopy:ptr length:size freeWhenDone:NO]; id primitive = [[NSData alloc] initWithBytesNoCopy:ptr length:size freeWhenDone:NO];
return {value, primitive, ContainerNone}; return {value, primitive, ContainerNone};
} }
}
if (JSValueIsArray(context, value)) if (JSValueIsArray(context, value))
return {object, [NSMutableArray array], ContainerArray}; return {object, [NSMutableArray array], ContainerArray};