2021-09-08 22:34:27 -03:00
|
|
|
/*
|
2022-03-15 11:58:47 -03:00
|
|
|
* Copyright (c) 2021-2022, Tim Flynn <trflynn89@serenityos.org>
|
2021-09-08 22:34:27 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-03-15 11:58:47 -03:00
|
|
|
#include <LibJS/Runtime/Intl/NumberFormat.h>
|
2021-09-08 22:34:27 -03:00
|
|
|
#include <LibJS/Runtime/NativeFunction.h>
|
|
|
|
|
|
|
|
|
|
namespace JS::Intl {
|
|
|
|
|
|
|
|
|
|
class NumberFormatConstructor final : public NativeFunction {
|
|
|
|
|
JS_OBJECT(NumberFormatConstructor, NativeFunction);
|
|
|
|
|
|
|
|
|
|
public:
|
2022-08-15 20:20:49 -03:00
|
|
|
virtual void initialize(Realm&) override;
|
2021-09-08 22:34:27 -03:00
|
|
|
virtual ~NumberFormatConstructor() override = default;
|
|
|
|
|
|
2021-10-20 17:16:30 -03:00
|
|
|
virtual ThrowCompletionOr<Value> call() override;
|
|
|
|
|
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
|
2021-09-08 22:34:27 -03:00
|
|
|
|
|
|
|
|
private:
|
2022-08-28 18:51:28 -03:00
|
|
|
explicit NumberFormatConstructor(Realm&);
|
|
|
|
|
|
2021-09-08 22:34:27 -03:00
|
|
|
virtual bool has_constructor() const override { return true; }
|
2021-09-10 12:12:05 -03:00
|
|
|
|
2021-10-22 18:49:43 -03:00
|
|
|
JS_DECLARE_NATIVE_FUNCTION(supported_locales_of);
|
2021-09-08 22:34:27 -03:00
|
|
|
};
|
|
|
|
|
|
2022-08-20 04:25:24 -03:00
|
|
|
ThrowCompletionOr<NumberFormat*> initialize_number_format(VM&, NumberFormat&, Value locales_value, Value options_value);
|
|
|
|
|
ThrowCompletionOr<void> set_number_format_digit_options(VM&, NumberFormatBase& intl_object, Object const& options, int default_min_fraction_digits, int default_max_fraction_digits, NumberFormat::Notation notation);
|
|
|
|
|
ThrowCompletionOr<void> set_number_format_unit_options(VM&, NumberFormat& intl_object, Object const& options);
|
2022-03-15 11:58:47 -03:00
|
|
|
|
2021-09-08 22:34:27 -03:00
|
|
|
}
|