Skip to content

Commit

Permalink
Merge pull request #2329 from nvmkuruc/gfpyhash
Browse files Browse the repository at this point in the history
Use `TfHash` in `__hash__` implementations in `pxr/base/gf`

(Internal change: 2269113)
  • Loading branch information
pixar-oss committed Mar 31, 2023
2 parents 8a43c77 + da692f9 commit da2b53c
Show file tree
Hide file tree
Showing 32 changed files with 64 additions and 58 deletions.
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapDualQuat.template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "pxr/base/gf/dualQuat{{ SCALAR_SUFFIX(S) }}.h"
{% endfor %}

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -70,7 +71,7 @@ static {{ DUALQUAT }}& __itruediv__({{ DUALQUAT }} &self, {{ SCL }} value)
}

static size_t __hash__({{ DUALQUAT }} const &self) {
return hash_value(self);
return TfHash{}(self);
}

// Zero-initialized default ctor for python.
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapDualQuatd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "pxr/base/gf/dualQuatf.h"
#include "pxr/base/gf/dualQuath.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -70,7 +71,7 @@ static GfDualQuatd& __itruediv__(GfDualQuatd &self, double value)
}

static size_t __hash__(GfDualQuatd const &self) {
return hash_value(self);
return TfHash{}(self);
}

// Zero-initialized default ctor for python.
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapDualQuatf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "pxr/base/gf/dualQuatf.h"
#include "pxr/base/gf/dualQuath.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -70,7 +71,7 @@ static GfDualQuatf& __itruediv__(GfDualQuatf &self, float value)
}

static size_t __hash__(GfDualQuatf const &self) {
return hash_value(self);
return TfHash{}(self);
}

// Zero-initialized default ctor for python.
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapDualQuath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "pxr/base/gf/dualQuatf.h"
#include "pxr/base/gf/dualQuath.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -70,7 +71,7 @@ static GfDualQuath& __itruediv__(GfDualQuath &self, GfHalf value)
}

static size_t __hash__(GfDualQuath const &self) {
return hash_value(self);
return TfHash{}(self);
}

// Zero-initialized default ctor for python.
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapMatrix.template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
{% block customIncludes %}
{% endblock customIncludes %}

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/py3Compat.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -267,7 +268,7 @@ struct {{ MAT }}_Pickle_Suite : boost::python::pickle_suite
}
};

static size_t __hash__({{ MAT }} const &m) { return hash_value(m); }
static size_t __hash__({{ MAT }} const &m) { return TfHash{}(m); }

static boost::python::tuple get_dimension()
{
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapMatrix2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "pxr/base/gf/pyBufferUtils.h"


#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/py3Compat.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -264,7 +265,7 @@ struct GfMatrix2d_Pickle_Suite : boost::python::pickle_suite
}
};

static size_t __hash__(GfMatrix2d const &m) { return hash_value(m); }
static size_t __hash__(GfMatrix2d const &m) { return TfHash{}(m); }

static boost::python::tuple get_dimension()
{
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapMatrix2f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "pxr/base/gf/pyBufferUtils.h"


#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/py3Compat.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -264,7 +265,7 @@ struct GfMatrix2f_Pickle_Suite : boost::python::pickle_suite
}
};

static size_t __hash__(GfMatrix2f const &m) { return hash_value(m); }
static size_t __hash__(GfMatrix2f const &m) { return TfHash{}(m); }

static boost::python::tuple get_dimension()
{
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapMatrix3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "pxr/base/gf/quatd.h"
#include "pxr/base/gf/rotation.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/py3Compat.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -270,7 +271,7 @@ struct GfMatrix3d_Pickle_Suite : boost::python::pickle_suite
}
};

static size_t __hash__(GfMatrix3d const &m) { return hash_value(m); }
static size_t __hash__(GfMatrix3d const &m) { return TfHash{}(m); }

static boost::python::tuple get_dimension()
{
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapMatrix3f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "pxr/base/gf/quatf.h"
#include "pxr/base/gf/rotation.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/py3Compat.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -270,7 +271,7 @@ struct GfMatrix3f_Pickle_Suite : boost::python::pickle_suite
}
};

static size_t __hash__(GfMatrix3f const &m) { return hash_value(m); }
static size_t __hash__(GfMatrix3f const &m) { return TfHash{}(m); }

static boost::python::tuple get_dimension()
{
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapMatrix4d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "pxr/base/gf/quatd.h"
#include "pxr/base/gf/rotation.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/py3Compat.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -294,7 +295,7 @@ struct GfMatrix4d_Pickle_Suite : boost::python::pickle_suite
}
};

static size_t __hash__(GfMatrix4d const &m) { return hash_value(m); }
static size_t __hash__(GfMatrix4d const &m) { return TfHash{}(m); }

static boost::python::tuple get_dimension()
{
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapMatrix4f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "pxr/base/gf/quatf.h"
#include "pxr/base/gf/rotation.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/py3Compat.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -294,7 +295,7 @@ struct GfMatrix4f_Pickle_Suite : boost::python::pickle_suite
}
};

static size_t __hash__(GfMatrix4f const &m) { return hash_value(m); }
static size_t __hash__(GfMatrix4f const &m) { return TfHash{}(m); }

