diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-10 19:22:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-10 19:22:19 +0400 |
commit | 1c99e6aa0b79403d83325eb831e2efab6ae4e255 (patch) | |
tree | 62b8feead2e646eaa7e8533fa5979ecbc724c7c8 /source | |
parent | e56844e98b5ab2332de301c9f85efdf9c2478558 (diff) |
pyapi internal api code: check for == -1 rather then < 0, for known error returns.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/intern/bpy_app.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 12 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 8 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna_anim.c | 8 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna_callback.c | 8 |
5 files changed, 19 insertions, 19 deletions
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index bea63d2b6e8..3e2353c3571 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -182,7 +182,7 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *clos const int flag = GET_INT_FROM_POINTER(closure); const int param = PyObject_IsTrue(value); - if (param < 0) { + if (param == -1) { PyErr_SetString(PyExc_TypeError, "bpy.app.debug can only be True/False"); return -1; } diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index bd3fc95cd7e..8769700f32c 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -388,7 +388,7 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert values[i] = false; } else { - if (PyC_AsArray(values, ret, len, &PyBool_Type, false, "BoolVectorProperty get") < 0) { + if (PyC_AsArray(values, ret, len, &PyBool_Type, false, "BoolVectorProperty get") == -1) { printf_func_error(py_func); for (i = 0; i < len; ++i) @@ -622,7 +622,7 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA values[i] = 0; } else { - if (PyC_AsArray(values, ret, len, &PyLong_Type, false, "IntVectorProperty get") < 0) { + if (PyC_AsArray(values, ret, len, &PyLong_Type, false, "IntVectorProperty get") == -1) { printf_func_error(py_func); for (i = 0; i < len; ++i) @@ -856,7 +856,7 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR values[i] = 0.0f; } else { - if (PyC_AsArray(values, ret, len, &PyFloat_Type, false, "FloatVectorProperty get") < 0) { + if (PyC_AsArray(values, ret, len, &PyFloat_Type, false, "FloatVectorProperty get") == -1) { printf_func_error(py_func); for (i = 0; i < len; ++i) @@ -1941,7 +1941,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject return NULL; } - if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, false, "BoolVectorProperty(default=sequence)") < 0) + if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, false, "BoolVectorProperty(default=sequence)") == -1) return NULL; if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { @@ -2136,7 +2136,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject return NULL; } - if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, false, "IntVectorProperty(default=sequence)") < 0) + if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, false, "IntVectorProperty(default=sequence)") == -1) return NULL; if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { @@ -2356,7 +2356,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec return NULL; } - if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, false, "FloatVectorProperty(default=sequence)") < 0) + if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, false, "FloatVectorProperty(default=sequence)") == -1) return NULL; if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 5be6c33ec18..94f262f57f5 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1187,7 +1187,7 @@ int pyrna_set_to_enum_bitfield(EnumPropertyItem *items, PyObject *value, int *r_ return -1; } - if (pyrna_enum_value_from_id(items, param, &ret, error_prefix) < 0) { + if (pyrna_enum_value_from_id(items, param, &ret, error_prefix) == -1) { return -1; } @@ -1682,13 +1682,13 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb /* type checkins is done by each function */ if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { /* set of enum items, concatenate all values with OR */ - if (pyrna_prop_to_enum_bitfield(ptr, prop, value, &val, error_prefix) < 0) { + if (pyrna_prop_to_enum_bitfield(ptr, prop, value, &val, error_prefix) == -1) { return -1; } } else { /* simple enum string */ - if (pyrna_string_to_enum(value, ptr, prop, &val, error_prefix) < 0) { + if (pyrna_string_to_enum(value, ptr, prop, &val, error_prefix) == -1) { return -1; } } @@ -4384,7 +4384,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) bool attr_signed; RawPropertyType raw_type; - if (foreach_parse_args(self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) < 0) + if (foreach_parse_args(self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) == -1) return NULL; if (tot == 0) diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index 234eeae8a4a..a19f8e2d8ed 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -160,14 +160,14 @@ static int pyrna_struct_keyframe_parse( return -1; } - if (pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) < 0) + if (pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) == -1) return -1; if (*cfra == FLT_MAX) *cfra = CTX_data_scene(BPy_GetContext())->r.cfra; /* flag may be null (no option currently for remove keyframes e.g.). */ - if (pyoptions && options && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) < 0)) + if (pyoptions && options && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) == -1)) return -1; return 0; /* success */ @@ -301,7 +301,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args) if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index)) return NULL; - if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) < 0) { + if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) == -1) { return NULL; } else { @@ -377,7 +377,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args) if (!PyArg_ParseTuple(args, "s|i:driver_remove", &path, &index)) return NULL; - if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) < 0) { + if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) { return NULL; } else { diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index c66b336a1da..1043f68dbdb 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -101,7 +101,7 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args) if (RNA_struct_is_a(self->ptr.type, &RNA_Region)) { if (cb_event_str) { - if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") < 0) { + if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") == -1) { return NULL; } } @@ -212,10 +212,10 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) return NULL; } - if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") < 0) { + if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") == -1) { return NULL; } - else if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_add()") < 0) { + else if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_add()") == -1) { return NULL; } else { @@ -278,7 +278,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar customdata = ED_region_draw_cb_customdata(handle); Py_DECREF((PyObject *)customdata); - if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_remove()") < 0) { + if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_remove()") == -1) { return NULL; } else { |