Skip to content

Commit

Permalink
Rename bun.zig to BunObject.zig (#8344)
Browse files Browse the repository at this point in the history
* Rename `bun.zig` to `BunObject.zig`

* Rename `bun.classes.ts` to `BunObject.classes.ts`

* Update references to `bun.zig`

---------

Co-authored-by: Jarred Sumner <[email protected]>
  • Loading branch information
Jarred-Sumner and Jarred-Sumner authored Jan 22, 2024
1 parent c577c64 commit b7b0e28
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 28 deletions.
2 changes: 2 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const BunBuildOptions = struct {
fallback_html_version: u64 = 0,

tinycc: bool = true,
project: [:0]const u8 = "",

pub fn updateRuntime(this: *BunBuildOptions) anyerror!void {
if (std.fs.cwd().openFile("src/runtime.out.js", .{ .mode = .read_only })) |file| {
Expand Down Expand Up @@ -378,6 +379,7 @@ pub fn build_(b: *Build) !void {
actual_build_options.sizegen = true;
}

actual_build_options.project = "bun";
obj.addOptions("build_options", actual_build_options.step(b));

// Generated Code
Expand Down
5 changes: 3 additions & 2 deletions root.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub usingnamespace @import("src/main.zig");
pub usingnamespace @import("./src/main.zig");

pub const bun = @import("src/bun.zig");
/// These functions are used throughout Bun's codebase.
pub const bun = @import("./src/bun.zig");

pub const content = struct {
pub const error_js_path = "packages/bun-error/dist/index.js";
Expand Down
2 changes: 1 addition & 1 deletion src/bindgen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ pub const main = @import("./bun.js/bindings/bindings-generator.zig").main;
pub export fn PLCrashReportHandler(_: ?*anyopaque) void {}
pub export fn mkdirp(_: ?*anyopaque) void {}
pub const build_options = @import("build_options");
pub const bun = @import("./bun.zig");
pub const bun = @import("./BunObject.zig");
pub const JavaScriptCore = @import("./jsc.zig");
pub const C = @import("./c.zig");
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/bun.js/api/glob.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const Syscall = @import("../../sys.zig");
const std = @import("std");
const Allocator = std.mem.Allocator;

const bun = @import("../../bun.zig");
const BunString = @import("../../bun.zig").String;
const bun = @import("root").bun;
const BunString = bun.String;
const string = bun.string;
const JSC = bun.JSC;
const JSArray = @import("../bindings/bindings.zig").JSArray;
Expand Down
30 changes: 15 additions & 15 deletions src/bun.js/bindings/bindings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6054,22 +6054,22 @@ pub fn JSPropertyIterator(comptime options: JSPropertyIteratorOptions) type {
}

// DOMCall Fields
pub const __DOMCall_ptr = @import("../api/bun.zig").FFIObject.dom_call;
pub const __DOMCall__reader_u8 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.u8;
pub const __DOMCall__reader_u16 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.u16;
pub const __DOMCall__reader_u32 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.u32;
pub const __DOMCall__reader_ptr = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.ptr;
pub const __DOMCall__reader_i8 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.i8;
pub const __DOMCall__reader_i16 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.i16;
pub const __DOMCall__reader_i32 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.i32;
pub const __DOMCall__reader_f32 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.f32;
pub const __DOMCall__reader_f64 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.f64;
pub const __DOMCall__reader_i64 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.i64;
pub const __DOMCall__reader_u64 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.u64;
pub const __DOMCall__reader_intptr = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.intptr;
pub const __DOMCall_ptr = JSC.API.Bun.FFIObject.dom_call;
pub const __DOMCall__reader_u8 = JSC.API.Bun.FFIObject.Reader.DOMCalls.u8;
pub const __DOMCall__reader_u16 = JSC.API.Bun.FFIObject.Reader.DOMCalls.u16;
pub const __DOMCall__reader_u32 = JSC.API.Bun.FFIObject.Reader.DOMCalls.u32;
pub const __DOMCall__reader_ptr = JSC.API.Bun.FFIObject.Reader.DOMCalls.ptr;
pub const __DOMCall__reader_i8 = JSC.API.Bun.FFIObject.Reader.DOMCalls.i8;
pub const __DOMCall__reader_i16 = JSC.API.Bun.FFIObject.Reader.DOMCalls.i16;
pub const __DOMCall__reader_i32 = JSC.API.Bun.FFIObject.Reader.DOMCalls.i32;
pub const __DOMCall__reader_f32 = JSC.API.Bun.FFIObject.Reader.DOMCalls.f32;
pub const __DOMCall__reader_f64 = JSC.API.Bun.FFIObject.Reader.DOMCalls.f64;
pub const __DOMCall__reader_i64 = JSC.API.Bun.FFIObject.Reader.DOMCalls.i64;
pub const __DOMCall__reader_u64 = JSC.API.Bun.FFIObject.Reader.DOMCalls.u64;
pub const __DOMCall__reader_intptr = JSC.API.Bun.FFIObject.Reader.DOMCalls.intptr;
pub const DOMCalls = &.{
.{ .ptr = @import("../api/bun.zig").FFIObject.dom_call },
@import("../api/bun.zig").FFIObject.Reader.DOMCalls,
.{ .ptr = JSC.API.Bun.FFIObject.dom_call },
JSC.API.Bun.FFIObject.Reader.DOMCalls,
};

extern "c" fn JSCInitialize(env: [*]const [*:0]u8, count: usize, cb: *const fn ([*]const u8, len: usize) callconv(.C) void) void;
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/bindings/exports.zig
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ comptime {
@export(ErrorCode.JSErrorObject, .{ .name = "Zig_ErrorCodeJSErrorObject" });
}

const Bun = @import("../api/bun.zig");
const Bun = JSC.API.Bun;
pub const BunTimer = Bun.Timer;
pub const Formatter = ConsoleObject.Formatter;
pub const HTTPServerRequestContext = JSC.API.HTTPServer.RequestContext;
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/module_loader.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1986,7 +1986,7 @@ pub const ModuleLoader = struct {
if (!jsc_vm.origin.isEmpty()) {
writer.writeAll("export default `") catch unreachable;
// TODO: escape backtick char, though we might already do that
@import("./api/bun.zig").getPublicPath(specifier, jsc_vm.origin, @TypeOf(&writer), &writer);
JSC.API.Bun.getPublicPath(specifier, jsc_vm.origin, @TypeOf(&writer), &writer);
writer.writeAll("`;\n") catch unreachable;
} else {
writer.writeAll("export default ") catch unreachable;
Expand Down
7 changes: 7 additions & 0 deletions src/bun.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/// The functions in this file are used throughout Bun's codebase
//
// Do not import this file directly!
// To import it:
// @import("root").bun
//
// Otherwise, you risk a circular dependency or Zig including multiple copies of this file which leads to strange bugs.
const std = @import("std");
pub const Environment = @import("env.zig");

Expand Down
4 changes: 2 additions & 2 deletions src/glob.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
const std = @import("std");
const math = std.math;
const mem = std.mem;
const BunString = @import("./bun.zig").String;
const BunString = bun.String;
const expect = std.testing.expect;
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayListUnmanaged;
const ArrayListManaged = std.ArrayList;
const DirIterator = @import("./bun.js/node/dir_iterator.zig");
const bun = @import("./bun.zig");
const bun = @import("root").bun;
const Syscall = bun.sys;
const PathLike = @import("./bun.js/node/types.zig").PathLike;
const Maybe = @import("./bun.js/node/types.zig").Maybe;
Expand Down
6 changes: 3 additions & 3 deletions src/jsc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub const API = struct {
pub const DebugHTTPServer = @import("./bun.js/api/server.zig").DebugHTTPServer;
pub const DebugHTTPSServer = @import("./bun.js/api/server.zig").DebugHTTPSServer;
pub const AnyRequestContext = @import("./bun.js/api/server.zig").AnyRequestContext;
pub const Bun = @import("./bun.js/api/bun.zig");
pub const Bun = @import("./bun.js/api/BunObject.zig");
pub const FileSystemRouter = @import("./bun.js/api/filesystem_router.zig").FileSystemRouter;
pub const MatchedRoute = @import("./bun.js/api/filesystem_router.zig").MatchedRoute;
pub const TCPSocket = @import("./bun.js/api/bun/socket.zig").TCPSocket;
Expand Down Expand Up @@ -81,8 +81,8 @@ pub inline fn markBinding(src: std.builtin.SourceLocation) void {
if (comptime is_bindgen) unreachable;
__jsc_log("{s} ({s}:{d})", .{ src.fn_name, src.file, src.line });
}
pub const Subprocess = @import("./bun.js/api/bun.zig").Subprocess;
pub const ResourceUsage = @import("./bun.js/api/bun.zig").ResourceUsage;
pub const Subprocess = API.Bun.Subprocess;
pub const ResourceUsage = API.Bun.ResourceUsage;

/// Generated code! To regenerate, run:
///
Expand Down
3 changes: 2 additions & 1 deletion src/sha.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const BoringSSL = @import("root").bun.BoringSSL;
const std = @import("std");
pub const bun = @import("./bun.zig");

pub const bun = if (@import("build_options").project.len == 0) @import("./bun.zig") else @import("root").bun;

fn NewHasher(comptime digest_size: comptime_int, comptime ContextType: type, comptime Full: anytype, comptime Init: anytype, comptime Update: anytype, comptime Final: anytype) type {
return struct {
Expand Down

0 comments on commit b7b0e28

Please sign in to comment.