Cleanup: Python, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/python` module. No functional changes.
This commit is contained in:
@@ -118,22 +118,20 @@ static PyObject *bpy_app_handlers_persistent_new(PyTypeObject *UNUSED(type),
|
||||
"get the dictionary from the function passed");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
/* set id */
|
||||
if (*dict_ptr == NULL) {
|
||||
*dict_ptr = PyDict_New();
|
||||
}
|
||||
|
||||
PyDict_SetItemString(*dict_ptr, PERMINENT_CB_ID, Py_None);
|
||||
/* set id */
|
||||
if (*dict_ptr == NULL) {
|
||||
*dict_ptr = PyDict_New();
|
||||
}
|
||||
|
||||
PyDict_SetItemString(*dict_ptr, PERMINENT_CB_ID, Py_None);
|
||||
|
||||
Py_INCREF(value);
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError, "bpy.app.handlers.persistent expected a function");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_ValueError, "bpy.app.handlers.persistent expected a function");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* dummy type because decorators can't be PyCFunctions */
|
||||
|
||||
@@ -83,9 +83,8 @@ int bpy_pydriver_create_dict(void)
|
||||
if (d == NULL) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
bpy_pydriver_Dict = d;
|
||||
}
|
||||
|
||||
bpy_pydriver_Dict = d;
|
||||
|
||||
/* import some modules: builtins, bpy, math, (Blender.noise)*/
|
||||
PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins());
|
||||
@@ -680,11 +679,8 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
|
||||
if (isfinite(result)) {
|
||||
return (float)result;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"\tBPY_driver_eval() - driver '%s' evaluates to '%f'\n",
|
||||
driver->expression,
|
||||
result);
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
fprintf(
|
||||
stderr, "\tBPY_driver_eval() - driver '%s' evaluates to '%f'\n", driver->expression, result);
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -244,21 +244,20 @@ static PyObject *bpy_lib_enter(BPy_Library *self)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
int i = 0, code;
|
||||
while ((code = BKE_idtype_idcode_iter_step(&i))) {
|
||||
if (BKE_idtype_idcode_is_linkable(code)) {
|
||||
const char *name_plural = BKE_idtype_idcode_to_name_plural(code);
|
||||
PyObject *str = PyUnicode_FromString(name_plural);
|
||||
PyObject *item;
|
||||
|
||||
PyDict_SetItem(self->dict, str, item = PyList_New(0));
|
||||
Py_DECREF(item);
|
||||
PyDict_SetItem(from_dict, str, item = _bpy_names(self, code));
|
||||
Py_DECREF(item);
|
||||
int i = 0, code;
|
||||
while ((code = BKE_idtype_idcode_iter_step(&i))) {
|
||||
if (BKE_idtype_idcode_is_linkable(code)) {
|
||||
const char *name_plural = BKE_idtype_idcode_to_name_plural(code);
|
||||
PyObject *str = PyUnicode_FromString(name_plural);
|
||||
PyObject *item;
|
||||
|
||||
Py_DECREF(str);
|
||||
}
|
||||
PyDict_SetItem(self->dict, str, item = PyList_New(0));
|
||||
Py_DECREF(item);
|
||||
PyDict_SetItem(from_dict, str, item = _bpy_names(self, code));
|
||||
Py_DECREF(item);
|
||||
|
||||
Py_DECREF(str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,65 +392,64 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
Library *lib = mainl->curlib; /* newly added lib, assign before append end */
|
||||
BLO_library_link_end(mainl, &(self->blo_handle), self->flag, NULL, NULL, NULL, NULL);
|
||||
BLO_blendhandle_close(self->blo_handle);
|
||||
self->blo_handle = NULL;
|
||||
|
||||
GHash *old_to_new_ids = BLI_ghash_ptr_new(__func__);
|
||||
Library *lib = mainl->curlib; /* newly added lib, assign before append end */
|
||||
BLO_library_link_end(mainl, &(self->blo_handle), self->flag, NULL, NULL, NULL, NULL);
|
||||
BLO_blendhandle_close(self->blo_handle);
|
||||
self->blo_handle = NULL;
|
||||
|
||||
/* copied from wm_operator.c */
|
||||
{
|
||||
/* mark all library linked objects to be updated */
|
||||
BKE_main_lib_objects_recalc_all(bmain);
|
||||
GHash *old_to_new_ids = BLI_ghash_ptr_new(__func__);
|
||||
|
||||
/* append, rather than linking */
|
||||
if (do_append) {
|
||||
BKE_library_make_local(bmain, lib, old_to_new_ids, true, false);
|
||||
}
|
||||
/* copied from wm_operator.c */
|
||||
{
|
||||
/* mark all library linked objects to be updated */
|
||||
BKE_main_lib_objects_recalc_all(bmain);
|
||||
|
||||
/* append, rather than linking */
|
||||
if (do_append) {
|
||||
BKE_library_make_local(bmain, lib, old_to_new_ids, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false);
|
||||
BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false);
|
||||
|
||||
/* finally swap the capsules for real bpy objects
|
||||
* important since BLO_library_append_end initializes NodeTree types used by srna->refine */
|
||||
/* finally swap the capsules for real bpy objects
|
||||
* important since BLO_library_append_end initializes NodeTree types used by srna->refine */
|
||||
#ifdef USE_RNA_DATABLOCKS
|
||||
{
|
||||
int idcode_step = 0, idcode;
|
||||
while ((idcode = BKE_idtype_idcode_iter_step(&idcode_step))) {
|
||||
if (BKE_idtype_idcode_is_linkable(idcode) && (idcode != ID_WS || do_append)) {
|
||||
const char *name_plural = BKE_idtype_idcode_to_name_plural(idcode);
|
||||
PyObject *ls = PyDict_GetItemString(self->dict, name_plural);
|
||||
if (ls && PyList_Check(ls)) {
|
||||
Py_ssize_t size = PyList_GET_SIZE(ls);
|
||||
Py_ssize_t i;
|
||||
PyObject *item;
|
||||
{
|
||||
int idcode_step = 0, idcode;
|
||||
while ((idcode = BKE_idtype_idcode_iter_step(&idcode_step))) {
|
||||
if (BKE_idtype_idcode_is_linkable(idcode) && (idcode != ID_WS || do_append)) {
|
||||
const char *name_plural = BKE_idtype_idcode_to_name_plural(idcode);
|
||||
PyObject *ls = PyDict_GetItemString(self->dict, name_plural);
|
||||
if (ls && PyList_Check(ls)) {
|
||||
Py_ssize_t size = PyList_GET_SIZE(ls);
|
||||
Py_ssize_t i;
|
||||
PyObject *item;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
item = PyList_GET_ITEM(ls, i);
|
||||
if (PyCapsule_CheckExact(item)) {
|
||||
PointerRNA id_ptr;
|
||||
ID *id;
|
||||
for (i = 0; i < size; i++) {
|
||||
item = PyList_GET_ITEM(ls, i);
|
||||
if (PyCapsule_CheckExact(item)) {
|
||||
PointerRNA id_ptr;
|
||||
ID *id;
|
||||
|
||||
id = PyCapsule_GetPointer(item, NULL);
|
||||
id = BLI_ghash_lookup_default(old_to_new_ids, id, id);
|
||||
Py_DECREF(item);
|
||||
id = PyCapsule_GetPointer(item, NULL);
|
||||
id = BLI_ghash_lookup_default(old_to_new_ids, id, id);
|
||||
Py_DECREF(item);
|
||||
|
||||
RNA_id_pointer_create(id, &id_ptr);
|
||||
item = pyrna_struct_CreatePyObject(&id_ptr);
|
||||
PyList_SET_ITEM(ls, i, item);
|
||||
}
|
||||
RNA_id_pointer_create(id, &id_ptr);
|
||||
item = pyrna_struct_CreatePyObject(&id_ptr);
|
||||
PyList_SET_ITEM(ls, i, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* USE_RNA_DATABLOCKS */
|
||||
|
||||
BLI_ghash_free(old_to_new_ids, NULL, NULL);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
BLI_ghash_free(old_to_new_ids, NULL, NULL);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *bpy_lib_dir(BPy_Library *self)
|
||||
|
||||
@@ -1408,9 +1408,8 @@ static bool py_long_as_int(PyObject *py_long, int *r_int)
|
||||
*r_int = (int)PyLong_AS_LONG(py_long);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -1716,16 +1715,15 @@ static int bpy_prop_callback_check(PyObject *py_func, const char *keyword, int a
|
||||
Py_TYPE(py_func)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(py_func);
|
||||
if (f_code->co_argcount != argcount) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%s keyword: expected a function taking %d arguments, not %d",
|
||||
keyword,
|
||||
argcount,
|
||||
f_code->co_argcount);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(py_func);
|
||||
if (f_code->co_argcount != argcount) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%s keyword: expected a function taking %d arguments, not %d",
|
||||
keyword,
|
||||
argcount,
|
||||
f_code->co_argcount);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1981,7 +1979,7 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop,
|
||||
Py_DECREF(args); \
|
||||
return ret; \
|
||||
} \
|
||||
else if (PyTuple_GET_SIZE(args) > 1) { \
|
||||
if (PyTuple_GET_SIZE(args) > 1) { \
|
||||
PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \
|
||||
return NULL; \
|
||||
} \
|
||||
@@ -3537,7 +3535,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
Py_DECREF(args);
|
||||
return ret;
|
||||
}
|
||||
else if (PyTuple_GET_SIZE(args) > 1) {
|
||||
if (PyTuple_GET_SIZE(args) > 1) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected one positional arg, one keyword arg");
|
||||
return NULL;
|
||||
}
|
||||
@@ -3546,27 +3544,27 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
if (srna == NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
else if (srna == NULL) {
|
||||
if (srna == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
const char *id = NULL;
|
||||
|
||||
static const char *_keywords[] = {
|
||||
"attr",
|
||||
NULL,
|
||||
};
|
||||
static _PyArg_Parser _parser = {"s:RemoveProperty", _keywords, 0};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &id)) {
|
||||
return NULL;
|
||||
}
|
||||
const char *id = NULL;
|
||||
|
||||
if (RNA_def_property_free_identifier(srna, id) != 1) {
|
||||
PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id);
|
||||
return NULL;
|
||||
}
|
||||
static const char *_keywords[] = {
|
||||
"attr",
|
||||
NULL,
|
||||
};
|
||||
static _PyArg_Parser _parser = {"s:RemoveProperty", _keywords, 0};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &id)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (RNA_def_property_free_identifier(srna, id) != 1) {
|
||||
PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -181,24 +181,24 @@ static int pyrna_struct_anim_args_parse_no_resolve(PointerRNA *ptr,
|
||||
*r_path_full = path;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
char *path_prefix = RNA_path_from_ID_to_struct(ptr);
|
||||
if (path_prefix == NULL) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s could not make path for type %s",
|
||||
error_prefix,
|
||||
RNA_struct_identifier(ptr->type));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (*path == '[') {
|
||||
*r_path_full = BLI_string_joinN(path_prefix, path);
|
||||
}
|
||||
else {
|
||||
*r_path_full = BLI_string_join_by_sep_charN('.', path_prefix, path);
|
||||
}
|
||||
MEM_freeN(path_prefix);
|
||||
char *path_prefix = RNA_path_from_ID_to_struct(ptr);
|
||||
if (path_prefix == NULL) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s could not make path for type %s",
|
||||
error_prefix,
|
||||
RNA_struct_identifier(ptr->type));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (*path == '[') {
|
||||
*r_path_full = BLI_string_joinN(path_prefix, path);
|
||||
}
|
||||
else {
|
||||
*r_path_full = BLI_string_join_by_sep_charN('.', path_prefix, path);
|
||||
}
|
||||
MEM_freeN(path_prefix);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -383,33 +383,32 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
else {
|
||||
ID *id = self->ptr.owner_id;
|
||||
ReportList reports;
|
||||
bool result;
|
||||
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
ID *id = self->ptr.owner_id;
|
||||
ReportList reports;
|
||||
bool result;
|
||||
|
||||
BLI_assert(BKE_id_is_in_global_main(id));
|
||||
result = (insert_keyframe(G_MAIN,
|
||||
&reports,
|
||||
id,
|
||||
NULL,
|
||||
group_name,
|
||||
path_full,
|
||||
index,
|
||||
&anim_eval_context,
|
||||
keytype,
|
||||
NULL,
|
||||
options) != 0);
|
||||
MEM_freeN((void *)path_full);
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
BLI_assert(BKE_id_is_in_global_main(id));
|
||||
result = (insert_keyframe(G_MAIN,
|
||||
&reports,
|
||||
id,
|
||||
NULL,
|
||||
group_name,
|
||||
path_full,
|
||||
index,
|
||||
&anim_eval_context,
|
||||
keytype,
|
||||
NULL,
|
||||
options) != 0);
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
|
||||
char pyrna_struct_keyframe_delete_doc[] =
|
||||
@@ -453,7 +452,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
NULL) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else if (self->ptr.type == &RNA_NlaStrip) {
|
||||
if (self->ptr.type == &RNA_NlaStrip) {
|
||||
/* Handle special properties for NLA Strips, whose F-Curves are stored on the
|
||||
* strips themselves. These are stored separately or else the properties will
|
||||
* not have any effect.
|
||||
@@ -518,22 +517,21 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
else {
|
||||
bool result;
|
||||
ReportList reports;
|
||||
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
bool result;
|
||||
ReportList reports;
|
||||
|
||||
result = (delete_keyframe(
|
||||
G.main, &reports, self->ptr.owner_id, NULL, path_full, index, cfra) != 0);
|
||||
MEM_freeN((void *)path_full);
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
result = (delete_keyframe(G.main, &reports, self->ptr.owner_id, NULL, path_full, index, cfra) !=
|
||||
0);
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
|
||||
char pyrna_struct_driver_add_doc[] =
|
||||
@@ -563,60 +561,59 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
||||
&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
PyObject *ret = NULL;
|
||||
ReportList reports;
|
||||
int result;
|
||||
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
PyObject *ret = NULL;
|
||||
ReportList reports;
|
||||
int result;
|
||||
|
||||
result = ANIM_add_driver(&reports,
|
||||
(ID *)self->ptr.owner_id,
|
||||
path_full,
|
||||
index,
|
||||
CREATEDRIVER_WITH_FMODIFIER,
|
||||
DRIVER_TYPE_PYTHON);
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
result = ANIM_add_driver(&reports,
|
||||
(ID *)self->ptr.owner_id,
|
||||
path_full,
|
||||
index,
|
||||
CREATEDRIVER_WITH_FMODIFIER,
|
||||
DRIVER_TYPE_PYTHON);
|
||||
|
||||
if (result) {
|
||||
ID *id = self->ptr.owner_id;
|
||||
AnimData *adt = BKE_animdata_from_id(id);
|
||||
FCurve *fcu;
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PointerRNA tptr;
|
||||
if (result) {
|
||||
ID *id = self->ptr.owner_id;
|
||||
AnimData *adt = BKE_animdata_from_id(id);
|
||||
FCurve *fcu;
|
||||
|
||||
if (index == -1) { /* all, use a list */
|
||||
int i = 0;
|
||||
ret = PyList_New(0);
|
||||
while ((fcu = BKE_fcurve_find(&adt->drivers, path_full, i++))) {
|
||||
RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
|
||||
PyList_APPEND(ret, pyrna_struct_CreatePyObject(&tptr));
|
||||
}
|
||||
}
|
||||
else {
|
||||
fcu = BKE_fcurve_find(&adt->drivers, path_full, index);
|
||||
PointerRNA tptr;
|
||||
|
||||
if (index == -1) { /* all, use a list */
|
||||
int i = 0;
|
||||
ret = PyList_New(0);
|
||||
while ((fcu = BKE_fcurve_find(&adt->drivers, path_full, i++))) {
|
||||
RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
|
||||
ret = pyrna_struct_CreatePyObject(&tptr);
|
||||
PyList_APPEND(ret, pyrna_struct_CreatePyObject(&tptr));
|
||||
}
|
||||
|
||||
bContext *context = BPy_GetContext();
|
||||
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
|
||||
DEG_relations_tag_update(CTX_data_main(context));
|
||||
}
|
||||
else {
|
||||
/* XXX, should be handled by reports, */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"bpy_struct.driver_add(): failed because of an internal error");
|
||||
return NULL;
|
||||
fcu = BKE_fcurve_find(&adt->drivers, path_full, index);
|
||||
RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
|
||||
ret = pyrna_struct_CreatePyObject(&tptr);
|
||||
}
|
||||
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
return ret;
|
||||
bContext *context = BPy_GetContext();
|
||||
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
|
||||
DEG_relations_tag_update(CTX_data_main(context));
|
||||
}
|
||||
else {
|
||||
/* XXX, should be handled by reports, */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"bpy_struct.driver_add(): failed because of an internal error");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char pyrna_struct_driver_remove_doc[] =
|
||||
@@ -646,26 +643,25 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
|
||||
&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
short result;
|
||||
ReportList reports;
|
||||
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
short result;
|
||||
ReportList reports;
|
||||
|
||||
result = ANIM_remove_driver(&reports, (ID *)self->ptr.owner_id, path_full, index, 0);
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
|
||||
if (path != path_full) {
|
||||
MEM_freeN((void *)path_full);
|
||||
}
|
||||
result = ANIM_remove_driver(&reports, (ID *)self->ptr.owner_id, path_full, index, 0);
|
||||
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bContext *context = BPy_GetContext();
|
||||
WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, NULL);
|
||||
DEG_relations_tag_update(CTX_data_main(context));
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
if (path != path_full) {
|
||||
MEM_freeN((void *)path_full);
|
||||
}
|
||||
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bContext *context = BPy_GetContext();
|
||||
WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, NULL);
|
||||
DEG_relations_tag_update(CTX_data_main(context));
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ static int validate_array_type(PyObject *seq,
|
||||
Py_TYPE(seq)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else if ((seq_size != dimsize[dim]) && (is_dynamic == false)) {
|
||||
if ((seq_size != dimsize[dim]) && (is_dynamic == false)) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s sequences of dimension %d should contain %d items, not %d",
|
||||
error_prefix,
|
||||
@@ -201,7 +201,7 @@ static int validate_array_type(PyObject *seq,
|
||||
i);
|
||||
return -1;
|
||||
}
|
||||
else if (!check_item_type(item)) {
|
||||
if (!check_item_type(item)) {
|
||||
Py_DECREF(item);
|
||||
|
||||
#if 0
|
||||
@@ -279,7 +279,7 @@ static int validate_array_length(PyObject *rvalue,
|
||||
RNA_property_identifier(prop));
|
||||
return -1;
|
||||
}
|
||||
else if ((RNA_property_flag(prop) & PROP_DYNAMIC) && lvalue_dim == 0) {
|
||||
if ((RNA_property_flag(prop) & PROP_DYNAMIC) && lvalue_dim == 0) {
|
||||
if (RNA_property_array_length(ptr, prop) != tot) {
|
||||
#if 0
|
||||
/* length is flexible */
|
||||
@@ -382,7 +382,7 @@ static int validate_array(PyObject *rvalue,
|
||||
RNA_property_identifier(prop));
|
||||
return -1;
|
||||
}
|
||||
else if (totdim != 2) {
|
||||
if (totdim != 2) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s %.200s.%.200s, matrix assign array with %d dimensions",
|
||||
error_prefix,
|
||||
@@ -391,7 +391,7 @@ static int validate_array(PyObject *rvalue,
|
||||
totdim);
|
||||
return -1;
|
||||
}
|
||||
else if (pymat->num_col != dimsize[0] || pymat->num_row != dimsize[1]) {
|
||||
if (pymat->num_col != dimsize[0] || pymat->num_row != dimsize[1]) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s %.200s.%.200s, matrix assign dimension size mismatch, "
|
||||
"is %dx%d, expected be %dx%d",
|
||||
@@ -404,10 +404,9 @@ static int validate_array(PyObject *rvalue,
|
||||
dimsize[1]);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
*r_totitem = dimsize[0] * dimsize[1];
|
||||
return 0;
|
||||
}
|
||||
|
||||
*r_totitem = dimsize[0] * dimsize[1];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif /* USE_MATHUTILS */
|
||||
@@ -1017,31 +1016,31 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
float tmp[32];
|
||||
float *tmp_arr;
|
||||
|
||||
if (len * sizeof(float) > sizeof(tmp)) {
|
||||
tmp_arr = PyMem_MALLOC(len * sizeof(float));
|
||||
}
|
||||
else {
|
||||
tmp_arr = tmp;
|
||||
}
|
||||
float tmp[32];
|
||||
float *tmp_arr;
|
||||
|
||||
RNA_property_float_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (tmp_arr[i] == value_f) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp_arr != tmp) {
|
||||
PyMem_FREE(tmp_arr);
|
||||
}
|
||||
|
||||
return i < len ? 1 : 0;
|
||||
if (len * sizeof(float) > sizeof(tmp)) {
|
||||
tmp_arr = PyMem_MALLOC(len * sizeof(float));
|
||||
}
|
||||
else {
|
||||
tmp_arr = tmp;
|
||||
}
|
||||
|
||||
RNA_property_float_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (tmp_arr[i] == value_f) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp_arr != tmp) {
|
||||
PyMem_FREE(tmp_arr);
|
||||
}
|
||||
|
||||
return i < len ? 1 : 0;
|
||||
|
||||
break;
|
||||
}
|
||||
case PROP_INT: {
|
||||
@@ -1050,31 +1049,31 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
int tmp[32];
|
||||
int *tmp_arr;
|
||||
|
||||
if (len * sizeof(int) > sizeof(tmp)) {
|
||||
tmp_arr = PyMem_MALLOC(len * sizeof(int));
|
||||
}
|
||||
else {
|
||||
tmp_arr = tmp;
|
||||
}
|
||||
int tmp[32];
|
||||
int *tmp_arr;
|
||||
|
||||
RNA_property_int_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (tmp_arr[i] == value_i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp_arr != tmp) {
|
||||
PyMem_FREE(tmp_arr);
|
||||
}
|
||||
|
||||
return i < len ? 1 : 0;
|
||||
if (len * sizeof(int) > sizeof(tmp)) {
|
||||
tmp_arr = PyMem_MALLOC(len * sizeof(int));
|
||||
}
|
||||
else {
|
||||
tmp_arr = tmp;
|
||||
}
|
||||
|
||||
RNA_property_int_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (tmp_arr[i] == value_i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp_arr != tmp) {
|
||||
PyMem_FREE(tmp_arr);
|
||||
}
|
||||
|
||||
return i < len ? 1 : 0;
|
||||
|
||||
break;
|
||||
}
|
||||
case PROP_BOOLEAN: {
|
||||
@@ -1083,31 +1082,31 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
bool tmp[32];
|
||||
bool *tmp_arr;
|
||||
|
||||
if (len * sizeof(bool) > sizeof(tmp)) {
|
||||
tmp_arr = PyMem_MALLOC(len * sizeof(bool));
|
||||
}
|
||||
else {
|
||||
tmp_arr = tmp;
|
||||
}
|
||||
bool tmp[32];
|
||||
bool *tmp_arr;
|
||||
|
||||
RNA_property_boolean_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (tmp_arr[i] == value_i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp_arr != tmp) {
|
||||
PyMem_FREE(tmp_arr);
|
||||
}
|
||||
|
||||
return i < len ? 1 : 0;
|
||||
if (len * sizeof(bool) > sizeof(tmp)) {
|
||||
tmp_arr = PyMem_MALLOC(len * sizeof(bool));
|
||||
}
|
||||
else {
|
||||
tmp_arr = tmp;
|
||||
}
|
||||
|
||||
RNA_property_boolean_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (tmp_arr[i] == value_i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp_arr != tmp) {
|
||||
PyMem_FREE(tmp_arr);
|
||||
}
|
||||
|
||||
return i < len ? 1 : 0;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,10 +317,10 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
|
||||
error_prefix) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else if (params.region_type_str && pyrna_enum_value_from_id(rna_enum_region_type_items,
|
||||
params.region_type_str,
|
||||
¶ms.region_type,
|
||||
error_prefix) == -1) {
|
||||
if (params.region_type_str && pyrna_enum_value_from_id(rna_enum_region_type_items,
|
||||
params.region_type_str,
|
||||
¶ms.region_type,
|
||||
error_prefix) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -352,29 +352,26 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
|
||||
region_draw_mode_items, params.event_str, ¶ms.event, error_prefix) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else if (pyrna_enum_value_from_id(rna_enum_region_type_items,
|
||||
params.region_type_str,
|
||||
¶ms.region_type,
|
||||
error_prefix) == -1) {
|
||||
if (pyrna_enum_value_from_id(rna_enum_region_type_items,
|
||||
params.region_type_str,
|
||||
¶ms.region_type,
|
||||
error_prefix) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
|
||||
if (spaceid == SPACE_EMPTY) {
|
||||
PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
SpaceType *st = BKE_spacetype_from_id(spaceid);
|
||||
ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
|
||||
if (art == NULL) {
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
|
||||
return NULL;
|
||||
}
|
||||
handle = ED_region_draw_cb_activate(art, cb_region_draw, (void *)args, params.event);
|
||||
}
|
||||
|
||||
const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
|
||||
if (spaceid == SPACE_EMPTY) {
|
||||
PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SpaceType *st = BKE_spacetype_from_id(spaceid);
|
||||
ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
|
||||
if (art == NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
|
||||
return NULL;
|
||||
}
|
||||
handle = ED_region_draw_cb_activate(art, cb_region_draw, (void *)args, params.event);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "callback_add(): type does not support callbacks");
|
||||
@@ -448,24 +445,21 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
|
||||
error_prefix) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
|
||||
if (spaceid == SPACE_EMPTY) {
|
||||
PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
SpaceType *st = BKE_spacetype_from_id(spaceid);
|
||||
ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
|
||||
if (art == NULL) {
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
|
||||
return NULL;
|
||||
}
|
||||
ED_region_draw_cb_exit(art, handle);
|
||||
capsule_clear = true;
|
||||
}
|
||||
|
||||
const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
|
||||
if (spaceid == SPACE_EMPTY) {
|
||||
PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SpaceType *st = BKE_spacetype_from_id(spaceid);
|
||||
ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
|
||||
if (art == NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
|
||||
return NULL;
|
||||
}
|
||||
ED_region_draw_cb_exit(art, handle);
|
||||
capsule_clear = true;
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "callback_remove(): type does not support callbacks");
|
||||
|
||||
@@ -367,10 +367,10 @@ static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *ar
|
||||
WM_gizmo_target_property_float_get_array(gz, gz_prop, value);
|
||||
return PyC_Tuple_PackArray_F32(value, array_len);
|
||||
}
|
||||
else {
|
||||
float value = WM_gizmo_target_property_float_get(gz, gz_prop);
|
||||
return PyFloat_FromDouble(value);
|
||||
}
|
||||
|
||||
float value = WM_gizmo_target_property_float_get(gz, gz_prop);
|
||||
return PyFloat_FromDouble(value);
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
Reference in New Issue
Block a user