Bug 1284406 part 2 - Avoid including ICU header when Intl API is disabled. r=Waldo
authorXidorn Quan <me@upsuper.org>
Wed, 20 Jul 2016 15:00:13 +1000
changeset 305596 10ac75b9846cdf348b2ddee69c128ed62bd62fb6
parent 305595 42f884f30bc362ec9e85cd9a352dfb487745e7a8
child 305597 4a4bbb7e9e798c40a3b25dbb2ddbfafb793acbe3
push id79651
push userxquan@mozilla.com
push dateWed, 20 Jul 2016 05:02:21 +0000
treeherdermozilla-inbound@4a4bbb7e9e79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1284406
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1284406 part 2 - Avoid including ICU header when Intl API is disabled. r=Waldo MozReview-Commit-ID: IirLcgh8s89
js/src/builtin/Intl.cpp
js/src/builtin/Intl.h
--- 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 */