Bindings for JSTypedArray.h (typed arrays + array buffers).
The JSTypedArrayType enum itself lives in jsvalueref (as in C, where it is declared in JSValueRef.h). Everything here is macOS 10.12+.
Procs
proc JSObjectGetArrayBufferByteLength(ctx: JSContextRef; obj: JSObjectRef; exception: ptr JSValueRef): csize_t {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
proc JSObjectGetArrayBufferBytesPtr(ctx: JSContextRef; obj: JSObjectRef; exception: ptr JSValueRef): pointer {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
- Temporary pointer. Nil unless obj is an ArrayBuffer.
proc JSObjectGetTypedArrayBuffer(ctx: JSContextRef; obj: JSObjectRef; exception: ptr JSValueRef): JSObjectRef {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
- Backing ArrayBuffer, or nil.
proc JSObjectGetTypedArrayByteLength(ctx: JSContextRef; obj: JSObjectRef; exception: ptr JSValueRef): csize_t {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
proc JSObjectGetTypedArrayByteOffset(ctx: JSContextRef; obj: JSObjectRef; exception: ptr JSValueRef): csize_t {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
proc JSObjectGetTypedArrayBytesPtr(ctx: JSContextRef; obj: JSObjectRef; exception: ptr JSValueRef): pointer {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
- Temporary pointer; may not survive further JS API calls. Nil unless obj is a typed array.
proc JSObjectGetTypedArrayLength(ctx: JSContextRef; obj: JSObjectRef; exception: ptr JSValueRef): csize_t {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
- Element count, or 0.
proc JSObjectMakeArrayBufferWithBytesNoCopy(ctx: JSContextRef; bytes: pointer; byteLength: csize_t; bytesDeallocator: JSTypedArrayBytesDeallocator; deallocatorContext: pointer; exception: ptr JSValueRef): JSObjectRef {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
- Takes over bytes; the deallocator always runs, even on failure.
proc JSObjectMakeTypedArray(ctx: JSContextRef; arrayType: JSTypedArrayType; length: csize_t; exception: ptr JSValueRef): JSObjectRef {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
- Zero-filled. Nil for None/ArrayBuffer types or on error.
proc JSObjectMakeTypedArrayWithArrayBuffer(ctx: JSContextRef; arrayType: JSTypedArrayType; buffer: JSObjectRef; exception: ptr JSValueRef): JSObjectRef {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
proc JSObjectMakeTypedArrayWithArrayBufferAndOffset(ctx: JSContextRef; arrayType: JSTypedArrayType; buffer: JSObjectRef; byteOffset: csize_t; length: csize_t; exception: ptr JSValueRef): JSObjectRef {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
proc JSObjectMakeTypedArrayWithBytesNoCopy(ctx: JSContextRef; arrayType: JSTypedArrayType; bytes: pointer; byteLength: csize_t; bytesDeallocator: JSTypedArrayBytesDeallocator; deallocatorContext: pointer; exception: ptr JSValueRef): JSObjectRef {. header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [], tags: [], forbids: [].}
- Takes over bytes; the deallocator always runs, even on failure.
Exports
-
JSCheckScriptSyntax, JSClassRef, JSContextGroupRef, JSContextRef, JSEvaluateScript, JSGarbageCollect, JSGlobalContextRef, JSObjectRef, JSPropertyNameAccumulatorRef, JSPropertyNameArrayRef, JSStringRef, JSTypedArrayBytesDeallocator, JSValueRef, OpaqueJSClass, OpaqueJSContext, OpaqueJSContextGroup, OpaqueJSPropertyNameAccumulator, OpaqueJSPropertyNameArray, OpaqueJSString, OpaqueJSValue, jscHeader, JSBigIntCreateWithDouble, JSBigIntCreateWithInt64, JSBigIntCreateWithString, JSBigIntCreateWithUInt64, JSCheckScriptSyntax, JSClassRef, JSContextGroupRef, JSContextRef, JSEvaluateScript, JSGarbageCollect, JSGlobalContextRef, JSObjectRef, JSPropertyNameAccumulatorRef, JSPropertyNameArrayRef, JSRelationCondition, JSStringRef, JSType, JSTypedArrayBytesDeallocator, JSTypedArrayType, JSValueCompare, JSValueCompareDouble, JSValueCompareInt64, JSValueCompareUInt64, JSValueCreateJSONString, JSValueGetType, JSValueGetTypedArrayType, JSValueIsArray, JSValueIsBigInt, JSValueIsBoolean, JSValueIsDate, JSValueIsEqual, JSValueIsInstanceOfConstructor, JSValueIsNull, JSValueIsNumber, JSValueIsObject, JSValueIsObjectOfClass, JSValueIsStrictEqual, JSValueIsString, JSValueIsSymbol, JSValueIsUndefined, JSValueMakeBoolean, JSValueMakeFromJSONString, JSValueMakeNull, JSValueMakeNumber, JSValueMakeString, JSValueMakeSymbol, JSValueMakeUndefined, JSValueProtect, JSValueRef, JSValueToBoolean, JSValueToInt32, JSValueToInt64, JSValueToNumber, JSValueToObject, JSValueToStringCopy, JSValueToUInt32, JSValueToUInt64, JSValueUnprotect, OpaqueJSClass, OpaqueJSContext, OpaqueJSContextGroup, OpaqueJSPropertyNameAccumulator, OpaqueJSPropertyNameArray, OpaqueJSString, OpaqueJSValue, jscHeader