michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef builtin_Intl_h michael@0: #define builtin_Intl_h michael@0: michael@0: #include "NamespaceImports.h" michael@0: #include "unicode/utypes.h" michael@0: michael@0: /* michael@0: * The Intl module specified by standard ECMA-402, michael@0: * ECMAScript Internationalization API Specification. michael@0: */ michael@0: michael@0: /** michael@0: * Initializes the Intl Object and its standard built-in properties. michael@0: * Spec: ECMAScript Internationalization API Specification, 8.0, 8.1 michael@0: */ michael@0: extern JSObject * michael@0: js_InitIntlClass(JSContext *cx, js::HandleObject obj); michael@0: michael@0: namespace js { michael@0: michael@0: /* michael@0: * The following functions are for use by self-hosted code. michael@0: */ michael@0: michael@0: michael@0: /******************** Collator ********************/ michael@0: michael@0: /** michael@0: * Returns a new instance of the standard built-in Collator constructor. michael@0: * Self-hosted code cannot cache this constructor (as it does for others in michael@0: * Utilities.js) because it is initialized after self-hosted code is compiled. michael@0: * michael@0: * Usage: collator = intl_Collator(locales, options) michael@0: */ michael@0: extern bool michael@0: intl_Collator(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Returns an object indicating the supported locales for collation michael@0: * by having a true-valued property for each such locale with the michael@0: * canonicalized language tag as the property name. The object has no michael@0: * prototype. michael@0: * michael@0: * Usage: availableLocales = intl_Collator_availableLocales() michael@0: */ michael@0: extern bool michael@0: intl_Collator_availableLocales(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Returns an array with the collation type identifiers per Unicode michael@0: * Technical Standard 35, Unicode Locale Data Markup Language, for the michael@0: * collations supported for the given locale. "standard" and "search" are michael@0: * excluded. michael@0: * michael@0: * Usage: collations = intl_availableCollations(locale) michael@0: */ michael@0: extern bool michael@0: intl_availableCollations(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Compares x and y (which must be String values), and returns a number less michael@0: * than 0 if x < y, 0 if x = y, or a number greater than 0 if x > y according michael@0: * to the sort order for the locale and collation options of the given michael@0: * Collator. michael@0: * michael@0: * Spec: ECMAScript Internationalization API Specification, 10.3.2. michael@0: * michael@0: * Usage: result = intl_CompareStrings(collator, x, y) michael@0: */ michael@0: extern bool michael@0: intl_CompareStrings(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: michael@0: /******************** NumberFormat ********************/ michael@0: michael@0: /** michael@0: * Returns a new instance of the standard built-in NumberFormat constructor. michael@0: * Self-hosted code cannot cache this constructor (as it does for others in michael@0: * Utilities.js) because it is initialized after self-hosted code is compiled. michael@0: * michael@0: * Usage: numberFormat = intl_NumberFormat(locales, options) michael@0: */ michael@0: extern bool michael@0: intl_NumberFormat(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Returns an object indicating the supported locales for number formatting michael@0: * by having a true-valued property for each such locale with the michael@0: * canonicalized language tag as the property name. The object has no michael@0: * prototype. michael@0: * michael@0: * Usage: availableLocales = intl_NumberFormat_availableLocales() michael@0: */ michael@0: extern bool michael@0: intl_NumberFormat_availableLocales(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Returns the numbering system type identifier per Unicode michael@0: * Technical Standard 35, Unicode Locale Data Markup Language, for the michael@0: * default numbering system for the given locale. michael@0: * michael@0: * Usage: defaultNumberingSystem = intl_numberingSystem(locale) michael@0: */ michael@0: extern bool michael@0: intl_numberingSystem(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Returns a string representing the number x according to the effective michael@0: * locale and the formatting options of the given NumberFormat. michael@0: * michael@0: * Spec: ECMAScript Internationalization API Specification, 11.3.2. michael@0: * michael@0: * Usage: formatted = intl_FormatNumber(numberFormat, x) michael@0: */ michael@0: extern bool michael@0: intl_FormatNumber(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: michael@0: /******************** DateTimeFormat ********************/ michael@0: michael@0: /** michael@0: * Returns a new instance of the standard built-in DateTimeFormat constructor. michael@0: * Self-hosted code cannot cache this constructor (as it does for others in michael@0: * Utilities.js) because it is initialized after self-hosted code is compiled. michael@0: * michael@0: * Usage: dateTimeFormat = intl_DateTimeFormat(locales, options) michael@0: */ michael@0: extern bool michael@0: intl_DateTimeFormat(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Returns an object indicating the supported locales for date and time michael@0: * formatting by having a true-valued property for each such locale with the michael@0: * canonicalized language tag as the property name. The object has no michael@0: * prototype. michael@0: * michael@0: * Usage: availableLocales = intl_DateTimeFormat_availableLocales() michael@0: */ michael@0: extern bool michael@0: intl_DateTimeFormat_availableLocales(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Returns an array with the calendar type identifiers per Unicode michael@0: * Technical Standard 35, Unicode Locale Data Markup Language, for the michael@0: * supported calendars for the given locale. The default calendar is michael@0: * element 0. michael@0: * michael@0: * Usage: calendars = intl_availableCalendars(locale) michael@0: */ michael@0: extern bool michael@0: intl_availableCalendars(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Return a pattern in the date-time format pattern language of Unicode michael@0: * Technical Standard 35, Unicode Locale Data Markup Language, for the michael@0: * best-fit date-time format pattern corresponding to skeleton for the michael@0: * given locale. michael@0: * michael@0: * Usage: pattern = intl_patternForSkeleton(locale, skeleton) michael@0: */ michael@0: extern bool michael@0: intl_patternForSkeleton(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Returns a String value representing x (which must be a Number value) michael@0: * according to the effective locale and the formatting options of the michael@0: * given DateTimeFormat. michael@0: * michael@0: * Spec: ECMAScript Internationalization API Specification, 12.3.2. michael@0: * michael@0: * Usage: formatted = intl_FormatDateTime(dateTimeFormat, x) michael@0: */ michael@0: extern bool michael@0: intl_FormatDateTime(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /** michael@0: * Cast jschar* strings to UChar* strings used by ICU. michael@0: */ michael@0: inline const UChar * michael@0: JSCharToUChar(const jschar *chars) michael@0: { michael@0: return reinterpret_cast(chars); michael@0: } michael@0: michael@0: inline UChar * michael@0: JSCharToUChar(jschar *chars) michael@0: { michael@0: return reinterpret_cast(chars); michael@0: } michael@0: michael@0: } // namespace js michael@0: michael@0: #endif /* builtin_Intl_h */