py api cleanup, replace use...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 21 Nov 2012 02:28:36 +0000 (02:28 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 21 Nov 2012 02:28:36 +0000 (02:28 +0000)
- PyLong_FromSsize_t --> PyLong_FromLong
- PyLong_AsSsize_t --> PyLong_AsLong

In all places except for those where python api expects PySsize_t (index lookups mainly).

- use PyBool_FromLong in a few areas of the BGE.
- fix incorrect assumption in the BGE that PySequence_Check() means PySequence_Fast_ functions can be used.

46 files changed:
source/blender/python/bmesh/bmesh_py_ops.c
source/blender/python/bmesh/bmesh_py_types_customdata.c
source/blender/python/bmesh/bmesh_py_types_meshdata.c
source/blender/python/generic/idprop_py_api.c
source/blender/python/generic/py_capi_utils.c
source/blender/python/intern/bpy_app.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/bpy_rna_array.c
source/gameengine/Expressions/IntValue.cpp
source/gameengine/Expressions/ListValue.cpp
source/gameengine/Expressions/PyObjectPlus.cpp
source/gameengine/GameLogic/SCA_IController.cpp
source/gameengine/GameLogic/SCA_ILogicBrick.cpp
source/gameengine/GameLogic/SCA_ISensor.cpp
source/gameengine/GameLogic/SCA_JoystickSensor.cpp
source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
source/gameengine/GameLogic/SCA_MouseSensor.cpp
source/gameengine/GameLogic/SCA_PythonController.cpp
source/gameengine/GameLogic/SCA_PythonController.h
source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
source/gameengine/GameLogic/SCA_PythonMouse.cpp
source/gameengine/GameLogic/SCA_RandomActuator.cpp
source/gameengine/GameLogic/SCA_RandomSensor.cpp
source/gameengine/Ketsji/BL_Shader.cpp
source/gameengine/Ketsji/KX_BlenderMaterial.cpp
source/gameengine/Ketsji/KX_Camera.cpp
source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_Light.cpp
source/gameengine/Ketsji/KX_MeshProxy.cpp
source/gameengine/Ketsji/KX_ObjectActuator.cpp
source/gameengine/Ketsji/KX_PolyProxy.cpp
source/gameengine/Ketsji/KX_PolygonMaterial.cpp
source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_PythonSeq.cpp
source/gameengine/Ketsji/KX_VehicleWrapper.cpp
source/gameengine/Ketsji/KX_VertexProxy.cpp
source/gameengine/VideoTexture/FilterBlueScreen.cpp
source/gameengine/VideoTexture/FilterColor.cpp
source/gameengine/VideoTexture/FilterNormal.cpp
source/gameengine/VideoTexture/ImageRender.cpp
source/gameengine/VideoTexture/ImageViewport.cpp
source/gameengine/VideoTexture/ImageViewport.h
source/gameengine/VideoTexture/VideoBase.cpp
source/gameengine/VideoTexture/VideoFFmpeg.cpp

index 4457a8390e10f3cc4104fecd4b09fdabd404ae25..2b82826eb043f8e0baddd7517eada2b092b3acf6 100644 (file)
@@ -342,7 +342,7 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *
                                        item = PyBool_FromLong((BMO_SLOT_AS_BOOL(slot)));
                                        break;
                                case BMO_OP_SLOT_INT:
-                                       item = PyLong_FromSsize_t(BMO_SLOT_AS_INT(slot));
+                                       item = PyLong_FromLong(BMO_SLOT_AS_INT(slot));
                                        break;
                                case BMO_OP_SLOT_FLT:
                                        item = PyFloat_FromDouble((double)BMO_SLOT_AS_FLOAT(slot));
index 1fea12d105cebce66155422de4c6b3b5c8deccd1..14132d08fe64c81e01a069aed59fa50d7f82364b 100644 (file)
@@ -981,7 +981,7 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
                }
                case CD_PROP_INT:
                {
-                       ret = PyLong_FromSsize_t((Py_ssize_t)(*(int *)value));
+                       ret = PyLong_FromLong(*(int *)value);
                        break;
                }
                case CD_PROP_STR:
@@ -1060,7 +1060,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
                }
                case CD_PROP_INT:
                {
-                       int tmp_val = PyLong_AsSsize_t(py_value);
+                       int tmp_val = PyLong_AsLong(py_value);
                        if (UNLIKELY(tmp_val == -1 && PyErr_Occurred())) {
                                PyErr_Format(PyExc_TypeError, "expected an int, not a %.200s", Py_TYPE(py_value)->tp_name);
                                ret = -1;
index 8316d33ea385639dde86ee7afb3ec15864fb6bef..b0870578f5a1355776c052e2c67086e771661b17 100644 (file)
@@ -527,7 +527,7 @@ static PyObject *bpy_bmdeformvert_keys(BPy_BMDeformVert *self)
 
        ret = PyList_New(self->data->totweight);
        for (i = 0; i < self->data->totweight; i++, dw++) {
-               PyList_SET_ITEM(ret, i, PyLong_FromSsize_t(dw->def_nr));
+               PyList_SET_ITEM(ret, i, PyLong_FromLong(dw->def_nr));
        }
 
        return ret;
@@ -576,7 +576,7 @@ static PyObject *bpy_bmdeformvert_items(BPy_BMDeformVert *self)
        for (i = 0; i < self->data->totweight; i++, dw++) {
                item = PyTuple_New(2);
 
-               PyTuple_SET_ITEM(item, 0, PyLong_FromSsize_t(dw->def_nr));
+               PyTuple_SET_ITEM(item, 0, PyLong_FromLong(dw->def_nr));
                PyTuple_SET_ITEM(item, 1, PyFloat_FromDouble(dw->weight));
 
                PyList_SET_ITEM(ret, i, item);
index 529b2e708adcd92af2233314942897ea10a24043..53112d460988c9e7ce4ab44ae327d7a129554446 100644 (file)
@@ -249,7 +249,7 @@ static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *UNUS
 #if 0
 static PyObject *BPy_IDGroup_GetType(BPy_IDProperty *self)
 {
-       return PyLong_FromSsize_t(self->prop->type);
+       return PyLong_FromLong(self->prop->type);
 }
 #endif
 
@@ -351,7 +351,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
                prop = IDP_New(IDP_DOUBLE, &val, name);
        }
        else if (PyLong_Check(ob)) {
-               val.i = (int) PyLong_AsSsize_t(ob);
+               val.i = (int)PyLong_AsLong(ob);
                prop = IDP_New(IDP_INT, &val, name);
        }
        else if (PyUnicode_Check(ob)) {
@@ -409,7 +409,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
                                prop = IDP_New(IDP_ARRAY, &val, name);
                                for (i = 0; i < val.array.len; i++) {
                                        item = PySequence_Fast_GET_ITEM(ob_seq_fast, i);
-                                       ((int *)IDP_Array(prop))[i] = (int)PyLong_AsSsize_t(item);
+                                       ((int *)IDP_Array(prop))[i] = (int)PyLong_AsLong(item);
                                }
                                break;
                        case IDP_IDPARRAY:
@@ -1072,7 +1072,7 @@ static int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *value)
                        ((double *)IDP_Array(self->prop))[index] = d;
                        break;
                case IDP_INT:
-                       i = PyLong_AsSsize_t(value);
+                       i = PyLong_AsLong(value);
                        if (i == -1 && PyErr_Occurred()) {
                                PyErr_SetString(PyExc_TypeError, "expected an int type");
                                return -1;
index b8537a1359f3fce8c81f272a87ae2b8c51ea95b4..f62fdaf09db4af768c205a7b5f23778f9fa859a7 100644 (file)
@@ -83,13 +83,13 @@ int PyC_AsArray(void *array, PyObject *value, const Py_ssize_t length,
                /* could use is_double for 'long int' but no use now */
                int *array_int = array;
                for (i = 0; i < length; i++) {
-                       array_int[i] = PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value_fast, i));
+                       array_int[i] = PyLong_AsLong(PySequence_Fast_GET_ITEM(value_fast, i));
                }
        }
        else if (type == &PyBool_Type) {
                int *array_bool = array;
                for (i = 0; i < length; i++) {
-                       array_bool[i] = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value_fast, i)) != 0);
+                       array_bool[i] = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value_fast, i)) != 0);
                }
        }
        else {
@@ -567,7 +567,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
                        ret = PyObject_CallFunction(calcsize, (char *)"s", format);
 
                        if (ret) {
-                               sizes[i] = PyLong_AsSsize_t(ret);
+                               sizes[i] = PyLong_AsLong(ret);
                                Py_DECREF(ret);
                                ret = PyObject_CallFunction(unpack, (char *)"sy#", format, (char *)ptr, sizes[i]);
                        }
index a8aa7269b724ba98e161ff797fd168f4152af50a..b1eeff8b3ae61ec1462246a2204b70a08efa71ef 100644 (file)
@@ -195,12 +195,12 @@ PyDoc_STRVAR(bpy_app_debug_value_doc,
 );
 static PyObject *bpy_app_debug_value_get(PyObject *UNUSED(self), void *UNUSED(closure))
 {
-       return PyLong_FromSsize_t(G.debug_value);
+       return PyLong_FromLong(G.debug_value);
 }
 
 static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void *UNUSED(closure))
 {
-       int param = PyLong_AsSsize_t(value);
+       int param = PyLong_AsLong(value);
 
        if (param == -1 && PyErr_Occurred()) {
                PyErr_SetString(PyExc_TypeError, "bpy.app.debug_value can only be set to a whole number");
index eaaced416fe46e2125e2d649fe24a4cb67b06547..0a889ce77780ed96abf93811fc8a9b0baa3657cd 100644 (file)
@@ -1344,7 +1344,7 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
                        ret = PyBool_FromLong(RNA_property_boolean_get(ptr, prop));
                        break;
                case PROP_INT:
-                       ret = PyLong_FromSsize_t((Py_ssize_t)RNA_property_int_get(ptr, prop));
+                       ret = PyLong_FromLong(RNA_property_int_get(ptr, prop));
                        break;
                case PROP_FLOAT:
                        ret = PyFloat_FromDouble(RNA_property_float_get(ptr, prop));
@@ -2371,7 +2371,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
 
                                RNA_property_int_get_array(ptr, prop, values);
                                for (count = start; count < stop; count++)
-                                       PyTuple_SET_ITEM(tuple, count - start, PyLong_FromSsize_t(values[count]));
+                                       PyTuple_SET_ITEM(tuple, count - start, PyLong_FromLong(values[count]));
 
                                if (values != values_stack) {
                                        PyMem_FREE(values);
@@ -4077,7 +4077,7 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self)
                        }
                        else {
                                /* a bit strange but better then returning an empty list */
-                               PyTuple_SET_ITEM(item, 0, PyLong_FromSsize_t(i));
+                               PyTuple_SET_ITEM(item, 0, PyLong_FromLong(i));
                        }
                        PyTuple_SET_ITEM(item, 1, pyrna_struct_CreatePyObject(&itemptr));
 
@@ -4256,7 +4256,7 @@ static PyObject *pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key
        }
        RNA_PROP_END;
 