static boost::python::tuple get_dimension()
{
Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapQuaternion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "pxr/pxr.h"
#include "pxr/base/gf/quaternion.h"
#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -65,7 +66,7 @@ static string _Repr(GfQuaternion const &self) {
TfPyRepr(self.GetImaginary()) + ")";
}

static size_t __hash__(GfQuaternion const &self) { return hash_value(self); }
static size_t __hash__(GfQuaternion const &self) { return TfHash{}(self); }

} // anonymous namespace

Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapRange.template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "pxr/base/gf/range{{ DIM }}{{ S[0] }}.h"
{% endfor %}

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -67,7 +68,7 @@ static {{ RNG }}& __itruediv__({{ RNG }} &self, double value)
return self /= value;
}

static size_t __hash__({{ RNG }} const &r) { return hash_value(r); }
static size_t __hash__({{ RNG }} const &r) { return TfHash{}(r); }

} // anonymous namespace

Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapRange1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "pxr/base/gf/range1d.h"
#include "pxr/base/gf/range1f.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -65,7 +66,7 @@ static GfRange1d& __itruediv__(GfRange1d &self, double value)
return self /= value;
}

static size_t __hash__(GfRange1d const &r) { return hash_value(r); }
static size_t __hash__(GfRange1d const &r) { return TfHash{}(r); }

} // anonymous namespace

Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapRange1f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "pxr/base/gf/range1f.h"
#include "pxr/base/gf/range1d.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -65,7 +66,7 @@ static GfRange1f& __itruediv__(GfRange1f &self, double value)
return self /= value;
}

static size_t __hash__(GfRange1f const &r) { return hash_value(r); }
static size_t __hash__(GfRange1f const &r) { return TfHash{}(r); }

} // anonymous namespace

Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapRange2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "pxr/base/gf/range2d.h"
#include "pxr/base/gf/range2f.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -65,7 +66,7 @@ static GfRange2d& __itruediv__(GfRange2d &self, double value)
return self /= value;
}

static size_t __hash__(GfRange2d const &r) { return hash_value(r); }
static size_t __hash__(GfRange2d const &r) { return TfHash{}(r); }

} // anonymous namespace

Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapRange2f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "pxr/base/gf/range2f.h"
#include "pxr/base/gf/range2d.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -65,7 +66,7 @@ static GfRange2f& __itruediv__(GfRange2f &self, double value)
return self /= value;
}

static size_t __hash__(GfRange2f const &r) { return hash_value(r); }
static size_t __hash__(GfRange2f const &r) { return TfHash{}(r); }

} // anonymous namespace

Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapRange3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "pxr/base/gf/range3d.h"
#include "pxr/base/gf/range3f.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -65,7 +66,7 @@ static GfRange3d& __itruediv__(GfRange3d &self, double value)
return self /= value;
}

static size_t __hash__(GfRange3d const &r) { return hash_value(r); }
static size_t __hash__(GfRange3d const &r) { return TfHash{}(r); }

} // anonymous namespace

Expand Down
3 changes: 2 additions & 1 deletion pxr/base/gf/wrapRange3f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "pxr/base/gf/range3f.h"
#include "pxr/base/gf/range3d.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/wrapTypeHelpers.h"
#include "pxr/base/tf/pyContainerConversions.h"
Expand Down Expand Up @@ -65,7 +66,7 @@ static GfRange3f& __itruediv__(GfRange3f &self, double value)
return self /= value;
}

static size_t __hash__(GfRange3f const &r) { return hash_value(r); }
static size_t __hash__(GfRange3f const &r) { return TfHash{}(r); }

} // anonymous namespace

Expand Down
5 changes: 2 additions & 3 deletions pxr/base/gf/wrapVec.template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "pxr/base/gf/pyBufferUtils.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/py3Compat.h"
#include "pxr/base/tf/pyContainerConversions.h"
#include "pxr/base/tf/pyUtils.h"
Expand All @@ -53,8 +54,6 @@
#include <boost/python/tuple.hpp>
#include <boost/python/slice.hpp>

#include <boost/functional/hash.hpp>

#include <string>

using namespace boost::python;
Expand Down Expand Up @@ -180,7 +179,7 @@ static string __repr__({{ VEC }} const &self) {
}

static size_t __hash__({{ VEC }} const &self) {
return boost::hash<{{ VEC }}>()(self);
return TfHash{}(self);
}

{% if IS_FLOATING_POINT(SCL) %}
Expand Down
5 changes: 2 additions & 3 deletions pxr/base/gf/wrapVec2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "pxr/base/gf/pyBufferUtils.h"

#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/py3Compat.h"
#include "pxr/base/tf/pyContainerConversions.h"
#include "pxr/base/tf/pyUtils.h"
Expand All @@ -51,8 +52,6 @@
#include <boost/python/tuple.hpp>
#include <boost/python/slice.hpp>

#include <boost/functional/hash.hpp>

#include <string>

using namespace boost::python;
Expand Down Expand Up @@ -178,7 +177,7 @@ static string __repr__(GfVec2d const &self) {
}

static size_t __hash__(GfVec2d const &self) {
return boost::hash<GfVec2d>()(self);
return TfHash{}(self);
}


Expand Down
Loading

0 comments on commit da2b53c

Please sign in to comment.