summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/JavaUtil.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2012-11-12 20:18:19 +0100
committerJose <jose@zeroc.com>2012-11-12 20:18:19 +0100
commitd20f9b3983d0da9912da600506b52e7bd3272a03 (patch)
tree79acf9785d17efb5eb50a5a5de9f357882c930c8 /cpp/src/Slice/JavaUtil.cpp
parentEclipse plug-in minor updates (diff)
downloadice-d20f9b3983d0da9912da600506b52e7bd3272a03.tar.bz2
ice-d20f9b3983d0da9912da600506b52e7bd3272a03.tar.xz
ice-d20f9b3983d0da9912da600506b52e7bd3272a03.zip
Java serial versionUUID fixes
Diffstat (limited to 'cpp/src/Slice/JavaUtil.cpp')
-rw-r--r--cpp/src/Slice/JavaUtil.cpp77
1 files changed, 45 insertions, 32 deletions
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp
index 0c75dadedd0..6b6559b4f2f 100644
--- a/cpp/src/Slice/JavaUtil.cpp
+++ b/cpp/src/Slice/JavaUtil.cpp
@@ -32,6 +32,21 @@ using namespace Slice;
using namespace IceUtil;
using namespace IceUtilInternal;
+
+namespace
+{
+
+void
+hashAdd(long& hashCode, const std::string& value)
+{
+ for(std::string::const_iterator p = value.begin(); p != value.end(); ++p)
+ {
+ hashCode = ((hashCode << 5) + hashCode) ^ *p;
+ }
+}
+
+}
+
long
Slice::computeSerialVersionUUID(const ClassDefPtr& p)
{
@@ -66,23 +81,9 @@ Slice::computeSerialVersionUUID(const ClassDefPtr& p)
os << "]";
const string data = os.str();
- MD5 md5(reinterpret_cast<const unsigned char*>(data.c_str()), static_cast<int>(data.size()));
- vector<unsigned char> bytes;
- bytes.resize(16);
- md5.getDigest(reinterpret_cast<unsigned char*>(&bytes[0]));
-
- long h0 = 0;
- long h1 = 0;
- for(int i = 0; i < 8; ++i)
- {
- h0 |= (long)bytes[i] << (i * 4);
- }
-
- for(int i = 0; i < 8; ++i)
- {
- h1 |= (long)bytes[i + 8] << (i * 4);
- }
- return abs(h0 ^ h1);
+ long hashCode = 5381;
+ hashAdd(hashCode, data);
+ return hashCode;
}
long
@@ -105,26 +106,38 @@ Slice::computeSerialVersionUUID(const StructPtr& p)
os << "]";
const string data = os.str();
- MD5 md5(reinterpret_cast<const unsigned char*>(data.c_str()), static_cast<int>(data.size()));
- vector<unsigned char> bytes;
- bytes.resize(16);
- md5.getDigest(reinterpret_cast<unsigned char*>(&bytes[0]));
-
- long h0 = 0;
- long h1 = 0;
- for(int i = 0; i < 8; ++i)
- {
- h0 |= (long)bytes[i] << (i * 4);
- }
-
- for(int i = 0; i < 8; ++i)
+ long hashCode = 5381;
+ hashAdd(hashCode, data);
+ return hashCode;
+}
+
+long
+Slice::computeSerialVersionUUID(const ExceptionPtr& p)
+{
+ ostringstream os;
+
+ os << "Name: " << p->scoped();
+ os << " Members: [";
+ DataMemberList members = p->dataMembers();
+ for(DataMemberList::const_iterator i = members.begin(); i != members.end();)
{
- h1 |= (long)bytes[i + 8] << (i * 4);
+ os << (*i)->name() << ":" << (*i)->type();
+ i++;
+ if(i != members.end())
+ {
+ os << ", ";
+ }
}
+ os << "]";
- return abs(h0 ^ h1);
+ const string data = os.str();
+ long hashCode = 5381;
+ hashAdd(hashCode, data);
+ return hashCode;
}
+
+
Slice::JavaOutput::JavaOutput()
{
}