Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // limitations under the License. | 4 // limitations under the License. |
| 5 | 5 |
| 6 #ifndef V8_I18N_H_ | 6 #ifndef V8_I18N_H_ |
| 7 #define V8_I18N_H_ | 7 #define V8_I18N_H_ |
| 8 | 8 |
| 9 #include "src/objects.h" | 9 #include "src/objects.h" |
| 10 #include "unicode/uversion.h" | 10 #include "unicode/uversion.h" |
| 11 | 11 |
| 12 namespace U_ICU_NAMESPACE { | 12 namespace U_ICU_NAMESPACE { |
| 13 class BreakIterator; | 13 class BreakIterator; |
| 14 class Collator; | 14 class Collator; |
| 15 class DecimalFormat; | 15 class DecimalFormat; |
| 16 class SimpleDateFormat; | 16 class SimpleDateFormat; |
| 17 class PluralRules; | |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace v8 { | 20 namespace v8 { |
| 20 namespace internal { | 21 namespace internal { |
| 21 | 22 |
| 22 template <typename T> | 23 template <typename T> |
| 23 class Handle; | 24 class Handle; |
| 24 | 25 |
| 25 class DateFormat { | 26 class DateFormat { |
| 26 public: | 27 public: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 static void DeleteCollator(const v8::WeakCallbackInfo<void>& data); | 95 static void DeleteCollator(const v8::WeakCallbackInfo<void>& data); |
| 95 | 96 |
| 96 // Layout description. | 97 // Layout description. |
| 97 static const int kCollator = JSObject::kHeaderSize; | 98 static const int kCollator = JSObject::kHeaderSize; |
| 98 static const int kSize = kCollator + kPointerSize; | 99 static const int kSize = kCollator + kPointerSize; |
| 99 | 100 |
| 100 private: | 101 private: |
| 101 Collator(); | 102 Collator(); |
| 102 }; | 103 }; |
| 103 | 104 |
| 105 class PluralRules { | |
| 106 public: | |
| 107 // Create a PluralRules and DecimalFormat for the specificied locale and | |
| 108 // options. Returns false on an ICU failure. | |
| 109 static bool InitializePluralRules(Isolate* isolate, Handle<String> locale, | |
| 110 Handle<JSObject> options, | |
| 111 Handle<JSObject> resolved, | |
| 112 icu::PluralRules** plural_rules, | |
| 113 icu::DecimalFormat** decimal_format); | |
| 114 | |
| 115 // Unpacks PluralRules object from corresponding JavaScript object. | |
| 116 static icu::PluralRules* UnpackPluralRules(Isolate* isolate, | |
| 117 Handle<JSObject> obj); | |
| 118 | |
| 119 // Unpacks NumberFormat object from corresponding JavaScript PluralRUles | |
| 120 // object. | |
| 121 static icu::DecimalFormat* UnpackNumberFormat(Isolate* isolate, | |
| 122 Handle<JSObject> obj); | |
| 123 | |
| 124 // Release memory we allocated for the Collator once the JS object that holds | |
|
jungshik at Google
2017/05/08 19:16:54
Collator? You mean PluralRules, don't you?
| |
| 125 // the pointer gets garbage collected. | |
| 126 static void DeletePluralRules(const v8::WeakCallbackInfo<void>& data); | |
| 127 | |
| 128 // Layout description. | |
| 129 static const int kPluralRules = JSObject::kHeaderSize; | |
| 130 // Values are formatted with this NumberFormat and then parsed as a Number | |
| 131 // to round them based on the options passed into the PluralRules objct. | |
| 132 // TODO(littledan): If a future version of ICU supports the rounding | |
| 133 // built-in to PluralRules, switch to that, see this bug: | |
| 134 // http://bugs.icu-project.org/trac/ticket/12763 | |
|
jungshik at Google
2017/05/08 19:16:54
That bug was fixed and is a part of ICU 59. I'll
jungshik at Google
2017/05/19 05:28:34
FYI, ICU in Chromium tree was updated to 59.1.
| |
| 135 static const int kNumberFormat = kPluralRules + kPointerSize; | |
| 136 static const int kSize = kNumberFormat + kPointerSize; | |
| 137 | |
| 138 private: | |
| 139 PluralRules(); | |
| 140 }; | |
| 141 | |
| 104 class V8BreakIterator { | 142 class V8BreakIterator { |
| 105 public: | 143 public: |
| 106 // Create a BreakIterator for the specificied locale and options. Returns the | 144 // Create a BreakIterator for the specificied locale and options. Returns the |
| 107 // resolved settings for the locale / options. | 145 // resolved settings for the locale / options. |
| 108 static icu::BreakIterator* InitializeBreakIterator( | 146 static icu::BreakIterator* InitializeBreakIterator( |
| 109 Isolate* isolate, | 147 Isolate* isolate, |
| 110 Handle<String> locale, | 148 Handle<String> locale, |
| 111 Handle<JSObject> options, | 149 Handle<JSObject> options, |
| 112 Handle<JSObject> resolved); | 150 Handle<JSObject> resolved); |
| 113 | 151 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 125 static const int kSize = kUnicodeString + kPointerSize; | 163 static const int kSize = kUnicodeString + kPointerSize; |
| 126 | 164 |
| 127 private: | 165 private: |
| 128 V8BreakIterator(); | 166 V8BreakIterator(); |
| 129 }; | 167 }; |
| 130 | 168 |
| 131 } // namespace internal | 169 } // namespace internal |
| 132 } // namespace v8 | 170 } // namespace v8 |
| 133 | 171 |
| 134 #endif // V8_I18N_H_ | 172 #endif // V8_I18N_H_ |
| OLD | NEW |