mirror of
https://github.com/bellard/quickjs.git
synced 2025-09-30 15:04:24 +03:00
Add JS_NewTypedArray()
(#272)
This commit is contained in:
10
quickjs.c
10
quickjs.c
@@ -53393,6 +53393,16 @@ static JSValue js_typed_array_get_byteOffset(JSContext *ctx,
|
||||
return JS_NewInt32(ctx, ta->offset);
|
||||
}
|
||||
|
||||
JSValue JS_NewTypedArray(JSContext *ctx, int argc, JSValueConst *argv,
|
||||
JSTypedArrayEnum type)
|
||||
{
|
||||
if (type < JS_TYPED_ARRAY_UINT8C || type > JS_TYPED_ARRAY_FLOAT64)
|
||||
return JS_ThrowRangeError(ctx, "invalid typed array type");
|
||||
|
||||
return js_typed_array_constructor(ctx, JS_UNDEFINED, argc, argv,
|
||||
JS_CLASS_UINT8C_ARRAY + type);
|
||||
}
|
||||
|
||||
/* Return the buffer associated to the typed array or an exception if
|
||||
it is not a typed array or if the buffer is detached. pbyte_offset,
|
||||
pbyte_length or pbytes_per_element can be NULL. */
|
||||
|
Reference in New Issue
Block a user