Skip to content

Commit 19a91cc

Browse files
refactor: update for Zig v0.14.0
1 parent 59b0f61 commit 19a91cc

File tree

7 files changed

+23
-22
lines changed

7 files changed

+23
-22
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
zig 0.13.0
1+
zig 0.14.0

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ Tagged versions of this project are available and can be added as dependency to
2323
your project via `zig fetch`, like so:
2424

2525
```bash
26-
zig fetch --save https://github.com/thi-ng/zig-thing/archive/refs/tags/v0.1.0.tar.gz
26+
zig fetch --save https://github.com/thi-ng/zig-thing/archive/refs/tags/v0.1.1.tar.gz
2727
```
2828

29-
The `--save` option adds a new dependency called `thi.ng` to your
29+
The `--save` option adds a new dependency called `thing` to your
3030
`build.zig.zon` project file.
3131

3232
You'll also need to update your main `build.zig` with these additions:
@@ -40,13 +40,13 @@ const exe = b.addExecutable(.{ ... });
4040
// </standard_boilerplate>
4141
4242
// declare & configure dependency (via build.zig.zon)
43-
const thing = b.dependency("thi.ng", .{
43+
const thing = b.dependency("thing", .{
4444
.target = target,
4545
.optimize = optimize,
46-
}).module("thi.ng");
46+
}).module("thing");
4747
4848
// declare module for importing via given id
49-
exe.root_module.addImport("thi.ng", thing);
49+
exe.root_module.addImport("thing", thing);
5050
```
5151

5252
**Important:** If you're having a test build step configured (or any other build
@@ -56,7 +56,7 @@ step requiring separate compilation), you'll also need to add the
5656
With these changes, you can then import the module in your source code like so:
5757

5858
```zig
59-
const thing = @import("thi.ng");
59+
const thing = @import("thing");
6060
```
6161

6262
## Building & Testing

build.zig.zon

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.{
2-
.name = "thi.ng",
3-
.version = "0.1.0",
4-
.minimum_zig_version = "0.13.0",
2+
.name = .thing,
3+
.version = "0.1.1",
4+
.minimum_zig_version = "0.14.0",
5+
.fingerprint = 0x5b4c2c83314fb2b8,
56
.paths = .{
67
"src",
78
"build.zig",

src/dual_list.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const DualListError = error{
2121
/// https://mastodon.thi.ng/@toxi/111449052682849612
2222
pub fn FixedBufferDualList(comptime SIZE: usize, comptime T: type) type {
2323
const info = @typeInfo(T);
24-
if (!(info == .Int and info.Int.signedness == .unsigned)) {
24+
if (!(info == .int and info.int.signedness == .unsigned)) {
2525
@compileError("unsupported type: expected an uint, but got: " ++ @typeName(T));
2626
}
2727
const sentinel = std.math.maxInt(T);

src/ndarray.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ pub fn NDArray(comptime N: usize, comptime CTYPE: type) type {
170170

171171
pub fn sum(self: *const Self) T {
172172
const info = @typeInfo(T);
173-
if (!(info == .Int or info == .Float)) @compileError("only supported for int/float types");
173+
if (!(info == .int or info == .float)) @compileError("only supported for int/float types");
174174
var acc: T = 0;
175175
var iter = self.values(.{});
176176
while (true) {
@@ -238,7 +238,7 @@ pub fn NDArray(comptime N: usize, comptime CTYPE: type) type {
238238
}
239239

240240
pub fn eqApprox(self: *const Self, other: *const Self, tolerance: T) bool {
241-
if (@typeInfo(T) != .Float) @compileError("only supported for float types");
241+
if (@typeInfo(T) != .float) @compileError("only supported for float types");
242242
if (!std.mem.eql(u32, self.shape[0..], other.shape[0..])) return false;
243243
var ia = self.values(.{});
244244
var ib = other.values(.{});
@@ -447,7 +447,7 @@ fn iabs(x: isize) isize {
447447

448448
pub fn range(n: u32, comptime T: type, allocator: *const Allocator) !NDArray(1, T) {
449449
const info = @typeInfo(T);
450-
if (!(info == .Int or info == .Float)) @compileError("only int or float types supported");
450+
if (!(info == .int or info == .float)) @compileError("only int or float types supported");
451451
var res = try NDArray(1, T).init(.{
452452
.allocator = allocator,
453453
.shape = .{n},

src/random.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22

33
const std = @import("std");
4-
const Random = std.rand.Random;
4+
const Random = std.Random;
55

66
pub const Sfc32 = @import("random/sfc32.zig");
77

src/vectors.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const swizzles = @import("vectors/swizzle.zig");
1313
/// their integer-based counterparts)
1414
pub fn Vec(comptime SIZE: u32, comptime CTYPE: type) type {
1515
const INFO = @typeInfo(CTYPE);
16-
if (!(INFO == .Int or INFO == .Float)) {
16+
if (!(INFO == .int or INFO == .float)) {
1717
@compileError("unsupported component type: " ++ CTYPE);
1818
}
1919
if (SIZE < 1) {
@@ -92,7 +92,7 @@ pub fn Vec(comptime SIZE: u32, comptime CTYPE: type) type {
9292
}
9393

9494
pub inline fn divN(a: V, n: T) V {
95-
return if (INFO == .Int) @divTrunc(a, of(n)) else a / of(n);
95+
return if (INFO == .int) @divTrunc(a, of(n)) else a / of(n);
9696
}
9797

9898
pub inline fn dot(a: V, b: V) T {
@@ -185,11 +185,11 @@ fn VecTypeSpecific(comptime SIZE: u32, comptime T: type) type {
185185
return @select(T, delta > invDelta, delta, invDelta) <= @as(V, @splat(eps));
186186
}
187187
};
188-
if (INFO == .Int) {
188+
if (INFO == .int) {
189189
const base = struct {
190190
pub fn fromVec(comptime S: type, a: @Vector(SIZE, S)) V {
191191
comptime var i = 0;
192-
const isFloat = @typeInfo(S) == .Float;
192+
const isFloat = @typeInfo(S) == .float;
193193
var res: [SIZE]T = undefined;
194194
inline while (i < SIZE) : (i += 1) {
195195
res[i] = if (isFloat) @as(T, @intFromFloat(a[i])) else @as(T, @intCast(a[i]));
@@ -240,7 +240,7 @@ fn VecTypeSpecific(comptime SIZE: u32, comptime T: type) type {
240240

241241
pub inline fn fromVec(comptime S: type, a: @Vector(SIZE, S)) V {
242242
comptime var i = 0;
243-
const isInt = @typeInfo(S) == .Int;
243+
const isInt = @typeInfo(S) == .int;
244244
var res: [SIZE]T = undefined;
245245
inline while (i < SIZE) : (i += 1) {
246246
res[i] = if (isInt) @as(T, @floatFromInt(a[i])) else @as(T, @floatCast(a[i]));
@@ -501,7 +501,7 @@ pub fn BVec(comptime SIZE: u32) type {
501501
fn VecSizeSpecific(comptime SIZE: u32, comptime T: type) type {
502502
const V = @Vector(SIZE, T);
503503
const INFO = @typeInfo(T);
504-
const isFloat = INFO == .Float;
504+
const isFloat = INFO == .float;
505505
if (SIZE == 2) {
506506
const base = if (isFloat or isSignedInt(T)) struct {
507507
pub fn perpendicularCCW(a: V) V {
@@ -604,7 +604,7 @@ fn VecSizeSpecific(comptime SIZE: u32, comptime T: type) type {
604604

605605
fn isSignedInt(comptime a: type) bool {
606606
const info = @typeInfo(a);
607-
return info == .Int and info.Int.signedness == std.builtin.Signedness.signed;
607+
return info == .int and info.int.signedness == std.builtin.Signedness.signed;
608608
}
609609

610610
fn _map(comptime SIZE: u32, comptime T: type, a: @Vector(SIZE, T), comptime f: anytype, args: anytype) @TypeOf(a) {

0 commit comments

Comments
 (0)