-       return PyLong_FromSsize_t(index);
+       return PyLong_FromLong(index);
 }
 
 static void foreach_attr_type(BPy_PropertyRNA *self, const char *attr,
@@ -4463,13 +4463,13 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
 
                                switch (raw_type) {
                                        case PROP_RAW_CHAR:
-                                               item = PyLong_FromSsize_t((Py_ssize_t) ((char *)array)[i]);
+                                               item = PyLong_FromLong((long) ((char *)array)[i]);
                                                break;
                                        case PROP_RAW_SHORT:
-                                               item = PyLong_FromSsize_t((Py_ssize_t) ((short *)array)[i]);
+                                               item = PyLong_FromLong((long) ((short *)array)[i]);
                                                break;
                                        case PROP_RAW_INT:
-                                               item = PyLong_FromSsize_t((Py_ssize_t) ((int *)array)[i]);
+                                               item = PyLong_FromLong((long) ((int *)array)[i]);
                                                break;
                                        case PROP_RAW_FLOAT:
                                                item = PyFloat_FromDouble((double) ((float *)array)[i]);
@@ -4756,7 +4756,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
                        case PROP_INT:
                                ret = PyTuple_New(len);
                                for (a = 0; a < len; a++)
-                                       PyTuple_SET_ITEM(ret, a, PyLong_FromSsize_t((Py_ssize_t)((int *)data)[a]));
+                                       PyTuple_SET_ITEM(ret, a, PyLong_FromLong(((int *)data)[a]));
                                break;
                        case PROP_FLOAT:
                                switch (RNA_property_subtype(prop)) {
@@ -4797,7 +4797,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
                                ret = PyBool_FromLong(*(int *)data);
                                break;
                        case PROP_INT:
-                               ret = PyLong_FromSsize_t((Py_ssize_t)*(int *)data);
+                               ret = PyLong_FromLong(*(int *)data);
                                break;
                        case PROP_FLOAT:
                                ret = PyFloat_FromDouble(*(float *)data);
index e66d8f05309242897c3b610214e49e16410febcf..62c0ced9eab92d6b1e311678b9d0a7506e26ae1d 100644 (file)
@@ -507,7 +507,7 @@ static void py_to_float(PyObject *py, char *data)
 
 static void py_to_int(PyObject *py, char *data)
 {
-       *(int *)data = (int)PyLong_AsSsize_t(py);
+       *(int *)data = (int)PyLong_AsLong(py);
 }
 
 static void py_to_bool(PyObject *py, char *data)
@@ -609,7 +609,7 @@ PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index)
                        item = PyBool_FromLong(RNA_property_boolean_get_index(ptr, prop, index));
                        break;
                case PROP_INT:
-                       item = PyLong_FromSsize_t(RNA_property_int_get_index(ptr, prop, index));
+                       item = PyLong_FromLong(RNA_property_int_get_index(ptr, prop, index));
                        break;
                default:
                        PyErr_SetString(PyExc_TypeError, "not an array type");
@@ -766,7 +766,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
                case PROP_BOOLEAN:
                case PROP_INT:
                {
-                       int value_i = PyLong_AsSsize_t(value);
+                       int value_i = PyLong_AsLong(value);
                        if (value_i == -1 && PyErr_Occurred()) {
                                PyErr_Clear();
                                return 0;
index 0261a4a2d02d72ff61606adc26da4a63211ea0aa..2cacea984674b68a4b4ac088bab38a1ede751508 100644 (file)
@@ -323,9 +323,6 @@ void CIntValue::SetValue(CValue* newval)
 #ifdef WITH_PYTHON
 PyObject *CIntValue::ConvertValueToPython()
 {
-       if ((m_int > INT_MIN) && (m_int < INT_MAX))
-               return PyLong_FromSsize_t(m_int);
-       else
-               return PyLong_FromLongLong(m_int);
+       return PyLong_FromLongLong(m_int);
 }
 #endif // WITH_PYTHON
index 8cff5a01c0eeedfad403c82d1c4b9ac1bf3c801f..5f97b03fed43f2c9b779330b7e50d13deba74802 100644 (file)
@@ -365,7 +365,7 @@ static PyObject *listvalue_mapping_subscript(PyObject *self, PyObject *key)
                }
        }
        else if (PyIndex_Check(key)) {
-               int index = PyLong_AsSsize_t(key);
+               Py_ssize_t index = PyLong_AsSsize_t(key);
                return listvalue_buffer_item(self, index); /* wont add a ref */
        }
        else if (PySlice_Check(key)) {
@@ -602,10 +602,10 @@ PyObject *CListValue::Pyindex(PyObject *value)
        int numelem = GetCount();
        for (int i=0;i<numelem;i++)
        {
-               CValue* elem =                  GetValue(i);
+               CValue* elem = GetValue(i);
                if (checkobj==elem || CheckEqual(checkobj,elem))
                {
-                       result = PyLong_FromSsize_t(i);
+                       result = PyLong_FromLong(i);
                        break;
                }
        }
@@ -628,7 +628,7 @@ PyObject *CListValue::Pycount(PyObject *value)
 
        if (checkobj==NULL) { /* in this case just return that there are no items in the list */
                PyErr_Clear();
-               return PyLong_FromSsize_t(0);
+               return PyLong_FromLong(0);
        }
 
        int numelem = GetCount();
@@ -642,7 +642,7 @@ PyObject *CListValue::Pycount(PyObject *value)
        }
        checkobj->Release();
 
-       return PyLong_FromSsize_t(numfound);
+       return PyLong_FromLong(numfound);
 }
 
 /* Matches python dict.get(key, [default]) */
index 77c76ca8153288a438e66f0a7c46fa5153097714..11b00b7bbf56df19ae35cc0ae289ac7eae34bcb4 100644 (file)
@@ -311,14 +311,14 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef *
                                {
                                        bool *val = reinterpret_cast<bool*>(ptr);
                                        ptr += sizeof(bool);
-                                       PyList_SET_ITEM(resultlist,i,PyLong_FromSsize_t(*val));
+                                       PyList_SET_ITEM(resultlist,i,PyBool_FromLong(*val));
                                        break;
                                }
                        case KX_PYATTRIBUTE_TYPE_SHORT:
                                {
                                        short int *val = reinterpret_cast<short int*>(ptr);
                                        ptr += sizeof(short int);
-                                       PyList_SET_ITEM(resultlist,i,PyLong_FromSsize_t(*val));
+                                       PyList_SET_ITEM(resultlist,i,PyLong_FromLong(*val));
                                        break;
                                }
                        case KX_PYATTRIBUTE_TYPE_ENUM:
@@ -333,7 +333,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef *
                                {
                                        int *val = reinterpret_cast<int*>(ptr);
                                        ptr += sizeof(int);
-                                       PyList_SET_ITEM(resultlist,i,PyLong_FromSsize_t(*val));
+                                       PyList_SET_ITEM(resultlist,i,PyLong_FromLong(*val));
                                        break;
                                }
                        case KX_PYATTRIBUTE_TYPE_FLOAT:
@@ -381,17 +381,17 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef *
                                }
                                if (attrdef->m_imax)
                                        bval = !bval;
