update to latest Zig (zig fmt)

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2023-06-25 00:01:55 -07:00
parent 419d82d5fd
commit 29964c99bb
39 changed files with 156 additions and 156 deletions

View file

@ -126,7 +126,7 @@ pub fn getNameIndex(self: Face, name: [:0]const u8) ?u32 {
pub fn getKerning(self: Face, left_char_index: u32, right_char_index: u32, mode: KerningMode) Error!Vector {
var kerning: Vector = undefined;
try intToError(c.FT_Get_Kerning(self.handle, left_char_index, right_char_index, @enumToInt(mode), &kerning));
try intToError(c.FT_Get_Kerning(self.handle, left_char_index, right_char_index, @intFromEnum(mode), &kerning));
return kerning;
}
@ -152,7 +152,7 @@ pub fn iterateCharmap(self: Face) CharmapIterator {
}
pub fn selectCharmap(self: Face, encoding: Encoding) Error!void {
return intToError(c.FT_Select_Charmap(self.handle, @enumToInt(encoding)));
return intToError(c.FT_Select_Charmap(self.handle, @intFromEnum(encoding)));
}
pub fn setCharmap(self: Face, char_map: *CharMap) Error!void {
@ -223,7 +223,7 @@ pub fn getGlyphLayersIterator(self: Face, glyph_index: u32) GlyphLayersIterator
pub fn getColorGlyphPaint(self: Face, base_glyph: u32, root_transform: RootTransform) ?Paint {
var opaque_paint: OpaquePaint = undefined;
if (c.FT_Get_Color_Glyph_Paint(self.handle, base_glyph, @enumToInt(root_transform), &opaque_paint) == 0)
if (c.FT_Get_Color_Glyph_Paint(self.handle, base_glyph, @intFromEnum(root_transform), &opaque_paint) == 0)
return null;
return self.getPaint(opaque_paint);
}
@ -239,7 +239,7 @@ pub fn getPaint(self: Face, opaque_paint: OpaquePaint) ?Paint {
var p: c.FT_COLR_Paint = undefined;
if (c.FT_Get_Paint(self.handle, opaque_paint, &p) == 0)
return null;
return switch (@intToEnum(PaintFormat, p.format)) {
return switch (@enumFromInt(PaintFormat, p.format)) {
.color_layers => Paint{ .color_layers = p.u.colr_layers },
.glyph => Paint{ .glyph = p.u.glyph },
.solid => Paint{ .solid = p.u.solid },

View file

@ -57,7 +57,7 @@ pub fn advance(self: GlyphSlot) Vector {
}
pub fn format(self: GlyphSlot) GlyphFormat {
return @intToEnum(GlyphFormat, self.handle.*.format);
return @enumFromInt(GlyphFormat, self.handle.*.format);
}
pub fn ownBitmap(self: GlyphSlot) Error!void {
@ -89,7 +89,7 @@ pub fn rsbDelta(self: GlyphSlot) i32 {
}
pub fn render(self: GlyphSlot, render_mode: RenderMode) Error!void {
return intToError(c.FT_Render_Glyph(self.handle, @enumToInt(render_mode)));
return intToError(c.FT_Render_Glyph(self.handle, @intFromEnum(render_mode)));
}
pub fn getSubGlyphInfo(self: GlyphSlot, sub_index: u32) Error!SubGlyphInfo {

View file

@ -78,7 +78,7 @@ pub fn renderOutline(self: Library, outline: Outline, params: *RasterParams) Err
}
pub fn setLcdFilter(self: Library, lcd_filter: LcdFilter) Error!void {
return intToError(c.FT_Library_SetLcdFilter(self.handle, @enumToInt(lcd_filter)));
return intToError(c.FT_Library_SetLcdFilter(self.handle, @intFromEnum(lcd_filter)));
}
pub extern fn FT_Outline_Render(library: c.FT_Library, outline: [*c]c.FT_Outline, params: [*c]RasterParams) c_int;

View file

@ -179,7 +179,7 @@ pub const OpenArgs = struct {
.stream => |d| oa.stream = d,
.driver => |d| oa.driver = d,
.params => |*d| {
oa.params = @intToPtr(*c.FT_Parameter, @ptrToInt(d.ptr));
oa.params = @ptrFromInt(*c.FT_Parameter, @intFromPtr(d.ptr));
oa.num_params = @intCast(u31, d.len);
},
}

View file

@ -32,7 +32,7 @@ pub const Glyph = struct {
pub fn newGlyph(library: Library, glyph_format: GlyphFormat) Glyph {
var g: c.FT_Glyph = undefined;
return .{
.handle = c.FT_New_Glyph(library.handle, @enumToInt(glyph_format), &g),
.handle = c.FT_New_Glyph(library.handle, @intFromEnum(glyph_format), &g),
};
}
@ -48,17 +48,17 @@ pub const Glyph = struct {
pub fn getCBox(self: Glyph, bbox_mode: BBoxMode) BBox {
var b: BBox = undefined;
c.FT_Glyph_Get_CBox(self.handle, @enumToInt(bbox_mode), &b);
c.FT_Glyph_Get_CBox(self.handle, @intFromEnum(bbox_mode), &b);
return b;
}
pub fn toBitmapGlyph(self: *Glyph, render_mode: RenderMode, origin: ?Vector) Error!BitmapGlyph {
try intToError(c.FT_Glyph_To_Bitmap(&self.handle, @enumToInt(render_mode), if (origin) |o| &o else null, 1));
try intToError(c.FT_Glyph_To_Bitmap(&self.handle, @intFromEnum(render_mode), if (origin) |o| &o else null, 1));
return BitmapGlyph{ .handle = @ptrCast(c.FT_BitmapGlyph, self.handle) };
}
pub fn copyBitmapGlyph(self: *Glyph, render_mode: RenderMode, origin: ?Vector) Error!BitmapGlyph {
try intToError(c.FT_Glyph_To_Bitmap(&self.handle, @enumToInt(render_mode), if (origin) |o| &o else null, 0));
try intToError(c.FT_Glyph_To_Bitmap(&self.handle, @intFromEnum(render_mode), if (origin) |o| &o else null, 0));
return BitmapGlyph{ .handle = @ptrCast(c.FT_BitmapGlyph, self.handle) };
}
@ -83,7 +83,7 @@ pub const Glyph = struct {
}
pub fn format(self: Glyph) GlyphFormat {
return @intToEnum(GlyphFormat, self.handle.*.format);
return @enumFromInt(GlyphFormat, self.handle.*.format);
}
pub fn advanceX(self: Glyph) isize {

View file

@ -13,13 +13,13 @@ pub const Blob = struct {
pub fn init(data: []u8, mode: MemoryMode) ?Blob {
return Blob{
.handle = c.hb_blob_create_or_fail(&data[0], @intCast(c_uint, data.len), @enumToInt(mode), null, null) orelse return null,
.handle = c.hb_blob_create_or_fail(&data[0], @intCast(c_uint, data.len), @intFromEnum(mode), null, null) orelse return null,
};
}
pub fn initOrEmpty(data: []u8, mode: MemoryMode) Blob {
return .{
.handle = c.hb_blob_create(&data[0], @intCast(c_uint, data.len), @enumToInt(mode), null, null).?,
.handle = c.hb_blob_create(&data[0], @intCast(c_uint, data.len), @intFromEnum(mode), null, null).?,
};
}

View file

@ -56,8 +56,8 @@ pub const SegmentProps = struct {
pub fn from(c_struct: c.hb_segment_properties_t) SegmentProps {
return .{
.direction = @intToEnum(Direction, c_struct.direction),
.script = @intToEnum(Script, c_struct.script),
.direction = @enumFromInt(Direction, c_struct.direction),
.script = @enumFromInt(Script, c_struct.script),
.language = Language{ .handle = c_struct.language },
};
}
@ -66,8 +66,8 @@ pub const SegmentProps = struct {
return .{
.reserved1 = undefined,
.reserved2 = undefined,
.direction = @enumToInt(self.direction),
.script = @enumToInt(self.script),
.direction = @intFromEnum(self.direction),
.script = @intFromEnum(self.script),
.language = self.language.handle,
};
}
@ -197,27 +197,27 @@ pub const Buffer = struct {
}
pub fn getContentType(self: Buffer) ContentType {
return @intToEnum(ContentType, c.hb_buffer_get_content_type(self.handle));
return @enumFromInt(ContentType, c.hb_buffer_get_content_type(self.handle));
}
pub fn setContentType(self: Buffer, content_type: ContentType) void {
c.hb_buffer_set_content_type(self.handle, @enumToInt(content_type));
c.hb_buffer_set_content_type(self.handle, @intFromEnum(content_type));
}
pub fn getDirection(self: Buffer) Direction {
return @intToEnum(Direction, c.hb_buffer_get_direction(self.handle));
return @enumFromInt(Direction, c.hb_buffer_get_direction(self.handle));
}
pub fn setDirection(self: Buffer, direction: Direction) void {
c.hb_buffer_set_direction(self.handle, @enumToInt(direction));
c.hb_buffer_set_direction(self.handle, @intFromEnum(direction));
}
pub fn getScript(self: Buffer) Script {
return @intToEnum(Script, c.hb_buffer_get_script(self.handle));
return @enumFromInt(Script, c.hb_buffer_get_script(self.handle));
}
pub fn setScript(self: Buffer, script: Script) void {
c.hb_buffer_set_script(self.handle, @enumToInt(script));
c.hb_buffer_set_script(self.handle, @intFromEnum(script));
}
pub fn getLanguage(self: Buffer) Language {
@ -237,11 +237,11 @@ pub const Buffer = struct {
}
pub fn getClusterLevel(self: Buffer) ClusterLevel {
return @intToEnum(ClusterLevel, c.hb_buffer_get_cluster_level(self.handle));
return @enumFromInt(ClusterLevel, c.hb_buffer_get_cluster_level(self.handle));
}
pub fn setClusterLevel(self: Buffer, level: ClusterLevel) void {
c.hb_buffer_set_cluster_level(self.handle, @enumToInt(level));
c.hb_buffer_set_cluster_level(self.handle, @intFromEnum(level));
}
pub fn getLength(self: Buffer) u32 {

View file

@ -9,11 +9,11 @@ pub const Direction = enum(u3) {
bit = c.HB_DIRECTION_BTT,
pub fn fromString(str: []const u8) Direction {
return @intToEnum(Direction, c.hb_direction_from_string(str.ptr, @intCast(c_int, str.len)));
return @enumFromInt(Direction, c.hb_direction_from_string(str.ptr, @intCast(c_int, str.len)));
}
pub fn toString(self: Direction) [:0]const u8 {
return std.mem.span(@ptrCast([*:0]const u8, c.hb_direction_to_string(@enumToInt(self))));
return std.mem.span(@ptrCast([*:0]const u8, c.hb_direction_to_string(@intFromEnum(self))));
}
};
@ -184,19 +184,19 @@ pub const Script = enum(u31) {
invalid = c.HB_SCRIPT_INVALID,
pub fn fromISO15924Tag(tag: Tag) Script {
return @intToEnum(Script, c.hb_script_from_iso15924_tag(tag.handle));
return @enumFromInt(Script, c.hb_script_from_iso15924_tag(tag.handle));
}
pub fn fromString(str: []const u8) Script {
return @intToEnum(Script, c.hb_script_from_string(str.ptr, @intCast(c_int, str.len)));
return @enumFromInt(Script, c.hb_script_from_string(str.ptr, @intCast(c_int, str.len)));
}
pub fn toISO15924Tag(self: Script) Tag {
return .{ .handle = c.hb_script_to_iso15924_tag(@enumToInt(self)) };
return .{ .handle = c.hb_script_to_iso15924_tag(@intFromEnum(self)) };
}
pub fn getHorizontalDirection(self: Script) Direction {
return @intToEnum(Direction, c.hb_script_get_horizontal_direction(@enumToInt(self)));
return @enumFromInt(Direction, c.hb_script_get_horizontal_direction(@intFromEnum(self)));
}
};

View file

@ -84,7 +84,7 @@ pub const Bitmap = struct {
}
pub fn pixelMode(self: Bitmap) PixelMode {
return @intToEnum(PixelMode, self.handle.pixel_mode);
return @enumFromInt(PixelMode, self.handle.pixel_mode);
}
pub fn buffer(self: Bitmap) ?[]const u8 {
@ -188,15 +188,15 @@ pub const Outline = struct {
}
pub fn orientation(self: Outline) Orientation {
return @intToEnum(Orientation, c.FT_Outline_Get_Orientation(self.handle));
return @enumFromInt(Orientation, c.FT_Outline_Get_Orientation(self.handle));
}
pub fn getInsideBorder(self: Outline) Stroker.Border {
return @intToEnum(Stroker.Border, c.FT_Outline_GetInsideBorder(self.handle));
return @enumFromInt(Stroker.Border, c.FT_Outline_GetInsideBorder(self.handle));
}
pub fn getOutsideBorder(self: Outline) Stroker.Border {
return @intToEnum(Stroker.Border, c.FT_Outline_GetOutsideBorder(self.handle));
return @enumFromInt(Stroker.Border, c.FT_Outline_GetOutsideBorder(self.handle));
}
pub fn Funcs(comptime Context: type) type {

View file

@ -31,7 +31,7 @@ pub const Stroker = struct {
handle: c.FT_Stroker,
pub fn set(self: Stroker, radius: i32, line_cap: LineCap, line_join: LineJoin, miter_limit: i32) void {
c.FT_Stroker_Set(self.handle, radius, @enumToInt(line_cap), @enumToInt(line_join), miter_limit);
c.FT_Stroker_Set(self.handle, radius, @intFromEnum(line_cap), @intFromEnum(line_join), miter_limit);
}
pub fn rewind(self: Stroker) void {
@ -64,12 +64,12 @@ pub const Stroker = struct {
pub fn getBorderCounts(self: Stroker, border: Border) Error!BorderCounts {
var counts: BorderCounts = undefined;
try intToError(c.FT_Stroker_GetBorderCounts(self.handle, @enumToInt(border), &counts.points, &counts.contours));
try intToError(c.FT_Stroker_GetBorderCounts(self.handle, @intFromEnum(border), &counts.points, &counts.contours));
return counts;
}
pub fn exportBorder(self: Stroker, border: Border, outline: *Outline) void {
c.FT_Stroker_ExportBorder(self.handle, @enumToInt(border), outline.handle);
c.FT_Stroker_ExportBorder(self.handle, @intFromEnum(border), outline.handle);
}
pub fn getCounts(self: Stroker) Error!BorderCounts {