Skip to content

Commit 0957269

Browse files
committed
Added documentation for the TypedArray API
1 parent e659470 commit 0957269

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

JavaScriptCore/API/JSTypedArray.h

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33

44
#include <JavaScriptCore/JSValueRef.h>
55

6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
/*!
11+
@enum JSType
12+
@abstract A constant identifying the Typed Array type of a JSValue.
13+
@constant kJSTypedArrayTypeNone Not a Typed Array.
14+
@constant kJSTypedArrayTypeInt8Array Int8Array
15+
@constant kJSTypedArrayTypeInt16Array Int16Array
16+
@constant kJSTypedArrayTypeInt32Array Int32Array
17+
@constant kJSTypedArrayTypeUint8Array Int8Array
18+
@constant kJSTypedArrayTypeUint8ClampedArray Int8ClampedArray
19+
@constant kJSTypedArrayTypeUint16Array Uint16Array
20+
@constant kJSTypedArrayTypeUint32Array Uint32Array
21+
@constant kJSTypedArrayTypeFloat32Array Float32Array
22+
@constant kJSTypedArrayTypeFloat64Array Float64Array
23+
*/
624
typedef enum {
725
kJSTypedArrayTypeNone,
826
kJSTypedArrayTypeInt8Array,
@@ -17,14 +35,35 @@ typedef enum {
1735
kJSTypedArrayTypeLast
1836
} JSTypedArrayType;
1937

38+
/*!
39+
@function
40+
@abstract Returns a JavaScript value's Typed Array type
41+
@param ctx The execution context to use.
42+
@param value The JSValue whose Typed Array type you want to obtain.
43+
@result A value of type JSTypedArrayType that identifies value's Typed Array type.
44+
*/
45+
JS_EXPORT JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef value);
2046

21-
#ifdef __cplusplus
22-
extern "C" {
23-
#endif
24-
25-
JS_EXPORT JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef array);
47+
/*!
48+
@function
49+
@abstract Creates a JavaScript Typed Array with the given number of elements
50+
@param ctx The execution context to use.
51+
@param arrayClass A value of type JSTypedArrayType identifying the type of array you want to create
52+
@param numElements The number of elements for the array.
53+
@result A JSValueRef that is a Typed Array or NULL if there was an error
54+
*/
2655
JS_EXPORT JSValueRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayClass, size_t numElements);
27-
JS_EXPORT void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef array, size_t * byteLength);
56+
57+
/*!
58+
@function
59+
@abstract Returns a pointer to a Typed Array's data in memory
60+
@param ctx The execution context to use.
61+
@param value The JSValue whose Typed Array type data pointer you want to obtain.
62+
@param byteLength A pointer to a size_t in which to store the byte length of the Typed Array
63+
@result A pointer to the Typed Array's data or NULL if the JSValue is not a Typed Array
64+
*/
65+
JS_EXPORT void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef value, size_t * byteLength);
66+
2867

2968
#ifdef __cplusplus
3069
}

0 commit comments

Comments
 (0)