NLA SoC: Merge from 2.5
[blender.git] / source / gameengine / VideoTexture / FilterBlueScreen.cpp
index 50c3a87ffc41947298bd1d520f00b87bb1e89f34..6d26e5b6d35c039f96b94a94ed506f1c25d08b16 100644 (file)
@@ -81,17 +81,17 @@ static int setColor (PyFilter * self, PyObject * value, void * closure)
 {
        // check validity of parameter
        if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 3
-               || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
-               || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1))
-               || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 2)))
+               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
+               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))
+               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 2)))
        {
                PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 3 ints");
                return -1;
        }
        // set color
-       getFilter(self)->setColor((unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
-               (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))),
-               (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2))));
+       getFilter(self)->setColor((unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))),
+               (unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1))),
+               (unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2))));
        // success
        return 0;
 }
@@ -108,15 +108,15 @@ static int setLimits (PyFilter * self, PyObject * value, void * closure)
 {
        // check validity of parameter
        if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2
-               || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
-               || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1)))
+               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
+               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
        {
                PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
                return -1;
        }
        // set limits
-       getFilter(self)->setLimits((unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
-               (unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))));
+       getFilter(self)->setLimits((unsigned short)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))),
+               (unsigned short)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1))));
        // success
        return 0;
 }
@@ -125,18 +125,23 @@ static int setLimits (PyFilter * self, PyObject * value, void * closure)
 // attributes structure
 static PyGetSetDef filterBSGetSets[] =
 { 
-       {"color", (getter)getColor, (setter)setColor, "blue screen color", NULL},
-       {"limits", (getter)getLimits, (setter)setLimits, "blue screen color limits", NULL},
+       {(char*)"color", (getter)getColor, (setter)setColor, (char*)"blue screen color", NULL},
+       {(char*)"limits", (getter)getLimits, (setter)setLimits, (char*)"blue screen color limits", NULL},
        // attributes from FilterBase class
-       {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL},
+       {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
        {NULL}
 };
 
 // define python type
 PyTypeObject FilterBlueScreenType =
 { 
-       PyObject_HEAD_INIT(NULL)
+#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
        "VideoTexture.FilterBlueScreen",   /*tp_name*/
        sizeof(PyFilter),          /*tp_basicsize*/
        0,                         /*tp_itemsize*/