mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:48:11 +00:00
LibJS: Implement a nearly empty Intl.ListFormat object
This adds plumbing for the Intl.ListFormat object, constructor, and prototype.
This commit is contained in:
parent
4ad2159812
commit
8e75e5fabb
12 changed files with 279 additions and 0 deletions
53
Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h
Normal file
53
Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Tim Flynn <trflynn89@pm.me>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS::Intl {
|
||||
|
||||
class ListFormat final : public Object {
|
||||
JS_OBJECT(ListFormat, Object);
|
||||
|
||||
public:
|
||||
enum class Type {
|
||||
Invalid,
|
||||
Conjunction,
|
||||
Disjunction,
|
||||
Unit,
|
||||
};
|
||||
|
||||
enum class Style {
|
||||
Invalid,
|
||||
Narrow,
|
||||
Short,
|
||||
Long,
|
||||
};
|
||||
|
||||
ListFormat(Object& prototype);
|
||||
virtual ~ListFormat() override = default;
|
||||
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
|
||||
Type type() const { return m_type; }
|
||||
void set_type(StringView type);
|
||||
StringView type_string() const;
|
||||
|
||||
Style style() const { return m_style; }
|
||||
void set_style(StringView style);
|
||||
StringView style_string() const;
|
||||
|
||||
private:
|
||||
String m_locale; // [[Locale]]
|
||||
Type m_type { Type::Invalid }; // [[Type]]
|
||||
Style m_style { Style::Invalid }; // [[Style]]
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue