From c57c40db61a897c2de9f6c99299556d10ef86abf Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 10 Nov 2019 13:37:59 -0300 Subject: [PATCH] use at-as builtin --- src/custom.zig | 12 ++++++------ src/image.zig | 24 ++++++++++++------------ src/lv2_helpers.zig | 6 +++--- src/plugin.zig | 2 +- src/runner.zig | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/custom.zig b/src/custom.zig index 0727113..b748ac5 100644 --- a/src/custom.zig +++ b/src/custom.zig @@ -149,12 +149,12 @@ pub const Embed = struct { pub fn setup(self: *@This()) !void { var in_fmt = c.SF_INFO{ - .frames = c_int(0), - .samplerate = c_int(0), - .channels = c_int(0), - .format = c_int(0), - .sections = c_int(0), - .seekable = c_int(0), + .frames = @as(c_int, 0), + .samplerate = @as(c_int, 0), + .channels = @as(c_int, 0), + .format = @as(c_int, 0), + .sections = @as(c_int, 0), + .seekable = @as(c_int, 0), }; self.sndfile = try image.sopen( diff --git a/src/image.zig b/src/image.zig index c9a436c..3e521fb 100644 --- a/src/image.zig +++ b/src/image.zig @@ -90,7 +90,7 @@ pub fn temporaryName(allocator: *std.mem.Allocator) ![]u8 { // generate a random uppercase letter, that is, 65 + random number. for (fill) |_, f_idx| { var idx = @intCast(u8, r.random.uintLessThan(u5, 24)); - var letter = u8(65) + idx; + var letter = @as(u8, 65) + idx; fill[f_idx] = letter; } @@ -107,12 +107,12 @@ pub fn temporaryName(allocator: *std.mem.Allocator) ![]u8 { pub fn mkSfInfo() c.SF_INFO { return c.SF_INFO{ - .frames = c_int(0), - .samplerate = c_int(44100), - .channels = c_int(1), + .frames = @as(c_int, 0), + .samplerate = @as(c_int, 44100), + .channels = @as(c_int, 1), .format = c.SF_FORMAT_ULAW | c.SF_FORMAT_RAW | c.SF_ENDIAN_BIG, - .sections = c_int(0), - .seekable = c_int(0), + .sections = @as(c_int, 0), + .seekable = @as(c_int, 0), }; } @@ -138,8 +138,8 @@ pub const Image = struct { var image = try allocator.create(Image); - std.debug.assert(in_fmt.frames > i64(0)); - std.debug.assert(in_fmt.seekable == i32(1)); + std.debug.assert(in_fmt.frames > @as(i64, 0)); + std.debug.assert(in_fmt.seekable == @as(i32, 1)); image.* = Image{ .allocator = allocator, @@ -160,8 +160,8 @@ pub const Image = struct { var image = try self.allocator.create(Image); - std.debug.assert(in_fmt.frames > i64(0)); - std.debug.assert(in_fmt.seekable == i32(1)); + std.debug.assert(in_fmt.frames > @as(i64, 0)); + std.debug.assert(in_fmt.seekable == @as(i32, 1)); image.* = Image{ .allocator = self.allocator, @@ -367,7 +367,7 @@ pub const Image = struct { // pre-plugin copy, merged with bmp header copy try self.copyBytes( out_file, - usize(0), + @as(usize, 0), seek_pos.start, ); @@ -462,7 +462,7 @@ pub const Image = struct { // pre-plugin copy, merged with bmp header copy try self.copyBytes( out_file, - usize(0), + @as(usize, 0), seek_pos.start, ); diff --git a/src/lv2_helpers.zig b/src/lv2_helpers.zig index d9a89f5..825ea19 100644 --- a/src/lv2_helpers.zig +++ b/src/lv2_helpers.zig @@ -70,8 +70,8 @@ pub fn setupPorts(ctx: *plugin.Context) ![]Port { port.* = Port{ .lilv_port = null, .ptype = .Control, - .index = f32(0), - .value = f32(0), + .index = @as(f32, 0), + .value = @as(f32, 0), .is_input = false, .optional = false, }; @@ -106,7 +106,7 @@ pub fn setupPorts(ctx: *plugin.Context) ![]Port { port.index = i; if (std.math.isNan(values[i])) { - port.value = f32(0); + port.value = @as(f32, 0); } else { port.value = values[i]; } diff --git a/src/plugin.zig b/src/plugin.zig index 861b452..ebc7f03 100644 --- a/src/plugin.zig +++ b/src/plugin.zig @@ -95,7 +95,7 @@ pub const RunContext = struct { allocator: *std.mem.Allocator, plugin: *const c.LilvPlugin, ) !RunContext { - var instance = c.lilv_plugin_instantiate(plugin, f64(44100), null); + var instance = c.lilv_plugin_instantiate(plugin, @as(f64, 44100), null); errdefer c.lilv_instance_free(instance); if (instance == null) { diff --git a/src/runner.zig b/src/runner.zig index 8169393..869f0f5 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -352,7 +352,7 @@ pub const Runner = struct { .Mbeq => blk: { const pos = try cmd.consumePosition(); - const bands = try cmd.floatArgMany(self.allocator, 2, 15, f32(0)); + const bands = try cmd.floatArgMany(self.allocator, 2, 15, @as(f32, 0)); defer self.allocator.free(bands); try self.mbeqCmd(pos, bands);