]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/longlong.cpp
Fix recursion problems when loading pages from a virtual file system using the WebKit...
[wxWidgets.git] / src / common / longlong.cpp
index 360d087b3e351610f4aab3fa66157b225dae0b9f..1ceefe012303c0677d29e8b557b4face30673d26 100644 (file)
     #include "wx/txtstrm.h"
 #endif
 
     #include "wx/txtstrm.h"
 #endif
 
-#if defined(__MWERKS__) && defined(__WXMSW__)
-    #include <string.h>     // for memset()
-#else
-    #include <memory.h>     // for memset()
-#endif
+#include <string.h>            // for memset()
 
 #include "wx/ioswrap.h"
 
 
 #include "wx/ioswrap.h"
 
@@ -137,6 +133,22 @@ wxULongLongNative& wxULongLongNative::operator=(const class wxULongLongWx &ll)
 }
 #endif
 
 }
 #endif
 
+#ifdef __VISUALC6__
+double wxULongLongNative::ToDouble() const
+{
+    // Work around the problem of casting unsigned __int64 to double in VC6
+    // (which for unknown reasons only manifests itself in DLL builds, i.e.
+    // when using /MD).
+    static const __int64 int64_t_max = 9223372036854775807i64;
+    if ( m_ll <= int64_t_max )
+        return wx_truncate_cast(double, (wxLongLong_t)m_ll);
+
+    double d = wx_truncate_cast(double, int64_t_max);
+    d += (__int64)(m_ll - int64_t_max - 1); // The cast is safe because of -1
+    return d + 1;
+}
+#endif // __VISUALC6__
+
 #endif // wxUSE_LONGLONG_NATIVE
 
 // ============================================================================
 #endif // wxUSE_LONGLONG_NATIVE
 
 // ============================================================================
@@ -194,6 +206,19 @@ double wxLongLongWx::ToDouble() const
     return d;
 }
 
     return d;
 }
 
+double wxULongLongWx::ToDouble() const
+{
+    unsigned double d = m_hi;
+    d *= 1.0 + (double)ULONG_MAX;
+    d += m_lo;
+
+#ifdef wxLONGLONG_TEST_MODE
+    wxASSERT( d == m_ll );
+#endif // wxLONGLONG_TEST_MODE
+
+    return d;
+}
+
 wxLongLongWx wxLongLongWx::operator<<(int shift) const
 {
     wxLongLongWx ll(*this);
 wxLongLongWx wxLongLongWx::operator<<(int shift) const
 {
     wxLongLongWx ll(*this);
@@ -1163,7 +1188,7 @@ void *wxULongLongWx::asArray(void) const
             while ( ll != 0 )                                        \
             {                                                        \
                 long digit = (ll % 10).ToLong();                     \
             while ( ll != 0 )                                        \
             {                                                        \
                 long digit = (ll % 10).ToLong();                     \
-                result.Prepend((wxChar)(_T('0') - digit));           \
+                result.Prepend((wxChar)(wxT('0') - digit));          \
                 ll /= 10;                                            \
             }                                                        \
         }                                                            \
                 ll /= 10;                                            \
             }                                                        \
         }                                                            \
@@ -1172,15 +1197,15 @@ void *wxULongLongWx::asArray(void) const
             while ( ll != 0 )                                        \
             {                                                        \
                 long digit = (ll % 10).ToLong();                     \
             while ( ll != 0 )                                        \
             {                                                        \
                 long digit = (ll % 10).ToLong();                     \
-                result.Prepend((wxChar)(_T('0') + digit));           \
+                result.Prepend((wxChar)(wxT('0') + digit));          \
                 ll /= 10;                                            \
             }                                                        \
         }                                                            \
                                                                      \
         if ( result.empty() )                                        \
                 ll /= 10;                                            \
             }                                                        \
         }                                                            \
                                                                      \
         if ( result.empty() )                                        \
-            result = _T('0');                                        \
+            result = wxT('0');                                       \
         else if ( neg )                                              \
         else if ( neg )                                              \
-            result.Prepend(_T('-'));                                 \
+            result.Prepend(wxT('-'));                                \
                                                                      \
         return result;                                               \
     }
                                                                      \
         return result;                                               \
     }
@@ -1195,12 +1220,12 @@ void *wxULongLongWx::asArray(void) const
                                                                      \
         while ( ll != 0 )                                            \
         {                                                            \
                                                                      \
         while ( ll != 0 )                                            \
         {                                                            \
-            result.Prepend((wxChar)(_T('0') + (ll % 10).ToULong())); \
+            result.Prepend((wxChar)(wxT('0') + (ll % 10).ToULong())); \
             ll /= 10;                                                \
         }                                                            \
                                                                      \
         if ( result.empty() )                                        \
             ll /= 10;                                                \
         }                                                            \
                                                                      \
         if ( result.empty() )                                        \
-            result = _T('0');                                        \
+            result = wxT('0');                                       \
                                                                      \
         return result;                                               \
     }
                                                                      \
         return result;                                               \
     }
@@ -1254,7 +1279,7 @@ WXDLLIMPEXP_BASE wxTextOutputStream& operator<< (wxTextOutputStream& o, const wx
     return o << ll.ToString();
 }
 
     return o << ll.ToString();
 }
 
-#define READ_STRING_CHAR(s, idx, len) ((wxChar) ((idx!=len) ? s[idx++] : 0))
+#define READ_STRING_CHAR(s, idx, len) ((idx!=len) ? (wxChar)s[idx++] : wxT('\0'))
 
 WXDLLIMPEXP_BASE class wxTextInputStream &operator>>(class wxTextInputStream &o, wxULongLong &ll)
 {
 
 WXDLLIMPEXP_BASE class wxTextInputStream &operator>>(class wxTextInputStream &o, wxULongLong &ll)
 {