blob: 2a4c208601298ac56e8075804079a144b12b5327 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2013 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4// limitations under the License.
5
6#ifndef V8_I18N_H_
7#define V8_I18N_H_
8
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00009#include "src/handles.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000010#include "unicode/uversion.h"
11
12namespace U_ICU_NAMESPACE {
13class BreakIterator;
14class Collator;
15class DecimalFormat;
16class SimpleDateFormat;
17}
18
19namespace v8 {
20namespace internal {
21
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000022// Forward declarations.
23class ObjectTemplateInfo;
24
Ben Murdochb8a8cc12014-11-26 15:28:44 +000025class I18N {
26 public:
27 // Creates an ObjectTemplate with one internal field.
28 static Handle<ObjectTemplateInfo> GetTemplate(Isolate* isolate);
29
30 // Creates an ObjectTemplate with two internal fields.
31 static Handle<ObjectTemplateInfo> GetTemplate2(Isolate* isolate);
32
33 private:
34 I18N();
35};
36
37
38class DateFormat {
39 public:
40 // Create a formatter for the specificied locale and options. Returns the
41 // resolved settings for the locale / options.
42 static icu::SimpleDateFormat* InitializeDateTimeFormat(
43 Isolate* isolate,
44 Handle<String> locale,
45 Handle<JSObject> options,
46 Handle<JSObject> resolved);
47
48 // Unpacks date format object from corresponding JavaScript object.
49 static icu::SimpleDateFormat* UnpackDateFormat(Isolate* isolate,
50 Handle<JSObject> obj);
51
52 // Release memory we allocated for the DateFormat once the JS object that
53 // holds the pointer gets garbage collected.
Ben Murdochc5610432016-08-08 18:44:38 +010054 static void DeleteDateFormat(const v8::WeakCallbackInfo<void>& data);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000055
56 private:
57 DateFormat();
58};
59
60
61class NumberFormat {
62 public:
63 // Create a formatter for the specificied locale and options. Returns the
64 // resolved settings for the locale / options.
65 static icu::DecimalFormat* InitializeNumberFormat(
66 Isolate* isolate,
67 Handle<String> locale,
68 Handle<JSObject> options,
69 Handle<JSObject> resolved);
70
71 // Unpacks number format object from corresponding JavaScript object.
72 static icu::DecimalFormat* UnpackNumberFormat(Isolate* isolate,
73 Handle<JSObject> obj);
74
75 // Release memory we allocated for the NumberFormat once the JS object that
76 // holds the pointer gets garbage collected.
Ben Murdochc5610432016-08-08 18:44:38 +010077 static void DeleteNumberFormat(const v8::WeakCallbackInfo<void>& data);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000078
79 private:
80 NumberFormat();
81};
82
83
84class Collator {
85 public:
86 // Create a collator for the specificied locale and options. Returns the
87 // resolved settings for the locale / options.
88 static icu::Collator* InitializeCollator(
89 Isolate* isolate,
90 Handle<String> locale,
91 Handle<JSObject> options,
92 Handle<JSObject> resolved);
93
94 // Unpacks collator object from corresponding JavaScript object.
95 static icu::Collator* UnpackCollator(Isolate* isolate, Handle<JSObject> obj);
96
97 // Release memory we allocated for the Collator once the JS object that holds
98 // the pointer gets garbage collected.
Ben Murdochc5610432016-08-08 18:44:38 +010099 static void DeleteCollator(const v8::WeakCallbackInfo<void>& data);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000100
101 private:
102 Collator();
103};
104
105class BreakIterator {
106 public:
107 // Create a BreakIterator for the specificied locale and options. Returns the
108 // resolved settings for the locale / options.
109 static icu::BreakIterator* InitializeBreakIterator(
110 Isolate* isolate,
111 Handle<String> locale,
112 Handle<JSObject> options,
113 Handle<JSObject> resolved);
114
115 // Unpacks break iterator object from corresponding JavaScript object.
116 static icu::BreakIterator* UnpackBreakIterator(Isolate* isolate,
117 Handle<JSObject> obj);
118
119 // Release memory we allocated for the BreakIterator once the JS object that
120 // holds the pointer gets garbage collected.
Ben Murdochc5610432016-08-08 18:44:38 +0100121 static void DeleteBreakIterator(const v8::WeakCallbackInfo<void>& data);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000122
123 private:
124 BreakIterator();
125};
126
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000127} // namespace internal
128} // namespace v8
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000129
130#endif // V8_I18N_H_