-                               return PyLong_FromSsize_t(bval);
+                               return PyBool_FromLong(bval);
                        }
                case KX_PYATTRIBUTE_TYPE_BOOL:
                        {
                                bool *val = reinterpret_cast<bool*>(ptr);
-                               return PyLong_FromSsize_t(*val);
+                               return PyBool_FromLong(*val);
                        }
                case KX_PYATTRIBUTE_TYPE_SHORT:
                        {
                                short int *val = reinterpret_cast<short int*>(ptr);
-                               return PyLong_FromSsize_t(*val);
+                               return PyLong_FromLong(*val);
                        }
                case KX_PYATTRIBUTE_TYPE_ENUM:
                        // enum are like int, just make sure the field size is the same
@@ -403,7 +403,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef *
                case KX_PYATTRIBUTE_TYPE_INT:
                        {
                                int *val = reinterpret_cast<int*>(ptr);
-                               return PyLong_FromSsize_t(*val);
+                               return PyLong_FromLong(*val);
                        }
                case KX_PYATTRIBUTE_TYPE_FLOAT:
                        {
@@ -583,7 +583,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
                                        ptr += sizeof(bool);
                                        if (PyLong_Check(item)) 
                                        {
-                                               *var = (PyLong_AsSsize_t(item) != 0);
+                                               *var = (PyLong_AsLong(item) != 0);
                                        } 
                                        else if (PyBool_Check(item))
                                        {
@@ -602,7 +602,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
                                        ptr += sizeof(short int);
                                        if (PyLong_Check(item)) 
                                        {
-                                               long val = PyLong_AsSsize_t(item);
+                                               int val = PyLong_AsLong(item);
                                                if (attrdef->m_clamp)
                                                {
                                                        if (val < attrdef->m_imin)
@@ -638,7 +638,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
                                        ptr += sizeof(int);
                                        if (PyLong_Check(item)) 
                                        {
-                                               long val = PyLong_AsSsize_t(item);
+                                               int val = PyLong_AsLong(item);
                                                if (attrdef->m_clamp)
                                                {
                                                        if (val < attrdef->m_imin)
@@ -786,7 +786,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
                                bool *var = reinterpret_cast<bool*>(ptr);
                                if (PyLong_Check(value)) 
                                {
-                                       *var = (PyLong_AsSsize_t(value) != 0);
+                                       *var = (PyLong_AsLong(value) != 0);
                                } 
                                else if (PyBool_Check(value))
                                {
@@ -804,7 +804,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
                                bool bval;
                                if (PyLong_Check(value)) 
                                {
-                                       bval = (PyLong_AsSsize_t(value) != 0);
+                                       bval = (PyLong_AsLong(value) != 0);
                                } 
                                else if (PyBool_Check(value))
                                {
@@ -847,7 +847,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
                                short int *var = reinterpret_cast<short int*>(ptr);
                                if (PyLong_Check(value)) 
                                {
-                                       long val = PyLong_AsSsize_t(value);
+                                       int val = PyLong_AsLong(value);
                                        if (attrdef->m_clamp)
                                        {
                                                if (val < attrdef->m_imin)
@@ -882,7 +882,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
                                int *var = reinterpret_cast<int*>(ptr);
                                if (PyLong_Check(value)) 
                                {
-                                       long val = PyLong_AsSsize_t(value);
+                                       int val = PyLong_AsLong(value);
                                        if (attrdef->m_clamp)
                                        {
                                                if (val < attrdef->m_imin)
index 57f7dd64287a0f9ade3da67548cfe97b62dd5de1..f922e617367af3ee1ad77caee5b2297fa8578ac2 100644 (file)
@@ -241,7 +241,7 @@ PyAttributeDef SCA_IController::Attributes[] = {
 PyObject *SCA_IController::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_IController* self = static_cast<SCA_IController*>(self_v);
-       return PyLong_FromSsize_t(self->m_statemask);
+       return PyLong_FromLong(self->m_statemask);
 }
 
 PyObject *SCA_IController::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
index 4916d8a0a570e8ca0cb23aeff9597588c26cff37..34fa1c98a73106439a14f1a3ec81184a2580d11c 100644 (file)
@@ -256,7 +256,7 @@ bool SCA_ILogicBrick::PyArgToBool(int boolArg)
 
 PyObject *SCA_ILogicBrick::BoolToPyArg(bool boolarg)
 {
-       return PyLong_FromSsize_t(boolarg? KX_TRUE: KX_FALSE);
+       return PyLong_FromLong(boolarg ? KX_TRUE: KX_FALSE);
 }
 
 #endif // WITH_PYTHON
index bfb78abef0432610b89dc31f8baf9f94a349410a..1cb17af83251f98b49f19113322747eba54b3ec5 100644 (file)
@@ -383,16 +383,16 @@ PyAttributeDef SCA_ISensor::Attributes[] = {
 PyObject *SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v);
-       int retval = 0;
+       bool retval = false;
        if (SCA_PythonController::m_sCurrentController)
                retval = SCA_PythonController::m_sCurrentController->IsTriggered(self);
-       return PyLong_FromSsize_t(retval);
+       return PyBool_FromLong(retval);
 }
 
 PyObject *SCA_ISensor::pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v);
-       return PyLong_FromSsize_t(self->GetState());
+       return PyBool_FromLong(self->GetState());
 }
 
 PyObject *SCA_ISensor::pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -414,7 +414,7 @@ PyObject *SCA_ISensor::pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF
        {
                status = 3;
        }
-       return PyLong_FromSsize_t(status);
+       return PyLong_FromLong(status);
 }
 
 PyObject *SCA_ISensor::pyattr_get_posTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
index 0c4dcae16f79da260e85e1f042d70a24953f9d17..c7e31f75306ba5780e4f61df1a7d28c1c9bf3a24 100644 (file)
@@ -319,7 +319,7 @@ PyObject *SCA_JoystickSensor::PyGetButtonActiveList( )
        if (joy) {
                for (i=0; i < joy->GetNumberOfButtons(); i++) {
                        if (joy->aButtonPressIsPositive(i)) {
-                               value = PyLong_FromSsize_t(i);
+                               value = PyLong_FromLong(i);
                                PyList_Append(ls, value);
                                Py_DECREF(value);
                        }
@@ -355,7 +355,7 @@ PyObject *SCA_JoystickSensor::pyattr_get_axis_values(void *self_v, const KX_PYAT
        PyObject *list= PyList_New(axis_index);
        
        while (axis_index--) {
-               PyList_SET_ITEM(list, axis_index, PyLong_FromSsize_t(joy->GetAxisPosition(axis_index)));
+               PyList_SET_ITEM(list, axis_index, PyLong_FromLong(joy->GetAxisPosition(axis_index)));
        }
        
        return list;
@@ -371,7 +371,7 @@ PyObject *SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYAT
                return NULL;
        }
        
-       return PyLong_FromSsize_t(joy->GetAxisPosition(self->m_axis-1));
+       return PyLong_FromLong(joy->GetAxisPosition(self->m_axis-1));
 }
 
 PyObject *SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -383,7 +383,7 @@ PyObject *SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATT
        PyObject *list= PyList_New(hat_index);
        
        while (hat_index--) {
-               PyList_SET_ITEM(list, hat_index, PyLong_FromSsize_t(joy->GetHat(hat_index)));
+               PyList_SET_ITEM(list, hat_index, PyLong_FromLong(joy->GetHat(hat_index)));
        }
        
        return list;
@@ -394,28 +394,28 @@ PyObject *SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATT
        SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
        SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
        
-       return PyLong_FromSsize_t(joy->GetHat(self->m_hat-1));
+       return PyLong_FromLong(joy->GetHat(self->m_hat-1));
 }
 
 PyObject *SCA_JoystickSensor::pyattr_get_num_axis(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
        SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
-       return PyLong_FromSsize_t( joy ? joy->GetNumberOfAxes() : 0 );
+       return PyLong_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
 }
 
 PyObject *SCA_JoystickSensor::pyattr_get_num_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
        SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
-       return PyLong_FromSsize_t( joy ? joy->GetNumberOfButtons() : 0 );
+       return PyLong_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
 }
 
 PyObject *SCA_JoystickSensor::pyattr_get_num_hats(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
        SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
-       return PyLong_FromSsize_t( joy ? joy->GetNumberOfHats() : 0 );
+       return PyLong_FromLong( joy ? joy->GetNumberOfHats() : 0 );
 }
 
 PyObject *SCA_JoystickSensor::pyattr_get_connected(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
index b3346270b61571b849d7b05501e49d1d83c2e1e3..7005ea1ba5b21161242f3ceef500567f934ca2c3 100644 (file)
@@ -439,17 +439,18 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
                return NULL;
        }
        
-       int keycode = PyLong_AsSsize_t(value);
+       SCA_IInputDevice::KX_EnumInputs keycode = (SCA_IInputDevice::KX_EnumInputs)PyLong_AsLong(value);
        
-       if ((keycode < SCA_IInputDevice::KX_BEGINKEY)
-               || (keycode > SCA_IInputDevice::KX_ENDKEY)) {
+       if ((keycode < SCA_IInputDevice::KX_BEGINKEY) ||
+           (keycode > SCA_IInputDevice::KX_ENDKEY))
+       {
                PyErr_SetString(PyExc_AttributeError, "sensor.getKeyStatus(int): Keyboard Sensor, invalid keycode specified!");
                return NULL;
        }
        
        SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
-       const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) keycode);
-       return PyLong_FromSsize_t(inevent.m_status);
+       const SCA_InputEvent & inevent = inputdev->GetEventValue(keycode);
+       return PyLong_FromLong(inevent.m_status);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -509,8 +510,8 @@ PyObject *SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBU
                if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
                {
                        PyObject *keypair = PyList_New(2);
-                       PyList_SET_ITEM(keypair,0,PyLong_FromSsize_t(i));
-                       PyList_SET_ITEM(keypair,1,PyLong_FromSsize_t(inevent.m_status));
+                       PyList_SET_ITEM(keypair,0,PyLong_FromLong(i));
+                       PyList_SET_ITEM(keypair,1,PyLong_FromLong(inevent.m_status));
                        PyList_Append(resultlist,keypair);
                }
        }
index 51e0bc6550b902f76a1f950892a38840f6008ff4..a7cf4963f04dc61ff1a9ab93d1267b5684490695 100644 (file)
@@ -250,17 +250,18 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
 {
        if (PyLong_Check(value))
        {
-               int button = PyLong_AsSsize_t(value);
+               SCA_IInputDevice::KX_EnumInputs button = (SCA_IInputDevice::KX_EnumInputs)PyLong_AsLong(value);
                
-               if ((button < SCA_IInputDevice::KX_LEFTMOUSE)
-                       || (button > SCA_IInputDevice::KX_RIGHTMOUSE)) {
+               if ((button < SCA_IInputDevice::KX_LEFTMOUSE) ||
+                   (button > SCA_IInputDevice::KX_RIGHTMOUSE))
+               {
                        PyErr_SetString(PyExc_ValueError, "sensor.getButtonStatus(int): Mouse Sensor, invalid button specified!");
                        return NULL;
                }
                
                SCA_IInputDevice* mousedev = ((SCA_MouseManager *)m_eventmgr)->GetInputDevice();
-               const SCA_InputEvent& event = mousedev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) button);
-               return PyLong_FromSsize_t(event.m_status);
+               const SCA_InputEvent& event = mousedev->GetEventValue(button);
+               return PyLong_FromLong(event.m_status);
        }
        
        Py_RETURN_NONE;
index ece9d7b6c8f39b4680710e2ca2d2e15e54e22fa7..c2b1470ae7ae21ad0391a84d6df5c3e7542d3517 100644 (file)
@@ -168,12 +168,16 @@ void SCA_PythonController::SetNamespace(PyObject* pythondictionary)
 }
 #endif
 
-int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor)
+bool SCA_PythonController::IsTriggered(class SCA_ISensor* sensor)
 {
        if (std::find(m_triggeredSensors.begin(), m_triggeredSensors.end(), sensor) != 
                m_triggeredSensors.end())
-               return 1;
-       return 0;
+       {
+               return true;
+       }
+       else {
+               return false;
+       }
 }
 
 #ifdef WITH_PYTHON
index f1f10d227111548f2b626b28ffeca86dd1613b40..d2549318c2eec1b430d2a034a4fb783e34c59571 100644 (file)
@@ -90,7 +90,7 @@ class SCA_PythonController : public SCA_IController
        void    SetDebug(bool debug) { m_debug = debug; }
        void    AddTriggeredSensor(class SCA_ISensor* sensor)
                { m_triggeredSensors.push_back(sensor); }
-       int             IsTriggered(class SCA_ISensor* sensor);
+       bool    IsTriggered(class SCA_ISensor* sensor);
        bool    Compile();
        bool    Import();
        void    ErrorPrint(const char *error_msg);
index 42cda9433b809dbfae4e2a97f0928d5396b0632f..19aae46f2a33dc07e6404c4a215dfc1f266020b8 100644 (file)
@@ -117,7 +117,7 @@ PyObject *SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBU
        {
                const SCA_InputEvent & inevent = self->m_keyboard->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
                
-               PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status));
+               PyDict_SetItem(self->m_event_dict, PyLong_FromLong(i), PyLong_FromLong(inevent.m_status));
        }
        Py_INCREF(self->m_event_dict);
        return self->m_event_dict;
@@ -134,7 +134,7 @@ PyObject *SCA_PythonKeyboard::pyattr_get_active_events(void *self_v, const KX_PY
                const SCA_InputEvent & inevent = self->m_keyboard->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
                
                if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
-                       PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status));
+                       PyDict_SetItem(self->m_event_dict, PyLong_FromLong(i), PyLong_FromLong(inevent.m_status));
        }
        Py_INCREF(self->m_event_dict);
        return self->m_event_dict;
