v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-display-names.h
Go to the documentation of this file.
1// Copyright 2019 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_DISPLAY_NAMES_H_
6#define V8_OBJECTS_JS_DISPLAY_NAMES_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
16#include "src/heap/factory.h"
17#include "src/objects/managed.h"
18#include "src/objects/objects.h"
19
20// Has to be the last include (doesn't have include guards):
22
23namespace v8 {
24namespace internal {
25
26class DisplayNamesInternal;
27
28#include "torque-generated/src/objects/js-display-names-tq.inc"
29
31 : public TorqueGeneratedJSDisplayNames<JSDisplayNames, JSObject> {
32 public:
33 // Creates display names object with properties derived from input
34 // locales and options.
38 DirectHandle<Object> options);
39
41 Isolate* isolate, DirectHandle<JSDisplayNames> format_holder);
42
43 static MaybeDirectHandle<Object> Of(Isolate* isolate,
45 Handle<Object> code_obj);
46
47 V8_EXPORT_PRIVATE static const std::set<std::string>& GetAvailableLocales();
48
49 Handle<String> StyleAsString(Isolate* isolate) const;
52
53 // Style: identifying the display names style used.
54 //
55 // ecma402/#sec-properties-of-intl-displaynames-instances
56 enum class Style {
57 kLong, // Everything spelled out.
58 kShort, // Abbreviations used when possible.
59 kNarrow // Use the shortest possible form.
60 };
61 inline void set_style(Style style);
62 inline Style style() const;
63
64 // Type: identifying the fallback of the display names.
65 //
66 // ecma402/#sec-properties-of-intl-displaynames-instances
67 enum class Fallback {
68 kCode,
69 kNone,
70 };
71 inline void set_fallback(Fallback fallback);
72 inline Fallback fallback() const;
73
74 enum class LanguageDisplay {
77 };
79 inline LanguageDisplay language_display() const;
80
81 // Bit positions in |flags|.
82 DEFINE_TORQUE_GENERATED_JS_DISPLAY_NAMES_FLAGS()
83
84 static_assert(StyleBits::is_valid(Style::kLong));
85 static_assert(StyleBits::is_valid(Style::kShort));
86 static_assert(StyleBits::is_valid(Style::kNarrow));
87 static_assert(FallbackBit::is_valid(Fallback::kCode));
88 static_assert(FallbackBit::is_valid(Fallback::kNone));
89 static_assert(LanguageDisplayBit::is_valid(LanguageDisplay::kDialect));
90 static_assert(LanguageDisplayBit::is_valid(LanguageDisplay::kStandard));
91
93
95
97};
98
99} // namespace internal
100} // namespace v8
101
102#include "src/objects/object-macros-undef.h"
103
104#endif // V8_OBJECTS_JS_DISPLAY_NAMES_H_
void set_style(Style style)
static MaybeDirectHandle< Object > Of(Isolate *isolate, DirectHandle< JSDisplayNames > holder, Handle< Object > code_obj)
static V8_EXPORT_PRIVATE const std::set< std::string > & GetAvailableLocales()
LanguageDisplay language_display() const
Handle< String > StyleAsString(Isolate *isolate) const
DirectHandle< String > LanguageDisplayAsString(Isolate *isolate) const
Handle< String > FallbackAsString(Isolate *isolate) const
void set_language_display(LanguageDisplay language_display)
static MaybeDirectHandle< JSDisplayNames > New(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Object > locales, DirectHandle< Object > options)
static DirectHandle< JSObject > ResolvedOptions(Isolate *isolate, DirectHandle< JSDisplayNames > format_holder)
void set_fallback(Fallback fallback)
#define DECL_ACCESSORS(name,...)
#define DECL_PRINTER(Name)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define V8_EXPORT_PRIVATE
Definition macros.h:460