Skip to content

Commit

Permalink
meta: ensure there's a single 'bun' import per file in zig (oven-sh#1…
Browse files Browse the repository at this point in the history
…0137)

* meta: ensure there's a single 'bun' import per file in zig

* undo this change in codegen
  • Loading branch information
nektro authored Apr 10, 2024
1 parent 698d0f7 commit e209ae8
Show file tree
Hide file tree
Showing 121 changed files with 461 additions and 452 deletions.
2 changes: 0 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -629,5 +629,3 @@ pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, obj_step: *
obj.link_function_sections = true;
}
}

// !
6 changes: 3 additions & 3 deletions misctools/fetch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pub usingnamespace @import("root").bun;
const clap = bun.clap;

const URL = @import("../src/url.zig").URL;
const Headers = @import("root").bun.http.Headers;
const Headers = bun.http.Headers;
const Method = @import("../src/http/method.zig").Method;
const ColonListType = @import("../src/cli/colon_list_type.zig").ColonListType;
const HeadersTuple = ColonListType(string, noop_resolver);
const path_handler = @import("../src/resolver/resolve_path.zig");
const HTTPThread = @import("root").bun.http.HTTPThread;
const HTTP = @import("root").bun.http;
const HTTPThread = bun.http.HTTPThread;
const HTTP = bun.http;
fn noop_resolver(in: string) !string {
return in;
}
Expand Down
2 changes: 1 addition & 1 deletion misctools/http_bench.zig
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub const Arguments = struct {
}
};

const HTTP = @import("root").bun.http;
const HTTP = bun.http;
const NetworkThread = HTTP.NetworkThread;

var stdout_: std.fs.File = undefined;
Expand Down
6 changes: 3 additions & 3 deletions misctools/machbench.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const C = bun.C;
const clap = @import("../src/deps/zig-clap/clap.zig");

const URL = @import("../src/url.zig").URL;
const Headers = @import("root").bun.http.Headers;
const Headers = bun.http.Headers;
const Method = @import("../src/http/method.zig").Method;
const ColonListType = @import("../src/cli/colon_list_type.zig").ColonListType;
const HeadersTuple = ColonListType(string, noop_resolver);
const path_handler = @import("../src/resolver/resolve_path.zig");
const NetworkThread = @import("root").bun.http.NetworkThread;
const HTTP = @import("root").bun.http;
const NetworkThread = bun.http.NetworkThread;
const HTTP = bun.http;
fn noop_resolver(in: string) !string {
return in;
}
Expand Down
8 changes: 4 additions & 4 deletions src/__global.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const std = @import("std");
const Environment = @import("./env.zig");

const Output = @import("output.zig");
const use_mimalloc = @import("root").bun.use_mimalloc;
const use_mimalloc = bun.use_mimalloc;
const StringTypes = @import("./string_types.zig");
const Mimalloc = @import("root").bun.Mimalloc;
const Mimalloc = bun.Mimalloc;
const bun = @import("root").bun;

const version_string = Environment.version_string;
Expand Down Expand Up @@ -61,7 +61,7 @@ else

pub inline fn getStartTime() i128 {
if (Environment.isTest) return 0;
return @import("root").bun.start_time;
return bun.start_time;
}

