Issue #2046 - Trim builtin/Intl.*'s #include set down to what is required for Intl itself

This commit is contained in:
Martok 2023-02-16 22:24:52 +01:00 • committed by roytam1
commit 5ad62567e0
4 changed files with 39 additions and 64 deletions

View file

@ -3,22 +3,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* /* Implementation of the Intl object and its non-constructor properties. */
* The Intl module specified by standard ECMA-402,
* ECMAScript Internationalization API Specification.
*/
#include "builtin/Intl.h" #include "builtin/Intl.h"
#include "mozilla/Casting.h" #include "mozilla/Assertions.h"
#include "mozilla/FloatingPoint.h" #include "mozilla/Likely.h"
#include "mozilla/PodOperations.h"
#include "mozilla/Range.h" #include "mozilla/Range.h"
#include <string.h>
#include "jsapi.h" #include "jsapi.h"
#include "jsatom.h"
#include "jscntxt.h" #include "jscntxt.h"
#include "jsobj.h" #include "jsobj.h"
@ -30,22 +23,12 @@
#include "builtin/intl/PluralRules.h" #include "builtin/intl/PluralRules.h"
#include "builtin/intl/RelativeTimeFormat.h" #include "builtin/intl/RelativeTimeFormat.h"
#include "builtin/intl/ScopedICUObject.h" #include "builtin/intl/ScopedICUObject.h"
#include "ds/Sort.h"
#include "vm/DateTime.h"
#include "vm/GlobalObject.h" #include "vm/GlobalObject.h"
#include "vm/Interpreter.h"
#include "vm/Stack.h"
#include "vm/StringBuffer.h"
#include "vm/Unicode.h"
#include "jsobjinlines.h" #include "jsobjinlines.h"
#include "vm/NativeObject-inl.h"
using namespace js; using namespace js;
using mozilla::IsFinite;
using js::intl::CallICU; using js::intl::CallICU;
using js::intl::GetAvailableLocales; using js::intl::GetAvailableLocales;
using js::intl::IcuLocale; using js::intl::IcuLocale;

View file

@ -6,21 +6,13 @@
#ifndef builtin_Intl_h #ifndef builtin_Intl_h
#define builtin_Intl_h #define builtin_Intl_h
#include "mozilla/HashFunctions.h" #include "mozilla/Attributes.h"
#include "mozilla/MemoryReporting.h"
#include "jsalloc.h" #include "js/RootingAPI.h"
#include "NamespaceImports.h"
#include "js/GCAPI.h" struct JSContext;
#include "js/GCHashTable.h" class JSObject;
namespace JS { class Value; }
#include "unicode/utypes.h"
/*
* The Intl module specified by standard ECMA-402,
* ECMAScript Internationalization API Specification.
*/
namespace js { namespace js {
@ -29,7 +21,7 @@ namespace js {
* Spec: ECMAScript Internationalization API Specification, 8.0, 8.1 * Spec: ECMAScript Internationalization API Specification, 8.0, 8.1
*/ */
extern JSObject* extern JSObject*
InitIntlClass(JSContext* cx, HandleObject obj); InitIntlClass(JSContext* cx, JS::Handle<JSObject*> obj);
/* /*
* The following functions are for use by self-hosted code. * The following functions are for use by self-hosted code.
@ -59,7 +51,7 @@ InitIntlClass(JSContext* cx, HandleObject obj);
* NOTE: "calendar" and "locale" properties are *not* added to the object. * NOTE: "calendar" and "locale" properties are *not* added to the object.
*/ */
extern MOZ_MUST_USE bool extern MOZ_MUST_USE bool
intl_GetCalendarInfo(JSContext* cx, unsigned argc, Value* vp); intl_GetCalendarInfo(JSContext* cx, unsigned argc, JS::Value* vp);
/** /**
* Returns an Array with CLDR-based fields display names. * Returns an Array with CLDR-based fields display names.
@ -101,34 +93,7 @@ intl_GetCalendarInfo(JSContext* cx, unsigned argc, Value* vp);
* ] * ]
*/ */
extern MOZ_MUST_USE bool extern MOZ_MUST_USE bool
intl_ComputeDisplayNames(JSContext* cx, unsigned argc, Value* vp); intl_ComputeDisplayNames(JSContext* cx, unsigned argc, JS::Value* vp);
/**
* Cast char16_t* strings to UChar* strings used by ICU.
*/
inline const UChar*
Char16ToUChar(const char16_t* chars)
{
return reinterpret_cast<const UChar*>(chars);
}
inline UChar*
Char16ToUChar(char16_t* chars)
{
return reinterpret_cast<UChar*>(chars);
}
inline char16_t*
UCharToChar16(UChar* chars)
{
return reinterpret_cast<char16_t*>(chars);
}
inline const char16_t*
UCharToChar16(const UChar* chars)
{
return reinterpret_cast<const char16_t*>(chars);
}
} // namespace js } // namespace js

View file

@ -20,4 +20,31 @@
#include "unicode/ureldatefmt.h" #include "unicode/ureldatefmt.h"
#include "unicode/ustring.h" #include "unicode/ustring.h"
/**
* Cast char16_t* strings to UChar* strings used by ICU.
*/
inline const UChar*
Char16ToUChar(const char16_t* chars)
{
return reinterpret_cast<const UChar*>(chars);
}
inline UChar*
Char16ToUChar(char16_t* chars)
{
return reinterpret_cast<UChar*>(chars);
}
inline char16_t*
UCharToChar16(UChar* chars)
{
return reinterpret_cast<char16_t*>(chars);
}
inline const char16_t*
UCharToChar16(const UChar* chars)
{
return reinterpret_cast<const char16_t*>(chars);
}
#endif /* builtin_intl_ICUHeader_h */ #endif /* builtin_intl_ICUHeader_h */

View file

@ -30,7 +30,7 @@
#include "jstypes.h" #include "jstypes.h"
#include "jsutil.h" #include "jsutil.h"
#include "builtin/Intl.h" #include "builtin/intl/ICUHeader.h"
#include "builtin/RegExp.h" #include "builtin/RegExp.h"
#include "jit/InlinableNatives.h" #include "jit/InlinableNatives.h"
#include "js/Conversions.h" #include "js/Conversions.h"