2013-07-03 11:22:29 +00:00
|
|
|
// Copyright 2013 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2013-07-03 11:22:29 +00:00
|
|
|
// limitations under the License.
|
|
|
|
|
2013-08-07 03:40:44 +00:00
|
|
|
#ifndef V8_I18N_H_
|
|
|
|
#define V8_I18N_H_
|
2013-07-03 11:22:29 +00:00
|
|
|
|
2015-08-11 07:34:10 +00:00
|
|
|
#include "src/handles.h"
|
2014-06-20 08:40:11 +00:00
|
|
|
#include "unicode/uversion.h"
|
2013-07-03 11:22:29 +00:00
|
|
|
|
|
|
|
namespace U_ICU_NAMESPACE {
|
2013-08-20 08:46:36 +00:00
|
|
|
class BreakIterator;
|
2013-08-09 09:51:09 +00:00
|
|
|
class Collator;
|
2013-08-07 12:14:50 +00:00
|
|
|
class DecimalFormat;
|
2013-07-03 11:22:29 +00:00
|
|
|
class SimpleDateFormat;
|
|
|
|
}
|
|
|
|
|
2013-08-07 03:40:44 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2013-07-03 11:22:29 +00:00
|
|
|
|
2015-08-11 12:00:01 +00:00
|
|
|
// Forward declarations.
|
|
|
|
class ObjectTemplateInfo;
|
|
|
|
|
2013-08-07 03:40:44 +00:00
|
|
|
class I18N {
|
2013-07-03 11:22:29 +00:00
|
|
|
public:
|
2013-08-07 03:40:44 +00:00
|
|
|
// 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();
|
|
|
|
};
|
2013-07-03 11:22:29 +00:00
|
|
|
|
2013-08-07 12:14:50 +00:00
|
|
|
|
2013-08-07 03:40:44 +00:00
|
|
|
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);
|
2013-07-03 11:22:29 +00:00
|
|
|
|
|
|
|
// Unpacks date format object from corresponding JavaScript object.
|
2013-08-07 03:40:44 +00:00
|
|
|
static icu::SimpleDateFormat* UnpackDateFormat(Isolate* isolate,
|
|
|
|
Handle<JSObject> obj);
|
2013-07-03 11:22:29 +00:00
|
|
|
|
|
|
|
// Release memory we allocated for the DateFormat once the JS object that
|
|
|
|
// holds the pointer gets garbage collected.
|
2013-12-18 08:09:37 +00:00
|
|
|
static void DeleteDateFormat(
|
|
|
|
const v8::WeakCallbackData<v8::Value, void>& data);
|
|
|
|
|
2013-07-03 11:22:29 +00:00
|
|
|
private:
|
|
|
|
DateFormat();
|
|
|
|
};
|
|
|
|
|
2013-08-07 12:14:50 +00:00
|
|
|
|
|
|
|
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.
|
2013-12-18 08:09:37 +00:00
|
|
|
static void DeleteNumberFormat(
|
|
|
|
const v8::WeakCallbackData<v8::Value, void>& data);
|
|
|
|
|
2013-08-07 12:14:50 +00:00
|
|
|
private:
|
|
|
|
NumberFormat();
|
|
|
|
};
|
|
|
|
|
2013-08-09 09:51:09 +00:00
|
|
|
|
|
|
|
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.
|
2013-12-18 08:09:37 +00:00
|
|
|
static void DeleteCollator(
|
|
|
|
const v8::WeakCallbackData<v8::Value, void>& data);
|
|
|
|
|
2013-08-09 09:51:09 +00:00
|
|
|
private:
|
|
|
|
Collator();
|
|
|
|
};
|
|
|
|
|
2013-08-20 08:46:36 +00:00
|
|
|
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.
|
2013-12-18 08:09:37 +00:00
|
|
|
static void DeleteBreakIterator(
|
|
|
|
const v8::WeakCallbackData<v8::Value, void>& data);
|
2013-08-20 08:46:36 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
BreakIterator();
|
|
|
|
};
|
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2013-07-03 11:22:29 +00:00
|
|
|
|
2013-08-07 03:40:44 +00:00
|
|
|
#endif // V8_I18N_H_
|