diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-10-06 20:48:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-10-06 20:48:28 +0400 |
commit | dda63a9dde8600f85e43bc4d654cbe80d07cab6e (patch) | |
tree | 76010b4123957872bba0dbcd399da90e590ddfff /source/blender/python/api2_2x/Key.c | |
parent | aaaae785276e287d9a30a005d14af61524845d72 (diff) |
added comparison function to many python types so you can do == and =!
Diffstat (limited to 'source/blender/python/api2_2x/Key.c')
-rw-r--r-- | source/blender/python/api2_2x/Key.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/python/api2_2x/Key.c b/source/blender/python/api2_2x/Key.c index 32d7bc26191..0630fe6cf3e 100644 --- a/source/blender/python/api2_2x/Key.c +++ b/source/blender/python/api2_2x/Key.c @@ -61,6 +61,7 @@ static void Key_dealloc( PyObject * self ); static void KeyBlock_dealloc( PyObject * self ); +static int Key_compare( BPy_Key * a, BPy_Key * b ); static PyObject *Key_repr( BPy_Key * self ); static PyObject *Key_getBlocks( PyObject * self ); @@ -138,7 +139,7 @@ PyTypeObject Key_Type = { ( printfunc ) 0, /*tp_print */ ( getattrfunc ) 0, /*tp_getattr */ ( setattrfunc ) 0, /*tp_setattr */ - 0, /*tp_compare*/ + ( cmpfunc) Key_compare, /*tp_compare*/ ( reprfunc ) Key_repr, /* tp_repr */ /* Method suites for standard classes */ @@ -306,6 +307,12 @@ PyObject *Key_CreatePyObject( Key * k ) return ( PyObject * ) key; } + +static int Key_compare( BPy_Key * a, BPy_Key * b ) +{ + return ( a->key == b->key ) ? 0 : -1; +} + static PyObject *Key_repr( BPy_Key * self ) { return PyString_FromFormat( "[Key \"%s\"]", self->key->id.name + 2 ); |