1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-21 07:34:08 +00:00

update to zig master

This commit is contained in:
Rene Schallner 2024-10-14 22:26:18 +02:00
parent 54c2ed64c6
commit 33a041e02c
No known key found for this signature in database
2 changed files with 15 additions and 15 deletions

View file

@ -139,7 +139,7 @@ pub const BuildResult = struct {
// See `fiobjectify` for more information. // See `fiobjectify` for more information.
pub fn build(self: *Self, data: anytype) BuildResult { pub fn build(self: *Self, data: anytype) BuildResult {
const T = @TypeOf(data); const T = @TypeOf(data);
if (@typeInfo(T) != .Struct) { if (@typeInfo(T) != .@"struct") {
@compileError("No struct: '" ++ @typeName(T) ++ "'"); @compileError("No struct: '" ++ @typeName(T) ++ "'");
} }
@ -157,29 +157,29 @@ fn fiobjectify(
) fio.FIOBJ { ) fio.FIOBJ {
const T = @TypeOf(value); const T = @TypeOf(value);
switch (@typeInfo(T)) { switch (@typeInfo(T)) {
.Float, .ComptimeFloat => { .float, .comptime_float => {
return fio.fiobj_float_new(value); return fio.fiobj_float_new(value);
}, },
.Int, .ComptimeInt => { .int, .comptime_int => {
return fio.fiobj_num_new_bignum(value); return fio.fiobj_num_new_bignum(value);
}, },
.Bool => { .bool => {
return if (value) fio.fiobj_true() else fio.fiobj_false(); return if (value) fio.fiobj_true() else fio.fiobj_false();
}, },
.Null => { .null => {
return 0; return 0;
}, },
.Optional => { .optional => {
if (value) |payload| { if (value) |payload| {
return fiobjectify(payload); return fiobjectify(payload);
} else { } else {
return fiobjectify(null); return fiobjectify(null);
} }
}, },
.Enum => { .@"enum" => {
return fio.fiobj_num_new_bignum(@intFromEnum(value)); return fio.fiobj_num_new_bignum(@intFromEnum(value));
}, },
.Union => { .@"union" => {
const info = @typeInfo(T).Union; const info = @typeInfo(T).Union;
if (info.tag_type) |UnionTagType| { if (info.tag_type) |UnionTagType| {
inline for (info.fields) |u_field| { inline for (info.fields) |u_field| {
@ -191,7 +191,7 @@ fn fiobjectify(
@compileError("Unable to fiobjectify untagged union '" ++ @typeName(T) ++ "'"); @compileError("Unable to fiobjectify untagged union '" ++ @typeName(T) ++ "'");
} }
}, },
.Struct => |S| { .@"struct" => |S| {
// create a new fio hashmap // create a new fio hashmap
const m = fio.fiobj_hash_new(); const m = fio.fiobj_hash_new();
// std.debug.print("new struct\n", .{}); // std.debug.print("new struct\n", .{});
@ -211,10 +211,10 @@ fn fiobjectify(
} }
return m; return m;
}, },
.ErrorSet => return fiobjectify(@as([]const u8, @errorName(value))), .error_set => return fiobjectify(@as([]const u8, @errorName(value))),
.Pointer => |ptr_info| switch (ptr_info.size) { .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) { .One => switch (@typeInfo(ptr_info.child)) {
.Array => { .array => {
const Slice = []const std.meta.Elem(ptr_info.child); const Slice = []const std.meta.Elem(ptr_info.child);
return fiobjectify(@as(Slice, value)); return fiobjectify(@as(Slice, value));
}, },
@ -239,8 +239,8 @@ fn fiobjectify(
}, },
else => @compileError("Unable to fiobjectify type '" ++ @typeName(T) ++ "'"), else => @compileError("Unable to fiobjectify type '" ++ @typeName(T) ++ "'"),
}, },
.Array => return fiobjectify(&value), .array => return fiobjectify(&value),
.Vector => |info| { .vector => |info| {
const array: [info.len]info.child = value; const array: [info.len]info.child = value;
return fiobjectify(&array); return fiobjectify(&array);
}, },

View file

@ -339,7 +339,7 @@ pub fn _internal_sendError(self: *const Self, err: anyerror, err_trace: ?std.bui
if (err_trace) |trace| { if (err_trace) |trace| {
const debugInfo = try std.debug.getSelfDebugInfo(); const debugInfo = try std.debug.getSelfDebugInfo();
const ttyConfig: std.io.tty.Config = .no_color; const ttyConfig: std.io.tty.Config = .no_color;
try std.debug.writeStackTrace(trace, writer, fba.allocator(), debugInfo, ttyConfig); try std.debug.writeStackTrace(trace, writer, debugInfo, ttyConfig);
} }
try self.sendBody(string.items); try self.sendBody(string.items);