Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-06-28 17:27:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-06-28 17:27:06 +0400
commit1b5851b4f963f32890ea7479ba410844bb906b5e (patch)
tree776927ba4784792f39641b54dfe62c08a0e19082
parent7d88981a24e16c9ddd5d882183d9421e7ce90d23 (diff)
PyNumberMethods needed ifdefs for python3.x and some other corrections.
-rw-r--r--source/blender/python/generic/BGL.c9
-rw-r--r--source/blender/python/generic/Mathutils.c2
-rw-r--r--source/blender/python/generic/euler.c13
-rw-r--r--source/blender/python/generic/matrix.c41
-rw-r--r--source/blender/python/generic/quat.c42
-rw-r--r--source/blender/python/generic/vector.c40
6 files changed, 139 insertions, 8 deletions
diff --git a/source/blender/python/generic/BGL.c b/source/blender/python/generic/BGL.c
index a90fabd3586..de82781cf3a 100644
--- a/source/blender/python/generic/BGL.c
+++ b/source/blender/python/generic/BGL.c
@@ -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 */
diff --git a/source/blender/python/generic/Mathutils.c b/source/blender/python/generic/Mathutils.c
index ec94a48ddbd..ffb110376b0 100644
--- a/source/blender/python/generic/Mathutils.c
+++ b/source/blender/python/generic/Mathutils.c
@@ -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)
diff --git a/source/blender/python/generic/euler.c b/source/blender/python/generic/euler.c
index 9041eb84a3d..769c82ed034 100644
--- a/source/blender/python/generic/euler.c
+++ b/source/blender/python/generic/euler.c
@@ -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;
}
diff --git a/source/blender/python/generic/matrix.c b/source/blender/python/generic/matrix.c
index b546aa1226c..311a14fbb0a 100644
--- a/source/blender/python/generic/matrix.c
+++ b/source/blender/python/generic/matrix.c
@@ -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 )
{
diff --git a/source/blender/python/generic/quat.c b/source/blender/python/generic/quat.c
index e7413d38ee5..7cd3cf738dd 100644
--- a/source/blender/python/generic/quat.c
+++ b/source/blender/python/generic/quat.c
@@ -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 )
{
diff --git a/source/blender/python/generic/vector.c b/source/blender/python/generic/vector.c
index 9ce0a7ca2f9..d8d4c33b6f8 100644
--- a/source/blender/python/generic/vector.c
+++ b/source/blender/python/generic/vector.c
@@ -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--------------------------*/
/*