mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
LibJS: Convert Object::create() to NonnullGCPtr
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 03:17:23 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/ddc6e139a6 Pull-request: https://github.com/SerenityOS/serenity/pull/16479 Reviewed-by: https://github.com/davidot ✅
@@ -102,7 +102,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::stringify_impl(VM& vm, Value val
|
||||
state.gap = DeprecatedString::empty();
|
||||
}
|
||||
|
||||
auto* wrapper = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
auto wrapper = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
MUST(wrapper->create_data_property_or_throw(DeprecatedString::empty(), value));
|
||||
return serialize_json_property(vm, state, DeprecatedString::empty(), wrapper);
|
||||
}
|
||||
@@ -401,7 +401,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse)
|
||||
return vm.throw_completion<SyntaxError>(ErrorType::JsonMalformed);
|
||||
Value unfiltered = parse_json_value(vm, json.value());
|
||||
if (reviver.is_function()) {
|
||||
auto* root = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
auto root = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
auto root_name = DeprecatedString::empty();
|
||||
MUST(root->create_data_property_or_throw(root_name, unfiltered));
|
||||
return internalize_json_property(vm, root, root_name, reviver.as_function());
|
||||
@@ -431,7 +431,7 @@ Value JSONObject::parse_json_value(VM& vm, JsonValue const& value)
|
||||
Object* JSONObject::parse_json_object(VM& vm, JsonObject const& json_object)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
auto object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
json_object.for_each_member([&](auto& key, auto& value) {
|
||||
object->define_direct_property(key, parse_json_value(vm, value), default_attributes);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user