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_PLURAL_RULES_H_ 10 #define V8_OBJECTS_JS_PLURAL_RULES_H_ 11 12 #include "src/heap/factory.h" 13 #include "src/isolate.h" 14 #include "src/objects.h" 15 #include "src/objects/intl-objects.h" 16 #include "src/objects/managed.h" 17 18 // Has to be the last include (doesn't have include guards): 19 #include "src/objects/object-macros.h" 20 21 namespace v8 { 22 namespace internal { 23 24 class JSPluralRules : public JSObject { 25 public: 26 V8_WARN_UNUSED_RESULT static MaybeHandle<JSPluralRules> InitializePluralRules( 27 Isolate* isolate, Handle<JSPluralRules> plural_rules, 28 Handle<Object> locales, Handle<Object> options); 29 30 static Handle<JSObject> ResolvedOptions(Isolate* isolate, 31 Handle<JSPluralRules> plural_rules); 32 33 V8_WARN_UNUSED_RESULT static MaybeHandle<String> ResolvePlural( 34 Isolate* isolate, Handle<JSPluralRules> plural_rules, 35 Handle<Object> number); 36 37 DECL_CAST(JSPluralRules) 38 DECL_PRINTER(JSPluralRules) 39 DECL_VERIFIER(JSPluralRules) 40 41 // Layout description. 42 #define JS_PLURAL_RULES_FIELDS(V) \ 43 V(kLocaleOffset, kPointerSize) \ 44 /* In the future, this can be an enum, \ 45 and not a string. */ \ 46 V(kTypeOffset, kPointerSize) \ 47 V(kICUPluralRulesOffset, kPointerSize) \ 48 V(kICUDecimalFormatOffset, kPointerSize) \ 49 /* Total size. */ \ 50 V(kSize, 0) 51 52 DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_PLURAL_RULES_FIELDS) 53 #undef JS_PLURAL_RULES_FIELDS 54 55 DECL_ACCESSORS(locale, String) 56 DECL_ACCESSORS(type, String) 57 DECL_ACCESSORS(icu_plural_rules, Managed<icu::PluralRules>) 58 DECL_ACCESSORS(icu_decimal_format, Managed<icu::DecimalFormat>) 59 60 private: 61 DISALLOW_IMPLICIT_CONSTRUCTORS(JSPluralRules); 62 }; 63 64 } // namespace internal 65 } // namespace v8 66 67 #include "src/objects/object-macros-undef.h" 68 69 #endif // V8_OBJECTS_JS_PLURAL_RULES_H_ 70