Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Zig master for 0.14.0 #135

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/middleware.zig
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn EndpointHandler(comptime HandlerType: anytype, comptime ContextType: anyt
pub fn onRequest(handler: *HandlerType, r: zap.Request, context: *ContextType) bool {
const self: *Self = @fieldParentPtr("handler", handler);
r.setUserContext(context);
if (self.options.checkPath and
if (!self.options.checkPath or
std.mem.startsWith(u8, r.path orelse "", self.endpoint.settings.path))
{
self.endpoint.onRequest(r);
Expand Down
28 changes: 14 additions & 14 deletions src/mustache.zig
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub const BuildResult = struct {
// See `fiobjectify` for more information.
pub fn build(self: *Self, data: anytype) BuildResult {
const T = @TypeOf(data);
if (@typeInfo(T) != .Struct) {
if (@typeInfo(T) != .@"struct") {
@compileError("No struct: '" ++ @typeName(T) ++ "'");
}

Expand All @@ -157,29 +157,29 @@ fn fiobjectify(
) fio.FIOBJ {
const T = @TypeOf(value);
switch (@typeInfo(T)) {
.Float, .ComptimeFloat => {
.float, .comptime_float => {
return fio.fiobj_float_new(value);
},
.Int, .ComptimeInt => {
.int, .comptime_int => {
return fio.fiobj_num_new_bignum(value);
},
.Bool => {
.bool => {
return if (value) fio.fiobj_true() else fio.fiobj_false();
},
.Null => {
.null => {
return 0;
},
.Optional => {
.optional => {
if (value) |payload| {
return fiobjectify(payload);
} else {
return fiobjectify(null);
}
},
.Enum => {
.@"enum" => {
return fio.fiobj_num_new_bignum(@intFromEnum(value));
},
.Union => {
.@"union" => {
const info = @typeInfo(T).Union;
if (info.tag_type) |UnionTagType| {
inline for (info.fields) |u_field| {
Expand All @@ -191,7 +191,7 @@ fn fiobjectify(
@compileError("Unable to fiobjectify untagged union '" ++ @typeName(T) ++ "'");
}
},
.Struct => |S| {
.@"struct" => |S| {
// create a new fio hashmap
const m = fio.fiobj_hash_new();
// std.debug.print("new struct\n", .{});
Expand All @@ -211,10 +211,10 @@ fn fiobjectify(
}
return m;
},
.ErrorSet => return fiobjectify(@as([]const u8, @errorName(value))),
.Pointer => |ptr_info| switch (ptr_info.size) {
.error_set => return fiobjectify(@as([]const u8, @errorName(value))),
.pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
.Array => {
.array => {
const Slice = []const std.meta.Elem(ptr_info.child);
return fiobjectify(@as(Slice, value));
},
Expand All @@ -239,8 +239,8 @@ fn fiobjectify(
},
else => @compileError("Unable to fiobjectify type '" ++ @typeName(T) ++ "'"),
},
.Array => return fiobjectify(&value),
.Vector => |info| {
.array => return fiobjectify(&value),
.vector => |info| {
const array: [info.len]info.child = value;
return fiobjectify(&array);
},
Expand Down
2 changes: 1 addition & 1 deletion src/request.zig
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ pub fn _internal_sendError(self: *const Self, err: anyerror, err_trace: ?std.bui
if (err_trace) |trace| {
const debugInfo = try std.debug.getSelfDebugInfo();
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);
Expand Down
Loading