js/src/builtin/Intl.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/builtin/Intl.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,199 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef builtin_Intl_h
    1.11 +#define builtin_Intl_h
    1.12 +
    1.13 +#include "NamespaceImports.h"
    1.14 +#include "unicode/utypes.h"
    1.15 +
    1.16 +/*
    1.17 + * The Intl module specified by standard ECMA-402,
    1.18 + * ECMAScript Internationalization API Specification.
    1.19 + */
    1.20 +
    1.21 +/**
    1.22 + * Initializes the Intl Object and its standard built-in properties.
    1.23 + * Spec: ECMAScript Internationalization API Specification, 8.0, 8.1
    1.24 + */
    1.25 +extern JSObject *
    1.26 +js_InitIntlClass(JSContext *cx, js::HandleObject obj);
    1.27 +
    1.28 +namespace js {
    1.29 +
    1.30 +/*
    1.31 + * The following functions are for use by self-hosted code.
    1.32 + */
    1.33 +
    1.34 +
    1.35 +/******************** Collator ********************/
    1.36 +
    1.37 +/**
    1.38 + * Returns a new instance of the standard built-in Collator constructor.
    1.39 + * Self-hosted code cannot cache this constructor (as it does for others in
    1.40 + * Utilities.js) because it is initialized after self-hosted code is compiled.
    1.41 + *
    1.42 + * Usage: collator = intl_Collator(locales, options)
    1.43 + */
    1.44 +extern bool
    1.45 +intl_Collator(JSContext *cx, unsigned argc, Value *vp);
    1.46 +
    1.47 +/**
    1.48 + * Returns an object indicating the supported locales for collation
    1.49 + * by having a true-valued property for each such locale with the
    1.50 + * canonicalized language tag as the property name. The object has no
    1.51 + * prototype.
    1.52 + *
    1.53 + * Usage: availableLocales = intl_Collator_availableLocales()
    1.54 + */
    1.55 +extern bool
    1.56 +intl_Collator_availableLocales(JSContext *cx, unsigned argc, Value *vp);
    1.57 +
    1.58 +/**
    1.59 + * Returns an array with the collation type identifiers per Unicode
    1.60 + * Technical Standard 35, Unicode Locale Data Markup Language, for the
    1.61 + * collations supported for the given locale. "standard" and "search" are
    1.62 + * excluded.
    1.63 + *
    1.64 + * Usage: collations = intl_availableCollations(locale)
    1.65 + */
    1.66 +extern bool
    1.67 +intl_availableCollations(JSContext *cx, unsigned argc, Value *vp);
    1.68 +
    1.69 +/**
    1.70 + * Compares x and y (which must be String values), and returns a number less
    1.71 + * than 0 if x < y, 0 if x = y, or a number greater than 0 if x > y according
    1.72 + * to the sort order for the locale and collation options of the given
    1.73 + * Collator.
    1.74 + *
    1.75 + * Spec: ECMAScript Internationalization API Specification, 10.3.2.
    1.76 + *
    1.77 + * Usage: result = intl_CompareStrings(collator, x, y)
    1.78 + */
    1.79 +extern bool
    1.80 +intl_CompareStrings(JSContext *cx, unsigned argc, Value *vp);
    1.81 +
    1.82 +
    1.83 +/******************** NumberFormat ********************/
    1.84 +
    1.85 +/**
    1.86 + * Returns a new instance of the standard built-in NumberFormat constructor.
    1.87 + * Self-hosted code cannot cache this constructor (as it does for others in
    1.88 + * Utilities.js) because it is initialized after self-hosted code is compiled.
    1.89 + *
    1.90 + * Usage: numberFormat = intl_NumberFormat(locales, options)
    1.91 + */
    1.92 +extern bool
    1.93 +intl_NumberFormat(JSContext *cx, unsigned argc, Value *vp);
    1.94 +
    1.95 +/**
    1.96 + * Returns an object indicating the supported locales for number formatting
    1.97 + * by having a true-valued property for each such locale with the
    1.98 + * canonicalized language tag as the property name. The object has no
    1.99 + * prototype.
   1.100 + *
   1.101 + * Usage: availableLocales = intl_NumberFormat_availableLocales()
   1.102 + */
   1.103 +extern bool
   1.104 +intl_NumberFormat_availableLocales(JSContext *cx, unsigned argc, Value *vp);
   1.105 +
   1.106 +/**
   1.107 + * Returns the numbering system type identifier per Unicode
   1.108 + * Technical Standard 35, Unicode Locale Data Markup Language, for the
   1.109 + * default numbering system for the given locale.
   1.110 + *
   1.111 + * Usage: defaultNumberingSystem = intl_numberingSystem(locale)
   1.112 + */
   1.113 +extern bool
   1.114 +intl_numberingSystem(JSContext *cx, unsigned argc, Value *vp);
   1.115 +
   1.116 +/**
   1.117 + * Returns a string representing the number x according to the effective
   1.118 + * locale and the formatting options of the given NumberFormat.
   1.119 + *
   1.120 + * Spec: ECMAScript Internationalization API Specification, 11.3.2.
   1.121 + *
   1.122 + * Usage: formatted = intl_FormatNumber(numberFormat, x)
   1.123 + */
   1.124 +extern bool
   1.125 +intl_FormatNumber(JSContext *cx, unsigned argc, Value *vp);
   1.126 +
   1.127 +
   1.128 +/******************** DateTimeFormat ********************/
   1.129 +
   1.130 +/**
   1.131 + * Returns a new instance of the standard built-in DateTimeFormat constructor.
   1.132 + * Self-hosted code cannot cache this constructor (as it does for others in
   1.133 + * Utilities.js) because it is initialized after self-hosted code is compiled.
   1.134 + *
   1.135 + * Usage: dateTimeFormat = intl_DateTimeFormat(locales, options)
   1.136 + */
   1.137 +extern bool
   1.138 +intl_DateTimeFormat(JSContext *cx, unsigned argc, Value *vp);
   1.139 +
   1.140 +/**
   1.141 + * Returns an object indicating the supported locales for date and time
   1.142 + * formatting by having a true-valued property for each such locale with the
   1.143 + * canonicalized language tag as the property name. The object has no
   1.144 + * prototype.
   1.145 + *
   1.146 + * Usage: availableLocales = intl_DateTimeFormat_availableLocales()
   1.147 + */
   1.148 +extern bool
   1.149 +intl_DateTimeFormat_availableLocales(JSContext *cx, unsigned argc, Value *vp);
   1.150 +
   1.151 +/**
   1.152 + * Returns an array with the calendar type identifiers per Unicode
   1.153 + * Technical Standard 35, Unicode Locale Data Markup Language, for the
   1.154 + * supported calendars for the given locale. The default calendar is
   1.155 + * element 0.
   1.156 + *
   1.157 + * Usage: calendars = intl_availableCalendars(locale)
   1.158 + */
   1.159 +extern bool
   1.160 +intl_availableCalendars(JSContext *cx, unsigned argc, Value *vp);
   1.161 +
   1.162 +/**
   1.163 + * Return a pattern in the date-time format pattern language of Unicode
   1.164 + * Technical Standard 35, Unicode Locale Data Markup Language, for the
   1.165 + * best-fit date-time format pattern corresponding to skeleton for the
   1.166 + * given locale.
   1.167 + *
   1.168 + * Usage: pattern = intl_patternForSkeleton(locale, skeleton)
   1.169 + */
   1.170 +extern bool
   1.171 +intl_patternForSkeleton(JSContext *cx, unsigned argc, Value *vp);
   1.172 +
   1.173 +/**
   1.174 + * Returns a String value representing x (which must be a Number value)
   1.175 + * according to the effective locale and the formatting options of the
   1.176 + * given DateTimeFormat.
   1.177 + *
   1.178 + * Spec: ECMAScript Internationalization API Specification, 12.3.2.
   1.179 + *
   1.180 + * Usage: formatted = intl_FormatDateTime(dateTimeFormat, x)
   1.181 + */
   1.182 +extern bool
   1.183 +intl_FormatDateTime(JSContext *cx, unsigned argc, Value *vp);
   1.184 +
   1.185 +/**
   1.186 + * Cast jschar* strings to UChar* strings used by ICU.
   1.187 + */
   1.188 +inline const UChar *
   1.189 +JSCharToUChar(const jschar *chars)
   1.190 +{
   1.191 +  return reinterpret_cast<const UChar *>(chars);
   1.192 +}
   1.193 +
   1.194 +inline UChar *
   1.195 +JSCharToUChar(jschar *chars)
   1.196 +{
   1.197 +  return reinterpret_cast<UChar *>(chars);
   1.198 +}
   1.199 +
   1.200 +} // namespace js
   1.201 +
   1.202 +#endif /* builtin_Intl_h */

mercurial