index 0806bda072b486753dd09174ac626c8ec1c67764..1617f714113bdba5a8577535cba14f4176b18e7f 100644 (file)
@@ -100,7 +100,7 @@ PyObject *SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_
        {
                const SCA_InputEvent & inevent = self->m_mouse->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
                
-               PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status));
+               PyDict_SetItem(self->m_event_dict, PyLong_FromLong(i), PyLong_FromLong(inevent.m_status));
        }
        Py_INCREF(self->m_event_dict);
        return self->m_event_dict;
@@ -117,7 +117,7 @@ PyObject *SCA_PythonMouse::pyattr_get_active_events(void *self_v, const KX_PYATT
                const SCA_InputEvent & inevent = self->m_mouse->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
                
                if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
-                       PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status));
+                       PyDict_SetItem(self->m_event_dict, PyLong_FromLong(i), PyLong_FromLong(inevent.m_status));
        }
        Py_INCREF(self->m_event_dict);
        return self->m_event_dict;
index 01995b13ad722cfe84ae69d0b3e4929669b708fd..5568072abcffa82027558d4cc0c7ef0408c9aaf6 100644 (file)
@@ -363,17 +363,17 @@ PyAttributeDef SCA_RandomActuator::Attributes[] = {
 PyObject *SCA_RandomActuator::pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_RandomActuator* act = static_cast<SCA_RandomActuator*>(self);
-       return PyLong_FromSsize_t(act->m_base->GetSeed());
+       return PyLong_FromLong(act->m_base->GetSeed());
 }
 
 int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
 {
        SCA_RandomActuator* act = static_cast<SCA_RandomActuator*>(self);
-       if (PyLong_Check(value))        {
-               int ival = PyLong_AsSsize_t(value);
-               act->m_base->SetSeed(ival);
+       if (PyLong_Check(value)) {
+               act->m_base->SetSeed(PyLong_AsLong(value));
                return PY_SET_ATTR_SUCCESS;
-       } else {
+       }
+       else {
                PyErr_SetString(PyExc_TypeError, "actuator.seed = int: Random Actuator, expected an integer");
                return PY_SET_ATTR_FAIL;
        }
index 7199ee6cf22fc781d0e3cc3bc79ac67a61e06a02..4e93556453a3e4e3b64f7364da028cf56323990f 100644 (file)
@@ -168,7 +168,7 @@ PyAttributeDef SCA_RandomSensor::Attributes[] = {
 PyObject *SCA_RandomSensor::pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_RandomSensor* self = static_cast<SCA_RandomSensor*>(self_v);
-       return PyLong_FromSsize_t(self->m_basegenerator->GetSeed());
+       return PyLong_FromLong(self->m_basegenerator->GetSeed());
 }
 
 int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -178,7 +178,7 @@ int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *at
                PyErr_SetString(PyExc_TypeError, "sensor.seed = int: Random Sensor, expected an integer");
                return PY_SET_ATTR_FAIL;
        }
-       self->m_basegenerator->SetSeed(PyLong_AsSsize_t(value));
+       self->m_basegenerator->SetSeed(PyLong_AsLong(value));
        return PY_SET_ATTR_SUCCESS;
 }
 
index b047588df5ae7c4f9383647ed89bcb25e578fb22..4a74024b5bbd5f7c4c941297ebad0de3b0565c00 100644 (file)
@@ -849,7 +849,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, delSource, "delSource( )" )
 
 KX_PYMETHODDEF_DOC( BL_Shader, isValid, "isValid()" )
 {
-       return PyLong_FromSsize_t( ( mShader !=0 &&  mOk ) );
+       return PyBool_FromLong(( mShader !=0 &&  mOk ));
 }
 
 KX_PYMETHODDEF_DOC( BL_Shader, getVertexProg, "getVertexProg( )" )
@@ -1224,7 +1224,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( uniform_name, (list2
        for (unsigned int i=0; (i<list_size && i<4); i++)
        {
                PyObject *item = PySequence_GetItem(listPtr, i);
-               array_data[i] = PyLong_AsSsize_t(item);
+               array_data[i] = PyLong_AsLong(item);
                Py_DECREF(item);
        }
        
index 88e26fd9a551e5004b5375ba5708838dc7f71073..20c36c2cc44dc7a660611de04ad16610b8486870 100644 (file)
@@ -849,7 +849,7 @@ PyObject *KX_BlenderMaterial::pyattr_get_shader(void *self_v, const KX_PYATTRIBU
 PyObject *KX_BlenderMaterial::pyattr_get_materialIndex(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        KX_BlenderMaterial* self = static_cast<KX_BlenderMaterial*>(self_v);
-       return PyLong_FromSsize_t(self->GetMaterialIndex());
+       return PyLong_FromLong(self->GetMaterialIndex());
 }
 
 PyObject *KX_BlenderMaterial::pyattr_get_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -931,7 +931,7 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
 
 KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()")
 {
-       return PyLong_FromSsize_t( GetMaterialIndex() );
+       return PyLong_FromLong(GetMaterialIndex());
 }
 
 KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getTexture, "getTexture( index )" )
index 39b0a24865e8690bfe61ed3ec909124a587d870a..e56dbfdcac82c63185660ecd428cb26a6229fcf1 100644 (file)
@@ -593,7 +593,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum,
                MT_Point3 center;
                if (PyVecTo(pycenter, center))
                {
-                       return PyLong_FromSsize_t(SphereInsideFrustum(center, radius)); /* new ref */
+                       return PyLong_FromLong(SphereInsideFrustum(center, radius)); /* new ref */
                }
        }
 
@@ -644,7 +644,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, boxInsideFrustum,
                        return NULL;
        }
        
-       return PyLong_FromSsize_t(BoxInsideFrustum(box)); /* new ref */
+       return PyLong_FromLong(BoxInsideFrustum(box)); /* new ref */
 }
 
 KX_PYMETHODDEF_DOC_O(KX_Camera, pointInsideFrustum,
@@ -666,7 +666,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, pointInsideFrustum,
        MT_Point3 point;
        if (PyVecTo(value, point))
        {
-               return PyLong_FromSsize_t(PointInsideFrustum(point)); /* new ref */
+               return PyLong_FromLong(PointInsideFrustum(point)); /* new ref */
        }
        
        PyErr_SetString(PyExc_TypeError, "camera.pointInsideFrustum(point): KX_Camera, expected point argument.");
@@ -869,11 +869,11 @@ PyObject *KX_Camera::pyattr_get_world_to_camera(void *self_v, const KX_PYATTRIBU
 
 
 PyObject *KX_Camera::pyattr_get_INSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{      return PyLong_FromSsize_t(INSIDE); }
+{      return PyLong_FromLong(INSIDE); }
 PyObject *KX_Camera::pyattr_get_OUTSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{      return PyLong_FromSsize_t(OUTSIDE); }
+{      return PyLong_FromLong(OUTSIDE); }
 PyObject *KX_Camera::pyattr_get_INTERSECT(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{      return PyLong_FromSsize_t(INTERSECT); }
+{      return PyLong_FromLong(INTERSECT); }
 
 
 bool ConvertPythonToCamera(PyObject *value, KX_Camera **object, bool py_none_ok, const char *error_prefix)
index 662db974ee856ea82802be881bcd823c30541e65..e09449c4f1d4237016fd94c8ef2c82a7419c11a5 100644 (file)
@@ -52,7 +52,7 @@ KX_ConstraintWrapper::~KX_ConstraintWrapper()
 
 PyObject *KX_ConstraintWrapper::PyGetConstraintId()
 {
-       return PyLong_FromSsize_t(m_constraintId);
+       return PyLong_FromLong(m_constraintId);
 }
 
 
index cfccb8e8ced1b62fa80c8719f2c90b196b362da1..c7f6954fd6cc014d32496ee0c95867f7043ce8c7 100644 (file)
@@ -2475,13 +2475,13 @@ PyObject *KX_GameObject::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF
        KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
        int state = 0;
        state |= self->GetState();
-       return PyLong_FromSsize_t(state);
+       return PyLong_FromLong(state);
 }
 
 int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
 {
        KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-       int state_i = PyLong_AsSsize_t(value);
+       int state_i = PyLong_AsLong(value);
        unsigned int state = 0;
        
        if (state_i == -1 && PyErr_Occurred()) {
@@ -2897,7 +2897,7 @@ PyObject *KX_GameObject::PyGetPhysicsId()
        {
                physid= (uint_ptr)ctrl->GetUserData();
        }
-       return PyLong_FromSsize_t((long)physid);
+       return PyLong_FromLong((long)physid);
 }
 
 PyObject *KX_GameObject::PyGetPropertyNames()
index a4e90cb1e83832c96b2cb94316c5d6c8d8f54114..cf58d18838ae7ec0ab7d3b8993bddebc8b25ac3a 100644 (file)
@@ -372,11 +372,11 @@ PyObject *KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUT
        const char* type = attrdef->m_name;
 
        if (!strcmp(type, "SPOT")) {
-               retvalue = PyLong_FromSsize_t(RAS_LightObject::LIGHT_SPOT);
+               retvalue = PyLong_FromLong(RAS_LightObject::LIGHT_SPOT);
        } else if (!strcmp(type, "SUN")) {
-               retvalue = PyLong_FromSsize_t(RAS_LightObject::LIGHT_SUN);
+               retvalue = PyLong_FromLong(RAS_LightObject::LIGHT_SUN);
        } else if (!strcmp(type, "NORMAL")) {
-               retvalue = PyLong_FromSsize_t(RAS_LightObject::LIGHT_NORMAL);
+               retvalue = PyLong_FromLong(RAS_LightObject::LIGHT_NORMAL);
        }
        else {
                /* should never happen */
@@ -390,13 +390,13 @@ PyObject *KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUT
 PyObject *KX_LightObject::pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
-       return PyLong_FromSsize_t(self->m_lightobj.m_type);
+       return PyLong_FromLong(self->m_lightobj.m_type);
 }
 
 int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
 {
        KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
-       int val = PyLong_AsSsize_t(value);
+       const int val = PyLong_AsLong(value);
        if ((val==-1 && PyErr_Occurred()) || val<0 || val>2) {
                PyErr_SetString(PyExc_ValueError, "light.type= val: KX_LightObject, expected an int between 0 and 2");
                return PY_SET_ATTR_FAIL;
index dbbf6bd8c2a28b2180d8ca1140d36d2758f55337..d83e98d4712a78d881151e2bc4e1630f735e1739 100644 (file)
@@ -172,7 +172,7 @@ PyObject *KX_MeshProxy::PyGetVertexArrayLength(PyObject *args, PyObject *kwds)
                        length = m_meshobj->NumVertices(mat);
        }
        
-       return PyLong_FromSsize_t(length);
+       return PyLong_FromLong(length);
 }
 
 
@@ -406,13 +406,13 @@ PyObject *KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_
 PyObject * KX_MeshProxy::pyattr_get_numMaterials(void * selfv, const KX_PYATTRIBUTE_DEF * attrdef)
 {
        KX_MeshProxy * self = static_cast<KX_MeshProxy *> (selfv);
-       return PyLong_FromSsize_t(self->m_meshobj->NumMaterials());
+       return PyLong_FromLong(self->m_meshobj->NumMaterials());
 }
 
 PyObject * KX_MeshProxy::pyattr_get_numPolygons(void * selfv, const KX_PYATTRIBUTE_DEF * attrdef)
 {
        KX_MeshProxy * self = static_cast<KX_MeshProxy *> (selfv);
-       return PyLong_FromSsize_t(self->m_meshobj->NumPolygons());
+       return PyLong_FromLong(self->m_meshobj->NumPolygons());
 }
 
 /* a close copy of ConvertPythonToGameObject but for meshes */
index e5f7ea22b36097a435e25b058f8cbee5473149dc..931039bc54c6e1b9c6ed9826afb7e8313d82161b 100644 (file)
@@ -529,7 +529,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE
        {
                self->m_drot[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
                self->m_dloc[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
-               self->m_bitLocalFlag.Torque = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2)) != 0);
+               self->m_bitLocalFlag.Torque = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0);
 
                if (!PyErr_Occurred())
                {
@@ -565,7 +565,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE
        {
                self->m_drot[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
                self->m_dloc[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
-               self->m_bitLocalFlag.DLoc = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2)) != 0);
+               self->m_bitLocalFlag.DLoc = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0);
 
                if (!PyErr_Occurred())
                {
@@ -601,7 +601,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE
        {
                self->m_drot[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
                self->m_dloc[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
-               self->m_bitLocalFlag.DRot = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2)) != 0);
+               self->m_bitLocalFlag.DRot = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0);
 
                if (!PyErr_Occurred())
                {
index 465e91ffb32c2d2b26a5087076204b895f1bb790..840ffdde165bbefc87ded31b787fdac34406129a 100644 (file)
@@ -140,21 +140,21 @@ PyObject *KX_PolyProxy::pyattr_get_v1(void *self_v, const KX_PYATTRIBUTE_DEF *at
 {
        KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
 
-       return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 0));
+       return PyLong_FromLong(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 0));
 }
 
 PyObject *KX_PolyProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
 
-       return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 1));
+       return PyLong_FromLong(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 1));
 }
 
 PyObject *KX_PolyProxy::pyattr_get_v3(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
 
-       return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 2));
+       return PyLong_FromLong(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 2));
 }
 
 PyObject *KX_PolyProxy::pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -163,9 +163,9 @@ PyObject *KX_PolyProxy::pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *at
 
        if (3 < self->m_polygon->VertexCount())
        {
-               return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 3));
+               return PyLong_FromLong(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 3));
        }
-       return PyLong_FromSsize_t(0);
+       return PyLong_FromLong(0);
 }
 
 PyObject *KX_PolyProxy::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -192,25 +192,25 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialIndex,
                        // found it
                        break;
        }
-       return PyLong_FromSsize_t(matid);
+       return PyLong_FromLong(matid);
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getNumVertex,
 "getNumVertex() : returns the number of vertex of the polygon, 3 or 4\n")
 {
-       return PyLong_FromSsize_t(m_polygon->VertexCount());
+       return PyLong_FromLong(m_polygon->VertexCount());
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isVisible,
 "isVisible() : returns whether the polygon is visible or not\n")
 {
-       return PyLong_FromSsize_t(m_polygon->IsVisible());
+       return PyLong_FromLong(m_polygon->IsVisible());
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isCollider,
 "isCollider() : returns whether the polygon is receives collision or not\n")
 {
-       return PyLong_FromSsize_t(m_polygon->IsCollider());
+       return PyLong_FromLong(m_polygon->IsCollider());
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialName,
@@ -243,9 +243,9 @@ KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex,
        }
        if (index < m_polygon->VertexCount())
        {
-               return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, index));
+               return PyLong_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, index));
        }
-       return PyLong_FromSsize_t(0);
+       return PyLong_FromLong(0);
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMesh,
index f89b918f31bc9e2526ce7ded0ca7ad9be334daec..b02df7be26fc261035a1014d7484921b5fedc9a5 100644 (file)
@@ -146,7 +146,7 @@ bool KX_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingI
                PyObject *ret = PyObject_CallMethod(m_pymaterial, (char *)"activate", (char *)"(NNO)", pyRasty, pyCachingInfo, (PyObject *) this->m_proxy);
                if (ret)
                {
-                       bool value = PyLong_AsSsize_t(ret);
+                       bool value = PyLong_AsLong(ret);
                        Py_DECREF(ret);
                        dopass = value;
                }
@@ -381,7 +381,7 @@ PyObject *KX_PolygonMaterial::pyattr_get_gl_texture(void *self_v, const KX_PYATT
        if (self->m_tface.tpage)
                bindcode= self->m_tface.tpage->bindcode;
        
-       return PyLong_FromSsize_t(bindcode);
+       return PyLong_FromLong(bindcode);
 }
 
 
index 4475ac8ec968b3b2a099f757c330fb6018486e39..a562b3ff682b1f7a497aae8792dc0464106d883b 100644 (file)
@@ -51,7 +51,7 @@
 #ifdef WITH_PYTHON
 
 // macro copied from KX_PythonInit.cpp
-#define KX_MACRO_addTypesToDict(dict, name, name2) PyDict_SetItemString(dict, #name, item=PyLong_FromSsize_t(name2)); Py_DECREF(item)
+#define KX_MACRO_addTypesToDict(dict, name, name2) PyDict_SetItemString(dict, #name, item=PyLong_FromLong(name2)); Py_DECREF(item)
 
 // nasty glob variable to connect scripting language
 // if there is a better way (without global), please do so!
index 7f6655861f130dc5f2e21a3f83ff753b5d00864f..5c4d1710e6fec56c1d218db30d26fbfc6f4f596c 100644 (file)
@@ -193,10 +193,10 @@ static PyObject *gp_OrigPythonSysPath= NULL;
 static PyObject *gp_OrigPythonSysModules= NULL;
 
 /* Macro for building the keyboard translation */
-//#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, PyLong_FromSsize_t(SCA_IInputDevice::KX_##name))
-#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, item=PyLong_FromSsize_t(name)); Py_DECREF(item)
+//#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, PyLong_FromLong(SCA_IInputDevice::KX_##name))
+#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, item=PyLong_FromLong(name)); Py_DECREF(item)
 /* For the defines for types from logic bricks, we do stuff explicitly... */
-#define KX_MACRO_addTypesToDict(dict, name, name2) PyDict_SetItemString(dict, #name, item=PyLong_FromSsize_t(name2)); Py_DECREF(item)
+#define KX_MACRO_addTypesToDict(dict, name, name2) PyDict_SetItemString(dict, #name, item=PyLong_FromLong(name2)); Py_DECREF(item)
 
 
 // temporarily python stuff, will be put in another place later !
@@ -429,7 +429,7 @@ static PyObject *gPySetExitKey(PyObject *, PyObject *args)
 
 static PyObject *gPyGetExitKey(PyObject *)
 {
-       return PyLong_FromSsize_t(KX_KetsjiEngine::GetExitKey());
+       return PyLong_FromLong(KX_KetsjiEngine::GetExitKey());
 }
 
 static PyObject *gPySetMaxLogicFrame(PyObject *, PyObject *args)
@@ -444,7 +444,7 @@ static PyObject *gPySetMaxLogicFrame(PyObject *, PyObject *args)
 
 static PyObject *gPyGetMaxLogicFrame(PyObject *)
 {
-       return PyLong_FromSsize_t(KX_KetsjiEngine::GetMaxLogicFrame());
+       return PyLong_FromLong(KX_KetsjiEngine::GetMaxLogicFrame());
 }
 
 static PyObject *gPySetMaxPhysicsFrame(PyObject *, PyObject *args)
@@ -459,7 +459,7 @@ static PyObject *gPySetMaxPhysicsFrame(PyObject *, PyObject *args)
 
 static PyObject *gPyGetMaxPhysicsFrame(PyObject *)
 {
-       return PyLong_FromSsize_t(KX_KetsjiEngine::GetMaxPhysicsFrame());
+       return PyLong_FromLong(KX_KetsjiEngine::GetMaxPhysicsFrame());
 }
 
 static PyObject *gPySetPhysicsTicRate(PyObject *, PyObject *args)
@@ -862,14 +862,14 @@ static struct PyMethodDef game_methods[] = {
 
 static PyObject *gPyGetWindowHeight(PyObject *, PyObject *args)
 {
-       return PyLong_FromSsize_t((gp_Canvas ? gp_Canvas->GetHeight() : 0));
+       return PyLong_FromLong((gp_Canvas ? gp_Canvas->GetHeight() : 0));
 }
 
 
 
 static PyObject *gPyGetWindowWidth(PyObject *, PyObject *args)
 {
-       return PyLong_FromSsize_t((gp_Canvas ? gp_Canvas->GetWidth() : 0));
+       return PyLong_FromLong((gp_Canvas ? gp_Canvas->GetWidth() : 0));
 }
 
 
@@ -1203,7 +1203,7 @@ static PyObject *gPyGetGLSLMaterialSetting(PyObject *,
        }
 
        enabled = ((gs->glslflag & flag) != 0);
-       return PyLong_FromSsize_t(enabled);
+       return PyLong_FromLong(enabled);
 }
 
 #define KX_TEXFACE_MATERIAL                            0
@@ -1246,7 +1246,7 @@ static PyObject *gPyGetMaterialType(PyObject *)
        else
                flag = KX_TEXFACE_MATERIAL;
        
-       return PyLong_FromSsize_t(flag);
+       return PyLong_FromLong(flag);
 }
 
 static PyObject *gPySetAnisotropicFiltering(PyObject *, PyObject *args)
index 6b4d88709e83a957588b1c1cb86203ddea90f258..f0e11645bc1983bb720e613d8d55a4c645a23d4d 100644 (file)
@@ -100,7 +100,7 @@ static Py_ssize_t KX_PythonSeq_len( PyObject *self )
        }
 }
 
-static PyObject *KX_PythonSeq_getIndex(PyObject *self, int index)
+static PyObject *KX_PythonSeq_getIndex(PyObject *self, Py_ssize_t index)
 {
        PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base);
         
@@ -273,8 +273,8 @@ static PyObject * KX_PythonSeq_subscript(PyObject *self, PyObject *key)
                return NULL;
        }
        
-       if (PyLong_Check(key)) {
-               return KX_PythonSeq_getIndex(self, PyLong_AsSsize_t( key ));
+       if (PyIndex_Check(key)) {
+               return KX_PythonSeq_getIndex(self, PyLong_AsSsize_t(key));
        }
        else if ( PyUnicode_Check(key) ) {
                const char *name = _PyUnicode_AsString(key);
index b5d6f11a2d52f25a78fd29a84c11474eb465a715..9cc91a33886499803a150e7e7de9dff0a0248ab5 100644 (file)
@@ -126,13 +126,13 @@ PyObject *KX_VehicleWrapper::PyGetWheelOrientationQuaternion(PyObject *args)
 
 PyObject *KX_VehicleWrapper::PyGetNumWheels(PyObject *args)
 {
-       return PyLong_FromSsize_t(m_vehicle->GetNumWheels());
+       return PyLong_FromLong(m_vehicle->GetNumWheels());
 }
 
 
 PyObject *KX_VehicleWrapper::PyGetConstraintId(PyObject *args)
 {
-       return PyLong_FromSsize_t(m_vehicle->GetUserConstraintId());
+       return PyLong_FromLong(m_vehicle->GetUserConstraintId());
 }
 
 
@@ -263,7 +263,7 @@ PyObject *KX_VehicleWrapper::PySetSteeringValue(PyObject *args)
 
 PyObject *KX_VehicleWrapper::PyGetConstraintType(PyObject *args)
 {
-       return PyLong_FromSsize_t(m_vehicle->GetUserConstraintType());
+       return PyLong_FromLong(m_vehicle->GetUserConstraintType());
 }
 
 
index 82e414d7c42d95fa27d752260e23a6dfca4e255d..2354359af1810e1f2c11afcfd62ea77070866390 100644 (file)
@@ -494,13 +494,13 @@ PyObject *KX_VertexProxy::PySetNormal(PyObject *value)
 PyObject *KX_VertexProxy::PyGetRGBA()
 {
        int *rgba = (int *) m_vertex->getRGBA();
-       return PyLong_FromSsize_t(*rgba);
+       return PyLong_FromLong(*rgba);
 }
 
 PyObject *KX_VertexProxy::PySetRGBA(PyObject *value)
 {
        if (PyLong_Check(value)) {
-               int rgba = PyLong_AsSsize_t(value);
+               int rgba = PyLong_AsLong(value);
                m_vertex->SetRGBA(rgba);
                m_mesh->SetMeshModified(true);
                Py_RETURN_NONE;
index 551694bf8c09205dddd19f7eaa79b62e0fd83a7c..662ecabd283514b2a3454f3f71210d49ac2f7fcc 100644 (file)
@@ -87,18 +87,21 @@ static PyObject *getColor (PyFilter *self, void *closure)
 static int setColor (PyFilter *self, PyObject *value, void *closure)
 {
        // check validity of parameter
-       if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 3
-               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
-               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))
-               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 2)))
+       if (value == NULL ||
+           !(PyTuple_Check(value) || PyList_Check(value)) ||
+           PySequence_Fast_GET_SIZE(value) != 3 ||
+           !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)(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))));
+       getFilter(self)->setColor(
+               (unsigned char)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
+               (unsigned char)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1))),
+               (unsigned char)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2))));
        // success
        return 0;
 }
@@ -114,16 +117,19 @@ static PyObject *getLimits (PyFilter *self, void *closure)
 static int setLimits (PyFilter *self, PyObject *value, void *closure)
 {
        // check validity of parameter
-       if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2
-               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
-               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
+       if (value == NULL ||
+           !(PyTuple_Check(value) || PyList_Check(value)) ||
+           PySequence_Fast_GET_SIZE(value) != 2 ||
+           !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)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))),
-               (unsigned short)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1))));
+       getFilter(self)->setLimits(
+               (unsigned short)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
+               (unsigned short)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1))));
        // success
        return 0;
 }
@@ -163,14 +169,14 @@ PyTypeObject FilterBlueScreenType =
        0,                         /*tp_as_buffer*/
        Py_TPFLAGS_DEFAULT,        /*tp_flags*/
        "Filter for Blue Screen objects",       /* tp_doc */
-       0,                             /* tp_traverse */
-       0,                             /* tp_clear */
-       0,                             /* tp_richcompare */
-       0,                             /* tp_weaklistoffset */
-       0,                             /* tp_iter */
-       0,                             /* tp_iternext */
-       NULL,                /* tp_methods */
-       0,                   /* tp_members */
+       0,                         /* tp_traverse */
+       0,                         /* tp_clear */
+       0,                         /* tp_richcompare */
+       0,                         /* tp_weaklistoffset */
+       0,                         /* tp_iter */
+       0,                         /* tp_iternext */
+       NULL,                      /* tp_methods */
+       0,                         /* tp_members */
        filterBSGetSets,           /* tp_getset */
        0,                         /* tp_base */
        0,                         /* tp_dict */
index 75803e4651695671442c631667d987cab3446441..e4101b5587d22bbddd7e492d0927f8add28b3c6f 100644 (file)
@@ -151,7 +151,7 @@ static int setMatrix (PyFilter *self, PyObject *value, void *closure)
                        valid = PyLong_Check(PySequence_Fast_GET_ITEM(row, c));
                        // if it is valid, save it in matrix
                        if (valid)
-                               mat[r][c] = short(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(row, c)));
+                               mat[r][c] = short(PyLong_AsLong(PySequence_Fast_GET_ITEM(row, c)));
                }
        }
        // if parameter is not valid, report error
@@ -284,7 +284,7 @@ static int setLevels (PyFilter *self, PyObject *value, void *closure)
                        valid = PyLong_Check(PySequence_Fast_GET_ITEM(row, c));
                        // if it is valid, save it in matrix
                        if (valid)
-                               lev[r][c] = (unsigned short)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(row, c)));
+                               lev[r][c] = (unsigned short)(PyLong_AsLong(PySequence_Fast_GET_ITEM(row, c)));
                }
        }
        // if parameter is not valid, report error
index 8499934d61b94e8adbec0aa73212c48bac618faf..ba963d9307954bc645e35cf7d405dc3eee2ec44c 100644 (file)
@@ -85,7 +85,7 @@ static int setColor (PyFilter *self, PyObject *value, void *closure)
                return -1;
        }
        // set color index
-       getFilter(self)->setColor((unsigned short)(PyLong_AsSsize_t(value)));
+       getFilter(self)->setColor((unsigned short)(PyLong_AsLong(value)));
        // success
        return 0;
 }
index b8dd4ad45528370d08ba2415bd62203493a87161..f778f84086442af2abb20c7d89503624658bf8c4 100644 (file)
@@ -360,10 +360,11 @@ static int setBackground (PyImage *self, PyObject *value, void *closure)
                return -1;
        }
        // set background color
-       getImageRender(self)->setBackground((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))),
-               (unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 3))));
+       getImageRender(self)->setBackground(
+               (unsigned char)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
+               (unsigned char)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1))),
+               (unsigned char)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2))),
+               (unsigned char)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 3))));
        // success
        return 0;
 }
index b221cb9662480df4bcb60e1e56a1db66cb22f140..5fc388bdefb6ea54e90cf8316d80d2c3380e9883 100644 (file)
@@ -89,7 +89,7 @@ void ImageViewport::setWhole (bool whole)
        setPosition();
 }
 
-void ImageViewport::setCaptureSize (short * size)
+void ImageViewport::setCaptureSize (short size[2])
 {
        m_whole = false;
        if (size == NULL) 
@@ -109,7 +109,7 @@ void ImageViewport::setCaptureSize (short * size)
 }
 
 // set position of capture rectangle
-void ImageViewport::setPosition (GLint * pos)
+void ImageViewport::setPosition (GLint pos[2])
 {
        // if new position is not provided, use existing position
        if (pos == NULL) pos = m_position;
@@ -258,25 +258,30 @@ int ImageViewport_setAlpha (PyImage *self, PyObject *value, void *closure)
 // get position
 static PyObject *ImageViewport_getPosition (PyImage *self, void *closure)
 {
-       return Py_BuildValue("(ii)", getImageViewport(self)->getPosition()[0],
-               getImageViewport(self)->getPosition()[1]);
+       GLint *pos = getImageViewport(self)->getPosition();
+       PyObject *ret = PyTuple_New(2);
+       PyTuple_SET_ITEM(ret, 0, PyLong_FromLong(pos[0]));
+       PyTuple_SET_ITEM(ret, 1, PyLong_FromLong(pos[1]));
+       return ret;
 }
 
 // set position
 static int ImageViewport_setPosition (PyImage *self, PyObject *value, void *closure)
 {
        // check validity of parameter
-       if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2
-               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
-               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
+       if (value == NULL ||
+           !(PyTuple_Check(value) || PyList_Check(value)) ||
+           PySequence_Fast_GET_SIZE(value) != 2 ||
+           !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 position
-       GLint pos [] = {
-               GLint(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))),
-                       GLint(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1)))
+       GLint pos[2] = {
+           GLint(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
+           GLint(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1)))
        };
        getImageViewport(self)->setPosition(pos);
        // success
@@ -286,25 +291,30 @@ static int ImageViewport_setPosition (PyImage *self, PyObject *value, void *clos
 // get capture size
 PyObject *ImageViewport_getCaptureSize (PyImage *self, void *closure)
 {
-       return Py_BuildValue("(ii)", getImageViewport(self)->getCaptureSize()[0],
-               getImageViewport(self)->getCaptureSize()[1]);
+       short *size = getImageViewport(self)->getCaptureSize();
+       PyObject *ret = PyTuple_New(2);
+       PyTuple_SET_ITEM(ret, 0, PyLong_FromLong(size[0]));
+       PyTuple_SET_ITEM(ret, 1, PyLong_FromLong(size[1]));
+       return ret;
 }
 
 // set capture size
 int ImageViewport_setCaptureSize (PyImage *self, PyObject *value, void *closure)
 {
        // check validity of parameter
-       if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2
-               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
-               || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
+       if (value == NULL ||
+           !(PyTuple_Check(value) || PyList_Check(value)) ||
+           PySequence_Fast_GET_SIZE(value) != 2 ||
+           !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 capture size
-       short size [] = {
-               short(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))),
-                       short(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1)))
+       short size[2] = {
+           short(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
+           short(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1)))
        };
        try
        {
index 2c2b2a26ec2f2c0a43aaa72997300237c208382d..5afd4654d62cdce2d2fe246c44c20ccc1556c36a 100644 (file)
@@ -60,12 +60,12 @@ public:
        /// get capture size in viewport
        short * getCaptureSize (void) { return m_capSize; }
        /// set capture size in viewport
-       void setCaptureSize (short * size = NULL);
+       void setCaptureSize (short size[2] = NULL);
 
        /// get position in viewport
        GLint * getPosition (void) { return m_position; }
        /// set position in viewport
-       void setPosition (GLint * pos = NULL);
+       void setPosition (GLint pos[2] = NULL);
 
 protected:
        /// frame buffer rectangle
index f723001fa5a39642f76232d4aa15542bbb739fd7..576e358fe75278f3f455d674f69c6b24996bd263 100644 (file)
@@ -184,7 +184,7 @@ int Video_setRepeat(PyImage *self, PyObject *value, void *closure)
                return -1;
        }
        // set repeat
-       getVideo(self)->setRepeat(int(PyLong_AsSsize_t(value)));
+       getVideo(self)->setRepeat(int(PyLong_AsLong(value)));
        // success
        return 0;
 }
index 937705c963e27491c6678abf82fb75611393f63e..8976a21376a0f734f4b03d8638396899632e06ff 100644 (file)
@@ -1142,7 +1142,7 @@ static int VideoFFmpeg_setPreseek(PyImage *self, PyObject *value, void *closure)
                return -1;
        }
        // set preseek
-       getFFmpeg(self)->setPreseek(PyLong_AsSsize_t(value));
+       getFFmpeg(self)->setPreseek(PyLong_AsLong(value));
        // success
        return 0;
 }