v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-duration-format-inl.h
Go to the documentation of this file.
1// Copyright 2022 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_DURATION_FORMAT_INL_H_
6#define V8_OBJECTS_JS_DURATION_FORMAT_INL_H_
7
8#ifndef V8_INTL_SUPPORT
9#error Internationalization is expected to be enabled.
10#endif // V8_INTL_SUPPORT
11
13// Include the non-inl header before the rest of the headers.
14
16
17// Has to be the last include (doesn't have include guards):
19
20namespace v8 {
21namespace internal {
22
23#include "torque-generated/src/objects/js-duration-format-tq-inl.inc"
24
25TQ_OBJECT_CONSTRUCTORS_IMPL(JSDurationFormat)
26
27ACCESSORS(JSDurationFormat, icu_locale, Tagged<Managed<icu::Locale>>,
28 kIcuLocaleOffset)
29
30#define IMPL_INLINE_SETTER_GETTER(T, n, B, f, M) \
31 inline void JSDurationFormat::set_##n(T value) { \
32 DCHECK(B::is_valid(value)); \
33 DCHECK_GE(T::M, value); \
34 set_##f(B::update(f(), value)); \
35 } \
36 inline JSDurationFormat::T JSDurationFormat::n() const { \
37 return B::decode(f()); \
38 }
39
40#define IMPL_INLINE_DISPLAY_SETTER_GETTER(f, R) \
41 IMPL_INLINE_SETTER_GETTER(Display, f##_display, R##DisplayBit, \
42 display_flags, kAlways)
43
44#define IMPL_INLINE_FIELD_STYLE3_SETTER_GETTER(f, R) \
45 IMPL_INLINE_SETTER_GETTER(FieldStyle, f##_style, R##StyleBits, style_flags, \
46 kStyle3Max)
47
48#define IMPL_INLINE_FIELD_STYLE4_SETTER_GETTER(f, R) \
49 IMPL_INLINE_SETTER_GETTER(FieldStyle, f##_style, R##StyleBits, style_flags, \
50 kStyle4Max)
51
52#define IMPL_INLINE_FIELD_STYLE5_SETTER_GETTER(f, R) \
53 IMPL_INLINE_SETTER_GETTER(FieldStyle, f##_style, R##StyleBits, style_flags, \
54 kStyle5Max)
55
63IMPL_INLINE_DISPLAY_SETTER_GETTER(milliseconds, Milliseconds)
64IMPL_INLINE_DISPLAY_SETTER_GETTER(microseconds, Microseconds)
66
67IMPL_INLINE_SETTER_GETTER(Style, style, StyleBits, style_flags, kDigital)
69 kMax)
70
78IMPL_INLINE_FIELD_STYLE4_SETTER_GETTER(milliseconds, Milliseconds)
79IMPL_INLINE_FIELD_STYLE4_SETTER_GETTER(microseconds, Microseconds)
81
82#undef IMPL_INLINE_SETTER_GETTER
83#undef IMPL_INLINE_DISPLAY_SETTER_GETTER
84#undef IMPL_INLINE_FIELD_STYLE3_SETTER_GETTER
85#undef IMPL_INLINE_FIELD_STYLE5_SETTER_GETTER
86
87inline void JSDurationFormat::set_fractional_digits(int32_t digits) {
88 DCHECK((0 <= digits && digits <= 9) || digits == kUndefinedFractionalDigits);
89 int hints = display_flags();
90 hints = FractionalDigitsBits::update(hints, digits);
91 set_display_flags(hints);
92}
94 int32_t v = FractionalDigitsBits::decode(display_flags());
95 DCHECK((0 <= v && v <= 9) || v == kUndefinedFractionalDigits);
96 return v;
97}
98
101 kIcuNumberFormatterOffset)
102} // namespace internal
103} // namespace v8
104
106
107#endif // V8_OBJECTS_JS_DURATION_FORMAT_INL_H_
static const uint32_t kUndefinedFractionalDigits
#define IMPL_INLINE_SETTER_GETTER(T, n, B, f, M)
#define IMPL_INLINE_FIELD_STYLE3_SETTER_GETTER(f, R)
#define IMPL_INLINE_DISPLAY_SETTER_GETTER(f, R)
#define IMPL_INLINE_FIELD_STYLE4_SETTER_GETTER(f, R)
#define IMPL_INLINE_FIELD_STYLE5_SETTER_GETTER(f, R)
JSDurationFormat::FieldStyle style
double years
double months
double weeks
double days
#define ACCESSORS(holder, name, type, offset)
#define TQ_OBJECT_CONSTRUCTORS_IMPL(Type)
#define DCHECK(condition)
Definition logging.h:482