v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-plural-rules.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_PLURAL_RULES_H_
6#define V8_OBJECTS_JS_PLURAL_RULES_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"
19#include "src/objects/managed.h"
20#include "src/objects/objects.h"
21
22// Has to be the last include (doesn't have include guards):
24
25namespace U_ICU_NAMESPACE {
26class PluralRules;
27namespace number {
28class LocalizedNumberFormatter;
29class LocalizedNumberRangeFormatter;
30} // namespace number
31} // namespace U_ICU_NAMESPACE
32
33namespace v8 {
34namespace internal {
35
36#include "torque-generated/src/objects/js-plural-rules-tq.inc"
37
39 : public TorqueGeneratedJSPluralRules<JSPluralRules, JSObject> {
40 public:
42 Isolate* isolate, DirectHandle<Map> map, DirectHandle<Object> locales,
43 DirectHandle<Object> options);
44
46 Isolate* isolate, DirectHandle<JSPluralRules> plural_rules);
47
49 Isolate* isolate, DirectHandle<JSPluralRules> plural_rules,
50 double number);
51
53 Isolate* isolate, DirectHandle<JSPluralRules> plural_rules, double x,
54 double y);
55
56 V8_EXPORT_PRIVATE static const std::set<std::string>& GetAvailableLocales();
57
58 // [[Type]] is one of the values "cardinal" or "ordinal",
59 // identifying the plural rules used.
60 enum class Type { CARDINAL, ORDINAL };
61 inline void set_type(Type type);
62 inline Type type() const;
63
64 Handle<String> TypeAsString(Isolate* isolate) const;
65
67
68 // Bit positions in |flags|.
69 DEFINE_TORQUE_GENERATED_JS_PLURAL_RULES_FLAGS()
70
71 static_assert(TypeBit::is_valid(Type::CARDINAL));
72 static_assert(TypeBit::is_valid(Type::ORDINAL));
73
74 DECL_ACCESSORS(icu_plural_rules, Tagged<Managed<icu::PluralRules>>)
76 Tagged<Managed<icu::number::LocalizedNumberFormatter>>)
77
79};
80
81} // namespace internal
82} // namespace v8
83
84#include "src/objects/object-macros-undef.h"
85
86#endif // V8_OBJECTS_JS_PLURAL_RULES_H_
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > ResolvePlural(Isolate *isolate, DirectHandle< JSPluralRules > plural_rules, double number)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > ResolvePluralRange(Isolate *isolate, DirectHandle< JSPluralRules > plural_rules, double x, double y)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSPluralRules > New(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Object > locales, DirectHandle< Object > options)
Handle< String > TypeAsString(Isolate *isolate) const
static DirectHandle< JSObject > ResolvedOptions(Isolate *isolate, DirectHandle< JSPluralRules > plural_rules)
static V8_EXPORT_PRIVATE const std::set< std::string > & GetAvailableLocales()
int x
#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