Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: src/extensions/experimental/i18n-extension.cc

Issue 6596100: Remove break iterator support from the i18n api extension. It breaks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/extensions/experimental/experimental.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "i18n-extension.h" 28 #include "i18n-extension.h"
29 29
30 #include <algorithm> 30 #include <algorithm>
31 #include <string> 31 #include <string>
32 32
33 #include "break-iterator.h"
34 #include "unicode/locid.h" 33 #include "unicode/locid.h"
35 #include "unicode/uloc.h" 34 #include "unicode/uloc.h"
36 35
37 namespace v8 { 36 namespace v8 {
38 namespace internal { 37 namespace internal {
39 38
40 I18NExtension* I18NExtension::extension_ = NULL; 39 I18NExtension* I18NExtension::extension_ = NULL;
41 40
42 // TODO(cira): maybe move JS code to a .js file and generata cc files from it? 41 // TODO(cira): maybe move JS code to a .js file and generata cc files from it?
43 // TODO(cira): Remove v8 prefix from v8Locale once we have stable API. 42 // TODO(cira): Remove v8 prefix from v8Locale once we have stable API.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 "};" 80 "};"
82 "v8Locale.prototype.displayRegion = function(optDisplayLocale) {" 81 "v8Locale.prototype.displayRegion = function(optDisplayLocale) {"
83 " var displayLocale = this.displayLocale_(optDisplayLocale);" 82 " var displayLocale = this.displayLocale_(optDisplayLocale);"
84 " native function NativeJSDisplayRegion();" 83 " native function NativeJSDisplayRegion();"
85 " return NativeJSDisplayRegion(this.locale, displayLocale);" 84 " return NativeJSDisplayRegion(this.locale, displayLocale);"
86 "};" 85 "};"
87 "v8Locale.prototype.displayName = function(optDisplayLocale) {" 86 "v8Locale.prototype.displayName = function(optDisplayLocale) {"
88 " var displayLocale = this.displayLocale_(optDisplayLocale);" 87 " var displayLocale = this.displayLocale_(optDisplayLocale);"
89 " native function NativeJSDisplayName();" 88 " native function NativeJSDisplayName();"
90 " return NativeJSDisplayName(this.locale, displayLocale);" 89 " return NativeJSDisplayName(this.locale, displayLocale);"
91 "};"
92 "v8Locale.v8BreakIterator = function(locale, type) {"
93 " native function NativeJSBreakIterator();"
94 " var iterator = NativeJSBreakIterator(locale, type);"
95 " iterator.type = type;"
96 " return iterator;"
97 "};"
98 "v8Locale.v8BreakIterator.BreakType = {"
99 " 'unknown': -1,"
100 " 'none': 0,"
101 " 'number': 100,"
102 " 'word': 200,"
103 " 'kana': 300,"
104 " 'ideo': 400"
105 "};"
106 "v8Locale.prototype.v8CreateBreakIterator = function(type) {"
107 " return new v8Locale.v8BreakIterator(this.locale, type);"
108 "};"; 90 "};";
109 91
110 v8::Handle<v8::FunctionTemplate> I18NExtension::GetNativeFunction( 92 v8::Handle<v8::FunctionTemplate> I18NExtension::GetNativeFunction(
111 v8::Handle<v8::String> name) { 93 v8::Handle<v8::String> name) {
112 if (name->Equals(v8::String::New("NativeJSLocale"))) { 94 if (name->Equals(v8::String::New("NativeJSLocale"))) {
113 return v8::FunctionTemplate::New(JSLocale); 95 return v8::FunctionTemplate::New(JSLocale);
114 } else if (name->Equals(v8::String::New("NativeJSAvailableLocales"))) { 96 } else if (name->Equals(v8::String::New("NativeJSAvailableLocales"))) {
115 return v8::FunctionTemplate::New(JSAvailableLocales); 97 return v8::FunctionTemplate::New(JSAvailableLocales);
116 } else if (name->Equals(v8::String::New("NativeJSMaximizedLocale"))) { 98 } else if (name->Equals(v8::String::New("NativeJSMaximizedLocale"))) {
117 return v8::FunctionTemplate::New(JSMaximizedLocale); 99 return v8::FunctionTemplate::New(JSMaximizedLocale);
118 } else if (name->Equals(v8::String::New("NativeJSMinimizedLocale"))) { 100 } else if (name->Equals(v8::String::New("NativeJSMinimizedLocale"))) {
119 return v8::FunctionTemplate::New(JSMinimizedLocale); 101 return v8::FunctionTemplate::New(JSMinimizedLocale);
120 } else if (name->Equals(v8::String::New("NativeJSDisplayLanguage"))) { 102 } else if (name->Equals(v8::String::New("NativeJSDisplayLanguage"))) {
121 return v8::FunctionTemplate::New(JSDisplayLanguage); 103 return v8::FunctionTemplate::New(JSDisplayLanguage);
122 } else if (name->Equals(v8::String::New("NativeJSDisplayScript"))) { 104 } else if (name->Equals(v8::String::New("NativeJSDisplayScript"))) {
123 return v8::FunctionTemplate::New(JSDisplayScript); 105 return v8::FunctionTemplate::New(JSDisplayScript);
124 } else if (name->Equals(v8::String::New("NativeJSDisplayRegion"))) { 106 } else if (name->Equals(v8::String::New("NativeJSDisplayRegion"))) {
125 return v8::FunctionTemplate::New(JSDisplayRegion); 107 return v8::FunctionTemplate::New(JSDisplayRegion);
126 } else if (name->Equals(v8::String::New("NativeJSDisplayName"))) { 108 } else if (name->Equals(v8::String::New("NativeJSDisplayName"))) {
127 return v8::FunctionTemplate::New(JSDisplayName); 109 return v8::FunctionTemplate::New(JSDisplayName);
128 } else if (name->Equals(v8::String::New("NativeJSBreakIterator"))) {
129 return v8::FunctionTemplate::New(BreakIterator::JSBreakIterator);
130 } 110 }
131 111
132 return v8::Handle<v8::FunctionTemplate>(); 112 return v8::Handle<v8::FunctionTemplate>();
133 } 113 }
134 114
135 v8::Handle<v8::Value> I18NExtension::JSLocale(const v8::Arguments& args) { 115 v8::Handle<v8::Value> I18NExtension::JSLocale(const v8::Arguments& args) {
136 // TODO(cira): Fetch browser locale. Accept en-US as good default for now. 116 // TODO(cira): Fetch browser locale. Accept en-US as good default for now.
137 // We could possibly pass browser locale as a parameter in the constructor. 117 // We could possibly pass browser locale as a parameter in the constructor.
138 std::string locale_name("en-US"); 118 std::string locale_name("en-US");
139 if (args.Length() == 1 && args[0]->IsString()) { 119 if (args.Length() == 1 && args[0]->IsString()) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 extension_ = new I18NExtension(); 255 extension_ = new I18NExtension();
276 } 256 }
277 return extension_; 257 return extension_;
278 } 258 }
279 259
280 void I18NExtension::Register() { 260 void I18NExtension::Register() {
281 static v8::DeclareExtension i18n_extension_declaration(I18NExtension::get()); 261 static v8::DeclareExtension i18n_extension_declaration(I18NExtension::get());
282 } 262 }
283 263
284 } } // namespace v8::internal 264 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/extensions/experimental/experimental.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698