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 13 matching lines...) Expand all Loading... |
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 // limitations under the License. | 27 // limitations under the License. |
28 | 28 |
29 #include "i18n-extension.h" | 29 #include "i18n-extension.h" |
30 | 30 |
31 #include "break-iterator.h" | 31 #include "break-iterator.h" |
32 #include "collator.h" | 32 #include "collator.h" |
33 #include "date-format.h" | 33 #include "date-format.h" |
34 #include "locale.h" | |
35 #include "natives.h" | 34 #include "natives.h" |
36 #include "number-format.h" | 35 #include "number-format.h" |
37 | 36 |
38 using v8::internal::I18NNatives; | 37 using v8::internal::I18NNatives; |
39 | 38 |
40 namespace v8_i18n { | 39 namespace v8_i18n { |
41 | 40 |
42 Extension::Extension() | 41 Extension::Extension() |
43 : v8::Extension("v8/i18n", | 42 : v8::Extension("v8/i18n", |
44 reinterpret_cast<const char*>( | 43 reinterpret_cast<const char*>( |
45 I18NNatives::GetScriptsSource().start()), | 44 I18NNatives::GetScriptsSource().start()), |
46 0, | 45 0, |
47 0, | 46 0, |
48 I18NNatives::GetScriptsSource().length()) {} | 47 I18NNatives::GetScriptsSource().length()) {} |
49 | 48 |
50 v8::Handle<v8::FunctionTemplate> Extension::GetNativeFunction( | 49 v8::Handle<v8::FunctionTemplate> Extension::GetNativeFunction( |
51 v8::Handle<v8::String> name) { | 50 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. | 51 // Date format and parse. |
64 if (name->Equals(v8::String::New("NativeJSCreateDateTimeFormat"))) { | 52 if (name->Equals(v8::String::New("NativeJSCreateDateTimeFormat"))) { |
65 return v8::FunctionTemplate::New(DateFormat::JSCreateDateTimeFormat); | 53 return v8::FunctionTemplate::New(DateFormat::JSCreateDateTimeFormat); |
66 } else if (name->Equals(v8::String::New("NativeJSInternalDateFormat"))) { | 54 } else if (name->Equals(v8::String::New("NativeJSInternalDateFormat"))) { |
67 return v8::FunctionTemplate::New(DateFormat::JSInternalFormat); | 55 return v8::FunctionTemplate::New(DateFormat::JSInternalFormat); |
68 } else if (name->Equals(v8::String::New("NativeJSInternalDateParse"))) { | 56 } else if (name->Equals(v8::String::New("NativeJSInternalDateParse"))) { |
69 return v8::FunctionTemplate::New(DateFormat::JSInternalParse); | 57 return v8::FunctionTemplate::New(DateFormat::JSInternalParse); |
70 } | 58 } |
71 | 59 |
72 // Number format and parse. | 60 // Number format and parse. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return v8::Handle<v8::FunctionTemplate>(); | 96 return v8::Handle<v8::FunctionTemplate>(); |
109 } | 97 } |
110 | 98 |
111 | 99 |
112 void Extension::Register() { | 100 void Extension::Register() { |
113 static Extension i18n_extension; | 101 static Extension i18n_extension; |
114 static v8::DeclareExtension extension_declaration(&i18n_extension); | 102 static v8::DeclareExtension extension_declaration(&i18n_extension); |
115 } | 103 } |
116 | 104 |
117 } // namespace v8_i18n | 105 } // namespace v8_i18n |
OLD | NEW |