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_INTL_SUPPORT
6 #error Internationalization is expected to be enabled.
7 #endif // V8_INTL_SUPPORT
8
9 #ifndef V8_OBJECTS_JS_RELATIVE_TIME_FORMAT_INL_H_
10 #define V8_OBJECTS_JS_RELATIVE_TIME_FORMAT_INL_H_
11
12 #include "src/objects-inl.h"
13 #include "src/objects/js-relative-time-format.h"
14
15 // Has to be the last include (doesn't have include guards):
16 #include "src/objects/object-macros.h"
17
18 namespace v8 {
19 namespace internal {
20
21 // Base relative time format accessors.
ACCESSORS(JSRelativeTimeFormat,locale,String,kLocaleOffset)22 ACCESSORS(JSRelativeTimeFormat, locale, String, kLocaleOffset)
23 ACCESSORS(JSRelativeTimeFormat, formatter, Foreign, kFormatterOffset)
24 SMI_ACCESSORS(JSRelativeTimeFormat, flags, kFlagsOffset)
25
26 // TODO(ftang): Use bit field accessor for style and numeric later.
27
28 inline void JSRelativeTimeFormat::set_style(Style style) {
29 DCHECK_GT(Style::COUNT, style);
30 int hints = flags();
31 hints = StyleBits::update(hints, style);
32 set_flags(hints);
33 }
34
style()35 inline JSRelativeTimeFormat::Style JSRelativeTimeFormat::style() const {
36 return StyleBits::decode(flags());
37 }
38
set_numeric(Numeric numeric)39 inline void JSRelativeTimeFormat::set_numeric(Numeric numeric) {
40 DCHECK_GT(Numeric::COUNT, numeric);
41 int hints = flags();
42 hints = NumericBits::update(hints, numeric);
43 set_flags(hints);
44 }
45
numeric()46 inline JSRelativeTimeFormat::Numeric JSRelativeTimeFormat::numeric() const {
47 return NumericBits::decode(flags());
48 }
49
50 CAST_ACCESSOR(JSRelativeTimeFormat);
51
52 } // namespace internal
53 } // namespace v8
54
55 #include "src/objects/object-macros-undef.h"
56
57 #endif // V8_OBJECTS_JS_RELATIVE_TIME_FORMAT_INL_H_
58