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 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 | 135 |
| 136 for (int32_t i = 0; i < length - 1; ++i) { | 136 for (int32_t i = 0; i < length - 1; ++i) { |
| 137 target[i] = static_cast<UChar>(source[i]); | 137 target[i] = static_cast<UChar>(source[i]); |
| 138 } | 138 } |
| 139 | 139 |
| 140 target[length - 1] = 0x0u; | 140 target[length - 1] = 0x0u; |
| 141 } | 141 } |
| 142 | 142 |
| 143 | 143 |
| 144 // static | 144 // static |
| 145 // Chrome Linux doesn't like static initializers in class, so we create | |
| 146 // template on demand. | |
| 147 v8::Local<v8::ObjectTemplate> Utils::GetTemplate(v8::Isolate* isolate) { | 145 v8::Local<v8::ObjectTemplate> Utils::GetTemplate(v8::Isolate* isolate) { |
| 148 static v8::Persistent<v8::ObjectTemplate> icu_template; | 146 i::Isolate* internal = reinterpret_cast<i::Isolate*>(isolate); |
| 149 | 147 if (internal->heap()->i18n_template_one() == |
| 150 if (icu_template.IsEmpty()) { | 148 internal->heap()->the_hole_value()) { |
| 151 v8::Local<v8::ObjectTemplate> raw_template(v8::ObjectTemplate::New()); | 149 v8::Local<v8::ObjectTemplate> raw_template(v8::ObjectTemplate::New()); |
| 152 | |
| 153 // Set aside internal field for ICU class. | |
| 154 raw_template->SetInternalFieldCount(1); | 150 raw_template->SetInternalFieldCount(1); |
| 155 | 151 internal->heap() |
| 156 icu_template.Reset(isolate, raw_template); | 152 ->SetI18nTemplateOne(*v8::Utils::OpenHandle(*raw_template)); |
| 157 } | 153 } |
| 158 | 154 |
| 159 return v8::Local<v8::ObjectTemplate>::New(isolate, icu_template); | 155 i::Handle<i::ObjectTemplateInfo> tmpl( |
| 156 i::ObjectTemplateInfo::cast(internal->heap()->i18n_template_one()), | |
|
Michael Starzinger
2013/07/25 13:56:06
Just use internal->i18n_template_one() here, gives
Michael Starzinger
2013/07/25 13:57:22
That should have been internal->factory()->i18n_te
| |
| 157 internal); | |
| 158 return v8::Utils::ToLocal(tmpl); | |
| 160 } | 159 } |
| 161 | 160 |
| 162 | 161 |
| 163 // static | 162 // static |
| 164 // Chrome Linux doesn't like static initializers in class, so we create | |
| 165 // template on demand. This one has 2 internal fields. | |
| 166 v8::Local<v8::ObjectTemplate> Utils::GetTemplate2(v8::Isolate* isolate) { | 163 v8::Local<v8::ObjectTemplate> Utils::GetTemplate2(v8::Isolate* isolate) { |
| 167 static v8::Persistent<v8::ObjectTemplate> icu_template_2; | 164 i::Isolate* internal = reinterpret_cast<i::Isolate*>(isolate); |
| 168 | 165 if (internal->heap()->i18n_template_two() == |
| 169 if (icu_template_2.IsEmpty()) { | 166 internal->heap()->the_hole_value()) { |
| 170 v8::Local<v8::ObjectTemplate> raw_template(v8::ObjectTemplate::New()); | 167 v8::Local<v8::ObjectTemplate> raw_template(v8::ObjectTemplate::New()); |
| 171 | |
| 172 // Set aside internal field for ICU class and additional data. | |
| 173 raw_template->SetInternalFieldCount(2); | 168 raw_template->SetInternalFieldCount(2); |
| 174 | 169 internal->heap() |
| 175 icu_template_2.Reset(isolate, raw_template); | 170 ->SetI18nTemplateTwo(*v8::Utils::OpenHandle(*raw_template)); |
| 176 } | 171 } |
| 177 | 172 |
| 178 return v8::Local<v8::ObjectTemplate>::New(isolate, icu_template_2); | 173 i::Handle<i::ObjectTemplateInfo> tmpl( |
| 174 i::ObjectTemplateInfo::cast(internal->heap()->i18n_template_two()), | |
|
Michael Starzinger
2013/07/25 13:56:06
Likewise.
| |
| 175 internal); | |
| 176 return v8::Utils::ToLocal(tmpl); | |
| 179 } | 177 } |
| 180 | 178 |
| 181 } // namespace v8_i18n | 179 } // namespace v8_i18n |
| OLD | NEW |