prefer snake case in enums

This commit is contained in:
Halil Durak
2026-02-17 02:48:30 +03:00
parent d4e24dabc2
commit 094270dff7
3 changed files with 38 additions and 38 deletions

View File

@@ -306,10 +306,10 @@ pub fn zigValueToJs(self: *const Local, value: anytype, comptime opts: CallOpts)
js.Value => return value,
js.Exception => return .{ .local = self, .handle = isolate.throwException(value.handle) },
js.ArrayBufferRef(.Int8), js.ArrayBufferRef(.Uint8), js.ArrayBufferRef(.Uint8Clamped),
js.ArrayBufferRef(.Int16), js.ArrayBufferRef(.Uint16),
js.ArrayBufferRef(.Int32), js.ArrayBufferRef(.Uint32),
js.ArrayBufferRef(.Float16), js.ArrayBufferRef(.Float32), js.ArrayBufferRef(.Float64),
js.ArrayBufferRef(.int8), js.ArrayBufferRef(.uint8), js.ArrayBufferRef(.uint8_clamped),
js.ArrayBufferRef(.int16), js.ArrayBufferRef(.uint16),
js.ArrayBufferRef(.int32), js.ArrayBufferRef(.uint32),
js.ArrayBufferRef(.float16), js.ArrayBufferRef(.float32), js.ArrayBufferRef(.float64),
=> {
return .{ .local = self, .handle = value.handle };
},

View File

@@ -78,16 +78,16 @@ pub const ArrayBuffer = struct {
};
pub const ArrayType = enum(u8) {
Int8,
Uint8,
Uint8Clamped,
Int16,
Uint16,
Int32,
Uint32,
Float16,
Float32,
Float64,
int8,
uint8,
uint8_clamped,
int16,
uint16,
int32,
uint32,
float16,
float32,
float64,
};
pub fn ArrayBufferRef(comptime kind: ArrayType) type {
@@ -95,15 +95,15 @@ pub fn ArrayBufferRef(comptime kind: ArrayType) type {
const Self = @This();
const BackingInt = switch (kind) {
.Int8 => i8,
.Uint8, .Uint8Clamped => u8,
.Int16 => i16,
.Uint16 => u16,
.Int32 => i32,
.Uint32 => u32,
.Float16 => f16,
.Float32 => f32,
.Float64 => f64,
.int8 => i8,
.uint8, .uint8_clamped => u8,
.int16 => i16,
.uint16 => u16,
.int32 => i32,
.uint32 => u32,
.float16 => f16,
.float32 => f32,
.float64 => f64,
};
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).?;
}
const internal: *const v8.Value = switch (comptime kind) {
.Int8 => @ptrCast(v8.v8__Int8Array__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).?),
.Int16 => @ptrCast(v8.v8__Int16Array__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).?),
.Uint32 => @ptrCast(v8.v8__Uint32Array__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).?),
.Float64 => @ptrCast(v8.v8__Float64Array__New(array_buffer, 0, size).?),
const handle: *const v8.Value = switch (comptime kind) {
.int8 => @ptrCast(v8.v8__Int8Array__New(array_buffer, 0, size).?),
.uint8 => @ptrCast(v8.v8__Uint8Array__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).?),
.uint16 => @ptrCast(v8.v8__Uint16Array__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).?),
.float16 => @ptrCast(v8.v8__Float16Array__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).?),
};
return .{ .internal = internal };
return .{ .handle = handle };
}
};
}

View File

@@ -29,7 +29,7 @@ const Page = @import("../Page.zig");
const ImageData = @This();
_width: u32,
_height: u32,
_data: js.ArrayBufferRef(.Uint8Clamped),
_data: js.ArrayBufferRef(.uint8_clamped),
pub const ConstructorSettings = struct {
/// Specifies the color space of the image data.
@@ -74,7 +74,7 @@ pub fn constructor(
return page._factory.create(ImageData{
._width = width,
._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");
}
pub fn getData(self: *const ImageData) js.ArrayBufferRef(.Uint8Clamped) {
pub fn getData(self: *const ImageData) js.ArrayBufferRef(.uint8_clamped) {
return self._data;
}