py api cleanup, replace use...

- 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.
This commit is contained in:
Campbell Barton
2012-11-21 02:28:36 +00:00
parent 387bb73e43
commit 3fd388fb06
46 changed files with 216 additions and 196 deletions

View 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));

View 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;

View 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);