js/src/builtin/Intl.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef builtin_Intl_h
michael@0 8 #define builtin_Intl_h
michael@0 9
michael@0 10 #include "NamespaceImports.h"
michael@0 11 #include "unicode/utypes.h"
michael@0 12
michael@0 13 /*
michael@0 14 * The Intl module specified by standard ECMA-402,
michael@0 15 * ECMAScript Internationalization API Specification.
michael@0 16 */
michael@0 17
michael@0 18 /**
michael@0 19 * Initializes the Intl Object and its standard built-in properties.
michael@0 20 * Spec: ECMAScript Internationalization API Specification, 8.0, 8.1
michael@0 21 */
michael@0 22 extern JSObject *
michael@0 23 js_InitIntlClass(JSContext *cx, js::HandleObject obj);
michael@0 24
michael@0 25 namespace js {
michael@0 26
michael@0 27 /*
michael@0 28 * The following functions are for use by self-hosted code.
michael@0 29 */
michael@0 30
michael@0 31
michael@0 32 /******************** Collator ********************/
michael@0 33
michael@0 34 /**
michael@0 35 * Returns a new instance of the standard built-in Collator constructor.
michael@0 36 * Self-hosted code cannot cache this constructor (as it does for others in
michael@0 37 * Utilities.js) because it is initialized after self-hosted code is compiled.
michael@0 38 *
michael@0 39 * Usage: collator = intl_Collator(locales, options)
michael@0 40 */
michael@0 41 extern bool
michael@0 42 intl_Collator(JSContext *cx, unsigned argc, Value *vp);
michael@0 43
michael@0 44 /**
michael@0 45 * Returns an object indicating the supported locales for collation
michael@0 46 * by having a true-valued property for each such locale with the
michael@0 47 * canonicalized language tag as the property name. The object has no
michael@0 48 * prototype.
michael@0 49 *
michael@0 50 * Usage: availableLocales = intl_Collator_availableLocales()
michael@0 51 */
michael@0 52 extern bool
michael@0 53 intl_Collator_availableLocales(JSContext *cx, unsigned argc, Value *vp);
michael@0 54
michael@0 55 /**
michael@0 56 * Returns an array with the collation type identifiers per Unicode
michael@0 57 * Technical Standard 35, Unicode Locale Data Markup Language, for the
michael@0 58 * collations supported for the given locale. "standard" and "search" are
michael@0 59 * excluded.
michael@0 60 *
michael@0 61 * Usage: collations = intl_availableCollations(locale)
michael@0 62 */
michael@0 63 extern bool
michael@0 64 intl_availableCollations(JSContext *cx, unsigned argc, Value *vp);
michael@0 65
michael@0 66 /**
michael@0 67 * Compares x and y (which must be String values), and returns a number less
michael@0 68 * than 0 if x < y, 0 if x = y, or a number greater than 0 if x > y according
michael@0 69 * to the sort order for the locale and collation options of the given
michael@0 70 * Collator.
michael@0 71 *
michael@0 72 * Spec: ECMAScript Internationalization API Specification, 10.3.2.
michael@0 73 *
michael@0 74 * Usage: result = intl_CompareStrings(collator, x, y)
michael@0 75 */
michael@0 76 extern bool
michael@0 77 intl_CompareStrings(JSContext *cx, unsigned argc, Value *vp);
michael@0 78
michael@0 79
michael@0 80 /******************** NumberFormat ********************/
michael@0 81
michael@0 82 /**
michael@0 83 * Returns a new instance of the standard built-in NumberFormat constructor.
michael@0 84 * Self-hosted code cannot cache this constructor (as it does for others in
michael@0 85 * Utilities.js) because it is initialized after self-hosted code is compiled.
michael@0 86 *
michael@0 87 * Usage: numberFormat = intl_NumberFormat(locales, options)
michael@0 88 */
michael@0 89 extern bool
michael@0 90 intl_NumberFormat(JSContext *cx, unsigned argc, Value *vp);
michael@0 91
michael@0 92 /**
michael@0 93 * Returns an object indicating the supported locales for number formatting
michael@0 94 * by having a true-valued property for each such locale with the
michael@0 95 * canonicalized language tag as the property name. The object has no
michael@0 96 * prototype.
michael@0 97 *
michael@0 98 * Usage: availableLocales = intl_NumberFormat_availableLocales()
michael@0 99 */
michael@0 100 extern bool
michael@0 101 intl_NumberFormat_availableLocales(JSContext *cx, unsigned argc, Value *vp);
michael@0 102
michael@0 103 /**
michael@0 104 * Returns the numbering system type identifier per Unicode
michael@0 105 * Technical Standard 35, Unicode Locale Data Markup Language, for the
michael@0 106 * default numbering system for the given locale.
michael@0 107 *
michael@0 108 * Usage: defaultNumberingSystem = intl_numberingSystem(locale)
michael@0 109 */
michael@0 110 extern bool
michael@0 111 intl_numberingSystem(JSContext *cx, unsigned argc, Value *vp);
michael@0 112
michael@0 113 /**
michael@0 114 * Returns a string representing the number x according to the effective
michael@0 115 * locale and the formatting options of the given NumberFormat.
michael@0 116 *
michael@0 117 * Spec: ECMAScript Internationalization API Specification, 11.3.2.
michael@0 118 *
michael@0 119 * Usage: formatted = intl_FormatNumber(numberFormat, x)
michael@0 120 */
michael@0 121 extern bool
michael@0 122 intl_FormatNumber(JSContext *cx, unsigned argc, Value *vp);
michael@0 123
michael@0 124
michael@0 125 /******************** DateTimeFormat ********************/
michael@0 126
michael@0 127 /**
michael@0 128 * Returns a new instance of the standard built-in DateTimeFormat constructor.
michael@0 129 * Self-hosted code cannot cache this constructor (as it does for others in
michael@0 130 * Utilities.js) because it is initialized after self-hosted code is compiled.
michael@0 131 *
michael@0 132 * Usage: dateTimeFormat = intl_DateTimeFormat(locales, options)
michael@0 133 */
michael@0 134 extern bool
michael@0 135 intl_DateTimeFormat(JSContext *cx, unsigned argc, Value *vp);
michael@0 136
michael@0 137 /**
michael@0 138 * Returns an object indicating the supported locales for date and time
michael@0 139 * formatting by having a true-valued property for each such locale with the
michael@0 140 * canonicalized language tag as the property name. The object has no
michael@0 141 * prototype.
michael@0 142 *
michael@0 143 * Usage: availableLocales = intl_DateTimeFormat_availableLocales()
michael@0 144 */
michael@0 145 extern bool
michael@0 146 intl_DateTimeFormat_availableLocales(JSContext *cx, unsigned argc, Value *vp);
michael@0 147
michael@0 148 /**
michael@0 149 * Returns an array with the calendar type identifiers per Unicode
michael@0 150 * Technical Standard 35, Unicode Locale Data Markup Language, for the
michael@0 151 * supported calendars for the given locale. The default calendar is
michael@0 152 * element 0.
michael@0 153 *
michael@0 154 * Usage: calendars = intl_availableCalendars(locale)
michael@0 155 */
michael@0 156 extern bool
michael@0 157 intl_availableCalendars(JSContext *cx, unsigned argc, Value *vp);
michael@0 158
michael@0 159 /**
michael@0 160 * Return a pattern in the date-time format pattern language of Unicode
michael@0 161 * Technical Standard 35, Unicode Locale Data Markup Language, for the
michael@0 162 * best-fit date-time format pattern corresponding to skeleton for the
michael@0 163 * given locale.
michael@0 164 *
michael@0 165 * Usage: pattern = intl_patternForSkeleton(locale, skeleton)
michael@0 166 */
michael@0 167 extern bool
michael@0 168 intl_patternForSkeleton(JSContext *cx, unsigned argc, Value *vp);
michael@0 169
michael@0 170 /**
michael@0 171 * Returns a String value representing x (which must be a Number value)
michael@0 172 * according to the effective locale and the formatting options of the
michael@0 173 * given DateTimeFormat.
michael@0 174 *
michael@0 175 * Spec: ECMAScript Internationalization API Specification, 12.3.2.
michael@0 176 *
michael@0 177 * Usage: formatted = intl_FormatDateTime(dateTimeFormat, x)
michael@0 178 */
michael@0 179 extern bool
michael@0 180 intl_FormatDateTime(JSContext *cx, unsigned argc, Value *vp);
michael@0 181
michael@0 182 /**
michael@0 183 * Cast jschar* strings to UChar* strings used by ICU.
michael@0 184 */
michael@0 185 inline const UChar *
michael@0 186 JSCharToUChar(const jschar *chars)
michael@0 187 {
michael@0 188 return reinterpret_cast<const UChar *>(chars);
michael@0 189 }
michael@0 190
michael@0 191 inline UChar *
michael@0 192 JSCharToUChar(jschar *chars)
michael@0 193 {
michael@0 194 return reinterpret_cast<UChar *>(chars);
michael@0 195 }
michael@0 196
michael@0 197 } // namespace js
michael@0 198
michael@0 199 #endif /* builtin_Intl_h */

mercurial