Skip to content

Commit

Permalink
Add win32 path.toNamespacedPath and align rest of node:path with Node
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Feb 12, 2024
1 parent f88855d commit 8e272e5
Show file tree
Hide file tree
Showing 41 changed files with 5,387 additions and 1,743 deletions.
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;
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()));
};
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});
}

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

0 comments on commit 8e272e5

Please sign in to comment.