diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-03 22:23:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-03 22:23:30 +0400 |
commit | 9b948717b019fbd8e511595bd23ed1970b077085 (patch) | |
tree | 52e9203e26a4900b43bb82e699f6ca8a8a5b2cda /source/blender/python | |
parent | a18ead1521ccd14d45adc335dd1dddd89a71cc96 (diff) |
code cleanup: float <> double conversion.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/generic/idprop_py_api.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 12c2909523d..d2890bc046e 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -49,33 +49,33 @@ * static conversion functions to avoid duplicate code, no type checking. */ -static PyObject *idprop_py_from_idp_string(IDProperty *prop) +static PyObject *idprop_py_from_idp_string(const IDProperty *prop) { if (prop->subtype == IDP_STRING_SUB_BYTE) { - return PyBytes_FromStringAndSize(IDP_Array(prop), prop->len); + return PyBytes_FromStringAndSize(IDP_String(prop), prop->len); } else { #ifdef USE_STRING_COERCE return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len - 1); #else - return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len - 1); + return PyUnicode_FromStringAndSize(IDP_String(prop), prop->len - 1); #endif } } -static PyObject *idprop_py_from_idp_int(IDProperty *prop) +static PyObject *idprop_py_from_idp_int(const IDProperty *prop) { - return PyLong_FromLong((long)prop->data.val); + return PyLong_FromLong((long)IDP_Int(prop)); } -static PyObject *idprop_py_from_idp_float(IDProperty *prop) +static PyObject *idprop_py_from_idp_float(const IDProperty *prop) { - return PyFloat_FromDouble((double)(*(float *)(&prop->data.val))); + return PyFloat_FromDouble((double)IDP_Float(prop)); } -static PyObject *idprop_py_from_idp_double(IDProperty *prop) +static PyObject *idprop_py_from_idp_double(const IDProperty *prop) { - return PyFloat_FromDouble((*(double *)(&prop->data.val))); + return PyFloat_FromDouble(IDP_Double(prop)); } static PyObject *idprop_py_from_idp_group(ID *id, IDProperty *prop, IDProperty *parent) @@ -189,7 +189,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject PyErr_SetString(PyExc_TypeError, "expected an int type"); return -1; } - prop->data.val = ivalue; + IDP_Int(prop) = ivalue; break; } case IDP_FLOAT: @@ -199,7 +199,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject PyErr_SetString(PyExc_TypeError, "expected a float"); return -1; } - *(float *)&self->prop->data.val = fvalue; + IDP_Float(self->prop) = fvalue; break; } case IDP_DOUBLE: @@ -209,7 +209,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject PyErr_SetString(PyExc_TypeError, "expected a float"); return -1; } - *(double *)&self->prop->data.val = dvalue; + IDP_Double(self->prop) = dvalue; break; } default: |