Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-11-21 06:28:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-21 06:28:36 +0400
commit3fd388fb06e474a4e9e2f6816eb0a0b95ab433e7 (patch)
tree214a3ade3c842bc301aa6bedf7f3f826c873b2a6 /source/blender
parent387bb73e4343be164f167565cefebbee613cdb7b (diff)
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.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c4
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.c4
-rw-r--r--source/blender/python/generic/idprop_py_api.c8
-rw-r--r--source/blender/python/generic/py_capi_utils.c6
-rw-r--r--source/blender/python/intern/bpy_app.c4
-rw-r--r--source/blender/python/intern/bpy_rna.c18
-rw-r--r--source/blender/python/intern/bpy_rna_array.c6
8 files changed, 26 insertions, 26 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index 4457a8390e1..2b82826eb04 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -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));
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index 1fea12d105c..14132d08fe6 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -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;
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
index 8316d33ea38..b0870578f5a 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
@@ -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);
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 529b2e708ad..53112d46098 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -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;
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index b8537a1359f..f62fdaf09db 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -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]);
}
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index a8aa7269b72..b1eeff8b3ae 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -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");
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index eaaced416fe..0a889ce7778 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -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);
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index e66d8f05309..62c0ced9eab 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -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;