mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 20:54:43 +00:00
Uint8ClampedArray: update comment + change enum literals
I feel `ref` and `copy` is on-point on what's being actually happening.
This commit is contained in:
@@ -77,11 +77,14 @@ pub const ArrayBuffer = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// `mutable` indicates bytes are not copied by `simpleZigValueToJs`;
|
/// `ref` indicates bytes are not copied by `simpleZigValueToJs`;
|
||||||
/// instead, `BackingStore` takes ownership of already allocated `values`.
|
/// instead, `values` references an already allocated memory. Note that
|
||||||
pub fn Uint8ClampedArray(comptime state: enum(u1) { immutable, mutable }) type {
|
/// this variant assumes memory is (de)allocated by an arena allocator.
|
||||||
|
///
|
||||||
|
/// `copy` behaves the same as `TypedArray(T)`.
|
||||||
|
pub fn Uint8ClampedArray(comptime state: enum(u1) { ref, copy }) type {
|
||||||
return struct {
|
return struct {
|
||||||
values: if (state == .mutable) []u8 else []const u8,
|
values: if (state == .ref) []u8 else []const u8,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +205,7 @@ pub fn simpleZigValueToJs(isolate: Isolate, value: anytype, comptime fail: bool,
|
|||||||
// but this can never be valid.
|
// but this can never be valid.
|
||||||
@compileError("Invalid TypeArray type: " ++ @typeName(value_type));
|
@compileError("Invalid TypeArray type: " ++ @typeName(value_type));
|
||||||
},
|
},
|
||||||
Uint8ClampedArray(.mutable) => {
|
Uint8ClampedArray(.ref) => {
|
||||||
const values = value.values;
|
const values = value.values;
|
||||||
const len = values.len;
|
const len = values.len;
|
||||||
var array_buffer: *const v8.ArrayBuffer = undefined;
|
var array_buffer: *const v8.ArrayBuffer = undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user