Bug 1284406 part 2 - Avoid including ICU header when Intl API is disabled. r=Waldo
MozReview-Commit-ID: IirLcgh8s89
--- a/js/src/builtin/Intl.cpp
+++ b/js/src/builtin/Intl.cpp
@@ -72,16 +72,43 @@ using icu::NumberingSystem;
* against ICU. However, we still want to compile this code in order to prevent
* bit rot. The following stub implementations for ICU functions make this
* possible. The functions using them should never be called, so they assert
* and return error codes. Signatures adapted from ICU header files locid.h,
* numsys.h, ucal.h, ucol.h, udat.h, udatpg.h, uenum.h, unum.h; see the ICU
* directory for license.
*/
+typedef bool UBool;
+typedef char16_t UChar;
+typedef double UDate;
+
+enum UErrorCode {
+ U_ZERO_ERROR,
+ U_BUFFER_OVERFLOW_ERROR,
+};
+
+static inline UBool
+U_FAILURE(UErrorCode code)
+{
+ MOZ_CRASH("U_FAILURE: Intl API disabled");
+}
+
+inline const UChar*
+Char16ToUChar(const char16_t* chars)
+{
+ MOZ_CRASH("Char16ToUChar: Intl API disabled");
+}
+
+inline UChar*
+Char16ToUChar(char16_t* chars)
+{
+ MOZ_CRASH("Char16ToUChar: Intl API disabled");
+}
+
static int32_t
u_strlen(const UChar* s)
{
MOZ_CRASH("u_strlen: Intl API disabled");
}
struct UEnumeration;
--- a/js/src/builtin/Intl.h
+++ b/js/src/builtin/Intl.h
@@ -3,17 +3,19 @@
* 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 builtin_Intl_h
#define builtin_Intl_h
#include "NamespaceImports.h"
+#if ENABLE_INTL_API
#include "unicode/utypes.h"
+#endif
/*
* The Intl module specified by standard ECMA-402,
* ECMAScript Internationalization API Specification.
*/
namespace js {
@@ -174,26 +176,28 @@ intl_patternForSkeleton(JSContext* cx, u
*
* Spec: ECMAScript Internationalization API Specification, 12.3.2.
*
* Usage: formatted = intl_FormatDateTime(dateTimeFormat, x)
*/
extern MOZ_MUST_USE bool
intl_FormatDateTime(JSContext* cx, unsigned argc, Value* vp);
+#if ENABLE_INTL_API
/**
* 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);
}
+#endif // ENABLE_INTL_API
} // namespace js
#endif /* builtin_Intl_h */