-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
node:net: stub out [get|set]DefaultAutoSelectFamily[AttemptTimeout] (#…
- Loading branch information
Showing
3 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
const std = @import("std"); | ||
const bun = @import("root").bun; | ||
const Environment = bun.Environment; | ||
const JSC = bun.JSC; | ||
const string = bun.string; | ||
const Output = bun.Output; | ||
const ZigString = JSC.ZigString; | ||
|
||
// | ||
// | ||
|
||
pub var autoSelectFamilyDefault: bool = true; | ||
|
||
pub fn getDefaultAutoSelectFamily(global: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { | ||
return JSC.JSFunction.create(global, "getDefaultAutoSelectFamily", (struct { | ||
fn getter(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { | ||
_ = globalThis; | ||
_ = callframe; | ||
return JSC.jsBoolean(autoSelectFamilyDefault); | ||
} | ||
}).getter, 0, .{}); | ||
} | ||
|
||
pub fn setDefaultAutoSelectFamily(global: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { | ||
return JSC.JSFunction.create(global, "setDefaultAutoSelectFamily", (struct { | ||
fn setter(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { | ||
const arguments = callframe.arguments(1); | ||
if (arguments.len < 1) { | ||
globalThis.throw("missing argument", .{}); | ||
return .undefined; | ||
} | ||
const arg = arguments.slice()[0]; | ||
if (!arg.isBoolean()) { | ||
globalThis.throwInvalidArguments("autoSelectFamilyDefault", .{}); | ||
return .undefined; | ||
} | ||
const value = arg.toBoolean(); | ||
autoSelectFamilyDefault = value; | ||
return JSC.jsBoolean(value); | ||
} | ||
}).setter, 1, .{}); | ||
} | ||
|
||
// | ||
// | ||
|
||
pub var autoSelectFamilyAttemptTimeoutDefault: u32 = 250; | ||
|
||
pub fn getDefaultAutoSelectFamilyAttemptTimeout(global: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { | ||
return JSC.JSFunction.create(global, "getDefaultAutoSelectFamilyAttemptTimeout", (struct { | ||
fn getter(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { | ||
_ = globalThis; | ||
_ = callframe; | ||
return JSC.jsNumber(autoSelectFamilyAttemptTimeoutDefault); | ||
} | ||
}).getter, 0, .{}); | ||
} | ||
|
||
pub fn setDefaultAutoSelectFamilyAttemptTimeout(global: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { | ||
return JSC.JSFunction.create(global, "setDefaultAutoSelectFamilyAttemptTimeout", (struct { | ||
fn setter(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { | ||
const arguments = callframe.arguments(1); | ||
if (arguments.len < 1) { | ||
globalThis.throw("missing argument", .{}); | ||
return .undefined; | ||
} | ||
const arg = arguments.slice()[0]; | ||
if (!arg.isInt32AsAnyInt()) { | ||
globalThis.throwInvalidArguments("autoSelectFamilyAttemptTimeoutDefault", .{}); | ||
return .undefined; | ||
} | ||
const value: u32 = @max(10, arg.coerceToInt32(globalThis)); | ||
autoSelectFamilyAttemptTimeoutDefault = value; | ||
return JSC.jsNumber(value); | ||
} | ||
}).setter, 1, .{}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters