Bug 1091594 - Added explicit integer casts to char16ptr_t. r=jmathies
authorJacek Caban <jacek@codeweavers.com>
Mon, 03 Nov 2014 14:09:48 +0100
changeset 213675 9c16882c6c05ec8a75c05d3e9015148a3fa35047
parent 213674 68ab1ca23ecc6c3e8ad0cf8a0a74930e830339de
child 213676 7e8e6288be38ef43e3ea1097ef9df3c4b41b5ccd
push id27758
push userryanvm@gmail.com
push dateMon, 03 Nov 2014 21:18:21 +0000
treeherdermozilla-central@9b03757d6c99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies
bugs1091594
milestone36.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 1091594 - Added explicit integer casts to char16ptr_t. r=jmathies
mfbt/Char16.h
--- a/mfbt/Char16.h
+++ b/mfbt/Char16.h
@@ -100,16 +100,40 @@ public:
   explicit operator char16_t*() const
   {
     return const_cast<char16_t*>(mPtr);
   }
   explicit operator wchar_t*() const
   {
     return const_cast<wchar_t*>(static_cast<const wchar_t*>(*this));
   }
+  explicit operator int() const
+  {
+    return reinterpret_cast<intptr_t>(mPtr);
+  }
+  explicit operator unsigned int() const
+  {
+    return reinterpret_cast<uintptr_t>(mPtr);
+  }
+  explicit operator long() const
+  {
+    return reinterpret_cast<intptr_t>(mPtr);
+  }
+  explicit operator unsigned long() const
+  {
+    return reinterpret_cast<uintptr_t>(mPtr);
+  }
+  explicit operator long long() const
+  {
+    return reinterpret_cast<intptr_t>(mPtr);
+  }
+  explicit operator unsigned long long() const
+  {
+    return reinterpret_cast<uintptr_t>(mPtr);
+  }
 
   /**
    * Some Windows API calls accept BYTE* but require that data actually be
    * WCHAR*.  Supporting this requires explicit operators to support the
    * requisite explicit casts.
    */
   explicit operator const char*() const
   {
@@ -145,17 +169,37 @@ public:
   bool operator!=(const char16ptr_t& aOther) const
   {
     return mPtr != aOther.mPtr;
   }
   bool operator!=(decltype(nullptr)) const
   {
     return mPtr != nullptr;
   }
-  char16ptr_t operator+(size_t aValue) const
+  char16ptr_t operator+(int aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  char16ptr_t operator+(unsigned int aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  char16ptr_t operator+(long aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  char16ptr_t operator+(unsigned long aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  char16ptr_t operator+(long long aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  char16ptr_t operator+(unsigned long long aValue) const
   {
     return char16ptr_t(mPtr + aValue);
   }
   ptrdiff_t operator-(const char16ptr_t& aOther) const
   {
     return mPtr - aOther.mPtr;
   }
 };