mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
zig: prefer .jsUndefined() over .undefined for JSValue (#20332)
This commit is contained in:
@@ -433,7 +433,7 @@ pub inline fn basenameJS_T(comptime T: type, globalObject: *JSC.JSGlobalObject,
|
||||
}
|
||||
|
||||
pub fn basename(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(JSC.conv) JSC.JSValue {
|
||||
const suffix_ptr: ?JSC.JSValue = if (args_len > 1 and args_ptr[1] != .undefined) args_ptr[1] else null;
|
||||
const suffix_ptr: ?JSC.JSValue = if (args_len > 1 and !args_ptr[1].isUndefined()) args_ptr[1] else null;
|
||||
|
||||
if (suffix_ptr) |_suffix_ptr| {
|
||||
// Supress exeption in zig. It does globalThis.vm().throwError() in JS land.
|
||||
@@ -443,7 +443,7 @@ pub fn basename(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*
|
||||
};
|
||||
}
|
||||
|
||||
const path_ptr = if (args_len > 0) args_ptr[0] else .undefined;
|
||||
const path_ptr: JSC.JSValue = if (args_len > 0) args_ptr[0] else .jsUndefined();
|
||||
// Supress exeption in zig. It does globalThis.vm().throwError() in JS land.
|
||||
validateString(globalObject, path_ptr, "path", .{}) catch {
|
||||
return .zero;
|
||||
@@ -634,7 +634,7 @@ pub inline fn dirnameJS_T(comptime T: type, globalObject: *JSC.JSGlobalObject, i
|
||||
}
|
||||
|
||||
pub fn dirname(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(JSC.conv) JSC.JSValue {
|
||||
const path_ptr = if (args_len > 0) args_ptr[0] else .undefined;
|
||||
const path_ptr: JSC.JSValue = if (args_len > 0) args_ptr[0] else .jsUndefined();
|
||||
// Supress exeption in zig. It does globalThis.vm().throwError() in JS land.
|
||||
validateString(globalObject, path_ptr, "path", .{}) catch {
|
||||
// Returning .zero translates to a nullprt JSC.JSValue.
|
||||
@@ -833,7 +833,7 @@ pub inline fn extnameJS_T(comptime T: type, globalObject: *JSC.JSGlobalObject, i
|
||||
}
|
||||
|
||||
pub fn extname(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(JSC.conv) JSC.JSValue {
|
||||
const path_ptr = if (args_len > 0) args_ptr[0] else .undefined;
|
||||
const path_ptr: JSC.JSValue = if (args_len > 0) args_ptr[0] else .jsUndefined();
|
||||
// Supress exeption in zig. It does globalThis.vm().throwError() in JS land.
|
||||
validateString(globalObject, path_ptr, "path", .{}) catch {
|
||||
// Returning .zero translates to a nullprt JSC.JSValue.
|
||||
@@ -947,7 +947,7 @@ pub fn formatJS_T(comptime T: type, globalObject: *JSC.JSGlobalObject, allocator
|
||||
}
|
||||
|
||||
pub fn format(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) bun.JSError!JSC.JSValue {
|
||||
const pathObject_ptr = if (args_len > 0) args_ptr[0] else .undefined;
|
||||
const pathObject_ptr: JSC.JSValue = if (args_len > 0) args_ptr[0] else .jsUndefined();
|
||||
// Supress exeption in zig. It does globalThis.vm().throwError() in JS land.
|
||||
validateObject(globalObject, pathObject_ptr, "pathObject", .{}, .{}) catch {
|
||||
// Returning .zero translates to a nullprt JSC.JSValue.
|
||||
@@ -1040,7 +1040,7 @@ pub fn isAbsoluteWindowsZigString(pathZStr: JSC.ZigString) bool {
|
||||
}
|
||||
|
||||
pub fn isAbsolute(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(JSC.conv) JSC.JSValue {
|
||||
const path_ptr = if (args_len > 0) args_ptr[0] else .undefined;
|
||||
const path_ptr: JSC.JSValue = if (args_len > 0) args_ptr[0] else .jsUndefined();
|
||||
// Supress exeption in zig. It does globalThis.vm().throwError() in JS land.
|
||||
validateString(globalObject, path_ptr, "path", .{}) catch {
|
||||
// Returning .zero translates to a nullprt JSC.JSValue.
|
||||
@@ -1664,7 +1664,7 @@ pub fn normalizeJS_T(comptime T: type, globalObject: *JSC.JSGlobalObject, alloca
|
||||
}
|
||||
|
||||
pub fn normalize(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(JSC.conv) JSC.JSValue {
|
||||
const path_ptr = if (args_len > 0) args_ptr[0] else .undefined;
|
||||
const path_ptr: JSC.JSValue = if (args_len > 0) args_ptr[0] else .jsUndefined();
|
||||
// Supress exeption in zig. It does globalThis.vm().throwError() in JS land.
|
||||
validateString(globalObject, path_ptr, "path", .{}) catch {
|
||||
// Returning .zero translates to a nullprt JSC.JSValue.
|
||||
@@ -1987,7 +1987,7 @@ pub inline fn parseJS_T(comptime T: type, globalObject: *JSC.JSGlobalObject, isW
|
||||
}
|
||||
|
||||
pub fn parse(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(JSC.conv) JSC.JSValue {
|
||||
const path_ptr = if (args_len > 0) args_ptr[0] else .undefined;
|
||||
const path_ptr: JSC.JSValue = if (args_len > 0) args_ptr[0] else .jsUndefined();
|
||||
// Supress exeption in zig. It does globalThis.vm().throwError() in JS land.
|
||||
validateString(globalObject, path_ptr, "path", .{}) catch {
|
||||
// Returning .zero translates to a nullprt JSC.JSValue.
|
||||
@@ -2348,13 +2348,13 @@ pub fn relativeJS_T(comptime T: type, globalObject: *JSC.JSGlobalObject, allocat
|
||||
}
|
||||
|
||||
pub fn relative(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(JSC.conv) JSC.JSValue {
|
||||
const from_ptr = if (args_len > 0) args_ptr[0] else .undefined;
|
||||
const from_ptr: JSC.JSValue = if (args_len > 0) args_ptr[0] else .jsUndefined();
|
||||
// Supress exeption in zig. It does globalThis.vm().throwError() in JS land.
|
||||
validateString(globalObject, from_ptr, "from", .{}) catch {
|
||||
// Returning .zero translates to a nullprt JSC.JSValue.
|
||||
return .zero;
|
||||
};
|
||||
const to_ptr = if (args_len > 1) args_ptr[1] else .undefined;
|
||||
const to_ptr: JSC.JSValue = if (args_len > 1) args_ptr[1] else .jsUndefined();
|
||||
// Supress exeption in zig. It does globalThis.vm().throwError() in JS land.
|
||||
validateString(globalObject, to_ptr, "to", .{}) catch {
|
||||
return .zero;
|
||||
@@ -2940,7 +2940,7 @@ pub fn toNamespacedPathJS_T(comptime T: type, globalObject: *JSC.JSGlobalObject,
|
||||
}
|
||||
|
||||
pub fn toNamespacedPath(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(JSC.conv) JSC.JSValue {
|
||||
if (args_len == 0) return .undefined;
|
||||
if (args_len == 0) return .jsUndefined();
|
||||
var path_ptr = args_ptr[0];
|
||||
|
||||
// Based on Node v21.6.1 path.win32.toNamespacedPath and path.posix.toNamespacedPath:
|
||||
|
||||
Reference in New Issue
Block a user