PyNumberMethods needed ifdefs for python3.x and some other corrections.

This commit is contained in:
2009-06-28 13:27:06 +00:00
parent 7d88981a24
commit 1b5851b4f9
6 changed files with 139 additions and 8 deletions

View File

@@ -83,8 +83,13 @@ static PyObject *Buffer_getattr( PyObject * self, char *name );
static PyObject *Buffer_repr( PyObject * self );
PyTypeObject buffer_Type = {
PyObject_HEAD_INIT( NULL ) /* required python macro */
0, /*ob_size */
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
#else
/* python 2.5 and below */
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
#endif
"buffer", /*tp_name */
sizeof( Buffer ), /*tp_basicsize */
0, /*tp_itemsize */

View File

@@ -1244,7 +1244,7 @@ PyObject *BaseMathObject_getOwner( BaseMathObject * self, void *type )
PyObject *BaseMathObject_getWrapped( BaseMathObject *self, void *type )
{
PyBool_FromLong((self->wrapped == Py_WRAP) ? 1:0);
return PyBool_FromLong((self->wrapped == Py_WRAP) ? 1:0);
}
void BaseMathObject_dealloc(BaseMathObject * self)

View File

@@ -65,7 +65,7 @@ static struct PyMethodDef Euler_methods[] = {
//----------------------------------Mathutils.Euler() -------------------
//makes a new euler for you to play with
static PyObject *Euler_new(PyObject * self, PyObject * args)
static PyObject *Euler_new(PyObject * self, PyObject * args, PyObject * kwargs)
{
PyObject *listObject = NULL;
@@ -173,8 +173,13 @@ static PyObject *Euler_Unique(EulerObject * self)
heading = self->eul[0] * (float)Py_PI / 180;
pitch = self->eul[1] * (float)Py_PI / 180;
bank = self->eul[2] * (float)Py_PI / 180;
#else
heading = self->eul[0];
pitch = self->eul[1];
bank = self->eul[2];
#endif
//wrap heading in +180 / -180
pitch += Py_PI;
pitch -= floor(pitch * Opi2) * pi2;
@@ -271,8 +276,10 @@ static PyObject *Euler_Rotate(EulerObject * self, PyObject *args)
static PyObject *Euler_MakeCompatible(EulerObject * self, EulerObject *value)
{
#ifdef USE_MATHUTILS_DEG
float eul_from_rad[3];
int x;
#endif
if(!EulerObject_Check(value)) {
PyErr_SetString(PyExc_TypeError, "euler.makeCompatible(euler):expected a single euler argument.");
@@ -460,7 +467,7 @@ static int Euler_ass_slice(EulerObject * self, int begin, int end,
PyObject *e;
if(!BaseMath_ReadCallback(self))
return NULL;
return -1;
CLAMP(begin, 0, 3);
if (end<0) end= 4+end;
@@ -636,5 +643,5 @@ PyObject *newEulerObject_cb(PyObject *cb_user, int cb_type, int cb_subtype)
self->cb_subtype= (unsigned char)cb_subtype;
}
return self;
return (PyObject *)self;
}

View File

@@ -1012,6 +1012,46 @@ static PySequenceMethods Matrix_SeqMethods = {
(ssizeobjargproc) Matrix_ass_item, /* sq_ass_item */
(ssizessizeobjargproc) Matrix_ass_slice, /* sq_ass_slice */
};
#if (PY_VERSION_HEX >= 0x03000000)
static PyNumberMethods Matrix_NumMethods = {
(binaryfunc) Matrix_add, /*nb_add*/
(binaryfunc) Matrix_sub, /*nb_subtract*/
(binaryfunc) Matrix_mul, /*nb_multiply*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
(unaryfunc) 0, /*nb_negative*/
(unaryfunc) 0, /*tp_positive*/
(unaryfunc) 0, /*tp_absolute*/
(inquiry) 0, /*tp_bool*/
(unaryfunc) Matrix_inv, /*nb_invert*/
0, /*nb_lshift*/
(binaryfunc)0, /*nb_rshift*/
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
0, /*nb_int*/
0, /*nb_reserved*/
0, /*nb_float*/
0, /* nb_inplace_add */
0, /* nb_inplace_subtract */
0, /* nb_inplace_multiply */
0, /* nb_inplace_remainder */
0, /* nb_inplace_power */
0, /* nb_inplace_lshift */
0, /* nb_inplace_rshift */
0, /* nb_inplace_and */
0, /* nb_inplace_xor */
0, /* nb_inplace_or */
0, /* nb_floor_divide */
0, /* nb_true_divide */
0, /* nb_inplace_floor_divide */
0, /* nb_inplace_true_divide */
0, /* nb_index */
};
#else
static PyNumberMethods Matrix_NumMethods = {
(binaryfunc) Matrix_add, /* __add__ */
(binaryfunc) Matrix_sub, /* __sub__ */
@@ -1037,6 +1077,7 @@ static PyNumberMethods Matrix_NumMethods = {
(unaryfunc) 0, /* __oct__ */
(unaryfunc) 0, /* __hex__ */
};
#endif
static PyObject *Matrix_getRowSize( MatrixObject * self, void *type )
{

View File

@@ -622,6 +622,45 @@ static PySequenceMethods Quaternion_SeqMethods = {
(ssizeobjargproc) Quaternion_ass_item, /* sq_ass_item */
(ssizessizeobjargproc) Quaternion_ass_slice, /* sq_ass_slice */
};
#if (PY_VERSION_HEX >= 0x03000000)
static PyNumberMethods Quaternion_NumMethods = {
(binaryfunc) Quaternion_add, /*nb_add*/
(binaryfunc) Quaternion_sub, /*nb_subtract*/
(binaryfunc) Quaternion_mul, /*nb_multiply*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
(unaryfunc) 0, /*nb_negative*/
(unaryfunc) 0, /*tp_positive*/
(unaryfunc) 0, /*tp_absolute*/
(inquiry) 0, /*tp_bool*/
(unaryfunc) 0, /*nb_invert*/
0, /*nb_lshift*/
(binaryfunc)0, /*nb_rshift*/
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
0, /*nb_int*/
0, /*nb_reserved*/
0, /*nb_float*/
0, /* nb_inplace_add */
0, /* nb_inplace_subtract */
0, /* nb_inplace_multiply */
0, /* nb_inplace_remainder */
0, /* nb_inplace_power */
0, /* nb_inplace_lshift */
0, /* nb_inplace_rshift */
0, /* nb_inplace_and */
0, /* nb_inplace_xor */
0, /* nb_inplace_or */
0, /* nb_floor_divide */
0, /* nb_true_divide */
0, /* nb_inplace_floor_divide */
0, /* nb_inplace_true_divide */
0, /* nb_index */
};
#else
static PyNumberMethods Quaternion_NumMethods = {
(binaryfunc) Quaternion_add, /* __add__ */
(binaryfunc) Quaternion_sub, /* __sub__ */
@@ -646,9 +685,8 @@ static PyNumberMethods Quaternion_NumMethods = {
(unaryfunc) 0, /* __float__ */
(unaryfunc) 0, /* __oct__ */
(unaryfunc) 0, /* __hex__ */
};
#endif
static PyObject *Quaternion_getAxis( QuaternionObject * self, void *type )
{

View File

@@ -1077,6 +1077,44 @@ static PySequenceMethods Vector_SeqMethods = {
(ssizessizeobjargproc) Vector_ass_slice, /* sq_ass_slice */
};
#if (PY_VERSION_HEX >= 0x03000000)
static PyNumberMethods Vector_NumMethods = {
(binaryfunc) Vector_add, /*nb_add*/
(binaryfunc) Vector_sub, /*nb_subtract*/
(binaryfunc) Vector_mul, /*nb_multiply*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
(unaryfunc) Vector_neg, /*nb_negative*/
(unaryfunc) 0, /*tp_positive*/
(unaryfunc) 0, /*tp_absolute*/
(inquiry) 0, /*tp_bool*/
(unaryfunc) 0, /*nb_invert*/
0, /*nb_lshift*/
(binaryfunc)0, /*nb_rshift*/
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
0, /*nb_int*/
0, /*nb_reserved*/
0, /*nb_float*/
Vector_iadd, /* nb_inplace_add */
Vector_isub, /* nb_inplace_subtract */
Vector_imul, /* nb_inplace_multiply */
0, /* nb_inplace_remainder */
0, /* nb_inplace_power */
0, /* nb_inplace_lshift */
0, /* nb_inplace_rshift */
0, /* nb_inplace_and */
0, /* nb_inplace_xor */
0, /* nb_inplace_or */
0, /* nb_floor_divide */
Vector_div, /* nb_true_divide */
0, /* nb_inplace_floor_divide */
Vector_idiv, /* nb_inplace_true_divide */
0, /* nb_index */
};
#else
static PyNumberMethods Vector_NumMethods = {
(binaryfunc) Vector_add, /* __add__ */
(binaryfunc) Vector_sub, /* __sub__ */
@@ -1122,6 +1160,8 @@ static PyNumberMethods Vector_NumMethods = {
(binaryfunc) NULL, /*__ifloordiv__*/
(binaryfunc) NULL, /*__itruediv__*/
};
#endif
/*------------------PY_OBECT DEFINITION--------------------------*/
/*