Bug 943287 - Part 2. Use nsICollation of ICU version when ICU is built on UNIX. r?hsivonen draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 16 Jun 2016 22:21:06 +0900
changeset 379750 fd7a8cd1ceeed6471db74389305c04e573c3f972
parent 379749 60474b23e0d2ca0e066939a1f1c6de4b38213270
child 523561 02ffddb2213801fcd2eee1cd2331d467035d0b08
push id21043
push userm_kato@ga2.so-net.ne.jp
push dateFri, 17 Jun 2016 09:25:21 +0000
reviewershsivonen
bugs943287
milestone50.0a1
Bug 943287 - Part 2. Use nsICollation of ICU version when ICU is built on UNIX. r?hsivonen Use ICU implemattio on UNIX with ICU support. We don't turn on ICU + Windows yet because ucol.h (uset.h) seems to requrie C++ exception support on MSVC. MozReview-Commit-ID: 8e4U6IcCic2
intl/build/nsI18nModule.cpp
intl/locale/mac/moz.build
intl/locale/nsLocaleConstructors.h
intl/locale/tests/unit/test_collation_icu.js
intl/locale/tests/unit/test_collation_mac_icu.js
intl/locale/tests/unit/xpcshell.ini
intl/locale/unix/moz.build
--- a/intl/build/nsI18nModule.cpp
+++ b/intl/build/nsI18nModule.cpp
@@ -54,28 +54,18 @@ NS_DEFINE_NAMED_CID(NS_SAVEASCHARSET_CID
 NS_DEFINE_NAMED_CID(NS_UNICODE_NORMALIZER_CID);
 NS_DEFINE_NAMED_CID(NS_STRINGBUNDLESERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_STRINGBUNDLETEXTOVERRIDE_CID);
 NS_DEFINE_NAMED_CID(NS_LOCALESERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_COLLATIONFACTORY_CID);
 NS_DEFINE_NAMED_CID(NS_SCRIPTABLEDATEFORMAT_CID);
 NS_DEFINE_NAMED_CID(NS_LANGUAGEATOMSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID);
-#ifdef XP_WIN
 NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
 NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
-#endif
-#ifdef USE_UNIX_LOCALE
-NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
-NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
-#endif
-#ifdef USE_MAC_LOCALE
-NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
-NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
-#endif
 
 static const mozilla::Module::CIDEntry kIntlCIDs[] = {
     { &kNS_LBRK_CID, false, nullptr, nsJISx4051LineBreakerConstructor },
     { &kNS_WBRK_CID, false, nullptr, nsSampleWordBreakerConstructor },
     { &kNS_SEMANTICUNITSCANNER_CID, false, nullptr, nsSemanticUnitScannerConstructor },
     { &kNS_UNICHARUTIL_CID, false, nullptr, nsCaseConversionImp2Constructor },
     { &kNS_UNICHARCATEGORY_CID, false, nullptr, nsCategoryImpConstructor },
     { &kNS_ENTITYCONVERTER_CID, false, nullptr, nsEntityConverterConstructor },
@@ -83,26 +73,34 @@ static const mozilla::Module::CIDEntry k
     { &kNS_UNICODE_NORMALIZER_CID, false, nullptr, nsUnicodeNormalizerConstructor },
     { &kNS_STRINGBUNDLESERVICE_CID, false, nullptr, nsStringBundleServiceConstructor },
     { &kNS_STRINGBUNDLETEXTOVERRIDE_CID, false, nullptr, nsStringBundleTextOverrideConstructor },
     { &kNS_LOCALESERVICE_CID, false, nullptr, CreateLocaleService },
     { &kNS_COLLATIONFACTORY_CID, false, nullptr, nsCollationFactoryConstructor },
     { &kNS_SCRIPTABLEDATEFORMAT_CID, false, nullptr, NS_NewScriptableDateFormat },
     { &kNS_LANGUAGEATOMSERVICE_CID, false, nullptr, nsLanguageAtomServiceConstructor },
     { &kNS_PLATFORMCHARSET_CID, false, nullptr, nsPlatformCharsetConstructor },
+
+#if defined(XP_WIN)
+    { &kNS_COLLATION_CID, false, nullptr, nsCollationWinConstructor },
+#elif defined(ENABLE_INTL_API) || defined(USE_MAC_LOCALE)
+    { &kNS_COLLATION_CID, false, nullptr, nsCollationICUConstructor },
+#elif defined(USE_UNIX_LOCALE)
+    { &kNS_COLLATION_CID, false, nullptr, nsCollationUnixConstructor },
+#else
+#error "Due to no ICU, this platform requires nsICollation implementation"
+#endif
+
 #ifdef XP_WIN
-    { &kNS_COLLATION_CID, false, nullptr, nsCollationWinConstructor },
     { &kNS_DATETIMEFORMAT_CID, false, nullptr, nsDateTimeFormatWinConstructor },
 #endif
 #ifdef USE_UNIX_LOCALE
-    { &kNS_COLLATION_CID, false, nullptr, nsCollationUnixConstructor },
     { &kNS_DATETIMEFORMAT_CID, false, nullptr, nsDateTimeFormatUnixConstructor },
 #endif
 #ifdef USE_MAC_LOCALE
-    { &kNS_COLLATION_CID, false, nullptr, nsCollationICUConstructor },
     { &kNS_DATETIMEFORMAT_CID, false, nullptr, nsDateTimeFormatMacConstructor },
 #endif
     { nullptr }
 };
 
 static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
     { NS_LBRK_CONTRACTID, &kNS_LBRK_CID },
     { NS_WBRK_CONTRACTID, &kNS_WBRK_CID },
@@ -114,28 +112,18 @@ static const mozilla::Module::ContractID
     { NS_UNICODE_NORMALIZER_CONTRACTID, &kNS_UNICODE_NORMALIZER_CID },
     { NS_STRINGBUNDLE_CONTRACTID, &kNS_STRINGBUNDLESERVICE_CID },
     { NS_STRINGBUNDLETEXTOVERRIDE_CONTRACTID, &kNS_STRINGBUNDLETEXTOVERRIDE_CID },
     { NS_LOCALESERVICE_CONTRACTID, &kNS_LOCALESERVICE_CID },
     { NS_COLLATIONFACTORY_CONTRACTID, &kNS_COLLATIONFACTORY_CID },
     { NS_SCRIPTABLEDATEFORMAT_CONTRACTID, &kNS_SCRIPTABLEDATEFORMAT_CID },
     { NS_LANGUAGEATOMSERVICE_CONTRACTID, &kNS_LANGUAGEATOMSERVICE_CID },
     { NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID },
-#ifdef XP_WIN
     { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
     { NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
-#endif
-#ifdef USE_UNIX_LOCALE
-    { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
-    { NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
-#endif
-#ifdef USE_MAC_LOCALE
-    { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
-    { NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
-#endif
     { nullptr }
 };
 
 static const mozilla::Module kIntlModule = {
     mozilla::Module::kVersion,
     kIntlCIDs,
     kIntlContracts,
     nullptr,
--- a/intl/locale/mac/moz.build
+++ b/intl/locale/mac/moz.build
@@ -1,18 +1,21 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 UNIFIED_SOURCES += [
-    '../nsCollationICU.cpp',
     'nsDateTimeFormatMac.cpp',
     'nsMacCharset.cpp',
 ]
 
+SOURCES += [
+    '../nsCollationICU.cpp',
+]
+SOURCES['../nsCollationICU.cpp'].flags += CONFIG['MOZ_ICU_CFLAGS']
+
 FINAL_LIBRARY = 'xul'
-CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
 LOCAL_INCLUDES += CONFIG['MOZ_ICU_INCLUDES']
 LOCAL_INCLUDES += [
     '..',
 ]
--- a/intl/locale/nsLocaleConstructors.h
+++ b/intl/locale/nsLocaleConstructors.h
@@ -18,28 +18,33 @@
 #if defined(XP_MACOSX)
 #define USE_MAC_LOCALE
 #endif
 
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
 #define USE_UNIX_LOCALE
 #endif
 
+#if defined(XP_WIN)
+#include "windows/nsCollationWin.h"
+#elif defined(ENABLE_INTL_API) || defined(USE_MAC_LOCALE)
+#include "nsCollationICU.h"
+#elif defined(USE_UNIX_LOCALE)
+#include "unix/nsCollationUnix.h"
+#endif
+
 #ifdef XP_WIN
-#include "windows/nsCollationWin.h"
 #include "windows/nsDateTimeFormatWin.h"
 #endif
 
 #ifdef USE_MAC_LOCALE
-#include "nsCollationICU.h"
 #include "mac/nsDateTimeFormatMac.h"
 #endif
 
 #ifdef USE_UNIX_LOCALE
-#include "unix/nsCollationUnix.h"
 #include "unix/nsDateTimeFormatUnix.h"
 #endif
 
 #define NSLOCALE_MAKE_CTOR(ctor_, iface_, func_)          \
 static nsresult                                           \
 ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
 {                                                         \
   *aResult = nullptr;                                      \
@@ -56,24 +61,29 @@ ctor_(nsISupports* aOuter, REFNSIID aIID
 
 
 NSLOCALE_MAKE_CTOR(CreateLocaleService, nsILocaleService, NS_NewLocaleService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationFactory)
 //NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableDateTimeFormat)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLanguageAtomService)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init)
 
+#if defined(XP_WIN)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationWin)
+#elif defined(ENABLE_INTL_API) || defined(USE_MAC_LOCALE)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationICU)
+#elif defined(USE_UNIX_LOCALE)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationUnix)
+#endif
+
 #ifdef XP_WIN
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationWin)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatWin)
 #endif
 
 #ifdef USE_UNIX_LOCALE
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationUnix)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatUnix)
 #endif  
 
 #ifdef USE_MAC_LOCALE
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationICU)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatMac)
 #endif  
 
 #endif
rename from intl/locale/tests/unit/test_collation_mac_icu.js
rename to intl/locale/tests/unit/test_collation_icu.js
--- a/intl/locale/tests/unit/xpcshell.ini
+++ b/intl/locale/tests/unit/xpcshell.ini
@@ -5,15 +5,15 @@ skip-if = toolkit == 'gonk'
 
 [test_bug22310.js]
 skip-if = toolkit != "windows" && toolkit != "cocoa"
 
 [test_bug371611.js]
 [test_bug374040.js]
 skip-if = toolkit == "windows" || toolkit == "cocoa"
 
-[test_collation_mac_icu.js]
-skip-if = toolkit != "cocoa"
+[test_collation_icu.js]
+skip-if = toolkit == "android" || toolkit == "windows"
 
 [test_bug1086527.js]
 [test_pluralForm.js]
 [test_pluralForm_english.js]
 [test_pluralForm_makeGetter.js]
--- a/intl/locale/unix/moz.build
+++ b/intl/locale/unix/moz.build
@@ -1,16 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 SOURCES += [
-    'nsCollationUnix.cpp',
     'nsDateTimeFormatUnix.cpp',
     'nsPosixLocale.cpp',
 ]
 
 if CONFIG['OS_TARGET'] == 'Android':
     SOURCES += [
         'nsAndroidCharset.cpp',
     ]
@@ -20,16 +19,27 @@ else:
     ]
     GENERATED_FILES = [
         'unixcharset.properties.h',
     ]
     unixcharset = GENERATED_FILES['unixcharset.properties.h']
     unixcharset.script = '../props2arrays.py'
     unixcharset.inputs = ['unixcharset.properties']
 
+if CONFIG['ENABLE_INTL_API']:
+    SOURCES += [
+        '../nsCollationICU.cpp',
+    ]
+    SOURCES['../nsCollationICU.cpp'].flags += CONFIG['MOZ_ICU_CFLAGS']
+    LOCAL_INCLUDES += CONFIG['MOZ_ICU_INCLUDES']
+else:
+    SOURCES += [
+        'nsCollationUnix.cpp',
+    ]
+
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '..',
 ]
 
 # CODESET is not automatically defined on some older versions of Redhat.
 # Define _XOPEN_SOURCE so CODESET will get defined and thus allow