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

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

Issue 6673011: Add v8Locale.Collator (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: final: ready for check-in Created 9 years, 8 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/i18n-extension.h ('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 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 12 matching lines...) Expand all
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" 33 #include "break-iterator.h"
34 #include "collator.h"
34 #include "natives.h" 35 #include "natives.h"
35 #include "unicode/locid.h" 36 #include "unicode/locid.h"
36 #include "unicode/uloc.h" 37 #include "unicode/uloc.h"
37 38
38 namespace v8 { 39 namespace v8 {
39 namespace internal { 40 namespace internal {
40 41
41 I18NExtension* I18NExtension::extension_ = NULL; 42 I18NExtension* I18NExtension::extension_ = NULL;
42 43
43 // Returns a pointer to static string containing the actual 44 // Returns a pointer to static string containing the actual
(...skipping 23 matching lines...) Expand all
67 } else if (name->Equals(v8::String::New("NativeJSDisplayLanguage"))) { 68 } else if (name->Equals(v8::String::New("NativeJSDisplayLanguage"))) {
68 return v8::FunctionTemplate::New(JSDisplayLanguage); 69 return v8::FunctionTemplate::New(JSDisplayLanguage);
69 } else if (name->Equals(v8::String::New("NativeJSDisplayScript"))) { 70 } else if (name->Equals(v8::String::New("NativeJSDisplayScript"))) {
70 return v8::FunctionTemplate::New(JSDisplayScript); 71 return v8::FunctionTemplate::New(JSDisplayScript);
71 } else if (name->Equals(v8::String::New("NativeJSDisplayRegion"))) { 72 } else if (name->Equals(v8::String::New("NativeJSDisplayRegion"))) {
72 return v8::FunctionTemplate::New(JSDisplayRegion); 73 return v8::FunctionTemplate::New(JSDisplayRegion);
73 } else if (name->Equals(v8::String::New("NativeJSDisplayName"))) { 74 } else if (name->Equals(v8::String::New("NativeJSDisplayName"))) {
74 return v8::FunctionTemplate::New(JSDisplayName); 75 return v8::FunctionTemplate::New(JSDisplayName);
75 } else if (name->Equals(v8::String::New("NativeJSBreakIterator"))) { 76 } else if (name->Equals(v8::String::New("NativeJSBreakIterator"))) {
76 return v8::FunctionTemplate::New(BreakIterator::JSBreakIterator); 77 return v8::FunctionTemplate::New(BreakIterator::JSBreakIterator);
78 } else if (name->Equals(v8::String::New("NativeJSCollator"))) {
79 return v8::FunctionTemplate::New(Collator::JSCollator);
77 } 80 }
78 81
79 return v8::Handle<v8::FunctionTemplate>(); 82 return v8::Handle<v8::FunctionTemplate>();
80 } 83 }
81 84
82 v8::Handle<v8::Value> I18NExtension::JSLocale(const v8::Arguments& args) { 85 v8::Handle<v8::Value> I18NExtension::JSLocale(const v8::Arguments& args) {
83 // TODO(cira): Fetch browser locale. Accept en-US as good default for now. 86 // TODO(cira): Fetch browser locale. Accept en-US as good default for now.
84 // We could possibly pass browser locale as a parameter in the constructor. 87 // We could possibly pass browser locale as a parameter in the constructor.
85 std::string locale_name("en-US"); 88 std::string locale_name("en-US");
86 if (args.Length() == 1 && args[0]->IsString()) { 89 if (args.Length() == 1 && args[0]->IsString()) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 extension_ = new I18NExtension(); 225 extension_ = new I18NExtension();
223 } 226 }
224 return extension_; 227 return extension_;
225 } 228 }
226 229
227 void I18NExtension::Register() { 230 void I18NExtension::Register() {
228 static v8::DeclareExtension i18n_extension_declaration(I18NExtension::get()); 231 static v8::DeclareExtension i18n_extension_declaration(I18NExtension::get());
229 } 232 }
230 233
231 } } // namespace v8::internal 234 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/extensions/experimental/i18n-extension.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698