mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
safety: a lot more exception checker progress (#20817)
This commit is contained in:
@@ -841,17 +841,17 @@ pub const String = extern struct {
|
||||
extern fn BunString__toWTFString(this: *String) void;
|
||||
extern fn BunString__createUTF8ForJS(globalObject: *JSC.JSGlobalObject, ptr: [*]const u8, len: usize) JSC.JSValue;
|
||||
|
||||
pub fn createUTF8ForJS(globalObject: *JSC.JSGlobalObject, utf8_slice: []const u8) JSC.JSValue {
|
||||
pub fn createUTF8ForJS(globalObject: *JSC.JSGlobalObject, utf8_slice: []const u8) bun.JSError!JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
return BunString__createUTF8ForJS(globalObject, utf8_slice.ptr, utf8_slice.len);
|
||||
return bun.jsc.fromJSHostCall(globalObject, @src(), BunString__createUTF8ForJS, .{ globalObject, utf8_slice.ptr, utf8_slice.len });
|
||||
}
|
||||
|
||||
pub fn createFormatForJS(globalObject: *JSC.JSGlobalObject, comptime fmt: [:0]const u8, args: anytype) JSC.JSValue {
|
||||
pub fn createFormatForJS(globalObject: *JSC.JSGlobalObject, comptime fmt: [:0]const u8, args: anytype) bun.JSError!JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
var builder = std.ArrayList(u8).init(bun.default_allocator);
|
||||
defer builder.deinit();
|
||||
builder.writer().print(fmt, args) catch bun.outOfMemory();
|
||||
return BunString__createUTF8ForJS(globalObject, builder.items.ptr, builder.items.len);
|
||||
return bun.jsc.fromJSHostCall(globalObject, @src(), BunString__createUTF8ForJS, .{ globalObject, builder.items.ptr, builder.items.len });
|
||||
}
|
||||
|
||||
pub fn parseDate(this: *String, globalObject: *JSC.JSGlobalObject) f64 {
|
||||
@@ -1217,15 +1217,15 @@ pub const SliceWithUnderlyingString = struct {
|
||||
try writer.writeAll(self.utf8.slice());
|
||||
}
|
||||
|
||||
pub fn toJS(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
pub fn toJS(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject) bun.JSError!JSC.JSValue {
|
||||
return this.toJSWithOptions(globalObject, false);
|
||||
}
|
||||
|
||||
pub fn transferToJS(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
pub fn transferToJS(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject) bun.JSError!JSC.JSValue {
|
||||
return this.toJSWithOptions(globalObject, true);
|
||||
}
|
||||
|
||||
fn toJSWithOptions(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject, transfer: bool) JSC.JSValue {
|
||||
fn toJSWithOptions(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject, transfer: bool) bun.JSError!JSC.JSValue {
|
||||
if ((this.underlying.tag == .Dead or this.underlying.tag == .Empty) and this.utf8.length() > 0) {
|
||||
if (comptime bun.Environment.allow_assert) {
|
||||
if (this.utf8.allocator.get()) |allocator| {
|
||||
|
||||
Reference in New Issue
Block a user