2011-04-02 Nico Weber <thakis@chromium.org>
authorthakis@chromium.org <thakis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Apr 2011 04:55:07 +0000 (04:55 +0000)
committerthakis@chromium.org <thakis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Apr 2011 04:55:07 +0000 (04:55 +0000)
        Reviewed by Adam Barth.

        Explicitly use icu namespace for ports building with U_USING_ICU_NAMESPACE=0

        By default, ICU includes |using namespace icu;| in its header files
        for backwards compatibility. Clients can define
        U_USING_ICU_NAMESPACE=0 to tell ICU to not do this. Prefixing all ICU
        classes with |icu::| makes this file compile no matter what
        U_USING_ICU_NAMESPACE is set to.

        https://bugs.webkit.org/show_bug.cgi?id=57715

        * platform/text/LocalizedNumberICU.cpp:
        (WebCore::createFormatterForCurrentLocale):
        (WebCore::numberFormatter):
        (WebCore::parseLocalizedNumber):
        (WebCore::formatLocalizedNumber):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82787 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/text/LocalizedNumberICU.cpp

index a9436be..67888aa 100644 (file)
@@ -1,3 +1,23 @@
+2011-04-02  Nico Weber  <thakis@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Explicitly use icu namespace for ports building with U_USING_ICU_NAMESPACE=0
+
+        By default, ICU includes |using namespace icu;| in its header files
+        for backwards compatibility. Clients can define
+        U_USING_ICU_NAMESPACE=0 to tell ICU to not do this. Prefixing all ICU
+        classes with |icu::| makes this file compile no matter what
+        U_USING_ICU_NAMESPACE is set to.
+
+        https://bugs.webkit.org/show_bug.cgi?id=57715
+
+        * platform/text/LocalizedNumberICU.cpp:
+        (WebCore::createFormatterForCurrentLocale):
+        (WebCore::numberFormatter):
+        (WebCore::parseLocalizedNumber):
+        (WebCore::formatLocalizedNumber):
+
 2011-04-02  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
index 7c4b1cb..a8c62a7 100644 (file)
@@ -41,18 +41,18 @@ using namespace std;
 
 namespace WebCore {
 
-static PassOwnPtr<NumberFormat> createFormatterForCurrentLocale()
+static PassOwnPtr<icu::NumberFormat> createFormatterForCurrentLocale()
 {
     UErrorCode status = U_ZERO_ERROR;
-    OwnPtr<NumberFormat> formatter = adoptPtr(NumberFormat::createInstance(status));
+    OwnPtr<icu::NumberFormat> formatter = adoptPtr(icu::NumberFormat::createInstance(status));
     return U_SUCCESS(status) ? formatter.release() : 0;
 }
 
 // This might return 0.
-static NumberFormat* numberFormatter()
+static icu::NumberFormat* numberFormatter()
 {
     ASSERT(isMainThread());
-    static NumberFormat* formatter = createFormatterForCurrentLocale().leakPtr();
+    static icu::NumberFormat* formatter = createFormatterForCurrentLocale().leakPtr();
     return formatter;
 }
 
@@ -60,12 +60,12 @@ double parseLocalizedNumber(const String& numberString)
 {
     if (numberString.isEmpty())
         return numeric_limits<double>::quiet_NaN();
-    NumberFormat* formatter = numberFormatter();
+    icu::NumberFormat* formatter = numberFormatter();
     if (!formatter)
         return numeric_limits<double>::quiet_NaN();
-    UnicodeString numberUnicodeString(numberString.characters(), numberString.length());
-    Formattable result;
-    ParsePosition position(0);
+    icu::UnicodeString numberUnicodeString(numberString.characters(), numberString.length());
+    icu::Formattable result;
+    icu::ParsePosition position(0);
     formatter->parse(numberUnicodeString, result, position);
     if (position.getIndex() != numberUnicodeString.length())
         return numeric_limits<double>::quiet_NaN();
@@ -76,10 +76,10 @@ double parseLocalizedNumber(const String& numberString)
 
 String formatLocalizedNumber(double number, unsigned fractionDigits)
 {
-    NumberFormat* formatter = numberFormatter();
+    icu::NumberFormat* formatter = numberFormatter();
     if (!formatter)
         return String();
-    UnicodeString result;
+    icu::UnicodeString result;
     formatter->setMaximumFractionDigits(clampToInteger(fractionDigits));
     formatter->format(number, result);
     return String(result.getBuffer(), result.length());