code cleanup: double promotion warnings, also allow cmake to build SDL without audaspace.

This commit is contained in:
2012-11-09 16:15:00 +00:00
parent b67a297d33
commit d25b13d13f
10 changed files with 49 additions and 51 deletions

View File

@@ -486,8 +486,8 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef *
static bool py_check_attr_float(float *var, PyObject *value, const PyAttributeDef *attrdef)
{
double val = PyFloat_AsDouble(value);
if (val == -1.0 && PyErr_Occurred())
float val = PyFloat_AsDouble(value);
if (val == -1.0f && PyErr_Occurred())
{
PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name);
return false;
@@ -664,13 +664,13 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
{
float *var = reinterpret_cast<float*>(ptr);
ptr += sizeof(float);
double val = PyFloat_AsDouble(item);
if (val == -1.0 && PyErr_Occurred())
float val = PyFloat_AsDouble(item);
if (val == -1.0f && PyErr_Occurred())
{
PyErr_Format(PyExc_TypeError, "expected a float for attribute \"%s\"", attrdef->m_name);
goto UNDO_AND_ERROR;
}
else if (attrdef->m_clamp)
else if (attrdef->m_clamp)
{
if (val < attrdef->m_fmin)
val = attrdef->m_fmin;
@@ -985,10 +985,10 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
for (int i=0; i<3; i++)
{
item = PySequence_GetItem(value, i); /* new ref */
double val = PyFloat_AsDouble(item);
float val = PyFloat_AsDouble(item);
Py_DECREF(item);
item = NULL;
if (val == -1.0 && PyErr_Occurred())
if (val == -1.0f && PyErr_Occurred())
{
PyErr_Format(PyExc_TypeError, "expected a sequence of 3 floats for attribute \"%s\"", attrdef->m_name);
goto RESTORE_AND_ERROR;