Skip to content
Snippets Groups Projects
Commit 5f9cba77 authored by David Gobbi's avatar David Gobbi Committed by Code Review
Browse files

Merge topic '14037-pyclass-hashable' into master

aea22686 BUG 14037: Add hash function to PyVTKClass type.
parents b1fdbfb8 aea22686
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,17 @@ static PyObject *PyVTKClass_Repr(PyObject *op)
return PyString_FromString(buf);
}
//--------------------------------------------------------------------
static long PyVTKClass_Hash(PyObject *op)
{
size_t y = reinterpret_cast<size_t>(op);
y = (y >> 4) | (y << (8 * sizeof(op) - 4));
long x = static_cast<long>(y);
if (x == -1) { x = -2; }
return x;
}
//--------------------------------------------------------------------
static PyObject *PyVTKClass_Call(PyObject *op, PyObject *arg, PyObject *kw)
{
......@@ -398,7 +409,7 @@ PyTypeObject PyVTKClass_Type = {
0, // tp_as_number
0, // tp_as_sequence
0, // tp_as_mapping
0, // tp_hash
PyVTKClass_Hash, // tp_hash
PyVTKClass_Call, // tp_call
PyVTKClass_String, // tp_string
PyVTKClass_GetAttr, // tp_getattro
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment