Browse Source

try harder to avoid 64-bit complaints

David Rose 18 years ago
parent
commit
7ccbc378f4
2 changed files with 22 additions and 1 deletions
  1. 11 0
      dtool/src/dtoolbase/stl_compares.I
  2. 11 1
      dtool/src/dtoolbase/stl_compares.h

+ 11 - 0
dtool/src/dtoolbase/stl_compares.I

@@ -124,6 +124,17 @@ is_equal(const Key &a, const Key &b) const {
 template<class Key, class Compare>
 INLINE size_t integer_hash<Key, Compare>::
 add_hash(size_t hash, const Key &key) {
+  PN_uint32 key32 = (PN_uint32)(key);
+  return AddHash::add_hash(hash, &key32, 1);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: pointer_hash::add_hash
+//       Access: Public, Static
+//  Description: Adds the indicated key into a running hash.
+////////////////////////////////////////////////////////////////////
+INLINE size_t pointer_hash::
+add_hash(size_t hash, void *key) {
   // We don't mind if this loses precision.
   PN_uint32 key32 = (PN_uint32)reinterpret_cast<unsigned long>(key);
   return AddHash::add_hash(hash, &key32, 1);

+ 11 - 1
dtool/src/dtoolbase/stl_compares.h

@@ -144,6 +144,17 @@ public:
   INLINE static size_t add_hash(size_t start, const Key &key);
 };
 
+////////////////////////////////////////////////////////////////////
+//       Class : pointer_hash
+// Description : This is the default hash_compare class, which assumes
+//               the Key is a pointer value.  It is the same as the
+//               system-provided hash_compare.
+////////////////////////////////////////////////////////////////////
+class pointer_hash : public stl_hash_compare<void *, less<void *> > {
+public:
+  INLINE static size_t add_hash(size_t start, void *key);
+};
+
 ////////////////////////////////////////////////////////////////////
 //       Class : floating_point_hash
 // Description : This hash_compare class hashes a float or a double.
@@ -209,7 +220,6 @@ public:
 
 typedef floating_point_hash<float> float_hash;
 typedef floating_point_hash<double> double_hash;
-typedef integer_hash<const void *> pointer_hash;
 typedef integer_hash<int> int_hash;
 typedef integer_hash<size_t> size_t_hash;
 typedef sequence_hash<string> string_hash;