From 61f4d6ae4d23de0a668ab03fb0670a49435dde00 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 14 Aug 2007 06:38:44 +0000 Subject: added bone comparison for the python api --- source/blender/python/api2_2x/Bone.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'source/blender/python/api2_2x/Bone.c') diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c index ad589615b7d..733b8251215 100644 --- a/source/blender/python/api2_2x/Bone.c +++ b/source/blender/python/api2_2x/Bone.c @@ -762,6 +762,14 @@ static PyObject *EditBone_repr(BPy_EditBone *self) return PyString_FromFormat( "[EditBone \"%s\"]", self->name ); } +static int EditBone_compare( BPy_EditBone * a, BPy_EditBone * b ) +{ + /* if they are not wrapped, then they cant be the same */ + if (a->editbone==NULL && b->editbone==NULL) return -1; + return ( a->editbone == b->editbone ) ? 0 : -1; +} + + //------------------------tp_doc //The __doc__ string for this object static char BPy_EditBone_doc[] = "This is an internal subobject of armature\ @@ -829,7 +837,7 @@ PyTypeObject EditBone_Type = { 0, //tp_print 0, //tp_getattr 0, //tp_setattr - 0, //tp_compare + (cmpfunc)EditBone_compare, //tp_compare (reprfunc)EditBone_repr, //tp_repr 0, //tp_as_number 0, //tp_as_sequence @@ -1246,6 +1254,10 @@ static PyObject *Bone_repr(BPy_Bone *self) { return PyString_FromFormat( "[Bone \"%s\"]", self->bone->name ); } +static int Bone_compare( BPy_Bone * a, BPy_Bone * b ) +{ + return ( a->bone == b->bone ) ? 0 : -1; +} //------------------------tp_dealloc //This tells how to 'tear-down' our object when ref count hits 0 static void Bone_dealloc(BPy_Bone * self) @@ -1262,15 +1274,15 @@ static char BPy_Bone_doc[] = "This object wraps a Blender Boneobject.\n\ PyTypeObject Bone_Type = { PyObject_HEAD_INIT(NULL) //tp_head 0, //tp_internal - "Bone", //tp_name - sizeof(BPy_Bone), //tp_basicsize + "Bone", //tp_name + sizeof(BPy_Bone), //tp_basicsize 0, //tp_itemsize - (destructor)Bone_dealloc, //tp_dealloc + (destructor)Bone_dealloc, //tp_dealloc 0, //tp_print 0, //tp_getattr 0, //tp_setattr - 0, //tp_compare - (reprfunc) Bone_repr, //tp_repr + (cmpfunc) Bone_compare, //tp_compare + (reprfunc) Bone_repr, //tp_repr 0, //tp_as_number 0, //tp_as_sequence 0, //tp_as_mapping -- cgit v1.2.3