v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-list-format.h
Go to the documentation of this file.
1// Copyright 2018 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_OBJECTS_JS_LIST_FORMAT_H_
6#define V8_OBJECTS_JS_LIST_FORMAT_H_
7
8#ifndef V8_INTL_SUPPORT
9#error Internationalization is expected to be enabled.
10#endif // V8_INTL_SUPPORT
11
12#include <set>
13#include <string>
14
15#include "src/base/bit-field.h"
17#include "src/heap/factory.h"
18#include "src/objects/managed.h"
19#include "src/objects/objects.h"
20#include "unicode/uversion.h"
21
22// Has to be the last include (doesn't have include guards):
24
25namespace U_ICU_NAMESPACE {
26class ListFormatter;
27} // namespace U_ICU_NAMESPACE
28
29namespace v8 {
30namespace internal {
31
32#include "torque-generated/src/objects/js-list-format-tq.inc"
33
35 : public TorqueGeneratedJSListFormat<JSListFormat, JSObject> {
36 public:
37 // Creates relative time format object with properties derived from input
38 // locales and options.
42 DirectHandle<Object> options);
43
45 Isolate* isolate, DirectHandle<JSListFormat> format_holder);
46
47 // ecma402 #sec-formatlist
49 Isolate* isolate, DirectHandle<JSListFormat> format_holder,
51
52 // ecma42 #sec-formatlisttoparts
54 Isolate* isolate, DirectHandle<JSListFormat> format_holder,
56
57 V8_EXPORT_PRIVATE static const std::set<std::string>& GetAvailableLocales();
58
59 Handle<String> StyleAsString(Isolate* isolate) const;
60 Handle<String> TypeAsString(Isolate* isolate) const;
61
62 // ListFormat accessors.
64
65 // Style: identifying the relative time format style used.
66 //
67 // ecma402/#sec-properties-of-intl-listformat-instances
68 enum class Style {
69 LONG, // Everything spelled out.
70 SHORT, // Abbreviations used when possible.
71 NARROW // Use the shortest possible form.
72 };
73 inline void set_style(Style style);
74 inline Style style() const;
75
76 // Type: identifying the list of types used.
77 //
78 // ecma402/#sec-properties-of-intl-listformat-instances
79 enum class Type {
80 CONJUNCTION, // for "and"-based lists (e.g., "A, B and C")
81 DISJUNCTION, // for "or"-based lists (e.g., "A, B or C"),
82 UNIT // for lists of values with units (e.g., "5 pounds, 12 ounces").
83 };
84 inline void set_type(Type type);
85 inline Type type() const;
86
87 // Bit positions in |flags|.
88 DEFINE_TORQUE_GENERATED_JS_LIST_FORMAT_FLAGS()
89
90 static_assert(StyleBits::is_valid(Style::LONG));
91 static_assert(StyleBits::is_valid(Style::SHORT));
92 static_assert(StyleBits::is_valid(Style::NARROW));
93 static_assert(TypeBits::is_valid(Type::CONJUNCTION));
94 static_assert(TypeBits::is_valid(Type::DISJUNCTION));
95 static_assert(TypeBits::is_valid(Type::UNIT));
96
98
100};
101
102} // namespace internal
103} // namespace v8
104
105#include "src/objects/object-macros-undef.h"
106
107#endif // V8_OBJECTS_JS_LIST_FORMAT_H_
static DirectHandle< JSObject > ResolvedOptions(Isolate *isolate, DirectHandle< JSListFormat > format_holder)
void set_style(Style style)
Handle< String > StyleAsString(Isolate *isolate) const
static MaybeDirectHandle< JSListFormat > New(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Object > locales, DirectHandle< Object > options)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > FormatList(Isolate *isolate, DirectHandle< JSListFormat > format_holder, DirectHandle< FixedArray > list)
Handle< String > TypeAsString(Isolate *isolate) const
static V8_EXPORT_PRIVATE const std::set< std::string > & GetAvailableLocales()
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSArray > FormatListToParts(Isolate *isolate, DirectHandle< JSListFormat > format_holder, DirectHandle< FixedArray > list)
#define DECL_ACCESSORS(name,...)
#define DECL_PRINTER(Name)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671
long LONG