summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-09-13 18:35:58 +0100
committerLinus Groh <mail@linusgroh.de>2021-09-13 19:07:26 +0100
commit297bf19508cca57345ccd00b4ec4f1b5855e8183 (patch)
tree244a3892982a1edf094fbc5e54be71c043a9a8a2 /Userland/Libraries/LibJS
parentfdd26567c11f4e69b315ac7be8b7b9114c24af8b (diff)
downloadserenity-297bf19508cca57345ccd00b4ec4f1b5855e8183.zip
LibJS: Convert Temporal.TimeZone.prototype to be a PrototypeObject
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp21
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h7
2 files changed, 8 insertions, 20 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp
index f86a627788..60e7b26edb 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 11.4 Properties of the Temporal.TimeZone Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-timezone-prototype-object
TimeZonePrototype::TimeZonePrototype(GlobalObject& global_object)
- : Object(*global_object.object_prototype())
+ : PrototypeObject(*global_object.object_prototype())
{
}
@@ -38,19 +38,6 @@ void TimeZonePrototype::initialize(GlobalObject& global_object)
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.TimeZone"), Attribute::Configurable);
}
-static TimeZone* 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 {};
- if (!is<TimeZone>(this_object)) {
- vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.TimeZone");
- return {};
- }
- return static_cast<TimeZone*>(this_object);
-}
-
// 11.4.3 get Temporal.TimeZone.prototype.id, https://tc39.es/proposal-temporal/#sec-get-temporal.timezone.prototype.id
JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::id_getter)
{
@@ -66,7 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_nanoseconds_for)
{
// 1. Let timeZone be the this value.
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
- auto* time_zone = typed_this(global_object);
+ auto* time_zone = typed_this_object(global_object);
if (vm.exception())
return {};
@@ -88,7 +75,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_string_for)
{
// 1. Let timeZone be the this value.
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
- auto* time_zone = typed_this(global_object);
+ auto* time_zone = typed_this_object(global_object);
if (vm.exception())
return {};
@@ -129,7 +116,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_string)
{
// 1. Let timeZone be the this value.
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
- auto* time_zone = typed_this(global_object);
+ auto* time_zone = typed_this_object(global_object);
if (vm.exception())
return {};
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h
index 1a95ca42f7..3137cb5ee3 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h
@@ -6,12 +6,13 @@
#pragma once
-#include <LibJS/Runtime/Object.h>
+#include <LibJS/Runtime/PrototypeObject.h>
+#include <LibJS/Runtime/Temporal/TimeZone.h>
namespace JS::Temporal {
-class TimeZonePrototype final : public Object {
- JS_OBJECT(TimeZonePrototype, Object);
+class TimeZonePrototype final : public PrototypeObject<TimeZonePrototype, TimeZone> {
+ JS_PROTOTYPE_OBJECT(TimeZonePrototype, TimeZone, Temporal.TimeZone);
public:
explicit TimeZonePrototype(GlobalObject&);