diff --git a/js/public/experimental/Intl.h b/js/public/experimental/Intl.h new file mode 100644 index 000000000000..88ea80d2d313 --- /dev/null +++ b/js/public/experimental/Intl.h @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef js_experimental_Intl_h +#define js_experimental_Intl_h + +#include "jstypes.h" // JS_FRIEND_API + +#include "js/RootingAPI.h" // JS::Handle + +struct JS_PUBLIC_API JSContext; +class JS_PUBLIC_API JSObject; + +namespace JS { + +/** + * Create and add the Intl.MozDateTimeFormat constructor function to the + * provided object. + * + * This custom date/time formatter constructor gives users the ability to + * specify a custom format pattern. This pattern is passed *directly* to ICU + * with NO SYNTAX PARSING OR VALIDATION WHATSOEVER. ICU appears to have a + * modicum of testing of this, and it won't fall over completely if passed bad + * input. But the current behavior is entirely under-specified and emphatically + * not shippable on the web, and it *must* be fixed before this functionality + * can be exposed in the real world. (There are also some questions about + * whether the format exposed here is the *right* one to standardize, that will + * also need to be resolved to ship this.) + * + * If JS was built without JS_HAS_INTL_API, this function will throw an + * exception. + */ +extern JS_FRIEND_API bool AddMozDateTimeFormatConstructor( + JSContext* cx, Handle intl); + +/** + * Create and add the Intl.MozDisplayNames constructor function to the + * provided object. This constructor acts like the standard |Intl.DisplayNames| + * but accepts certain additional syntax that isn't standardized to the point of + * being shippable. + * + * If JS was built without JS_HAS_INTL_API, this function will throw an + * exception. + */ +extern JS_FRIEND_API bool AddMozDisplayNamesConstructor(JSContext* cx, + Handle intl); + +/** + * Create and add the Intl.DisplayNames constructor function to the provided + * object, implementing standardized behavior (that isn't yet shippable because + * we're not *quite* comfortable with the spec's progress yet). + * + * If JS was built without JS_HAS_INTL_API, this function will throw an + * exception. + */ +extern JS_FRIEND_API bool AddDisplayNamesConstructor(JSContext* cx, + Handle intl); + +} // namespace JS + +#endif // js_experimental_Intl_h diff --git a/js/src/builtin/intl/DateTimeFormat.cpp b/js/src/builtin/intl/DateTimeFormat.cpp index 820fbb4a0ade..cb6b032d2700 100644 --- a/js/src/builtin/intl/DateTimeFormat.cpp +++ b/js/src/builtin/intl/DateTimeFormat.cpp @@ -23,6 +23,7 @@ #include "gc/FreeOp.h" #include "js/CharacterEncoding.h" #include "js/Date.h" +#include "js/experimental/Intl.h" // JS::AddMozDateTimeFormatConstructor #include "js/GCAPI.h" #include "js/PropertySpec.h" #include "js/StableStringChars.h" diff --git a/js/src/builtin/intl/DisplayNames.cpp b/js/src/builtin/intl/DisplayNames.cpp index 42b8e32cb47f..3f25c7f9b338 100644 --- a/js/src/builtin/intl/DisplayNames.cpp +++ b/js/src/builtin/intl/DisplayNames.cpp @@ -30,6 +30,7 @@ #include "gc/Rooting.h" #include "js/CallArgs.h" #include "js/Class.h" +#include "js/experimental/Intl.h" // JS::AddMozDateTimeFormatConstructor, JS::AddDisplayNamesConstructor #include "js/GCVector.h" #include "js/PropertyDescriptor.h" #include "js/PropertySpec.h" diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index d8a0cac39e89..bd6ecde59079 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -21,6 +21,7 @@ #include "gc/WeakMap.h" #include "js/CharacterEncoding.h" #include "js/experimental/CodeCoverage.h" +#include "js/experimental/Intl.h" // JS::Add{,Moz}DisplayNamesConstructor, JS::AddMozDateTimeFormatConstructor #include "js/friend/StackLimits.h" // JS_STACK_GROWTH_DIRECTION #include "js/friend/WindowProxy.h" // js::ToWindowIfWindowProxy #include "js/Object.h" // JS::GetClass diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 3faecbd8f541..3e448c8539cc 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -852,57 +852,6 @@ extern JS_FRIEND_API bool ReportIsNotFunction(JSContext* cx, JS::HandleValue v); extern JS_FRIEND_API JSObject* ConvertArgsToArray(JSContext* cx, const JS::CallArgs& args); -} // namespace js - -namespace JS { - -/** - * Create and add the Intl.MozDateTimeFormat constructor function to the - * provided object. - * - * This custom date/time formatter constructor gives users the ability to - * specify a custom format pattern. This pattern is passed *directly* to ICU - * with NO SYNTAX PARSING OR VALIDATION WHATSOEVER. ICU appears to have a - * modicum of testing of this, and it won't fall over completely if passed bad - * input. But the current behavior is entirely under-specified and emphatically - * not shippable on the web, and it *must* be fixed before this functionality - * can be exposed in the real world. (There are also some questions about - * whether the format exposed here is the *right* one to standardize, that will - * also need to be resolved to ship this.) - * - * If JS was built without JS_HAS_INTL_API, this function will throw an - * exception. - */ -extern JS_FRIEND_API bool AddMozDateTimeFormatConstructor( - JSContext* cx, Handle intl); - -/** - * Create and add the Intl.MozDisplayNames constructor function to the - * provided object. This constructor acts like the standard |Intl.DisplayNames| - * but accepts certain additional syntax that isn't standardized to the point of - * being shippable. - * - * If JS was built without JS_HAS_INTL_API, this function will throw an - * exception. - */ -extern JS_FRIEND_API bool AddMozDisplayNamesConstructor(JSContext* cx, - Handle intl); - -/** - * Create and add the Intl.DisplayNames constructor function to the provided - * object, implementing standardized behavior (that isn't yet shippable because - * we're not *quite* comfortable with the spec's progress yet). - * - * If JS was built without JS_HAS_INTL_API, this function will throw an - * exception. - */ -extern JS_FRIEND_API bool AddDisplayNamesConstructor(JSContext* cx, - Handle intl); - -} // namespace JS - -namespace js { - class MOZ_STACK_CLASS JS_FRIEND_API AutoAssertNoContentJS { public: explicit AutoAssertNoContentJS(JSContext* cx); diff --git a/js/src/moz.build b/js/src/moz.build index d6ddd32b334e..c3ecbb6657eb 100755 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -224,6 +224,7 @@ EXPORTS.js += [ # We expose them as-is, buyer beware. EXPORTS.js.experimental += [ '../public/experimental/CodeCoverage.h', + '../public/experimental/Intl.h', '../public/experimental/JitInfo.h', '../public/experimental/SourceHook.h', '../public/experimental/TypedData.h', diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 0a9aa3b0cb85..cea6895fc543 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -109,6 +109,7 @@ #include "js/ErrorReport.h" // JS::PrintError #include "js/Exception.h" // JS::StealPendingExceptionStack #include "js/experimental/CodeCoverage.h" // js::EnableCodeCoverage +#include "js/experimental/Intl.h" // JS::AddMoz{DateTimeFormat,DisplayNames}Constructor #include "js/experimental/JitInfo.h" // JSJit{Getter,Setter,Method}CallArgs, JSJitGetterInfo, JSJit{Getter,Setter}Op, JSJitInfo #include "js/experimental/SourceHook.h" // js::{Set,Forget,}SourceHook #include "js/experimental/TypedData.h" // JS_NewUint8Array diff --git a/toolkit/components/mozintl/MozIntlHelper.cpp b/toolkit/components/mozintl/MozIntlHelper.cpp index 20d43283eb08..f76cbe2924a5 100644 --- a/toolkit/components/mozintl/MozIntlHelper.cpp +++ b/toolkit/components/mozintl/MozIntlHelper.cpp @@ -5,6 +5,7 @@ #include "MozIntlHelper.h" #include "jsapi.h" +#include "js/experimental/Intl.h" // JS::AddMozDateTimeFormatConstructor #include "js/PropertySpec.h" #include "js/Wrapper.h"