Skip to content

Commit

Permalink
make it available to js
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac committed Feb 7, 2025
1 parent eb97edb commit 087e768
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 242 deletions.
6 changes: 5 additions & 1 deletion src/bun.js/api/net.classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ export default [
define({
name: "SocketAddressNew",
construct: true,
finalize: true,
finalize: false,
klass: {
isSocketAddress: {
fn: "isSocketAddress",
length: 1,
enumerable: false,
configurable: true,
},
parse: {
fn: "parse",
length: 1,
enumerable: false,
configurable: true,
},
},
proto: {
Expand Down
5 changes: 0 additions & 5 deletions src/bun.js/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4180,11 +4180,6 @@ int32_t JSC__JSValue__toInt32(JSC__JSValue JSValue0)
return JSC::JSValue::decode(JSValue0).asInt32();
}

uint32_t JSC__JSValue__toUInt32(JSC__JSValue value)
{
return JSC::JSValue::decode(value).asUInt32();
}

CPP_DECL double JSC__JSValue__coerceToDouble(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
{
ASSERT_NO_PENDING_EXCEPTION(arg1);
Expand Down
25 changes: 14 additions & 11 deletions src/bun.js/bindings/bindings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3176,17 +3176,22 @@ pub const JSGlobalObject = opaque {
return JSC.Error.ERR_INVALID_ARG_TYPE.fmt(this, fmt, args);
}

pub fn createError(
this: *JSGlobalObject,
pub const SysErrOptions = struct {
code: JSC.Node.ErrorCode,
error_name: string,
comptime message: string,
errno: ?i32 = null,
name: ?string = null,
};
pub fn throwSysError(
this: *JSGlobalObject,
opts: SysErrOptions,
comptime message: bun.stringZ,
args: anytype,
) JSValue {
) JSError {
const err = createErrorInstance(this, message, args);
err.put(this, ZigString.static("code"), ZigString.init(@tagName(code)).toJS(this));
err.put(this, ZigString.static("name"), ZigString.init(error_name).toJS(this));
return err;
err.put(this, ZigString.static("code"), ZigString.init(@tagName(opts.code)).toJS(this));
if (opts.name) |name| err.put(this, ZigString.static("name"), ZigString.init(name).toJS(this));
if (opts.errno) |errno| err.put(this, ZigString.static("errno"), JSC.toJS(this, i32, errno, .temporary));
return this.throwValue(err);
}

pub fn throw(this: *JSGlobalObject, comptime fmt: [:0]const u8, args: anytype) JSError {
Expand Down Expand Up @@ -5870,9 +5875,6 @@ pub const JSValue = enum(i64) {
}
return FFI.JSVALUE_TO_INT32(.{ .asJSValue = this });
}
pub fn asUInt32(this: JSValue) ?u32 {
return if (this.isInt32()) cppFn("toUInt32", .{this}) else null;
}

pub fn asFileDescriptor(this: JSValue) bun.FileDescriptor {
bun.assert(this.isNumber());
Expand Down Expand Up @@ -6129,6 +6131,7 @@ pub const JSValue = enum(i64) {
"toError_",
"toInt32",
"toInt64",
"toUInt32",
"toObject",
"toPropertyKeyValue",
"toString",
Expand Down
1 change: 0 additions & 1 deletion 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: 0 additions & 1 deletion src/bun.js/bindings/headers.zig

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

123 changes: 0 additions & 123 deletions src/bun.js/node/node_net.zig

This file was deleted.

Loading

0 comments on commit 087e768

Please sign in to comment.