5 #ifndef V8_INTL_SUPPORT 6 #error Internationalization is expected to be enabled. 7 #endif // V8_INTL_SUPPORT 9 #ifndef V8_OBJECTS_JS_NUMBER_FORMAT_H_ 10 #define V8_OBJECTS_JS_NUMBER_FORMAT_H_ 15 #include "src/heap/factory.h" 16 #include "src/isolate.h" 17 #include "src/objects.h" 18 #include "src/objects/intl-objects.h" 19 #include "src/objects/managed.h" 22 #include "src/objects/object-macros.h" 57 V8_WARN_UNUSED_RESULT
static Maybe<int> FormatToParts(
62 Isolate* isolate,
const icu::NumberFormat& number_format,
double number);
64 static std::set<std::string> GetAvailableLocales();
82 inline void set_style(Style style);
83 inline Style style()
const;
87 enum class CurrencyDisplay {
94 inline void set_currency_display(CurrencyDisplay currency_display);
95 inline CurrencyDisplay currency_display()
const;
98 #define JS_NUMBER_FORMAT_FIELDS(V) \ 99 V(kLocaleOffset, kTaggedSize) \ 100 V(kICUNumberFormatOffset, kTaggedSize) \ 101 V(kBoundFormatOffset, kTaggedSize) \ 102 V(kFlagsOffset, kTaggedSize) \ 106 DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_NUMBER_FORMAT_FIELDS)
107 #undef JS_NUMBER_FORMAT_FIELDS 110 #define FLAGS_BIT_FIELDS(V, _) \ 111 V(StyleBits, Style, 2, _) \ 112 V(CurrencyDisplayBits, CurrencyDisplay, 2, _) 114 DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
115 #undef FLAGS_BIT_FIELDS 117 STATIC_ASSERT(Style::DECIMAL <= StyleBits::kMax);
118 STATIC_ASSERT(Style::PERCENT <= StyleBits::kMax);
119 STATIC_ASSERT(Style::CURRENCY <= StyleBits::kMax);
121 STATIC_ASSERT(CurrencyDisplay::CODE <= CurrencyDisplayBits::kMax);
122 STATIC_ASSERT(CurrencyDisplay::SYMBOL <= CurrencyDisplayBits::kMax);
123 STATIC_ASSERT(CurrencyDisplay::NAME <= CurrencyDisplayBits::kMax);
125 DECL_ACCESSORS2(locale,
String)
127 DECL_ACCESSORS(bound_format,
Object)
128 DECL_INT_ACCESSORS(flags)
141 : field_id(field_id), begin_pos(begin_pos), end_pos(end_pos) {}
144 std::vector<NumberFormatSpan> FlattenRegionsToParts(
145 std::vector<NumberFormatSpan>* regions);
150 #include "src/objects/object-macros-undef.h" 152 #endif // V8_OBJECTS_JS_NUMBER_FORMAT_H_