V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
js-locale-inl.h
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_LOCALE_INL_H_
10 #define V8_OBJECTS_JS_LOCALE_INL_H_
11 
12 #include "src/api-inl.h"
13 #include "src/objects-inl.h"
14 #include "src/objects/js-locale.h"
15 
16 // Has to be the last include (doesn't have include guards):
17 #include "src/objects/object-macros.h"
18 
19 namespace v8 {
20 namespace internal {
21 
22 // Base locale accessors.
23 ACCESSORS(JSLocale, language, Object, kLanguageOffset);
24 ACCESSORS(JSLocale, script, Object, kScriptOffset);
25 ACCESSORS(JSLocale, region, Object, kRegionOffset);
26 ACCESSORS(JSLocale, base_name, Object, kBaseNameOffset);
27 ACCESSORS2(JSLocale, locale, String, kLocaleOffset);
28 
29 // Unicode extension accessors.
30 ACCESSORS(JSLocale, calendar, Object, kCalendarOffset);
31 ACCESSORS(JSLocale, collation, Object, kCollationOffset);
32 ACCESSORS(JSLocale, numbering_system, Object, kNumberingSystemOffset);
33 SMI_ACCESSORS(JSLocale, flags, kFlagsOffset)
34 
35 CAST_ACCESSOR(JSLocale);
36 
37 inline void JSLocale::set_case_first(CaseFirst case_first) {
38  DCHECK_GT(CaseFirst::COUNT, case_first);
39  int hints = flags();
40  hints = CaseFirstBits::update(hints, case_first);
41  set_flags(hints);
42 }
43 
44 inline JSLocale::CaseFirst JSLocale::case_first() const {
45  return CaseFirstBits::decode(flags());
46 }
47 
48 inline void JSLocale::set_hour_cycle(HourCycle hour_cycle) {
49  DCHECK_GT(HourCycle::COUNT, hour_cycle);
50  int hints = flags();
51  hints = HourCycleBits::update(hints, hour_cycle);
52  set_flags(hints);
53 }
54 
55 inline JSLocale::HourCycle JSLocale::hour_cycle() const {
56  return HourCycleBits::decode(flags());
57 }
58 
59 inline void JSLocale::set_numeric(Numeric numeric) {
60  DCHECK_GT(Numeric::COUNT, numeric);
61  int hints = flags();
62  hints = NumericBits::update(hints, numeric);
63  set_flags(hints);
64 }
65 
66 inline JSLocale::Numeric JSLocale::numeric() const {
67  return NumericBits::decode(flags());
68 }
69 
70 } // namespace internal
71 } // namespace v8
72 
73 #include "src/objects/object-macros-undef.h"
74 
75 #endif // V8_OBJECTS_JS_LOCALE_INL_H_
Definition: libplatform.h:13