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