From ebc64f2b4d03cc4712f3595ea4f103dac8039280 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Tue, 5 Sep 2023 05:11:39 -0800 Subject: [PATCH] zig fmt --- src/bun.js/api/bun.zig | 1 - src/bun.js/api/ffi.zig | 1 - src/bun.js/api/server.zig | 1 - src/bun.js/bindings/bindings.zig | 3 --- src/bun.js/javascript.zig | 1 - src/bun.js/node/syscall.zig | 2 +- src/c.zig | 6 +++--- src/cli.zig | 9 ++++----- src/js/out/ResolvedSourceTag.zig | 10 +++++----- src/main.zig | 8 ++------ src/string_immutable.zig | 5 ++--- src/sys.zig | 4 ++-- 12 files changed, 19 insertions(+), 32 deletions(-) diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 7e0622bdc7..ae5b000f04 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -204,7 +204,6 @@ const MarkedArrayBuffer = @import("../base.zig").MarkedArrayBuffer; const getAllocator = @import("../base.zig").getAllocator; const JSValue = @import("root").bun.JSC.JSValue; - const JSGlobalObject = @import("root").bun.JSC.JSGlobalObject; const ExceptionValueRef = @import("root").bun.JSC.ExceptionValueRef; const JSPrivateDataPtr = @import("root").bun.JSC.JSPrivateDataPtr; diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig index dd5e804180..d8a9ab4b46 100644 --- a/src/bun.js/api/ffi.zig +++ b/src/bun.js/api/ffi.zig @@ -50,7 +50,6 @@ const MarkedArrayBuffer = @import("../base.zig").MarkedArrayBuffer; const getAllocator = @import("../base.zig").getAllocator; const JSValue = @import("root").bun.JSC.JSValue; - const JSGlobalObject = @import("root").bun.JSC.JSGlobalObject; const ExceptionValueRef = @import("root").bun.JSC.ExceptionValueRef; const JSPrivateDataPtr = @import("root").bun.JSC.JSPrivateDataPtr; diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 08a2a79ba5..dd0b2580b9 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -49,7 +49,6 @@ const MarkedArrayBuffer = @import("../base.zig").MarkedArrayBuffer; const getAllocator = @import("../base.zig").getAllocator; const JSValue = @import("root").bun.JSC.JSValue; - const JSGlobalObject = @import("root").bun.JSC.JSGlobalObject; const ExceptionValueRef = @import("root").bun.JSC.ExceptionValueRef; const JSPrivateDataPtr = @import("root").bun.JSC.JSPrivateDataPtr; diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 9ca1b647cc..cd93daaddc 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -4917,9 +4917,6 @@ pub const JSValue = enum(JSValueReprInt) { extern "c" fn AsyncContextFrame__withAsyncContextIfNeeded(global: *JSGlobalObject, callback: JSValue) JSValue; - - - pub const Exception = extern struct { pub const shim = Shimmer("JSC", "Exception", @This()); bytes: shim.Bytes, diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 4559773b1f..5468043196 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -1581,7 +1581,6 @@ pub const VirtualMachine = struct { ret.path = result_path.text; } - pub fn resolveForAPI( res: *ErrorableString, global: *JSGlobalObject, diff --git a/src/bun.js/node/syscall.zig b/src/bun.js/node/syscall.zig index 9823b525f5..3db0f577ba 100644 --- a/src/bun.js/node/syscall.zig +++ b/src/bun.js/node/syscall.zig @@ -932,7 +932,7 @@ pub fn getFdPath(fd_: bun.FileDescriptor, out_buffer: *[MAX_PATH_BYTES]u8) Maybe var slash_buf: [MAX_PATH_BYTES * 2]u8 = undefined; var slash_str = bun.strings.fromWPath(&slash_buf, wide_slice); - return .{.result = bun.path.normalizeStringBuf(slash_str, out_buffer, false, .loose) }; + return .{ .result = bun.path.normalizeStringBuf(slash_str, out_buffer, false, .loose) }; }, .macos, .ios, .watchos, .tvos => { // On macOS, we can use F.GETPATH fcntl command to query the OS for diff --git a/src/c.zig b/src/c.zig index 2324d05c80..b3da68a0cc 100644 --- a/src/c.zig +++ b/src/c.zig @@ -394,7 +394,7 @@ fn _dlsym(handle: ?*anyopaque, name: [:0]const u8) ?*anyopaque { } else if (comptime Environment.isMac or Environment.isLinux) { return std.c.dlsym(handle, name.ptr); } - + return bun.todo(@src(), null); } @@ -456,7 +456,7 @@ pub extern fn fmod(f64, f64) f64; pub fn dlopen(filename: [:0]const u8, flags: i32) ?*anyopaque { if (comptime Environment.isWindows) { return bun.windows.LoadLibraryA(filename); - } + } return std.c.dlopen(filename, flags); -} \ No newline at end of file +} diff --git a/src/cli.zig b/src/cli.zig index e436d283cf..f9f82dea80 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -241,9 +241,8 @@ pub const Arguments = struct { } pub fn loadConfigPath(allocator: std.mem.Allocator, auto_loaded: bool, config_path: [:0]const u8, ctx: *Command.Context, comptime cmd: Command.Tag) !void { - - var config_file = switch (bun.sys.openA(config_path, std.os.O.RDONLY, 0)){ - .result => |fd| std.fs.File{ .handle = bun.fdcast( fd) }, + var config_file = switch (bun.sys.openA(config_path, std.os.O.RDONLY, 0)) { + .result => |fd| std.fs.File{ .handle = bun.fdcast(fd) }, .err => |err| { if (auto_loaded) return; Output.prettyErrorln("{}\nwhile opening config \"{s}\"", .{ @@ -251,7 +250,7 @@ pub const Arguments = struct { config_path, }); Global.exit(1); - } + }, }; defer config_file.close(); @@ -329,7 +328,7 @@ pub const Arguments = struct { ctx.args.absolute_working_dir = try allocator.dupe(u8, cwd); } - + var parts = [_]string{ ctx.args.absolute_working_dir.?, config_path_ }; config_path_ = resolve_path.joinAbsStringBuf( ctx.args.absolute_working_dir.?, diff --git a/src/js/out/ResolvedSourceTag.zig b/src/js/out/ResolvedSourceTag.zig index 5bc2289887..21bd8ab58b 100644 --- a/src/js/out/ResolvedSourceTag.zig +++ b/src/js/out/ResolvedSourceTag.zig @@ -61,16 +61,16 @@ pub const ResolvedSourceTag = enum(u32) { @"node:wasi" = 561, @"node:worker_threads" = 562, @"node:zlib" = 563, - @"depd" = 564, + depd = 564, @"detect-libc" = 565, @"detect-libc/linux" = 566, @"isomorphic-fetch" = 567, @"node-fetch" = 568, - @"undici" = 569, - @"vercel_fetch" = 570, - @"ws" = 571, + undici = 569, + vercel_fetch = 570, + ws = 571, // Native modules run through a different system using ESM registry. - @"bun" = 1024, + bun = 1024, @"bun:jsc" = 1025, @"node:buffer" = 1026, @"node:constants" = 1027, diff --git a/src/main.zig b/src/main.zig index 4b534aff41..abd303c74e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -18,12 +18,11 @@ pub fn main() void { const Output = bun.Output; const Environment = bun.Environment; - if (comptime Environment.isRelease) CrashReporter.start() catch unreachable; if (comptime Environment.isWindows) { std.c.environ = @ptrCast(std.os.environ.ptr); - _environ = @ptrCast( std.os.environ.ptr); + _environ = @ptrCast(std.os.environ.ptr); } bun.start_time = std.time.nanoTimestamp(); @@ -45,13 +44,10 @@ pub fn main() void { bun.CLI.Cli.start(bun.default_allocator, stdout, stderr, MainPanicHandler); } - - test "panic" { panic("woah", null); } pub const build_options = @import("build_options"); -comptime { -} \ No newline at end of file +comptime {} diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 1952fd0d8d..bb6b172e1a 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -1494,7 +1494,7 @@ pub fn toWObjectPath(wbuf: []u16, utf8: []const u8) [:0]const u16 { } wbuf[0..4].* = [_]u16{ '\\', '?', '?', '\\' }; - return wbuf[0..toWPathNormalized(wbuf[4..], utf8).len + 4:0]; + return wbuf[0 .. toWPathNormalized(wbuf[4..], utf8).len + 4 :0]; } // These are the same because they don't have rules like needing a trailing slash @@ -1551,10 +1551,9 @@ pub fn toWPathMaybeDir(wbuf: []u16, utf8: []const u8, comptime add_trailing_lash std.debug.assert(wbuf.len > 0); var result = bun.simdutf.convert.utf8.to.utf16.with_errors.le( utf8, - wbuf[0..wbuf.len -| (1 + @as(usize, @intFromBool( add_trailing_lash)))], + wbuf[0..wbuf.len -| (1 + @as(usize, @intFromBool(add_trailing_lash)))], ); - if (add_trailing_lash and result.count > 0 and wbuf[result.count - 1] != '\\') { wbuf[result.count] = '\\'; result.count += 1; diff --git a/src/sys.zig b/src/sys.zig index feab69b891..dfa908d857 100644 --- a/src/sys.zig +++ b/src/sys.zig @@ -526,7 +526,7 @@ pub fn openatOSPath(dirfd: bun.FileDescriptor, file_path: bun.OSPathSlice, flags pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: bun.Mode, perm: bun.Mode) Maybe(bun.FileDescriptor) { if (comptime Environment.isWindows) { - if (flags & O.DIRECTORY != 0) { + if (flags & O.DIRECTORY != 0) { return openDirAtWindowsA(dirfd, file_path, false, flags & O.NOFOLLOW != 0); } @@ -539,7 +539,7 @@ pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: bun.Mod pub fn openatA(dirfd: bun.FileDescriptor, file_path: []const u8, flags: bun.Mode, perm: bun.Mode) Maybe(bun.FileDescriptor) { if (comptime Environment.isWindows) { - if (flags & O.DIRECTORY != 0) { + if (flags & O.DIRECTORY != 0) { return openDirAtWindowsA(dirfd, file_path, false, flags & O.NOFOLLOW != 0); }