LibJS: Convert Intl::DateTimeFormatFunction::create() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-13 20:49:50 +00:00
parent 46acce5142
commit 81d5bbcb04
Notes: sideshowbarker 2024-07-17 22:01:16 +09:00
3 changed files with 4 additions and 4 deletions

View file

@ -14,9 +14,9 @@
namespace JS::Intl {
// 11.5.5 DateTime Format Functions, https://tc39.es/ecma402/#sec-datetime-format-functions
DateTimeFormatFunction* DateTimeFormatFunction::create(Realm& realm, DateTimeFormat& date_time_format)
NonnullGCPtr<DateTimeFormatFunction> DateTimeFormatFunction::create(Realm& realm, DateTimeFormat& date_time_format)
{
return realm.heap().allocate<DateTimeFormatFunction>(realm, date_time_format, *realm.intrinsics().function_prototype());
return *realm.heap().allocate<DateTimeFormatFunction>(realm, date_time_format, *realm.intrinsics().function_prototype());
}
DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype)

View file

@ -16,7 +16,7 @@ class DateTimeFormatFunction final : public NativeFunction {
JS_OBJECT(DateTimeFormatFunction, NativeFunction);
public:
static DateTimeFormatFunction* create(Realm&, DateTimeFormat&);
static NonnullGCPtr<DateTimeFormatFunction> create(Realm&, DateTimeFormat&);
virtual ~DateTimeFormatFunction() override = default;
virtual void initialize(Realm&) override;

View file

@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format)
if (!date_time_format->bound_format()) {
// a. Let F be a new built-in function object as defined in DateTime Format Functions (11.1.6).
// b. Set F.[[DateTimeFormat]] to dtf.
auto* bound_format = DateTimeFormatFunction::create(realm, *date_time_format);
auto bound_format = DateTimeFormatFunction::create(realm, *date_time_format);
// c. Set dtf.[[BoundFormat]] to F.
date_time_format->set_bound_format(bound_format);