A couple small zig cleanup things (#20196)

This commit is contained in:
Jarred Sumner
2025-06-05 05:11:28 -07:00
committed by GitHub
parent c82345c0a0
commit f62940bbda
2 changed files with 42 additions and 42 deletions

View File

@@ -52,7 +52,7 @@ pub fn NewIterator(comptime use_windows_ospath: bool) type {
.macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris => struct {
dir: Dir,
seek: i64,
buf: [8192]u8, // TODO align(@alignOf(os.system.dirent)),
buf: [8192]u8 align(@alignOf(std.posix.system.dirent)),
index: usize,
end_index: usize,
received_eof: bool = false,

View File

@@ -44,7 +44,7 @@ pub fn NewResponse(ssl_flag: i32) type {
}
pub fn prepareForSendfile(res: *Response) void {
return c.uws_res_prepare_for_sendfile(ssl_flag, res.downcast());
c.uws_res_prepare_for_sendfile(ssl_flag, res.downcast());
}
pub fn uncork(_: *Response) void {
@@ -316,9 +316,9 @@ pub const AnyResponse = union(enum) {
};
}
pub fn flushHeaders(this: AnyResponse) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.flushHeaders(),
};
}
}
pub fn getWriteOffset(this: AnyResponse) u64 {
return switch (this) {
@@ -333,9 +333,9 @@ pub const AnyResponse = union(enum) {
}
pub fn writeContinue(this: AnyResponse) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.writeContinue(),
};
}
}
pub fn state(this: AnyResponse) State {
@@ -359,25 +359,25 @@ pub const AnyResponse = union(enum) {
}
pub fn onData(this: AnyResponse, comptime UserDataType: type, comptime handler: fn (UserDataType, []const u8, bool) void, optional_data: UserDataType) void {
return switch (this) {
switch (this) {
inline .SSL, .TCP => |resp, ssl| resp.onData(UserDataType, struct {
pub fn onDataCallback(user_data: UserDataType, _: *uws.NewApp(ssl == .SSL).Response, data: []const u8, last: bool) void {
@call(.always_inline, handler, .{ user_data, data, last });
}
}.onDataCallback, optional_data),
};
}
}
pub fn writeStatus(this: AnyResponse, status: []const u8) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.writeStatus(status),
};
}
}
pub fn writeHeader(this: AnyResponse, key: []const u8, value: []const u8) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.writeHeader(key, value),
};
}
}
pub fn write(this: AnyResponse, data: []const u8) WriteResult {
@@ -387,9 +387,9 @@ pub const AnyResponse = union(enum) {
}
pub fn end(this: AnyResponse, data: []const u8, close_connection: bool) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.end(data, close_connection),
};
}
}
pub fn shouldCloseConnection(this: AnyResponse) bool {
@@ -405,27 +405,27 @@ pub const AnyResponse = union(enum) {
}
pub fn pause(this: AnyResponse) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.pause(),
};
}
}
pub fn @"resume"(this: AnyResponse) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.@"resume"(),
};
}
}
pub fn writeHeaderInt(this: AnyResponse, key: []const u8, value: u64) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.writeHeaderInt(key, value),
};
}
}
pub fn endWithoutBody(this: AnyResponse, close_connection: bool) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.endWithoutBody(close_connection),
};
}
}
pub fn onWritable(this: AnyResponse, comptime UserDataType: type, comptime handler: fn (UserDataType, u64, AnyResponse) bool, optional_data: UserDataType) void {
@@ -438,10 +438,10 @@ pub const AnyResponse = union(enum) {
return handler(user_data, offset, .{ .TCP = resp });
}
};
return switch (this) {
switch (this) {
.SSL => |resp| resp.onWritable(UserDataType, wrapper.ssl_handler, optional_data),
.TCP => |resp| resp.onWritable(UserDataType, wrapper.tcp_handler, optional_data),
};
}
}
pub fn onTimeout(this: AnyResponse, comptime UserDataType: type, comptime handler: fn (UserDataType, AnyResponse) void, optional_data: UserDataType) void {
@@ -454,10 +454,10 @@ pub const AnyResponse = union(enum) {
}
};
return switch (this) {
switch (this) {
.SSL => |resp| resp.onTimeout(UserDataType, wrapper.ssl_handler, optional_data),
.TCP => |resp| resp.onTimeout(UserDataType, wrapper.tcp_handler, optional_data),
};
}
}
pub fn onAborted(this: AnyResponse, comptime UserDataType: type, comptime handler: fn (UserDataType, AnyResponse) void, optional_data: UserDataType) void {
@@ -469,51 +469,51 @@ pub const AnyResponse = union(enum) {
handler(user_data, .{ .TCP = resp });
}
};
return switch (this) {
switch (this) {
.SSL => |resp| resp.onAborted(UserDataType, wrapper.ssl_handler, optional_data),
.TCP => |resp| resp.onAborted(UserDataType, wrapper.tcp_handler, optional_data),
};
}
}
pub fn clearAborted(this: AnyResponse) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.clearAborted(),
};
}
}
pub fn clearTimeout(this: AnyResponse) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.clearTimeout(),
};
}
}
pub fn clearOnWritable(this: AnyResponse) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.clearOnWritable(),
};
}
}
pub fn clearOnData(this: AnyResponse) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.clearOnData(),
};
}
}
pub fn endStream(this: AnyResponse, close_connection: bool) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.endStream(close_connection),
};
}
}
pub fn corked(this: AnyResponse, comptime handler: anytype, args_tuple: anytype) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.corked(handler, args_tuple),
};
}
}
pub fn runCorkedWithType(this: AnyResponse, comptime UserDataType: type, comptime handler: fn (UserDataType) void, optional_data: UserDataType) void {
return switch (this) {
switch (this) {
inline else => |resp| resp.runCorkedWithType(UserDataType, handler, optional_data),
};
}
}
pub fn upgrade(