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:
@@ -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));
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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]);
|
||||
}
|
||||
|
@@ -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");
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user