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

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

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

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