aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/bindings.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-11 19:14:34 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-11 19:14:34 -0700
commitcbb88672f217a90db1aa1eb29cd92d5d9035b22b (patch)
tree43a00501f3cde495967e116f0b660777051551f8 /src/bun.js/bindings/bindings.zig
parent1f900cff453700b19bca2acadfe26da4468c1282 (diff)
parent34b0e7a2bbd8bf8097341cdb0075d0908283e834 (diff)
downloadbun-jarred/esm-conditions.tar.gz
bun-jarred/esm-conditions.tar.zst
bun-jarred/esm-conditions.zip
Merge branch 'main' into jarred/esm-conditionsjarred/esm-conditions
Diffstat (limited to 'src/bun.js/bindings/bindings.zig')
-rw-r--r--src/bun.js/bindings/bindings.zig191
1 files changed, 125 insertions, 66 deletions
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index 35c9d26fa..7e3fa6d8e 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -291,7 +291,27 @@ pub const ZigString = extern struct {
return this.len * 2;
}
- /// Count the number of code points in the string.
+ pub fn utf16ByteLength(this: ZigString) usize {
+ if (this.isUTF8()) {
+ return bun.simdutf.length.utf16.from.utf8.le(this.slice());
+ }
+
+ if (this.is16Bit()) {
+ return this.len * 2;
+ }
+
+ return JSC.WebCore.Encoder.byteLengthU8(this.slice().ptr, this.slice().len, .utf16le);
+ }
+
+ pub fn latin1ByteLength(this: ZigString) usize {
+ if (this.isUTF8()) {
+ @panic("TODO");
+ }
+
+ return this.len;
+ }
+
+ /// Count the number of bytes in the UTF-8 version of the string.
/// This function is slow. Use maxUITF8ByteLength() to get a quick estimate
pub fn utf8ByteLength(this: ZigString) usize {
if (this.isUTF8()) {
@@ -370,11 +390,11 @@ pub const ZigString = extern struct {
}
pub fn markStatic(this: *ZigString) void {
- this.ptr = @intToPtr([*]const u8, @ptrToInt(this.ptr) | (1 << 60));
+ this.ptr = @ptrFromInt([*]const u8, @intFromPtr(this.ptr) | (1 << 60));
}
pub fn isStatic(this: *const ZigString) bool {
- return @ptrToInt(this.ptr) & (1 << 60) != 0;
+ return @intFromPtr(this.ptr) & (1 << 60) != 0;
}
pub const Slice = struct {
@@ -483,7 +503,7 @@ pub const ZigString = extern struct {
}
pub fn mut(this: Slice) []u8 {
- return @intToPtr([*]u8, @ptrToInt(this.ptr))[0..this.len];
+ return @ptrFromInt([*]u8, @intFromPtr(this.ptr))[0..this.len];
}
/// Does nothing if the slice is not allocated
@@ -504,7 +524,7 @@ pub const ZigString = extern struct {
pub const namespace = "";
pub inline fn is16Bit(this: *const ZigString) bool {
- return (@ptrToInt(this._unsafe_ptr_do_not_use) & (1 << 63)) != 0;
+ return (@intFromPtr(this._unsafe_ptr_do_not_use) & (1 << 63)) != 0;
}
pub inline fn utf16Slice(this: *const ZigString) []align(1) const u16 {
@@ -539,7 +559,7 @@ pub const ZigString = extern struct {
}
pub fn sortDesc(slice_: []ZigString) void {
- std.sort.sort(ZigString, slice_, {}, cmpDesc);
+ std.sort.block(ZigString, slice_, {}, cmpDesc);
}
pub fn cmpDesc(_: void, a: ZigString, b: ZigString) bool {
@@ -547,7 +567,7 @@ pub const ZigString = extern struct {
}
pub fn sortAsc(slice_: []ZigString) void {
- std.sort.sort(ZigString, slice_, {}, cmpAsc);
+ std.sort.block(ZigString, slice_, {}, cmpAsc);
}
pub fn cmpAsc(_: void, a: ZigString, b: ZigString) bool {
@@ -641,15 +661,15 @@ pub const ZigString = extern struct {
}
pub fn isUTF8(this: ZigString) bool {
- return (@ptrToInt(this._unsafe_ptr_do_not_use) & (1 << 61)) != 0;
+ return (@intFromPtr(this._unsafe_ptr_do_not_use) & (1 << 61)) != 0;
}
pub fn markUTF8(this: *ZigString) void {
- this._unsafe_ptr_do_not_use = @intToPtr([*]const u8, @ptrToInt(this._unsafe_ptr_do_not_use) | (1 << 61));
+ this._unsafe_ptr_do_not_use = @ptrFromInt([*]const u8, @intFromPtr(this._unsafe_ptr_do_not_use) | (1 << 61));
}
pub fn markUTF16(this: *ZigString) void {
- this._unsafe_ptr_do_not_use = @intToPtr([*]const u8, @ptrToInt(this._unsafe_ptr_do_not_use) | (1 << 63));
+ this._unsafe_ptr_do_not_use = @ptrFromInt([*]const u8, @intFromPtr(this._unsafe_ptr_do_not_use) | (1 << 63));
}
pub fn setOutputEncoding(this: *ZigString) void {
@@ -658,7 +678,7 @@ pub const ZigString = extern struct {
}
pub inline fn isGloballyAllocated(this: ZigString) bool {
- return (@ptrToInt(this._unsafe_ptr_do_not_use) & (1 << 62)) != 0;
+ return (@intFromPtr(this._unsafe_ptr_do_not_use) & (1 << 62)) != 0;
}
pub inline fn deinitGlobal(this: ZigString) void {
@@ -668,7 +688,7 @@ pub const ZigString = extern struct {
pub const mark = markGlobal;
pub inline fn markGlobal(this: *ZigString) void {
- this._unsafe_ptr_do_not_use = @intToPtr([*]const u8, @ptrToInt(this._unsafe_ptr_do_not_use) | (1 << 62));
+ this._unsafe_ptr_do_not_use = @ptrFromInt([*]const u8, @intFromPtr(this._unsafe_ptr_do_not_use) | (1 << 62));
}
pub fn format(self: ZigString, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
@@ -694,7 +714,7 @@ pub const ZigString = extern struct {
inline fn untagged(ptr: [*]const u8) [*]const u8 {
// this can be null ptr, so long as it's also a 0 length string
@setRuntimeSafety(false);
- return @intToPtr([*]const u8, @truncate(u53, @ptrToInt(ptr)));
+ return @ptrFromInt([*]const u8, @truncate(u53, @intFromPtr(ptr)));
}
pub fn slice(this: *const ZigString) []const u8 {
@@ -1303,7 +1323,7 @@ pub const FetchHeaders = opaque {
this: *FetchHeaders,
name_: HTTPHeaderName,
) bool {
- return fastHas_(this, @enumToInt(name_));
+ return fastHas_(this, @intFromEnum(name_));
}
pub fn fastGet(
@@ -1311,7 +1331,7 @@ pub const FetchHeaders = opaque {
name_: HTTPHeaderName,
) ?ZigString {
var str = ZigString.init("");
- fastGet_(this, @enumToInt(name_), &str);
+ fastGet_(this, @intFromEnum(name_), &str);
if (str.len == 0) {
return null;
}
@@ -1441,7 +1461,7 @@ pub const FetchHeaders = opaque {
this: *FetchHeaders,
header: HTTPHeaderName,
) void {
- return fastRemove_(this, @enumToInt(header));
+ return fastRemove_(this, @intFromEnum(header));
}
pub fn fastRemove_(
@@ -1561,10 +1581,10 @@ pub const FetchHeaders = opaque {
pub const SystemError = extern struct {
errno: c_int = 0,
/// label for errno
- code: ZigString = ZigString.init(""),
- message: ZigString = ZigString.init(""),
- path: ZigString = ZigString.init(""),
- syscall: ZigString = ZigString.init(""),
+ code: String = String.empty,
+ message: String = String.empty,
+ path: String = String.empty,
+ syscall: String = String.empty,
fd: i32 = -1,
pub fn Maybe(comptime Result: type) type {
@@ -1611,11 +1631,11 @@ pub const Sizes = @import("../bindings/sizes.zig");
pub const JSUint8Array = opaque {
pub const name = "Uint8Array_alias";
pub fn ptr(this: *JSUint8Array) [*]u8 {
- return @intToPtr(*[*]u8, @ptrToInt(this) + Sizes.Bun_FFI_PointerOffsetToTypedArrayVector).*;
+ return @ptrFromInt(*[*]u8, @intFromPtr(this) + Sizes.Bun_FFI_PointerOffsetToTypedArrayVector).*;
}
pub fn len(this: *JSUint8Array) usize {
- return @intToPtr(*usize, @ptrToInt(this) + Sizes.Bun_FFI_PointerOffsetToTypedArrayLength).*;
+ return @ptrFromInt(*usize, @intFromPtr(this) + Sizes.Bun_FFI_PointerOffsetToTypedArrayLength).*;
}
pub fn slice(this: *JSUint8Array) []u8 {
@@ -2045,6 +2065,9 @@ pub const JSPromise = extern struct {
pub fn isHandled(this: *const JSPromise, vm: *VM) bool {
return cppFn("isHandled", .{ this, vm });
}
+ pub fn setHandled(this: *JSPromise, vm: *VM) void {
+ cppFn("setHandled", .{ this, vm });
+ }
pub fn rejectWithCaughtException(this: *JSPromise, globalObject: *JSGlobalObject, scope: ThrowScope) void {
return cppFn("rejectWithCaughtException", .{ this, globalObject, scope });
@@ -2115,6 +2138,7 @@ pub const JSPromise = extern struct {
"asValue",
"create",
"isHandled",
+ "setHandled",
"reject",
"rejectAsHandled",
"rejectAsHandledException",
@@ -2149,6 +2173,9 @@ pub const JSInternalPromise = extern struct {
pub fn isHandled(this: *const JSInternalPromise, vm: *VM) bool {
return cppFn("isHandled", .{ this, vm });
}
+ pub fn setHandled(this: *JSInternalPromise, vm: *VM) void {
+ cppFn("setHandled", .{ this, vm });
+ }
pub fn rejectWithCaughtException(this: *JSInternalPromise, globalObject: *JSGlobalObject, scope: ThrowScope) void {
return cppFn("rejectWithCaughtException", .{ this, globalObject, scope });
@@ -2332,6 +2359,7 @@ pub const JSInternalPromise = extern struct {
"status",
"result",
"isHandled",
+ "setHandled",
"resolvedPromise",
"rejectedPromise",
"resolve",
@@ -2363,6 +2391,11 @@ pub const AnyPromise = union(enum) {
inline else => |promise| promise.isHandled(vm),
};
}
+ pub fn setHandled(this: AnyPromise, vm: *VM) void {
+ switch (this) {
+ inline else => |promise| promise.setHandled(vm),
+ }
+ }
pub fn rejectWithCaughtException(this: AnyPromise, globalObject: *JSGlobalObject, scope: ThrowScope) void {
switch (this) {
@@ -2699,6 +2732,23 @@ pub const JSGlobalObject = extern struct {
this.vm().throwError(this, this.createErrorInstance(Output.prettyFmt(fmt, false), args));
}
}
+ extern fn JSC__JSGlobalObject__queueMicrotaskCallback(*JSGlobalObject, *anyopaque, Function: *const (fn (*anyopaque) callconv(.C) void)) void;
+ pub fn queueMicrotaskCallback(
+ this: *JSGlobalObject,
+ ctx_val: anytype,
+ comptime Function: fn (ctx: @TypeOf(ctx_val)) void,
+ ) void {
+ JSC.markBinding(@src());
+ const Fn = Function;
+ const ContextType = @TypeOf(ctx_val);
+ const Wrapper = struct {
+ pub fn call(p: *anyopaque) callconv(.C) void {
+ Fn(bun.cast(ContextType, p));
+ }
+ };
+
+ JSC__JSGlobalObject__queueMicrotaskCallback(this, ctx_val, &Wrapper.call);
+ }
pub fn queueMicrotask(
this: *JSGlobalObject,
@@ -3156,7 +3206,7 @@ pub const JSValue = enum(JSValueReprInt) {
pub fn isObject(this: JSType) bool {
// inline constexpr bool isObjectType(JSType type) { return type >= ObjectType; }
- return @enumToInt(this) >= @enumToInt(JSType.Object);
+ return @intFromEnum(this) >= @intFromEnum(JSType.Object);
}
pub fn isFunction(this: JSType) bool {
@@ -3311,7 +3361,7 @@ pub const JSValue = enum(JSValueReprInt) {
};
pub inline fn cast(ptr: anytype) JSValue {
- return @intToEnum(JSValue, @bitCast(i64, @ptrToInt(ptr)));
+ return @enumFromInt(JSValue, @bitCast(i64, @intFromPtr(ptr)));
}
pub fn coerceToInt32(this: JSValue, globalThis: *JSC.JSGlobalObject) i32 {
@@ -3395,6 +3445,7 @@ pub const JSValue = enum(JSValueReprInt) {
c_int => @intCast(c_int, toInt32(this)),
?AnyPromise => asAnyPromise(this),
u52 => @truncate(u52, @intCast(u64, @max(this.toInt64(), 0))),
+ i52 => @truncate(i52, @intCast(i52, this.toInt64())),
u64 => toUInt64NoTruncate(this),
u8 => @truncate(u8, toU32(this)),
i16 => @truncate(i16, toInt32(this)),
@@ -3808,7 +3859,7 @@ pub const JSValue = enum(JSValueReprInt) {
return jsNumberFromInt32(@intCast(i32, i));
}
- return jsNumberFromDouble(@intToFloat(f64, @truncate(i52, i)));
+ return jsNumberFromDouble(@floatFromInt(f64, @truncate(i52, i)));
}
pub inline fn toJS(this: JSValue, _: *const JSGlobalObject) JSValue {
@@ -3820,7 +3871,7 @@ pub const JSValue = enum(JSValueReprInt) {
return jsNumberFromInt32(@intCast(i32, i));
}
- return jsNumberFromDouble(@intToFloat(f64, @intCast(i52, @truncate(u51, i))));
+ return jsNumberFromDouble(@floatFromInt(f64, @intCast(i52, @truncate(u51, i))));
}
pub fn coerceDoubleTruncatingIntoInt64(this: JSValue) i64 {
@@ -3834,7 +3885,7 @@ pub const JSValue = enum(JSValueReprInt) {
return if (double_value < 0) @as(i64, std.math.minInt(i64)) else @as(i64, std.math.maxInt(i64));
}
- return @floatToInt(
+ return @intFromFloat(
i64,
double_value,
);
@@ -3871,26 +3922,26 @@ pub const JSValue = enum(JSValueReprInt) {
}
pub inline fn isUndefined(this: JSValue) bool {
- return @enumToInt(this) == 0xa;
+ return @intFromEnum(this) == 0xa;
}
pub inline fn isNull(this: JSValue) bool {
- return @enumToInt(this) == 0x2;
+ return @intFromEnum(this) == 0x2;
}
pub inline fn isEmptyOrUndefinedOrNull(this: JSValue) bool {
- return switch (@enumToInt(this)) {
+ return switch (@intFromEnum(this)) {
0, 0xa, 0x2 => true,
else => false,
};
}
pub fn isUndefinedOrNull(this: JSValue) bool {
- return switch (@enumToInt(this)) {
+ return switch (@intFromEnum(this)) {
0xa, 0x2 => true,
else => false,
};
}
/// Empty as in "JSValue {}" rather than an empty string
pub inline fn isEmpty(this: JSValue) bool {
- return switch (@enumToInt(this)) {
+ return switch (@intFromEnum(this)) {
0 => true,
else => false,
};
@@ -4016,7 +4067,7 @@ pub const JSValue = enum(JSValueReprInt) {
pub inline fn isCell(this: JSValue) bool {
return switch (this) {
.zero, .undefined, .null, .true, .false => false,
- else => (@bitCast(u64, @enumToInt(this)) & FFI.NotCellMask) == 0,
+ else => (@bitCast(u64, @intFromEnum(this)) & FFI.NotCellMask) == 0,
};
}
@@ -4179,7 +4230,7 @@ pub const JSValue = enum(JSValueReprInt) {
// intended to be more lightweight than ZigString
pub fn fastGet(this: JSValue, global: *JSGlobalObject, builtin_name: BuiltinName) ?JSValue {
- const result = fastGet_(this, global, @enumToInt(builtin_name));
+ const result = fastGet_(this, global, @intFromEnum(builtin_name));
if (result == .zero) {
return null;
}
@@ -4188,7 +4239,7 @@ pub const JSValue = enum(JSValueReprInt) {
}
pub fn fastGetDirect(this: JSValue, global: *JSGlobalObject, builtin_name: BuiltinName) ?JSValue {
- const result = fastGetDirect_(this, global, @enumToInt(builtin_name));
+ const result = fastGetDirect_(this, global, @intFromEnum(builtin_name));
if (result == .zero) {
return null;
}
@@ -4243,7 +4294,7 @@ pub const JSValue = enum(JSValueReprInt) {
pub fn get(this: JSValue, global: *JSGlobalObject, property: []const u8) ?JSValue {
const value = getIfPropertyExistsImpl(this, global, property.ptr, @intCast(u32, property.len));
- return if (@enumToInt(value) != 0) value else return null;
+ return if (@intFromEnum(value) != 0) value else return null;
}
pub fn implementsToString(this: JSValue, global: *JSGlobalObject) bool {
@@ -4407,7 +4458,7 @@ pub const JSValue = enum(JSValueReprInt) {
/// This algorithm differs from the IsStrictlyEqual Algorithm by treating all NaN values as equivalent and by differentiating +0𝔽 from -0𝔽.
/// https://tc39.es/ecma262/#sec-samevalue
pub fn isSameValue(this: JSValue, other: JSValue, global: *JSGlobalObject) bool {
- return @enumToInt(this) == @enumToInt(other) or cppFn("isSameValue", .{ this, other, global });
+ return @intFromEnum(this) == @intFromEnum(other) or cppFn("isSameValue", .{ this, other, global });
}
pub fn deepEquals(this: JSValue, other: JSValue, global: *JSGlobalObject) bool {
@@ -4460,7 +4511,7 @@ pub const JSValue = enum(JSValueReprInt) {
/// Get the internal number of the `JSC::DateInstance` object
/// Returns NaN if the value is not a `JSC::DateInstance` (`Date` in JS)
- pub fn getUnixTimestamp(this: JSValue) f64 {
+ pub fn getUnixTimestamp(this: JSValue) f64 {
return cppFn("getUnixTimestamp", .{
this,
});
@@ -4492,7 +4543,7 @@ pub const JSValue = enum(JSValueReprInt) {
pub fn asNumber(this: JSValue) f64 {
if (this.isInt32()) {
- return @intToFloat(f64, this.asInt32());
+ return @floatFromInt(f64, this.asInt32());
}
if (isNumber(this)) {
@@ -4515,19 +4566,19 @@ pub const JSValue = enum(JSValueReprInt) {
}
pub fn asPtr(this: JSValue, comptime Pointer: type) *Pointer {
- return @intToPtr(*Pointer, this.asPtrAddress());
+ return @ptrFromInt(*Pointer, this.asPtrAddress());
}
pub fn fromPtrAddress(addr: anytype) JSValue {
- return jsNumber(@intToFloat(f64, @bitCast(usize, @as(usize, addr))));
+ return jsNumber(@floatFromInt(f64, @bitCast(usize, @as(usize, addr))));
}
pub fn asPtrAddress(this: JSValue) usize {
- return @bitCast(usize, @floatToInt(usize, this.asDouble()));
+ return @bitCast(usize, @intFromFloat(usize, this.asDouble()));
}
pub fn fromPtr(addr: anytype) JSValue {
- return fromPtrAddress(@ptrToInt(addr));
+ return fromPtrAddress(@intFromPtr(addr));
}
pub fn toBooleanSlow(this: JSValue, global: *JSGlobalObject) bool {
@@ -4546,13 +4597,20 @@ pub const JSValue = enum(JSValueReprInt) {
return FFI.JSVALUE_TO_BOOL(.{ .asJSValue = this });
}
+ pub inline fn asInt52(this: JSValue) i64 {
+ if (comptime bun.Environment.allow_assert) {
+ std.debug.assert(this.isNumber());
+ }
+ return @intFromFloat(i64, @max(@min(this.asDouble(), std.math.maxInt(i52)), std.math.minInt(i52)));
+ }
+
pub fn toInt32(this: JSValue) i32 {
if (this.isInt32()) {
return asInt32(this);
}
if (this.isNumber()) {
- return @truncate(i32, @floatToInt(i64, asDouble(this)));
+ return @truncate(i32, this.asInt52());
}
if (comptime bun.Environment.allow_assert) {
@@ -4570,11 +4628,11 @@ pub const JSValue = enum(JSValueReprInt) {
}
pub inline fn toU16(this: JSValue) u16 {
- return @truncate(u16, this.toU32());
+ return @truncate(u16, @max(this.toInt32(), 0));
}
pub inline fn toU32(this: JSValue) u32 {
- return @intCast(u32, @max(this.toInt32(), 0));
+ return @intCast(u32, @min(@max(this.toInt64(), 0), std.math.maxInt(u32)));
}
/// This function supports:
@@ -4591,11 +4649,11 @@ pub const JSValue = enum(JSValueReprInt) {
/// If the "length" property does not exist, this function will return 0.
pub fn getLength(this: JSValue, globalThis: *JSGlobalObject) u64 {
const len = this.getLengthIfPropertyExistsInternal(globalThis);
- if (len == std.math.f64_max) {
+ if (len == std.math.floatMax(f64)) {
return 0;
}
- return @floatToInt(u64, @max(len, 0));
+ return @intFromFloat(u64, @max(@min(len, std.math.maxInt(i52)), 0));
}
/// This function supports:
@@ -4612,11 +4670,11 @@ pub const JSValue = enum(JSValueReprInt) {
/// If the "length" property does not exist, this function will return null.
pub fn tryGetLength(this: JSValue, globalThis: *JSGlobalObject) ?f64 {
const len = this.getLengthIfPropertyExistsInternal(globalThis);
- if (len == std.math.f64_max) {
+ if (len == std.math.floatMax(f64)) {
return null;
}
- return @floatToInt(u64, @max(len, 0));
+ return @intFromFloat(u64, @max(@min(len, std.math.maxInt(i52)), 0));
}
/// Do not use this directly!
@@ -4661,15 +4719,15 @@ pub const JSValue = enum(JSValueReprInt) {
}
pub inline fn asRef(this: JSValue) C_API.JSValueRef {
- return @intToPtr(C_API.JSValueRef, @bitCast(usize, @enumToInt(this)));
+ return @ptrFromInt(C_API.JSValueRef, @bitCast(usize, @intFromEnum(this)));
}
pub inline fn c(this: C_API.JSValueRef) JSValue {
- return @intToEnum(JSValue, @bitCast(JSValue.Type, @ptrToInt(this)));
+ return @enumFromInt(JSValue, @bitCast(JSValue.Type, @intFromPtr(this)));
}
pub inline fn fromRef(this: C_API.JSValueRef) JSValue {
- return @intToEnum(JSValue, @bitCast(JSValue.Type, @ptrToInt(this)));
+ return @enumFromInt(JSValue, @bitCast(JSValue.Type, @intFromPtr(this)));
}
pub inline fn asObjectRef(this: JSValue) C_API.JSObjectRef {
@@ -4685,12 +4743,12 @@ pub const JSValue = enum(JSValueReprInt) {
}
pub inline fn asNullableVoid(this: JSValue) ?*anyopaque {
- return @intToPtr(?*anyopaque, @bitCast(usize, @enumToInt(this)));
+ return @ptrFromInt(?*anyopaque, @bitCast(usize, @intFromEnum(this)));
}
pub inline fn asVoid(this: JSValue) *anyopaque {
if (comptime bun.Environment.allow_assert) {
- if (@enumToInt(this) == 0) {
+ if (@intFromEnum(this) == 0) {
@panic("JSValue is null");
}
}
@@ -4857,7 +4915,7 @@ pub const Exception = extern struct {
pub fn create(globalObject: *JSGlobalObject, object: *JSObject, stack_capture: StackCaptureAction) *Exception {
return cppFn(
"create",
- .{ globalObject, object, @enumToInt(stack_capture) },
+ .{ globalObject, object, @intFromEnum(stack_capture) },
);
}
@@ -4893,7 +4951,7 @@ pub const VM = extern struct {
LargeHeap = 1,
};
pub fn create(heap_type: HeapType) *VM {
- return cppFn("create", .{@enumToInt(heap_type)});
+ return cppFn("create", .{@intFromEnum(heap_type)});
}
pub fn deinit(vm: *VM, global_object: *JSGlobalObject) void {
@@ -5157,16 +5215,16 @@ pub const CallFrame = opaque {
pub fn arguments(self: *const CallFrame, comptime max: usize) Arguments(max) {
const len = self.argumentsCount();
var ptr = self.argumentsPtr();
- return switch (@min(len, max)) {
+ return switch (@as(u4, @min(len, max))) {
0 => .{ .ptr = undefined, .len = 0 },
- 1 => Arguments(max).init(1, ptr),
- 2 => Arguments(max).init(@min(2, max), ptr),
- 3 => Arguments(max).init(@min(3, max), ptr),
- 4 => Arguments(max).init(@min(4, max), ptr),
- 5 => Arguments(max).init(@min(5, max), ptr),
- 6 => Arguments(max).init(@min(6, max), ptr),
- 7 => Arguments(max).init(@min(7, max), ptr),
- 8 => Arguments(max).init(@min(8, max), ptr),
+ 4 => Arguments(max).init(comptime @min(4, max), ptr),
+ 2 => Arguments(max).init(comptime @min(2, max), ptr),
+ 6 => Arguments(max).init(comptime @min(6, max), ptr),
+ 3 => Arguments(max).init(comptime @min(3, max), ptr),
+ 8 => Arguments(max).init(comptime @min(8, max), ptr),
+ 5 => Arguments(max).init(comptime @min(5, max), ptr),
+ 1 => Arguments(max).init(comptime @min(1, max), ptr),
+ 7 => Arguments(max).init(comptime @min(7, max), ptr),
else => unreachable,
};
}
@@ -5555,6 +5613,7 @@ pub const __DOMCall__reader_u64 = @import("../api/bun.zig").FFI.Reader.Class.fun
pub const __DOMCall__reader_intptr = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.intptr;
pub const __Crypto_getRandomValues = @import("../webcore.zig").Crypto.Class.functionDefinitions.getRandomValues;
pub const __Crypto_randomUUID = @import("../webcore.zig").Crypto.Class.functionDefinitions.randomUUID;
+pub const __Crypto_randomInt = @import("../webcore.zig").Crypto.Class.functionDefinitions.randomInt;
pub const __Crypto_timingSafeEqual = @import("../webcore.zig").Crypto.Class.functionDefinitions.timingSafeEqual;
pub const DOMCalls = .{
@import("../api/bun.zig").FFI,