Skip to content

Commit

Permalink
build: support Zig 0.13.0 in the binding generator
Browse files Browse the repository at this point in the history
Closes #79
  • Loading branch information
ianprime0509 committed Oct 11, 2024
1 parent cc4ce92 commit 66bd043
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ exe.root_module.addImport("gtk", gobject.module("gtk-4.0"));
exe.root_module.addImport("adw", gobject.module("adw-1"));
```

The generated bindings are tested on Zig 0.13.0 and master, though support for
the latest master may temporarily regress when breaking changes are made
upstream. The binding generator itself targets only the latest Zig master.
The binding generator and generated bindings are tested on Zig 0.13.0 and
master, though support for the latest master may temporarily regress when
breaking changes are made upstream.

## Companion projects

Expand Down
4 changes: 2 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@ pub fn build(b: *std.Build) void {
"freetype2-2.0",
"GObject-2.0",
};
const gir_fixes_profiles: std.EnumArray(GirProfile, []const []const u8) = .init(.{
const gir_fixes_profiles = std.EnumArray(GirProfile, []const []const u8).init(.{
.gnome46 = &.{
"AppStream-1.0",
},
.gnome47 = &.{},
});
const gir_fixes: []const []const u8 = b.option([]const []const u8, "gir-fixes", "GIR fixes to apply") orelse gir_fixes: {
var applicable_fixes: std.ArrayList([]const u8) = .init(b.allocator);
var applicable_fixes = std.ArrayList([]const u8).init(b.allocator);
defer applicable_fixes.deinit();
for (gir_fixes_common) |fix| {
applicable_fixes.append(b.fmt("{0s}=gir-fixes/common/{0s}.xslt", .{fix})) catch @panic("OOM");
Expand Down
3 changes: 2 additions & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const std = @import("std");
const builtin = @import("builtin");
const compat = @import("compat.zig");
const gir = @import("gir.zig");
const translate = @import("translate.zig");
const log = std.log;
Expand Down Expand Up @@ -31,7 +32,7 @@ pub const std_options: std.Options = .{

pub fn logImpl(
comptime level: log.Level,
comptime scope: @Type(.enum_literal),
comptime scope: compat.Reify(.enum_literal),
comptime format: []const u8,
args: anytype,
) void {
Expand Down
7 changes: 4 additions & 3 deletions src/zig_writer.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const std = @import("std");
const compat = @import("compat.zig");

pub fn zigWriter(out: anytype) ZigWriter(@TypeOf(out)) {
return .{ .out = out };
Expand Down Expand Up @@ -29,7 +30,7 @@ pub fn ZigWriter(comptime Writer: type) type {
/// made into its own project.
pub fn print(w: Self, comptime fmt: []const u8, args: anytype) Error!void {
@setEvalBranchQuota(100_000);
const arg_fields = @typeInfo(@TypeOf(args)).@"struct".fields;
const arg_fields = compat.typeInfo(@TypeOf(args)).@"struct".fields;

comptime var current_arg = 0;
comptime var i = 0;
Expand Down Expand Up @@ -100,11 +101,11 @@ pub fn ZigWriter(comptime Writer: type) type {
}

inline fn isString(comptime T: type) bool {
return switch (@typeInfo(T)) {
return switch (compat.typeInfo(T)) {
.pointer => |pointer| if (pointer.size == .Slice)
pointer.child == u8
else if (pointer.size == .One)
switch (@typeInfo(pointer.child)) {
switch (compat.typeInfo(pointer.child)) {
.array => |array| array.child == u8,
else => false,
}
Expand Down

0 comments on commit 66bd043

Please sign in to comment.