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 #include "src/i18n.h" | 6 #include "src/i18n.h" |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "src/api.h" | 10 #include "src/api.h" |
9 #include "src/factory.h" | 11 #include "src/factory.h" |
10 #include "src/isolate.h" | 12 #include "src/isolate.h" |
11 #include "unicode/brkiter.h" | 13 #include "unicode/brkiter.h" |
12 #include "unicode/calendar.h" | 14 #include "unicode/calendar.h" |
13 #include "unicode/coll.h" | 15 #include "unicode/coll.h" |
14 #include "unicode/curramt.h" | 16 #include "unicode/curramt.h" |
15 #include "unicode/dcfmtsym.h" | 17 #include "unicode/dcfmtsym.h" |
16 #include "unicode/decimfmt.h" | 18 #include "unicode/decimfmt.h" |
17 #include "unicode/dtfmtsym.h" | 19 #include "unicode/dtfmtsym.h" |
(...skipping 90 matching lines...) Loading... |
108 const double start_of_time = -9007199254740992; | 110 const double start_of_time = -9007199254740992; |
109 gc->setGregorianChange(start_of_time, status); | 111 gc->setGregorianChange(start_of_time, status); |
110 DCHECK(U_SUCCESS(status)); | 112 DCHECK(U_SUCCESS(status)); |
111 } | 113 } |
112 | 114 |
113 // Make formatter from skeleton. Calendar and numbering system are added | 115 // Make formatter from skeleton. Calendar and numbering system are added |
114 // to the locale as Unicode extension (if they were specified at all). | 116 // to the locale as Unicode extension (if they were specified at all). |
115 icu::SimpleDateFormat* date_format = NULL; | 117 icu::SimpleDateFormat* date_format = NULL; |
116 icu::UnicodeString skeleton; | 118 icu::UnicodeString skeleton; |
117 if (ExtractStringSetting(isolate, options, "skeleton", &skeleton)) { | 119 if (ExtractStringSetting(isolate, options, "skeleton", &skeleton)) { |
118 icu::DateTimePatternGenerator* generator = | 120 std::unique_ptr<icu::DateTimePatternGenerator> generator( |
119 icu::DateTimePatternGenerator::createInstance(icu_locale, status); | 121 icu::DateTimePatternGenerator::createInstance(icu_locale, status)); |
120 icu::UnicodeString pattern; | 122 icu::UnicodeString pattern; |
121 if (U_SUCCESS(status)) { | 123 if (U_SUCCESS(status)) |
122 pattern = generator->getBestPattern(skeleton, status); | 124 pattern = generator->getBestPattern(skeleton, status); |
123 delete generator; | |
124 } | |
125 | 125 |
126 date_format = new icu::SimpleDateFormat(pattern, icu_locale, status); | 126 date_format = new icu::SimpleDateFormat(pattern, icu_locale, status); |
127 if (U_SUCCESS(status)) { | 127 if (U_SUCCESS(status)) { |
128 date_format->adoptCalendar(calendar); | 128 date_format->adoptCalendar(calendar); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 if (U_FAILURE(status)) { | 132 if (U_FAILURE(status)) { |
133 delete calendar; | 133 delete calendar; |
134 delete date_format; | 134 delete date_format; |
135 date_format = NULL; | 135 date_format = nullptr; |
136 } | 136 } |
137 | 137 |
138 return date_format; | 138 return date_format; |
139 } | 139 } |
140 | 140 |
141 | 141 |
142 void SetResolvedDateSettings(Isolate* isolate, | 142 void SetResolvedDateSettings(Isolate* isolate, |
143 const icu::Locale& icu_locale, | 143 const icu::Locale& icu_locale, |
144 icu::SimpleDateFormat* date_format, | 144 icu::SimpleDateFormat* date_format, |
145 Handle<JSObject> resolved) { | 145 Handle<JSObject> resolved) { |
(...skipping 812 matching lines...) Loading... |
958 | 958 |
959 void BreakIterator::DeleteBreakIterator( | 959 void BreakIterator::DeleteBreakIterator( |
960 const v8::WeakCallbackInfo<void>& data) { | 960 const v8::WeakCallbackInfo<void>& data) { |
961 delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0)); | 961 delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0)); |
962 delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1)); | 962 delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1)); |
963 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); | 963 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); |
964 } | 964 } |
965 | 965 |
966 } // namespace internal | 966 } // namespace internal |
967 } // namespace v8 | 967 } // namespace v8 |
OLD | NEW |