Bug 1663365 - Move Intl functionality out of jsfriendapi.h to a new header. r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D92168
This commit is contained in:
Jeff Walden 2020-10-03 10:12:05 +00:00
Родитель 28464c988b
Коммит 0554852f27
8 изменённых файлов: 70 добавлений и 51 удалений

Просмотреть файл

@ -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<JSObject*> 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<JSObject*> 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<JSObject*> intl);
} // namespace JS
#endif // js_experimental_Intl_h

Просмотреть файл

@ -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"

Просмотреть файл

@ -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"

Просмотреть файл

@ -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

Просмотреть файл

@ -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<JSObject*> 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<JSObject*> 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<JSObject*> intl);
} // namespace JS
namespace js {
class MOZ_STACK_CLASS JS_FRIEND_API AutoAssertNoContentJS {
public:
explicit AutoAssertNoContentJS(JSContext* cx);

Просмотреть файл

@ -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',

Просмотреть файл

@ -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

Просмотреть файл

@ -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"