aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-11-02 09:05:43 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2026-11-02 09:05:43 +0100
commitecb79fc433765688cf60ac4ee8ebe38e782641cd (patch)
tree68c954fdc41bdf0b4b8e858c4252fd3b959fb85a
parent4363d446c1f40515f7830caa644cc4e580841122 (diff)
update to zig 0.17dev
-rw-r--r--build.zig8
-rw-r--r--src/http/Parameter.zig4
-rw-r--r--src/http/handler/context.zig2
-rw-r--r--src/zilch/Component.zig2
-rw-r--r--src/zilch/Env/value.sync-conflict-20261030-190805-2JYANE7.zig185
-rw-r--r--src/zilch/Env/value.zig4
-rw-r--r--src/zilch/app/root.wasm.zig2
-rw-r--r--src/zilch/html/Attribute.zig5
8 files changed, 13 insertions, 199 deletions
diff --git a/build.zig b/build.zig
index a805b17..3e9c21b 100644
--- a/build.zig
+++ b/build.zig
@@ -68,9 +68,7 @@ pub fn build(b: *std.Build) void {
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
- if (b.args) |args| {
- run_cmd.addArgs(args);
- }
+ run_cmd.addPassthruArgs();
const db_tests = b.addTest(.{
.root_module = db_mod,
@@ -106,13 +104,13 @@ pub fn build(b: *std.Build) void {
const fmt_step = b.step("fmt", "Format");
const do_fmt = b.addFmt(.{
- .paths = &.{"src"},
+ .paths = b.pathList(&.{"src"}),
});
fmt_step.dependOn(&do_fmt.step);
const check_fmt_step = b.step("check", "Check format and syntax");
const do_check_fmt = b.addFmt(.{
- .paths = &.{"src"},
+ .paths = b.pathList(&.{"src"}),
.check = true,
});
check_fmt_step.dependOn(&do_check_fmt.step);
diff --git a/src/http/Parameter.zig b/src/http/Parameter.zig
index 03260b2..9d2845a 100644
--- a/src/http/Parameter.zig
+++ b/src/http/Parameter.zig
@@ -31,10 +31,10 @@ pub fn Struct(comptime route: Route) type {
}
var types: [names.len]type = undefined;
- var attrs: [names.len]std.builtin.Type.StructField.Attributes = undefined;
+ var attrs: [names.len]std.builtin.Type.Struct.FieldAttributes = undefined;
@memset(&types, @This());
- @memset(&attrs, std.builtin.Type.StructField.Attributes{});
+ @memset(&attrs, .{});
return @Struct(.auto, null, names, &types, &attrs);
}
diff --git a/src/http/handler/context.zig b/src/http/handler/context.zig
index 4e55446..890fa52 100644
--- a/src/http/handler/context.zig
+++ b/src/http/handler/context.zig
@@ -40,6 +40,7 @@ pub fn Context(comptime r: anytype) type {
options: *const fn (Request) Response = badRequest,
trace: *const fn (Request) Response = badRequest,
patch: *const fn (Request) Response = badRequest,
+ query: *const fn (Request) Response = badRequest,
pub fn handle(
self: *const @This(),
@@ -66,6 +67,7 @@ pub fn Context(comptime r: anytype) type {
.OPTIONS => self.options,
.TRACE => self.trace,
.PATCH => self.patch,
+ .QUERY => self.query,
})(req);
}
diff --git a/src/zilch/Component.zig b/src/zilch/Component.zig
index 592b464..3a81301 100644
--- a/src/zilch/Component.zig
+++ b/src/zilch/Component.zig
@@ -37,7 +37,7 @@ pub fn build(comptime options: Options) Self {
fn handlerNeedsEvent(func: anytype) bool {
const T = @TypeOf(func);
- return @typeInfo(T).@"fn".params.len == 2;
+ return @typeInfo(T).@"fn".param_types.len == 2;
}
fn wrapHandler(ret: anytype) void {
diff --git a/src/zilch/Env/value.sync-conflict-20261030-190805-2JYANE7.zig b/src/zilch/Env/value.sync-conflict-20261030-190805-2JYANE7.zig
deleted file mode 100644
index 7ce2ce8..0000000
--- a/src/zilch/Env/value.sync-conflict-20261030-190805-2JYANE7.zig
+++ /dev/null
@@ -1,185 +0,0 @@
-const std = @import("std");
-const Object = @import("../Object.zig");
-const AnyFuture = @import("future.zig").AnyFuture;
-
-pub fn isString(comptime T: type) bool {
- return comptime blk: {
- const info = @typeInfo(T);
- if (info != .pointer) break :blk false;
-
- const ptr = &info.pointer;
- if (ptr.is_volatile or ptr.is_allowzero) break :blk false;
-
- if (ptr.size == .slice) {
- break :blk ptr.child == u8;
- }
-
- if (ptr.size == .one) {
- const child = @typeInfo(ptr.child);
- if (child == .array) {
- const arr = &child.array;
- break :blk arr.child == u8;
- }
- }
-
- break :blk false;
- };
-}
-
-pub fn isObjectRef(comptime T: type) bool {
- comptime {
- const info = @typeInfo(T);
- if (info != .pointer) return false;
-
- const ptr = &info.pointer;
- return ptr.size == .one and @sizeOf(ptr.child) == 0;
- }
-}
-
-pub const Value = extern struct {
- kind: Kind,
- value: extern union {
- object: *anyopaque,
- string: extern struct {
- ptr: [*]const u8,
- len: usize,
- },
- int: isize,
- uint: usize,
- float: f64,
- undefined: void,
- future: usize,
- },
-
- pub fn from(value: anytype) Value {
- const T = @TypeOf(value);
-
- return switch (T) {
- comptime_int => if (value >= 0) .{
- .kind = .uint,
- .value = .{ .uint = value },
- } else .{
- .kind = .int,
- .value = .{ .int = value },
- },
- usize => .{
- .kind = .uint,
- .value = .{ .uint = value },
- },
- isize => .{
- .kind = .int,
- .value = .{ .int = value },
- },
- f64, f32, f16 => .{
- .kind = .float,
- .value = .{ .float = value },
- },
- void => .{
- .kind = .undefined,
- .value = .{ .undefined = {} },
- },
- AnyFuture => .{
- .kind = .future,
- .value = .{ .future = value.unresolved.id },
- },
- else => blk: {
- if (comptime isString(T)) {
- break :blk .{
- .kind = .string,
- .value = .{
- .string = .{
- .ptr = @ptrCast(value),
- .len = value.len,
- },
- },
- };
- } else if (comptime isObjectRef(T)) {
- break :blk .{
- .kind = .object,
- .value = .{ .object = @ptrCast(value) },
- };
- } else if (@typeInfo(T) == .int) {
- // TODO: weil kuscheln mit janina.
- } else {
- @compileError(std.fmt.comptimePrint(
- "cannot auto convert type '{}'.",
- .{T},
- ));
- }
- },
- };
- }
-
- pub fn unwrap(self: *const Value, T: type) T {
- if (Kind.fromType(T) != self.kind) {
- std.log.err("unexpected {}, expected {}", .{ self.kind, T });
- @panic("type error");
- }
-
- return switch (T) {
- comptime_int => self.value.int,
- usize => self.value.uint,
- isize => self.value.int,
- f64, f32, f16 => self.value.float,
- void => {},
- AnyFuture => @panic("unsupported return type"),
- else => blk: {
- if (comptime isString(T)) {
- break :blk self.value.string.ptr[0..self.value.string.len];
- } else if (comptime isObjectRef(T)) {
- break :blk @ptrCast(self.value.object);
- } else {
- @compileError(std.fmt.comptimePrint(
- "cannot auto convert type '{}'.",
- .{T},
- ));
- }
- },
- };
- }
-
- pub const Kind = enum(u8) {
- object = 0,
- string = 1,
- int = 2,
- uint = 3,
- float = 4,
- undefined = 5,
- future = 6,
-
- pub fn asType(comptime self: Kind) type {
- return switch (self) {
- .object => return *Object,
- .string => return []const u8,
- .int => return isize,
- .uint => return usize,
- .float => f64,
- .undefined => return void,
- .future => AnyFuture,
- };
- }
-
- pub fn fromType(T: type) Kind {
- return switch (T) {
- comptime_int => .int,
- usize => .uint,
- isize => .int,
- f64, f32, f16 => .float,
- void => .undefined,
- AnyFuture => .future,
- else => blk: {
- if (comptime isString(T)) {
- break :blk .string;
- } else if (comptime isObjectRef(T)) {
- break :blk .object;
- } else {
- @compileError(std.fmt.comptimePrint(
- "cannot auto convert type '{}'.",
- .{T},
- ));
- }
- },
- };
- }
- };
-};
diff --git a/src/zilch/Env/value.zig b/src/zilch/Env/value.zig
index ea54ff2..398b99b 100644
--- a/src/zilch/Env/value.zig
+++ b/src/zilch/Env/value.zig
@@ -7,8 +7,8 @@ pub fn isString(comptime T: type) bool {
const info = @typeInfo(T);
if (info != .pointer) break :blk false;
- const ptr = &info.pointer;
- if (ptr.is_volatile or ptr.is_allowzero) break :blk false;
+ const ptr = info.pointer;
+ if (ptr.attrs.@"volatile" or ptr.attrs.@"allowzero") break :blk false;
if (ptr.size == .slice) {
break :blk ptr.child == u8;
diff --git a/src/zilch/app/root.wasm.zig b/src/zilch/app/root.wasm.zig
index ea04192..c94c491 100644
--- a/src/zilch/app/root.wasm.zig
+++ b/src/zilch/app/root.wasm.zig
@@ -5,7 +5,7 @@ const Options = @import("Options.zig");
pub fn App(comptime options: Options) type {
var names: [options.globals.len][]const u8 = undefined;
var types: [options.globals.len]type = undefined;
- var attrs: [options.globals.len]std.builtin.Type.StructField.Attributes = undefined;
+ var attrs: [options.globals.len]std.builtin.Type.Struct.FieldAttributes = undefined;
for (options.globals, 0..) |field, index| {
names[index] = field.name;
diff --git a/src/zilch/html/Attribute.zig b/src/zilch/html/Attribute.zig
index 1db49a0..0aa0354 100644
--- a/src/zilch/html/Attribute.zig
+++ b/src/zilch/html/Attribute.zig
@@ -13,12 +13,11 @@ pub fn from(attributes: anytype) []const Self {
@compileError("struct needed");
}
- const fields = info.@"struct".fields;
+ const fields = info.@"struct".field_names;
var attrs: []const Self = &.{};
- for (fields) |field| {
- const name = field.name;
+ for (fields) |name| {
const value = @field(attributes, name);
const next_attr: []const Self = &.{.{ .name = name, .value = value }};