Index: src/extensions/i18n/i18n-utils.cc |
diff --git a/src/extensions/i18n/i18n-utils.cc b/src/extensions/i18n/i18n-utils.cc |
index b720329f8b6f2446cd0e9b4f3171bfbfd89b0f80..fced1480f8f7508087ffb880991c9768f787eebf 100644 |
--- a/src/extensions/i18n/i18n-utils.cc |
+++ b/src/extensions/i18n/i18n-utils.cc |
@@ -142,40 +142,38 @@ void Utils::AsciiToUChar(const char* source, |
// static |
-// Chrome Linux doesn't like static initializers in class, so we create |
-// template on demand. |
v8::Local<v8::ObjectTemplate> Utils::GetTemplate(v8::Isolate* isolate) { |
- static v8::Persistent<v8::ObjectTemplate> icu_template; |
- |
- if (icu_template.IsEmpty()) { |
+ i::Isolate* internal = reinterpret_cast<i::Isolate*>(isolate); |
+ if (internal->heap()->i18n_template_one() == |
+ internal->heap()->the_hole_value()) { |
v8::Local<v8::ObjectTemplate> raw_template(v8::ObjectTemplate::New()); |
- |
- // Set aside internal field for ICU class. |
raw_template->SetInternalFieldCount(1); |
- |
- icu_template.Reset(isolate, raw_template); |
+ internal->heap() |
+ ->SetI18nTemplateOne(*v8::Utils::OpenHandle(*raw_template)); |
} |
- return v8::Local<v8::ObjectTemplate>::New(isolate, icu_template); |
+ i::Handle<i::ObjectTemplateInfo> tmpl( |
+ 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
|
+ internal); |
+ return v8::Utils::ToLocal(tmpl); |
} |
// static |
-// Chrome Linux doesn't like static initializers in class, so we create |
-// template on demand. This one has 2 internal fields. |
v8::Local<v8::ObjectTemplate> Utils::GetTemplate2(v8::Isolate* isolate) { |
- static v8::Persistent<v8::ObjectTemplate> icu_template_2; |
- |
- if (icu_template_2.IsEmpty()) { |
+ i::Isolate* internal = reinterpret_cast<i::Isolate*>(isolate); |
+ if (internal->heap()->i18n_template_two() == |
+ internal->heap()->the_hole_value()) { |
v8::Local<v8::ObjectTemplate> raw_template(v8::ObjectTemplate::New()); |
- |
- // Set aside internal field for ICU class and additional data. |
raw_template->SetInternalFieldCount(2); |
- |
- icu_template_2.Reset(isolate, raw_template); |
+ internal->heap() |
+ ->SetI18nTemplateTwo(*v8::Utils::OpenHandle(*raw_template)); |
} |
- return v8::Local<v8::ObjectTemplate>::New(isolate, icu_template_2); |
+ i::Handle<i::ObjectTemplateInfo> tmpl( |
+ i::ObjectTemplateInfo::cast(internal->heap()->i18n_template_two()), |
Michael Starzinger
2013/07/25 13:56:06
Likewise.
|
+ internal); |
+ return v8::Utils::ToLocal(tmpl); |
} |
} // namespace v8_i18n |