i18n.h 4.08 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 "src/objects.h"
11
#include "unicode/uversion.h"
12 13

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

20 21
namespace v8 {
namespace internal {
22

23 24 25 26 27 28 29 30 31
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);
32 33

  // Unpacks date format object from corresponding JavaScript object.
34 35
  static icu::SimpleDateFormat* UnpackDateFormat(Isolate* isolate,
                                                 Handle<JSObject> obj);
36 37 38

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

41 42 43 44
  // Layout description.
  static const int kSimpleDateFormat = JSObject::kHeaderSize;
  static const int kSize = kSimpleDateFormat + kPointerSize;

45 46 47 48
 private:
  DateFormat();
};

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

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.
66
  static void DeleteNumberFormat(const v8::WeakCallbackInfo<void>& data);
67

68 69 70 71
  // Layout description.
  static const int kDecimalFormat = JSObject::kHeaderSize;
  static const int kSize = kDecimalFormat + kPointerSize;

72 73 74 75
 private:
  NumberFormat();
};

76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

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.
92
  static void DeleteCollator(const v8::WeakCallbackInfo<void>& data);
93

94 95 96 97
  // Layout description.
  static const int kCollator = JSObject::kHeaderSize;
  static const int kSize = kCollator + kPointerSize;

98 99 100 101
 private:
  Collator();
};

102
class V8BreakIterator {
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
 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.
118
  static void DeleteBreakIterator(const v8::WeakCallbackInfo<void>& data);
119

120 121 122 123 124
  // Layout description.
  static const int kBreakIterator = JSObject::kHeaderSize;
  static const int kUnicodeString = kBreakIterator + kPointerSize;
  static const int kSize = kUnicodeString + kPointerSize;

125
 private:
126
  V8BreakIterator();
127 128
};

129 130
}  // namespace internal
}  // namespace v8
131

132
#endif  // V8_I18N_H_