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

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

Issue 18487004: Import the v8-i18n extension into v8 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27 // limitations under the License.
28
29 #include "i18n-extension.h"
30
31 #include "break-iterator.h"
32 #include "collator.h"
33 #include "date-format.h"
34 #include "locale.h"
35 #include "natives.h"
36 #include "number-format.h"
37
38 using v8::internal::I18NNatives;
39
40 namespace v8_i18n {
41
42 Extension::Extension()
43 : v8::Extension("v8/i18n",
44 reinterpret_cast<const char*>(
45 I18NNatives::GetScriptsSource().start()),
46 0,
47 0,
48 I18NNatives::GetScriptsSource().length()) {}
49
50 v8::Handle<v8::FunctionTemplate> Extension::GetNativeFunction(
51 v8::Handle<v8::String> name) {
52 // Standalone, helper methods.
53 if (name->Equals(v8::String::New("NativeJSCanonicalizeLanguageTag"))) {
54 return v8::FunctionTemplate::New(JSCanonicalizeLanguageTag);
55 } else if (name->Equals(v8::String::New("NativeJSAvailableLocalesOf"))) {
56 return v8::FunctionTemplate::New(JSAvailableLocalesOf);
57 } else if (name->Equals(v8::String::New("NativeJSGetDefaultICULocale"))) {
58 return v8::FunctionTemplate::New(JSGetDefaultICULocale);
59 } else if (name->Equals(v8::String::New("NativeJSGetLanguageTagVariants"))) {
60 return v8::FunctionTemplate::New(JSGetLanguageTagVariants);
61 }
62
63 // Date format and parse.
64 if (name->Equals(v8::String::New("NativeJSCreateDateTimeFormat"))) {
65 return v8::FunctionTemplate::New(DateFormat::JSCreateDateTimeFormat);
66 } else if (name->Equals(v8::String::New("NativeJSInternalDateFormat"))) {
67 return v8::FunctionTemplate::New(DateFormat::JSInternalFormat);
68 } else if (name->Equals(v8::String::New("NativeJSInternalDateParse"))) {
69 return v8::FunctionTemplate::New(DateFormat::JSInternalParse);
70 }
71
72 // Number format and parse.
73 if (name->Equals(v8::String::New("NativeJSCreateNumberFormat"))) {
74 return v8::FunctionTemplate::New(NumberFormat::JSCreateNumberFormat);
75 } else if (name->Equals(v8::String::New("NativeJSInternalNumberFormat"))) {
76 return v8::FunctionTemplate::New(NumberFormat::JSInternalFormat);
77 } else if (name->Equals(v8::String::New("NativeJSInternalNumberParse"))) {
78 return v8::FunctionTemplate::New(NumberFormat::JSInternalParse);
79 }
80
81 // Collator.
82 if (name->Equals(v8::String::New("NativeJSCreateCollator"))) {
83 return v8::FunctionTemplate::New(Collator::JSCreateCollator);
84 } else if (name->Equals(v8::String::New("NativeJSInternalCompare"))) {
85 return v8::FunctionTemplate::New(Collator::JSInternalCompare);
86 }
87
88 // Break iterator.
89 if (name->Equals(v8::String::New("NativeJSCreateBreakIterator"))) {
90 return v8::FunctionTemplate::New(BreakIterator::JSCreateBreakIterator);
91 } else if (name->Equals(v8::String::New("NativeJSBreakIteratorAdoptText"))) {
92 return v8::FunctionTemplate::New(
93 BreakIterator::JSInternalBreakIteratorAdoptText);
94 } else if (name->Equals(v8::String::New("NativeJSBreakIteratorFirst"))) {
95 return v8::FunctionTemplate::New(
96 BreakIterator::JSInternalBreakIteratorFirst);
97 } else if (name->Equals(v8::String::New("NativeJSBreakIteratorNext"))) {
98 return v8::FunctionTemplate::New(
99 BreakIterator::JSInternalBreakIteratorNext);
100 } else if (name->Equals(v8::String::New("NativeJSBreakIteratorCurrent"))) {
101 return v8::FunctionTemplate::New(
102 BreakIterator::JSInternalBreakIteratorCurrent);
103 } else if (name->Equals(v8::String::New("NativeJSBreakIteratorBreakType"))) {
104 return v8::FunctionTemplate::New(
105 BreakIterator::JSInternalBreakIteratorBreakType);
106 }
107
108 return v8::Handle<v8::FunctionTemplate>();
109 }
110
111 void Extension::Register() {
112 static Extension i18n_extension;
113 static v8::DeclareExtension extension_declaration(&i18n_extension);
114 }
115
116 } // namespace v8_i18n
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698