Adding an ifdef that forces wchar_t into PRUint16 temporarily on a nsAString method in order to allow linking from projects that don't have the /Zc:wchar_t- flag set.

BUG=none
TEST=can link with xulrunner libs from a project using the /Zc:wchar_t flag.

Review URL: http://codereview.chromium.org/119243

git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/xulrunner-sdk@17887 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/win/include/xpcom/nsStringAPI.h b/win/include/xpcom/nsStringAPI.h
index bbe6743..6ca05aa 100644
--- a/win/include/xpcom/nsStringAPI.h
+++ b/win/include/xpcom/nsStringAPI.h
@@ -62,6 +62,11 @@
   typedef PRUint32   size_type;
   typedef PRUint32   index_type;
 
+// Force BeginReading into using PRUint16s instead of wchar_t on Windows.
+// This avoids errors when linking from a project compiled with /Zc:wchar_t.
+#if defined(WIN32)
+#define char_type PRUint16
+#endif
   /**
    * Returns the length, beginning, and end of a string in one operation.
    */
@@ -70,6 +75,9 @@
 
   NS_HIDDEN_(const char_type*) BeginReading() const;
   NS_HIDDEN_(const char_type*) EndReading() const;
+#if defined(WIN32)
+#undef char_type
+#endif
 
   NS_HIDDEN_(char_type) CharAt(PRUint32 aPos) const
   {
@@ -785,7 +793,11 @@
 
   const char_type* get() const
   {
+#if defined(WIN32)
+    return reinterpret_cast<const char_type*>(BeginReading());
+#else
     return BeginReading();
+#endif
   }
 
   self_type& operator=(const self_type& aString)              { Assign(aString);   return *this; }
diff --git a/win/sdk/include/nsStringAPI.h b/win/sdk/include/nsStringAPI.h
index bbe6743..d76e378 100644
--- a/win/sdk/include/nsStringAPI.h
+++ b/win/sdk/include/nsStringAPI.h
@@ -62,14 +62,21 @@
   typedef PRUint32   size_type;
   typedef PRUint32   index_type;
 
+// Force BeginReading into using PRUint16s instead of wchar_t on Windows.
+// This avoids errors when linking from a project compiled with /Zc:wchar_t.
+#if defined(WIN32)
+#define char_type PRUint16
+#endif
   /**
    * Returns the length, beginning, and end of a string in one operation.
    */
   NS_HIDDEN_(PRUint32) BeginReading(const char_type **begin,
                                     const char_type **end = nsnull) const;
-
   NS_HIDDEN_(const char_type*) BeginReading() const;
   NS_HIDDEN_(const char_type*) EndReading() const;
+#if defined(WIN32)
+#undef char_type
+#endif
 
   NS_HIDDEN_(char_type) CharAt(PRUint32 aPos) const
   {
@@ -785,7 +792,11 @@
 
   const char_type* get() const
   {
+#if defined(WIN32)
+    return reinterpret_cast<const char_type*>(BeginReading());
+#else
     return BeginReading();
+#endif
   }
 
   self_type& operator=(const self_type& aString)              { Assign(aString);   return *this; }