mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 12:44:43 +00:00
prefer snake case in enums
This commit is contained in:
@@ -306,10 +306,10 @@ pub fn zigValueToJs(self: *const Local, value: anytype, comptime opts: CallOpts)
|
|||||||
js.Value => return value,
|
js.Value => return value,
|
||||||
js.Exception => return .{ .local = self, .handle = isolate.throwException(value.handle) },
|
js.Exception => return .{ .local = self, .handle = isolate.throwException(value.handle) },
|
||||||
|
|
||||||
js.ArrayBufferRef(.Int8), js.ArrayBufferRef(.Uint8), js.ArrayBufferRef(.Uint8Clamped),
|
js.ArrayBufferRef(.int8), js.ArrayBufferRef(.uint8), js.ArrayBufferRef(.uint8_clamped),
|
||||||
js.ArrayBufferRef(.Int16), js.ArrayBufferRef(.Uint16),
|
js.ArrayBufferRef(.int16), js.ArrayBufferRef(.uint16),
|
||||||
js.ArrayBufferRef(.Int32), js.ArrayBufferRef(.Uint32),
|
js.ArrayBufferRef(.int32), js.ArrayBufferRef(.uint32),
|
||||||
js.ArrayBufferRef(.Float16), js.ArrayBufferRef(.Float32), js.ArrayBufferRef(.Float64),
|
js.ArrayBufferRef(.float16), js.ArrayBufferRef(.float32), js.ArrayBufferRef(.float64),
|
||||||
=> {
|
=> {
|
||||||
return .{ .local = self, .handle = value.handle };
|
return .{ .local = self, .handle = value.handle };
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -78,16 +78,16 @@ pub const ArrayBuffer = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub const ArrayType = enum(u8) {
|
pub const ArrayType = enum(u8) {
|
||||||
Int8,
|
int8,
|
||||||
Uint8,
|
uint8,
|
||||||
Uint8Clamped,
|
uint8_clamped,
|
||||||
Int16,
|
int16,
|
||||||
Uint16,
|
uint16,
|
||||||
Int32,
|
int32,
|
||||||
Uint32,
|
uint32,
|
||||||
Float16,
|
float16,
|
||||||
Float32,
|
float32,
|
||||||
Float64,
|
float64,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn ArrayBufferRef(comptime kind: ArrayType) type {
|
pub fn ArrayBufferRef(comptime kind: ArrayType) type {
|
||||||
@@ -95,15 +95,15 @@ pub fn ArrayBufferRef(comptime kind: ArrayType) type {
|
|||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
const BackingInt = switch (kind) {
|
const BackingInt = switch (kind) {
|
||||||
.Int8 => i8,
|
.int8 => i8,
|
||||||
.Uint8, .Uint8Clamped => u8,
|
.uint8, .uint8_clamped => u8,
|
||||||
.Int16 => i16,
|
.int16 => i16,
|
||||||
.Uint16 => u16,
|
.uint16 => u16,
|
||||||
.Int32 => i32,
|
.int32 => i32,
|
||||||
.Uint32 => u32,
|
.uint32 => u32,
|
||||||
.Float16 => f16,
|
.float16 => f16,
|
||||||
.Float32 => f32,
|
.float32 => f32,
|
||||||
.Float64 => f64,
|
.float64 => f64,
|
||||||
};
|
};
|
||||||
|
|
||||||
handle: *const v8.Value,
|
handle: *const v8.Value,
|
||||||
@@ -125,20 +125,20 @@ pub fn ArrayBufferRef(comptime kind: ArrayType) type {
|
|||||||
array_buffer = v8.v8__ArrayBuffer__New2(isolate.handle, &backing_store_ptr).?;
|
array_buffer = v8.v8__ArrayBuffer__New2(isolate.handle, &backing_store_ptr).?;
|
||||||
}
|
}
|
||||||
|
|
||||||
const internal: *const v8.Value = switch (comptime kind) {
|
const handle: *const v8.Value = switch (comptime kind) {
|
||||||
.Int8 => @ptrCast(v8.v8__Int8Array__New(array_buffer, 0, size).?),
|
.int8 => @ptrCast(v8.v8__Int8Array__New(array_buffer, 0, size).?),
|
||||||
.Uint8 => @ptrCast(v8.v8__Uint8Array__New(array_buffer, 0, size).?),
|
.uint8 => @ptrCast(v8.v8__Uint8Array__New(array_buffer, 0, size).?),
|
||||||
.Uint8Clamped => @ptrCast(v8.v8__Uint8ClampedArray__New(array_buffer, 0, size).?),
|
.uint8_clamped => @ptrCast(v8.v8__Uint8ClampedArray__New(array_buffer, 0, size).?),
|
||||||
.Int16 => @ptrCast(v8.v8__Int16Array__New(array_buffer, 0, size).?),
|
.int16 => @ptrCast(v8.v8__Int16Array__New(array_buffer, 0, size).?),
|
||||||
.Uint16 => @ptrCast(v8.v8__Uint16Array__New(array_buffer, 0, size).?),
|
.uint16 => @ptrCast(v8.v8__Uint16Array__New(array_buffer, 0, size).?),
|
||||||
.Int32 => @ptrCast(v8.v8__Int32Array__New(array_buffer, 0, size).?),
|
.int32 => @ptrCast(v8.v8__Int32Array__New(array_buffer, 0, size).?),
|
||||||
.Uint32 => @ptrCast(v8.v8__Uint32Array__New(array_buffer, 0, size).?),
|
.uint32 => @ptrCast(v8.v8__Uint32Array__New(array_buffer, 0, size).?),
|
||||||
.Float16 => @ptrCast(v8.v8__Float16Array__New(array_buffer, 0, size).?),
|
.float16 => @ptrCast(v8.v8__Float16Array__New(array_buffer, 0, size).?),
|
||||||
.Float32 => @ptrCast(v8.v8__Float32Array__New(array_buffer, 0, size).?),
|
.float32 => @ptrCast(v8.v8__Float32Array__New(array_buffer, 0, size).?),
|
||||||
.Float64 => @ptrCast(v8.v8__Float64Array__New(array_buffer, 0, size).?),
|
.float64 => @ptrCast(v8.v8__Float64Array__New(array_buffer, 0, size).?),
|
||||||
};
|
};
|
||||||
|
|
||||||
return .{ .internal = internal };
|
return .{ .handle = handle };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const Page = @import("../Page.zig");
|
|||||||
const ImageData = @This();
|
const ImageData = @This();
|
||||||
_width: u32,
|
_width: u32,
|
||||||
_height: u32,
|
_height: u32,
|
||||||
_data: js.ArrayBufferRef(.Uint8Clamped),
|
_data: js.ArrayBufferRef(.uint8_clamped),
|
||||||
|
|
||||||
pub const ConstructorSettings = struct {
|
pub const ConstructorSettings = struct {
|
||||||
/// Specifies the color space of the image data.
|
/// Specifies the color space of the image data.
|
||||||
@@ -74,7 +74,7 @@ pub fn constructor(
|
|||||||
return page._factory.create(ImageData{
|
return page._factory.create(ImageData{
|
||||||
._width = width,
|
._width = width,
|
||||||
._height = height,
|
._height = height,
|
||||||
._data = page.js.createTypedArray(.Uint8Clamped, size),
|
._data = page.js.createTypedArray(.uint8_clamped, size),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ pub fn getColorSpace(_: *const ImageData) String {
|
|||||||
return comptime .wrap("srgb");
|
return comptime .wrap("srgb");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getData(self: *const ImageData) js.ArrayBufferRef(.Uint8Clamped) {
|
pub fn getData(self: *const ImageData) js.ArrayBufferRef(.uint8_clamped) {
|
||||||
return self._data;
|
return self._data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user