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

Add win32 path.toNamespacedPath and align rest of node:path with Node #8469

Merged
merged 1 commit into from
Feb 12, 2024
Merged
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/bun.js/api/bun/spawn.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn _getSystem() type {
const Environment = bun.Environment;
const system = _getSystem();

const Maybe = JSC.Node.Maybe;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By using JSC.Maybe we can continue to associate that one with sys.Error and allow JSC.Node.Maybe to be ErrorType agnostic. Doing this is the least invasive way to allow more configurability in the Maybe.

const Maybe = JSC.Maybe;

const fd_t = std.os.fd_t;
const pid_t = std.os.pid_t;
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/api/bun/subprocess.zig
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ pub const Subprocess = struct {
return this.exit_code != null or this.signal_code != null;
}

pub fn tryKill(this: *Subprocess, sig: i32) JSC.Node.Maybe(void) {
pub fn tryKill(this: *Subprocess, sig: i32) JSC.Maybe(void) {
if (this.hasExited()) {
return .{ .result = {} };
}
Expand Down
4 changes: 1 addition & 3 deletions src/bun.js/bindings/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ JSC_DEFINE_HOST_FUNCTION(Path_functionResolve,
JSC_DEFINE_HOST_FUNCTION(Path_functionToNamespacedPath,
(JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
// TODO:
return JSC::JSValue::encode(callFrame->argument(0));
DEFINE_CALLBACK_FUNCTION_BODY(Bun__Path__toNamespacedPath);
}

static JSC::JSObject* createPath(JSGlobalObject* globalThis, bool isWindows)
Expand Down
4 changes: 4 additions & 0 deletions src/bun.js/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3316,6 +3316,10 @@ JSC__JSValue JSC__JSValue__jsDoubleNumber(double arg0)
{
return JSC::JSValue::encode(JSC::jsNumber(arg0));
}
JSC__JSValue JSC__JSValue__jsEmptyString(JSC__JSGlobalObject* arg0)
{
return JSC::JSValue::encode(JSC::jsEmptyString(arg0->vm()));
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of exposing JSC::jsEmptyString to Zig.

JSC__JSValue JSC__JSValue__jsNull() { return JSC::JSValue::encode(JSC::jsNull()); };
JSC__JSValue JSC__JSValue__jsNumberFromChar(unsigned char arg0)
{
Expand Down
29 changes: 17 additions & 12 deletions src/bun.js/bindings/bindings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,9 @@ pub const ZigString = extern struct {
if (is16Bit(&this)) {
const buffer = this.toOwnedSlice(allocator) catch unreachable;
return Slice{
.allocator = NullableAllocator.init(allocator),
.ptr = buffer.ptr,
.len = @as(u32, @truncate(buffer.len)),
.allocator = NullableAllocator.init(allocator),
};
}

Expand Down Expand Up @@ -3960,27 +3960,32 @@ pub const JSValue = enum(JSValueReprInt) {
return null;
}

pub fn jsNumber(number: anytype) JSValue {
return jsNumberWithType(@TypeOf(number), number);
pub inline fn jsBoolean(i: bool) JSValue {
return cppFn("jsBoolean", .{i});
}

pub fn jsDoubleNumber(i: f64) JSValue {
return cppFn("jsDoubleNumber", .{i});
}

pub inline fn jsEmptyString(globalThis: *JSGlobalObject) JSValue {
return cppFn("jsEmptyString", .{globalThis});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ Part of exposing JSC::jsEmptyString to Zig. (rest of code close by is just code shuffle).


pub inline fn jsNull() JSValue {
return JSValue.null;
}
pub inline fn jsUndefined() JSValue {
return JSValue.undefined;
}
pub inline fn jsBoolean(i: bool) JSValue {
const out = cppFn("jsBoolean", .{i});
return out;

pub fn jsNumber(number: anytype) JSValue {
return jsNumberWithType(@TypeOf(number), number);
}

pub fn jsTDZValue() JSValue {
pub inline fn jsTDZValue() JSValue {
return cppFn("jsTDZValue", .{});
}

pub fn jsDoubleNumber(i: f64) JSValue {
return cppFn("jsDoubleNumber", .{i});
pub inline fn jsUndefined() JSValue {
return JSValue.undefined;
}

pub fn className(this: JSValue, globalThis: *JSGlobalObject) ZigString {
Expand Down
1 change: 1 addition & 0 deletions src/bun.js/bindings/headers.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/bun.js/bindings/headers.zig

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading