[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21218] branches/blender2.5/blender/source /blender/python/generic: PyNumberMethods needed ifdefs for python3. x and some other corrections.
Campbell Barton
ideasman42 at gmail.com
Sun Jun 28 15:27:06 CEST 2009
Revision: 21218
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21218
Author: campbellbarton
Date: 2009-06-28 15:27:06 +0200 (Sun, 28 Jun 2009)
Log Message:
-----------
PyNumberMethods needed ifdefs for python3.x and some other corrections.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/python/generic/BGL.c
branches/blender2.5/blender/source/blender/python/generic/Mathutils.c
branches/blender2.5/blender/source/blender/python/generic/euler.c
branches/blender2.5/blender/source/blender/python/generic/matrix.c
branches/blender2.5/blender/source/blender/python/generic/quat.c
branches/blender2.5/blender/source/blender/python/generic/vector.c
Modified: branches/blender2.5/blender/source/blender/python/generic/BGL.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/generic/BGL.c 2009-06-28 13:20:37 UTC (rev 21217)
+++ branches/blender2.5/blender/source/blender/python/generic/BGL.c 2009-06-28 13:27:06 UTC (rev 21218)
@@ -83,8 +83,13 @@
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 */
Modified: branches/blender2.5/blender/source/blender/python/generic/Mathutils.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/generic/Mathutils.c 2009-06-28 13:20:37 UTC (rev 21217)
+++ branches/blender2.5/blender/source/blender/python/generic/Mathutils.c 2009-06-28 13:27:06 UTC (rev 21218)
@@ -1244,7 +1244,7 @@
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)
Modified: branches/blender2.5/blender/source/blender/python/generic/euler.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/generic/euler.c 2009-06-28 13:20:37 UTC (rev 21217)
+++ branches/blender2.5/blender/source/blender/python/generic/euler.c 2009-06-28 13:27:06 UTC (rev 21218)
@@ -65,7 +65,7 @@
//----------------------------------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 @@
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_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 @@
PyObject *e;
if(!BaseMath_ReadCallback(self))
- return NULL;
+ return -1;
CLAMP(begin, 0, 3);
if (end<0) end= 4+end;
@@ -636,5 +643,5 @@
self->cb_subtype= (unsigned char)cb_subtype;
}
- return self;
+ return (PyObject *)self;
}
Modified: branches/blender2.5/blender/source/blender/python/generic/matrix.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/generic/matrix.c 2009-06-28 13:20:37 UTC (rev 21217)
+++ branches/blender2.5/blender/source/blender/python/generic/matrix.c 2009-06-28 13:27:06 UTC (rev 21218)
@@ -1012,7 +1012,47 @@
(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__ */
(binaryfunc) Matrix_mul, /* __mul__ */
@@ -1037,6 +1077,7 @@
(unaryfunc) 0, /* __oct__ */
(unaryfunc) 0, /* __hex__ */
};
+#endif
static PyObject *Matrix_getRowSize( MatrixObject * self, void *type )
{
Modified: branches/blender2.5/blender/source/blender/python/generic/quat.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/generic/quat.c 2009-06-28 13:20:37 UTC (rev 21217)
+++ branches/blender2.5/blender/source/blender/python/generic/quat.c 2009-06-28 13:27:06 UTC (rev 21218)
@@ -622,7 +622,46 @@
(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__ */
(binaryfunc) Quaternion_mul, /* __mul__ */
@@ -646,10 +685,9 @@
(unaryfunc) 0, /* __float__ */
(unaryfunc) 0, /* __oct__ */
(unaryfunc) 0, /* __hex__ */
-
};
+#endif
-
static PyObject *Quaternion_getAxis( QuaternionObject * self, void *type )
{
return Quaternion_item(self, GET_INT_FROM_POINTER(type));
Modified: branches/blender2.5/blender/source/blender/python/generic/vector.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/generic/vector.c 2009-06-28 13:20:37 UTC (rev 21217)
+++ branches/blender2.5/blender/source/blender/python/generic/vector.c 2009-06-28 13:27:06 UTC (rev 21218)
@@ -1077,7 +1077,45 @@
(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__ */
(binaryfunc) Vector_mul, /* __mul__ */
@@ -1122,6 +1160,8 @@
(binaryfunc) NULL, /*__ifloordiv__*/
(binaryfunc) NULL, /*__itruediv__*/
};
+#endif
+
/*------------------PY_OBECT DEFINITION--------------------------*/
/*
More information about the Bf-blender-cvs
mailing list