summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2005-09-22 14:01:13 +0000
committerBernard Normier <bernard@zeroc.com>2005-09-22 14:01:13 +0000
commit1fe509c0c26b31ee654dda17be99205362024f68 (patch)
treef0248f6827bece2662cc4899071c52b289c6b85a
parentFix (diff)
downloadice-1fe509c0c26b31ee654dda17be99205362024f68.tar.bz2
ice-1fe509c0c26b31ee654dda17be99205362024f68.tar.xz
ice-1fe509c0c26b31ee654dda17be99205362024f68.zip
Ported IceUtil to VS 2005 Beta 2 x64
-rw-r--r--cpp/include/IceUtil/Config.h8
-rw-r--r--cpp/include/IceUtil/Unicode.h41
-rw-r--r--cpp/src/IceUtil/Base64.cpp18
-rw-r--r--cpp/src/IceUtil/InputUtil.cpp6
-rw-r--r--cpp/src/IceUtil/Thread.cpp11
-rw-r--r--cpp/src/IceUtil/Time.cpp9
-rw-r--r--cpp/src/IceUtil/Unicode.cpp21
-rw-r--r--cpp/src/icecpp/config.h7
-rw-r--r--cpp/src/icecpp/prefix.c4
9 files changed, 93 insertions, 32 deletions
diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h
index c210fee5d2d..abba708baec 100644
--- a/cpp/include/IceUtil/Config.h
+++ b/cpp/include/IceUtil/Config.h
@@ -120,6 +120,14 @@
# pragma warning( disable : 4275 )
// ...: decorated name length exceeded, name was truncated
# pragma warning( disable : 4503 )
+//
+//
+// TEMPORARY: move deprecated warning on VC8 to level 4
+# if _MSC_VER==1400
+# pragma warning( 4 : 4996 )
+# endif
+#
+
# endif
#endif
diff --git a/cpp/include/IceUtil/Unicode.h b/cpp/include/IceUtil/Unicode.h
index 0846381ddb6..366e673b220 100644
--- a/cpp/include/IceUtil/Unicode.h
+++ b/cpp/include/IceUtil/Unicode.h
@@ -23,33 +23,56 @@ namespace IceUtil
// Since wstring is a typedef basic_string<wchar_t>, its type is also
// different depending on whether /Zc:wchar_t is used or not.
//
-// Ice is always built without /Zc:wchar_t, but provides wstringToString()
+// With Visual C++ 7.x, the default is typedef; with Visual C++ 8.0,
+// the default is native type.
+//
+// Ice is always built with the default, but provides wstringToString()
// and stringToWstring() implementations for both flavors of wstring.
//
# if defined(_NATIVE_WCHAR_T_DEFINED)
-//
-// We're using Ice with /Zc:wchar_t
-//
ICE_UTIL_API std::string wstringToString(const std::wstring&);
-ICE_UTIL_API std::wstring stringToNativeWstring(const std::string&);
+# if _MSC_VER >= 1400
+//
+// Building or using with VC8
+//
+ICE_UTIL_API std::wstring stringToWstring(const std::string&);
+ICE_UTIL_API std::string wstringToString(const std::basic_string<unsigned short>&);
+ICE_UTIL_API std::basic_string<unsigned short> stringToTypedefWstring(const std::string&);
+# else
+//
+// Using a VC7.x build with the non-default /Zc
+//
+ICE_UTIL_API std::wstring stringToNativeWstring(const std::string&);
inline std::wstring
stringToWstring(const std::string& str)
{
return stringToNativeWstring(str);
}
+# endif
# else
+ICE_UTIL_API std::string wstringToString(const std::wstring&);
+
+# if _MSC_VER < 1400
//
-// We're building Ice or using it without /Zc:wchar_t
+// Building or using with VC7.x
//
-ICE_UTIL_API std::string wstringToString(const std::wstring&);
ICE_UTIL_API std::wstring stringToWstring(const std::string&);
-
ICE_UTIL_API std::string wstringToString(const std::basic_string<__wchar_t>&);
ICE_UTIL_API std::basic_string<__wchar_t> stringToNativeWstring(const std::string&);
-
+# else
+//
+// Using a VC8.x build the non-default /Zc
+//
+ICE_UTIL_API std::wstring stringToTypedefWstring(const std::string&);
+inline std::wstring
+stringToWstring(const std::string& str)
+{
+ return stringToTypedefWstring(str);
+}
+# endif
# endif
#else
diff --git a/cpp/src/IceUtil/Base64.cpp b/cpp/src/IceUtil/Base64.cpp
index d8883f2389f..da1001251a9 100644
--- a/cpp/src/IceUtil/Base64.cpp
+++ b/cpp/src/IceUtil/Base64.cpp
@@ -23,9 +23,9 @@ IceUtil::Base64::encode(const vector<unsigned char>& plainSeq)
}
// Reserve enough space for the returned base64 string
- unsigned long base64Bytes = (((plainSeq.size() * 4) / 3) + 1);
- unsigned long newlineBytes = (((base64Bytes * 2) / 76) + 1);
- unsigned long totalBytes = base64Bytes + newlineBytes;
+ size_t base64Bytes = (((plainSeq.size() * 4) / 3) + 1);
+ size_t newlineBytes = (((base64Bytes * 2) / 76) + 1);
+ size_t totalBytes = base64Bytes + newlineBytes;
retval.reserve(totalBytes);
@@ -37,7 +37,7 @@ IceUtil::Base64::encode(const vector<unsigned char>& plainSeq)
unsigned char by6 = 0;
unsigned char by7 = 0;
- for(unsigned long i = 0; i < plainSeq.size(); i += 3)
+ for(size_t i = 0; i < plainSeq.size(); i += 3)
{
by1 = plainSeq[i];
by2 = 0;
@@ -103,7 +103,7 @@ IceUtil::Base64::decode(const string& str)
newStr.reserve(str.length());
- for(unsigned long j = 0; j < str.length(); j++)
+ for(size_t j = 0; j < str.length(); j++)
{
if(isBase64(str[j]))
{
@@ -120,11 +120,11 @@ IceUtil::Base64::decode(const string& str)
// Note: This is how we were previously computing the size of the return
// sequence. The method below is more efficient (and correct).
- // unsigned long lines = str.size() / 78;
- // unsigned long totalBytes = (lines * 76) + (((str.size() - (lines * 78)) * 3) / 4);
+ // size_t lines = str.size() / 78;
+ // size_t totalBytes = (lines * 76) + (((str.size() - (lines * 78)) * 3) / 4);
// Figure out how long the final sequence is going to be.
- unsigned long totalBytes = (newStr.size() * 3 / 4) + 1;
+ size_t totalBytes = (newStr.size() * 3 / 4) + 1;
retval.reserve(totalBytes);
@@ -135,7 +135,7 @@ IceUtil::Base64::decode(const string& str)
char c1, c2, c3, c4;
- for(unsigned long i = 0; i < newStr.length(); i += 4)
+ for(size_t i = 0; i < newStr.length(); i += 4)
{
c1 = 'A';
c2 = 'A';
diff --git a/cpp/src/IceUtil/InputUtil.cpp b/cpp/src/IceUtil/InputUtil.cpp
index 4e0a6f59e88..f554acea2eb 100644
--- a/cpp/src/IceUtil/InputUtil.cpp
+++ b/cpp/src/IceUtil/InputUtil.cpp
@@ -175,14 +175,14 @@ strToInt64Impl(const char* s, char** endptr, int base)
Int64
strToInt64(const char* s, char** endptr, int base)
{
-#if defined(_WIN32)
+#if defined(ICE_64)
+ return strtol(s, endptr, base);
+#elif defined(_WIN32)
# if defined(_MSC_VER) && (_MSC_VER < 1300)
return strToInt64Impl(s, endptr, base);
# else
return _strtoi64(s, endptr, base);
# endif
-#elif defined(ICE_64)
- return strtol(s, endptr, base);
#elif defined(__hpux)
return __strtoll(s, endptr, base);
#else
diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp
index 38b113382a0..65e1886a7b8 100644
--- a/cpp/src/IceUtil/Thread.cpp
+++ b/cpp/src/IceUtil/Thread.cpp
@@ -168,8 +168,8 @@ IceUtil::Thread::id() const
return _id;
}
-static void*
-startHook(void* arg)
+static unsigned int
+WINAPI startHook(void* arg)
{
try
{
@@ -229,8 +229,11 @@ IceUtil::Thread::start(size_t stackSize)
//
__incRef();
- _handle->handle = (HANDLE)_beginthreadex(
- 0, stackSize, (unsigned int (__stdcall*)(void*))startHook, (LPVOID)this, 0, &_id);
+ _handle->handle =
+ reinterpret_cast<HANDLE>(
+ _beginthreadex(0,
+ static_cast<unsigned int>(stackSize),
+ startHook, this, 0, &_id));
if(_handle->handle == 0)
{
diff --git a/cpp/src/IceUtil/Time.cpp b/cpp/src/IceUtil/Time.cpp
index ebd3f6a56e7..09069e9152e 100644
--- a/cpp/src/IceUtil/Time.cpp
+++ b/cpp/src/IceUtil/Time.cpp
@@ -29,24 +29,25 @@ IceUtil::Time::now()
#ifdef _WIN32
struct _timeb tb;
_ftime(&tb);
- return Time(tb.time * static_cast<Int64>(1000000) + tb.millitm * static_cast<Int64>(1000));
+ return Time(static_cast<Int64>(tb.time) * ICE_INT64(1000000) +
+ tb.millitm * 1000);
#else
struct timeval tv;
gettimeofday(&tv, 0);
- return Time(tv.tv_sec * static_cast<Int64>(1000000) + tv.tv_usec);
+ return Time(tv.tv_sec * ICE_INT64(1000000) + tv.tv_usec);
#endif
}
Time
IceUtil::Time::seconds(Int64 t)
{
- return Time(t * static_cast<Int64>(1000000));
+ return Time(t * ICE_INT64(1000000));
}
Time
IceUtil::Time::milliSeconds(Int64 t)
{
- return Time(t * static_cast<Int64>(1000));
+ return Time(t * ICE_INT64(1000));
}
Time
diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp
index 8fbe1267af5..724139f25bd 100644
--- a/cpp/src/IceUtil/Unicode.cpp
+++ b/cpp/src/IceUtil/Unicode.cpp
@@ -45,6 +45,7 @@ IceUtil::wstringToString(const wstring& str)
result += 0x80 | ((wc>>6) & 0x3f);
result += 0x80 | (wc & 0x3f);
}
+#if SIZEOF_WCHAR_T >= 4
else if(wc < 0x10FFFF)
{
result += 0xf0 | (wc>>18);
@@ -52,6 +53,7 @@ IceUtil::wstringToString(const wstring& str)
result += 0x80 | ((wc>>6) & 0x3f);
result += 0x80 | (wc & 0x3f);
}
+#endif
else
{
return result; // Error, not encodable.
@@ -159,11 +161,13 @@ IceUtil::stringToWstring(const string& str)
//
// See comments in IceUtil/Unicode.h
//
+
+# if _MSC_VER < 1400
string
IceUtil::wstringToString(const basic_string<__wchar_t>& str)
{
assert(sizeof(__wchar_t) == SIZEOF_WCHAR_T);
- return wstringToString(*reinterpret_cast<const wstring*>(&str));
+ return wstringToString(*reinterpret_cast<const wstring*>(&str));
}
basic_string<__wchar_t>
@@ -172,5 +176,20 @@ IceUtil::stringToNativeWstring(const string& str)
assert(sizeof(__wchar_t) == SIZEOF_WCHAR_T);
return reinterpret_cast<basic_string<__wchar_t>& >(stringToWstring(str));
}
+# else
+string
+IceUtil::wstringToString(const basic_string<unsigned short>& str)
+{
+ assert(sizeof(__wchar_t) == SIZEOF_WCHAR_T);
+ return wstringToString(*reinterpret_cast<const wstring*>(&str));
+}
+
+basic_string<unsigned short>
+IceUtil::stringToTypedefWstring(const string& str)
+{
+ assert(sizeof(__wchar_t) == SIZEOF_WCHAR_T);
+ return reinterpret_cast<basic_string<unsigned short>& >(stringToWstring(str));
+}
+# endif
#endif
diff --git a/cpp/src/icecpp/config.h b/cpp/src/icecpp/config.h
index 5eacee9d5f1..1480369ff05 100644
--- a/cpp/src/icecpp/config.h
+++ b/cpp/src/icecpp/config.h
@@ -29,6 +29,13 @@
# ifdef _MSC_VER
# pragma warning( disable : 4018 )
# pragma warning( disable : 4244 )
+//
+//
+// TEMPORARY: move deprecated warning on VC8 to level 4
+# if _MSC_VER==1400
+# pragma warning( 4 : 4996 )
+# pragma warning( 4 : 4267 )
+# endif
# endif
# define alloca _alloca
#endif
diff --git a/cpp/src/icecpp/prefix.c b/cpp/src/icecpp/prefix.c
index 7f56057a55d..075e148de88 100644
--- a/cpp/src/icecpp/prefix.c
+++ b/cpp/src/icecpp/prefix.c
@@ -137,7 +137,7 @@ concat VPROTO((char *first, ...))
while (arg != 0)
{
- length += strlen (arg);
+ length += (int) strlen (arg);
arg = va_arg (args, char *);
}
@@ -272,7 +272,7 @@ translate_name (name)
#endif
)
{
- prefix = save_string (prefix, strlen (prefix));
+ prefix = save_string (prefix, (int)strlen (prefix));
prefix[strlen (prefix) - 1] = 0;
}