| 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/handles.h" | 9 #include "src/handles.h" |
| 10 #include "src/objects.h" |
| 10 #include "unicode/uversion.h" | 11 #include "unicode/uversion.h" |
| 11 | 12 |
| 12 namespace U_ICU_NAMESPACE { | 13 namespace U_ICU_NAMESPACE { |
| 13 class BreakIterator; | 14 class BreakIterator; |
| 14 class Collator; | 15 class Collator; |
| 15 class DecimalFormat; | 16 class DecimalFormat; |
| 16 class SimpleDateFormat; | 17 class SimpleDateFormat; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace v8 { | 20 namespace v8 { |
| 20 namespace internal { | 21 namespace internal { |
| 21 | 22 |
| 22 // Forward declarations. | |
| 23 class ObjectTemplateInfo; | |
| 24 | |
| 25 class I18N { | |
| 26 public: | |
| 27 // Creates an ObjectTemplate with one internal field. | |
| 28 static Handle<ObjectTemplateInfo> GetTemplate(Isolate* isolate); | |
| 29 | |
| 30 // Creates an ObjectTemplate with two internal fields. | |
| 31 static Handle<ObjectTemplateInfo> GetTemplate2(Isolate* isolate); | |
| 32 | |
| 33 private: | |
| 34 I18N(); | |
| 35 }; | |
| 36 | |
| 37 | |
| 38 class DateFormat { | 23 class DateFormat { |
| 39 public: | 24 public: |
| 40 // Create a formatter for the specificied locale and options. Returns the | 25 // Create a formatter for the specificied locale and options. Returns the |
| 41 // resolved settings for the locale / options. | 26 // resolved settings for the locale / options. |
| 42 static icu::SimpleDateFormat* InitializeDateTimeFormat( | 27 static icu::SimpleDateFormat* InitializeDateTimeFormat( |
| 43 Isolate* isolate, | 28 Isolate* isolate, |
| 44 Handle<String> locale, | 29 Handle<String> locale, |
| 45 Handle<JSObject> options, | 30 Handle<JSObject> options, |
| 46 Handle<JSObject> resolved); | 31 Handle<JSObject> resolved); |
| 47 | 32 |
| 48 // Unpacks date format object from corresponding JavaScript object. | 33 // Unpacks date format object from corresponding JavaScript object. |
| 49 static icu::SimpleDateFormat* UnpackDateFormat(Isolate* isolate, | 34 static icu::SimpleDateFormat* UnpackDateFormat(Isolate* isolate, |
| 50 Handle<JSObject> obj); | 35 Handle<JSObject> obj); |
| 51 | 36 |
| 52 // Release memory we allocated for the DateFormat once the JS object that | 37 // Release memory we allocated for the DateFormat once the JS object that |
| 53 // holds the pointer gets garbage collected. | 38 // holds the pointer gets garbage collected. |
| 54 static void DeleteDateFormat(const v8::WeakCallbackInfo<void>& data); | 39 static void DeleteDateFormat(const v8::WeakCallbackInfo<void>& data); |
| 55 | 40 |
| 41 // Layout description. |
| 42 static const int kSimpleDateFormat = JSObject::kHeaderSize; |
| 43 static const int kSize = kSimpleDateFormat + kPointerSize; |
| 44 |
| 56 private: | 45 private: |
| 57 DateFormat(); | 46 DateFormat(); |
| 58 }; | 47 }; |
| 59 | 48 |
| 60 | 49 |
| 61 class NumberFormat { | 50 class NumberFormat { |
| 62 public: | 51 public: |
| 63 // Create a formatter for the specificied locale and options. Returns the | 52 // Create a formatter for the specificied locale and options. Returns the |
| 64 // resolved settings for the locale / options. | 53 // resolved settings for the locale / options. |
| 65 static icu::DecimalFormat* InitializeNumberFormat( | 54 static icu::DecimalFormat* InitializeNumberFormat( |
| 66 Isolate* isolate, | 55 Isolate* isolate, |
| 67 Handle<String> locale, | 56 Handle<String> locale, |
| 68 Handle<JSObject> options, | 57 Handle<JSObject> options, |
| 69 Handle<JSObject> resolved); | 58 Handle<JSObject> resolved); |
| 70 | 59 |
| 71 // Unpacks number format object from corresponding JavaScript object. | 60 // Unpacks number format object from corresponding JavaScript object. |
| 72 static icu::DecimalFormat* UnpackNumberFormat(Isolate* isolate, | 61 static icu::DecimalFormat* UnpackNumberFormat(Isolate* isolate, |
| 73 Handle<JSObject> obj); | 62 Handle<JSObject> obj); |
| 74 | 63 |
| 75 // Release memory we allocated for the NumberFormat once the JS object that | 64 // Release memory we allocated for the NumberFormat once the JS object that |
| 76 // holds the pointer gets garbage collected. | 65 // holds the pointer gets garbage collected. |
| 77 static void DeleteNumberFormat(const v8::WeakCallbackInfo<void>& data); | 66 static void DeleteNumberFormat(const v8::WeakCallbackInfo<void>& data); |
| 78 | 67 |
| 68 // Layout description. |
| 69 static const int kDecimalFormat = JSObject::kHeaderSize; |
| 70 static const int kSize = kDecimalFormat + kPointerSize; |
| 71 |
| 79 private: | 72 private: |
| 80 NumberFormat(); | 73 NumberFormat(); |
| 81 }; | 74 }; |
| 82 | 75 |
| 83 | 76 |
| 84 class Collator { | 77 class Collator { |
| 85 public: | 78 public: |
| 86 // Create a collator for the specificied locale and options. Returns the | 79 // Create a collator for the specificied locale and options. Returns the |
| 87 // resolved settings for the locale / options. | 80 // resolved settings for the locale / options. |
| 88 static icu::Collator* InitializeCollator( | 81 static icu::Collator* InitializeCollator( |
| 89 Isolate* isolate, | 82 Isolate* isolate, |
| 90 Handle<String> locale, | 83 Handle<String> locale, |
| 91 Handle<JSObject> options, | 84 Handle<JSObject> options, |
| 92 Handle<JSObject> resolved); | 85 Handle<JSObject> resolved); |
| 93 | 86 |
| 94 // Unpacks collator object from corresponding JavaScript object. | 87 // Unpacks collator object from corresponding JavaScript object. |
| 95 static icu::Collator* UnpackCollator(Isolate* isolate, Handle<JSObject> obj); | 88 static icu::Collator* UnpackCollator(Isolate* isolate, Handle<JSObject> obj); |
| 96 | 89 |
| 97 // Release memory we allocated for the Collator once the JS object that holds | 90 // Release memory we allocated for the Collator once the JS object that holds |
| 98 // the pointer gets garbage collected. | 91 // the pointer gets garbage collected. |
| 99 static void DeleteCollator(const v8::WeakCallbackInfo<void>& data); | 92 static void DeleteCollator(const v8::WeakCallbackInfo<void>& data); |
| 100 | 93 |
| 94 // Layout description. |
| 95 static const int kCollator = JSObject::kHeaderSize; |
| 96 static const int kSize = kCollator + kPointerSize; |
| 97 |
| 101 private: | 98 private: |
| 102 Collator(); | 99 Collator(); |
| 103 }; | 100 }; |
| 104 | 101 |
| 105 class BreakIterator { | 102 class V8BreakIterator { |
| 106 public: | 103 public: |
| 107 // Create a BreakIterator for the specificied locale and options. Returns the | 104 // Create a BreakIterator for the specificied locale and options. Returns the |
| 108 // resolved settings for the locale / options. | 105 // resolved settings for the locale / options. |
| 109 static icu::BreakIterator* InitializeBreakIterator( | 106 static icu::BreakIterator* InitializeBreakIterator( |
| 110 Isolate* isolate, | 107 Isolate* isolate, |
| 111 Handle<String> locale, | 108 Handle<String> locale, |
| 112 Handle<JSObject> options, | 109 Handle<JSObject> options, |
| 113 Handle<JSObject> resolved); | 110 Handle<JSObject> resolved); |
| 114 | 111 |
| 115 // Unpacks break iterator object from corresponding JavaScript object. | 112 // Unpacks break iterator object from corresponding JavaScript object. |
| 116 static icu::BreakIterator* UnpackBreakIterator(Isolate* isolate, | 113 static icu::BreakIterator* UnpackBreakIterator(Isolate* isolate, |
| 117 Handle<JSObject> obj); | 114 Handle<JSObject> obj); |
| 118 | 115 |
| 119 // Release memory we allocated for the BreakIterator once the JS object that | 116 // Release memory we allocated for the BreakIterator once the JS object that |
| 120 // holds the pointer gets garbage collected. | 117 // holds the pointer gets garbage collected. |
| 121 static void DeleteBreakIterator(const v8::WeakCallbackInfo<void>& data); | 118 static void DeleteBreakIterator(const v8::WeakCallbackInfo<void>& data); |
| 122 | 119 |
| 120 // Layout description. |
| 121 static const int kBreakIterator = JSObject::kHeaderSize; |
| 122 static const int kUnicodeString = kBreakIterator + kPointerSize; |
| 123 static const int kSize = kUnicodeString + kPointerSize; |
| 124 |
| 123 private: | 125 private: |
| 124 BreakIterator(); | 126 V8BreakIterator(); |
| 125 }; | 127 }; |
| 126 | 128 |
| 127 } // namespace internal | 129 } // namespace internal |
| 128 } // namespace v8 | 130 } // namespace v8 |
| 129 | 131 |
| 130 #endif // V8_I18N_H_ | 132 #endif // V8_I18N_H_ |
| OLD | NEW |