createEmptyObjectWithNullPrototype

This commit is contained in:
Dylan Conway
2023-11-30 16:48:53 -08:00
parent 70039ff038
commit 54df5c032d
3 changed files with 7 additions and 13 deletions

View File

@@ -1601,15 +1601,10 @@ JSC__JSObject__create(JSC__JSGlobalObject* globalObject, size_t initialCapacity,
return JSC::JSValue::encode(object);
}
JSC__JSValue JSC__JSValue__constructEmptyObject(JSC__JSGlobalObject* globalObject,
JSC__JSObject* prototype,
size_t initialCapacity)
JSC__JSValue JSC__JSValue__createEmptyObjectWithNullPrototype(JSC__JSGlobalObject* globalObject)
{
if (prototype == nullptr) {
return JSC::JSValue::encode(JSC::constructEmptyObject(globalObject->vm(), globalObject->nullPrototypeObjectStructure()));
} else {
return JSC::JSValue::encode(JSC::constructEmptyObject(globalObject, prototype, std::min(static_cast<unsigned int>(initialCapacity), JSFinalObject::maxInlineCapacity)));
}
return JSValue::encode(
JSC::constructEmptyObject(globalObject->vm(), globalObject->nullPrototypeObjectStructure()));
}
JSC__JSValue JSC__JSValue__createEmptyObject(JSC__JSGlobalObject* globalObject,

View File

@@ -3555,11 +3555,10 @@ pub const JSValue = enum(JSValueReprInt) {
return JSC__jsTypeStringForValue(globalObject, this);
}
extern fn JSC__JSValue__constructEmptyObject(globalObject: *JSGlobalObject, prototype: [*c]JSC.JSObject, len: usize) JSValue;
extern fn JSC__JSValue__createEmptyObjectWithNullPrototype(globalObject: *JSGlobalObject) JSValue;
/// Creates a new empty object with the specified prototype, or no prototype if null
pub fn constructEmptyObject(global: *JSGlobalObject, prototype: ?*JSC.JSObject, len: usize) JSValue {
return JSC__JSValue__constructEmptyObject(global, prototype, len);
pub fn createEmptyObjectWithNullPrototype(global: *JSGlobalObject) JSValue {
return JSC__JSValue__createEmptyObjectWithNullPrototype(global);
}
/// Creates a new empty object, with Object as its prototype

View File

@@ -622,7 +622,7 @@ pub fn parseArgs(globalThis: *JSGlobalObject, config_obj: JSValue) !JSValue {
log("Phase 2: parse options from tokens (tokens.len={d})", .{tokens.items.len});
// note that "values" needs to have a null prototype instead of Object, to avoid issues such as "values.toString"` being defined
var result_values = JSValue.constructEmptyObject(globalThis, null, 0);
var result_values = JSValue.createEmptyObjectWithNullPrototype(globalThis);
var result_positionals = JSC.JSValue.createEmptyArray(globalThis, 0);
var result_positionals_len: u32 = 0;
for (tokens.items) |t| {