i18n.h 3.78 KB
Newer Older
1
// Copyright 2013 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4 5
// limitations under the License.

6 7
#ifndef V8_I18N_H_
#define V8_I18N_H_
8

9
#include "src/handles.h"
10
#include "unicode/uversion.h"
11 12

namespace U_ICU_NAMESPACE {
13
class BreakIterator;
14
class Collator;
15
class DecimalFormat;
16 17 18
class SimpleDateFormat;
}

19 20
namespace v8 {
namespace internal {
21

22 23 24
// Forward declarations.
class ObjectTemplateInfo;

25
class I18N {
26
 public:
27 28 29 30 31 32 33 34 35
  // Creates an ObjectTemplate with one internal field.
  static Handle<ObjectTemplateInfo> GetTemplate(Isolate* isolate);

  // Creates an ObjectTemplate with two internal fields.
  static Handle<ObjectTemplateInfo> GetTemplate2(Isolate* isolate);

 private:
  I18N();
};
36

37

38 39 40 41 42 43 44 45 46
class DateFormat {
 public:
  // Create a formatter for the specificied locale and options. Returns the
  // resolved settings for the locale / options.
  static icu::SimpleDateFormat* InitializeDateTimeFormat(
      Isolate* isolate,
      Handle<String> locale,
      Handle<JSObject> options,
      Handle<JSObject> resolved);
47 48

  // Unpacks date format object from corresponding JavaScript object.
49 50
  static icu::SimpleDateFormat* UnpackDateFormat(Isolate* isolate,
                                                 Handle<JSObject> obj);
51 52 53

  // Release memory we allocated for the DateFormat once the JS object that
  // holds the pointer gets garbage collected.
54
  static void DeleteDateFormat(const v8::WeakCallbackInfo<void>& data);
55

56 57 58 59
 private:
  DateFormat();
};

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

class NumberFormat {
 public:
  // Create a formatter for the specificied locale and options. Returns the
  // resolved settings for the locale / options.
  static icu::DecimalFormat* InitializeNumberFormat(
      Isolate* isolate,
      Handle<String> locale,
      Handle<JSObject> options,
      Handle<JSObject> resolved);

  // Unpacks number format object from corresponding JavaScript object.
  static icu::DecimalFormat* UnpackNumberFormat(Isolate* isolate,
                                                Handle<JSObject> obj);

  // Release memory we allocated for the NumberFormat once the JS object that
  // holds the pointer gets garbage collected.
77
  static void DeleteNumberFormat(const v8::WeakCallbackInfo<void>& data);
78

79 80 81 82
 private:
  NumberFormat();
};

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

class Collator {
 public:
  // Create a collator for the specificied locale and options. Returns the
  // resolved settings for the locale / options.
  static icu::Collator* InitializeCollator(
      Isolate* isolate,
      Handle<String> locale,
      Handle<JSObject> options,
      Handle<JSObject> resolved);

  // Unpacks collator object from corresponding JavaScript object.
  static icu::Collator* UnpackCollator(Isolate* isolate, Handle<JSObject> obj);

  // Release memory we allocated for the Collator once the JS object that holds
  // the pointer gets garbage collected.
99
  static void DeleteCollator(const v8::WeakCallbackInfo<void>& data);
100

101 102 103 104
 private:
  Collator();
};

105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
class BreakIterator {
 public:
  // Create a BreakIterator for the specificied locale and options. Returns the
  // resolved settings for the locale / options.
  static icu::BreakIterator* InitializeBreakIterator(
      Isolate* isolate,
      Handle<String> locale,
      Handle<JSObject> options,
      Handle<JSObject> resolved);

  // Unpacks break iterator object from corresponding JavaScript object.
  static icu::BreakIterator* UnpackBreakIterator(Isolate* isolate,
                                                 Handle<JSObject> obj);

  // Release memory we allocated for the BreakIterator once the JS object that
  // holds the pointer gets garbage collected.
121
  static void DeleteBreakIterator(const v8::WeakCallbackInfo<void>& data);
122 123 124 125 126

 private:
  BreakIterator();
};

127 128
}  // namespace internal
}  // namespace v8
129

130
#endif  // V8_I18N_H_