change return values from mathutils callbacks to match pythons (-1 is error), so error macro's can be used in both.

This commit is contained in:
Campbell Barton
2011-02-28 18:42:41 +00:00
parent 506e8aa437
commit 7348a50d79
12 changed files with 224 additions and 220 deletions

View File

@@ -138,7 +138,7 @@ static PyObject *Euler_to_quaternion(EulerObject * self)
{
float quat[4];
if(!BaseMath_ReadCallback(self))
if(BaseMath_ReadCallback(self) == -1)
return NULL;
eulO_to_quat(quat, self->eul, self->order);
@@ -159,7 +159,7 @@ static PyObject *Euler_to_matrix(EulerObject * self)
{
float mat[9];
if(!BaseMath_ReadCallback(self))
if(BaseMath_ReadCallback(self) == -1)
return NULL;
eulO_to_mat3((float (*)[3])mat, self->eul, self->order);
@@ -177,7 +177,9 @@ static PyObject *Euler_zero(EulerObject * self)
{
zero_v3(self->eul);
(void)BaseMath_WriteCallback(self);
if(BaseMath_WriteCallback(self) == -1)
return NULL;
Py_RETURN_NONE;
}
@@ -205,7 +207,7 @@ static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args)
return NULL;
}
if(!BaseMath_ReadCallback(self))
if(BaseMath_ReadCallback(self) == -1)
return NULL;
@@ -228,7 +230,7 @@ static PyObject *Euler_rotate(EulerObject * self, PyObject *value)
{
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
if(!BaseMath_ReadCallback(self))
if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1)
@@ -254,7 +256,7 @@ static PyObject *Euler_make_compatible(EulerObject * self, PyObject *value)
{
float teul[EULER_SIZE];
if(!BaseMath_ReadCallback(self))
if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value, "euler.make_compatible(other), invalid 'other' arg") == -1)
@@ -282,7 +284,7 @@ static char Euler_copy_doc[] =
;
static PyObject *Euler_copy(EulerObject *self)
{
if(!BaseMath_ReadCallback(self))
if(BaseMath_ReadCallback(self) == -1)
return NULL;
return newEulerObject(self->eul, self->order, Py_NEW, Py_TYPE(self));
@@ -295,7 +297,7 @@ static PyObject *Euler_repr(EulerObject * self)
{
PyObject *ret, *tuple;
if(!BaseMath_ReadCallback(self))
if(BaseMath_ReadCallback(self) == -1)
return NULL;
tuple= Euler_ToTupleExt(self, -1);
@@ -315,7 +317,7 @@ static PyObject* Euler_richcmpr(PyObject *a, PyObject *b, int op)
EulerObject *eulA= (EulerObject*)a;
EulerObject *eulB= (EulerObject*)b;
if(!BaseMath_ReadCallback(eulA) || !BaseMath_ReadCallback(eulB))
if(BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1)
return NULL;
ok= ((eulA->order == eulB->order) && EXPP_VectorsAreEqual(eulA->eul, eulB->eul, EULER_SIZE, 1)) ? 0 : -1;
@@ -360,7 +362,7 @@ static PyObject *Euler_item(EulerObject * self, int i)
return NULL;
}
if(!BaseMath_ReadIndexCallback(self, i))
if(BaseMath_ReadIndexCallback(self, i) == -1)
return NULL;
return PyFloat_FromDouble(self->eul[i]);
@@ -386,7 +388,7 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value)
self->eul[i] = f;
if(!BaseMath_WriteIndexCallback(self, i))
if(BaseMath_WriteIndexCallback(self, i) == -1)
return -1;
return 0;
@@ -398,7 +400,7 @@ static PyObject *Euler_slice(EulerObject * self, int begin, int end)
PyObject *tuple;
int count;
if(!BaseMath_ReadCallback(self))
if(BaseMath_ReadCallback(self) == -1)
return NULL;
CLAMP(begin, 0, EULER_SIZE);
@@ -420,7 +422,7 @@ static int Euler_ass_slice(EulerObject * self, int begin, int end, PyObject * se
int i, size;
float eul[EULER_SIZE];
if(!BaseMath_ReadCallback(self))
if(BaseMath_ReadCallback(self) == -1)
return -1;
CLAMP(begin, 0, EULER_SIZE);
@@ -542,7 +544,7 @@ static int Euler_setAxis(EulerObject *self, PyObject *value, void *type)
/* rotation order */
static PyObject *Euler_getOrder(EulerObject *self, void *UNUSED(closure))
{
if(!BaseMath_ReadCallback(self)) /* can read order too */
if(BaseMath_ReadCallback(self) == -1) /* can read order too */
return NULL;
return PyUnicode_FromString(euler_order_str(self));