v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
i18n.h
Go to the documentation of this file.
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 #ifndef V8_I18N_H_
30 #define V8_I18N_H_
31 
32 #include "unicode/uversion.h"
33 #include "v8.h"
34 
35 namespace U_ICU_NAMESPACE {
36 class BreakIterator;
37 class Collator;
38 class DecimalFormat;
39 class SimpleDateFormat;
40 }
41 
42 namespace v8 {
43 namespace internal {
44 
45 class I18N {
46  public:
47  // Creates an ObjectTemplate with one internal field.
49 
50  // Creates an ObjectTemplate with two internal fields.
52 
53  private:
54  I18N();
55 };
56 
57 
58 class DateFormat {
59  public:
60  // Create a formatter for the specificied locale and options. Returns the
61  // resolved settings for the locale / options.
62  static icu::SimpleDateFormat* InitializeDateTimeFormat(
63  Isolate* isolate,
64  Handle<String> locale,
65  Handle<JSObject> options,
66  Handle<JSObject> resolved);
67 
68  // Unpacks date format object from corresponding JavaScript object.
69  static icu::SimpleDateFormat* UnpackDateFormat(Isolate* isolate,
71 
72  // Release memory we allocated for the DateFormat once the JS object that
73  // holds the pointer gets garbage collected.
74  static void DeleteDateFormat(
76 
77  private:
78  DateFormat();
79 };
80 
81 
82 class NumberFormat {
83  public:
84  // Create a formatter for the specificied locale and options. Returns the
85  // resolved settings for the locale / options.
86  static icu::DecimalFormat* InitializeNumberFormat(
87  Isolate* isolate,
88  Handle<String> locale,
89  Handle<JSObject> options,
90  Handle<JSObject> resolved);
91 
92  // Unpacks number format object from corresponding JavaScript object.
93  static icu::DecimalFormat* UnpackNumberFormat(Isolate* isolate,
95 
96  // Release memory we allocated for the NumberFormat once the JS object that
97  // holds the pointer gets garbage collected.
98  static void DeleteNumberFormat(
100 
101  private:
102  NumberFormat();
103 };
104 
105 
106 class Collator {
107  public:
108  // Create a collator for the specificied locale and options. Returns the
109  // resolved settings for the locale / options.
110  static icu::Collator* InitializeCollator(
111  Isolate* isolate,
112  Handle<String> locale,
113  Handle<JSObject> options,
114  Handle<JSObject> resolved);
115 
116  // Unpacks collator object from corresponding JavaScript object.
117  static icu::Collator* UnpackCollator(Isolate* isolate, Handle<JSObject> obj);
118 
119  // Release memory we allocated for the Collator once the JS object that holds
120  // the pointer gets garbage collected.
121  static void DeleteCollator(
123 
124  private:
125  Collator();
126 };
127 
129  public:
130  // Create a BreakIterator for the specificied locale and options. Returns the
131  // resolved settings for the locale / options.
132  static icu::BreakIterator* InitializeBreakIterator(
133  Isolate* isolate,
134  Handle<String> locale,
135  Handle<JSObject> options,
136  Handle<JSObject> resolved);
137 
138  // Unpacks break iterator object from corresponding JavaScript object.
139  static icu::BreakIterator* UnpackBreakIterator(Isolate* isolate,
141 
142  // Release memory we allocated for the BreakIterator once the JS object that
143  // holds the pointer gets garbage collected.
144  static void DeleteBreakIterator(
146 
147  private:
148  BreakIterator();
149 };
150 
151 } } // namespace v8::internal
152 
153 #endif // V8_I18N_H_
static icu::DecimalFormat * InitializeNumberFormat(Isolate *isolate, Handle< String > locale, Handle< JSObject > options, Handle< JSObject > resolved)
Definition: i18n.cc:889
static Handle< ObjectTemplateInfo > GetTemplate(Isolate *isolate)
Definition: i18n.cc:804
static icu::DecimalFormat * UnpackNumberFormat(Isolate *isolate, Handle< JSObject > obj)
Definition: i18n.cc:928
static void DeleteCollator(const v8::WeakCallbackData< v8::Value, void > &data)
Definition: i18n.cc:997
static void DeleteBreakIterator(const v8::WeakCallbackData< v8::Value, void > &data)
Definition: i18n.cc:1056
static icu::BreakIterator * InitializeBreakIterator(Isolate *isolate, Handle< String > locale, Handle< JSObject > options, Handle< JSObject > resolved)
Definition: i18n.cc:1004
static icu::SimpleDateFormat * InitializeDateTimeFormat(Isolate *isolate, Handle< String > locale, Handle< JSObject > options, Handle< JSObject > resolved)
Definition: i18n.cc:816
static icu::SimpleDateFormat * UnpackDateFormat(Isolate *isolate, Handle< JSObject > obj)
Definition: i18n.cc:854
static Handle< ObjectTemplateInfo > GetTemplate2(Isolate *isolate)
Definition: i18n.cc:810
static icu::Collator * UnpackCollator(Isolate *isolate, Handle< JSObject > obj)
Definition: i18n.cc:985
static void DeleteDateFormat(const v8::WeakCallbackData< v8::Value, void > &data)
Definition: i18n.cc:882
static icu::BreakIterator * UnpackBreakIterator(Isolate *isolate, Handle< JSObject > obj)
Definition: i18n.cc:1044
static icu::Collator * InitializeCollator(Isolate *isolate, Handle< String > locale, Handle< JSObject > options, Handle< JSObject > resolved)
Definition: i18n.cc:948
HeapObject * obj
static void DeleteNumberFormat(const v8::WeakCallbackData< v8::Value, void > &data)
Definition: i18n.cc:941