diff options
author | Linus Groh <mail@linusgroh.de> | 2021-09-13 18:08:56 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-13 19:07:26 +0100 |
commit | 8253e1481823e462fcfa325259df2729cadfc954 (patch) | |
tree | ebf142abf83227d2888833ebc176569dca93b6ac /Userland/Libraries/LibJS | |
parent | b0c1179ff82ed43b3d57d7a147e5bf4187ae11f8 (diff) | |
download | serenity-8253e1481823e462fcfa325259df2729cadfc954.zip |
LibJS: Convert Intl.NumberFormat.prototype to be a PrototypeObject
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp | 20 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h | 7 |
2 files changed, 6 insertions, 21 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp index cb3477d1b3..40f7d7e4f9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp @@ -11,25 +11,9 @@ namespace JS::Intl { -static NumberFormat* typed_this(GlobalObject& global_object) -{ - auto& vm = global_object.vm(); - - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return nullptr; - - if (!is<NumberFormat>(this_object)) { - vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Intl.NumberFormat"); - return nullptr; - } - - return static_cast<NumberFormat*>(this_object); -} - // 15.4 Properties of the Intl.NumberFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-numberformat-prototype-object NumberFormatPrototype::NumberFormatPrototype(GlobalObject& global_object) - : Object(*global_object.object_prototype()) + : PrototypeObject(*global_object.object_prototype()) { } @@ -53,7 +37,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options) // 2. If the implementation supports the normative optional constructor mode of 4.3 Note 1, then // a. Set nf to ? UnwrapNumberFormat(nf). // 3. Perform ? RequireInternalSlot(nf, [[InitializedNumberFormat]]). - auto* number_format = typed_this(global_object); + auto* number_format = typed_this_object(global_object); if (vm.exception()) return {}; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h index f392ab7824..16a7408c58 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h @@ -6,12 +6,13 @@ #pragma once -#include <LibJS/Runtime/Object.h> +#include <LibJS/Runtime/Intl/NumberFormat.h> +#include <LibJS/Runtime/PrototypeObject.h> namespace JS::Intl { -class NumberFormatPrototype final : public Object { - JS_OBJECT(NumberFormatPrototype, Object); +class NumberFormatPrototype final : public PrototypeObject<NumberFormatPrototype, NumberFormat> { + JS_PROTOTYPE_OBJECT(NumberFormatPrototype, NumberFormat, Intl.NumberFormat); public: explicit NumberFormatPrototype(GlobalObject&); |