use at-as builtin

This commit is contained in:
Luna 2019-11-10 13:37:59 -03:00
parent a411659d6b
commit c57c40db61
5 changed files with 23 additions and 23 deletions

View File

@ -149,12 +149,12 @@ pub const Embed = struct {
pub fn setup(self: *@This()) !void { pub fn setup(self: *@This()) !void {
var in_fmt = c.SF_INFO{ var in_fmt = c.SF_INFO{
.frames = c_int(0), .frames = @as(c_int, 0),
.samplerate = c_int(0), .samplerate = @as(c_int, 0),
.channels = c_int(0), .channels = @as(c_int, 0),
.format = c_int(0), .format = @as(c_int, 0),
.sections = c_int(0), .sections = @as(c_int, 0),
.seekable = c_int(0), .seekable = @as(c_int, 0),
}; };
self.sndfile = try image.sopen( self.sndfile = try image.sopen(

View File

@ -90,7 +90,7 @@ pub fn temporaryName(allocator: *std.mem.Allocator) ![]u8 {
// generate a random uppercase letter, that is, 65 + random number. // generate a random uppercase letter, that is, 65 + random number.
for (fill) |_, f_idx| { for (fill) |_, f_idx| {
var idx = @intCast(u8, r.random.uintLessThan(u5, 24)); var idx = @intCast(u8, r.random.uintLessThan(u5, 24));
var letter = u8(65) + idx; var letter = @as(u8, 65) + idx;
fill[f_idx] = letter; fill[f_idx] = letter;
} }
@ -107,12 +107,12 @@ pub fn temporaryName(allocator: *std.mem.Allocator) ![]u8 {
pub fn mkSfInfo() c.SF_INFO { pub fn mkSfInfo() c.SF_INFO {
return c.SF_INFO{ return c.SF_INFO{
.frames = c_int(0), .frames = @as(c_int, 0),
.samplerate = c_int(44100), .samplerate = @as(c_int, 44100),
.channels = c_int(1), .channels = @as(c_int, 1),
.format = c.SF_FORMAT_ULAW | c.SF_FORMAT_RAW | c.SF_ENDIAN_BIG, .format = c.SF_FORMAT_ULAW | c.SF_FORMAT_RAW | c.SF_ENDIAN_BIG,
.sections = c_int(0), .sections = @as(c_int, 0),
.seekable = c_int(0), .seekable = @as(c_int, 0),
}; };
} }
@ -138,8 +138,8 @@ pub const Image = struct {
var image = try allocator.create(Image); var image = try allocator.create(Image);
std.debug.assert(in_fmt.frames > i64(0)); std.debug.assert(in_fmt.frames > @as(i64, 0));
std.debug.assert(in_fmt.seekable == i32(1)); std.debug.assert(in_fmt.seekable == @as(i32, 1));
image.* = Image{ image.* = Image{
.allocator = allocator, .allocator = allocator,
@ -160,8 +160,8 @@ pub const Image = struct {
var image = try self.allocator.create(Image); var image = try self.allocator.create(Image);
std.debug.assert(in_fmt.frames > i64(0)); std.debug.assert(in_fmt.frames > @as(i64, 0));
std.debug.assert(in_fmt.seekable == i32(1)); std.debug.assert(in_fmt.seekable == @as(i32, 1));
image.* = Image{ image.* = Image{
.allocator = self.allocator, .allocator = self.allocator,
@ -367,7 +367,7 @@ pub const Image = struct {
// pre-plugin copy, merged with bmp header copy // pre-plugin copy, merged with bmp header copy
try self.copyBytes( try self.copyBytes(
out_file, out_file,
usize(0), @as(usize, 0),
seek_pos.start, seek_pos.start,
); );
@ -462,7 +462,7 @@ pub const Image = struct {
// pre-plugin copy, merged with bmp header copy // pre-plugin copy, merged with bmp header copy
try self.copyBytes( try self.copyBytes(
out_file, out_file,
usize(0), @as(usize, 0),
seek_pos.start, seek_pos.start,
); );

View File

@ -70,8 +70,8 @@ pub fn setupPorts(ctx: *plugin.Context) ![]Port {
port.* = Port{ port.* = Port{
.lilv_port = null, .lilv_port = null,
.ptype = .Control, .ptype = .Control,
.index = f32(0), .index = @as(f32, 0),
.value = f32(0), .value = @as(f32, 0),
.is_input = false, .is_input = false,
.optional = false, .optional = false,
}; };
@ -106,7 +106,7 @@ pub fn setupPorts(ctx: *plugin.Context) ![]Port {
port.index = i; port.index = i;
if (std.math.isNan(values[i])) { if (std.math.isNan(values[i])) {
port.value = f32(0); port.value = @as(f32, 0);
} else { } else {
port.value = values[i]; port.value = values[i];
} }

View File

@ -95,7 +95,7 @@ pub const RunContext = struct {
allocator: *std.mem.Allocator, allocator: *std.mem.Allocator,
plugin: *const c.LilvPlugin, plugin: *const c.LilvPlugin,
) !RunContext { ) !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); errdefer c.lilv_instance_free(instance);
if (instance == null) { if (instance == null) {

View File

@ -352,7 +352,7 @@ pub const Runner = struct {
.Mbeq => blk: { .Mbeq => blk: {
const pos = try cmd.consumePosition(); 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); defer self.allocator.free(bands);
try self.mbeqCmd(pos, bands); try self.mbeqCmd(pos, bands);