pub fn setThreadName(name: StringTypes.stringZ) void {
Expand Down Expand Up @@ -194,7 +194,7 @@ pub fn crash() noreturn {
}

const Global = @This();
const string = @import("root").bun.string;
const string = bun.string;

pub const BunInfo = struct {
bun_version: string,
Expand Down
2 changes: 1 addition & 1 deletion src/allocators.zig
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn OverflowGroup(comptime Block: type) type {
// ...right?
const max = 4095;
const UsedSize = std.math.IntFittingRange(0, max + 1);
const default_allocator = @import("root").bun.default_allocator;
const default_allocator = bun.default_allocator;
used: UsedSize = 0,
allocated: UsedSize = 0,
ptrs: [max]*Block = undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/analytics/analytics_thread.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const C = bun.C;

const sync = @import("../sync.zig");
const std = @import("std");
const HTTP = @import("root").bun.http;
const HTTP = bun.http;

const URL = @import("../url.zig").URL;
const Fs = @import("../fs.zig");
const Analytics = @import("./analytics_schema.zig").analytics;
const Writer = @import("./analytics_schema.zig").Writer;
const Headers = @import("root").bun.http.Headers;
const Headers = bun.http.Headers;
const Futex = @import("../futex.zig");
const Semver = @import("../install/semver.zig");

Expand Down
2 changes: 1 addition & 1 deletion src/bench/string-handling.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const strings = @import("root").bun.strings;
const strings = bun.strings;
const std = @import("std");

pub fn main() anyerror!void {
Expand Down
60 changes: 30 additions & 30 deletions src/bun.js/api/BunObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,16 @@ pub const BunObject = struct {
};

const Bun = @This();
const default_allocator = @import("root").bun.default_allocator;
const default_allocator = bun.default_allocator;
const bun = @import("root").bun;
const uv = bun.windows.libuv;
const Environment = bun.Environment;

const Global = bun.Global;
const strings = bun.strings;
const string = bun.string;
const Output = @import("root").bun.Output;
const MutableString = @import("root").bun.MutableString;
const Output = bun.Output;
const MutableString = bun.MutableString;
const std = @import("std");
const Allocator = std.mem.Allocator;
const IdentityContext = @import("../../identity_context.zig").IdentityContext;
Expand All @@ -173,7 +173,7 @@ const Resolver = @import("../../resolver/resolver.zig");
const ast = @import("../../import_record.zig");

const MacroEntryPoint = bun.bundler.MacroEntryPoint;
const logger = @import("root").bun.logger;
const logger = bun.logger;
const Api = @import("../../api/schema.zig").Api;
const options = @import("../../options.zig");
const Bundler = bun.Bundler;
Expand All @@ -184,45 +184,45 @@ const js_ast = bun.JSAst;
const NodeFallbackModules = @import("../../node_fallbacks.zig");
const ImportKind = ast.ImportKind;
const Analytics = @import("../../analytics/analytics_thread.zig");
const ZigString = @import("root").bun.JSC.ZigString;
const ZigString = bun.JSC.ZigString;
const Runtime = @import("../../runtime.zig");
const Router = @import("./filesystem_router.zig");
const ImportRecord = ast.ImportRecord;
const DotEnv = @import("../../env_loader.zig");
const ParseResult = bun.bundler.ParseResult;
const PackageJSON = @import("../../resolver/package_json.zig").PackageJSON;
const MacroRemap = @import("../../resolver/package_json.zig").MacroMap;
const WebCore = @import("root").bun.JSC.WebCore;
const WebCore = bun.JSC.WebCore;
const Request = WebCore.Request;
const Response = WebCore.Response;
const Headers = WebCore.Headers;
const Fetch = WebCore.Fetch;
const js = @import("root").bun.JSC.C;
const JSC = @import("root").bun.JSC;
const js = bun.JSC.C;
const JSC = bun.JSC;
const JSError = @import("../base.zig").JSError;

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;
const ConsoleObject = @import("root").bun.JSC.ConsoleObject;
const Node = @import("root").bun.JSC.Node;
const ZigException = @import("root").bun.JSC.ZigException;
const ZigStackTrace = @import("root").bun.JSC.ZigStackTrace;
const ErrorableResolvedSource = @import("root").bun.JSC.ErrorableResolvedSource;
const ResolvedSource = @import("root").bun.JSC.ResolvedSource;
const JSPromise = @import("root").bun.JSC.JSPromise;
const JSInternalPromise = @import("root").bun.JSC.JSInternalPromise;
const JSModuleLoader = @import("root").bun.JSC.JSModuleLoader;
const JSPromiseRejectionOperation = @import("root").bun.JSC.JSPromiseRejectionOperation;
const Exception = @import("root").bun.JSC.Exception;
const ErrorableZigString = @import("root").bun.JSC.ErrorableZigString;
const ZigGlobalObject = @import("root").bun.JSC.ZigGlobalObject;
const VM = @import("root").bun.JSC.VM;
const JSFunction = @import("root").bun.JSC.JSFunction;
const JSValue = bun.JSC.JSValue;

const JSGlobalObject = bun.JSC.JSGlobalObject;
const ExceptionValueRef = bun.JSC.ExceptionValueRef;
const JSPrivateDataPtr = bun.JSC.JSPrivateDataPtr;
const ConsoleObject = bun.JSC.ConsoleObject;
const Node = bun.JSC.Node;
const ZigException = bun.JSC.ZigException;
const ZigStackTrace = bun.JSC.ZigStackTrace;
const ErrorableResolvedSource = bun.JSC.ErrorableResolvedSource;
const ResolvedSource = bun.JSC.ResolvedSource;
const JSPromise = bun.JSC.JSPromise;
const JSInternalPromise = bun.JSC.JSInternalPromise;
const JSModuleLoader = bun.JSC.JSModuleLoader;
const JSPromiseRejectionOperation = bun.JSC.JSPromiseRejectionOperation;
const Exception = bun.JSC.Exception;
const ErrorableZigString = bun.JSC.ErrorableZigString;
const ZigGlobalObject = bun.JSC.ZigGlobalObject;
const VM = bun.JSC.VM;
const JSFunction = bun.JSC.JSFunction;
const Config = @import("../config.zig");
const URL = @import("../../url.zig").URL;
const Transpiler = bun.JSC.API.JSTranspiler;
Expand Down Expand Up @@ -3410,7 +3410,7 @@ const TOMLObject = struct {
globalThis: *JSC.JSGlobalObject,
callframe: *JSC.CallFrame,
) callconv(.C) JSC.JSValue {
var arena = @import("root").bun.ArenaAllocator.init(globalThis.allocator());
var arena = bun.ArenaAllocator.init(globalThis.allocator());
const allocator = arena.allocator();
defer arena.deinit();
var log = logger.Log.init(default_allocator);
Expand Down Expand Up @@ -3481,7 +3481,7 @@ pub const Timer = struct {
return VirtualMachine.get().timer.last_id;
}

const uws = @import("root").bun.uws;
const uws = bun.uws;

// TODO: reference count to avoid multiple Strong references to the same
// object in setInterval
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/api/JSTranspiler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Expr = JSAst.Expr;
pub usingnamespace JSC.Codegen.JSTranspiler;

bundler: Bundler.Bundler,
arena: @import("root").bun.ArenaAllocator,
arena: bun.ArenaAllocator,
transpiler_options: TranspilerOptions,
scan_pass_result: ScanPassResult,
buffer_writer: ?JSPrinter.BufferWriter = null,
Expand Down Expand Up @@ -744,7 +744,7 @@ pub fn constructor(
globalThis: *JSC.JSGlobalObject,
callframe: *JSC.CallFrame,
) callconv(.C) ?*Transpiler {
var temp = @import("root").bun.ArenaAllocator.init(getAllocator(globalThis));
var temp = bun.ArenaAllocator.init(getAllocator(globalThis));
const arguments = callframe.arguments(3);
var args = JSC.Node.ArgumentsSlice.init(
globalThis.bunVM(),
Expand Down
12 changes: 6 additions & 6 deletions src/bun.js/api/bun/dns_resolver.zig
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const Bun = @This();
const default_allocator = @import("root").bun.default_allocator;
const default_allocator = bun.default_allocator;
const bun = @import("root").bun;
const Environment = bun.Environment;

const Global = bun.Global;
const strings = bun.strings;
const string = bun.string;
const Output = @import("root").bun.Output;
const MutableString = @import("root").bun.MutableString;
const Output = bun.Output;
const MutableString = bun.MutableString;
const std = @import("std");
const Allocator = std.mem.Allocator;
const JSC = @import("root").bun.JSC;
const JSC = bun.JSC;
const JSValue = JSC.JSValue;
const JSGlobalObject = JSC.JSGlobalObject;
const c_ares = bun.c_ares;
Expand Down Expand Up @@ -330,7 +330,7 @@ pub fn addrInfoToJSArray(
globalThis: *JSC.JSGlobalObject,
) JSC.JSValue {
var stack = std.heap.stackFallback(2048, parent_allocator);
var arena = @import("root").bun.ArenaAllocator.init(stack.get());
var arena = bun.ArenaAllocator.init(stack.get());
const array = JSC.JSValue.createEmptyArray(
globalThis,
addrInfoCount(addr_info),
Expand Down Expand Up @@ -642,7 +642,7 @@ pub const GetAddrInfo = struct {
.addrinfo => |addrinfo| addrInfoToJSArray(globalThis.allocator(), addrinfo orelse return null, globalThis),
.list => |list| brk: {
var stack = std.heap.stackFallback(2048, globalThis.allocator());
var arena = @import("root").bun.ArenaAllocator.init(stack.get());
var arena = bun.ArenaAllocator.init(stack.get());
const array = JSC.JSValue.createEmptyArray(globalThis, @as(u32, @truncate(list.items.len)));
var i: u32 = 0;
const items: []const Result = list.items;
Expand Down
10 changes: 5 additions & 5 deletions src/bun.js/api/bun/socket.zig
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
const default_allocator = @import("root").bun.default_allocator;
const default_allocator = bun.default_allocator;
const bun = @import("root").bun;
const Environment = bun.Environment;

const Global = bun.Global;
const strings = bun.strings;
const string = bun.string;
const Output = @import("root").bun.Output;
const MutableString = @import("root").bun.MutableString;
const Output = bun.Output;
const MutableString = bun.MutableString;
const std = @import("std");
const Allocator = std.mem.Allocator;
const JSC = @import("root").bun.JSC;
const JSC = bun.JSC;
const JSValue = JSC.JSValue;
const JSGlobalObject = JSC.JSGlobalObject;
const Which = @import("../../../which.zig");
const uws = @import("root").bun.uws;
const uws = bun.uws;
const ZigString = JSC.ZigString;
const BoringSSL = bun.BoringSSL;
const X509 = @import("./x509.zig");
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/api/bun/spawn.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const JSC = @import("root").bun.JSC;
const JSC = bun.JSC;
const bun = @import("root").bun;
const string = bun.string;
const std = @import("std");
Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/api/bun/spawn/stdio.zig
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const Allocator = std.mem.Allocator;
const uws = bun.uws;
const std = @import("std");
const default_allocator = @import("root").bun.default_allocator;
const default_allocator = bun.default_allocator;
const bun = @import("root").bun;
const Environment = bun.Environment;
const Async = bun.Async;
const JSC = @import("root").bun.JSC;
const JSC = bun.JSC;
const JSValue = JSC.JSValue;
const JSGlobalObject = JSC.JSGlobalObject;
const Output = @import("root").bun.Output;
const Output = bun.Output;
const os = std.os;
const uv = bun.windows.libuv;
pub const Stdio = union(enum) {
Expand Down
10 changes: 5 additions & 5 deletions src/bun.js/api/bun/subprocess.zig
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const default_allocator = @import("root").bun.default_allocator;
const default_allocator = bun.default_allocator;
const bun = @import("root").bun;
const Environment = bun.Environment;

const Global = bun.Global;
const strings = bun.strings;
const string = bun.string;
const Output = @import("root").bun.Output;
const MutableString = @import("root").bun.MutableString;
const Output = bun.Output;
const MutableString = bun.MutableString;
const std = @import("std");
const Allocator = std.mem.Allocator;
const JSC = @import("root").bun.JSC;
const JSC = bun.JSC;
const JSValue = JSC.JSValue;
const JSGlobalObject = JSC.JSGlobalObject;
const Which = @import("../../../which.zig");
Expand Down Expand Up @@ -1555,7 +1555,7 @@ pub const Subprocess = struct {
secondaryArgsValue: ?JSValue,
comptime is_sync: bool,
) JSValue {
var arena = @import("root").bun.ArenaAllocator.init(bun.default_allocator);
var arena = bun.ArenaAllocator.init(bun.default_allocator);
defer arena.deinit();
var allocator = arena.allocator();

Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/api/bun/x509.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const BoringSSL = bun.BoringSSL;
const bun = @import("root").bun;
const ZigString = JSC.ZigString;
const std = @import("std");
const JSC = @import("root").bun.JSC;
const JSC = bun.JSC;
const JSValue = JSC.JSValue;
const JSGlobalObject = JSC.JSGlobalObject;

Expand Down
Loading

0 comments on commit e209ae8

Please sign in to comment.