Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-08-12 04:59:16 +0300
committerHans Goudey <h.goudey@me.com>2020-08-12 04:59:16 +0300
commitef11238c743e6985fe325280fb13e05d6ec27378 (patch)
tree1dd2605a676bee52296535825b99f000a9c255eb /source/blender/python/intern
parent1f768bbe4145daed111636ca09dd53b25b8d29b5 (diff)
parentec5f39208785c1bbe723054ffe69e1ac2ab470dd (diff)
Merge branch 'master' into property-search-uiproperty-search-ui
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r--source/blender/python/intern/bpy.h5
-rw-r--r--source/blender/python/intern/bpy_app.h5
-rw-r--r--source/blender/python/intern/bpy_app_alembic.h5
-rw-r--r--source/blender/python/intern/bpy_app_build_options.h5
-rw-r--r--source/blender/python/intern/bpy_app_ffmpeg.h5
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c18
-rw-r--r--source/blender/python/intern/bpy_app_handlers.h5
-rw-r--r--source/blender/python/intern/bpy_app_icons.h5
-rw-r--r--source/blender/python/intern/bpy_app_ocio.h5
-rw-r--r--source/blender/python/intern/bpy_app_oiio.h5
-rw-r--r--source/blender/python/intern/bpy_app_opensubdiv.h5
-rw-r--r--source/blender/python/intern/bpy_app_openvdb.h5
-rw-r--r--source/blender/python/intern/bpy_app_sdl.h5
-rw-r--r--source/blender/python/intern/bpy_app_timers.h5
-rw-r--r--source/blender/python/intern/bpy_app_translations.c8
-rw-r--r--source/blender/python/intern/bpy_app_translations.h5
-rw-r--r--source/blender/python/intern/bpy_app_usd.h5
-rw-r--r--source/blender/python/intern/bpy_capi_utils.h5
-rw-r--r--source/blender/python/intern/bpy_driver.c16
-rw-r--r--source/blender/python/intern/bpy_driver.h5
-rw-r--r--source/blender/python/intern/bpy_gizmo_wrap.h5
-rw-r--r--source/blender/python/intern/bpy_interface.c9
-rw-r--r--source/blender/python/intern/bpy_intern_string.h5
-rw-r--r--source/blender/python/intern/bpy_library.h5
-rw-r--r--source/blender/python/intern/bpy_library_load.c118
-rw-r--r--source/blender/python/intern/bpy_msgbus.h5
-rw-r--r--source/blender/python/intern/bpy_operator.c9
-rw-r--r--source/blender/python/intern/bpy_operator.h5
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.h5
-rw-r--r--source/blender/python/intern/bpy_path.h5
-rw-r--r--source/blender/python/intern/bpy_props.c60
-rw-r--r--source/blender/python/intern/bpy_props.h5
-rw-r--r--source/blender/python/intern/bpy_rna.c839
-rw-r--r--source/blender/python/intern/bpy_rna.h5
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c216
-rw-r--r--source/blender/python/intern/bpy_rna_anim.h5
-rw-r--r--source/blender/python/intern/bpy_rna_array.c125
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c76
-rw-r--r--source/blender/python/intern/bpy_rna_callback.h5
-rw-r--r--source/blender/python/intern/bpy_rna_driver.h5
-rw-r--r--source/blender/python/intern/bpy_rna_gizmo.c8
-rw-r--r--source/blender/python/intern/bpy_rna_gizmo.h5
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.h5
-rw-r--r--source/blender/python/intern/bpy_rna_types_capi.h5
-rw-r--r--source/blender/python/intern/bpy_traceback.h5
-rw-r--r--source/blender/python/intern/bpy_utils_previews.h5
-rw-r--r--source/blender/python/intern/bpy_utils_units.h5
47 files changed, 762 insertions, 915 deletions
diff --git a/source/blender/python/intern/bpy.h b/source/blender/python/intern/bpy.h
index 8f91c4e1208..744bf903443 100644
--- a/source/blender/python/intern/bpy.h
+++ b/source/blender/python/intern/bpy.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_H__
-#define __BPY_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -38,5 +37,3 @@ extern struct CLG_LogRef *BPY_LOG_RNA;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_H__ */
diff --git a/source/blender/python/intern/bpy_app.h b/source/blender/python/intern/bpy_app.h
index 880686f3536..0e5b6747543 100644
--- a/source/blender/python/intern/bpy_app.h
+++ b/source/blender/python/intern/bpy_app.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_H__
-#define __BPY_APP_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_H__ */
diff --git a/source/blender/python/intern/bpy_app_alembic.h b/source/blender/python/intern/bpy_app_alembic.h
index fcd93fb2b13..4288b556172 100644
--- a/source/blender/python/intern/bpy_app_alembic.h
+++ b/source/blender/python/intern/bpy_app_alembic.h
@@ -21,8 +21,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_ALEMBIC_H__
-#define __BPY_APP_ALEMBIC_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -33,5 +32,3 @@ PyObject *BPY_app_alembic_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_ALEMBIC_H__ */
diff --git a/source/blender/python/intern/bpy_app_build_options.h b/source/blender/python/intern/bpy_app_build_options.h
index a10f42d53be..390e3409fb8 100644
--- a/source/blender/python/intern/bpy_app_build_options.h
+++ b/source/blender/python/intern/bpy_app_build_options.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_BUILD_OPTIONS_H__
-#define __BPY_APP_BUILD_OPTIONS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_build_options_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_BUILD_OPTIONS_H__ */
diff --git a/source/blender/python/intern/bpy_app_ffmpeg.h b/source/blender/python/intern/bpy_app_ffmpeg.h
index 4809288662b..b189592e03e 100644
--- a/source/blender/python/intern/bpy_app_ffmpeg.h
+++ b/source/blender/python/intern/bpy_app_ffmpeg.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_FFMPEG_H__
-#define __BPY_APP_FFMPEG_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_ffmpeg_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_FFMPEG_H__ */
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index dde1d13477f..cdbd3bc0b9c 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -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 */
diff --git a/source/blender/python/intern/bpy_app_handlers.h b/source/blender/python/intern/bpy_app_handlers.h
index 9c9dd75dd18..eb8e85fc96e 100644
--- a/source/blender/python/intern/bpy_app_handlers.h
+++ b/source/blender/python/intern/bpy_app_handlers.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_HANDLERS_H__
-#define __BPY_APP_HANDLERS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_handlers_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_HANDLERS_H__ */
diff --git a/source/blender/python/intern/bpy_app_icons.h b/source/blender/python/intern/bpy_app_icons.h
index 2904dc06136..b0dcbe4b0ea 100644
--- a/source/blender/python/intern/bpy_app_icons.h
+++ b/source/blender/python/intern/bpy_app_icons.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_ICONS_H__
-#define __BPY_APP_ICONS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_icons_module(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_ICONS_H__ */
diff --git a/source/blender/python/intern/bpy_app_ocio.h b/source/blender/python/intern/bpy_app_ocio.h
index 145cea1a9be..bc4529a962c 100644
--- a/source/blender/python/intern/bpy_app_ocio.h
+++ b/source/blender/python/intern/bpy_app_ocio.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_OCIO_H__
-#define __BPY_APP_OCIO_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_ocio_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_OCIO_H__ */
diff --git a/source/blender/python/intern/bpy_app_oiio.h b/source/blender/python/intern/bpy_app_oiio.h
index e106a9a055a..47092899eec 100644
--- a/source/blender/python/intern/bpy_app_oiio.h
+++ b/source/blender/python/intern/bpy_app_oiio.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_OIIO_H__
-#define __BPY_APP_OIIO_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_oiio_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_OIIO_H__ */
diff --git a/source/blender/python/intern/bpy_app_opensubdiv.h b/source/blender/python/intern/bpy_app_opensubdiv.h
index f659e58c071..e18c827e6d8 100644
--- a/source/blender/python/intern/bpy_app_opensubdiv.h
+++ b/source/blender/python/intern/bpy_app_opensubdiv.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_OPENSUBDIV_H__
-#define __BPY_APP_OPENSUBDIV_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_opensubdiv_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_OPENSUBDIV_H__ */
diff --git a/source/blender/python/intern/bpy_app_openvdb.h b/source/blender/python/intern/bpy_app_openvdb.h
index 60c2bbaa922..ab73d561412 100644
--- a/source/blender/python/intern/bpy_app_openvdb.h
+++ b/source/blender/python/intern/bpy_app_openvdb.h
@@ -21,8 +21,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_OPENVDB_H__
-#define __BPY_APP_OPENVDB_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -33,5 +32,3 @@ PyObject *BPY_app_openvdb_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_OPENVDB_H__ */
diff --git a/source/blender/python/intern/bpy_app_sdl.h b/source/blender/python/intern/bpy_app_sdl.h
index dd21ece89c7..b1d349c2a59 100644
--- a/source/blender/python/intern/bpy_app_sdl.h
+++ b/source/blender/python/intern/bpy_app_sdl.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_SDL_H__
-#define __BPY_APP_SDL_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_sdl_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_SDL_H__ */
diff --git a/source/blender/python/intern/bpy_app_timers.h b/source/blender/python/intern/bpy_app_timers.h
index 6da92eb8b31..9e62541c83a 100644
--- a/source/blender/python/intern/bpy_app_timers.h
+++ b/source/blender/python/intern/bpy_app_timers.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_TIMERS_H__
-#define __BPY_APP_TIMERS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_timers_module(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_TIMERS_H__ */
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c
index 190d4eb1855..c152c920453 100644
--- a/source/blender/python/intern/bpy_app_translations.c
+++ b/source/blender/python/intern/bpy_app_translations.c
@@ -566,7 +566,7 @@ static PyObject *_py_pgettext(PyObject *args,
PyDoc_STRVAR(
app_translations_pgettext_doc,
- ".. method:: pgettext(msgid, msgctxt)\n"
+ ".. method:: pgettext(msgid, msgctxt=None)\n"
"\n"
" Try to translate the given msgid (with optional msgctxt).\n"
"\n"
@@ -600,7 +600,7 @@ static PyObject *app_translations_pgettext(BlenderAppTranslations *UNUSED(self),
}
PyDoc_STRVAR(app_translations_pgettext_iface_doc,
- ".. method:: pgettext_iface(msgid, msgctxt)\n"
+ ".. method:: pgettext_iface(msgid, msgctxt=None)\n"
"\n"
" Try to translate the given msgid (with optional msgctxt), if labels' translation "
"is enabled.\n"
@@ -622,7 +622,7 @@ static PyObject *app_translations_pgettext_iface(BlenderAppTranslations *UNUSED(
}
PyDoc_STRVAR(app_translations_pgettext_tip_doc,
- ".. method:: pgettext_tip(msgid, msgctxt)\n"
+ ".. method:: pgettext_tip(msgid, msgctxt=None)\n"
"\n"
" Try to translate the given msgid (with optional msgctxt), if tooltips' "
"translation is enabled.\n"
@@ -644,7 +644,7 @@ static PyObject *app_translations_pgettext_tip(BlenderAppTranslations *UNUSED(se
}
PyDoc_STRVAR(app_translations_pgettext_data_doc,
- ".. method:: pgettext_data(msgid, msgctxt)\n"
+ ".. method:: pgettext_data(msgid, msgctxt=None)\n"
"\n"
" Try to translate the given msgid (with optional msgctxt), if new data name's "
"translation is enabled.\n"
diff --git a/source/blender/python/intern/bpy_app_translations.h b/source/blender/python/intern/bpy_app_translations.h
index 1e98c7d9aaa..090cab5917c 100644
--- a/source/blender/python/intern/bpy_app_translations.h
+++ b/source/blender/python/intern/bpy_app_translations.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_TRANSLATIONS_H__
-#define __BPY_APP_TRANSLATIONS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -31,5 +30,3 @@ void BPY_app_translations_end(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_TRANSLATIONS_H__ */
diff --git a/source/blender/python/intern/bpy_app_usd.h b/source/blender/python/intern/bpy_app_usd.h
index 0482b10974d..2801408c2aa 100644
--- a/source/blender/python/intern/bpy_app_usd.h
+++ b/source/blender/python/intern/bpy_app_usd.h
@@ -21,8 +21,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_USD_H__
-#define __BPY_APP_USD_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -33,5 +32,3 @@ PyObject *BPY_app_usd_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_USD_H__ */
diff --git a/source/blender/python/intern/bpy_capi_utils.h b/source/blender/python/intern/bpy_capi_utils.h
index 11409397028..861b23190a2 100644
--- a/source/blender/python/intern/bpy_capi_utils.h
+++ b/source/blender/python/intern/bpy_capi_utils.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_CAPI_UTILS_H__
-#define __BPY_CAPI_UTILS_H__
+#pragma once
#if PY_VERSION_HEX < 0x03070000
# error "Python 3.7 or greater is required, you'll need to update your Python."
@@ -59,5 +58,3 @@ extern void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilsta
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_CAPI_UTILS_H__ */
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index d48ad2b197c..7fb4b0c469c 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -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;
}
diff --git a/source/blender/python/intern/bpy_driver.h b/source/blender/python/intern/bpy_driver.h
index 84f3cbdbbb3..d5064d9fa56 100644
--- a/source/blender/python/intern/bpy_driver.h
+++ b/source/blender/python/intern/bpy_driver.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_DRIVER_H__
-#define __BPY_DRIVER_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -31,5 +30,3 @@ extern PyObject *bpy_pydriver_Dict;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_DRIVER_H__ */
diff --git a/source/blender/python/intern/bpy_gizmo_wrap.h b/source/blender/python/intern/bpy_gizmo_wrap.h
index 3a46dd5d78b..86b56ab2bd9 100644
--- a/source/blender/python/intern/bpy_gizmo_wrap.h
+++ b/source/blender/python/intern/bpy_gizmo_wrap.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_GIZMO_WRAP_H__
-#define __BPY_GIZMO_WRAP_H__
+#pragma once
struct wmGizmoGroupType;
struct wmGizmoType;
@@ -35,5 +34,3 @@ void BPY_RNA_gizmogroup_wrapper(struct wmGizmoGroupType *gzgt, void *userdata);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_GIZMO_WRAP_H__ */
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index f91afa414ce..c311041e4cb 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -438,6 +438,12 @@ static void python_script_error_jump_text(struct Text *text)
}
}
+void BPY_python_backtrace(/* FILE */ void *fp)
+{
+ fputs("\n# Python backtrace\n", fp);
+ PyC_StackPrint(fp);
+}
+
/* super annoying, undo _PyModule_Clear(), bug [#23871] */
#define PYMODULE_CLEAR_WORKAROUND
@@ -921,8 +927,11 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
/* TODO, reloading the module isn't functional at the moment. */
static void bpy_module_free(void *mod);
+
+/* Defined in 'creator.c' when building as a Python module. */
extern int main_python_enter(int argc, const char **argv);
extern void main_python_exit(void);
+
static struct PyModuleDef bpy_proxy_def = {
PyModuleDef_HEAD_INIT,
"bpy", /* m_name */
diff --git a/source/blender/python/intern/bpy_intern_string.h b/source/blender/python/intern/bpy_intern_string.h
index f87a43e6bf6..0c75b723fb8 100644
--- a/source/blender/python/intern/bpy_intern_string.h
+++ b/source/blender/python/intern/bpy_intern_string.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BPY_INTERN_STRING_H__
-#define __BPY_INTERN_STRING_H__
+#pragma once
/** \file
* \ingroup pythonintern
@@ -48,5 +47,3 @@ extern PyObject *bpy_intern_str_unregister;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_INTERN_STRING_H__ */
diff --git a/source/blender/python/intern/bpy_library.h b/source/blender/python/intern/bpy_library.h
index aca4ae94d6e..fbcf111e37d 100644
--- a/source/blender/python/intern/bpy_library.h
+++ b/source/blender/python/intern/bpy_library.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_LIBRARY_H__
-#define __BPY_LIBRARY_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -33,5 +32,3 @@ extern PyMethodDef BPY_library_write_method_def;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_LIBRARY_H__ */
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index 05cbc9af601..bcf13b1d88f 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -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);
-
- Py_DECREF(str);
- }
+
+ 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);
+
+ 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;
-
- 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);
-
- RNA_id_pointer_create(id, &id_ptr);
- item = pyrna_struct_CreatePyObject(&id_ptr);
- PyList_SET_ITEM(ls, i, 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;
+
+ 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);
}
}
}
}
}
+ }
#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)
diff --git a/source/blender/python/intern/bpy_msgbus.h b/source/blender/python/intern/bpy_msgbus.h
index 9a797218832..8d4846fd707 100644
--- a/source/blender/python/intern/bpy_msgbus.h
+++ b/source/blender/python/intern/bpy_msgbus.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_MSGBUS_H__
-#define __BPY_MSGBUS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_msgbus_module(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_MSGBUS_H__ */
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 4b2b5f129a7..274c1934e9e 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -227,7 +227,14 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
context_dict_back = CTX_py_dict_get(C);
- CTX_py_dict_set(C, (void *)context_dict);
+ /**
+ * It might be that there is already a Python context override. We don't want to remove that
+ * except when this operator call sets a new override explicitly. This is necessary so that
+ * called operator runs in the same context as the calling code by default.
+ */
+ if (context_dict != NULL) {
+ CTX_py_dict_set(C, (void *)context_dict);
+ }
Py_XINCREF(context_dict); /* so we done loose it */
if (WM_operator_poll_context((bContext *)C, ot, context) == false) {
diff --git a/source/blender/python/intern/bpy_operator.h b/source/blender/python/intern/bpy_operator.h
index 37a6acfe822..3cb335d5d9a 100644
--- a/source/blender/python/intern/bpy_operator.h
+++ b/source/blender/python/intern/bpy_operator.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_OPERATOR_H__
-#define __BPY_OPERATOR_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -38,5 +37,3 @@ PyObject *BPY_operator_module(void);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/python/intern/bpy_operator_wrap.h b/source/blender/python/intern/bpy_operator_wrap.h
index 942f9dbea39..9e496cd8d26 100644
--- a/source/blender/python/intern/bpy_operator_wrap.h
+++ b/source/blender/python/intern/bpy_operator_wrap.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_OPERATOR_WRAP_H__
-#define __BPY_OPERATOR_WRAP_H__
+#pragma once
struct wmOperatorType;
@@ -37,5 +36,3 @@ void BPY_RNA_operator_macro_wrapper(struct wmOperatorType *ot, void *userdata);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/python/intern/bpy_path.h b/source/blender/python/intern/bpy_path.h
index 0da9e610b53..3e25cb26288 100644
--- a/source/blender/python/intern/bpy_path.h
+++ b/source/blender/python/intern/bpy_path.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_PATH_H__
-#define __BPY_PATH_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPyInit__bpy_path(void);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index a1f9d4afc51..66c67ca061c 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -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; \
} \
@@ -2961,7 +2959,7 @@ PyDoc_STRVAR(BPy_StringProperty_doc,
"default=\"\", "
"maxlen=0, "
"options={'ANIMATABLE'}, "
- "options=set(), "
+ "override=set(), "
"tags=set(), "
"subtype='NONE', "
"update=None, "
@@ -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;
}
diff --git a/source/blender/python/intern/bpy_props.h b/source/blender/python/intern/bpy_props.h
index 9bcfe8e263a..3d7860dcdd8 100644
--- a/source/blender/python/intern/bpy_props.h
+++ b/source/blender/python/intern/bpy_props.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_PROPS_H__
-#define __BPY_PROPS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -36,5 +35,3 @@ StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 893832b61b6..955a24bc880 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -987,24 +987,23 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
PyErr_SetString(PyExc_RuntimeError, "could not use property type, internal error");
return NULL;
}
- else {
- /* This should never fail. */
- int len = -1;
- char *c = type_fmt;
- while ((*c++ = tolower(*type_id++))) {
- }
+ /* This should never fail. */
+ int len = -1;
+ char *c = type_fmt;
- if (type == PROP_COLLECTION) {
- len = pyrna_prop_collection_length(self);
- }
- else if (RNA_property_array_check(self->prop)) {
- len = pyrna_prop_array_length((BPy_PropertyArrayRNA *)self);
- }
+ while ((*c++ = tolower(*type_id++))) {
+ }
- if (len != -1) {
- sprintf(--c, "[%d]", len);
- }
+ if (type == PROP_COLLECTION) {
+ len = pyrna_prop_collection_length(self);
+ }
+ else if (RNA_property_array_check(self->prop)) {
+ len = pyrna_prop_array_length((BPy_PropertyArrayRNA *)self);
+ }
+
+ if (len != -1) {
+ sprintf(--c, "[%d]", len);
}
/* If a pointer, try to print name of pointer target too. */
@@ -1246,17 +1245,16 @@ static int pyrna_string_to_enum(
Py_TYPE(item)->tp_name);
return -1;
}
- else {
- if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, r_value)) {
- const char *enum_str = pyrna_enum_as_string(ptr, prop);
- PyErr_Format(PyExc_TypeError,
- "%.200s enum \"%.200s\" not found in (%s)",
- error_prefix,
- param,
- enum_str);
- MEM_freeN((void *)enum_str);
- return -1;
- }
+
+ if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, r_value)) {
+ const char *enum_str = pyrna_enum_as_string(ptr, prop);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s enum \"%.200s\" not found in (%s)",
+ error_prefix,
+ param,
+ enum_str);
+ MEM_freeN((void *)enum_str);
+ return -1;
}
return 0;
@@ -1715,14 +1713,14 @@ static int pyrna_py_to_prop(
Py_TYPE(value)->tp_name);
return -1;
}
+
+ if (data) {
+ *((bool *)data) = param;
+ }
else {
- if (data) {
- *((bool *)data) = param;
- }
- else {
- RNA_property_boolean_set(ptr, prop, param);
- }
+ RNA_property_boolean_set(ptr, prop, param);
}
+
break;
}
case PROP_INT: {
@@ -1737,7 +1735,7 @@ static int pyrna_py_to_prop(
RNA_property_identifier(prop));
return -1;
}
- else if (param == -1 && PyErr_Occurred()) {
+ if (param == -1 && PyErr_Occurred()) {
PyErr_Format(PyExc_TypeError,
"%.200s %.200s.%.200s expected an int type, not %.200s",
error_prefix,
@@ -1746,16 +1744,16 @@ static int pyrna_py_to_prop(
Py_TYPE(value)->tp_name);
return -1;
}
+
+ int param_i = (int)param;
+ if (data) {
+ RNA_property_int_clamp(ptr, prop, &param_i);
+ *((int *)data) = param_i;
+ }
else {
- int param_i = (int)param;
- if (data) {
- RNA_property_int_clamp(ptr, prop, &param_i);
- *((int *)data) = param_i;
- }
- else {
- RNA_property_int_set(ptr, prop, param_i);
- }
+ RNA_property_int_set(ptr, prop, param_i);
}
+
break;
}
case PROP_FLOAT: {
@@ -1769,15 +1767,15 @@ static int pyrna_py_to_prop(
Py_TYPE(value)->tp_name);
return -1;
}
+
+ if (data) {
+ RNA_property_float_clamp(ptr, prop, (float *)&param);
+ *((float *)data) = param;
+ }
else {
- if (data) {
- RNA_property_float_clamp(ptr, prop, (float *)&param);
- *((float *)data) = param;
- }
- else {
- RNA_property_float_set(ptr, prop, param);
- }
+ RNA_property_float_set(ptr, prop, param);
}
+
break;
}
case PROP_STRING: {
@@ -1835,19 +1833,18 @@ static int pyrna_py_to_prop(
return -1;
}
- else {
- if (data) {
- if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
- BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
- }
- else {
- *((char **)data) = (char *)param;
- }
+
+ if (data) {
+ if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
+ BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
}
else {
- RNA_property_string_set_bytes(ptr, prop, param, PyBytes_Size(value));
+ *((char **)data) = (char *)param;
}
}
+ else {
+ RNA_property_string_set_bytes(ptr, prop, param, PyBytes_Size(value));
+ }
}
else {
/* Unicode String. */
@@ -1886,22 +1883,22 @@ static int pyrna_py_to_prop(
return -1;
}
- else {
- /* Same as bytes. */
- /* XXX, this is suspect, but needed for function calls,
- * need to see if there's a better way. */
- if (data) {
- if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
- BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
- }
- else {
- *((char **)data) = (char *)param;
- }
+
+ /* Same as bytes. */
+ /* XXX, this is suspect, but needed for function calls,
+ * need to see if there's a better way. */
+ if (data) {
+ if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
+ BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
}
else {
- RNA_property_string_set(ptr, prop, param);
+ *((char **)data) = (char *)param;
}
}
+ else {
+ RNA_property_string_set(ptr, prop, param);
+ }
+
#ifdef USE_STRING_COERCE
Py_XDECREF(value_coerce);
#endif /* USE_STRING_COERCE */
@@ -1971,7 +1968,7 @@ static int pyrna_py_to_prop(
PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
}
- else if (base_type == &RNA_GizmoProperties) {
+ if (base_type == &RNA_GizmoProperties) {
PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
}
@@ -2008,7 +2005,7 @@ static int pyrna_py_to_prop(
Py_XDECREF(value_new);
return -1;
}
- else if ((flag & PROP_NEVER_NULL) && value == Py_None) {
+ if ((flag & PROP_NEVER_NULL) && value == Py_None) {
PyErr_Format(PyExc_TypeError,
"%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
error_prefix,
@@ -2018,8 +2015,8 @@ static int pyrna_py_to_prop(
Py_XDECREF(value_new);
return -1;
}
- else if ((value != Py_None) && ((flag & PROP_ID_SELF_CHECK) &&
- ptr->owner_id == ((BPy_StructRNA *)value)->ptr.owner_id)) {
+ if ((value != Py_None) && ((flag & PROP_ID_SELF_CHECK) &&
+ ptr->owner_id == ((BPy_StructRNA *)value)->ptr.owner_id)) {
PyErr_Format(PyExc_TypeError,
"%.200s %.200s.%.200s ID type does not support assignment to itself",
error_prefix,
@@ -2028,85 +2025,84 @@ static int pyrna_py_to_prop(
Py_XDECREF(value_new);
return -1;
}
- else {
- BPy_StructRNA *param = (BPy_StructRNA *)value;
- bool raise_error = false;
- if (data) {
- if (flag_parameter & PARM_RNAPTR) {
- if (flag & PROP_THICK_WRAP) {
- if (value == Py_None) {
- memset(data, 0, sizeof(PointerRNA));
- }
- else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
- *((PointerRNA *)data) = param->ptr;
- }
- else {
- raise_error = true;
- }
+ BPy_StructRNA *param = (BPy_StructRNA *)value;
+ bool raise_error = false;
+ if (data) {
+
+ if (flag_parameter & PARM_RNAPTR) {
+ if (flag & PROP_THICK_WRAP) {
+ if (value == Py_None) {
+ memset(data, 0, sizeof(PointerRNA));
+ }
+ else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
+ *((PointerRNA *)data) = param->ptr;
}
else {
- /* For function calls, we sometimes want to pass the 'ptr' directly,
- * but watch out that it remains valid!
- * We could possibly support this later if needed. */
- BLI_assert(value_new == NULL);
- if (value == Py_None) {
- *((void **)data) = NULL;
- }
- else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
- *((PointerRNA **)data) = &param->ptr;
- }
- else {
- raise_error = true;
- }
+ raise_error = true;
}
}
- else if (value == Py_None) {
- *((void **)data) = NULL;
- }
- else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
- *((void **)data) = param->ptr.data;
- }
else {
- raise_error = true;
+ /* For function calls, we sometimes want to pass the 'ptr' directly,
+ * but watch out that it remains valid!
+ * We could possibly support this later if needed. */
+ BLI_assert(value_new == NULL);
+ if (value == Py_None) {
+ *((void **)data) = NULL;
+ }
+ else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
+ *((PointerRNA **)data) = &param->ptr;
+ }
+ else {
+ raise_error = true;
+ }
}
}
+ else if (value == Py_None) {
+ *((void **)data) = NULL;
+ }
+ else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
+ *((void **)data) = param->ptr.data;
+ }
else {
- /* Data == NULL, assign to RNA. */
- if (value == Py_None || RNA_struct_is_a(param->ptr.type, ptr_type)) {
- ReportList reports;
- BKE_reports_init(&reports, RPT_STORE);
- RNA_property_pointer_set(
- ptr, prop, value == Py_None ? PointerRNA_NULL : param->ptr, &reports);
- int err = (BPy_reports_to_error(&reports, PyExc_RuntimeError, true));
- if (err == -1) {
- Py_XDECREF(value_new);
- return -1;
- }
- }
- else {
- raise_error = true;
+ raise_error = true;
+ }
+ }
+ else {
+ /* Data == NULL, assign to RNA. */
+ if (value == Py_None || RNA_struct_is_a(param->ptr.type, ptr_type)) {
+ ReportList reports;
+ BKE_reports_init(&reports, RPT_STORE);
+ RNA_property_pointer_set(
+ ptr, prop, value == Py_None ? PointerRNA_NULL : param->ptr, &reports);
+ int err = (BPy_reports_to_error(&reports, PyExc_RuntimeError, true));
+ if (err == -1) {
+ Py_XDECREF(value_new);
+ return -1;
}
}
+ else {
+ raise_error = true;
+ }
+ }
- if (raise_error) {
- if (pyrna_struct_validity_check(param) == -1) {
- /* Error set. */
- }
- else {
- PointerRNA tmp;
- RNA_pointer_create(NULL, ptr_type, NULL, &tmp);
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
- error_prefix,
- RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop),
- RNA_struct_identifier(tmp.type),
- RNA_struct_identifier(param->ptr.type));
- }
- Py_XDECREF(value_new);
- return -1;
+ if (raise_error) {
+ if (pyrna_struct_validity_check(param) == -1) {
+ /* Error set. */
}
+ else {
+ PointerRNA tmp;
+ RNA_pointer_create(NULL, ptr_type, NULL, &tmp);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
+ error_prefix,
+ RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop),
+ RNA_struct_identifier(tmp.type),
+ RNA_struct_identifier(param->ptr.type));
+ }
+ Py_XDECREF(value_new);
+ return -1;
}
Py_XDECREF(value_new);
@@ -2295,9 +2291,8 @@ static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self)
if (RNA_property_array_dimension(&self->ptr, self->prop, NULL) > 1) {
return RNA_property_multi_array_length(&self->ptr, self->prop, self->arraydim);
}
- else {
- return RNA_property_array_length(&self->ptr, self->prop);
- }
+
+ return RNA_property_array_length(&self->ptr, self->prop);
}
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self)
@@ -2356,25 +2351,24 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s
if (RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum_abs, &newptr)) {
return pyrna_struct_CreatePyObject(&newptr);
}
- else {
- const int len = RNA_property_collection_length(&self->ptr, self->prop);
- if (keynum_abs >= len) {
- PyErr_Format(PyExc_IndexError,
- "bpy_prop_collection[index]: "
- "index %d out of range, size %d",
- keynum,
- len);
- }
- else {
- PyErr_Format(PyExc_RuntimeError,
- "bpy_prop_collection[index]: internal error, "
- "valid index %d given in %d sized collection, but value not found",
- keynum_abs,
- len);
- }
- return NULL;
+ const int len = RNA_property_collection_length(&self->ptr, self->prop);
+ if (keynum_abs >= len) {
+ PyErr_Format(PyExc_IndexError,
+ "bpy_prop_collection[index]: "
+ "index %d out of range, size %d",
+ keynum,
+ len);
+ }
+ else {
+ PyErr_Format(PyExc_RuntimeError,
+ "bpy_prop_collection[index]: internal error, "
+ "valid index %d given in %d sized collection, but value not found",
+ keynum_abs,
+ len);
}
+
+ return NULL;
}
/* Values type must have been already checked. */
@@ -2473,79 +2467,76 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel
PyTuple_GET_SIZE(key));
return -1;
}
- else if (self->ptr.type != &RNA_BlendData) {
+ if (self->ptr.type != &RNA_BlendData) {
PyErr_Format(PyExc_KeyError,
"%s: is only valid for bpy.data collections, not %.200s",
err_prefix,
RNA_struct_identifier(self->ptr.type));
return -1;
}
- else if ((keyname = _PyUnicode_AsString(PyTuple_GET_ITEM(key, 0))) == NULL) {
+ if ((keyname = _PyUnicode_AsString(PyTuple_GET_ITEM(key, 0))) == NULL) {
PyErr_Format(PyExc_KeyError,
"%s: id must be a string, not %.200s",
err_prefix,
Py_TYPE(PyTuple_GET_ITEM(key, 0))->tp_name);
return -1;
}
- else {
- PyObject *keylib = PyTuple_GET_ITEM(key, 1);
- Library *lib;
- bool found = false;
-
- if (keylib == Py_None) {
- lib = NULL;
- }
- else if (PyUnicode_Check(keylib)) {
- Main *bmain = self->ptr.data;
- const char *keylib_str = _PyUnicode_AsString(keylib);
- lib = BLI_findstring(&bmain->libraries, keylib_str, offsetof(Library, filepath));
- if (lib == NULL) {
- if (err_not_found) {
- PyErr_Format(PyExc_KeyError,
- "%s: lib name '%.240s' "
- "does not reference a valid library",
- err_prefix,
- keylib_str);
- return -1;
- }
- else {
- return 0;
- }
+
+ PyObject *keylib = PyTuple_GET_ITEM(key, 1);
+ Library *lib;
+ bool found = false;
+
+ if (keylib == Py_None) {
+ lib = NULL;
+ }
+ else if (PyUnicode_Check(keylib)) {
+ Main *bmain = self->ptr.data;
+ const char *keylib_str = _PyUnicode_AsString(keylib);
+ lib = BLI_findstring(&bmain->libraries, keylib_str, offsetof(Library, filepath));
+ if (lib == NULL) {
+ if (err_not_found) {
+ PyErr_Format(PyExc_KeyError,
+ "%s: lib name '%.240s' "
+ "does not reference a valid library",
+ err_prefix,
+ keylib_str);
+ return -1;
}
+
+ return 0;
}
- else {
- PyErr_Format(PyExc_KeyError,
- "%s: lib must be a string or None, not %.200s",
- err_prefix,
- Py_TYPE(keylib)->tp_name);
- return -1;
- }
+ }
+ else {
+ PyErr_Format(PyExc_KeyError,
+ "%s: lib must be a string or None, not %.200s",
+ err_prefix,
+ Py_TYPE(keylib)->tp_name);
+ return -1;
+ }
- /* lib is either a valid pointer or NULL,
- * either way can do direct comparison with id.lib */
+ /* lib is either a valid pointer or NULL,
+ * either way can do direct comparison with id.lib */
- RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
- ID *id = itemptr.data; /* Always an ID. */
- if (id->lib == lib && (STREQLEN(keyname, id->name + 2, sizeof(id->name) - 2))) {
- found = true;
- if (r_ptr) {
- *r_ptr = itemptr;
- }
- break;
+ RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
+ ID *id = itemptr.data; /* Always an ID. */
+ if (id->lib == lib && (STREQLEN(keyname, id->name + 2, sizeof(id->name) - 2))) {
+ found = true;
+ if (r_ptr) {
+ *r_ptr = itemptr;
}
+ break;
}
- RNA_PROP_END;
+ }
+ RNA_PROP_END;
- /* We may want to fail silently as with collection.get(). */
- if ((found == false) && err_not_found) {
- /* Only runs for getitem access so use fixed string. */
- PyErr_SetString(PyExc_KeyError, "bpy_prop_collection[key, lib]: not found");
- return -1;
- }
- else {
- return found; /* 1 / 0, no exception. */
- }
+ /* We may want to fail silently as with collection.get(). */
+ if ((found == false) && err_not_found) {
+ /* Only runs for getitem access so use fixed string. */
+ PyErr_SetString(PyExc_KeyError, "bpy_prop_collection[key, lib]: not found");
+ return -1;
}
+
+ return found; /* 1 / 0, no exception. */
}
static PyObject *pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *self,
@@ -2560,9 +2551,8 @@ static PyObject *pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *s
if (contains == 1) {
return pyrna_struct_CreatePyObject(&ptr);
}
- else {
- return NULL;
- }
+
+ return NULL;
}
static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self,
@@ -2707,7 +2697,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
if (PyUnicode_Check(key)) {
return pyrna_prop_collection_subscript_str(self, _PyUnicode_AsString(key));
}
- else if (PyIndex_Check(key)) {
+ if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
if (i == -1 && PyErr_Occurred()) {
return NULL;
@@ -2715,62 +2705,59 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
return pyrna_prop_collection_subscript_int(self, i);
}
- else if (PySlice_Check(key)) {
+ if (PySlice_Check(key)) {
PySliceObject *key_slice = (PySliceObject *)key;
Py_ssize_t step = 1;
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
return NULL;
}
- else if (step != 1) {
+ if (step != 1) {
PyErr_SetString(PyExc_TypeError, "bpy_prop_collection[slice]: slice steps not supported");
return NULL;
}
- else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
+ if (key_slice->start == Py_None && key_slice->stop == Py_None) {
return pyrna_prop_collection_subscript_slice(self, 0, PY_SSIZE_T_MAX);
}
- else {
- Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- /* Avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
- return NULL;
- }
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
- return NULL;
- }
+ Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- if (start < 0 || stop < 0) {
- /* Only get the length for negative values. */
- Py_ssize_t len = (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop);
- if (start < 0) {
- start += len;
- }
- if (stop < 0) {
- stop += len;
- }
- }
+ /* Avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
+ return NULL;
+ }
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
+ return NULL;
+ }
- if (stop - start <= 0) {
- return PyList_New(0);
+ if (start < 0 || stop < 0) {
+ /* Only get the length for negative values. */
+ Py_ssize_t len = (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop);
+ if (start < 0) {
+ start += len;
}
- else {
- return pyrna_prop_collection_subscript_slice(self, start, stop);
+ if (stop < 0) {
+ stop += len;
}
}
+
+ if (stop - start <= 0) {
+ return PyList_New(0);
+ }
+
+ return pyrna_prop_collection_subscript_slice(self, start, stop);
}
- else if (PyTuple_Check(key)) {
+ if (PyTuple_Check(key)) {
/* Special case, for ID datablocks we. */
return pyrna_prop_collection_subscript_str_lib_pair(
self, key, "bpy_prop_collection[id, lib]", true);
}
- else {
- PyErr_Format(PyExc_TypeError,
- "bpy_prop_collection[key]: invalid key, "
- "must be a string or an int, not %.200s",
- Py_TYPE(key)->tp_name);
- return NULL;
- }
+
+ PyErr_Format(PyExc_TypeError,
+ "bpy_prop_collection[key]: invalid key, "
+ "must be a string or an int, not %.200s",
+ Py_TYPE(key)->tp_name);
+ return NULL;
}
/* generic check to see if a PyObject is compatible with a collection
@@ -2786,18 +2773,17 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
"this collection doesn't support None assignment");
return -1;
}
- else {
- return 0; /* None is OK. */
- }
+
+ return 0; /* None is OK. */
}
- else if (BPy_StructRNA_Check(value) == 0) {
+ if (BPy_StructRNA_Check(value) == 0) {
PyErr_Format(PyExc_TypeError,
"bpy_prop_collection[key] = value: invalid, "
"expected a StructRNA type or None, not a %.200s",
Py_TYPE(value)->tp_name);
return -1;
}
- else if ((prop_srna = RNA_property_pointer_type(&self->ptr, self->prop))) {
+ if ((prop_srna = RNA_property_pointer_type(&self->ptr, self->prop))) {
StructRNA *value_srna = ((BPy_StructRNA *)value)->ptr.type;
if (RNA_struct_is_a(value_srna, prop_srna) == 0) {
PyErr_Format(PyExc_TypeError,
@@ -2807,9 +2793,8 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
RNA_struct_identifier(value_srna));
return -1;
}
- else {
- return 0; /* OK, this is the correct type! */
- }
+
+ return 0; /* OK, this is the correct type! */
}
PyErr_Format(PyExc_TypeError,
@@ -2831,7 +2816,7 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
PyErr_SetString(PyExc_TypeError, "del bpy_prop_collection[key]: not supported");
return -1;
}
- else if (pyrna_prop_collection_type_check(self, value) == -1) {
+ if (pyrna_prop_collection_type_check(self, value) == -1) {
return -1; /* Exception is set. */
}
@@ -2895,13 +2880,12 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
}
}
#endif
- else {
- PyErr_Format(PyExc_TypeError,
- "bpy_prop_collection[key]: invalid key, "
- "must be a string or an int, not %.200s",
- Py_TYPE(key)->tp_name);
- return -1;
- }
+
+ PyErr_Format(PyExc_TypeError,
+ "bpy_prop_collection[key]: invalid key, "
+ "must be a string or an int, not %.200s",
+ Py_TYPE(key)->tp_name);
+ return -1;
}
static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject *key)
@@ -2921,43 +2905,40 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
}
return pyrna_prop_array_subscript_int(self, i);
}
- else if (PySlice_Check(key)) {
+ if (PySlice_Check(key)) {
Py_ssize_t step = 1;
PySliceObject *key_slice = (PySliceObject *)key;
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
return NULL;
}
- else if (step != 1) {
+ if (step != 1) {
PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice]: slice steps not supported");
return NULL;
}
- else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
+ if (key_slice->start == Py_None && key_slice->stop == Py_None) {
/* Note: no significant advantage with optimizing [:] slice as with collections,
* but include here for consistency with collection slice func */
Py_ssize_t len = (Py_ssize_t)pyrna_prop_array_length(self);
return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, 0, len, len);
}
- else {
- int len = pyrna_prop_array_length(self);
- Py_ssize_t start, stop, slicelength;
- if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0) {
- return NULL;
- }
+ int len = pyrna_prop_array_length(self);
+ Py_ssize_t start, stop, slicelength;
- if (slicelength <= 0) {
- return PyTuple_New(0);
- }
- else {
- return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, start, stop, len);
- }
+ if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0) {
+ return NULL;
}
+
+ if (slicelength <= 0) {
+ return PyTuple_New(0);
+ }
+
+ return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, start, stop, len);
}
- else {
- PyErr_SetString(PyExc_AttributeError, "bpy_prop_array[key]: invalid key, key must be an int");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_AttributeError, "bpy_prop_array[key]: invalid key, key must be an int");
+ return NULL;
}
/**
@@ -2972,7 +2953,7 @@ static PyObject *prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, in
"element in assignment is not a sequence type"))) {
return NULL;
}
- else if (PySequence_Fast_GET_SIZE(value_fast) != length) {
+ if (PySequence_Fast_GET_SIZE(value_fast) != length) {
Py_DECREF(value_fast);
PyErr_SetString(PyExc_ValueError,
"bpy_prop_array[slice] = value: "
@@ -2980,9 +2961,8 @@ static PyObject *prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, in
return NULL;
}
- else {
- return value_fast;
- }
+
+ return value_fast;
}
static int prop_subscript_ass_array_slice__float_recursive(
@@ -3005,17 +2985,16 @@ static int prop_subscript_ass_array_slice__float_recursive(
}
return index;
}
- else {
- BLI_assert(totdim == 1);
- const float min = range[0], max = range[1];
- int i;
- for (i = 0; i != length; i++) {
- float v = PyFloat_AsDouble(value_items[i]);
- CLAMP(v, min, max);
- value[i] = v;
- }
- return i;
+
+ BLI_assert(totdim == 1);
+ const float min = range[0], max = range[1];
+ int i;
+ for (i = 0; i != length; i++) {
+ float v = PyFloat_AsDouble(value_items[i]);
+ CLAMP(v, min, max);
+ value[i] = v;
}
+ return i;
}
static int prop_subscript_ass_array_slice__int_recursive(
@@ -3038,17 +3017,16 @@ static int prop_subscript_ass_array_slice__int_recursive(
}
return index;
}
- else {
- BLI_assert(totdim == 1);
- const int min = range[0], max = range[1];
- int i;
- for (i = 0; i != length; i++) {
- int v = PyLong_AsLong(value_items[i]);
- CLAMP(v, min, max);
- value[i] = v;
- }
- return i;
+
+ BLI_assert(totdim == 1);
+ const int min = range[0], max = range[1];
+ int i;
+ for (i = 0; i != length; i++) {
+ int v = PyLong_AsLong(value_items[i]);
+ CLAMP(v, min, max);
+ value[i] = v;
}
+ return i;
}
static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items,
@@ -3073,15 +3051,14 @@ static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items
}
return index;
}
- else {
- BLI_assert(totdim == 1);
- int i;
- for (i = 0; i != length; i++) {
- int v = PyLong_AsLong(value_items[i]);
- value[i] = v;
- }
- return i;
+
+ BLI_assert(totdim == 1);
+ int i;
+ for (i = 0; i != length; i++) {
+ int v = PyLong_AsLong(value_items[i]);
+ value[i] = v;
}
+ return i;
}
/* Could call `pyrna_py_to_prop_array_index(self, i, value)` in a loop, but it is slow. */
@@ -3364,23 +3341,21 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
return pyrna_prop_collection_subscript_str_lib_pair_ptr(
self, key, "(id, lib) in bpy_prop_collection", false, NULL);
}
- else {
-
- /* Key in dict style check. */
- const char *keyname = _PyUnicode_AsString(key);
- if (keyname == NULL) {
- PyErr_SetString(PyExc_TypeError,
- "bpy_prop_collection.__contains__: expected a string or a tuple of strings");
- return -1;
- }
+ /* Key in dict style check. */
+ const char *keyname = _PyUnicode_AsString(key);
- if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr)) {
- return 1;
- }
+ if (keyname == NULL) {
+ PyErr_SetString(PyExc_TypeError,
+ "bpy_prop_collection.__contains__: expected a string or a tuple of strings");
+ return -1;
+ }
- return 0;
+ if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr)) {
+ return 1;
}
+
+ return 0;
}
static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
@@ -3821,30 +3796,25 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
path);
return NULL;
}
- else {
- return pyrna_array_index(&r_ptr, r_prop, index);
- }
+
+ return pyrna_array_index(&r_ptr, r_prop, index);
}
- else {
- if (coerce == Py_False) {
- return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
- }
- else {
- return pyrna_prop_to_py(&r_ptr, r_prop);
- }
+
+ if (coerce == Py_False) {
+ return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
}
+
+ return pyrna_prop_to_py(&r_ptr, r_prop);
}
- else {
- return pyrna_struct_CreatePyObject(&r_ptr);
- }
- }
- else {
- PyErr_Format(PyExc_ValueError,
- "%.200s.path_resolve(\"%.200s\") could not be resolved",
- RNA_struct_identifier(self->ptr.type),
- path);
- return NULL;
+
+ return pyrna_struct_CreatePyObject(&r_ptr);
}
+
+ PyErr_Format(PyExc_ValueError,
+ "%.200s.path_resolve(\"%.200s\") could not be resolved",
+ RNA_struct_identifier(self->ptr.type),
+ path);
+ return NULL;
}
PyDoc_STRVAR(pyrna_struct_path_from_id_doc,
@@ -3954,22 +3924,21 @@ static PyObject *pyrna_prop_as_bytes(BPy_PropertyRNA *self)
RNA_property_identifier(self->prop));
return NULL;
}
- else {
- PyObject *ret;
- char buf_fixed[256], *buf;
- int buf_len;
- buf = RNA_property_string_get_alloc(
- &self->ptr, self->prop, buf_fixed, sizeof(buf_fixed), &buf_len);
+ PyObject *ret;
+ char buf_fixed[256], *buf;
+ int buf_len;
- ret = PyBytes_FromStringAndSize(buf, buf_len);
+ buf = RNA_property_string_get_alloc(
+ &self->ptr, self->prop, buf_fixed, sizeof(buf_fixed), &buf_len);
- if (buf_fixed != buf) {
- MEM_freeN(buf);
- }
+ ret = PyBytes_FromStringAndSize(buf, buf_len);
- return ret;
+ if (buf_fixed != buf) {
+ MEM_freeN(buf);
}
+
+ return ret;
}
PyDoc_STRVAR(pyrna_prop_update_doc,
@@ -4478,7 +4447,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
PyErr_SetString(PyExc_AttributeError, "bpy_struct: __setattr__ must be a string");
return -1;
}
- else if (name[0] != '_' && (prop = RNA_struct_find_property(&self->ptr, name))) {
+ if (name[0] != '_' && (prop = RNA_struct_find_property(&self->ptr, name))) {
if (!RNA_property_editable_flag(&self->ptr, prop)) {
PyErr_Format(PyExc_AttributeError,
"bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only",
@@ -4497,22 +4466,21 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
name);
return -1;
}
- else {
- PointerRNA newptr;
- ListBase newlb;
- short newtype;
- int done = CTX_data_get(C, name, &newptr, &newlb, &newtype);
+ PointerRNA newptr;
+ ListBase newlb;
+ short newtype;
- if (done == 1) {
- PyErr_Format(
- PyExc_AttributeError, "bpy_struct: Context property \"%.200s\" is read-only", name);
- BLI_freelistN(&newlb);
- return -1;
- }
+ int done = CTX_data_get(C, name, &newptr, &newlb, &newtype);
+ if (done == 1) {
+ PyErr_Format(
+ PyExc_AttributeError, "bpy_struct: Context property \"%.200s\" is read-only", name);
BLI_freelistN(&newlb);
+ return -1;
}
+
+ BLI_freelistN(&newlb);
}
/* pyrna_py_to_prop sets its own exceptions */
@@ -4523,9 +4491,8 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
}
return pyrna_py_to_prop(&self->ptr, prop, NULL, value, "bpy_struct: item.attr = val:");
}
- else {
- return PyObject_GenericSetAttr((PyObject *)self, pyname, value);
- }
+
+ return PyObject_GenericSetAttr((PyObject *)self, pyname, value);
}
static PyObject *pyrna_prop_dir(BPy_PropertyRNA *self)
@@ -4563,7 +4530,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
PyErr_SetString(PyExc_AttributeError, "bpy_prop_collection: __getattr__ must be a string");
return NULL;
}
- else if (name[0] != '_') {
+ if (name[0] != '_') {
PyObject *ret;
PropertyRNA *prop;
FunctionRNA *func;
@@ -4575,7 +4542,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
return ret;
}
- else if ((func = RNA_struct_find_function(r_ptr.type, name))) {
+ if ((func = RNA_struct_find_function(r_ptr.type, name))) {
PyObject *self_collection = pyrna_struct_CreatePyObject(&r_ptr);
ret = pyrna_func_to_py(&((BPy_DummyPointerRNA *)self_collection)->ptr, func);
Py_DECREF(self_collection);
@@ -4639,11 +4606,11 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam
PyErr_SetString(PyExc_AttributeError, "bpy_prop: __setattr__ must be a string");
return -1;
}
- else if (value == NULL) {
+ if (value == NULL) {
PyErr_SetString(PyExc_AttributeError, "bpy_prop: del not supported");
return -1;
}
- else if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
+ if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
if ((prop = RNA_struct_find_property(&r_ptr, name))) {
/* pyrna_py_to_prop sets its own exceptions. */
return pyrna_py_to_prop(&r_ptr, prop, NULL, value, "BPy_PropertyRNA - Attribute (setattr):");
@@ -4673,9 +4640,8 @@ static PyObject *pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self)
"bpy_prop_collection.add(): not supported for this collection");
return NULL;
}
- else {
- return pyrna_struct_CreatePyObject(&r_ptr);
- }
+
+ return pyrna_struct_CreatePyObject(&r_ptr);
}
static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyObject *value)
@@ -5798,7 +5764,7 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
Py_INCREF(base);
return (PyObject *)base;
}
- else if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) {
+ if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) {
/* this almost never runs, only when using user defined subclasses of built-in object.
* this isn't common since it's NOT related to registerable subclasses. eg:
*
@@ -5826,10 +5792,9 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
type->tp_name);
return NULL;
}
- else {
- PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): expected a single argument");
- return NULL;
- }
+
+ PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): expected a single argument");
+ return NULL;
}
/* only needed for subtyping, so a new class gets a valid BPy_StructRNA
@@ -5845,18 +5810,17 @@ static PyObject *pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *UN
if (type == Py_TYPE(base)) {
return Py_INCREF_RET((PyObject *)base);
}
- else if (PyType_IsSubtype(type, &pyrna_prop_Type)) {
+ if (PyType_IsSubtype(type, &pyrna_prop_Type)) {
BPy_PropertyRNA *ret = (BPy_PropertyRNA *)type->tp_alloc(type, 0);
ret->ptr = base->ptr;
ret->prop = base->prop;
return (PyObject *)ret;
}
- else {
- PyErr_Format(PyExc_TypeError,
- "bpy_prop.__new__(type): type '%.200s' is not a subtype of bpy_prop",
- type->tp_name);
- return NULL;
- }
+
+ PyErr_Format(PyExc_TypeError,
+ "bpy_prop.__new__(type): type '%.200s' is not a subtype of bpy_prop",
+ type->tp_name);
+ return NULL;
}
static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
@@ -6192,9 +6156,8 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
err = -1;
break;
}
- else { /* PyDict_GetItemString wont raise an error. */
- continue;
- }
+ /* PyDict_GetItemString wont raise an error. */
+ continue;
}
#ifdef DEBUG_STRING_FREE
@@ -7131,25 +7094,24 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
- else {
- BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&self->iter.ptr);
+
+ BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&self->iter.ptr);
# ifdef USE_PYRNA_STRUCT_REFERENCE
- if (pyrna) { /* Unlikely, but may fail. */
- if ((PyObject *)pyrna != Py_None) {
- /* hold a reference to the iterator since it may have
- * allocated memory 'pyrna' needs. eg: introspecting dynamic enum's */
- /* TODO, we could have an api call to know if this is
- * needed since most collections don't */
- pyrna_struct_reference_set(pyrna, (PyObject *)self);
- }
+ if (pyrna) { /* Unlikely, but may fail. */
+ if ((PyObject *)pyrna != Py_None) {
+ /* hold a reference to the iterator since it may have
+ * allocated memory 'pyrna' needs. eg: introspecting dynamic enum's */
+ /* TODO, we could have an api call to know if this is
+ * needed since most collections don't */
+ pyrna_struct_reference_set(pyrna, (PyObject *)self);
}
+ }
# endif /* !USE_PYRNA_STRUCT_REFERENCE */
- RNA_property_collection_next(&self->iter);
+ RNA_property_collection_next(&self->iter);
- return (PyObject *)pyrna;
- }
+ return (PyObject *)pyrna;
}
static void pyrna_prop_collection_iter_dealloc(BPy_PropertyCollectionIterRNA *self)
@@ -7413,9 +7375,8 @@ static StructRNA *srna_from_ptr(PointerRNA *ptr)
if (ptr->type == &RNA_Struct) {
return ptr->data;
}
- else {
- return ptr->type;
- }
+
+ return ptr->type;
}
/* Always returns a new ref, be sure to decref when done. */
@@ -7445,15 +7406,14 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
Py_INCREF(pyrna);
return (PyObject *)pyrna;
}
- else {
- /* Existing users will need to use 'type_recast' method. */
- Py_DECREF(pyrna);
- *instance = NULL;
- /* Continue as if no instance was made. */
+
+ /* Existing users will need to use 'type_recast' method. */
+ Py_DECREF(pyrna);
+ *instance = NULL;
+ /* Continue as if no instance was made. */
#if 0 /* No need to assign, will be written to next... */
pyrna = NULL;
#endif
- }
}
{
@@ -7560,9 +7520,8 @@ PyObject *pyrna_id_CreatePyObject(ID *id)
RNA_id_pointer_create(id, &ptr);
return pyrna_struct_CreatePyObject(&ptr);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
@@ -7571,10 +7530,9 @@ bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
*id = ((BPy_StructRNA *)obj)->ptr.owner_id;
return true;
}
- else {
- *id = NULL;
- return false;
- }
+
+ *id = NULL;
+ return false;
}
bool pyrna_id_CheckPyObject(PyObject *obj)
@@ -7869,30 +7827,29 @@ StructRNA *srna_from_self(PyObject *self, const char *error_prefix)
if (self == NULL) {
return NULL;
}
- else if (PyCapsule_CheckExact(self)) {
+ if (PyCapsule_CheckExact(self)) {
return PyCapsule_GetPointer(self, NULL);
}
- else if (PyType_Check(self) == 0) {
+ if (PyType_Check(self) == 0) {
return NULL;
}
- else {
- /* These cases above not errors, they just mean the type was not compatible
- * After this any errors will be raised in the script */
- PyObject *error_type, *error_value, *error_traceback;
- StructRNA *srna;
+ /* These cases above not errors, they just mean the type was not compatible
+ * After this any errors will be raised in the script */
- PyErr_Fetch(&error_type, &error_value, &error_traceback);
- PyErr_Clear();
+ PyObject *error_type, *error_value, *error_traceback;
+ StructRNA *srna;
- srna = pyrna_struct_as_srna(self, false, error_prefix);
+ PyErr_Fetch(&error_type, &error_value, &error_traceback);
+ PyErr_Clear();
- if (!PyErr_Occurred()) {
- PyErr_Restore(error_type, error_value, error_traceback);
- }
+ srna = pyrna_struct_as_srna(self, false, error_prefix);
- return srna;
+ if (!PyErr_Occurred()) {
+ PyErr_Restore(error_type, error_value, error_traceback);
}
+
+ return srna;
}
static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item)
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index fadda9a8002..a2c2171d151 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_RNA_H__
-#define __BPY_RNA_H__
+#pragma once
/* --- bpy build options --- */
#ifdef WITH_PYTHON_SAFETY
@@ -272,5 +271,3 @@ extern BPy_StructRNA *bpy_context_module;
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 8aba2ae8598..ae19f89c348 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -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);
-
- 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);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
- return NULL;
- }
-
- return PyBool_FromLong(result);
+ ID *id = self->ptr.owner_id;
+ ReportList reports;
+ bool result;
+
+ BKE_reports_init(&reports, RPT_STORE);
+
+ 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);
+
+ 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));
+ if (path != path_full) {
+ MEM_freeN((void *)path_full);
+ }
- return PyBool_FromLong(result);
+ 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);
}
diff --git a/source/blender/python/intern/bpy_rna_anim.h b/source/blender/python/intern/bpy_rna_anim.h
index 88537778dde..7c840e616b1 100644
--- a/source/blender/python/intern/bpy_rna_anim.h
+++ b/source/blender/python/intern/bpy_rna_anim.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BPY_RNA_ANIM_H__
-#define __BPY_RNA_ANIM_H__
+#pragma once
/** \file
* \ingroup pythonintern
@@ -38,5 +37,3 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_ANIM_H__ */
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index 1e5b53b819e..66e07d556a6 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -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);
+ if (len * sizeof(float) > sizeof(tmp)) {
+ tmp_arr = PyMem_MALLOC(len * sizeof(float));
+ }
+ else {
+ tmp_arr = tmp;
+ }
- for (i = 0; i < len; i++) {
- if (tmp_arr[i] == value_f) {
- break;
- }
- }
+ RNA_property_float_get_array(ptr, prop, tmp_arr);
- if (tmp_arr != tmp) {
- PyMem_FREE(tmp_arr);
+ for (i = 0; i < len; i++) {
+ if (tmp_arr[i] == value_f) {
+ break;
}
+ }
- return i < len ? 1 : 0;
+ 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);
+ if (len * sizeof(int) > sizeof(tmp)) {
+ tmp_arr = PyMem_MALLOC(len * sizeof(int));
+ }
+ else {
+ tmp_arr = tmp;
+ }
- for (i = 0; i < len; i++) {
- if (tmp_arr[i] == value_i) {
- break;
- }
- }
+ RNA_property_int_get_array(ptr, prop, tmp_arr);
- if (tmp_arr != tmp) {
- PyMem_FREE(tmp_arr);
+ for (i = 0; i < len; i++) {
+ if (tmp_arr[i] == value_i) {
+ break;
}
+ }
- return i < len ? 1 : 0;
+ 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);
+ if (len * sizeof(bool) > sizeof(tmp)) {
+ tmp_arr = PyMem_MALLOC(len * sizeof(bool));
+ }
+ else {
+ tmp_arr = tmp;
+ }
- for (i = 0; i < len; i++) {
- if (tmp_arr[i] == value_i) {
- break;
- }
- }
+ RNA_property_boolean_get_array(ptr, prop, tmp_arr);
- if (tmp_arr != tmp) {
- PyMem_FREE(tmp_arr);
+ for (i = 0; i < len; i++) {
+ if (tmp_arr[i] == value_i) {
+ break;
}
+ }
- return i < len ? 1 : 0;
+ if (tmp_arr != tmp) {
+ PyMem_FREE(tmp_arr);
}
+
+ return i < len ? 1 : 0;
+
break;
}
}
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index f9bcb8943f4..976b8a65ac7 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -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,
- &params.region_type,
- error_prefix) == -1) {
+ if (params.region_type_str && pyrna_enum_value_from_id(rna_enum_region_type_items,
+ params.region_type_str,
+ &params.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, &params.event, error_prefix) == -1) {
return NULL;
}
- else if (pyrna_enum_value_from_id(rna_enum_region_type_items,
- params.region_type_str,
- &params.region_type,
- error_prefix) == -1) {
+ if (pyrna_enum_value_from_id(rna_enum_region_type_items,
+ params.region_type_str,
+ &params.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");
diff --git a/source/blender/python/intern/bpy_rna_callback.h b/source/blender/python/intern/bpy_rna_callback.h
index 67392b60995..ae42c4cb1a4 100644
--- a/source/blender/python/intern/bpy_rna_callback.h
+++ b/source/blender/python/intern/bpy_rna_callback.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BPY_RNA_CALLBACK_H__
-#define __BPY_RNA_CALLBACK_H__
+#pragma once
/** \file
* \ingroup pythonintern
@@ -39,5 +38,3 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *cls, PyObject *args);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_CALLBACK_H__ */
diff --git a/source/blender/python/intern/bpy_rna_driver.h b/source/blender/python/intern/bpy_rna_driver.h
index a534f770732..cc2c4550870 100644
--- a/source/blender/python/intern/bpy_rna_driver.h
+++ b/source/blender/python/intern/bpy_rna_driver.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BPY_RNA_DRIVER_H__
-#define __BPY_RNA_DRIVER_H__
+#pragma once
/** \file
* \ingroup pythonintern
@@ -38,5 +37,3 @@ bool pyrna_driver_is_equal_anim_rna(const struct PathResolvedRNA *anim_rna,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_DRIVER_H__ */
diff --git a/source/blender/python/intern/bpy_rna_gizmo.c b/source/blender/python/intern/bpy_rna_gizmo.c
index aff81c68358..4ef718ef023 100644
--- a/source/blender/python/intern/bpy_rna_gizmo.c
+++ b/source/blender/python/intern/bpy_rna_gizmo.c
@@ -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: {
diff --git a/source/blender/python/intern/bpy_rna_gizmo.h b/source/blender/python/intern/bpy_rna_gizmo.h
index b209dbf4a26..307b694338c 100644
--- a/source/blender/python/intern/bpy_rna_gizmo.h
+++ b/source/blender/python/intern/bpy_rna_gizmo.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_RNA_GIZMO_H__
-#define __BPY_RNA_GIZMO_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ int BPY_rna_gizmo_module(PyObject *);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_GIZMO_H__ */
diff --git a/source/blender/python/intern/bpy_rna_id_collection.h b/source/blender/python/intern/bpy_rna_id_collection.h
index 223ae126323..320a9e66ff8 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.h
+++ b/source/blender/python/intern/bpy_rna_id_collection.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_RNA_ID_COLLECTION_H__
-#define __BPY_RNA_ID_COLLECTION_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -32,5 +31,3 @@ extern PyMethodDef BPY_rna_id_collection_orphans_purge_method_def;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_ID_COLLECTION_H__ */
diff --git a/source/blender/python/intern/bpy_rna_types_capi.h b/source/blender/python/intern/bpy_rna_types_capi.h
index 402dc2c7936..eb8dd14d888 100644
--- a/source/blender/python/intern/bpy_rna_types_capi.h
+++ b/source/blender/python/intern/bpy_rna_types_capi.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_RNA_TYPES_CAPI_H__
-#define __BPY_RNA_TYPES_CAPI_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ void BPY_rna_types_extend_capi(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_TYPES_CAPI_H__ */
diff --git a/source/blender/python/intern/bpy_traceback.h b/source/blender/python/intern/bpy_traceback.h
index cb23dd23c9b..26f6a574439 100644
--- a/source/blender/python/intern/bpy_traceback.h
+++ b/source/blender/python/intern/bpy_traceback.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_TRACEBACK_H__
-#define __BPY_TRACEBACK_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_TRACEBACK_H__ */
diff --git a/source/blender/python/intern/bpy_utils_previews.h b/source/blender/python/intern/bpy_utils_previews.h
index 23fd0216668..dbe74f619a9 100644
--- a/source/blender/python/intern/bpy_utils_previews.h
+++ b/source/blender/python/intern/bpy_utils_previews.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_UTILS_PREVIEWS_H__
-#define __BPY_UTILS_PREVIEWS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_utils_previews_module(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_UTILS_PREVIEWS_H__ */
diff --git a/source/blender/python/intern/bpy_utils_units.h b/source/blender/python/intern/bpy_utils_units.h
index add766d0d93..7a135bc6163 100644
--- a/source/blender/python/intern/bpy_utils_units.h
+++ b/source/blender/python/intern/bpy_utils_units.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_UTILS_UNITS_H__
-#define __BPY_UTILS_UNITS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_utils_units(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_UTILS_UNITS_H__ */