diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp index 24f2bb0ed43..3e25fdeb159 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp @@ -10,12 +10,12 @@ #include "../../stroke/BasicStrokeShaders.h" +#include "../../../../python/generic/py_capi_utils.h" + #ifdef __cplusplus extern "C" { #endif -#include "../../../../python/generic/py_capi_utils.h" - using namespace Freestyle; /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index f3ed7b851a0..f715edbc082 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -57,6 +57,7 @@ typedef enum eReportType { RPT_ERROR_INVALID_CONTEXT = (1 << 7), RPT_ERROR_OUT_OF_MEMORY = (1 << 8), } eReportType; +ENUM_OPERATORS(eReportType, RPT_ERROR_OUT_OF_MEMORY) #define RPT_DEBUG_ALL (RPT_DEBUG) #define RPT_INFO_ALL (RPT_INFO) diff --git a/source/blender/python/BPY_extern_clog.h b/source/blender/python/BPY_extern_clog.h index 4bfc8ffb09c..17c46ea471a 100644 --- a/source/blender/python/BPY_extern_clog.h +++ b/source/blender/python/BPY_extern_clog.h @@ -10,7 +10,15 @@ #pragma once -/* bpy_interface.c */ +#ifdef __cplusplus +extern "C" { +#endif + +/* bpy_interface.cc */ extern struct CLG_LogRef *BPY_LOG_RNA; extern struct CLG_LogRef *BPY_LOG_CONTEXT; + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/python/bmesh/bmesh_py_api.h b/source/blender/python/bmesh/bmesh_py_api.h index 3b990ddc190..5d323de9f61 100644 --- a/source/blender/python/bmesh/bmesh_py_api.h +++ b/source/blender/python/bmesh/bmesh_py_api.h @@ -8,4 +8,12 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + PyObject *BPyInit_bmesh(void); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/python/generic/bgl.h b/source/blender/python/generic/bgl.h index 3c096d4a85e..fd53ee678bf 100644 --- a/source/blender/python/generic/bgl.h +++ b/source/blender/python/generic/bgl.h @@ -8,6 +8,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + PyObject *BPyInit_bgl(void); /** @@ -47,3 +51,7 @@ typedef struct _Buffer { /** The type object. */ extern PyTypeObject BGL_bufferType; + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/python/generic/blf_py_api.h b/source/blender/python/generic/blf_py_api.h index 3104717576d..aca6f9ffa38 100644 --- a/source/blender/python/generic/blf_py_api.h +++ b/source/blender/python/generic/blf_py_api.h @@ -10,4 +10,12 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + PyObject *BPyInit_blf(void); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/python/generic/idprop_py_api.h b/source/blender/python/generic/idprop_py_api.h index 8e9cdaa7287..ff626799b8b 100644 --- a/source/blender/python/generic/idprop_py_api.h +++ b/source/blender/python/generic/idprop_py_api.h @@ -8,6 +8,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + struct BPy_IDGroup_Iter; struct ID; struct IDProperty; @@ -99,3 +103,7 @@ bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *key, struct IDProperty *grou void IDProp_Init_Types(void); PyObject *BPyInit_idprop(void); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/python/generic/idprop_py_ui_api.h b/source/blender/python/generic/idprop_py_ui_api.h index 73fc20a0c03..a30926f6435 100644 --- a/source/blender/python/generic/idprop_py_ui_api.h +++ b/source/blender/python/generic/idprop_py_ui_api.h @@ -8,6 +8,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + struct IDProperty; extern PyTypeObject BPy_IDPropertyUIManager_Type; @@ -18,3 +22,7 @@ typedef struct BPy_IDPropertyUIManager { } BPy_IDPropertyUIManager; void IDPropertyUIData_Init_Types(void); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/python/generic/imbuf_py_api.h b/source/blender/python/generic/imbuf_py_api.h index 7ad18de87fb..92fa5420755 100644 --- a/source/blender/python/generic/imbuf_py_api.h +++ b/source/blender/python/generic/imbuf_py_api.h @@ -8,6 +8,14 @@ * \ingroup pygen */ +#ifdef __cplusplus +extern "C" { +#endif + PyObject *BPyInit_imbuf(void); extern PyTypeObject Py_ImBuf_Type; + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/python/generic/py_capi_rna.h b/source/blender/python/generic/py_capi_rna.h index 164a1145621..02a78b38260 100644 --- a/source/blender/python/generic/py_capi_rna.h +++ b/source/blender/python/generic/py_capi_rna.h @@ -11,6 +11,10 @@ #include "BLI_sys_types.h" +#ifdef __cplusplus +extern "C" { +#endif + struct EnumPropertyItem; /** @@ -76,3 +80,7 @@ int pyrna_enum_value_parse_string(PyObject *o, void *p); * Use with #PyArg_ParseTuple's `O&` formatting. */ int pyrna_enum_bitfield_parse_set(PyObject *o, void *p); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index 20fd31b6438..2206a8a17c9 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -10,13 +10,13 @@ #ifndef __PY_CAPI_UTILS_H__ #define __PY_CAPI_UTILS_H__ +#include "BLI_sys_types.h" +#include "BLI_utildefines_variadic.h" + #ifdef __cplusplus extern "C" { #endif -#include "BLI_sys_types.h" -#include "BLI_utildefines_variadic.h" - /** Useful to print Python objects while debugging. */ void PyC_ObSpit(const char *name, PyObject *var); /** @@ -84,17 +84,6 @@ PyObject *PyC_Tuple_PackArray_I32(const int *array, uint len); PyObject *PyC_Tuple_PackArray_I32FromBool(const int *array, uint len); PyObject *PyC_Tuple_PackArray_Bool(const bool *array, uint len); -#define PyC_Tuple_Pack_F32(...) \ - PyC_Tuple_PackArray_F32(((const float[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) -#define PyC_Tuple_Pack_F64(...) \ - PyC_Tuple_PackArray_F64(((const double[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) -#define PyC_Tuple_Pack_I32(...) \ - PyC_Tuple_PackArray_I32(((const int[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) -#define PyC_Tuple_Pack_I32FromBool(...) \ - PyC_Tuple_PackArray_I32FromBool(((const int[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) -#define PyC_Tuple_Pack_Bool(...) \ - PyC_Tuple_PackArray_Bool(((const bool[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) - PyObject *PyC_Tuple_PackArray_Multi_F32(const float *array, const int dims[], int dims_len); PyObject *PyC_Tuple_PackArray_Multi_F64(const double *array, const int dims[], int dims_len); PyObject *PyC_Tuple_PackArray_Multi_I32(const int *array, const int dims[], int dims_len); @@ -297,4 +286,43 @@ bool PyC_StructFmt_type_is_bool(char format); } #endif +#ifdef __cplusplus +# include "BLI_span.hh" + +inline PyObject *PyC_Tuple_Pack_F32(const blender::Span values) +{ + return PyC_Tuple_PackArray_F32(values.data(), values.size()); +} +inline PyObject *PyC_Tuple_Pack_F64(const blender::Span values) +{ + return PyC_Tuple_PackArray_F64(values.data(), values.size()); +} +inline PyObject *PyC_Tuple_Pack_I32(const blender::Span values) +{ + return PyC_Tuple_PackArray_I32(values.data(), values.size()); +} +inline PyObject *PyC_Tuple_Pack_I32FromBool(const blender::Span values) +{ + return PyC_Tuple_PackArray_I32FromBool(values.data(), values.size()); +} +inline PyObject *PyC_Tuple_Pack_Bool(const blender::Span values) +{ + return PyC_Tuple_PackArray_Bool(values.data(), values.size()); +} + +#else + +# define PyC_Tuple_Pack_F32(...) \ + PyC_Tuple_PackArray_F32(((const float[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) +# define PyC_Tuple_Pack_F64(...) \ + PyC_Tuple_PackArray_F64(((const double[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) +# define PyC_Tuple_Pack_I32(...) \ + PyC_Tuple_PackArray_I32(((const int[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) +# define PyC_Tuple_Pack_I32FromBool(...) \ + PyC_Tuple_PackArray_I32FromBool(((const int[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) +# define PyC_Tuple_Pack_Bool(...) \ + PyC_Tuple_PackArray_Bool(((const bool[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) + +#endif + #endif /* __PY_CAPI_UTILS_H__ */ diff --git a/source/blender/python/gpu/gpu_py_api.h b/source/blender/python/gpu/gpu_py_api.h index 645b88dd7f3..c1e184f66b8 100644 --- a/source/blender/python/gpu/gpu_py_api.h +++ b/source/blender/python/gpu/gpu_py_api.h @@ -8,8 +8,16 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + /* Each type object could have a method for free GPU resources. * However, it is currently of little use. */ // #define BPYGPU_USE_GPUOBJ_FREE_METHOD PyObject *BPyInit_gpu(void); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index f2d316a29a0..138a6dcc83d 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -23,52 +23,52 @@ set(INC_SYS ) set(SRC - bpy.c - bpy_app.c - bpy_app_alembic.c - bpy_app_build_options.c - bpy_app_ffmpeg.c - bpy_app_handlers.c - bpy_app_icons.c - bpy_app_ocio.c - bpy_app_oiio.c - bpy_app_opensubdiv.c - bpy_app_openvdb.c - bpy_app_sdl.c - bpy_app_timers.c - bpy_app_translations.c - bpy_app_usd.c - bpy_capi_utils.c - bpy_driver.c - bpy_gizmo_wrap.c - bpy_interface.c - bpy_interface_atexit.c - bpy_interface_run.c - bpy_intern_string.c - bpy_library_load.c - bpy_library_write.c - bpy_msgbus.c - bpy_operator.c - bpy_operator_wrap.c - bpy_path.c - bpy_props.c - bpy_rna.c - bpy_rna_anim.c - bpy_rna_array.c - bpy_rna_callback.c - bpy_rna_context.c - bpy_rna_data.c - bpy_rna_driver.c - bpy_rna_gizmo.c - bpy_rna_id_collection.c - bpy_rna_operator.c - bpy_rna_text.c - bpy_rna_types_capi.c - bpy_rna_ui.c - bpy_traceback.c - bpy_utils_previews.c - bpy_utils_units.c - stubs.c + bpy.cc + bpy_app.cc + bpy_app_alembic.cc + bpy_app_build_options.cc + bpy_app_ffmpeg.cc + bpy_app_handlers.cc + bpy_app_icons.cc + bpy_app_ocio.cc + bpy_app_oiio.cc + bpy_app_opensubdiv.cc + bpy_app_openvdb.cc + bpy_app_sdl.cc + bpy_app_timers.cc + bpy_app_translations.cc + bpy_app_usd.cc + bpy_capi_utils.cc + bpy_driver.cc + bpy_gizmo_wrap.cc + bpy_interface.cc + bpy_interface_atexit.cc + bpy_interface_run.cc + bpy_intern_string.cc + bpy_library_load.cc + bpy_library_write.cc + bpy_msgbus.cc + bpy_operator.cc + bpy_operator_wrap.cc + bpy_path.cc + bpy_props.cc + bpy_rna.cc + bpy_rna_anim.cc + bpy_rna_array.cc + bpy_rna_callback.cc + bpy_rna_context.cc + bpy_rna_data.cc + bpy_rna_driver.cc + bpy_rna_gizmo.cc + bpy_rna_id_collection.cc + bpy_rna_operator.cc + bpy_rna_text.cc + bpy_rna_types_capi.cc + bpy_rna_ui.cc + bpy_traceback.cc + bpy_utils_previews.cc + bpy_utils_units.cc + stubs.cc bpy.h bpy_app.h diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.cc similarity index 86% rename from source/blender/python/intern/bpy.c rename to source/blender/python/intern/bpy.cc index 19416fffcc3..664a4683841 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.cc @@ -60,7 +60,7 @@ # include "BPy_Freestyle.h" #endif -PyObject *bpy_package_py = NULL; +PyObject *bpy_package_py = nullptr; PyDoc_STRVAR(bpy_script_paths_doc, ".. function:: script_paths()\n" @@ -69,30 +69,30 @@ PyDoc_STRVAR(bpy_script_paths_doc, "\n" " :return: (system, user) strings will be empty when not found.\n" " :rtype: tuple of strings\n"); -static PyObject *bpy_script_paths(PyObject *UNUSED(self)) +static PyObject *bpy_script_paths(PyObject * /*self*/) { PyObject *ret = PyTuple_New(2); PyObject *item; const char *path; - path = BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS, NULL); + path = BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS, nullptr); item = PyC_UnicodeFromBytes(path ? path : ""); - BLI_assert(item != NULL); + BLI_assert(item != nullptr); PyTuple_SET_ITEM(ret, 0, item); - path = BKE_appdir_folder_id(BLENDER_USER_SCRIPTS, NULL); + path = BKE_appdir_folder_id(BLENDER_USER_SCRIPTS, nullptr); item = PyC_UnicodeFromBytes(path ? path : ""); - BLI_assert(item != NULL); + BLI_assert(item != nullptr); PyTuple_SET_ITEM(ret, 1, item); return ret; } static bool bpy_blend_foreach_path_cb(BPathForeachPathData *bpath_data, - char *UNUSED(path_dst), - size_t UNUSED(path_dst_maxncpy), + char * /*path_dst*/, + size_t /*path_dst_maxncpy*/, const char *path_src) { - PyObject *py_list = bpath_data->user_data; + PyObject *py_list = static_cast(bpath_data->user_data); PyList_APPEND(py_list, PyC_UnicodeFromBytes(path_src)); return false; /* Never edits the path. */ } @@ -110,16 +110,16 @@ PyDoc_STRVAR(bpy_blend_paths_doc, " :type local: boolean\n" " :return: path list.\n" " :rtype: list of strings\n"); -static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_blend_paths(PyObject * /*self*/, PyObject *args, PyObject *kw) { - eBPathForeachFlag flag = 0; + eBPathForeachFlag flag = eBPathForeachFlag(0); PyObject *list; bool absolute = false; bool packed = false; bool local = false; - static const char *_keywords[] = {"absolute", "packed", "local", NULL}; + static const char *_keywords[] = {"absolute", "packed", "local", nullptr}; static _PyArg_Parser _parser = { "|$" /* Optional keyword only arguments. */ "O&" /* `absolute` */ @@ -139,7 +139,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec PyC_ParseBool, &local)) { - return NULL; + return nullptr; } if (absolute) { @@ -154,12 +154,12 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec list = PyList_New(0); - BKE_bpath_foreach_path_main(&(BPathForeachPathData){ - .bmain = G_MAIN, - .callback_function = bpy_blend_foreach_path_cb, - .flag = flag, - .user_data = list, - }); + BPathForeachPathData path_data{}; + path_data.bmain = G_MAIN; + path_data.callback_function = bpy_blend_foreach_path_cb; + path_data.flag = flag; + path_data.user_data = list; + BKE_bpath_foreach_path_main(&path_data); return list; } @@ -176,13 +176,13 @@ PyDoc_STRVAR(bpy_flip_name_doc, " :type strip_digits: bool\n" " :return: The flipped name.\n" " :rtype: string\n"); -static PyObject *bpy_flip_name(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_flip_name(PyObject * /*self*/, PyObject *args, PyObject *kw) { - const char *name_src = NULL; + const char *name_src = nullptr; Py_ssize_t name_src_len; bool strip_digits = false; - static const char *_keywords[] = {"", "strip_digits", NULL}; + static const char *_keywords[] = {"", "strip_digits", nullptr}; static _PyArg_Parser _parser = { "s#" /* `name` */ "|$" /* Optional, keyword only arguments. */ @@ -194,13 +194,13 @@ static PyObject *bpy_flip_name(PyObject *UNUSED(self), PyObject *args, PyObject if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &name_src, &name_src_len, PyC_ParseBool, &strip_digits)) { - return NULL; + return nullptr; } /* Worst case we gain one extra byte (besides null-terminator) by changing * "Left" to "Right", because only the first appearance of "Left" gets replaced. */ const size_t size = name_src_len + 2; - char *name_dst = PyMem_MALLOC(size); + char *name_dst = static_cast(PyMem_MALLOC(size)); const size_t name_dst_len = BLI_string_flip_side_name(name_dst, name_src, strip_digits, size); PyObject *result = PyUnicode_FromStringAndSize(name_dst, name_dst_len); @@ -211,22 +211,22 @@ static PyObject *bpy_flip_name(PyObject *UNUSED(self), PyObject *args, PyObject } // PyDoc_STRVAR(bpy_user_resource_doc[] = /* now in bpy/utils.py */ -static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_user_resource(PyObject * /*self*/, PyObject *args, PyObject *kw) { const struct PyC_StringEnumItems type_items[] = { {BLENDER_USER_DATAFILES, "DATAFILES"}, {BLENDER_USER_CONFIG, "CONFIG"}, {BLENDER_USER_SCRIPTS, "SCRIPTS"}, {BLENDER_USER_AUTOSAVE, "AUTOSAVE"}, - {0, NULL}, + {0, nullptr}, }; struct PyC_StringEnum type = {type_items}; - const char *subdir = NULL; + const char *subdir = nullptr; const char *path; - static const char *_keywords[] = {"type", "path", NULL}; + static const char *_keywords[] = {"type", "path", nullptr}; static _PyArg_Parser _parser = { "O&" /* `type` */ "|$" /* Optional keyword only arguments. */ @@ -236,7 +236,7 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj 0, }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, PyC_ParseStringEnum, &type, &subdir)) { - return NULL; + return nullptr; } /* same logic as BKE_appdir_folder_id_create(), @@ -255,21 +255,21 @@ PyDoc_STRVAR(bpy_system_resource_doc, " :type type: string\n" " :arg path: Optional subdirectory.\n" " :type path: string\n"); -static PyObject *bpy_system_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_system_resource(PyObject * /*self*/, PyObject *args, PyObject *kw) { const struct PyC_StringEnumItems type_items[] = { {BLENDER_SYSTEM_DATAFILES, "DATAFILES"}, {BLENDER_SYSTEM_SCRIPTS, "SCRIPTS"}, {BLENDER_SYSTEM_PYTHON, "PYTHON"}, - {0, NULL}, + {0, nullptr}, }; struct PyC_StringEnum type = {type_items}; - const char *subdir = NULL; + const char *subdir = nullptr; const char *path; - static const char *_keywords[] = {"type", "path", NULL}; + static const char *_keywords[] = {"type", "path", nullptr}; static _PyArg_Parser _parser = { "O&" /* `type` */ "|$" /* Optional keyword only arguments. */ @@ -279,7 +279,7 @@ static PyObject *bpy_system_resource(PyObject *UNUSED(self), PyObject *args, PyO 0, }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, PyC_ParseStringEnum, &type, &subdir)) { - return NULL; + return nullptr; } path = BKE_appdir_folder_id(type.value_found, subdir); @@ -301,20 +301,20 @@ PyDoc_STRVAR( " :type minor: string\n" " :return: the resource path (not necessarily existing).\n" " :rtype: string\n"); -static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_resource_path(PyObject * /*self*/, PyObject *args, PyObject *kw) { const struct PyC_StringEnumItems type_items[] = { {BLENDER_RESOURCE_PATH_USER, "USER"}, {BLENDER_RESOURCE_PATH_LOCAL, "LOCAL"}, {BLENDER_RESOURCE_PATH_SYSTEM, "SYSTEM"}, - {0, NULL}, + {0, nullptr}, }; struct PyC_StringEnum type = {type_items}; int major = BLENDER_VERSION / 100, minor = BLENDER_VERSION % 100; const char *path; - static const char *_keywords[] = {"type", "major", "minor", NULL}; + static const char *_keywords[] = {"type", "major", "minor", nullptr}; static _PyArg_Parser _parser = { "O&" /* `type` */ "|$" /* Optional keyword only arguments. */ @@ -327,7 +327,7 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, PyC_ParseStringEnum, &type, &major, &minor)) { - return NULL; + return nullptr; } path = BKE_appdir_resource_path_id_with_version(type.value_found, false, (major * 100) + minor); @@ -349,12 +349,12 @@ PyDoc_STRVAR(bpy_driver_secure_code_test_doc, " :type verbose: bool\n" " :return: True when the script is considered trusted.\n" " :rtype: bool\n"); -static PyObject *bpy_driver_secure_code_test(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_driver_secure_code_test(PyObject * /*self*/, PyObject *args, PyObject *kw) { PyObject *py_code; - PyObject *py_namespace = NULL; + PyObject *py_namespace = nullptr; const bool verbose = false; - static const char *_keywords[] = {"code", "namespace", "verbose", NULL}; + static const char *_keywords[] = {"code", "namespace", "verbose", nullptr}; static _PyArg_Parser _parser = { "O!" /* `expression` */ "|$" /* Optional keyword only arguments. */ @@ -374,7 +374,7 @@ static PyObject *bpy_driver_secure_code_test(PyObject *UNUSED(self), PyObject *a PyC_ParseBool, &verbose)) { - return NULL; + return nullptr; } return PyBool_FromLong(BPY_driver_secure_bytecode_test(py_code, py_namespace, verbose)); } @@ -388,18 +388,18 @@ PyDoc_STRVAR(bpy_escape_identifier_doc, " :type string: string\n" " :return: The escaped string.\n" " :rtype: string\n"); -static PyObject *bpy_escape_identifier(PyObject *UNUSED(self), PyObject *value) +static PyObject *bpy_escape_identifier(PyObject * /*self*/, PyObject *value) { Py_ssize_t value_str_len; const char *value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len); - if (value_str == NULL) { + if (value_str == nullptr) { PyErr_SetString(PyExc_TypeError, "expected a string"); - return NULL; + return nullptr; } const size_t size = (value_str_len * 2) + 1; - char *value_escape_str = PyMem_MALLOC(size); + char *value_escape_str = static_cast(PyMem_MALLOC(size)); const Py_ssize_t value_escape_str_len = BLI_str_escape(value_escape_str, value_str, size); PyObject *value_escape; @@ -426,18 +426,18 @@ PyDoc_STRVAR(bpy_unescape_identifier_doc, " :type string: string\n" " :return: The un-escaped string.\n" " :rtype: string\n"); -static PyObject *bpy_unescape_identifier(PyObject *UNUSED(self), PyObject *value) +static PyObject *bpy_unescape_identifier(PyObject * /*self*/, PyObject *value) { Py_ssize_t value_str_len; const char *value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len); - if (value_str == NULL) { + if (value_str == nullptr) { PyErr_SetString(PyExc_TypeError, "expected a string"); - return NULL; + return nullptr; } const size_t size = value_str_len + 1; - char *value_unescape_str = PyMem_MALLOC(size); + char *value_unescape_str = static_cast(PyMem_MALLOC(size)); const Py_ssize_t value_unescape_str_len = BLI_str_unescape(value_unescape_str, value_str, size); PyObject *value_unescape; @@ -454,6 +454,16 @@ static PyObject *bpy_unescape_identifier(PyObject *UNUSED(self), PyObject *value return value_unescape; } +extern "C" const char *buttons_context_dir[]; +extern "C" const char *clip_context_dir[]; +extern "C" const char *file_context_dir[]; +extern "C" const char *image_context_dir[]; +extern "C" const char *node_context_dir[]; +extern "C" const char *screen_context_dir[]; +extern "C" const char *sequencer_context_dir[]; +extern "C" const char *text_context_dir[]; +extern "C" const char *view3d_context_dir[]; + /** * \note only exposed for generating documentation, see: `doc/python_api/sphinx_doc_gen.py`. */ @@ -463,17 +473,8 @@ PyDoc_STRVAR( "\n" " :return: A dict where the key is the context and the value is a tuple of it's members.\n" " :rtype: dict\n"); -static PyObject *bpy_context_members(PyObject *UNUSED(self)) +static PyObject *bpy_context_members(PyObject * /*self*/) { - extern const char *buttons_context_dir[]; - extern const char *clip_context_dir[]; - extern const char *file_context_dir[]; - extern const char *image_context_dir[]; - extern const char *node_context_dir[]; - extern const char *screen_context_dir[]; - extern const char *sequencer_context_dir[]; - extern const char *text_context_dir[]; - extern const char *view3d_context_dir[]; struct { const char *name; @@ -519,7 +520,7 @@ PyDoc_STRVAR(bpy_rna_enum_items_static_doc, " :return: A dict where the key the name of the enum, the value is a tuple of " ":class:`bpy.types.EnumPropertyItem`.\n" " :rtype: dict of \n"); -static PyObject *bpy_rna_enum_items_static(PyObject *UNUSED(self)) +static PyObject *bpy_rna_enum_items_static(PyObject * /*self*/) { #define DEF_ENUM(id) {STRINGIFY(id), id}, struct { @@ -536,7 +537,7 @@ static PyObject *bpy_rna_enum_items_static(PyObject *UNUSED(self)) PyObject *value = PyTuple_New(items_count); for (int item_index = 0; item_index < items_count; item_index++) { PointerRNA ptr; - RNA_pointer_create(NULL, &RNA_EnumPropertyItem, (void *)&items[item_index], &ptr); + RNA_pointer_create(nullptr, &RNA_EnumPropertyItem, (void *)&items[item_index], &ptr); PyTuple_SET_ITEM(value, item_index, pyrna_struct_CreatePyObject(&ptr)); } PyDict_SetItemString(result, enum_info[i].id, value); @@ -551,7 +552,7 @@ PyDoc_STRVAR(bpy_ghost_backend_doc, "\n" " :return: An identifier for the GHOST back-end.\n" " :rtype: string\n"); -static PyObject *bpy_ghost_backend(PyObject *UNUSED(self)) +static PyObject *bpy_ghost_backend(PyObject * /*self*/) { return PyUnicode_FromString(WM_ghost_backend()); } @@ -563,7 +564,7 @@ static PyMethodDef bpy_methods[] = { METH_VARARGS | METH_KEYWORDS, bpy_blend_paths_doc}, {"flip_name", (PyCFunction)bpy_flip_name, METH_VARARGS | METH_KEYWORDS, bpy_flip_name_doc}, - {"user_resource", (PyCFunction)bpy_user_resource, METH_VARARGS | METH_KEYWORDS, NULL}, + {"user_resource", (PyCFunction)bpy_user_resource, METH_VARARGS | METH_KEYWORDS, nullptr}, {"system_resource", (PyCFunction)bpy_system_resource, METH_VARARGS | METH_KEYWORDS, @@ -590,12 +591,12 @@ static PyMethodDef bpy_methods[] = { bpy_driver_secure_code_test_doc}, {"_ghost_backend", (PyCFunction)bpy_ghost_backend, METH_NOARGS, bpy_ghost_backend_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyObject *bpy_import_test(const char *modname) { - PyObject *mod = PyImport_ImportModuleLevel(modname, NULL, NULL, NULL, 0); + PyObject *mod = PyImport_ImportModuleLevel(modname, nullptr, nullptr, nullptr, 0); GPU_bgl_end(); @@ -661,7 +662,7 @@ void BPy_init_modules(struct bContext *C) PyModule_AddObject(mod, "_utils_previews", BPY_utils_previews_module()); PyModule_AddObject(mod, "msgbus", BPY_msgbus_module()); - RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr); + RNA_pointer_create(nullptr, &RNA_Context, C, &ctx_ptr); bpy_context_module = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ctx_ptr); /* odd that this is needed, 1 ref on creation and another for the module * but without we get a crash on exit */ @@ -676,23 +677,23 @@ void BPy_init_modules(struct bContext *C) PyMethodDef *m = &bpy_methods[i]; /* Currently there is no need to support these. */ BLI_assert((m->ml_flags & (METH_CLASS | METH_STATIC)) == 0); - PyModule_AddObject(mod, m->ml_name, (PyObject *)PyCFunction_New(m, NULL)); + PyModule_AddObject(mod, m->ml_name, (PyObject *)PyCFunction_New(m, nullptr)); } /* Register functions (`bpy_rna.c`). */ PyModule_AddObject(mod, meth_bpy_register_class.ml_name, - (PyObject *)PyCFunction_New(&meth_bpy_register_class, NULL)); + (PyObject *)PyCFunction_New(&meth_bpy_register_class, nullptr)); PyModule_AddObject(mod, meth_bpy_unregister_class.ml_name, - (PyObject *)PyCFunction_New(&meth_bpy_unregister_class, NULL)); + (PyObject *)PyCFunction_New(&meth_bpy_unregister_class, nullptr)); PyModule_AddObject(mod, meth_bpy_owner_id_get.ml_name, - (PyObject *)PyCFunction_New(&meth_bpy_owner_id_get, NULL)); + (PyObject *)PyCFunction_New(&meth_bpy_owner_id_get, nullptr)); PyModule_AddObject(mod, meth_bpy_owner_id_set.ml_name, - (PyObject *)PyCFunction_New(&meth_bpy_owner_id_set, NULL)); + (PyObject *)PyCFunction_New(&meth_bpy_owner_id_set, nullptr)); /* add our own modules dir, this is a python package */ bpy_package_py = bpy_import_test("bpy"); diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.cc similarity index 82% rename from source/blender/python/intern/bpy_app.c rename to source/blender/python/intern/bpy_app.cc index f739e12eefb..fffa9e26254 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.cc @@ -59,19 +59,19 @@ #include "../generic/python_utildefines.h" #ifdef BUILD_DATE -extern char build_date[]; -extern char build_time[]; -extern ulong build_commit_timestamp; -extern char build_commit_date[]; -extern char build_commit_time[]; -extern char build_hash[]; -extern char build_branch[]; -extern char build_platform[]; -extern char build_type[]; -extern char build_cflags[]; -extern char build_cxxflags[]; -extern char build_linkflags[]; -extern char build_system[]; +extern "C" char build_date[]; +extern "C" char build_time[]; +extern "C" ulong build_commit_timestamp; +extern "C" char build_commit_date[]; +extern "C" char build_commit_time[]; +extern "C" char build_hash[]; +extern "C" char build_branch[]; +extern "C" char build_platform[]; +extern "C" char build_type[]; +extern "C" char build_cflags[]; +extern "C" char build_cxxflags[]; +extern "C" char build_linkflags[]; +extern "C" char build_system[]; #endif static PyTypeObject BlenderAppType; @@ -119,7 +119,7 @@ static PyStructSequence_Field app_info_fields[] = { /* Modules (not struct sequence). */ {"icons", "Manage custom icons"}, {"timers", "Manage timers"}, - {NULL}, + {nullptr}, }; PyDoc_STRVAR(bpy_app_doc, @@ -138,8 +138,8 @@ static PyObject *make_app_info(void) int pos = 0; app_info = PyStructSequence_New(&BlenderAppType); - if (app_info == NULL) { - return NULL; + if (app_info == nullptr) { + return nullptr; } #define SetIntItem(flag) PyStructSequence_SET_ITEM(app_info, pos++, PyLong_FromLong(flag)) #define SetStrItem(str) PyStructSequence_SET_ITEM(app_info, pos++, PyUnicode_FromString(str)) @@ -147,17 +147,17 @@ static PyObject *make_app_info(void) #define SetObjItem(obj) PyStructSequence_SET_ITEM(app_info, pos++, obj) SetObjItem( - PyC_Tuple_Pack_I32(BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_VERSION_PATCH)); + PyC_Tuple_Pack_I32({BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_VERSION_PATCH})); SetObjItem(PyC_Tuple_Pack_I32( - BLENDER_FILE_VERSION / 100, BLENDER_FILE_VERSION % 100, BLENDER_FILE_SUBVERSION)); + {BLENDER_FILE_VERSION / 100, BLENDER_FILE_VERSION % 100, BLENDER_FILE_SUBVERSION})); SetStrItem(BKE_blender_version_string()); SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE)); SetObjItem(PyBool_FromLong(G.background)); SetObjItem(PyBool_FromLong(G.factory_startup)); - /* build info, use bytes since we can't assume _any_ encoding: - * see patch #30154 for issue */ +/* build info, use bytes since we can't assume _any_ encoding: + * see patch #30154 for issue */ #ifdef BUILD_DATE SetBytesItem(build_date); SetBytesItem(build_time); @@ -211,7 +211,7 @@ static PyObject *make_app_info(void) if (PyErr_Occurred()) { Py_DECREF(app_info); - return NULL; + return nullptr; } return app_info; } @@ -222,13 +222,13 @@ static PyObject *make_app_info(void) PyDoc_STRVAR( bpy_app_debug_doc, "Boolean, for debug info (started with --debug / --debug_* matching this attribute name)"); -static PyObject *bpy_app_debug_get(PyObject *UNUSED(self), void *closure) +static PyObject *bpy_app_debug_get(PyObject * /*self*/, void *closure) { const int flag = POINTER_AS_INT(closure); return PyBool_FromLong(G.debug & flag); } -static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *closure) +static int bpy_app_debug_set(PyObject * /*self*/, PyObject *value, void *closure) { const int flag = POINTER_AS_INT(closure); const int param = PyObject_IsTrue(value); @@ -251,13 +251,13 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *clos PyDoc_STRVAR( bpy_app_global_flag_doc, "Boolean, for application behavior (started with --enable-* matching this attribute name)"); -static PyObject *bpy_app_global_flag_get(PyObject *UNUSED(self), void *closure) +static PyObject *bpy_app_global_flag_get(PyObject * /*self*/, void *closure) { const int flag = POINTER_AS_INT(closure); return PyBool_FromLong(G.f & flag); } -static int bpy_app_global_flag_set(PyObject *UNUSED(self), PyObject *value, void *closure) +static int bpy_app_global_flag_set(PyObject * /*self*/, PyObject *value, void *closure) { const int flag = POINTER_AS_INT(closure); const int param = PyObject_IsTrue(value); @@ -277,7 +277,7 @@ static int bpy_app_global_flag_set(PyObject *UNUSED(self), PyObject *value, void return 0; } -static int bpy_app_global_flag_set__only_disable(PyObject *UNUSED(self), +static int bpy_app_global_flag_set__only_disable(PyObject * /*self*/, PyObject *value, void *closure) { @@ -286,17 +286,17 @@ static int bpy_app_global_flag_set__only_disable(PyObject *UNUSED(self), PyErr_SetString(PyExc_ValueError, "This bpy.app.use_* option can only be disabled"); return -1; } - return bpy_app_global_flag_set(NULL, value, closure); + return bpy_app_global_flag_set(nullptr, value, closure); } PyDoc_STRVAR(bpy_app_debug_value_doc, "Short, number which can be set to non-zero values for testing purposes"); -static PyObject *bpy_app_debug_value_get(PyObject *UNUSED(self), void *UNUSED(closure)) +static PyObject *bpy_app_debug_value_get(PyObject * /*self*/, void * /*closure*/) { return PyLong_FromLong(G.debug_value); } -static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void *UNUSED(closure)) +static int bpy_app_debug_value_set(PyObject * /*self*/, PyObject *value, void * /*closure*/) { const short param = PyC_Long_AsI16(value); @@ -308,13 +308,13 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void G.debug_value = param; - WM_main_add_notifier(NC_WINDOW, NULL); + WM_main_add_notifier(NC_WINDOW, nullptr); return 0; } PyDoc_STRVAR(bpy_app_tempdir_doc, "String, the temp directory used by blender (read-only)"); -static PyObject *bpy_app_tempdir_get(PyObject *UNUSED(self), void *UNUSED(closure)) +static PyObject *bpy_app_tempdir_get(PyObject * /*self*/, void * /*closure*/) { return PyC_UnicodeFromBytes(BKE_tempdir_session()); } @@ -322,12 +322,12 @@ static PyObject *bpy_app_tempdir_get(PyObject *UNUSED(self), void *UNUSED(closur PyDoc_STRVAR( bpy_app_driver_dict_doc, "Dictionary for drivers namespace, editable in-place, reset on file load (read-only)"); -static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(closure)) +static PyObject *bpy_app_driver_dict_get(PyObject * /*self*/, void * /*closure*/) { - if (bpy_pydriver_Dict == NULL) { + if (bpy_pydriver_Dict == nullptr) { if (bpy_pydriver_create_dict() != 0) { PyErr_SetString(PyExc_RuntimeError, "bpy.app.driver_namespace failed to create dictionary"); - return NULL; + return nullptr; } } @@ -336,12 +336,13 @@ static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(cl PyDoc_STRVAR(bpy_app_preview_render_size_doc, "Reference size for icon/preview renders (read-only)"); -static PyObject *bpy_app_preview_render_size_get(PyObject *UNUSED(self), void *closure) +static PyObject *bpy_app_preview_render_size_get(PyObject * /*self*/, void *closure) { - return PyLong_FromLong((long)UI_icon_preview_to_render_size(POINTER_AS_INT(closure))); + return PyLong_FromLong( + (long)UI_icon_preview_to_render_size(eIconSizes(POINTER_AS_INT(closure)))); } -static PyObject *bpy_app_autoexec_fail_message_get(PyObject *UNUSED(self), void *UNUSED(closure)) +static PyObject *bpy_app_autoexec_fail_message_get(PyObject * /*self*/, void * /*closure*/) { return PyC_UnicodeFromBytes(G.autoexec_fail); } @@ -350,21 +351,21 @@ PyDoc_STRVAR(bpy_app_binary_path_doc, "The location of Blender's executable, useful for utilities that open new instances. " "Read-only unless Blender is built as a Python module - in this case the value is " "an empty string which script authors may point to a Blender binary."); -static PyObject *bpy_app_binary_path_get(PyObject *UNUSED(self), void *UNUSED(closure)) +static PyObject *bpy_app_binary_path_get(PyObject * /*self*/, void * /*closure*/) { return PyC_UnicodeFromBytes(BKE_appdir_program_path()); } -static int bpy_app_binary_path_set(PyObject *UNUSED(self), PyObject *value, void *UNUSED(closure)) +static int bpy_app_binary_path_set(PyObject * /*self*/, PyObject *value, void * /*closure*/) { #ifndef WITH_PYTHON_MODULE PyErr_SetString(PyExc_AttributeError, "bpy.app.binary_path is only writable when built as a Python module"); return -1; #endif - PyObject *value_coerce = NULL; + PyObject *value_coerce = nullptr; const char *filepath = PyC_UnicodeAsBytes(value, &value_coerce); - if (filepath == NULL) { + if (filepath == nullptr) { PyErr_Format(PyExc_ValueError, "expected a string or bytes, got %s", Py_TYPE(value)->tp_name); return -1; } @@ -454,29 +455,33 @@ static PyGetSetDef bpy_app_getsets[] = { bpy_app_debug_value_get, bpy_app_debug_value_set, bpy_app_debug_value_doc, - NULL}, - {"tempdir", bpy_app_tempdir_get, NULL, bpy_app_tempdir_doc, NULL}, - {"driver_namespace", bpy_app_driver_dict_get, NULL, bpy_app_driver_dict_doc, NULL}, + nullptr}, + {"tempdir", bpy_app_tempdir_get, nullptr, bpy_app_tempdir_doc, nullptr}, + {"driver_namespace", bpy_app_driver_dict_get, nullptr, bpy_app_driver_dict_doc, nullptr}, {"render_icon_size", bpy_app_preview_render_size_get, - NULL, + nullptr, bpy_app_preview_render_size_doc, (void *)ICON_SIZE_ICON}, {"render_preview_size", bpy_app_preview_render_size_get, - NULL, + nullptr, bpy_app_preview_render_size_doc, (void *)ICON_SIZE_PREVIEW}, /* security */ - {"autoexec_fail", bpy_app_global_flag_get, NULL, NULL, (void *)G_FLAG_SCRIPT_AUTOEXEC_FAIL}, + {"autoexec_fail", + bpy_app_global_flag_get, + nullptr, + nullptr, + (void *)G_FLAG_SCRIPT_AUTOEXEC_FAIL}, {"autoexec_fail_quiet", bpy_app_global_flag_get, - NULL, - NULL, + nullptr, + nullptr, (void *)G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET}, - {"autoexec_fail_message", bpy_app_autoexec_fail_message_get, NULL, NULL, NULL}, + {"autoexec_fail_message", bpy_app_autoexec_fail_message_get, nullptr, nullptr, nullptr}, /* Support script authors setting the Blender binary path to use, otherwise this value * is not known when built as a Python module. */ @@ -484,9 +489,9 @@ static PyGetSetDef bpy_app_getsets[] = { bpy_app_binary_path_get, bpy_app_binary_path_set, bpy_app_binary_path_doc, - NULL}, + nullptr}, - {NULL, NULL, NULL, NULL, NULL}, + {nullptr, nullptr, nullptr, nullptr, nullptr}, }; PyDoc_STRVAR(bpy_app_is_job_running_doc, @@ -498,13 +503,13 @@ PyDoc_STRVAR(bpy_app_is_job_running_doc, " :type job_type: str\n" " :return: Whether a job of the given type is currently running.\n" " :rtype: bool.\n"); -static PyObject *bpy_app_is_job_running(PyObject *UNUSED(self), PyObject *args, PyObject *kwds) +static PyObject *bpy_app_is_job_running(PyObject * /*self*/, PyObject *args, PyObject *kwds) { - struct BPy_EnumProperty_Parse job_type_enum = { - .items = rna_enum_wm_job_type_items, - .value = 0, - }; - static const char *_keywords[] = {"job_type", NULL}; + BPy_EnumProperty_Parse job_type_enum{}; + job_type_enum.items = rna_enum_wm_job_type_items; + job_type_enum.value = 0; + + static const char *_keywords[] = {"job_type", nullptr}; static _PyArg_Parser _parser = { "O&" /* `job_type` */ ":is_job_running", @@ -514,13 +519,13 @@ static PyObject *bpy_app_is_job_running(PyObject *UNUSED(self), PyObject *args, if (!_PyArg_ParseTupleAndKeywordsFast( args, kwds, &_parser, pyrna_enum_value_parse_string, &job_type_enum)) { - return NULL; + return nullptr; } - wmWindowManager *wm = G_MAIN->wm.first; + wmWindowManager *wm = static_cast(G_MAIN->wm.first); return PyBool_FromLong(WM_jobs_has_running_type(wm, job_type_enum.value)); } -char *(*BPY_python_app_help_text_fn)(bool all) = NULL; +char *(*BPY_python_app_help_text_fn)(bool all) = nullptr; PyDoc_STRVAR(bpy_app_help_text_doc, ".. staticmethod:: help_text(all=False)\n" @@ -530,10 +535,10 @@ PyDoc_STRVAR(bpy_app_help_text_doc, " :arg all: Return all arguments, " "even those which aren't available for the current platform.\n" " :type all: bool\n"); -static PyObject *bpy_app_help_text(PyObject *UNUSED(self), PyObject *args, PyObject *kwds) +static PyObject *bpy_app_help_text(PyObject * /*self*/, PyObject *args, PyObject *kwds) { bool all = false; - static const char *_keywords[] = {"all", NULL}; + static const char *_keywords[] = {"all", nullptr}; static _PyArg_Parser _parser = { "|$" /* Optional keyword only arguments. */ "O&" /* `all` */ @@ -542,7 +547,7 @@ static PyObject *bpy_app_help_text(PyObject *UNUSED(self), PyObject *args, PyObj 0, }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, PyC_ParseBool, &all)) { - return NULL; + return nullptr; } char *buf = BPY_python_app_help_text_fn(all); @@ -560,7 +565,7 @@ static PyMethodDef bpy_app_methods[] = { (PyCFunction)bpy_app_help_text, METH_VARARGS | METH_KEYWORDS | METH_STATIC, bpy_app_help_text_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static void py_struct_seq_getset_init(void) @@ -577,7 +582,7 @@ static void py_struct_seq_method_init(void) { for (PyMethodDef *method = bpy_app_methods; method->ml_name; method++) { BLI_assert_msg(method->ml_flags & METH_STATIC, "Only static methods make sense for 'bpy.app'"); - PyObject *item = PyCFunction_New(method, NULL); + PyObject *item = PyCFunction_New(method, nullptr); PyDict_SetItemString(BlenderAppType.tp_dict, method->ml_name, item); Py_DECREF(item); } @@ -594,8 +599,8 @@ PyObject *BPY_app_struct(void) ret = make_app_info(); /* prevent user from creating new instances */ - BlenderAppType.tp_init = NULL; - BlenderAppType.tp_new = NULL; + BlenderAppType.tp_init = nullptr; + BlenderAppType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppType.tp_hash = (hashfunc)_Py_HashPointer; diff --git a/source/blender/python/intern/bpy_app_alembic.c b/source/blender/python/intern/bpy_app_alembic.cc similarity index 91% rename from source/blender/python/intern/bpy_app_alembic.c rename to source/blender/python/intern/bpy_app_alembic.cc index 6e47a3b78a4..36980aff0cb 100644 --- a/source/blender/python/intern/bpy_app_alembic.c +++ b/source/blender/python/intern/bpy_app_alembic.cc @@ -23,7 +23,7 @@ static PyStructSequence_Field app_alembic_info_fields[] = { {"supported", "Boolean, True when Blender is built with Alembic support"}, {"version", "The Alembic version as a tuple of 3 numbers"}, {"version_string", "The Alembic version formatted as a string"}, - {NULL}, + {nullptr}, }; static PyStructSequence_Desc app_alembic_info_desc = { @@ -37,8 +37,8 @@ static PyObject *make_alembic_info(void) { PyObject *alembic_info = PyStructSequence_New(&BlenderAppABCType); - if (alembic_info == NULL) { - return NULL; + if (alembic_info == nullptr) { + return nullptr; } int pos = 0; @@ -56,7 +56,7 @@ static PyObject *make_alembic_info(void) const int patch = curversion - ((curversion / 100) * 100); SetObjItem(PyBool_FromLong(1)); - SetObjItem(PyC_Tuple_Pack_I32(major, minor, patch)); + SetObjItem(PyC_Tuple_Pack_I32({major, minor, patch})); SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d", major, minor, patch)); #else SetObjItem(PyBool_FromLong(0)); @@ -66,7 +66,7 @@ static PyObject *make_alembic_info(void) if (UNLIKELY(PyErr_Occurred())) { Py_DECREF(alembic_info); - return NULL; + return nullptr; } #undef SetStrItem @@ -82,8 +82,8 @@ PyObject *BPY_app_alembic_struct(void) PyObject *ret = make_alembic_info(); /* prevent user from creating new instances */ - BlenderAppABCType.tp_init = NULL; - BlenderAppABCType.tp_new = NULL; + BlenderAppABCType.tp_init = nullptr; + BlenderAppABCType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppABCType.tp_hash = (hashfunc)_Py_HashPointer; diff --git a/source/blender/python/intern/bpy_app_build_options.c b/source/blender/python/intern/bpy_app_build_options.cc similarity index 78% rename from source/blender/python/intern/bpy_app_build_options.c rename to source/blender/python/intern/bpy_app_build_options.cc index 0dc1861fea7..1412b8279f8 100644 --- a/source/blender/python/intern/bpy_app_build_options.c +++ b/source/blender/python/intern/bpy_app_build_options.cc @@ -16,51 +16,51 @@ static PyTypeObject BlenderAppBuildOptionsType; static PyStructSequence_Field app_builtopts_info_fields[] = { /* names mostly follow CMake options, lowercase, after `WITH_` */ - {"bullet", NULL}, - {"codec_avi", NULL}, - {"codec_ffmpeg", NULL}, - {"codec_sndfile", NULL}, - {"compositor_cpu", NULL}, - {"cycles", NULL}, - {"cycles_osl", NULL}, - {"freestyle", NULL}, - {"image_cineon", NULL}, - {"image_dds", NULL}, - {"image_hdr", NULL}, - {"image_openexr", NULL}, - {"image_openjpeg", NULL}, - {"image_tiff", NULL}, - {"input_ndof", NULL}, - {"audaspace", NULL}, - {"international", NULL}, - {"openal", NULL}, - {"opensubdiv", NULL}, - {"sdl", NULL}, - {"sdl_dynload", NULL}, - {"coreaudio", NULL}, - {"jack", NULL}, - {"pulseaudio", NULL}, - {"wasapi", NULL}, - {"libmv", NULL}, - {"mod_oceansim", NULL}, - {"mod_remesh", NULL}, - {"collada", NULL}, - {"io_wavefront_obj", NULL}, - {"io_ply", NULL}, - {"io_stl", NULL}, - {"io_gpencil", NULL}, - {"opencolorio", NULL}, - {"openmp", NULL}, - {"openvdb", NULL}, - {"alembic", NULL}, - {"usd", NULL}, - {"fluid", NULL}, - {"xr_openxr", NULL}, - {"potrace", NULL}, - {"pugixml", NULL}, - {"haru", NULL}, + {"bullet", nullptr}, + {"codec_avi", nullptr}, + {"codec_ffmpeg", nullptr}, + {"codec_sndfile", nullptr}, + {"compositor_cpu", nullptr}, + {"cycles", nullptr}, + {"cycles_osl", nullptr}, + {"freestyle", nullptr}, + {"image_cineon", nullptr}, + {"image_dds", nullptr}, + {"image_hdr", nullptr}, + {"image_openexr", nullptr}, + {"image_openjpeg", nullptr}, + {"image_tiff", nullptr}, + {"input_ndof", nullptr}, + {"audaspace", nullptr}, + {"international", nullptr}, + {"openal", nullptr}, + {"opensubdiv", nullptr}, + {"sdl", nullptr}, + {"sdl_dynload", nullptr}, + {"coreaudio", nullptr}, + {"jack", nullptr}, + {"pulseaudio", nullptr}, + {"wasapi", nullptr}, + {"libmv", nullptr}, + {"mod_oceansim", nullptr}, + {"mod_remesh", nullptr}, + {"collada", nullptr}, + {"io_wavefront_obj", nullptr}, + {"io_ply", nullptr}, + {"io_stl", nullptr}, + {"io_gpencil", nullptr}, + {"opencolorio", nullptr}, + {"openmp", nullptr}, + {"openvdb", nullptr}, + {"alembic", nullptr}, + {"usd", nullptr}, + {"fluid", nullptr}, + {"xr_openxr", nullptr}, + {"potrace", nullptr}, + {"pugixml", nullptr}, + {"haru", nullptr}, /* Sentinel (this line prevents `clang-format` wrapping into columns). */ - {NULL}, + {nullptr}, }; static PyStructSequence_Desc app_builtopts_info_desc = { @@ -76,8 +76,8 @@ static PyObject *make_builtopts_info(void) int pos = 0; builtopts_info = PyStructSequence_New(&BlenderAppBuildOptionsType); - if (builtopts_info == NULL) { - return NULL; + if (builtopts_info == nullptr) { + return nullptr; } #define SetObjIncref(item) \ @@ -346,8 +346,8 @@ PyObject *BPY_app_build_options_struct(void) ret = make_builtopts_info(); /* prevent user from creating new instances */ - BlenderAppBuildOptionsType.tp_init = NULL; - BlenderAppBuildOptionsType.tp_new = NULL; + BlenderAppBuildOptionsType.tp_init = nullptr; + BlenderAppBuildOptionsType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppBuildOptionsType.tp_hash = (hashfunc)_Py_HashPointer; diff --git a/source/blender/python/intern/bpy_app_ffmpeg.c b/source/blender/python/intern/bpy_app_ffmpeg.cc similarity index 91% rename from source/blender/python/intern/bpy_app_ffmpeg.c rename to source/blender/python/intern/bpy_app_ffmpeg.cc index d1d48db8dd5..0929ceac2c9 100644 --- a/source/blender/python/intern/bpy_app_ffmpeg.c +++ b/source/blender/python/intern/bpy_app_ffmpeg.cc @@ -14,11 +14,13 @@ #include "../generic/py_capi_utils.h" #ifdef WITH_FFMPEG +extern "C" { # include # include # include # include # include +} #endif static PyTypeObject BlenderAppFFmpegType; @@ -37,7 +39,7 @@ static PyStructSequence_Field app_ffmpeg_info_fields[] = { DEF_FFMPEG_LIB_VERSION(avformat), DEF_FFMPEG_LIB_VERSION(avutil), DEF_FFMPEG_LIB_VERSION(swscale), - {NULL}, + {nullptr}, }; #undef DEF_FFMPEG_LIB_VERSION @@ -59,8 +61,8 @@ static PyObject *make_ffmpeg_info(void) #endif ffmpeg_info = PyStructSequence_New(&BlenderAppFFmpegType); - if (ffmpeg_info == NULL) { - return NULL; + if (ffmpeg_info == nullptr) { + return nullptr; } #if 0 /* UNUSED */ @@ -76,7 +78,7 @@ static PyObject *make_ffmpeg_info(void) { \ curversion = lib##_version(); \ SetObjItem( \ - PyC_Tuple_Pack_I32(curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \ + PyC_Tuple_Pack_I32({curversion >> 16, (curversion >> 8) % 256, curversion % 256})); \ SetObjItem(PyUnicode_FromFormat( \ "%2d, %2d, %2d", curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \ } \ @@ -106,7 +108,7 @@ static PyObject *make_ffmpeg_info(void) if (UNLIKELY(PyErr_Occurred())) { Py_DECREF(ffmpeg_info); - return NULL; + return nullptr; } // #undef SetIntItem @@ -125,8 +127,8 @@ PyObject *BPY_app_ffmpeg_struct(void) ret = make_ffmpeg_info(); /* prevent user from creating new instances */ - BlenderAppFFmpegType.tp_init = NULL; - BlenderAppFFmpegType.tp_new = NULL; + BlenderAppFFmpegType.tp_init = nullptr; + BlenderAppFFmpegType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppFFmpegType.tp_hash = (hashfunc)_Py_HashPointer; diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.cc similarity index 83% rename from source/blender/python/intern/bpy_app_handlers.c rename to source/blender/python/intern/bpy_app_handlers.cc index db869555ba0..da51c54c8f3 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.cc @@ -96,7 +96,7 @@ static PyStructSequence_Field app_cb_info_fields[] = { {"persistent", "Function decorator for callback functions not to be removed when loading new files"}, - {NULL}, + {nullptr}, }; static PyStructSequence_Desc app_cb_info_desc = { @@ -118,27 +118,27 @@ static PyStructSequence_Desc app_cb_info_desc = { #define PERMINENT_CB_ID "_bpy_persistent" -static PyObject *bpy_app_handlers_persistent_new(PyTypeObject *UNUSED(type), +static PyObject *bpy_app_handlers_persistent_new(PyTypeObject * /*type*/, PyObject *args, - PyObject *UNUSED(kwds)) + PyObject * /*kwds*/) { PyObject *value; if (!PyArg_ParseTuple(args, "O:bpy.app.handlers.persistent", &value)) { - return NULL; + return nullptr; } if (PyFunction_Check(value)) { PyObject **dict_ptr = _PyObject_GetDictPtr(value); - if (dict_ptr == NULL) { + if (dict_ptr == nullptr) { PyErr_SetString(PyExc_ValueError, "bpy.app.handlers.persistent wasn't able to " "get the dictionary from the function passed"); - return NULL; + return nullptr; } /* set id */ - if (*dict_ptr == NULL) { + if (*dict_ptr == nullptr) { *dict_ptr = PyDict_New(); } @@ -149,69 +149,69 @@ static PyObject *bpy_app_handlers_persistent_new(PyTypeObject *UNUSED(type), } PyErr_SetString(PyExc_ValueError, "bpy.app.handlers.persistent expected a function"); - return NULL; + return nullptr; } /** Dummy type because decorators can't be a #PyCFunction. */ static PyTypeObject BPyPersistent_Type = { #if defined(_MSC_VER) - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) #else /*ob_base*/ PyVarObject_HEAD_INIT(&PyType_Type, 0) #endif /*tp_name*/ "persistent", /*tp_basicsize*/ 0, /*tp_itemsize*/ 0, - /*tp_dealloc*/ NULL, + /*tp_dealloc*/ nullptr, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, - /*tp_repr*/ NULL, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, + /*tp_repr*/ nullptr, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - /*tp_doc*/ NULL, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_doc*/ nullptr, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, - /*tp_methods*/ NULL, - /*tp_members*/ NULL, - /*tp_getset*/ NULL, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, + /*tp_methods*/ nullptr, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, /*tp_new*/ bpy_app_handlers_persistent_new, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; /** \} */ -static PyObject *py_cb_array[BKE_CB_EVT_TOT] = {NULL}; +static PyObject *py_cb_array[BKE_CB_EVT_TOT] = {nullptr}; static PyObject *make_app_cb_info(void) { @@ -219,17 +219,17 @@ static PyObject *make_app_cb_info(void) int pos; app_cb_info = PyStructSequence_New(&BlenderAppCbType); - if (app_cb_info == NULL) { - return NULL; + if (app_cb_info == nullptr) { + return nullptr; } for (pos = 0; pos < BKE_CB_EVT_TOT; pos++) { - if (app_cb_info_fields[pos].name == NULL) { + if (app_cb_info_fields[pos].name == nullptr) { Py_FatalError("invalid callback slots 1"); } PyStructSequence_SET_ITEM(app_cb_info, pos, (py_cb_array[pos] = PyList_New(0))); } - if (app_cb_info_fields[pos + APP_CB_OTHER_FIELDS].name != NULL) { + if (app_cb_info_fields[pos + APP_CB_OTHER_FIELDS].name != nullptr) { Py_FatalError("invalid callback slots 2"); } @@ -256,14 +256,14 @@ PyObject *BPY_app_handlers_struct(void) ret = make_app_cb_info(); /* prevent user from creating new instances */ - BlenderAppCbType.tp_init = NULL; - BlenderAppCbType.tp_new = NULL; + BlenderAppCbType.tp_init = nullptr; + BlenderAppCbType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppCbType.tp_hash = (hashfunc)_Py_HashPointer; /* assign the C callbacks */ if (ret) { - static bCallbackFuncStore funcstore_array[BKE_CB_EVT_TOT] = {{NULL}}; + static bCallbackFuncStore funcstore_array[BKE_CB_EVT_TOT] = {{nullptr}}; bCallbackFuncStore *funcstore; int pos = 0; @@ -272,7 +272,7 @@ PyObject *BPY_app_handlers_struct(void) funcstore->func = bpy_app_generic_callback; funcstore->alloc = 0; funcstore->arg = POINTER_FROM_INT(pos); - BKE_callback_add(funcstore, pos); + BKE_callback_add(funcstore, eCbEvent(pos)); } } @@ -289,7 +289,7 @@ void BPY_app_handlers_reset(const bool do_all) if (do_all) { for (pos = 0; pos < BKE_CB_EVT_TOT; pos++) { /* clear list */ - PyList_SetSlice(py_cb_array[pos], 0, PY_SSIZE_T_MAX, NULL); + PyList_SetSlice(py_cb_array[pos], 0, PY_SSIZE_T_MAX, nullptr); } } else { @@ -313,14 +313,14 @@ void BPY_app_handlers_reset(const bool do_all) PyObject **dict_ptr; if (PyFunction_Check(item) && (dict_ptr = _PyObject_GetDictPtr(item)) && (*dict_ptr) && - (PyDict_GetItem(*dict_ptr, perm_id_str) != NULL)) + (PyDict_GetItem(*dict_ptr, perm_id_str) != nullptr)) { /* keep */ } else { /* remove */ // PySequence_DelItem(ls, i); /* more obvious but slower */ - PyList_SetSlice(ls, i, i + 1, NULL); + PyList_SetSlice(ls, i, i + 1, nullptr); } } } @@ -344,7 +344,7 @@ static PyObject *choose_arguments(PyObject *func, PyObject *args_all, PyObject * } /* the actual callback - not necessarily called from py */ -void bpy_app_generic_callback(struct Main *UNUSED(main), +void bpy_app_generic_callback(struct Main * /*main*/, PointerRNA **pointers, const int pointers_num, void *arg) @@ -382,8 +382,8 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), for (pos = 0; pos < PyList_GET_SIZE(cb_list); pos++) { func = PyList_GET_ITEM(cb_list, pos); PyObject *args = choose_arguments(func, args_all, args_single); - ret = PyObject_Call(func, args, NULL); - if (ret == NULL) { + ret = PyObject_Call(func, args, nullptr); + if (ret == nullptr) { /* Don't set last system variables because they might cause some * dangling pointers to external render engines (when exception * happens during rendering) which will break logic of render pipeline diff --git a/source/blender/python/intern/bpy_app_icons.c b/source/blender/python/intern/bpy_app_icons.cc similarity index 84% rename from source/blender/python/intern/bpy_app_icons.c rename to source/blender/python/intern/bpy_app_icons.cc index 2af3f204ebf..686eb22124a 100644 --- a/source/blender/python/intern/bpy_app_icons.c +++ b/source/blender/python/intern/bpy_app_icons.cc @@ -35,13 +35,13 @@ PyDoc_STRVAR( " :type colors: byte sequence.\n" " :return: Unique icon value (pass to interface ``icon_value`` argument).\n" " :rtype: int\n"); -static PyObject *bpy_app_icons_new_triangles(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_app_icons_new_triangles(PyObject * /*self*/, PyObject *args, PyObject *kw) { /* bytes */ uchar coords_range[2]; PyObject *py_coords, *py_colors; - static const char *_keywords[] = {"range", "coords", "colors", NULL}; + static const char *_keywords[] = {"range", "coords", "colors", nullptr}; static _PyArg_Parser _parser = { "(BB)" /* `range` */ "S" /* `coords` */ @@ -53,29 +53,29 @@ static PyObject *bpy_app_icons_new_triangles(PyObject *UNUSED(self), PyObject *a if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &coords_range[0], &coords_range[1], &py_coords, &py_colors)) { - return NULL; + return nullptr; } const int coords_len = PyBytes_GET_SIZE(py_coords); const int tris_len = coords_len / 6; if (tris_len * 6 != coords_len) { PyErr_SetString(PyExc_ValueError, "coords must be multiple of 6"); - return NULL; + return nullptr; } if (PyBytes_GET_SIZE(py_colors) != 2 * coords_len) { PyErr_SetString(PyExc_ValueError, "colors must be twice size of coords"); - return NULL; + return nullptr; } const int coords_size = sizeof(uchar[2]) * tris_len * 3; const int colors_size = sizeof(uchar[4]) * tris_len * 3; - uchar(*coords)[2] = MEM_mallocN(coords_size, __func__); - uchar(*colors)[4] = MEM_mallocN(colors_size, __func__); + uchar(*coords)[2] = static_cast(MEM_mallocN(coords_size, __func__)); + uchar(*colors)[4] = static_cast(MEM_mallocN(colors_size, __func__)); memcpy(coords, PyBytes_AS_STRING(py_coords), coords_size); memcpy(colors, PyBytes_AS_STRING(py_colors), colors_size); - struct Icon_Geom *geom = MEM_mallocN(sizeof(*geom), __func__); + struct Icon_Geom *geom = static_cast(MEM_mallocN(sizeof(*geom), __func__)); geom->coords_len = tris_len; geom->coords_range[0] = coords_range[0]; geom->coords_range[1] = coords_range[1]; @@ -95,14 +95,14 @@ PyDoc_STRVAR(bpy_app_icons_new_triangles_from_file_doc, " :type filepath: string.\n" " :return: Unique icon value (pass to interface ``icon_value`` argument).\n" " :rtype: int\n"); -static PyObject *bpy_app_icons_new_triangles_from_file(PyObject *UNUSED(self), +static PyObject *bpy_app_icons_new_triangles_from_file(PyObject * /*self*/, PyObject *args, PyObject *kw) { /* bytes */ char *filepath; - static const char *_keywords[] = {"filepath", NULL}; + static const char *_keywords[] = {"filepath", nullptr}; static _PyArg_Parser _parser = { "s" /* `filepath` */ ":new_triangles_from_file", @@ -110,13 +110,13 @@ static PyObject *bpy_app_icons_new_triangles_from_file(PyObject *UNUSED(self), 0, }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &filepath)) { - return NULL; + return nullptr; } struct Icon_Geom *geom = BKE_icon_geom_from_file(filepath); - if (geom == NULL) { + if (geom == nullptr) { PyErr_SetString(PyExc_ValueError, "Unable to load from file"); - return NULL; + return nullptr; } const int icon_id = BKE_icon_geom_ensure(geom); return PyLong_FromLong(icon_id); @@ -126,10 +126,10 @@ PyDoc_STRVAR(bpy_app_icons_release_doc, ".. function:: release(icon_id)\n" "\n" " Release the icon.\n"); -static PyObject *bpy_app_icons_release(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_app_icons_release(PyObject * /*self*/, PyObject *args, PyObject *kw) { int icon_id; - static const char *_keywords[] = {"icon_id", NULL}; + static const char *_keywords[] = {"icon_id", nullptr}; static _PyArg_Parser _parser = { "i" /* `icon_id` */ ":release", @@ -137,12 +137,12 @@ static PyObject *bpy_app_icons_release(PyObject *UNUSED(self), PyObject *args, P 0, }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &icon_id)) { - return NULL; + return nullptr; } if (!BKE_icon_delete_unmanaged(icon_id)) { PyErr_SetString(PyExc_ValueError, "invalid icon_id"); - return NULL; + return nullptr; } Py_RETURN_NONE; } @@ -160,19 +160,19 @@ static PyMethodDef M_AppIcons_methods[] = { (PyCFunction)bpy_app_icons_release, METH_VARARGS | METH_KEYWORDS, bpy_app_icons_release_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyModuleDef M_AppIcons_module_def = { /*m_base*/ PyModuleDef_HEAD_INIT, /*m_name*/ "bpy.app.icons", - /*m_doc*/ NULL, + /*m_doc*/ nullptr, /*m_size*/ 0, /*m_methods*/ M_AppIcons_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; PyObject *BPY_app_icons_module(void) diff --git a/source/blender/python/intern/bpy_app_ocio.c b/source/blender/python/intern/bpy_app_ocio.cc similarity index 88% rename from source/blender/python/intern/bpy_app_ocio.c rename to source/blender/python/intern/bpy_app_ocio.cc index 989a1fbb20a..e78a0812cfe 100644 --- a/source/blender/python/intern/bpy_app_ocio.c +++ b/source/blender/python/intern/bpy_app_ocio.cc @@ -23,7 +23,7 @@ static PyStructSequence_Field app_ocio_info_fields[] = { {"supported", "Boolean, True when Blender is built with OpenColorIO support"}, {"version", "The OpenColorIO version as a tuple of 3 numbers"}, {"version_string", "The OpenColorIO version formatted as a string"}, - {NULL}, + {nullptr}, }; static PyStructSequence_Desc app_ocio_info_desc = { @@ -46,8 +46,8 @@ static PyObject *make_ocio_info(void) #endif ocio_info = PyStructSequence_New(&BlenderAppOCIOType); - if (ocio_info == NULL) { - return NULL; + if (ocio_info == nullptr) { + return nullptr; } #ifndef WITH_OCIO @@ -60,7 +60,7 @@ static PyObject *make_ocio_info(void) curversion = OCIO_getVersionHex(); SetObjItem(PyBool_FromLong(1)); SetObjItem( - PyC_Tuple_Pack_I32(curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256)); + PyC_Tuple_Pack_I32({curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256})); SetObjItem(PyUnicode_FromFormat( "%2d, %2d, %2d", curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256)); #else @@ -71,7 +71,7 @@ static PyObject *make_ocio_info(void) if (UNLIKELY(PyErr_Occurred())) { Py_DECREF(ocio_info); - return NULL; + return nullptr; } #undef SetStrItem @@ -89,8 +89,8 @@ PyObject *BPY_app_ocio_struct(void) ret = make_ocio_info(); /* prevent user from creating new instances */ - BlenderAppOCIOType.tp_init = NULL; - BlenderAppOCIOType.tp_new = NULL; + BlenderAppOCIOType.tp_init = nullptr; + BlenderAppOCIOType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppOCIOType.tp_hash = (hashfunc)_Py_HashPointer; diff --git a/source/blender/python/intern/bpy_app_oiio.c b/source/blender/python/intern/bpy_app_oiio.cc similarity index 87% rename from source/blender/python/intern/bpy_app_oiio.c rename to source/blender/python/intern/bpy_app_oiio.cc index 563581bec70..268a219867b 100644 --- a/source/blender/python/intern/bpy_app_oiio.c +++ b/source/blender/python/intern/bpy_app_oiio.cc @@ -21,7 +21,7 @@ static PyStructSequence_Field app_oiio_info_fields[] = { {"supported", "Boolean, True when Blender is built with OpenImageIO support"}, {"version", "The OpenImageIO version as a tuple of 3 numbers"}, {"version_string", "The OpenImageIO version formatted as a string"}, - {NULL}, + {nullptr}, }; static PyStructSequence_Desc app_oiio_info_desc = { @@ -39,21 +39,21 @@ static PyObject *make_oiio_info(void) int curversion; oiio_info = PyStructSequence_New(&BlenderAppOIIOType); - if (oiio_info == NULL) { - return NULL; + if (oiio_info == nullptr) { + return nullptr; } #define SetObjItem(obj) PyStructSequence_SET_ITEM(oiio_info, pos++, obj) curversion = OIIO_getVersionHex(); SetObjItem(PyBool_FromLong(1)); - SetObjItem(PyC_Tuple_Pack_I32(curversion / 10000, (curversion / 100) % 100, curversion % 100)); + SetObjItem(PyC_Tuple_Pack_I32({curversion / 10000, (curversion / 100) % 100, curversion % 100})); SetObjItem(PyUnicode_FromFormat( "%2d, %2d, %2d", curversion / 10000, (curversion / 100) % 100, curversion % 100)); if (UNLIKELY(PyErr_Occurred())) { Py_DECREF(oiio_info); - return NULL; + return nullptr; } #undef SetStrItem @@ -71,8 +71,8 @@ PyObject *BPY_app_oiio_struct(void) ret = make_oiio_info(); /* prevent user from creating new instances */ - BlenderAppOIIOType.tp_init = NULL; - BlenderAppOIIOType.tp_new = NULL; + BlenderAppOIIOType.tp_init = nullptr; + BlenderAppOIIOType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppOIIOType.tp_hash = (hashfunc)_Py_HashPointer; diff --git a/source/blender/python/intern/bpy_app_opensubdiv.c b/source/blender/python/intern/bpy_app_opensubdiv.cc similarity index 89% rename from source/blender/python/intern/bpy_app_opensubdiv.c rename to source/blender/python/intern/bpy_app_opensubdiv.cc index 6e07bb435db..18b34b53788 100644 --- a/source/blender/python/intern/bpy_app_opensubdiv.c +++ b/source/blender/python/intern/bpy_app_opensubdiv.cc @@ -23,7 +23,7 @@ static PyStructSequence_Field app_opensubdiv_info_fields[] = { {"supported", "Boolean, True when Blender is built with OpenSubdiv support"}, {"version", "The OpenSubdiv version as a tuple of 3 numbers"}, {"version_string", "The OpenSubdiv version formatted as a string"}, - {NULL}, + {nullptr}, }; static PyStructSequence_Desc app_opensubdiv_info_desc = { @@ -39,8 +39,8 @@ static PyObject *make_opensubdiv_info(void) int pos = 0; opensubdiv_info = PyStructSequence_New(&BlenderAppOpenSubdivType); - if (opensubdiv_info == NULL) { - return NULL; + if (opensubdiv_info == nullptr) { + return nullptr; } #ifndef WITH_OPENSUBDIV @@ -53,7 +53,7 @@ static PyObject *make_opensubdiv_info(void) #ifdef WITH_OPENSUBDIV const int curversion = openSubdiv_getVersionHex(); SetObjItem(PyBool_FromLong(1)); - SetObjItem(PyC_Tuple_Pack_I32(curversion / 10000, (curversion / 100) % 100, curversion % 100)); + SetObjItem(PyC_Tuple_Pack_I32({curversion / 10000, (curversion / 100) % 100, curversion % 100})); SetObjItem(PyUnicode_FromFormat( "%2d, %2d, %2d", curversion / 10000, (curversion / 100) % 100, curversion % 100)); #else @@ -64,7 +64,7 @@ static PyObject *make_opensubdiv_info(void) if (UNLIKELY(PyErr_Occurred())) { Py_DECREF(opensubdiv_info); - return NULL; + return nullptr; } #undef SetStrItem @@ -82,8 +82,8 @@ PyObject *BPY_app_opensubdiv_struct(void) ret = make_opensubdiv_info(); /* prevent user from creating new instances */ - BlenderAppOpenSubdivType.tp_init = NULL; - BlenderAppOpenSubdivType.tp_new = NULL; + BlenderAppOpenSubdivType.tp_init = nullptr; + BlenderAppOpenSubdivType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppOpenSubdivType.tp_hash = (hashfunc)_Py_HashPointer; diff --git a/source/blender/python/intern/bpy_app_openvdb.c b/source/blender/python/intern/bpy_app_openvdb.cc similarity index 89% rename from source/blender/python/intern/bpy_app_openvdb.c rename to source/blender/python/intern/bpy_app_openvdb.cc index ca76b996a10..cf2b19fe6fe 100644 --- a/source/blender/python/intern/bpy_app_openvdb.c +++ b/source/blender/python/intern/bpy_app_openvdb.cc @@ -23,7 +23,7 @@ static PyStructSequence_Field app_openvdb_info_fields[] = { {"supported", "Boolean, True when Blender is built with OpenVDB support"}, {"version", "The OpenVDB version as a tuple of 3 numbers"}, {"version_string", "The OpenVDB version formatted as a string"}, - {NULL}, + {nullptr}, }; static PyStructSequence_Desc app_openvdb_info_desc = { @@ -43,8 +43,8 @@ static PyObject *make_openvdb_info(void) #endif openvdb_info = PyStructSequence_New(&BlenderAppOVDBType); - if (openvdb_info == NULL) { - return NULL; + if (openvdb_info == nullptr) { + return nullptr; } #ifndef WITH_OPENVDB @@ -57,7 +57,7 @@ static PyObject *make_openvdb_info(void) curversion = OpenVDB_getVersionHex(); SetObjItem(PyBool_FromLong(1)); SetObjItem( - PyC_Tuple_Pack_I32(curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256)); + PyC_Tuple_Pack_I32({curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256})); SetObjItem(PyUnicode_FromFormat( "%2d, %2d, %2d", curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256)); #else @@ -68,7 +68,7 @@ static PyObject *make_openvdb_info(void) if (UNLIKELY(PyErr_Occurred())) { Py_DECREF(openvdb_info); - return NULL; + return nullptr; } #undef SetStrItem @@ -86,8 +86,8 @@ PyObject *BPY_app_openvdb_struct(void) ret = make_openvdb_info(); /* prevent user from creating new instances */ - BlenderAppOVDBType.tp_init = NULL; - BlenderAppOVDBType.tp_new = NULL; + BlenderAppOVDBType.tp_init = nullptr; + BlenderAppOVDBType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppOVDBType.tp_hash = (hashfunc)_Py_HashPointer; diff --git a/source/blender/python/intern/bpy_app_sdl.c b/source/blender/python/intern/bpy_app_sdl.cc similarity index 92% rename from source/blender/python/intern/bpy_app_sdl.c rename to source/blender/python/intern/bpy_app_sdl.cc index 1086cc14f93..76f63bea8aa 100644 --- a/source/blender/python/intern/bpy_app_sdl.c +++ b/source/blender/python/intern/bpy_app_sdl.cc @@ -41,7 +41,7 @@ static PyStructSequence_Field app_sdl_info_fields[] = { ("Boolean, True when SDL is available. This is False when " "either *supported* is False, or *dynload* is True and " "Blender cannot find the correct library.")}, - {NULL}, + {nullptr}, }; static PyStructSequence_Desc app_sdl_info_desc = { @@ -61,8 +61,8 @@ static PyObject *make_sdl_info(void) #endif sdl_info = PyStructSequence_New(&BlenderAppSDLType); - if (sdl_info == NULL) { - return NULL; + if (sdl_info == nullptr) { + return nullptr; } #define SetStrItem(str) PyStructSequence_SET_ITEM(sdl_info, pos++, PyUnicode_FromString(str)) @@ -86,7 +86,7 @@ static PyObject *make_sdl_info(void) # endif # endif - SetObjItem(PyC_Tuple_Pack_I32(version.major, version.minor, version.patch)); + SetObjItem(PyC_Tuple_Pack_I32({version.major, version.minor, version.patch})); if (sdl_available) { SetObjItem(PyUnicode_FromFormat("%d.%d.%d", version.major, version.minor, version.patch)); } @@ -104,7 +104,7 @@ static PyObject *make_sdl_info(void) if (UNLIKELY(PyErr_Occurred())) { Py_DECREF(sdl_info); - return NULL; + return nullptr; } #undef SetStrItem @@ -122,8 +122,8 @@ PyObject *BPY_app_sdl_struct(void) ret = make_sdl_info(); /* prevent user from creating new instances */ - BlenderAppSDLType.tp_init = NULL; - BlenderAppSDLType.tp_new = NULL; + BlenderAppSDLType.tp_init = nullptr; + BlenderAppSDLType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppSDLType.tp_hash = (hashfunc)_Py_HashPointer; diff --git a/source/blender/python/intern/bpy_app_timers.c b/source/blender/python/intern/bpy_app_timers.cc similarity index 84% rename from source/blender/python/intern/bpy_app_timers.c rename to source/blender/python/intern/bpy_app_timers.cc index d415dc87f0c..555940ba94e 100644 --- a/source/blender/python/intern/bpy_app_timers.c +++ b/source/blender/python/intern/bpy_app_timers.cc @@ -19,7 +19,7 @@ static double handle_returned_value(PyObject *function, PyObject *ret) { - if (ret == NULL) { + if (ret == nullptr) { PyErr_PrintEx(0); PyErr_Clear(); return -1; @@ -45,14 +45,14 @@ static double handle_returned_value(PyObject *function, PyObject *ret) return value; } -static double py_timer_execute(uintptr_t UNUSED(uuid), void *user_data) +static double py_timer_execute(uintptr_t /*uuid*/, void *user_data) { - PyObject *function = user_data; + PyObject *function = static_cast(user_data); PyGILState_STATE gilstate; gilstate = PyGILState_Ensure(); - PyObject *py_ret = PyObject_CallObject(function, NULL); + PyObject *py_ret = PyObject_CallObject(function, nullptr); const double ret = handle_returned_value(function, py_ret); PyGILState_Release(gilstate); @@ -60,9 +60,9 @@ static double py_timer_execute(uintptr_t UNUSED(uuid), void *user_data) return ret; } -static void py_timer_free(uintptr_t UNUSED(uuid), void *user_data) +static void py_timer_free(uintptr_t /*uuid*/, void *user_data) { - PyObject *function = user_data; + PyObject *function = static_cast(user_data); PyGILState_STATE gilstate; gilstate = PyGILState_Ensure(); @@ -88,13 +88,13 @@ PyDoc_STRVAR( " :type first_interval: float\n" " :arg persistent: Don't remove timer when a new file is loaded.\n" " :type persistent: bool\n"); -static PyObject *bpy_app_timers_register(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_app_timers_register(PyObject * /*self*/, PyObject *args, PyObject *kw) { PyObject *function; double first_interval = 0; int persistent = false; - static const char *_keywords[] = {"function", "first_interval", "persistent", NULL}; + static const char *_keywords[] = {"function", "first_interval", "persistent", nullptr}; static _PyArg_Parser _parser = { "O" /* `function` */ "|$" /* Optional keyword only arguments. */ @@ -106,12 +106,12 @@ static PyObject *bpy_app_timers_register(PyObject *UNUSED(self), PyObject *args, }; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &function, &first_interval, &persistent)) { - return NULL; + return nullptr; } if (!PyCallable_Check(function)) { PyErr_SetString(PyExc_TypeError, "function is not callable"); - return NULL; + return nullptr; } Py_INCREF(function); @@ -127,11 +127,11 @@ PyDoc_STRVAR(bpy_app_timers_unregister_doc, "\n" " :arg function: Function to unregister.\n" " :type function: function\n"); -static PyObject *bpy_app_timers_unregister(PyObject *UNUSED(self), PyObject *function) +static PyObject *bpy_app_timers_unregister(PyObject * /*self*/, PyObject *function) { if (!BLI_timer_unregister((intptr_t)function)) { PyErr_SetString(PyExc_ValueError, "Error: function is not registered"); - return NULL; + return nullptr; } Py_RETURN_NONE; } @@ -145,7 +145,7 @@ PyDoc_STRVAR(bpy_app_timers_is_registered_doc, " :type function: int\n" " :return: True when this function is registered, otherwise False.\n" " :rtype: bool\n"); -static PyObject *bpy_app_timers_is_registered(PyObject *UNUSED(self), PyObject *function) +static PyObject *bpy_app_timers_is_registered(PyObject * /*self*/, PyObject *function) { const bool ret = BLI_timer_is_registered((intptr_t)function); return PyBool_FromLong(ret); @@ -161,19 +161,19 @@ static PyMethodDef M_AppTimers_methods[] = { (PyCFunction)bpy_app_timers_is_registered, METH_O, bpy_app_timers_is_registered_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyModuleDef M_AppTimers_module_def = { /*m_base*/ PyModuleDef_HEAD_INIT, /*m_name*/ "bpy.app.timers", - /*m_doc*/ NULL, + /*m_doc*/ nullptr, /*m_size*/ 0, /*m_methods*/ M_AppTimers_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; PyObject *BPY_app_timers_module(void) diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.cc similarity index 88% rename from source/blender/python/intern/bpy_app_translations.c rename to source/blender/python/intern/bpy_app_translations.cc index 311a61491d4..e3da231d5e8 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.cc @@ -37,7 +37,7 @@ /** \name Local Struct to Store Translation * \{ */ -typedef struct { +struct BlenderAppTranslations { PyObject_HEAD /** The string used to separate context from actual message in PY_TRANSLATE RNA props. */ const char *context_separator; @@ -50,10 +50,10 @@ typedef struct { * (order is more or less random, first match wins!). */ PyObject *py_messages; -} BlenderAppTranslations; +}; /* Our singleton instance pointer */ -static BlenderAppTranslations *_translations = NULL; +static BlenderAppTranslations *_translations = nullptr; /** \} */ @@ -63,31 +63,32 @@ static BlenderAppTranslations *_translations = NULL; #ifdef WITH_INTERNATIONAL -typedef struct GHashKey { +struct GHashKey { const char *msgctxt; const char *msgid; -} GHashKey; +}; static GHashKey *_ghashutil_keyalloc(const void *msgctxt, const void *msgid) { - GHashKey *key = MEM_mallocN(sizeof(GHashKey), "Py i18n GHashKey"); - key->msgctxt = BLI_strdup(BLT_is_default_context(msgctxt) ? BLT_I18NCONTEXT_DEFAULT_BPYRNA : - msgctxt); - key->msgid = BLI_strdup(msgid); + GHashKey *key = static_cast(MEM_mallocN(sizeof(GHashKey), "Py i18n GHashKey")); + key->msgctxt = BLI_strdup(static_cast( + BLT_is_default_context(static_cast(msgctxt)) ? BLT_I18NCONTEXT_DEFAULT_BPYRNA : + msgctxt)); + key->msgid = BLI_strdup(static_cast(msgid)); return key; } static uint _ghashutil_keyhash(const void *ptr) { - const GHashKey *key = ptr; + const GHashKey *key = static_cast(ptr); const uint hash = BLI_ghashutil_strhash(key->msgctxt); return hash ^ BLI_ghashutil_strhash(key->msgid); } static bool _ghashutil_keycmp(const void *a, const void *b) { - const GHashKey *A = a; - const GHashKey *B = b; + const GHashKey *A = static_cast(a); + const GHashKey *B = static_cast(b); /* NOTE: comparing msgid first, most of the time it will be enough! */ if (BLI_ghashutil_strcmp(A->msgid, B->msgid) == false) { @@ -98,7 +99,7 @@ static bool _ghashutil_keycmp(const void *a, const void *b) static void _ghashutil_keyfree(void *ptr) { - const GHashKey *key = ptr; + const GHashKey *key = static_cast(ptr); /* We assume both msgctxt and msgid were BLI_strdup'ed! */ MEM_freeN((void *)key->msgctxt); @@ -121,25 +122,26 @@ static void _ghashutil_keyfree(void *ptr) * so let's try to optimize the later as much as we can! * Note changing of locale, as well as (un)registering a message dict, invalidate that cache. */ -static GHash *_translations_cache = NULL; +static GHash *_translations_cache = nullptr; static void _clear_translations_cache(void) { if (_translations_cache) { BLI_ghash_free(_translations_cache, _ghashutil_keyfree, _ghashutil_valfree); } - _translations_cache = NULL; + _translations_cache = nullptr; } static void _build_translations_cache(PyObject *py_messages, const char *locale) { PyObject *uuid, *uuid_dict; Py_ssize_t pos = 0; - char *language = NULL, *language_country = NULL, *language_variant = NULL; + char *language = nullptr, *language_country = nullptr, *language_variant = nullptr; /* For each py dict, we'll search for full locale, then language+country, then language+variant, * then only language keys... */ - BLT_lang_locale_explode(locale, &language, NULL, NULL, &language_country, &language_variant); + BLT_lang_locale_explode( + locale, &language, nullptr, nullptr, &language_country, &language_variant); /* Clear the cached ghash if needed, and create a new one. */ _clear_translations_cache(); @@ -150,8 +152,8 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale) PyObject *lang_dict; # if 0 - PyObject_Print(uuid_dict, stdout, 0); - printf("\n"); +PyObject_Print(uuid_dict, stdout, 0); +printf("\n"); # endif /* Try to get first complete locale, then language+country, @@ -189,7 +191,7 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale) /* Iterate over all translations of the found language dict, and populate our ghash cache. */ while (PyDict_Next(lang_dict, &ppos, &pykey, &trans)) { - const char *msgctxt = NULL, *msgid = NULL; + const char *msgctxt = nullptr, *msgid = nullptr; bool invalid_key = false; if ((PyTuple_CheckExact(pykey) == false) || (PyTuple_GET_SIZE(pykey) != 2)) { @@ -284,7 +286,7 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms key.msgctxt = BLT_is_default_context(msgctxt) ? BLT_I18NCONTEXT_DEFAULT_BPYRNA : msgctxt; key.msgid = msgid; - tmp = BLI_ghash_lookup(_translations_cache, &key); + tmp = static_cast(BLI_ghash_lookup(_translations_cache, &key)); return tmp ? tmp : msgid; @@ -312,7 +314,7 @@ static PyObject *app_translations_py_messages_register(BlenderAppTranslations *s PyObject *kw) { #ifdef WITH_INTERNATIONAL - static const char *kwlist[] = {"module_name", "translations_dict", NULL}; + static const char *kwlist[] = {"module_name", "translations_dict", nullptr}; PyObject *module_name, *uuid_dict; if (!PyArg_ParseTupleAndKeywords(args, @@ -324,7 +326,7 @@ static PyObject *app_translations_py_messages_register(BlenderAppTranslations *s &PyDict_Type, &uuid_dict)) { - return NULL; + return nullptr; } if (PyDict_Contains(self->py_messages, module_name)) { @@ -333,7 +335,7 @@ static PyObject *app_translations_py_messages_register(BlenderAppTranslations *s "bpy.app.translations.register: translations message cache already contains some data for " "addon '%s'", (const char *)PyUnicode_AsUTF8(module_name)); - return NULL; + return nullptr; } PyDict_SetItem(self->py_messages, module_name, uuid_dict); @@ -366,7 +368,7 @@ static PyObject *app_translations_py_messages_unregister(BlenderAppTranslations PyObject *kw) { #ifdef WITH_INTERNATIONAL - static const char *kwlist[] = {"module_name", NULL}; + static const char *kwlist[] = {"module_name", nullptr}; PyObject *module_name; if (!PyArg_ParseTupleAndKeywords(args, @@ -376,7 +378,7 @@ static PyObject *app_translations_py_messages_unregister(BlenderAppTranslations &PyUnicode_Type, &module_name)) { - return NULL; + return nullptr; } if (PyDict_Contains(self->py_messages, module_name)) { @@ -409,7 +411,8 @@ static BLT_i18n_contexts_descriptor _contexts[] = BLT_I18NCONTEXTS_DESC; /* These fields are just empty placeholders, actual values get set in app_translations_struct(). * This allows us to avoid many handwriting, and above all, * to keep all context definition stuff in BLT_translation.h! */ -static PyStructSequence_Field app_translations_contexts_fields[ARRAY_SIZE(_contexts)] = {{NULL}}; +static PyStructSequence_Field app_translations_contexts_fields[ARRAY_SIZE(_contexts)] = { + {nullptr}}; static PyStructSequence_Desc app_translations_contexts_desc = { "bpy.app.translations.contexts", /* name */ @@ -425,8 +428,8 @@ static PyObject *app_translations_contexts_make(void) int pos = 0; translations_contexts = PyStructSequence_New(&BlenderAppTranslationsContextsType); - if (translations_contexts == NULL) { - return NULL; + if (translations_contexts == nullptr) { + return nullptr; } #define SetObjString(item) \ @@ -477,14 +480,14 @@ static PyMemberDef app_translations_members[] = { offsetof(BlenderAppTranslations, contexts_C_to_py), READONLY, app_translations_contexts_C_to_py_doc}, - {NULL}, + {nullptr}, }; PyDoc_STRVAR(app_translations_locale_doc, "The actual locale currently in use (will always return a void string when Blender " "is built without " "internationalization support)."); -static PyObject *app_translations_locale_get(PyObject *UNUSED(self), void *UNUSED(userdata)) +static PyObject *app_translations_locale_get(PyObject * /*self*/, void * /*userdata*/) { return PyUnicode_FromString(BLT_lang_get()); } @@ -492,7 +495,7 @@ static PyObject *app_translations_locale_get(PyObject *UNUSED(self), void *UNUSE /* NOTE: defining as getter, as (even if quite unlikely), this *may* change during runtime... */ PyDoc_STRVAR(app_translations_locales_doc, "All locales currently known by Blender (i.e. available as translations)."); -static PyObject *app_translations_locales_get(PyObject *UNUSED(self), void *UNUSED(userdata)) +static PyObject *app_translations_locales_get(PyObject * /*self*/, void * /*userdata*/) { PyObject *ret; EnumPropertyItem *it, *items = BLT_lang_RNA_enum_properties(); @@ -522,9 +525,13 @@ static PyObject *app_translations_locales_get(PyObject *UNUSED(self), void *UNUS static PyGetSetDef app_translations_getseters[] = { /* {name, getter, setter, doc, userdata} */ - {"locale", (getter)app_translations_locale_get, NULL, app_translations_locale_doc, NULL}, - {"locales", (getter)app_translations_locales_get, NULL, app_translations_locales_doc, NULL}, - {NULL}, + {"locale", (getter)app_translations_locale_get, nullptr, app_translations_locale_doc, nullptr}, + {"locales", + (getter)app_translations_locales_get, + nullptr, + app_translations_locales_doc, + nullptr}, + {nullptr}, }; /* pgettext helper. */ @@ -532,15 +539,15 @@ static PyObject *_py_pgettext(PyObject *args, PyObject *kw, const char *(*_pgettext)(const char *, const char *)) { - static const char *kwlist[] = {"msgid", "msgctxt", NULL}; + static const char *kwlist[] = {"msgid", "msgctxt", nullptr}; #ifdef WITH_INTERNATIONAL - char *msgid, *msgctxt = NULL; + char *msgid, *msgctxt = nullptr; if (!PyArg_ParseTupleAndKeywords( args, kw, "s|z:bpy.app.translations.pgettext", (char **)kwlist, &msgid, &msgctxt)) { - return NULL; + return nullptr; } return PyUnicode_FromString((*_pgettext)(msgctxt ? msgctxt : BLT_I18NCONTEXT_DEFAULT, msgid)); @@ -551,7 +558,7 @@ static PyObject *_py_pgettext(PyObject *args, if (!PyArg_ParseTupleAndKeywords( args, kw, "O|O:bpy.app.translations.pgettext", (char **)kwlist, &msgid, &msgctxt)) { - return NULL; + return nullptr; } return Py_INCREF_RET(msgid); @@ -586,7 +593,7 @@ PyDoc_STRVAR( " :type msgctxt: string or None\n" " :return: The translated string (or msgid if no translation was found).\n" "\n"); -static PyObject *app_translations_pgettext(BlenderAppTranslations *UNUSED(self), +static PyObject *app_translations_pgettext(BlenderAppTranslations * /*self*/, PyObject *args, PyObject *kw) { @@ -608,7 +615,7 @@ PyDoc_STRVAR(app_translations_pgettext_iface_doc, " :type msgctxt: string or None\n" " :return: The translated string (or msgid if no translation was found).\n" "\n"); -static PyObject *app_translations_pgettext_iface(BlenderAppTranslations *UNUSED(self), +static PyObject *app_translations_pgettext_iface(BlenderAppTranslations * /*self*/, PyObject *args, PyObject *kw) { @@ -630,7 +637,7 @@ PyDoc_STRVAR(app_translations_pgettext_tip_doc, " :type msgctxt: string or None\n" " :return: The translated string (or msgid if no translation was found).\n" "\n"); -static PyObject *app_translations_pgettext_tip(BlenderAppTranslations *UNUSED(self), +static PyObject *app_translations_pgettext_tip(BlenderAppTranslations * /*self*/, PyObject *args, PyObject *kw) { @@ -652,7 +659,7 @@ PyDoc_STRVAR(app_translations_pgettext_data_doc, " :type msgctxt: string or None\n" " :return: The translated string (or ``msgid`` if no translation was found).\n" "\n"); -static PyObject *app_translations_pgettext_data(BlenderAppTranslations *UNUSED(self), +static PyObject *app_translations_pgettext_data(BlenderAppTranslations * /*self*/, PyObject *args, PyObject *kw) { @@ -674,19 +681,19 @@ PyDoc_STRVAR( " :type msgid: string\n" " :return: A tuple ``(language, country, variant, language_country, language@variant)``.\n" "\n"); -static PyObject *app_translations_locale_explode(BlenderAppTranslations *UNUSED(self), +static PyObject *app_translations_locale_explode(BlenderAppTranslations * /*self*/, PyObject *args, PyObject *kw) { PyObject *ret_tuple; - static const char *kwlist[] = {"locale", NULL}; + static const char *kwlist[] = {"locale", nullptr}; const char *locale; char *language, *country, *variant, *language_country, *language_variant; if (!PyArg_ParseTupleAndKeywords( args, kw, "s:bpy.app.translations.locale_explode", (char **)kwlist, &locale)) { - return NULL; + return nullptr; } BLT_lang_locale_explode( @@ -734,12 +741,10 @@ static PyMethodDef app_translations_methods[] = { (PyCFunction)app_translations_locale_explode, METH_VARARGS | METH_KEYWORDS | METH_STATIC, app_translations_locale_explode_doc}, - {NULL}, + {nullptr}, }; -static PyObject *app_translations_new(PyTypeObject *type, - PyObject *UNUSED(args), - PyObject *UNUSED(kw)) +static PyObject *app_translations_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kw*/) { // printf("%s (%p)\n", __func__, _translations); @@ -781,55 +786,55 @@ PyDoc_STRVAR(app_translations_doc, "to feature translations for its own UI messages.\n" "\n"); static PyTypeObject BlenderAppTranslationsType = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy.app._translations_type", /*tp_basicsize*/ sizeof(BlenderAppTranslations), /*tp_itemsize*/ 0, - /*tp_dealloc*/ NULL, + /*tp_dealloc*/ nullptr, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, - /*tp_repr*/ NULL, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, + /*tp_repr*/ nullptr, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT, /*tp_doc*/ app_translations_doc, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ app_translations_methods, /*tp_members*/ app_translations_members, /*tp_getset*/ app_translations_getseters, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, /*tp_new*/ (newfunc)app_translations_new, /*tp_free*/ app_translations_free, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; PyObject *BPY_app_translations_struct(void) @@ -845,22 +850,22 @@ PyObject *BPY_app_translations_struct(void) for (ctxt = _contexts, desc = app_translations_contexts_desc.fields; ctxt->c_id; ctxt++, desc++) { desc->name = ctxt->py_id; - desc->doc = NULL; + desc->doc = nullptr; } - desc->name = desc->doc = NULL; /* End sentinel! */ + desc->name = desc->doc = nullptr; /* End sentinel! */ PyStructSequence_InitType(&BlenderAppTranslationsContextsType, &app_translations_contexts_desc); } if (PyType_Ready(&BlenderAppTranslationsType) < 0) { - return NULL; + return nullptr; } - ret = PyObject_CallObject((PyObject *)&BlenderAppTranslationsType, NULL); + ret = PyObject_CallObject((PyObject *)&BlenderAppTranslationsType, nullptr); /* prevent user from creating new instances */ - BlenderAppTranslationsType.tp_new = NULL; + BlenderAppTranslationsType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppTranslationsType.tp_hash = (hashfunc)_Py_HashPointer; @@ -869,7 +874,7 @@ PyObject *BPY_app_translations_struct(void) void BPY_app_translations_end(void) { - /* In case the object remains in a module's name-space, see #44127. */ +/* In case the object remains in a module's name-space, see #44127. */ #ifdef WITH_INTERNATIONAL _clear_translations_cache(); #endif diff --git a/source/blender/python/intern/bpy_app_usd.c b/source/blender/python/intern/bpy_app_usd.cc similarity index 90% rename from source/blender/python/intern/bpy_app_usd.c rename to source/blender/python/intern/bpy_app_usd.cc index 85acaf40df8..fc03e3d4e7c 100644 --- a/source/blender/python/intern/bpy_app_usd.c +++ b/source/blender/python/intern/bpy_app_usd.cc @@ -23,7 +23,7 @@ static PyStructSequence_Field app_usd_info_fields[] = { {"supported", "Boolean, True when Blender is built with USD support"}, {"version", "The USD version as a tuple of 3 numbers"}, {"version_string", "The USD version formatted as a string"}, - {NULL}, + {nullptr}, }; static PyStructSequence_Desc app_usd_info_desc = { @@ -38,8 +38,8 @@ static PyObject *make_usd_info(void) { PyObject *usd_info = PyStructSequence_New(&BlenderAppUSDType); - if (usd_info == NULL) { - return NULL; + if (usd_info == nullptr) { + return nullptr; } int pos = 0; @@ -57,7 +57,7 @@ static PyObject *make_usd_info(void) const int patch = curversion % 100; SetObjItem(PyBool_FromLong(1)); - SetObjItem(PyC_Tuple_Pack_I32(major, minor, patch)); + SetObjItem(PyC_Tuple_Pack_I32({major, minor, patch})); SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d", major, minor, patch)); #else SetObjItem(PyBool_FromLong(0)); @@ -67,7 +67,7 @@ static PyObject *make_usd_info(void) if (UNLIKELY(PyErr_Occurred())) { Py_DECREF(usd_info); - return NULL; + return nullptr; } #undef SetStrItem @@ -83,8 +83,8 @@ PyObject *BPY_app_usd_struct(void) PyObject *ret = make_usd_info(); /* prevent user from creating new instances */ - BlenderAppUSDType.tp_init = NULL; - BlenderAppUSDType.tp_new = NULL; + BlenderAppUSDType.tp_init = nullptr; + BlenderAppUSDType.tp_new = nullptr; /* Without this we can't do `set(sys.modules)` #29635. */ BlenderAppUSDType.tp_hash = (hashfunc)_Py_HashPointer; diff --git a/source/blender/python/intern/bpy_capi_utils.c b/source/blender/python/intern/bpy_capi_utils.cc similarity index 92% rename from source/blender/python/intern/bpy_capi_utils.c rename to source/blender/python/intern/bpy_capi_utils.cc index f0fac3f6fc2..727596f9735 100644 --- a/source/blender/python/intern/bpy_capi_utils.c +++ b/source/blender/python/intern/bpy_capi_utils.cc @@ -41,7 +41,7 @@ short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool MEM_freeN(report_str); } - return (report_str == NULL) ? 0 : -1; + return (report_str == nullptr) ? 0 : -1; } void BPy_reports_write_stdout(const ReportList *reports, const char *header) @@ -66,7 +66,7 @@ bool BPy_errors_to_report_ex(ReportList *reports, } PyObject *err_str_py = use_full ? PyC_ExceptionBuffer() : PyC_ExceptionBuffer_Simple(); - if (err_str_py == NULL) { + if (err_str_py == nullptr) { BKE_report(reports, RPT_ERROR, "Unknown py-exception, could not convert"); return 0; } @@ -78,12 +78,12 @@ bool BPy_errors_to_report_ex(ReportList *reports, err_str_len -= 1; } - if (err_prefix == NULL) { + if (err_prefix == nullptr) { /* Not very helpful, better than nothing. */ err_prefix = "Python"; } - const char *location_filepath = NULL; + const char *location_filepath = nullptr; int location_line_number = -1; /* Give some additional context. */ @@ -114,5 +114,5 @@ bool BPy_errors_to_report_ex(ReportList *reports, bool BPy_errors_to_report(ReportList *reports) { - return BPy_errors_to_report_ex(reports, NULL, true, true); + return BPy_errors_to_report_ex(reports, nullptr, true, true); } diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.cc similarity index 72% rename from source/blender/python/intern/bpy_driver.c rename to source/blender/python/intern/bpy_driver.cc index 926b4566199..447eee4068b 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.cc @@ -44,10 +44,10 @@ # include #endif -PyObject *bpy_pydriver_Dict = NULL; +PyObject *bpy_pydriver_Dict = nullptr; #ifdef USE_BYTECODE_WHITELIST -static PyObject *bpy_pydriver_Dict__whitelist = NULL; +static PyObject *bpy_pydriver_Dict__whitelist = nullptr; #endif int bpy_pydriver_create_dict(void) @@ -60,7 +60,7 @@ int bpy_pydriver_create_dict(void) } d = PyDict_New(); - if (d == NULL) { + if (d == nullptr) { return -1; } @@ -79,14 +79,14 @@ int bpy_pydriver_create_dict(void) #endif /* Add `bpy` to global name-space. */ - mod = PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0); + mod = PyImport_ImportModuleLevel("bpy", nullptr, nullptr, nullptr, 0); if (mod) { PyDict_SetItemString(bpy_pydriver_Dict, "bpy", mod); Py_DECREF(mod); } /* Add noise to global name-space. */ - mod = PyImport_ImportModuleLevel("mathutils", NULL, NULL, NULL, 0); + mod = PyImport_ImportModuleLevel("mathutils", nullptr, nullptr, nullptr, 0); if (mod) { PyObject *modsub = PyDict_GetItemString(PyModule_GetDict(mod), "noise"); PyDict_SetItemString(bpy_pydriver_Dict, "noise", modsub); @@ -94,9 +94,9 @@ int bpy_pydriver_create_dict(void) } /* Add math utility functions. */ - mod = PyImport_ImportModuleLevel("bl_math", NULL, NULL, NULL, 0); + mod = PyImport_ImportModuleLevel("bl_math", nullptr, nullptr, nullptr, 0); if (mod) { - static const char *names[] = {"clamp", "lerp", "smoothstep", NULL}; + static const char *names[] = {"clamp", "lerp", "smoothstep", nullptr}; for (const char **pname = names; *pname; ++pname) { PyObject *func = PyDict_GetItemString(PyModule_GetDict(mod), *pname); @@ -130,7 +130,7 @@ int bpy_pydriver_create_dict(void) "lerp", "smoothstep", - NULL, + nullptr, }; for (int i = 0; whitelist[i]; i++) { @@ -138,7 +138,7 @@ int bpy_pydriver_create_dict(void) } /* Add all of `math` functions. */ - if (mod_math != NULL) { + if (mod_math != nullptr) { PyObject *mod_math_dict = PyModule_GetDict(mod_math); PyObject *arg_key, *arg_value; Py_ssize_t arg_pos = 0; @@ -160,17 +160,13 @@ int bpy_pydriver_create_dict(void) * Not thread safe but neither is Python. */ static struct { - float evaltime; + float evaltime = FLT_MAX; /* Borrowed reference to the `self` in `bpy_pydriver_Dict` * keep for as long as the same self is used. */ - PyObject *self; - BPy_StructRNA *depsgraph; -} g_pydriver_state_prev = { - .evaltime = FLT_MAX, - .self = NULL, - .depsgraph = NULL, -}; + PyObject *self = nullptr; + BPy_StructRNA *depsgraph = nullptr; +} g_pydriver_state_prev; static void bpy_pydriver_namespace_update_frame(const float evaltime) { @@ -185,7 +181,7 @@ static void bpy_pydriver_namespace_update_frame(const float evaltime) static void bpy_pydriver_namespace_update_self(PathResolvedRNA *anim_rna) { - if ((g_pydriver_state_prev.self == NULL) || + if ((g_pydriver_state_prev.self == nullptr) || (pyrna_driver_is_equal_anim_rna(anim_rna, g_pydriver_state_prev.self) == false)) { PyObject *item = pyrna_driver_self_from_anim_rna(anim_rna); @@ -201,14 +197,14 @@ static void bpy_pydriver_namespace_clear_self(void) if (g_pydriver_state_prev.self) { PyDict_DelItem(bpy_pydriver_Dict, bpy_intern_str_self); - g_pydriver_state_prev.self = NULL; + g_pydriver_state_prev.self = nullptr; } } static PyObject *bpy_pydriver_depsgraph_as_pyobject(struct Depsgraph *depsgraph) { PointerRNA depsgraph_ptr; - RNA_pointer_create(NULL, &RNA_Depsgraph, depsgraph, &depsgraph_ptr); + RNA_pointer_create(nullptr, &RNA_Depsgraph, depsgraph, &depsgraph_ptr); return pyrna_struct_CreatePyObject(&depsgraph_ptr); } @@ -219,15 +215,15 @@ static PyObject *bpy_pydriver_depsgraph_as_pyobject(struct Depsgraph *depsgraph) static void bpy_pydriver_namespace_update_depsgraph(struct Depsgraph *depsgraph) { /* This should never happen, but it's probably better to have None in Python - * than a NULL-wrapping Depsgraph Python struct. */ - BLI_assert(depsgraph != NULL); - if (UNLIKELY(depsgraph == NULL)) { + * than a nullptr-wrapping Depsgraph Python struct. */ + BLI_assert(depsgraph != nullptr); + if (UNLIKELY(depsgraph == nullptr)) { PyDict_SetItem(bpy_pydriver_Dict, bpy_intern_str_depsgraph, Py_None); - g_pydriver_state_prev.depsgraph = NULL; + g_pydriver_state_prev.depsgraph = nullptr; return; } - if ((g_pydriver_state_prev.depsgraph == NULL) || + if ((g_pydriver_state_prev.depsgraph == nullptr) || (depsgraph != g_pydriver_state_prev.depsgraph->ptr.data)) { PyObject *item = bpy_pydriver_depsgraph_as_pyobject(depsgraph); @@ -243,22 +239,22 @@ void BPY_driver_exit(void) if (bpy_pydriver_Dict) { /* Free the global dict used by python-drivers. */ PyDict_Clear(bpy_pydriver_Dict); Py_DECREF(bpy_pydriver_Dict); - bpy_pydriver_Dict = NULL; + bpy_pydriver_Dict = nullptr; } #ifdef USE_BYTECODE_WHITELIST if (bpy_pydriver_Dict__whitelist) { PyDict_Clear(bpy_pydriver_Dict__whitelist); Py_DECREF(bpy_pydriver_Dict__whitelist); - bpy_pydriver_Dict__whitelist = NULL; + bpy_pydriver_Dict__whitelist = nullptr; } #endif g_pydriver_state_prev.evaltime = FLT_MAX; /* Freed when clearing driver dictionary. */ - g_pydriver_state_prev.self = NULL; - g_pydriver_state_prev.depsgraph = NULL; + g_pydriver_state_prev.self = nullptr; + g_pydriver_state_prev.depsgraph = nullptr; } void BPY_driver_reset(void) @@ -300,161 +296,168 @@ static void pydriver_error(ChannelDriver *driver, const PathResolvedRNA *anim_rn anim_rna->prop ? RNA_property_identifier(anim_rna->prop) : null_str, anim_rna->prop_index); - // BPy_errors_to_report(NULL); /* TODO: reports. */ + // BPy_errors_to_report(nullptr); /* TODO: reports. */ PyErr_Print(); PyErr_Clear(); } #ifdef USE_BYTECODE_WHITELIST -# define OK_OP(op) [op] = true +static bool is_opcode_secure(const int opcode) +{ -static const bool secure_opcodes[255] = { +# define OK_OP(op) \ + case op: \ + return true; + + switch (opcode) { # if PY_VERSION_HEX >= 0x030b0000 /* Python 3.11 & newer. */ - OK_OP(CACHE), - OK_OP(POP_TOP), - OK_OP(PUSH_NULL), - OK_OP(NOP), - OK_OP(UNARY_POSITIVE), - OK_OP(UNARY_NEGATIVE), - OK_OP(UNARY_NOT), - OK_OP(UNARY_INVERT), - OK_OP(BINARY_SUBSCR), - OK_OP(GET_LEN), - OK_OP(LIST_TO_TUPLE), - OK_OP(RETURN_VALUE), - OK_OP(SWAP), - OK_OP(BUILD_TUPLE), - OK_OP(BUILD_LIST), - OK_OP(BUILD_SET), - OK_OP(BUILD_MAP), - OK_OP(COMPARE_OP), - OK_OP(JUMP_FORWARD), - OK_OP(JUMP_IF_FALSE_OR_POP), - OK_OP(JUMP_IF_TRUE_OR_POP), - OK_OP(POP_JUMP_FORWARD_IF_FALSE), - OK_OP(POP_JUMP_FORWARD_IF_TRUE), - OK_OP(LOAD_GLOBAL), - OK_OP(IS_OP), - OK_OP(CONTAINS_OP), - OK_OP(BINARY_OP), - OK_OP(LOAD_FAST), - OK_OP(STORE_FAST), - OK_OP(DELETE_FAST), - OK_OP(POP_JUMP_FORWARD_IF_NOT_NONE), - OK_OP(POP_JUMP_FORWARD_IF_NONE), - OK_OP(BUILD_SLICE), - OK_OP(LOAD_DEREF), - OK_OP(STORE_DEREF), - OK_OP(RESUME), - OK_OP(LIST_EXTEND), - OK_OP(SET_UPDATE), + OK_OP(CACHE) + OK_OP(POP_TOP) + OK_OP(PUSH_NULL) + OK_OP(NOP) + OK_OP(UNARY_POSITIVE) + OK_OP(UNARY_NEGATIVE) + OK_OP(UNARY_NOT) + OK_OP(UNARY_INVERT) + OK_OP(BINARY_SUBSCR) + OK_OP(GET_LEN) + OK_OP(LIST_TO_TUPLE) + OK_OP(RETURN_VALUE) + OK_OP(SWAP) + OK_OP(BUILD_TUPLE) + OK_OP(BUILD_LIST) + OK_OP(BUILD_SET) + OK_OP(BUILD_MAP) + OK_OP(COMPARE_OP) + OK_OP(JUMP_FORWARD) + OK_OP(JUMP_IF_FALSE_OR_POP) + OK_OP(JUMP_IF_TRUE_OR_POP) + OK_OP(POP_JUMP_FORWARD_IF_FALSE) + OK_OP(POP_JUMP_FORWARD_IF_TRUE) + OK_OP(LOAD_GLOBAL) + OK_OP(IS_OP) + OK_OP(CONTAINS_OP) + OK_OP(BINARY_OP) + OK_OP(LOAD_FAST) + OK_OP(STORE_FAST) + OK_OP(DELETE_FAST) + OK_OP(POP_JUMP_FORWARD_IF_NOT_NONE) + OK_OP(POP_JUMP_FORWARD_IF_NONE) + OK_OP(BUILD_SLICE) + OK_OP(LOAD_DEREF) + OK_OP(STORE_DEREF) + OK_OP(RESUME) + OK_OP(LIST_EXTEND) + OK_OP(SET_UPDATE) /* NOTE(@ideasman42): Don't enable dict manipulation, unless we can prove there is not way it * can be used to manipulate the name-space (potentially allowing malicious code). */ # if 0 - OK_OP(DICT_MERGE), - OK_OP(DICT_UPDATE), + OK_OP(DICT_MERGE) + OK_OP(DICT_UPDATE) # endif - OK_OP(POP_JUMP_BACKWARD_IF_NOT_NONE), - OK_OP(POP_JUMP_BACKWARD_IF_NONE), - OK_OP(POP_JUMP_BACKWARD_IF_FALSE), - OK_OP(POP_JUMP_BACKWARD_IF_TRUE), + OK_OP(POP_JUMP_BACKWARD_IF_NOT_NONE) + OK_OP(POP_JUMP_BACKWARD_IF_NONE) + OK_OP(POP_JUMP_BACKWARD_IF_FALSE) + OK_OP(POP_JUMP_BACKWARD_IF_TRUE) /* Special cases. */ - OK_OP(LOAD_CONST), /* Ok because constants are accepted. */ - OK_OP(LOAD_NAME), /* Ok, because `PyCodeObject.names` is checked. */ - OK_OP(CALL), /* Ok, because we check its "name" before calling. */ - OK_OP(KW_NAMES), /* Ok, because it's used for calling functions with keyword arguments. */ - OK_OP(PRECALL), /* Ok, because it's used for calling. */ + OK_OP(LOAD_CONST) /* Ok because constants are accepted. */ + OK_OP(LOAD_NAME) /* Ok, because `PyCodeObject.names` is checked. */ + OK_OP(CALL) /* Ok, because we check its "name" before calling. */ + OK_OP(KW_NAMES) /* Ok, because it's used for calling functions with keyword arguments. */ + OK_OP(PRECALL) /* Ok, because it's used for calling. */ # else /* Python 3.10 and older. */ - OK_OP(POP_TOP), - OK_OP(ROT_TWO), - OK_OP(ROT_THREE), - OK_OP(DUP_TOP), - OK_OP(DUP_TOP_TWO), - OK_OP(ROT_FOUR), - OK_OP(NOP), - OK_OP(UNARY_POSITIVE), - OK_OP(UNARY_NEGATIVE), - OK_OP(UNARY_NOT), - OK_OP(UNARY_INVERT), - OK_OP(BINARY_MATRIX_MULTIPLY), - OK_OP(INPLACE_MATRIX_MULTIPLY), - OK_OP(BINARY_POWER), - OK_OP(BINARY_MULTIPLY), - OK_OP(BINARY_MODULO), - OK_OP(BINARY_ADD), - OK_OP(BINARY_SUBTRACT), - OK_OP(BINARY_SUBSCR), - OK_OP(BINARY_FLOOR_DIVIDE), - OK_OP(BINARY_TRUE_DIVIDE), - OK_OP(INPLACE_FLOOR_DIVIDE), - OK_OP(INPLACE_TRUE_DIVIDE), - OK_OP(GET_LEN), - OK_OP(INPLACE_ADD), - OK_OP(INPLACE_SUBTRACT), - OK_OP(INPLACE_MULTIPLY), - OK_OP(INPLACE_MODULO), - OK_OP(BINARY_LSHIFT), - OK_OP(BINARY_RSHIFT), - OK_OP(BINARY_AND), - OK_OP(BINARY_XOR), - OK_OP(BINARY_OR), - OK_OP(INPLACE_POWER), - OK_OP(INPLACE_LSHIFT), - OK_OP(INPLACE_RSHIFT), - OK_OP(INPLACE_AND), - OK_OP(INPLACE_XOR), - OK_OP(INPLACE_OR), - OK_OP(LIST_TO_TUPLE), - OK_OP(RETURN_VALUE), - OK_OP(ROT_N), - OK_OP(BUILD_TUPLE), - OK_OP(BUILD_LIST), - OK_OP(BUILD_SET), - OK_OP(BUILD_MAP), - OK_OP(COMPARE_OP), - OK_OP(JUMP_FORWARD), - OK_OP(JUMP_IF_FALSE_OR_POP), - OK_OP(JUMP_IF_TRUE_OR_POP), - OK_OP(JUMP_ABSOLUTE), - OK_OP(POP_JUMP_IF_FALSE), - OK_OP(POP_JUMP_IF_TRUE), - OK_OP(LOAD_GLOBAL), - OK_OP(IS_OP), - OK_OP(CONTAINS_OP), - OK_OP(LOAD_FAST), - OK_OP(STORE_FAST), - OK_OP(DELETE_FAST), - OK_OP(BUILD_SLICE), - OK_OP(LOAD_DEREF), - OK_OP(STORE_DEREF), - OK_OP(LIST_EXTEND), - OK_OP(SET_UPDATE), + OK_OP(POP_TOP) + OK_OP(ROT_TWO) + OK_OP(ROT_THREE) + OK_OP(DUP_TOP) + OK_OP(DUP_TOP_TWO) + OK_OP(ROT_FOUR) + OK_OP(NOP) + OK_OP(UNARY_POSITIVE) + OK_OP(UNARY_NEGATIVE) + OK_OP(UNARY_NOT) + OK_OP(UNARY_INVERT) + OK_OP(BINARY_MATRIX_MULTIPLY) + OK_OP(INPLACE_MATRIX_MULTIPLY) + OK_OP(BINARY_POWER) + OK_OP(BINARY_MULTIPLY) + OK_OP(BINARY_MODULO) + OK_OP(BINARY_ADD) + OK_OP(BINARY_SUBTRACT) + OK_OP(BINARY_SUBSCR) + OK_OP(BINARY_FLOOR_DIVIDE) + OK_OP(BINARY_TRUE_DIVIDE) + OK_OP(INPLACE_FLOOR_DIVIDE) + OK_OP(INPLACE_TRUE_DIVIDE) + OK_OP(GET_LEN) + OK_OP(INPLACE_ADD) + OK_OP(INPLACE_SUBTRACT) + OK_OP(INPLACE_MULTIPLY) + OK_OP(INPLACE_MODULO) + OK_OP(BINARY_LSHIFT) + OK_OP(BINARY_RSHIFT) + OK_OP(BINARY_AND) + OK_OP(BINARY_XOR) + OK_OP(BINARY_OR) + OK_OP(INPLACE_POWER) + OK_OP(INPLACE_LSHIFT) + OK_OP(INPLACE_RSHIFT) + OK_OP(INPLACE_AND) + OK_OP(INPLACE_XOR) + OK_OP(INPLACE_OR) + OK_OP(LIST_TO_TUPLE) + OK_OP(RETURN_VALUE) + OK_OP(ROT_N) + OK_OP(BUILD_TUPLE) + OK_OP(BUILD_LIST) + OK_OP(BUILD_SET) + OK_OP(BUILD_MAP) + OK_OP(COMPARE_OP) + OK_OP(JUMP_FORWARD) + OK_OP(JUMP_IF_FALSE_OR_POP) + OK_OP(JUMP_IF_TRUE_OR_POP) + OK_OP(JUMP_ABSOLUTE) + OK_OP(POP_JUMP_IF_FALSE) + OK_OP(POP_JUMP_IF_TRUE) + OK_OP(LOAD_GLOBAL) + OK_OP(IS_OP) + OK_OP(CONTAINS_OP) + OK_OP(LOAD_FAST) + OK_OP(STORE_FAST) + OK_OP(DELETE_FAST) + OK_OP(BUILD_SLICE) + OK_OP(LOAD_DEREF) + OK_OP(STORE_DEREF) + OK_OP(LIST_EXTEND) + OK_OP(SET_UPDATE) /* NOTE(@ideasman42): Don't enable dict manipulation, unless we can prove there is not way it * can be used to manipulate the name-space (potentially allowing malicious code). */ # if 0 - OK_OP(DICT_MERGE), - OK_OP(DICT_UPDATE), + OK_OP(DICT_MERGE) + OK_OP(DICT_UPDATE) # endif /* Special cases. */ - OK_OP(LOAD_CONST), /* Ok because constants are accepted. */ - OK_OP(LOAD_NAME), /* Ok, because `PyCodeObject.names` is checked. */ - OK_OP(CALL_FUNCTION), /* Ok, because we check its "name" before calling. */ - OK_OP(CALL_FUNCTION_KW), - OK_OP(CALL_FUNCTION_EX), + OK_OP(LOAD_CONST) /* Ok because constants are accepted. */ + OK_OP(LOAD_NAME) /* Ok, because `PyCodeObject.names` is checked. */ + OK_OP(CALL_FUNCTION) /* Ok, because we check its "name" before calling. */ + OK_OP(CALL_FUNCTION_KW) + OK_OP(CALL_FUNCTION_EX) # endif /* Python 3.10 and older. */ -}; + } # undef OK_OP + return false; +} bool BPY_driver_secure_bytecode_test_ex(PyObject *expr_code, - PyObject *namespace_array[], + PyObject *py_namespace_array[], const bool verbose, const char *error_prefix) { @@ -466,8 +469,8 @@ bool BPY_driver_secure_bytecode_test_ex(PyObject *expr_code, PyObject *name = PyTuple_GET_ITEM(py_code->co_names, i); const char *name_str = PyUnicode_AsUTF8(name); bool contains_name = false; - for (int j = 0; namespace_array[j]; j++) { - if (PyDict_Contains(namespace_array[j], name)) { + for (int j = 0; py_namespace_array[j]; j++) { + if (PyDict_Contains(py_namespace_array[j], name)) { contains_name = true; break; } @@ -511,7 +514,7 @@ bool BPY_driver_secure_bytecode_test_ex(PyObject *expr_code, /* Loop over op-code's, the op-code arguments are ignored. */ for (Py_ssize_t i = 0; i < code_len; i++) { const int opcode = _Py_OPCODE(codestr[i]); - if (secure_opcodes[opcode] == false) { + if (!is_opcode_secure(opcode)) { if (verbose) { fprintf(stderr, "\t%s: restricted access disallows opcode '%d', " @@ -535,7 +538,9 @@ bool BPY_driver_secure_bytecode_test_ex(PyObject *expr_code, return true; } -bool BPY_driver_secure_bytecode_test(PyObject *expr_code, PyObject *namespace, const bool verbose) +bool BPY_driver_secure_bytecode_test(PyObject *expr_code, + PyObject *py_namespace, + const bool verbose) { if (!bpy_pydriver_Dict) { @@ -544,15 +549,9 @@ bool BPY_driver_secure_bytecode_test(PyObject *expr_code, PyObject *namespace, c return false; } } - return BPY_driver_secure_bytecode_test_ex(expr_code, - (PyObject *[]){ - bpy_pydriver_Dict, - bpy_pydriver_Dict__whitelist, - namespace, - NULL, - }, - verbose, - __func__); + PyObject *py_namespaces[] = { + bpy_pydriver_Dict, bpy_pydriver_Dict__whitelist, py_namespace, nullptr}; + return BPY_driver_secure_bytecode_test_ex(expr_code, py_namespaces, verbose, __func__); } #endif /* USE_BYTECODE_WHITELIST */ @@ -574,8 +573,8 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna, * original driver, otherwise these would get freed while editing. * Due to the GIL this is thread-safe. */ - PyObject *driver_vars = NULL; - PyObject *retval = NULL; + PyObject *driver_vars = nullptr; + PyObject *retval = nullptr; /* Speed up by pre-hashing string & avoids re-converting unicode strings for every execution. */ PyObject *expr_vars; @@ -642,7 +641,7 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna, bpy_pydriver_namespace_update_depsgraph(anim_eval_context->depsgraph); - if (driver_orig->expr_comp == NULL) { + if (driver_orig->expr_comp == nullptr) { driver_orig->flag |= DRIVER_FLAG_RECOMPILE; } @@ -674,7 +673,8 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna, expr_vars = PyTuple_New(BLI_listbase_count(&driver_orig->variables)); PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 1, expr_vars); - for (dvar = driver_orig->variables.first, i = 0; dvar; dvar = dvar->next) { + for (dvar = static_cast(driver_orig->variables.first), i = 0; dvar; + dvar = dvar->next) { PyTuple_SET_ITEM(expr_vars, i++, PyUnicode_FromString(dvar->name)); } @@ -686,16 +686,16 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna, /* Add target values to a dict that will be used as `__locals__` dict. */ driver_vars = _PyDict_NewPresized(PyTuple_GET_SIZE(expr_vars)); - for (dvar = driver->variables.first, i = 0; dvar; dvar = dvar->next) { - PyObject *driver_arg = NULL; + for (dvar = static_cast(driver->variables.first), i = 0; dvar; dvar = dvar->next) { + PyObject *driver_arg = nullptr; - /* Support for any RNA data. */ +/* Support for any RNA data. */ #ifdef USE_RNA_AS_PYOBJECT if (dvar->type == DVAR_TYPE_SINGLE_PROP) { driver_arg = pyrna_driver_get_variable_value( anim_eval_context, driver, dvar, &dvar->targets[0]); - if (driver_arg == NULL) { + if (driver_arg == nullptr) { driver_arg = PyFloat_FromDouble(0.0); dvar->curval = 0.0f; } @@ -737,7 +737,7 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna, } fprintf(stderr, "\t%s: couldn't add variable '%s' to namespace\n", __func__, dvar->name); - // BPy_errors_to_report(NULL); /* TODO: reports. */ + // BPy_errors_to_report(nullptr); /* TODO: reports. */ PyErr_Print(); PyErr_Clear(); } @@ -747,14 +747,11 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna, #ifdef USE_BYTECODE_WHITELIST if (is_recompile && expr_code) { if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC)) { + PyObject *py_namespaces[] = { + bpy_pydriver_Dict, bpy_pydriver_Dict__whitelist, driver_vars, nullptr}; if (!BPY_driver_secure_bytecode_test_ex( expr_code, - (PyObject *[]){ - bpy_pydriver_Dict, - bpy_pydriver_Dict__whitelist, - driver_vars, - NULL, - }, + py_namespaces, /* Always be verbose since this can give hints to why evaluation fails. */ true, __func__)) @@ -765,20 +762,21 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna, } Py_DECREF(expr_code); - expr_code = NULL; - PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 0, NULL); + expr_code = nullptr; + PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 0, nullptr); } } } #endif /* USE_BYTECODE_WHITELIST */ #if 0 /* slow, with this can avoid all Py_CompileString above. */ - /* execute expression to get a value */ - retval = PyRun_String(expr, Py_eval_input, bpy_pydriver_Dict, driver_vars); +/* execute expression to get a value */ +retval = PyRun_String(expr, Py_eval_input, bpy_pydriver_Dict, driver_vars); #else /* Evaluate the compiled expression. */ if (expr_code) { - retval = PyEval_EvalCode((void *)expr_code, bpy_pydriver_Dict, driver_vars); + retval = PyEval_EvalCode( + static_cast((void *)expr_code), bpy_pydriver_Dict, driver_vars); } #endif @@ -786,7 +784,7 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna, Py_DECREF(driver_vars); /* Process the result. */ - if (retval == NULL) { + if (retval == nullptr) { pydriver_error(driver, anim_rna); } else { diff --git a/source/blender/python/intern/bpy_driver.h b/source/blender/python/intern/bpy_driver.h index c84af7d24f7..d4ead8383fc 100644 --- a/source/blender/python/intern/bpy_driver.h +++ b/source/blender/python/intern/bpy_driver.h @@ -26,11 +26,11 @@ int bpy_pydriver_create_dict(void); extern PyObject *bpy_pydriver_Dict; extern bool BPY_driver_secure_bytecode_test_ex(PyObject *expr_code, - PyObject *namespace_array[], + PyObject *py_namespace_array[], const bool verbose, const char *error_prefix); extern bool BPY_driver_secure_bytecode_test(PyObject *expr_code, - PyObject *namespace, + PyObject *py_namespace, const bool verbose); #ifdef __cplusplus diff --git a/source/blender/python/intern/bpy_gizmo_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.cc similarity index 89% rename from source/blender/python/intern/bpy_gizmo_wrap.c rename to source/blender/python/intern/bpy_gizmo_wrap.cc index b7009347832..68589b8b899 100644 --- a/source/blender/python/intern/bpy_gizmo_wrap.c +++ b/source/blender/python/intern/bpy_gizmo_wrap.cc @@ -44,15 +44,15 @@ static bool bpy_gizmotype_target_property_def(wmGizmoType *gzt, PyObject *item) struct { char *id; - struct BPy_EnumProperty_Parse type_enum; + BPy_EnumProperty_Parse type_enum; int array_length; - } params = { - .id = NULL, /* not optional */ - .type_enum = {.items = rna_enum_property_type_items, .value = PROP_FLOAT}, - .array_length = 1, - }; + } params{}; + params.id = nullptr; /* not optional */ + params.type_enum.items = rna_enum_property_type_items; + params.type_enum.value = PROP_FLOAT; + params.array_length = 1; - static const char *const _keywords[] = {"id", "type", "array_length", NULL}; + static const char *const _keywords[] = {"id", "type", "array_length", nullptr}; static _PyArg_Parser _parser = { "|$" /* Optional keyword only arguments. */ "s" /* `id` */ @@ -73,7 +73,7 @@ static bool bpy_gizmotype_target_property_def(wmGizmoType *gzt, PyObject *item) goto fail; } - if (params.id == NULL) { + if (params.id == nullptr) { PyErr_SetString(PyExc_ValueError, "'id' argument not given"); goto fail; } @@ -94,7 +94,7 @@ fail: static void gizmo_properties_init(wmGizmoType *gzt) { - PyTypeObject *py_class = gzt->rna_ext.data; + PyTypeObject *py_class = static_cast(gzt->rna_ext.data); RNA_struct_blender_type_set(gzt->rna_ext.srna, gzt); /* only call this so pyrna_deferred_register_class gives a useful error @@ -117,7 +117,7 @@ static void gizmo_properties_init(wmGizmoType *gzt) bpy_intern_str_bl_target_properties); /* Some widgets may only exist to activate operators. */ - if (bl_target_properties != NULL) { + if (bl_target_properties != nullptr) { PyObject *bl_target_properties_fast; if (!(bl_target_properties_fast = PySequence_Fast(bl_target_properties, "bl_target_properties sequence"))) @@ -152,7 +152,7 @@ void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata) *gzt = *((wmGizmoType *)userdata); gzt->srna = srna; /* restore */ - /* don't do translations here yet */ +/* don't do translations here yet */ #if 0 /* Use i18n context from rna_ext.srna if possible (py gizmo-groups). */ if (gt->rna_ext.srna) { @@ -173,7 +173,7 @@ void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata) static void gizmogroup_properties_init(wmGizmoGroupType *gzgt) { - PyTypeObject *py_class = gzgt->rna_ext.data; + PyTypeObject *py_class = static_cast(gzgt->rna_ext.data); RNA_struct_blender_type_set(gzgt->rna_ext.srna, gzgt); /* only call this so pyrna_deferred_register_class gives a useful error @@ -195,11 +195,12 @@ void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata) *gzgt = *((wmGizmoGroupType *)userdata); gzgt->srna = srna; /* restore */ - /* don't do translations here yet */ +/* don't do translations here yet */ #if 0 /* Use i18n context from rna_ext.srna if possible (py gizmo-groups). */ if (gzgt->rna_ext.srna) { - RNA_def_struct_translation_context(gzgt->srna, RNA_struct_translation_context(gzgt->rna_ext.srna)); + RNA_def_struct_translation_context(gzgt->srna, + RNA_struct_translation_context(gzgt->rna_ext.srna)); } #endif diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.cc similarity index 93% rename from source/blender/python/intern/bpy_interface.c rename to source/blender/python/intern/bpy_interface.cc index 148254d9037..6461208118b 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.cc @@ -131,7 +131,7 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate) } } -void bpy_context_clear(bContext *UNUSED(C), const PyGILState_STATE *gilstate) +void bpy_context_clear(bContext * /*C*/, const PyGILState_STATE *gilstate) { py_call_level--; @@ -143,10 +143,10 @@ void bpy_context_clear(bContext *UNUSED(C), const PyGILState_STATE *gilstate) fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n"); } else if (py_call_level == 0) { - /* XXX: Calling classes currently won't store the context :\, - * can't set NULL because of this. but this is very flaky still. */ +/* XXX: Calling classes currently won't store the context :\, + * can't set nullptr because of this. but this is very flaky still. */ #if 0 - BPY_context_set(NULL); + BPY_context_set(nullptr); #endif #ifdef TIME_PY_RUN @@ -158,7 +158,7 @@ void bpy_context_clear(bContext *UNUSED(C), const PyGILState_STATE *gilstate) static void bpy_context_end(bContext *C) { - if (UNLIKELY(C == NULL)) { + if (UNLIKELY(C == nullptr)) { return; } CTX_wm_operator_poll_msg_clear(C); @@ -178,10 +178,10 @@ void BPY_context_dict_clear_members_array(void **dict_p, /* Copy on write. */ if (*dict_p == dict_orig) { - *dict_p = PyDict_Copy(dict_orig); + *dict_p = PyDict_Copy(static_cast(dict_orig)); } - PyObject *dict = *dict_p; + PyObject *dict = static_cast(*dict_p); BLI_assert(PyDict_Check(dict)); /* Use #PyDict_Pop instead of #PyDict_DelItemString to avoid setting the exception, @@ -209,7 +209,7 @@ void BPY_text_free_code(Text *text) } Py_DECREF((PyObject *)text->compiled); - text->compiled = NULL; + text->compiled = nullptr; if (use_gil) { PyGILState_Release(gilstate); @@ -220,7 +220,7 @@ void BPY_text_free_code(Text *text) void BPY_modules_update(void) { #if 0 /* slow, this runs all the time poll, draw etc 100's of time a sec. */ - PyObject *mod = PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0); + PyObject *mod = PyImport_ImportModuleLevel("bpy", nullptr, nullptr, nullptr, 0); PyModule_AddObject(mod, "data", BPY_rna_module()); PyModule_AddObject(mod, "types", BPY_rna_types()); /* This does not need updating. */ #endif @@ -231,7 +231,7 @@ void BPY_modules_update(void) bContext *BPY_context_get(void) { - return bpy_context_module->ptr.data; + return static_cast(bpy_context_module->ptr.data); } void BPY_context_set(bContext *C) @@ -241,12 +241,12 @@ void BPY_context_set(bContext *C) #ifdef WITH_FLUID /* defined in manta module */ -extern PyObject *Manta_initPython(void); +extern "C" PyObject *Manta_initPython(void); #endif #ifdef WITH_AUDASPACE_PY /* defined in AUD_C-API.cpp */ -extern PyObject *AUD_initPython(void); +extern "C" PyObject *AUD_initPython(void); #endif #ifdef WITH_CYCLES @@ -286,7 +286,7 @@ static struct _inittab bpy_internal_modules[] = { #endif {"gpu", BPyInit_gpu}, {"idprop", BPyInit_idprop}, - {NULL, NULL}, + {nullptr, nullptr}, }; #ifndef WITH_PYTHON_MODULE @@ -417,10 +417,10 @@ void BPY_python_start(bContext *C, int argc, const char **argv) } } - /* Allow to use our own included Python. `py_path_bundle` may be NULL. */ + /* Allow to use our own included Python. `py_path_bundle` may be nullptr. */ { - const char *py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, NULL); - if (py_path_bundle != NULL) { + const char *py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, nullptr); + if (py_path_bundle != nullptr) { # ifdef __APPLE__ /* Mac-OS allows file/directory names to contain `:` character @@ -437,7 +437,7 @@ void BPY_python_start(bContext *C, int argc, const char **argv) pystatus_exit_on_error(status); } else { - /* Common enough to use the system Python on Linux/Unix, warn on other systems. */ +/* Common enough to use the system Python on Linux/Unix, warn on other systems. */ # if defined(__APPLE__) || defined(_WIN32) fprintf(stderr, "Bundled Python not found and is expected on this platform " @@ -515,9 +515,8 @@ void BPY_python_start(bContext *C, int argc, const char **argv) #ifdef WITH_PYTHON_MODULE /* Disable all add-ons at exit, not essential, it just avoids resource leaks, see #71362. */ - BPY_run_string_eval(C, - (const char *[]){"atexit", "addon_utils", NULL}, - "atexit.register(addon_utils.disable_all)"); + const char *imports[] = {"atexit", "addon_utils", nullptr}; + BPY_run_string_eval(C, imports, "atexit.register(addon_utils.disable_all)"); #endif } @@ -633,7 +632,7 @@ void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr) const bool do_invalidate = (Py_REFCNT((PyObject *)pyob_ptr) > 1); Py_DECREF((PyObject *)pyob_ptr); if (do_invalidate) { - pyrna_invalidate(pyob_ptr); + pyrna_invalidate(static_cast(pyob_ptr)); } PyGILState_Release(gilstate); } @@ -645,7 +644,7 @@ void BPY_modules_load_user(bContext *C) Text *text; /* can happen on file load */ - if (bmain == NULL) { + if (bmain == nullptr) { return; } @@ -657,7 +656,9 @@ void BPY_modules_load_user(bContext *C) bpy_context_set(C, &gilstate); - for (text = bmain->texts.first; text; text = text->id.next) { + for (text = static_cast(bmain->texts.first); text; + text = static_cast(text->id.next)) + { if (text->flags & TXT_ISSCRIPT) { if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC)) { if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET)) { @@ -670,7 +671,7 @@ void BPY_modules_load_user(bContext *C) } } else { - BPY_run_text(C, text, NULL, false); + BPY_run_text(C, text, nullptr, false); /* Check if the script loaded a new file. */ if (bmain != CTX_data_main(C)) { @@ -689,7 +690,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult * PyObject *pyctx; PyObject *item; - PointerRNA *ptr = NULL; + PointerRNA *ptr = nullptr; bool done = false; if (use_gil) { @@ -699,7 +700,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult * pyctx = (PyObject *)CTX_py_dict_get(C); item = PyDict_GetItemString(pyctx, member); - if (item == NULL) { + if (item == nullptr) { /* pass */ } else if (item == Py_None) { @@ -715,7 +716,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult * } else if (PySequence_Check(item)) { PyObject *seq_fast = PySequence_Fast(item, "bpy_context_get sequence conversion"); - if (seq_fast == NULL) { + if (seq_fast == nullptr) { PyErr_Print(); PyErr_Clear(); } @@ -782,20 +783,20 @@ extern void main_python_exit(void); static struct PyModuleDef bpy_proxy_def = { /*m_base*/ PyModuleDef_HEAD_INIT, /*m_name*/ "bpy", - /*m_doc*/ NULL, + /*m_doc*/ nullptr, /*m_size*/ 0, - /*m_methods*/ NULL, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, + /*m_methods*/ nullptr, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, /*m_free*/ bpy_module_free, }; -typedef struct { +struct dealloc_obj { PyObject_HEAD /* Type-specific fields go here. */ PyObject *mod; -} dealloc_obj; +}; /* call once __file__ is set */ static void bpy_module_delay_init(PyObject *bpy_proxy) @@ -814,7 +815,7 @@ static void bpy_module_delay_init(PyObject *bpy_proxy) Py_DECREF(filepath_obj); argv[0] = filepath_abs; - argv[1] = NULL; + argv[1] = nullptr; // printf("module found %s\n", argv[0]); @@ -830,10 +831,10 @@ static void bpy_module_delay_init(PyObject *bpy_proxy) */ static bool bpy_module_ensure_compatible_version(void) { - /* First check the Python version used matches the major version that Blender was built with. - * While this isn't essential, the error message in this case may be cryptic and misleading. - * NOTE: using `Py_LIMITED_API` would remove the need for this, in practice it's - * unlikely Blender will ever used the limited API though. */ +/* First check the Python version used matches the major version that Blender was built with. + * While this isn't essential, the error message in this case may be cryptic and misleading. + * NOTE: using `Py_LIMITED_API` would remove the need for this, in practice it's + * unlikely Blender will ever used the limited API though. */ # if PY_VERSION_HEX >= 0x030b0000 /* Python 3.11 & newer. */ const uint version_runtime = Py_Version; # else @@ -887,7 +888,7 @@ PyMODINIT_FUNC PyInit_bpy(void); PyMODINIT_FUNC PyInit_bpy(void) { if (!bpy_module_ensure_compatible_version()) { - return NULL; /* The error has been set. */ + return nullptr; /* The error has been set. */ } PyObject *bpy_proxy = PyModule_Create(&bpy_proxy_def); @@ -916,7 +917,7 @@ PyMODINIT_FUNC PyInit_bpy(void) dealloc_obj_Type.tp_flags = Py_TPFLAGS_DEFAULT; if (PyType_Ready(&dealloc_obj_Type) < 0) { - return NULL; + return nullptr; } dob = (dealloc_obj *)dealloc_obj_Type.tp_alloc(&dealloc_obj_Type, 0); @@ -926,7 +927,7 @@ PyMODINIT_FUNC PyInit_bpy(void) return bpy_proxy; } -static void bpy_module_free(void *UNUSED(mod)) +static void bpy_module_free(void * /*mod*/) { main_python_exit(); } @@ -942,7 +943,7 @@ bool BPY_string_is_keyword(const char *str) "False", "None", "True", "and", "as", "assert", "async", "await", "break", "class", "continue", "def", "del", "elif", "else", "except", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "nonlocal", "not", - "or", "pass", "raise", "return", "try", "while", "with", "yield", NULL, + "or", "pass", "raise", "return", "try", "while", "with", "yield", nullptr, }; for (int i = 0; kwlist[i]; i++) { diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.cc similarity index 77% rename from source/blender/python/intern/bpy_interface_atexit.c rename to source/blender/python/intern/bpy_interface_atexit.cc index 66490d16526..c916b8134bc 100644 --- a/source/blender/python/intern/bpy_interface_atexit.c +++ b/source/blender/python/intern/bpy_interface_atexit.cc @@ -19,7 +19,7 @@ #include "WM_api.h" -static PyObject *bpy_atexit(PyObject *UNUSED(self), PyObject *UNUSED(args), PyObject *UNUSED(kw)) +static PyObject *bpy_atexit(PyObject * /*self*/, PyObject * /*args*/, PyObject * /*kw*/) { /* close down enough of blender at least not to crash */ struct bContext *C = BPY_context_get(); @@ -29,15 +29,15 @@ static PyObject *bpy_atexit(PyObject *UNUSED(self), PyObject *UNUSED(args), PyOb Py_RETURN_NONE; } -static PyMethodDef meth_bpy_atexit = {"bpy_atexit", (PyCFunction)bpy_atexit, METH_NOARGS, NULL}; -static PyObject *func_bpy_atregister = NULL; /* borrowed reference, `atexit` holds. */ +static PyMethodDef meth_bpy_atexit = {"bpy_atexit", (PyCFunction)bpy_atexit, METH_NOARGS, nullptr}; +static PyObject *func_bpy_atregister = nullptr; /* borrowed reference, `atexit` holds. */ static void atexit_func_call(const char *func_name, PyObject *atexit_func_arg) { /* NOTE(@ideasman42): no error checking, if any of these fail we'll get a crash * this is intended, but if its problematic it could be changed. */ - PyObject *atexit_mod = PyImport_ImportModuleLevel("atexit", NULL, NULL, NULL, 0); + PyObject *atexit_mod = PyImport_ImportModuleLevel("atexit", nullptr, nullptr, nullptr, 0); PyObject *atexit_func = PyObject_GetAttrString(atexit_mod, func_name); PyObject *args = PyTuple_New(1); PyObject *ret; @@ -62,16 +62,16 @@ static void atexit_func_call(const char *func_name, PyObject *atexit_func_arg) void BPY_atexit_register(void) { /* atexit module owns this new function reference */ - BLI_assert(func_bpy_atregister == NULL); + BLI_assert(func_bpy_atregister == nullptr); - func_bpy_atregister = (PyObject *)PyCFunction_New(&meth_bpy_atexit, NULL); + func_bpy_atregister = (PyObject *)PyCFunction_New(&meth_bpy_atexit, nullptr); atexit_func_call("register", func_bpy_atregister); } void BPY_atexit_unregister(void) { - BLI_assert(func_bpy_atregister != NULL); + BLI_assert(func_bpy_atregister != nullptr); atexit_func_call("unregister", func_bpy_atregister); - func_bpy_atregister = NULL; /* don't really need to set but just in case */ + func_bpy_atregister = nullptr; /* don't really need to set but just in case */ } diff --git a/source/blender/python/intern/bpy_interface_run.c b/source/blender/python/intern/bpy_interface_run.cc similarity index 91% rename from source/blender/python/intern/bpy_interface_run.c rename to source/blender/python/intern/bpy_interface_run.cc index 67b169fc7b6..ce5778aec03 100644 --- a/source/blender/python/intern/bpy_interface_run.c +++ b/source/blender/python/intern/bpy_interface_run.cc @@ -72,17 +72,17 @@ static void bpy_text_filepath_get(char *filepath, #ifdef PYMODULE_CLEAR_WORKAROUND /* bad!, we should never do this, but currently only safe way I could find to keep namespace. * from being cleared. - campbell */ -typedef struct { +struct PyModuleObject { PyObject_HEAD PyObject *md_dict; /* omit other values, we only want the dict. */ -} PyModuleObject; +}; #endif /** * Execute a file-path or text-block. * - * \param reports: Report exceptions as errors (may be NULL). + * \param reports: Report exceptions as errors (may be nullptr). * \param do_jump: See #BPY_run_text. * * \note Share a function for this since setup/cleanup logic is the same. @@ -91,17 +91,17 @@ static bool python_script_exec( bContext *C, const char *filepath, Text *text, ReportList *reports, const bool do_jump) { Main *bmain_old = CTX_data_main(C); - PyObject *main_mod = NULL; - PyObject *py_dict = NULL, *py_result = NULL; + PyObject *main_mod = nullptr; + PyObject *py_dict = nullptr, *py_result = nullptr; PyGILState_STATE gilstate; char filepath_dummy[FILE_MAX]; /** The `__file__` added into the name-space. */ - const char *filepath_namespace = NULL; + const char *filepath_namespace = nullptr; BLI_assert(filepath || text); - if (filepath == NULL && text == NULL) { + if (filepath == nullptr && text == nullptr) { return 0; } @@ -113,7 +113,7 @@ static bool python_script_exec( bpy_text_filepath_get(filepath_dummy, sizeof(filepath_dummy), bmain_old, text); filepath_namespace = filepath_dummy; - if (text->compiled == NULL) { /* if it wasn't already compiled, do it now */ + if (text->compiled == nullptr) { /* if it wasn't already compiled, do it now */ char *buf; PyObject *filepath_dummy_py; @@ -121,7 +121,7 @@ static bool python_script_exec( size_t buf_len_dummy; buf = txt_to_buf(text, &buf_len_dummy); - text->compiled = Py_CompileStringObject(buf, filepath_dummy_py, Py_file_input, NULL, -1); + text->compiled = Py_CompileStringObject(buf, filepath_dummy_py, Py_file_input, nullptr, -1); MEM_freeN(buf); Py_DECREF(filepath_dummy_py); @@ -133,7 +133,7 @@ static bool python_script_exec( if (text->compiled) { py_dict = PyC_DefaultNameSpace(filepath_dummy); - py_result = PyEval_EvalCode(text->compiled, py_dict, py_dict); + py_result = PyEval_EvalCode(static_cast(text->compiled), py_dict, py_dict); } } else { @@ -175,7 +175,7 @@ static bool python_script_exec( else { PyErr_Format( PyExc_IOError, "Python file \"%s\" could not be opened: %s", filepath, strerror(errno)); - py_result = NULL; + py_result = nullptr; } } @@ -203,7 +203,7 @@ static bool python_script_exec( PyObject *dict_back = mmod->md_dict; /* freeing the module will clear the namespace, * gives problems running classes defined in this namespace being used later. */ - mmod->md_dict = NULL; + mmod->md_dict = nullptr; Py_DECREF(dict_back); #endif @@ -214,7 +214,7 @@ static bool python_script_exec( bpy_context_clear(C, &gilstate); - return (py_result != NULL); + return (py_result != nullptr); } /** \} */ @@ -225,12 +225,12 @@ static bool python_script_exec( bool BPY_run_filepath(bContext *C, const char *filepath, ReportList *reports) { - return python_script_exec(C, filepath, NULL, reports, false); + return python_script_exec(C, filepath, nullptr, reports, false); } bool BPY_run_text(bContext *C, Text *text, ReportList *reports, const bool do_jump) { - return python_script_exec(C, NULL, text, reports, do_jump); + return python_script_exec(C, nullptr, text, reports, do_jump); } /** @@ -244,7 +244,7 @@ static bool bpy_run_string_impl(bContext *C, { BLI_assert(expr); PyGILState_STATE gilstate; - PyObject *main_mod = NULL; + PyObject *main_mod = nullptr; PyObject *py_dict, *retval; bool ok = true; @@ -260,13 +260,13 @@ static bool bpy_run_string_impl(bContext *C, if (imports && !PyC_NameSpace_ImportArray(py_dict, imports)) { Py_DECREF(py_dict); - retval = NULL; + retval = nullptr; } else { retval = PyRun_String(expr, mode, py_dict, py_dict); } - if (retval == NULL) { + if (retval == nullptr) { ok = false; ReportList reports; @@ -319,7 +319,7 @@ bool BPY_run_string_exec(bContext *C, const char *imports[], const char *expr) static void run_string_handle_error(struct BPy_RunErrInfo *err_info) { - if (err_info == NULL) { + if (err_info == nullptr) { PyErr_Print(); PyErr_Clear(); return; @@ -336,7 +336,7 @@ static void run_string_handle_error(struct BPy_RunErrInfo *err_info) const char *err_str = py_err_str ? PyUnicode_AsUTF8(py_err_str) : "Unable to extract exception"; PyErr_Clear(); - if (err_info->reports != NULL) { + if (err_info->reports != nullptr) { if (err_info->report_prefix) { BKE_reportf(err_info->reports, RPT_ERROR, "%s: %s", err_info->report_prefix, err_str); } @@ -346,14 +346,14 @@ static void run_string_handle_error(struct BPy_RunErrInfo *err_info) } /* Print the reports if they were not printed already. */ - if ((err_info->reports == NULL) || !BKE_reports_print_test(err_info->reports, RPT_ERROR)) { + if ((err_info->reports == nullptr) || !BKE_reports_print_test(err_info->reports, RPT_ERROR)) { if (err_info->report_prefix) { fprintf(stderr, "%s: ", err_info->report_prefix); } fprintf(stderr, "%s\n", err_str); } - if (err_info->r_string != NULL) { + if (err_info->r_string != nullptr) { *err_info->r_string = BLI_strdup(err_str); } @@ -398,7 +398,7 @@ bool BPY_run_string_as_string_and_len(bContext *C, bool ok = true; if (expr[0] == '\0') { - *r_value = NULL; + *r_value = nullptr; return ok; } diff --git a/source/blender/python/intern/bpy_intern_string.c b/source/blender/python/intern/bpy_intern_string.cc similarity index 100% rename from source/blender/python/intern/bpy_intern_string.c rename to source/blender/python/intern/bpy_intern_string.cc diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.cc similarity index 87% rename from source/blender/python/intern/bpy_library_load.c rename to source/blender/python/intern/bpy_library_load.cc index a78d8441ba3..4b3ee72eedc 100644 --- a/source/blender/python/intern/bpy_library_load.c +++ b/source/blender/python/intern/bpy_library_load.cc @@ -49,7 +49,7 @@ # include "bpy_rna.h" #endif -typedef struct { +struct BPy_Library { PyObject_HEAD /* Required Python macro. */ /* Collection iterator specific parts. */ char relpath[FILE_MAX]; @@ -69,7 +69,7 @@ typedef struct { * Defaults to #G.main, Otherwise use a temporary #Main when `bmain_is_temp` is true. */ Main *bmain; bool bmain_is_temp; -} BPy_Library; +}; static PyObject *bpy_lib_load(BPy_PropertyRNA *self, PyObject *args, PyObject *kwds); static PyObject *bpy_lib_enter(BPy_Library *self); @@ -80,7 +80,7 @@ static PyMethodDef bpy_lib_methods[] = { {"__enter__", (PyCFunction)bpy_lib_enter, METH_NOARGS}, {"__exit__", (PyCFunction)bpy_lib_exit, METH_VARARGS}, {"__dir__", (PyCFunction)bpy_lib_dir, METH_NOARGS}, - {NULL} /* sentinel */ + {nullptr} /* sentinel */ }; static void bpy_lib_dealloc(BPy_Library *self) @@ -90,55 +90,55 @@ static void bpy_lib_dealloc(BPy_Library *self) } static PyTypeObject bpy_lib_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy_lib", /*tp_basicsize*/ sizeof(BPy_Library), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)bpy_lib_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, - /*tp_repr*/ NULL, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, + /*tp_repr*/ nullptr, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, /*tp_getattro*/ PyObject_GenericGetAttr, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT, - /*tp_doc*/ NULL, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_doc*/ nullptr, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ bpy_lib_methods, - /*tp_members*/ NULL, - /*tp_getset*/ NULL, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ offsetof(BPy_Library, dict), - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; PyDoc_STRVAR( @@ -175,9 +175,9 @@ PyDoc_STRVAR( static PyObject *bpy_lib_load(BPy_PropertyRNA *self, PyObject *args, PyObject *kw) { Main *bmain_base = CTX_data_main(BPY_context_get()); - Main *bmain = self->ptr.data; /* Typically #G_MAIN */ + Main *bmain = static_cast
(self->ptr.data); /* Typically #G_MAIN */ BPy_Library *ret; - const char *filepath = NULL; + const char *filepath = nullptr; bool is_rel = false, is_link = false, use_assets_only = false; bool create_liboverrides = false, reuse_liboverrides = false, create_liboverrides_runtime = false; @@ -190,7 +190,7 @@ static PyObject *bpy_lib_load(BPy_PropertyRNA *self, PyObject *args, PyObject *k "create_liboverrides", "reuse_liboverrides", "create_liboverrides_runtime", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "s" /* `filepath` */ @@ -223,22 +223,22 @@ static PyObject *bpy_lib_load(BPy_PropertyRNA *self, PyObject *args, PyObject *k PyC_ParseBool, &create_liboverrides_runtime)) { - return NULL; + return nullptr; } if (!is_link && create_liboverrides) { PyErr_SetString(PyExc_ValueError, "`link` is False but `create_liboverrides` is True"); - return NULL; + return nullptr; } if (!create_liboverrides && reuse_liboverrides) { PyErr_SetString(PyExc_ValueError, "`create_liboverrides` is False but `reuse_liboverrides` is True"); - return NULL; + return nullptr; } if (!create_liboverrides && create_liboverrides_runtime) { PyErr_SetString(PyExc_ValueError, "`create_liboverrides` is False but `create_liboverrides_runtime` is True"); - return NULL; + return nullptr; } ret = PyObject_New(BPy_Library, &bpy_lib_Type); @@ -250,15 +250,15 @@ static PyObject *bpy_lib_load(BPy_PropertyRNA *self, PyObject *args, PyObject *k ret->bmain = bmain; ret->bmain_is_temp = (bmain != bmain_base); - ret->blo_handle = NULL; + ret->blo_handle = nullptr; ret->flag = ((is_link ? FILE_LINK : 0) | (is_rel ? FILE_RELPATH : 0) | (use_assets_only ? FILE_ASSETS_ONLY : 0)); ret->create_liboverrides = create_liboverrides; - ret->liboverride_flags = + ret->liboverride_flags = eBKELibLinkOverride( create_liboverrides ? ((reuse_liboverrides ? BKE_LIBLINK_OVERRIDE_USE_EXISTING_LIBOVERRIDES : 0) | (create_liboverrides_runtime ? BKE_LIBLINK_OVERRIDE_CREATE_RUNTIME : 0)) : - 0; + 0); ret->dict = _PyDict_NewPresized(INDEX_ID_MAX); @@ -301,11 +301,11 @@ static PyObject *bpy_lib_enter(BPy_Library *self) self->blo_handle = BLO_blendhandle_from_file(self->abspath, bf_reports); - if (self->blo_handle == NULL) { + if (self->blo_handle == nullptr) { if (BPy_reports_to_error(reports, PyExc_IOError, true) != -1) { PyErr_Format(PyExc_IOError, "load: %s failed to open blend file", self->abspath); } - return NULL; + return nullptr; } int i = 0, code; @@ -329,7 +329,7 @@ static PyObject *bpy_lib_enter(BPy_Library *self) STRNCPY(self_from->relpath, self->relpath); STRNCPY(self_from->abspath, self->abspath); - self_from->blo_handle = NULL; + self_from->blo_handle = nullptr; self_from->flag = 0; self_from->create_liboverrides = false; self_from->liboverride_flags = BKE_LIBLINK_OVERRIDE_INIT; @@ -395,7 +395,8 @@ static bool bpy_lib_exit_lapp_context_items_cb(BlendfileLinkAppendContext *lapp_ BlendfileLinkAppendContextItem *item, void *userdata) { - struct LibExitLappContextItemsIterData *data = userdata; + struct LibExitLappContextItemsIterData *data = static_cast( + userdata); /* Since `bpy_lib_exit` loops over all ID types, all items in `lapp_context` end up being looped * over for each ID type, so when it does not match the item can simply be skipped: it either has @@ -410,7 +411,7 @@ static bool bpy_lib_exit_lapp_context_items_cb(BlendfileLinkAppendContext *lapp_ ID *liboverride_id = data->py_library->create_liboverrides ? BKE_blendfile_link_append_context_item_liboverrideid_get(lapp_context, item) : - NULL; + nullptr; BLI_assert(py_list_index < data->py_list_size); @@ -421,12 +422,12 @@ static bool bpy_lib_exit_lapp_context_items_cb(BlendfileLinkAppendContext *lapp_ BLI_assert(item_src != Py_None); PyObject *py_item; - if (liboverride_id != NULL) { + if (liboverride_id != nullptr) { PointerRNA newid_ptr; RNA_id_pointer_create(liboverride_id, &newid_ptr); py_item = pyrna_struct_CreatePyObject(&newid_ptr); } - else if (new_id != NULL) { + else if (new_id != nullptr) { PointerRNA newid_ptr; RNA_id_pointer_create(new_id, &newid_ptr); py_item = pyrna_struct_CreatePyObject(&newid_ptr); @@ -447,7 +448,7 @@ static bool bpy_lib_exit_lapp_context_items_cb(BlendfileLinkAppendContext *lapp_ return true; } -static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) +static PyObject *bpy_lib_exit(BPy_Library *self, PyObject * /*args*/) { Main *bmain = self->bmain; const bool do_append = ((self->flag & FILE_LINK) == 0); @@ -477,7 +478,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) const char *name_plural = BKE_idtype_idcode_to_name_plural(idcode); PyObject *ls = PyDict_GetItemString(self->dict, name_plural); // printf("lib: %s\n", name_plural); - if (ls == NULL || !PyList_Check(ls)) { + if (ls == nullptr || !PyList_Check(ls)) { continue; } @@ -495,7 +496,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) /* NOTE: index of item in py list is stored in userdata pointer, so that it can be found * later on to replace the ID name by the actual ID pointer. */ - if (item_idname != NULL) { + if (item_idname != nullptr) { BlendfileLinkAppendContextItem *item = BKE_blendfile_link_append_context_item_add( lapp_context, item_idname, idcode, POINTER_FROM_INT(i)); BKE_blendfile_link_append_context_item_library_index_enable(lapp_context, item, 0); @@ -515,15 +516,15 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) } } - BKE_blendfile_link(lapp_context, NULL); + BKE_blendfile_link(lapp_context, nullptr); if (do_append) { - BKE_blendfile_append(lapp_context, NULL); + BKE_blendfile_append(lapp_context, nullptr); } else if (create_liboverrides) { - BKE_blendfile_override(lapp_context, self->liboverride_flags, NULL); + BKE_blendfile_override(lapp_context, self->liboverride_flags, nullptr); } - /* If enabled, replace named items in given lists by the final matching new ID pointer. */ +/* If enabled, replace named items in given lists by the final matching new ID pointer. */ #ifdef USE_RNA_DATABLOCKS idcode_step = 0; while ((idcode = BKE_idtype_idcode_iter_step(&idcode_step))) { @@ -533,7 +534,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) const char *name_plural = BKE_idtype_idcode_to_name_plural(idcode); PyObject *ls = PyDict_GetItemString(self->dict, name_plural); // printf("lib: %s\n", name_plural); - if (ls == NULL || !PyList_Check(ls)) { + if (ls == nullptr || !PyList_Check(ls)) { continue; } @@ -544,8 +545,11 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) /* Loop over linked items in `lapp_context` to find matching python one in the list, and * replace them with proper ID pointer. */ - struct LibExitLappContextItemsIterData iter_data = { - .idcode = idcode, .py_library = self, .py_list = ls, .py_list_size = size}; + LibExitLappContextItemsIterData iter_data{}; + iter_data.idcode = idcode; + iter_data.py_library = self; + iter_data.py_list = ls; + iter_data.py_list_size = size; BKE_blendfile_link_append_context_item_foreach( lapp_context, bpy_lib_exit_lapp_context_items_cb, @@ -555,7 +559,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) #endif // USE_RNA_DATABLOCKS BLO_blendhandle_close(self->blo_handle); - self->blo_handle = NULL; + self->blo_handle = nullptr; BKE_blendfile_link_append_context_free(lapp_context); BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false); diff --git a/source/blender/python/intern/bpy_library_write.c b/source/blender/python/intern/bpy_library_write.cc similarity index 94% rename from source/blender/python/intern/bpy_library_write.c rename to source/blender/python/intern/bpy_library_write.cc index 1c67f881159..fd2a923e952 100644 --- a/source/blender/python/intern/bpy_library_write.c +++ b/source/blender/python/intern/bpy_library_write.cc @@ -64,14 +64,14 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * /* args */ const char *filepath; char filepath_abs[FILE_MAX]; - PyObject *datablocks = NULL; + PyObject *datablocks = nullptr; const struct PyC_StringEnumItems path_remap_items[] = { {BLO_WRITE_PATH_REMAP_NONE, "NONE"}, {BLO_WRITE_PATH_REMAP_RELATIVE, "RELATIVE"}, {BLO_WRITE_PATH_REMAP_RELATIVE_ALL, "RELATIVE_ALL"}, {BLO_WRITE_PATH_REMAP_ABSOLUTE, "ABSOLUTE"}, - {0, NULL}, + {0, nullptr}, }; struct PyC_StringEnum path_remap = {path_remap_items, BLO_WRITE_PATH_REMAP_NONE}; @@ -83,7 +83,7 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * "path_remap", "fake_user", "compress", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "s" /* `filepath` */ @@ -109,10 +109,10 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * PyC_ParseBool, &use_compress)) { - return NULL; + return nullptr; } - Main *bmain_src = self->ptr.data; /* Typically #G_MAIN */ + Main *bmain_src = static_cast
(self->ptr.data); /* Typically #G_MAIN */ int write_flags = 0; if (use_compress) { @@ -125,7 +125,7 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * BKE_blendfile_write_partial_begin(bmain_src); /* array of ID's and backup any data we modify */ - struct { + struct IDStore { ID *id; /* original values */ short id_flag; @@ -134,13 +134,15 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * int id_store_len = 0; PyObject *ret; + int retval = 0; /* collect all id data from the set and store in 'id_store_array' */ { Py_ssize_t pos, hash; PyObject *key; - id_store_array = MEM_mallocN(sizeof(*id_store_array) * PySet_Size(datablocks), __func__); + id_store_array = static_cast( + MEM_mallocN(sizeof(*id_store_array) * PySet_Size(datablocks), __func__)); id_store = id_store_array; pos = hash = 0; @@ -148,7 +150,7 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * if (!pyrna_id_FromPyObject(key, &id_store->id)) { PyErr_Format(PyExc_TypeError, "Expected an ID type, not %.200s", Py_TYPE(key)->tp_name); - ret = NULL; + ret = nullptr; goto finally; } else { @@ -169,7 +171,6 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * } /* write blend */ - int retval = 0; ReportList reports; BKE_reports_init(&reports, RPT_STORE); @@ -189,7 +190,7 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * if (BPy_reports_to_error(&reports, PyExc_IOError, true) == 0) { PyErr_SetString(PyExc_IOError, "Unknown error writing library data"); } - ret = NULL; + ret = nullptr; } finally: diff --git a/source/blender/python/intern/bpy_msgbus.c b/source/blender/python/intern/bpy_msgbus.cc similarity index 89% rename from source/blender/python/intern/bpy_msgbus.c rename to source/blender/python/intern/bpy_msgbus.cc index d0be0a32c99..115738069e1 100644 --- a/source/blender/python/intern/bpy_msgbus.c +++ b/source/blender/python/intern/bpy_msgbus.cc @@ -64,7 +64,7 @@ static int py_msgbus_rna_key_from_py(PyObject *py_sub, /* Allow common case, object rotation, location - etc. */ if (BaseMathObject_CheckExact(py_sub)) { BaseMathObject *py_sub_math = (BaseMathObject *)py_sub; - if (py_sub_math->cb_user == NULL) { + if (py_sub_math->cb_user == nullptr) { PyErr_Format(PyExc_TypeError, "%s: math argument has no owner", error_prefix); return -1; } @@ -87,7 +87,7 @@ static int py_msgbus_rna_key_from_py(PyObject *py_sub, /* TODO: property / type, not instance. */ else if (PyType_Check(py_sub)) { StructRNA *data_type = pyrna_struct_as_srna(py_sub, false, error_prefix); - if (data_type == NULL) { + if (data_type == nullptr) { return -1; } msg_key_params->ptr.type = data_type; @@ -97,20 +97,20 @@ static int py_msgbus_rna_key_from_py(PyObject *py_sub, PyObject *data_type_py = PyTuple_GET_ITEM(py_sub, 0); PyObject *data_prop_py = PyTuple_GET_ITEM(py_sub, 1); StructRNA *data_type = pyrna_struct_as_srna(data_type_py, false, error_prefix); - if (data_type == NULL) { + if (data_type == nullptr) { return -1; } if (!PyUnicode_CheckExact(data_prop_py)) { PyErr_Format(PyExc_TypeError, "%s: expected property to be a string", error_prefix); return -1; } - PointerRNA data_type_ptr = { - .type = data_type, - }; + PointerRNA data_type_ptr{}; + data_type_ptr.type = data_type; + const char *data_prop_str = PyUnicode_AsUTF8(data_prop_py); PropertyRNA *data_prop = RNA_struct_find_property(&data_type_ptr, data_prop_str); - if (data_prop == NULL) { + if (data_prop == nullptr) { PyErr_Format(PyExc_TypeError, "%s: struct %.200s does not contain property %.200s", error_prefix, @@ -140,13 +140,13 @@ static int py_msgbus_rna_key_from_py(PyObject *py_sub, /* Follow wmMsgNotifyFn spec */ static void bpy_msgbus_notify(bContext *C, - wmMsgSubscribeKey *UNUSED(msg_key), + wmMsgSubscribeKey * /*msg_key*/, wmMsgSubscribeValue *msg_val) { PyGILState_STATE gilstate; bpy_context_set(C, &gilstate); - PyObject *user_data = msg_val->user_data; + PyObject *user_data = static_cast(msg_val->user_data); BLI_assert(PyTuple_GET_SIZE(user_data) == BPY_MSGBUS_USER_DATA_LEN); PyObject *callback_args = PyTuple_GET_ITEM(user_data, 0); @@ -159,7 +159,7 @@ static void bpy_msgbus_notify(bContext *C, PyObject *ret = PyObject_CallObject(callback_notify, callback_args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(callback_notify); } else { @@ -178,7 +178,7 @@ static void bpy_msgbus_notify(bContext *C, } /* Follow wmMsgSubscribeValueFreeDataFn spec */ -static void bpy_msgbus_subscribe_value_free_data(wmMsgSubscribeKey *UNUSED(msg_key), +static void bpy_msgbus_subscribe_value_free_data(wmMsgSubscribeKey * /*msg_key*/, wmMsgSubscribeValue *msg_val) { const PyGILState_STATE gilstate = PyGILState_Ensure(); @@ -212,27 +212,27 @@ PyDoc_STRVAR( "\n" " All subscribers will be cleared on file-load. Subscribers can be re-registered on load,\n" " see :mod:`bpy.app.handlers.load_post`.\n"); -static PyObject *bpy_msgbus_subscribe_rna(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_msgbus_subscribe_rna(PyObject * /*self*/, PyObject *args, PyObject *kw) { const char *error_prefix = "subscribe_rna"; - PyObject *py_sub = NULL; - PyObject *py_owner = NULL; - PyObject *callback_args = NULL; - PyObject *callback_notify = NULL; + PyObject *py_sub = nullptr; + PyObject *py_owner = nullptr; + PyObject *callback_args = nullptr; + PyObject *callback_notify = nullptr; enum { IS_PERSISTENT = (1 << 0), }; - PyObject *py_options = NULL; + PyObject *py_options = nullptr; const EnumPropertyItem py_options_enum[] = { {IS_PERSISTENT, "PERSISTENT", 0, ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; int options = 0; if (PyTuple_GET_SIZE(args) != 0) { PyErr_Format(PyExc_TypeError, "%s: only keyword arguments are supported", error_prefix); - return NULL; + return nullptr; } static const char *_keywords[] = { "key", @@ -240,7 +240,7 @@ static PyObject *bpy_msgbus_subscribe_rna(PyObject *UNUSED(self), PyObject *args "args", "notify", "options", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "O" /* `key` */ @@ -264,13 +264,13 @@ static PyObject *bpy_msgbus_subscribe_rna(PyObject *UNUSED(self), PyObject *args &PySet_Type, &py_options)) { - return NULL; + return nullptr; } if (py_options && (pyrna_enum_bitfield_from_set(py_options_enum, py_options, &options, error_prefix) == -1)) { - return NULL; + return nullptr; } /* NOTE: we may want to have a way to pass this in. */ @@ -281,14 +281,14 @@ static PyObject *bpy_msgbus_subscribe_rna(PyObject *UNUSED(self), PyObject *args wmMsgSubscribeValue msg_val_params = {0}; if (py_msgbus_rna_key_from_py(py_sub, &msg_key_params, error_prefix) == -1) { - return NULL; + return nullptr; } if (!PyFunction_Check(callback_notify)) { PyErr_Format(PyExc_TypeError, "notify expects a function, found %.200s", Py_TYPE(callback_notify)->tp_name); - return NULL; + return nullptr; } if (options != 0) { @@ -330,18 +330,18 @@ PyDoc_STRVAR( " (this typically doesn't need to be called explicitly since changes will automatically " "publish updates).\n" " In some cases it may be useful to publish changes explicitly using more general keys.\n"); -static PyObject *bpy_msgbus_publish_rna(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_msgbus_publish_rna(PyObject * /*self*/, PyObject *args, PyObject *kw) { const char *error_prefix = "publish_rna"; - PyObject *py_sub = NULL; + PyObject *py_sub = nullptr; if (PyTuple_GET_SIZE(args) != 0) { PyErr_Format(PyExc_TypeError, "%s: only keyword arguments are supported", error_prefix); - return NULL; + return nullptr; } static const char *_keywords[] = { "key", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "O" /* `key` */ @@ -350,7 +350,7 @@ static PyObject *bpy_msgbus_publish_rna(PyObject *UNUSED(self), PyObject *args, 0, }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &py_sub)) { - return NULL; + return nullptr; } /* NOTE: we may want to have a way to pass this in. */ @@ -359,7 +359,7 @@ static PyObject *bpy_msgbus_publish_rna(PyObject *UNUSED(self), PyObject *args, wmMsgParams_RNA msg_key_params = {{0}}; if (py_msgbus_rna_key_from_py(py_sub, &msg_key_params, error_prefix) == -1) { - return NULL; + return nullptr; } WM_msg_publish_rna_params(mbus, &msg_key_params); @@ -371,7 +371,7 @@ PyDoc_STRVAR(bpy_msgbus_clear_by_owner_doc, ".. function:: clear_by_owner(owner)\n" "\n" " Clear all subscribers using this owner.\n"); -static PyObject *bpy_msgbus_clear_by_owner(PyObject *UNUSED(self), PyObject *py_owner) +static PyObject *bpy_msgbus_clear_by_owner(PyObject * /*self*/, PyObject *py_owner) { bContext *C = BPY_context_get(); struct wmMsgBus *mbus = CTX_wm_message_bus(C); @@ -392,19 +392,19 @@ static PyMethodDef BPy_msgbus_methods[] = { (PyCFunction)bpy_msgbus_clear_by_owner, METH_O, bpy_msgbus_clear_by_owner_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyModuleDef _bpy_msgbus_def = { /*m_base*/ PyModuleDef_HEAD_INIT, /*m_name*/ "msgbus", - /*m_doc*/ NULL, + /*m_doc*/ nullptr, /*m_size*/ 0, /*m_methods*/ BPy_msgbus_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; PyObject *BPY_msgbus_module(void) diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.cc similarity index 79% rename from source/blender/python/intern/bpy_operator.c rename to source/blender/python/intern/bpy_operator.cc index 9cecb5f944e..e349b1fc8f0 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.cc @@ -49,24 +49,24 @@ static wmOperatorType *ot_lookup_from_py_string(PyObject *value, const char *py_fn_id) { const char *opname = PyUnicode_AsUTF8(value); - if (opname == NULL) { + if (opname == nullptr) { PyErr_Format(PyExc_TypeError, "%s() expects a string argument", py_fn_id); - return NULL; + return nullptr; } wmOperatorType *ot = WM_operatortype_find(opname, true); - if (ot == NULL) { + if (ot == nullptr) { PyErr_Format(PyExc_KeyError, "%s(\"%s\") not found", py_fn_id, opname); - return NULL; + return nullptr; } return ot; } -static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args) +static PyObject *pyop_poll(PyObject * /*self*/, PyObject *args) { wmOperatorType *ot; const char *opname; - const char *context_str = NULL; + const char *context_str = nullptr; PyObject *ret; wmOperatorCallContext context = WM_OP_EXEC_DEFAULT; @@ -75,13 +75,13 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args) * could make a tuple from self and pack the name and Context into it. */ bContext *C = BPY_context_get(); - if (C == NULL) { + if (C == nullptr) { PyErr_SetString(PyExc_RuntimeError, "Context is None, can't poll any operators"); - return NULL; + return nullptr; } /* All arguments are positional. */ - static const char *_keywords[] = {"", "", NULL}; + static const char *_keywords[] = {"", "", nullptr}; static _PyArg_Parser _parser = { "s" /* `opname` */ "|" /* Optional arguments. */ @@ -90,18 +90,18 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args) _keywords, 0, }; - if (!_PyArg_ParseTupleAndKeywordsFast(args, NULL, &_parser, &opname, &context_str)) { - return NULL; + if (!_PyArg_ParseTupleAndKeywordsFast(args, nullptr, &_parser, &opname, &context_str)) { + return nullptr; } ot = WM_operatortype_find(opname, true); - if (ot == NULL) { + if (ot == nullptr) { PyErr_Format(PyExc_AttributeError, "Polling operator \"bpy.ops.%s\" error, " "could not be found", opname); - return NULL; + return nullptr; } if (context_str) { @@ -115,10 +115,10 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args) opname, enum_str); MEM_freeN(enum_str); - return NULL; + return nullptr; } /* Copy back to the properly typed enum. */ - context = context_int; + context = wmOperatorCallContext(context_int); } /* main purpose of this function */ @@ -127,7 +127,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args) return Py_INCREF_RET(ret); } -static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) +static PyObject *pyop_call(PyObject * /*self*/, PyObject *args) { wmOperatorType *ot; int error_val = 0; @@ -135,8 +135,8 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) int operator_ret = OPERATOR_CANCELLED; const char *opname; - const char *context_str = NULL; - PyObject *kw = NULL; /* optional args */ + const char *context_str = nullptr; + PyObject *kw = nullptr; /* optional args */ wmOperatorCallContext context = WM_OP_EXEC_DEFAULT; int is_undo = false; @@ -145,13 +145,13 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) * could make a tuple from self and pack the name and Context into it. */ bContext *C = BPY_context_get(); - if (C == NULL) { + if (C == nullptr) { PyErr_SetString(PyExc_RuntimeError, "Context is None, can't poll any operators"); - return NULL; + return nullptr; } /* All arguments are positional. */ - static const char *_keywords[] = {"", "", "", "", NULL}; + static const char *_keywords[] = {"", "", "", "", nullptr}; static _PyArg_Parser _parser = { "s" /* `opname` */ "|" /* Optional arguments. */ @@ -163,19 +163,19 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, NULL, &_parser, &opname, &PyDict_Type, &kw, &context_str, &is_undo)) + args, nullptr, &_parser, &opname, &PyDict_Type, &kw, &context_str, &is_undo)) { - return NULL; + return nullptr; } ot = WM_operatortype_find(opname, true); - if (ot == NULL) { + if (ot == nullptr) { PyErr_Format(PyExc_AttributeError, "Calling operator \"bpy.ops.%s\" error, " "could not be found", opname); - return NULL; + return nullptr; } if (!pyrna_write_check()) { @@ -183,7 +183,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) "Calling operator \"bpy.ops.%s\" error, " "can't modify blend data in this state (drawing/rendering)", opname); - return NULL; + return nullptr; } if (context_str) { @@ -197,10 +197,10 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) opname, enum_str); MEM_freeN(enum_str); - return NULL; + return nullptr; } /* Copy back to the properly typed enum. */ - context = context_int; + context = wmOperatorCallContext(context_int); } if (WM_operator_poll_context((bContext *)C, ot, context) == false) { @@ -228,7 +228,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) if (error_val == 0) { ReportList *reports; - reports = MEM_mallocN(sizeof(ReportList), "wmOperatorReportList"); + reports = static_cast(MEM_mallocN(sizeof(ReportList), "wmOperatorReportList")); /* Own so these don't move into global reports. */ BKE_reports_init(reports, RPT_STORE | RPT_OP_HOLD | RPT_PRINT_HANDLED_BY_OWNER); @@ -254,7 +254,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) /* operator output is nice to have in the terminal/console too */ if (!BLI_listbase_is_empty(&reports->list)) { - BPy_reports_write_stdout(reports, NULL); + BPy_reports_write_stdout(reports, nullptr); } BKE_reports_clear(reports); @@ -274,18 +274,18 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) /* if there is some way to know an operator takes args we should use this */ { /* no props */ - if (kw != NULL) { + if (kw != nullptr) { PyErr_Format(PyExc_AttributeError, "Operator \"%s\" does not take any args", opname); - return NULL; + return nullptr; } - WM_operator_name_call(C, opname, WM_OP_EXEC_DEFAULT, NULL, NULL); + WM_operator_name_call(C, opname, WM_OP_EXEC_DEFAULT, nullptr, nullptr); } #endif } if (error_val == -1) { - return NULL; + return nullptr; } /* When calling `bpy.ops.wm.read_factory_settings()` `bpy.data's` main pointer @@ -298,30 +298,30 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) return pyrna_enum_bitfield_as_set(rna_enum_operator_return_items, operator_ret); } -static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) +static PyObject *pyop_as_string(PyObject * /*self*/, PyObject *args) { wmOperatorType *ot; PointerRNA ptr; const char *opname; - PyObject *kw = NULL; /* optional args */ + PyObject *kw = nullptr; /* optional args */ bool all_args = true; bool macro_args = true; int error_val = 0; - char *buf = NULL; + char *buf = nullptr; PyObject *pybuf; bContext *C = BPY_context_get(); - if (C == NULL) { + if (C == nullptr) { PyErr_SetString(PyExc_RuntimeError, "Context is None, can't get the string representation of this object."); - return NULL; + return nullptr; } /* All arguments are positional. */ - static const char *_keywords[] = {"", "", "", "", NULL}; + static const char *_keywords[] = {"", "", "", "", nullptr}; static _PyArg_Parser _parser = { "s" /* `opname` */ "|" /* Optional arguments. */ @@ -333,7 +333,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) 0, }; if (!_PyArg_ParseTupleAndKeywordsFast(args, - NULL, + nullptr, &_parser, &opname, &PyDict_Type, @@ -343,22 +343,22 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) PyC_ParseBool, ¯o_args)) { - return NULL; + return nullptr; } ot = WM_operatortype_find(opname, true); - if (ot == NULL) { + if (ot == nullptr) { PyErr_Format(PyExc_AttributeError, "_bpy.ops.as_string: operator \"%.200s\" " "could not be found", opname); - return NULL; + return nullptr; } // WM_operator_properties_create(&ptr, opname); /* Save another lookup */ - RNA_pointer_create(NULL, ot->srna, NULL, &ptr); + RNA_pointer_create(nullptr, ot->srna, nullptr, &ptr); if (kw && PyDict_Size(kw)) { error_val = pyrna_pydict_to_props( @@ -366,13 +366,13 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) } if (error_val == 0) { - buf = WM_operator_pystring_ex(C, NULL, all_args, macro_args, ot, &ptr); + buf = WM_operator_pystring_ex(C, nullptr, all_args, macro_args, ot, &ptr); } WM_operator_properties_free(&ptr); if (error_val == -1) { - return NULL; + return nullptr; } if (buf) { @@ -386,7 +386,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) return pybuf; } -static PyObject *pyop_dir(PyObject *UNUSED(self)) +static PyObject *pyop_dir(PyObject * /*self*/) { GHashIterator iter; PyObject *list; @@ -396,56 +396,56 @@ static PyObject *pyop_dir(PyObject *UNUSED(self)) list = PyList_New(BLI_ghash_len(iter.gh)); for (i = 0; !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter), i++) { - wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); + wmOperatorType *ot = static_cast(BLI_ghashIterator_getValue(&iter)); PyList_SET_ITEM(list, i, PyUnicode_FromString(ot->idname)); } return list; } -static PyObject *pyop_getrna_type(PyObject *UNUSED(self), PyObject *value) +static PyObject *pyop_getrna_type(PyObject * /*self*/, PyObject *value) { wmOperatorType *ot; - if ((ot = ot_lookup_from_py_string(value, "get_rna_type")) == NULL) { - return NULL; + if ((ot = ot_lookup_from_py_string(value, "get_rna_type")) == nullptr) { + return nullptr; } PointerRNA ptr; - RNA_pointer_create(NULL, &RNA_Struct, ot->srna, &ptr); + RNA_pointer_create(nullptr, &RNA_Struct, ot->srna, &ptr); BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr); return (PyObject *)pyrna; } -static PyObject *pyop_get_bl_options(PyObject *UNUSED(self), PyObject *value) +static PyObject *pyop_get_bl_options(PyObject * /*self*/, PyObject *value) { wmOperatorType *ot; - if ((ot = ot_lookup_from_py_string(value, "get_bl_options")) == NULL) { - return NULL; + if ((ot = ot_lookup_from_py_string(value, "get_bl_options")) == nullptr) { + return nullptr; } return pyrna_enum_bitfield_as_set(rna_enum_operator_type_flag_items, ot->flag); } static PyMethodDef bpy_ops_methods[] = { - {"poll", (PyCFunction)pyop_poll, METH_VARARGS, NULL}, - {"call", (PyCFunction)pyop_call, METH_VARARGS, NULL}, - {"as_string", (PyCFunction)pyop_as_string, METH_VARARGS, NULL}, - {"dir", (PyCFunction)pyop_dir, METH_NOARGS, NULL}, - {"get_rna_type", (PyCFunction)pyop_getrna_type, METH_O, NULL}, - {"get_bl_options", (PyCFunction)pyop_get_bl_options, METH_O, NULL}, - {"macro_define", (PyCFunction)PYOP_wrap_macro_define, METH_VARARGS, NULL}, - {NULL, NULL, 0, NULL}, + {"poll", (PyCFunction)pyop_poll, METH_VARARGS, nullptr}, + {"call", (PyCFunction)pyop_call, METH_VARARGS, nullptr}, + {"as_string", (PyCFunction)pyop_as_string, METH_VARARGS, nullptr}, + {"dir", (PyCFunction)pyop_dir, METH_NOARGS, nullptr}, + {"get_rna_type", (PyCFunction)pyop_getrna_type, METH_O, nullptr}, + {"get_bl_options", (PyCFunction)pyop_get_bl_options, METH_O, nullptr}, + {"macro_define", (PyCFunction)PYOP_wrap_macro_define, METH_VARARGS, nullptr}, + {nullptr, nullptr, 0, nullptr}, }; static PyModuleDef bpy_ops_module = { /*m_base*/ PyModuleDef_HEAD_INIT, /*m_name*/ "_bpy.ops", - /*m_doc*/ NULL, + /*m_doc*/ nullptr, /*m_size*/ -1, /* multiple "initialization" just copies the module dict. */ /*m_methods*/ bpy_ops_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; PyObject *BPY_operator_module(void) diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.cc similarity index 90% rename from source/blender/python/intern/bpy_operator_wrap.c rename to source/blender/python/intern/bpy_operator_wrap.cc index 1a736501ae9..33430ce04b6 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.cc @@ -28,7 +28,7 @@ static void operator_properties_init(wmOperatorType *ot) { - PyTypeObject *py_class = ot->rna_ext.data; + PyTypeObject *py_class = static_cast(ot->rna_ext.data); RNA_struct_blender_type_set(ot->rna_ext.srna, ot); /* Only call this so pyrna_deferred_register_class gives a useful error @@ -53,11 +53,11 @@ static void operator_properties_init(wmOperatorType *ot) PyObject *bl_property = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_property); if (bl_property) { const char *prop_id = PyUnicode_AsUTF8(bl_property); - if (prop_id != NULL) { + if (prop_id != nullptr) { PointerRNA ptr; PropertyRNA *prop; - RNA_pointer_create(NULL, ot->srna, NULL, &ptr); + RNA_pointer_create(nullptr, ot->srna, nullptr, &ptr); prop = RNA_struct_find_property(&ptr, prop_id); if (prop) { ot->prop = prop; @@ -123,7 +123,7 @@ void BPY_RNA_operator_macro_wrapper(wmOperatorType *ot, void *userdata) operator_properties_init(ot); } -PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args) +PyObject *PYOP_wrap_macro_define(PyObject * /*self*/, PyObject *args) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; @@ -135,18 +135,18 @@ PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args) const char *macroname; if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", ¯o, &opname)) { - return NULL; + return nullptr; } - if (WM_operatortype_find(opname, true) == NULL) { + if (WM_operatortype_find(opname, true) == nullptr) { PyErr_Format(PyExc_ValueError, "Macro Define: '%s' is not a valid operator id", opname); - return NULL; + return nullptr; } /* identifiers */ srna = pyrna_struct_as_srna((PyObject *)macro, false, "Macro Define:"); - if (srna == NULL) { - return NULL; + if (srna == nullptr) { + return nullptr; } macroname = RNA_struct_identifier(srna); @@ -154,12 +154,12 @@ PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args) if (!ot) { PyErr_Format(PyExc_ValueError, "Macro Define: '%s' is not a valid macro", macroname); - return NULL; + return nullptr; } otmacro = WM_operatortype_macro_define(ot, opname); - RNA_pointer_create(NULL, &RNA_OperatorMacro, otmacro, &ptr_otmacro); + RNA_pointer_create(nullptr, &RNA_OperatorMacro, otmacro, &ptr_otmacro); return pyrna_struct_CreatePyObject(&ptr_otmacro); } diff --git a/source/blender/python/intern/bpy_path.c b/source/blender/python/intern/bpy_path.cc similarity index 78% rename from source/blender/python/intern/bpy_path.c rename to source/blender/python/intern/bpy_path.cc index a27283a4cb7..ac233768f0d 100644 --- a/source/blender/python/intern/bpy_path.c +++ b/source/blender/python/intern/bpy_path.cc @@ -17,21 +17,21 @@ #include "../generic/py_capi_utils.h" /* #include "IMB_imbuf_types.h" */ -extern const char *imb_ext_image[]; -extern const char *imb_ext_movie[]; -extern const char *imb_ext_audio[]; +extern "C" const char *imb_ext_image[]; +extern "C" const char *imb_ext_movie[]; +extern "C" const char *imb_ext_audio[]; /*----------------------------MODULE INIT-------------------------*/ static PyModuleDef _bpy_path_module_def = { /*m_base*/ PyModuleDef_HEAD_INIT, /*m_name*/ "_bpy_path", - /*m_doc*/ NULL, + /*m_doc*/ nullptr, /*m_size*/ 0, - /*m_methods*/ NULL, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_methods*/ nullptr, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; PyObject *BPyInit__bpy_path(void) diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.cc similarity index 86% rename from source/blender/python/intern/bpy_props.c rename to source/blender/python/intern/bpy_props.cc index b59c39d930e..a1b1da3a54f 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.cc @@ -120,7 +120,7 @@ struct BPyPropStore { /** * Only store #PyObject types, so this member can be cast to an array and iterated over. - * NULL members are skipped. + * nullptr members are skipped. */ struct { /** Wrap: `RNA_def_property_*_funcs` (depending on type). */ @@ -151,11 +151,11 @@ struct BPyPropStore { }; #define BPY_PROP_STORE_PY_DATA_SIZE \ - (sizeof(((struct BPyPropStore *)NULL)->py_data) / sizeof(PyObject *)) + (sizeof(((struct BPyPropStore *)nullptr)->py_data) / sizeof(PyObject *)) #define ASSIGN_PYOBJECT_INCREF(a, b) \ { \ - BLI_assert((a) == NULL); \ + BLI_assert((a) == nullptr); \ Py_INCREF(b); \ a = b; \ } \ @@ -165,13 +165,13 @@ struct BPyPropStore { * Maintain a list of Python defined properties, so the GC can visit them, * and so they can be cleared on exit. */ -static ListBase g_bpy_prop_store_list = {NULL, NULL}; +static ListBase g_bpy_prop_store_list = {nullptr, nullptr}; static struct BPyPropStore *bpy_prop_py_data_ensure(PropertyRNA *prop) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); - if (prop_store == NULL) { - prop_store = MEM_callocN(sizeof(*prop_store), __func__); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); + if (prop_store == nullptr) { + prop_store = static_cast(MEM_callocN(sizeof(*prop_store), __func__)); RNA_def_py_data(prop, prop_store); BLI_addtail(&g_bpy_prop_store_list, prop_store); } @@ -183,8 +183,8 @@ static struct BPyPropStore *bpy_prop_py_data_ensure(PropertyRNA *prop) */ static void bpy_prop_py_data_remove(PropertyRNA *prop) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); - if (prop_store == NULL) { + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); + if (prop_store == nullptr) { return; } @@ -235,9 +235,9 @@ static PyObject *bpy_prop_deferred_repr(BPy_PropDeferred *self) * * When callable this object type passes the test for being an acceptable annotation. */ -static PyObject *bpy_prop_deferred_call(BPy_PropDeferred *UNUSED(self), - PyObject *UNUSED(args), - PyObject *UNUSED(kw)) +static PyObject *bpy_prop_deferred_call(BPy_PropDeferred * /*self*/, + PyObject * /*args*/, + PyObject * /*kw*/) { /* Dummy value. */ Py_RETURN_NONE; @@ -249,9 +249,9 @@ static PyObject *bpy_prop_deferred_call(BPy_PropDeferred *UNUSED(self), * Expose the function in case scripts need to introspect this information * (not currently used by Blender itself). */ -static PyObject *bpy_prop_deferred_function_get(BPy_PropDeferred *self, void *UNUSED(closure)) +static PyObject *bpy_prop_deferred_function_get(BPy_PropDeferred *self, void * /*closure*/) { - PyObject *ret = self->fn; + PyObject *ret = static_cast(self->fn); Py_IncRef(ret); return ret; } @@ -260,7 +260,7 @@ static PyObject *bpy_prop_deferred_function_get(BPy_PropDeferred *self, void *UN * Expose keywords in case scripts need to introspect this information * (not currently used by Blender itself). */ -static PyObject *bpy_prop_deferred_keywords_get(BPy_PropDeferred *self, void *UNUSED(closure)) +static PyObject *bpy_prop_deferred_keywords_get(BPy_PropDeferred *self, void * /*closure*/) { PyObject *ret = self->kw; Py_IncRef(ret); @@ -268,9 +268,9 @@ static PyObject *bpy_prop_deferred_keywords_get(BPy_PropDeferred *self, void *UN } static PyGetSetDef bpy_prop_deferred_getset[] = { - {"function", (getter)bpy_prop_deferred_function_get, (setter)NULL, NULL, NULL}, - {"keywords", (getter)bpy_prop_deferred_keywords_get, (setter)NULL, NULL, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {"function", (getter)bpy_prop_deferred_function_get, (setter) nullptr, nullptr, nullptr}, + {"keywords", (getter)bpy_prop_deferred_keywords_get, (setter) nullptr, nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; PyDoc_STRVAR(bpy_prop_deferred_doc, @@ -281,62 +281,62 @@ PyDoc_STRVAR(bpy_prop_deferred_doc, " This is not part of the stable API and may change between releases."); PyTypeObject bpy_prop_deferred_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "_PropertyDeferred", /*tp_basicsize*/ sizeof(BPy_PropDeferred), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)bpy_prop_deferred_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, /*tp_repr*/ (reprfunc)bpy_prop_deferred_repr, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, /*tp_call*/ (ternaryfunc)bpy_prop_deferred_call, - /*tp_str*/ NULL, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_str*/ nullptr, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_doc*/ bpy_prop_deferred_doc, /*tp_traverse*/ (traverseproc)bpy_prop_deferred_traverse, /*tp_clear*/ (inquiry)bpy_prop_deferred_clear, - /*tp_richcompare*/ NULL, + /*tp_richcompare*/ nullptr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, - /*tp_methods*/ NULL, - /*tp_members*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, + /*tp_methods*/ nullptr, + /*tp_members*/ nullptr, /*tp_getset*/ bpy_prop_deferred_getset, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; static PyObject *bpy_prop_deferred_data_CreatePyObject(PyObject *fn, PyObject *kw) { BPy_PropDeferred *self = PyObject_GC_New(BPy_PropDeferred, &bpy_prop_deferred_Type); self->fn = fn; - if (kw == NULL) { + if (kw == nullptr) { kw = PyDict_New(); } else { @@ -355,21 +355,21 @@ static PyObject *bpy_prop_deferred_data_CreatePyObject(PyObject *fn, PyObject *k * \{ */ /* PyObject's */ -static PyObject *pymeth_BoolProperty = NULL; -static PyObject *pymeth_BoolVectorProperty = NULL; -static PyObject *pymeth_IntProperty = NULL; -static PyObject *pymeth_IntVectorProperty = NULL; -static PyObject *pymeth_FloatProperty = NULL; -static PyObject *pymeth_FloatVectorProperty = NULL; -static PyObject *pymeth_StringProperty = NULL; -static PyObject *pymeth_EnumProperty = NULL; -static PyObject *pymeth_PointerProperty = NULL; -static PyObject *pymeth_CollectionProperty = NULL; -static PyObject *pymeth_RemoveProperty = NULL; +static PyObject *pymeth_BoolProperty = nullptr; +static PyObject *pymeth_BoolVectorProperty = nullptr; +static PyObject *pymeth_IntProperty = nullptr; +static PyObject *pymeth_IntVectorProperty = nullptr; +static PyObject *pymeth_FloatProperty = nullptr; +static PyObject *pymeth_FloatVectorProperty = nullptr; +static PyObject *pymeth_StringProperty = nullptr; +static PyObject *pymeth_EnumProperty = nullptr; +static PyObject *pymeth_PointerProperty = nullptr; +static PyObject *pymeth_CollectionProperty = nullptr; +static PyObject *pymeth_RemoveProperty = nullptr; static PyObject *pyrna_struct_as_instance(PointerRNA *ptr) { - PyObject *self = NULL; + PyObject *self = nullptr; /* first get self */ /* operators can store their own instance for later use */ if (ptr->data) { @@ -377,14 +377,14 @@ static PyObject *pyrna_struct_as_instance(PointerRNA *ptr) if (instance) { if (*instance) { - self = *instance; + self = static_cast(*instance); Py_INCREF(self); } } } /* in most cases this will run */ - if (self == NULL) { + if (self == nullptr) { self = pyrna_struct_CreatePyObject(ptr); } @@ -396,17 +396,17 @@ static void bpy_prop_assign_flag(PropertyRNA *prop, const int flag) const int flag_mask = ((PROP_ANIMATABLE) & ~flag); if (flag) { - RNA_def_property_flag(prop, flag); + RNA_def_property_flag(prop, PropertyFlag(flag)); } if (flag_mask) { - RNA_def_property_clear_flag(prop, flag_mask); + RNA_def_property_clear_flag(prop, PropertyFlag(flag_mask)); } } static void bpy_prop_assign_flag_override(PropertyRNA *prop, const int flag_override) { - RNA_def_property_override_flag(prop, flag_override); + RNA_def_property_override_flag(prop, PropertyOverrideFlag(flag_override)); } /** \} */ @@ -427,7 +427,7 @@ struct BPyPropArrayLength { */ static int bpy_prop_array_length_parse(PyObject *o, void *p) { - struct BPyPropArrayLength *array_len_info = p; + struct BPyPropArrayLength *array_len_info = static_cast(p); if (PyLong_CheckExact(o)) { int size; @@ -559,7 +559,7 @@ static void bpy_prop_array_matrix_swap_row_column_vn( /* callbacks */ static void bpy_prop_update_fn(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyGILState_STATE gilstate; PyObject *py_func; PyObject *args; @@ -567,7 +567,7 @@ static void bpy_prop_update_fn(struct bContext *C, PointerRNA *ptr, PropertyRNA PyObject *ret; const bool is_write_ok = pyrna_write_check(); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -588,7 +588,7 @@ static void bpy_prop_update_fn(struct bContext *C, PointerRNA *ptr, PropertyRNA Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -615,7 +615,7 @@ static void bpy_prop_update_fn(struct bContext *C, PointerRNA *ptr, PropertyRNA static bool bpy_prop_boolean_get_fn(PointerRNA *ptr, PropertyRNA *prop) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -625,7 +625,7 @@ static bool bpy_prop_boolean_get_fn(PointerRNA *ptr, PropertyRNA *prop) const bool is_write_ok = pyrna_write_check(); bool value; - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -647,7 +647,7 @@ static bool bpy_prop_boolean_get_fn(PointerRNA *ptr, PropertyRNA *prop) Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); value = false; } @@ -678,7 +678,7 @@ static bool bpy_prop_boolean_get_fn(PointerRNA *ptr, PropertyRNA *prop) static void bpy_prop_boolean_set_fn(PointerRNA *ptr, PropertyRNA *prop, bool value) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -687,7 +687,7 @@ static void bpy_prop_boolean_set_fn(PointerRNA *ptr, PropertyRNA *prop, bool val bool use_gil; const bool is_write_ok = pyrna_write_check(); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -711,7 +711,7 @@ static void bpy_prop_boolean_set_fn(PointerRNA *ptr, PropertyRNA *prop, bool val Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -734,7 +734,7 @@ static void bpy_prop_boolean_set_fn(PointerRNA *ptr, PropertyRNA *prop, bool val static void bpy_prop_boolean_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, bool *values) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -744,10 +744,11 @@ static void bpy_prop_boolean_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, bo const bool is_write_ok = pyrna_write_check(); bool is_values_set = false; int i, len = RNA_property_array_length(ptr, prop); - struct BPyPropArrayLength array_len_info = {.len_total = len}; + BPyPropArrayLength array_len_info{}; + array_len_info.len_total = len; array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -769,7 +770,7 @@ static void bpy_prop_boolean_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, bo Py_DECREF(args); - if (ret != NULL) { + if (ret != nullptr) { if (bpy_prop_array_from_py_with_dims(values, sizeof(*values), ret, @@ -803,7 +804,7 @@ static void bpy_prop_boolean_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, bo static void bpy_prop_boolean_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const bool *values) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -813,10 +814,11 @@ static void bpy_prop_boolean_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, co bool use_gil; const bool is_write_ok = pyrna_write_check(); const int len = RNA_property_array_length(ptr, prop); - struct BPyPropArrayLength array_len_info = {.len_total = len}; + BPyPropArrayLength array_len_info{}; + array_len_info.len_total = len; array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -847,7 +849,7 @@ static void bpy_prop_boolean_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, co Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -876,7 +878,7 @@ static void bpy_prop_boolean_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, co static int bpy_prop_int_get_fn(PointerRNA *ptr, PropertyRNA *prop) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -886,7 +888,7 @@ static int bpy_prop_int_get_fn(PointerRNA *ptr, PropertyRNA *prop) const bool is_write_ok = pyrna_write_check(); int value; - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -908,7 +910,7 @@ static int bpy_prop_int_get_fn(PointerRNA *ptr, PropertyRNA *prop) Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); value = 0.0f; } @@ -936,7 +938,7 @@ static int bpy_prop_int_get_fn(PointerRNA *ptr, PropertyRNA *prop) static void bpy_prop_int_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -945,7 +947,7 @@ static void bpy_prop_int_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value) bool use_gil; const bool is_write_ok = pyrna_write_check(); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -969,7 +971,7 @@ static void bpy_prop_int_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value) Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -992,7 +994,7 @@ static void bpy_prop_int_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value) static void bpy_prop_int_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, int *values) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1002,10 +1004,11 @@ static void bpy_prop_int_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, int *v const bool is_write_ok = pyrna_write_check(); bool is_values_set = false; int i, len = RNA_property_array_length(ptr, prop); - struct BPyPropArrayLength array_len_info = {.len_total = len}; + BPyPropArrayLength array_len_info{}; + array_len_info.len_total = len; array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1027,7 +1030,7 @@ static void bpy_prop_int_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, int *v Py_DECREF(args); - if (ret != NULL) { + if (ret != nullptr) { if (bpy_prop_array_from_py_with_dims(values, sizeof(*values), ret, @@ -1061,7 +1064,7 @@ static void bpy_prop_int_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, int *v static void bpy_prop_int_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const int *values) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1071,10 +1074,11 @@ static void bpy_prop_int_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const bool use_gil; const bool is_write_ok = pyrna_write_check(); const int len = RNA_property_array_length(ptr, prop); - struct BPyPropArrayLength array_len_info = {.len_total = len}; + BPyPropArrayLength array_len_info{}; + array_len_info.len_total = len; array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1106,7 +1110,7 @@ static void bpy_prop_int_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -1135,7 +1139,7 @@ static void bpy_prop_int_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const static float bpy_prop_float_get_fn(PointerRNA *ptr, PropertyRNA *prop) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1145,7 +1149,7 @@ static float bpy_prop_float_get_fn(PointerRNA *ptr, PropertyRNA *prop) const bool is_write_ok = pyrna_write_check(); float value; - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1167,7 +1171,7 @@ static float bpy_prop_float_get_fn(PointerRNA *ptr, PropertyRNA *prop) Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); value = 0.0f; } @@ -1195,7 +1199,7 @@ static float bpy_prop_float_get_fn(PointerRNA *ptr, PropertyRNA *prop) static void bpy_prop_float_set_fn(PointerRNA *ptr, PropertyRNA *prop, float value) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1204,7 +1208,7 @@ static void bpy_prop_float_set_fn(PointerRNA *ptr, PropertyRNA *prop, float valu bool use_gil; const bool is_write_ok = pyrna_write_check(); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1228,7 +1232,7 @@ static void bpy_prop_float_set_fn(PointerRNA *ptr, PropertyRNA *prop, float valu Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -1251,7 +1255,7 @@ static void bpy_prop_float_set_fn(PointerRNA *ptr, PropertyRNA *prop, float valu static void bpy_prop_float_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, float *values) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1261,10 +1265,11 @@ static void bpy_prop_float_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, floa const bool is_write_ok = pyrna_write_check(); bool is_values_set = false; int i, len = RNA_property_array_length(ptr, prop); - struct BPyPropArrayLength array_len_info = {.len_total = len}; + BPyPropArrayLength array_len_info{}; + array_len_info.len_total = len; array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1286,7 +1291,7 @@ static void bpy_prop_float_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, floa Py_DECREF(args); - if (ret != NULL) { + if (ret != nullptr) { if (bpy_prop_array_from_py_with_dims(values, sizeof(*values), ret, @@ -1324,7 +1329,7 @@ static void bpy_prop_float_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, floa static void bpy_prop_float_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const float *values) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1334,10 +1339,11 @@ static void bpy_prop_float_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, cons bool use_gil; const bool is_write_ok = pyrna_write_check(); const int len = RNA_property_array_length(ptr, prop); - struct BPyPropArrayLength array_len_info = {.len_total = len}; + BPyPropArrayLength array_len_info{}; + array_len_info.len_total = len; array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1369,7 +1375,7 @@ static void bpy_prop_float_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, cons Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -1398,7 +1404,7 @@ static void bpy_prop_float_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, cons static void bpy_prop_string_get_fn(PointerRNA *ptr, PropertyRNA *prop, char *value) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1407,7 +1413,7 @@ static void bpy_prop_string_get_fn(PointerRNA *ptr, PropertyRNA *prop, char *val bool use_gil; const bool is_write_ok = pyrna_write_check(); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1429,7 +1435,7 @@ static void bpy_prop_string_get_fn(PointerRNA *ptr, PropertyRNA *prop, char *val Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); value[0] = '\0'; } @@ -1458,7 +1464,7 @@ static void bpy_prop_string_get_fn(PointerRNA *ptr, PropertyRNA *prop, char *val static int bpy_prop_string_length_fn(PointerRNA *ptr, PropertyRNA *prop) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1468,7 +1474,7 @@ static int bpy_prop_string_length_fn(PointerRNA *ptr, PropertyRNA *prop) const bool is_write_ok = pyrna_write_check(); int length; - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1490,7 +1496,7 @@ static int bpy_prop_string_length_fn(PointerRNA *ptr, PropertyRNA *prop) Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); length = 0; } @@ -1521,7 +1527,7 @@ static int bpy_prop_string_length_fn(PointerRNA *ptr, PropertyRNA *prop) static void bpy_prop_string_set_fn(PointerRNA *ptr, PropertyRNA *prop, const char *value) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1531,7 +1537,7 @@ static void bpy_prop_string_set_fn(PointerRNA *ptr, PropertyRNA *prop, const cha const bool is_write_ok = pyrna_write_check(); PyObject *py_value; - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1562,7 +1568,7 @@ static void bpy_prop_string_set_fn(PointerRNA *ptr, PropertyRNA *prop, const cha Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -1589,14 +1595,14 @@ static bool bpy_prop_string_visit_fn_call(PyObject *py_func, void *visit_user_data) { const char *text; - const char *info = NULL; + const char *info = nullptr; if (PyTuple_CheckExact(item)) { /* Positional only. */ static const char *_keywords[] = { "", "", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "s" /* `text` */ @@ -1605,14 +1611,14 @@ static bool bpy_prop_string_visit_fn_call(PyObject *py_func, _keywords, 0, }; - if (!_PyArg_ParseTupleAndKeywordsFast(item, NULL, &_parser, &text, &info)) { + if (!_PyArg_ParseTupleAndKeywordsFast(item, nullptr, &_parser, &text, &info)) { PyC_Err_PrintWithFunc(py_func); return false; } } else { text = PyUnicode_AsUTF8(item); - if (UNLIKELY(text == NULL)) { + if (UNLIKELY(text == nullptr)) { PyErr_Clear(); PyErr_Format(PyExc_TypeError, "expected sequence of strings or tuple pairs of strings, not %.200s", @@ -1622,7 +1628,7 @@ static bool bpy_prop_string_visit_fn_call(PyObject *py_func, } } - StringPropertySearchVisitParams visit_params = {NULL}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = text; visit_params.info = info; visit_fn(visit_user_data, &visit_params); @@ -1636,7 +1642,7 @@ static void bpy_prop_string_visit_for_search_fn(const struct bContext *C, StringPropertySearchVisitFunc visit_fn, void *visit_user_data) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1644,7 +1650,7 @@ static void bpy_prop_string_visit_for_search_fn(const struct bContext *C, PyGILState_STATE gilstate; PyObject *py_edit_text; - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (C) { bpy_context_set((struct bContext *)C, &gilstate); @@ -1669,7 +1675,7 @@ static void bpy_prop_string_visit_for_search_fn(const struct bContext *C, Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -1678,14 +1684,14 @@ static void bpy_prop_string_visit_for_search_fn(const struct bContext *C, PyObject *it; PyObject *(*iternext)(PyObject *); it = PyObject_GetIter(ret); - if (it == NULL) { + if (it == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { iternext = *Py_TYPE(it)->tp_iternext; for (;;) { PyObject *py_text = iternext(it); - if (py_text == NULL) { + if (py_text == nullptr) { break; } const bool ok = bpy_prop_string_visit_fn_call( @@ -1712,7 +1718,7 @@ static void bpy_prop_string_visit_for_search_fn(const struct bContext *C, ret, "StringProperty(...): " "return value from search callback was not a sequence, iterator or generator"); - if (ret_fast == NULL) { + if (ret_fast == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -1748,7 +1754,7 @@ static void bpy_prop_string_visit_for_search_fn(const struct bContext *C, static bool bpy_prop_pointer_poll_fn(PointerRNA *self, PointerRNA candidate, PropertyRNA *prop) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_self; PyObject *py_candidate; PyObject *py_func; @@ -1758,7 +1764,7 @@ static bool bpy_prop_pointer_poll_fn(PointerRNA *self, PointerRNA candidate, Pro const int is_write_ok = pyrna_write_check(); const PyGILState_STATE gilstate = PyGILState_Ensure(); - BLI_assert(self != NULL); + BLI_assert(self != nullptr); py_self = pyrna_struct_as_instance(self); py_candidate = pyrna_struct_as_instance(&candidate); @@ -1776,7 +1782,7 @@ static bool bpy_prop_pointer_poll_fn(PointerRNA *self, PointerRNA candidate, Pro Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); result = false; } @@ -1801,7 +1807,7 @@ static bool bpy_prop_pointer_poll_fn(PointerRNA *self, PointerRNA candidate, Pro static int bpy_prop_enum_get_fn(PointerRNA *ptr, PropertyRNA *prop) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1811,7 +1817,7 @@ static int bpy_prop_enum_get_fn(PointerRNA *ptr, PropertyRNA *prop) const bool is_write_ok = pyrna_write_check(); int value; - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1833,7 +1839,7 @@ static int bpy_prop_enum_get_fn(PointerRNA *ptr, PropertyRNA *prop) Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); value = RNA_property_enum_get_default(ptr, prop); } @@ -1861,7 +1867,7 @@ static int bpy_prop_enum_get_fn(PointerRNA *ptr, PropertyRNA *prop) static void bpy_prop_enum_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value) { - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; PyObject *args; PyObject *self; @@ -1870,7 +1876,7 @@ static void bpy_prop_enum_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value) bool use_gil; const bool is_write_ok = pyrna_write_check(); - BLI_assert(prop_store != NULL); + BLI_assert(prop_store != nullptr); if (!is_write_ok) { pyrna_write_set(true); @@ -1894,7 +1900,7 @@ static void bpy_prop_enum_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value) Py_DECREF(args); - if (ret == NULL) { + if (ret == nullptr) { PyC_Err_PrintWithFunc(py_func); } else { @@ -1973,7 +1979,7 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, Py_ssize_t totbuf = 0; #endif short default_used = 0; - const char *default_str_cmp = NULL; + const char *default_str_cmp = nullptr; int default_int_cmp = 0; if (is_enum_flag) { @@ -1981,26 +1987,26 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyErr_SetString(PyExc_TypeError, "EnumProperty(...): maximum " STRINGIFY( RNA_ENUM_BITFLAG_SIZE) " members for a ENUM_FLAG type property"); - return NULL; + return nullptr; } if (default_py && !PySet_Check(default_py)) { PyErr_Format(PyExc_TypeError, "EnumProperty(...): default option must be a 'set' " "type when ENUM_FLAG is enabled, not a '%.200s'", Py_TYPE(default_py)->tp_name); - return NULL; + return nullptr; } } else { if (default_py) { if (!py_long_as_int(default_py, &default_int_cmp)) { default_str_cmp = PyUnicode_AsUTF8(default_py); - if (default_str_cmp == NULL) { + if (default_str_cmp == nullptr) { PyErr_Format(PyExc_TypeError, "EnumProperty(...): default option must be a 'str' or 'int' " "type when ENUM_FLAG is disabled, not a '%.200s'", Py_TYPE(default_py)->tp_name); - return NULL; + return nullptr; } } } @@ -2009,11 +2015,12 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, /* blank value */ *r_default_value = 0; - items = MEM_callocN(sizeof(EnumPropertyItem) * (seq_len + 1), "enum_items_from_py1"); + items = static_cast( + MEM_callocN(sizeof(EnumPropertyItem) * (seq_len + 1), "enum_items_from_py1")); for (i = 0; i < seq_len; i++) { EnumPropertyItem tmp = {0, "", 0, "", ""}; - const char *tmp_icon = NULL; + const char *tmp_icon = nullptr; Py_ssize_t item_size; Py_ssize_t id_str_len; Py_ssize_t name_str_len; @@ -2048,8 +2055,8 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, } if (default_py && default_used == 0) { - if ((default_str_cmp != NULL && STREQ(default_str_cmp, tmp.identifier)) || - (default_str_cmp == NULL && default_int_cmp == tmp.value)) + if ((default_str_cmp != nullptr && STREQ(default_str_cmp, tmp.identifier)) || + (default_str_cmp == nullptr && default_int_cmp == tmp.value)) { *r_default_value = tmp.value; default_used++; /* only ever 1 */ @@ -2078,7 +2085,7 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, "EnumProperty(...): expected a tuple containing " "(identifier, name, description) and optionally an " "icon name and unique number"); - return NULL; + return nullptr; } } @@ -2090,7 +2097,7 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyErr_Format(PyExc_TypeError, "EnumProperty(..., default={...}): set has %d unused member(s)", PySet_GET_SIZE(default_py) - default_used); - return NULL; + return nullptr; } } else { @@ -2107,7 +2114,7 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, "EnumProperty(..., default=%d): not found in enum members", default_int_cmp); } - return NULL; + return nullptr; } } @@ -2129,7 +2136,7 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, MEM_freeN(items); items = items_dup; } - /* end string duplication */ +/* end string duplication */ #endif return items; @@ -2141,13 +2148,13 @@ static const EnumPropertyItem *bpy_prop_enum_itemf_fn(struct bContext *C, bool *r_free) { PyGILState_STATE gilstate; - struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + struct BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func = prop_store->py_data.enum_data.itemf_fn; - PyObject *self = NULL; + PyObject *self = nullptr; PyObject *args; PyObject *items; /* returned from the function call */ - const EnumPropertyItem *eitems = NULL; + const EnumPropertyItem *eitems = nullptr; int err = 0; if (C) { @@ -2175,7 +2182,7 @@ static const EnumPropertyItem *bpy_prop_enum_itemf_fn(struct bContext *C, Py_DECREF(args); - if (items == NULL) { + if (items == nullptr) { err = -1; } else { @@ -2189,8 +2196,10 @@ static const EnumPropertyItem *bpy_prop_enum_itemf_fn(struct bContext *C, err = -1; } else { - eitems = enum_items_from_py( - items_fast, (RNA_property_flag(prop) & PROP_ENUM_FLAG) != 0, NULL, &default_value_dummy); + eitems = enum_items_from_py(items_fast, + (RNA_property_flag(prop) & PROP_ENUM_FLAG) != 0, + nullptr, + &default_value_dummy); Py_DECREF(items_fast); @@ -2258,7 +2267,7 @@ static void bpy_prop_callback_assign_update(PropertyRNA *prop, PyObject *update_ if (update_fn && update_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); - RNA_def_property_update_runtime(prop, bpy_prop_update_fn); + RNA_def_property_update_runtime(prop, reinterpret_cast(bpy_prop_update_fn)); ASSIGN_PYOBJECT_INCREF(prop_store->py_data.update_fn, update_fn); RNA_def_property_flag(prop, PROP_CONTEXT_PROPERTY_UPDATE); @@ -2270,15 +2279,15 @@ static void bpy_prop_callback_assign_pointer(PropertyRNA *prop, PyObject *poll_f if (poll_fn && poll_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); - RNA_def_property_poll_runtime(prop, bpy_prop_pointer_poll_fn); + RNA_def_property_poll_runtime(prop, reinterpret_cast(bpy_prop_pointer_poll_fn)); ASSIGN_PYOBJECT_INCREF(prop_store->py_data.pointer_data.poll_fn, poll_fn); } } static void bpy_prop_callback_assign_boolean(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn) { - BooleanPropertyGetFunc rna_get_fn = NULL; - BooleanPropertySetFunc rna_set_fn = NULL; + BooleanPropertyGetFunc rna_get_fn = nullptr; + BooleanPropertySetFunc rna_set_fn = nullptr; if (get_fn && get_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); @@ -2301,8 +2310,8 @@ static void bpy_prop_callback_assign_boolean_array(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn) { - BooleanArrayPropertyGetFunc rna_get_fn = NULL; - BooleanArrayPropertySetFunc rna_set_fn = NULL; + BooleanArrayPropertyGetFunc rna_get_fn = nullptr; + BooleanArrayPropertySetFunc rna_set_fn = nullptr; if (get_fn && get_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); @@ -2323,8 +2332,8 @@ static void bpy_prop_callback_assign_boolean_array(PropertyRNA *prop, static void bpy_prop_callback_assign_int(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn) { - IntPropertyGetFunc rna_get_fn = NULL; - IntPropertySetFunc rna_set_fn = NULL; + IntPropertyGetFunc rna_get_fn = nullptr; + IntPropertySetFunc rna_set_fn = nullptr; if (get_fn && get_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); @@ -2340,15 +2349,15 @@ static void bpy_prop_callback_assign_int(PropertyRNA *prop, PyObject *get_fn, Py ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn); } - RNA_def_property_int_funcs_runtime(prop, rna_get_fn, rna_set_fn, NULL); + RNA_def_property_int_funcs_runtime(prop, rna_get_fn, rna_set_fn, nullptr); } static void bpy_prop_callback_assign_int_array(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn) { - IntArrayPropertyGetFunc rna_get_fn = NULL; - IntArrayPropertySetFunc rna_set_fn = NULL; + IntArrayPropertyGetFunc rna_get_fn = nullptr; + IntArrayPropertySetFunc rna_set_fn = nullptr; if (get_fn && get_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); @@ -2364,13 +2373,13 @@ static void bpy_prop_callback_assign_int_array(PropertyRNA *prop, ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn); } - RNA_def_property_int_array_funcs_runtime(prop, rna_get_fn, rna_set_fn, NULL); + RNA_def_property_int_array_funcs_runtime(prop, rna_get_fn, rna_set_fn, nullptr); } static void bpy_prop_callback_assign_float(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn) { - FloatPropertyGetFunc rna_get_fn = NULL; - FloatPropertySetFunc rna_set_fn = NULL; + FloatPropertyGetFunc rna_get_fn = nullptr; + FloatPropertySetFunc rna_set_fn = nullptr; if (get_fn && get_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); @@ -2386,15 +2395,15 @@ static void bpy_prop_callback_assign_float(PropertyRNA *prop, PyObject *get_fn, ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn); } - RNA_def_property_float_funcs_runtime(prop, rna_get_fn, rna_set_fn, NULL); + RNA_def_property_float_funcs_runtime(prop, rna_get_fn, rna_set_fn, nullptr); } static void bpy_prop_callback_assign_float_array(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn) { - FloatArrayPropertyGetFunc rna_get_fn = NULL; - FloatArrayPropertySetFunc rna_set_fn = NULL; + FloatArrayPropertyGetFunc rna_get_fn = nullptr; + FloatArrayPropertySetFunc rna_set_fn = nullptr; if (get_fn && get_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); @@ -2410,7 +2419,7 @@ static void bpy_prop_callback_assign_float_array(PropertyRNA *prop, ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn); } - RNA_def_property_float_array_funcs_runtime(prop, rna_get_fn, rna_set_fn, NULL); + RNA_def_property_float_array_funcs_runtime(prop, rna_get_fn, rna_set_fn, nullptr); } static void bpy_prop_callback_assign_string(PropertyRNA *prop, @@ -2419,10 +2428,10 @@ static void bpy_prop_callback_assign_string(PropertyRNA *prop, PyObject *search_fn, const eStringPropertySearchFlag search_flag) { - StringPropertyGetFunc rna_get_fn = NULL; - StringPropertyLengthFunc rna_length_fn = NULL; - StringPropertySetFunc rna_set_fn = NULL; - StringPropertySearchFunc rna_search_fn = NULL; + StringPropertyGetFunc rna_get_fn = nullptr; + StringPropertyLengthFunc rna_length_fn = nullptr; + StringPropertySetFunc rna_set_fn = nullptr; + StringPropertySearchFunc rna_search_fn = nullptr; if (get_fn && get_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); @@ -2456,9 +2465,9 @@ static void bpy_prop_callback_assign_enum(PropertyRNA *prop, PyObject *set_fn, PyObject *itemf_fn) { - EnumPropertyGetFunc rna_get_fn = NULL; - EnumPropertyItemFunc rna_itemf_fn = NULL; - EnumPropertySetFunc rna_set_fn = NULL; + EnumPropertyGetFunc rna_get_fn = nullptr; + EnumPropertyItemFunc rna_itemf_fn = nullptr; + EnumPropertySetFunc rna_set_fn = nullptr; if (get_fn && get_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); @@ -2497,7 +2506,7 @@ static void bpy_prop_callback_assign_enum(PropertyRNA *prop, * \param args: The positional arguments of the caller. * \param kw: The keyword arguments of the caller. * \param method_object: The method of the caller (unfortunately this can't be deduced). - * \param r_deferred_result: The deferred result (or NULL in the case of an error). + * \param r_deferred_result: The deferred result (or nullptr in the case of an error). * The caller must return this value unless a valid `srna` is returned. * * \returns When not null, the caller is expected to perform the registration. @@ -2524,27 +2533,27 @@ static StructRNA *bpy_prop_deferred_data_or_srna(PyObject *self, *r_deferred_result = method_fn(self, args, kw); Py_DECREF(args); /* May be an error (depending on `r_deferred_result`). */ - return NULL; + return nullptr; } const char *error_prefix = method_def->ml_name; if (args_len > 1) { PyErr_Format(PyExc_ValueError, "%s: all args must be keywords", error_prefix); - *r_deferred_result = NULL; + *r_deferred_result = nullptr; /* An error. */ - return NULL; + return nullptr; } StructRNA *srna = srna_from_self(self, error_prefix); - if (srna == NULL) { + if (srna == nullptr) { *r_deferred_result = PyErr_Occurred() ? - NULL : + nullptr : bpy_prop_deferred_data_CreatePyObject(method_object, kw); /* May be an error (depending on `r_deferred_result`). */ - return NULL; + return nullptr; } - /* Crash if this is ever used by accident! */ +/* Crash if this is ever used by accident! */ #ifndef NDEBUG *r_deferred_result = (PyObject *)(intptr_t)1; #endif @@ -2570,7 +2579,7 @@ struct BPy_PropIDParse { */ static int bpy_prop_arg_parse_id(PyObject *o, void *p) { - struct BPy_PropIDParse *parse_data = p; + struct BPy_PropIDParse *parse_data = static_cast(p); StructRNA *srna = parse_data->srna; if (!PyUnicode_Check(o)) { @@ -2587,7 +2596,7 @@ static int bpy_prop_arg_parse_id(PyObject *o, void *p) return 0; } - parse_data->prop_free_handle = NULL; + parse_data->prop_free_handle = nullptr; if (UNLIKELY(RNA_def_property_free_identifier_deferred_prepare( srna, id, &parse_data->prop_free_handle) == -1)) { @@ -2615,9 +2624,10 @@ struct BPy_EnumProperty_Parse_WithSRNA { */ static int bpy_prop_arg_parse_tag_defines(PyObject *o, void *p) { - struct BPy_EnumProperty_Parse_WithSRNA *parse_data = p; + struct BPy_EnumProperty_Parse_WithSRNA *parse_data = + static_cast(p); parse_data->base.items = RNA_struct_property_tag_defines(parse_data->srna); - if (parse_data->base.items == NULL) { + if (parse_data->base.items == nullptr) { PyErr_Format(PyExc_TypeError, "property-tags not available for '%s'", RNA_struct_identifier(parse_data->srna)); @@ -2741,8 +2751,8 @@ static int bpy_prop_arg_parse_tag_defines(PyObject *o, void *p) static int bpy_struct_id_used(StructRNA *srna, char *identifier) { PointerRNA ptr; - RNA_pointer_create(NULL, srna, NULL, &ptr); - return (RNA_struct_find_property(&ptr, identifier) != NULL); + RNA_pointer_create(nullptr, srna, nullptr, &ptr); + return (RNA_struct_find_property(&ptr, identifier) != nullptr); } #endif @@ -2753,7 +2763,7 @@ static int bpy_struct_id_used(StructRNA *srna, char *identifier) * * Functions that register RNA. * - * \note The `self` argument is NULL when called from Python, + * \note The `self` argument is nullptr when called from Python, * but being abused from C so we can pass the `srna` along. * This isn't incorrect since its a Python object - but be careful. * @@ -2783,37 +2793,36 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) { /* Keep this block first. */ PyObject *deferred_result; srna = bpy_prop_deferred_data_or_srna(self, args, kw, pymeth_BoolProperty, &deferred_result); - if (srna == NULL) { + if (srna == nullptr) { return deferred_result; } } - struct BPy_PropIDParse id_data = { - .srna = srna, - }; - const char *name = NULL, *description = ""; - const char *translation_context = NULL; + BPy_PropIDParse id_data{}; + id_data.srna = srna; + + const char *name = nullptr, *description = ""; + const char *translation_context = nullptr; bool default_value = false; PropertyRNA *prop; - struct BPy_EnumProperty_Parse options_enum = { - .items = rna_enum_property_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse override_enum = { - .items = rna_enum_property_override_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { - .srna = srna, - }; - struct BPy_EnumProperty_Parse subtype_enum = { - .items = rna_enum_property_subtype_number_items, - .value = PROP_NONE, - }; + BPy_EnumProperty_Parse options_enum{}; + options_enum.items = rna_enum_property_flag_items; + options_enum.value = 0; - PyObject *update_fn = NULL; - PyObject *get_fn = NULL; - PyObject *set_fn = NULL; + BPy_EnumProperty_Parse override_enum{}; + override_enum.items = rna_enum_property_override_flag_items; + override_enum.value = 0; + + BPy_EnumProperty_Parse_WithSRNA tags_enum{}; + tags_enum.srna = srna; + + BPy_EnumProperty_Parse subtype_enum{}; + subtype_enum.items = rna_enum_property_subtype_number_items; + subtype_enum.value = PROP_NONE; + + PyObject *update_fn = nullptr; + PyObject *get_fn = nullptr; + PyObject *set_fn = nullptr; static const char *_keywords[] = { "attr", @@ -2828,7 +2837,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) "update", "get", "set", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "O&" /* `attr` */ @@ -2870,20 +2879,20 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) &get_fn, &set_fn)) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(update_fn, "update", 2) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(get_fn, "get", 1) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(set_fn, "set", 2) == -1) { - return NULL; + return nullptr; } - if (id_data.prop_free_handle != NULL) { + if (id_data.prop_free_handle != nullptr) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); } prop = RNA_def_property(srna, id_data.value, PROP_BOOLEAN, subtype_enum.value); @@ -2938,38 +2947,40 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject PyObject *deferred_result; srna = bpy_prop_deferred_data_or_srna( self, args, kw, pymeth_BoolVectorProperty, &deferred_result); - if (srna == NULL) { + if (srna == nullptr) { return deferred_result; } } - struct BPy_PropIDParse id_data = { - .srna = srna, - }; - const char *name = NULL, *description = ""; - const char *translation_context = NULL; + BPy_PropIDParse id_data{}; + id_data.srna = srna; + + const char *name = nullptr, *description = ""; + const char *translation_context = nullptr; bool default_value[RNA_MAX_ARRAY_DIMENSION][PYRNA_STACK_ARRAY] = {{false}}; - struct BPyPropArrayLength array_len_info = {.len_total = 3}; + BPyPropArrayLength array_len_info{}; + array_len_info.len_total = 3; PropertyRNA *prop; - PyObject *default_py = NULL; - struct BPy_EnumProperty_Parse options_enum = { - .items = rna_enum_property_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse override_enum = { - .items = rna_enum_property_override_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { - .srna = srna, - }; - struct BPy_EnumProperty_Parse subtype_enum = { - .items = rna_enum_property_subtype_number_array_items, - .value = PROP_NONE, - }; - PyObject *update_fn = NULL; - PyObject *get_fn = NULL; - PyObject *set_fn = NULL; + PyObject *default_py = nullptr; + + BPy_EnumProperty_Parse options_enum{}; + options_enum.items = rna_enum_property_flag_items; + options_enum.value = 0; + + BPy_EnumProperty_Parse override_enum{}; + override_enum.items = rna_enum_property_override_flag_items; + override_enum.value = 0; + + BPy_EnumProperty_Parse_WithSRNA tags_enum{}; + tags_enum.srna = srna; + + BPy_EnumProperty_Parse subtype_enum{}; + subtype_enum.items = rna_enum_property_subtype_number_array_items; + subtype_enum.value = PROP_NONE; + + PyObject *update_fn = nullptr; + PyObject *get_fn = nullptr; + PyObject *set_fn = nullptr; static const char *_keywords[] = { "attr", @@ -2985,7 +2996,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject "update", "get", "set", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "O&" /* `attr` */ @@ -3029,10 +3040,10 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject &get_fn, &set_fn)) { - return NULL; + return nullptr; } - if (default_py != NULL) { + if (default_py != nullptr) { if (bpy_prop_array_from_py_with_dims(default_value[0], sizeof(*default_value[0]), default_py, @@ -3040,34 +3051,34 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject &PyBool_Type, "BoolVectorProperty(default=sequence)") == -1) { - return NULL; + return nullptr; } } if (bpy_prop_callback_check(update_fn, "update", 2) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(get_fn, "get", 1) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(set_fn, "set", 2) == -1) { - return NULL; + return nullptr; } - if (id_data.prop_free_handle != NULL) { + if (id_data.prop_free_handle != nullptr) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); } prop = RNA_def_property(srna, id_data.value, PROP_BOOLEAN, subtype_enum.value); if (array_len_info.dims_len == 0) { RNA_def_property_array(prop, array_len_info.len_total); - if (default_py != NULL) { + if (default_py != nullptr) { RNA_def_property_boolean_array_default(prop, default_value[0]); } } else { RNA_def_property_multi_array(prop, array_len_info.dims_len, array_len_info.dims); - if (default_py != NULL) { + if (default_py != nullptr) { RNA_def_property_boolean_array_default(prop, &default_value[0][0]); } } @@ -3123,39 +3134,39 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) { /* Keep this block first. */ PyObject *deferred_result; srna = bpy_prop_deferred_data_or_srna(self, args, kw, pymeth_IntProperty, &deferred_result); - if (srna == NULL) { + if (srna == nullptr) { return deferred_result; } } - struct BPy_PropIDParse id_data = { - .srna = srna, - }; - const char *name = NULL, *description = ""; - const char *translation_context = NULL; + BPy_PropIDParse id_data{}; + id_data.srna = srna; + + const char *name = nullptr, *description = ""; + const char *translation_context = nullptr; int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX; int step = 1; int default_value = 0; PropertyRNA *prop; - struct BPy_EnumProperty_Parse options_enum = { - .items = rna_enum_property_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse override_enum = { - .items = rna_enum_property_override_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { - .srna = srna, - }; - struct BPy_EnumProperty_Parse subtype_enum = { - .items = rna_enum_property_subtype_number_items, - .value = PROP_NONE, - }; - PyObject *update_fn = NULL; - PyObject *get_fn = NULL; - PyObject *set_fn = NULL; + BPy_EnumProperty_Parse options_enum{}; + options_enum.items = rna_enum_property_flag_items; + options_enum.value = 0; + + BPy_EnumProperty_Parse override_enum{}; + override_enum.items = rna_enum_property_override_flag_items; + override_enum.value = 0; + + BPy_EnumProperty_Parse_WithSRNA tags_enum{}; + tags_enum.srna = srna; + + BPy_EnumProperty_Parse subtype_enum{}; + subtype_enum.items = rna_enum_property_subtype_number_items; + subtype_enum.value = PROP_NONE; + + PyObject *update_fn = nullptr; + PyObject *get_fn = nullptr; + PyObject *set_fn = nullptr; static const char *_keywords[] = { "attr", @@ -3175,7 +3186,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) "update", "get", "set", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "O&" /* `attr` */ @@ -3226,20 +3237,20 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) &get_fn, &set_fn)) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(update_fn, "update", 2) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(get_fn, "get", 1) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(set_fn, "set", 2) == -1) { - return NULL; + return nullptr; } - if (id_data.prop_free_handle != NULL) { + if (id_data.prop_free_handle != nullptr) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); } prop = RNA_def_property(srna, id_data.value, PROP_INT, subtype_enum.value); @@ -3303,48 +3314,49 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject PyObject *deferred_result; srna = bpy_prop_deferred_data_or_srna( self, args, kw, pymeth_IntVectorProperty, &deferred_result); - if (srna == NULL) { + if (srna == nullptr) { return deferred_result; } } - struct BPy_PropIDParse id_data = { - .srna = srna, - }; - const char *name = NULL, *description = ""; - const char *translation_context = NULL; + BPy_PropIDParse id_data{}; + id_data.srna = srna; + + const char *name = nullptr, *description = ""; + const char *translation_context = nullptr; int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX; int step = 1; int default_value[RNA_MAX_ARRAY_DIMENSION][PYRNA_STACK_ARRAY] = {0}; - struct BPyPropArrayLength array_len_info = {.len_total = 3}; + BPyPropArrayLength array_len_info{}; + array_len_info.len_total = 3; PropertyRNA *prop; - PyObject *default_py = NULL; + PyObject *default_py = nullptr; - struct BPy_EnumProperty_Parse options_enum = { - .items = rna_enum_property_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse override_enum = { - .items = rna_enum_property_override_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { - .srna = srna, - }; - struct BPy_EnumProperty_Parse subtype_enum = { - .items = rna_enum_property_subtype_number_array_items, - .value = PROP_NONE, - }; - PyObject *update_fn = NULL; - PyObject *get_fn = NULL; - PyObject *set_fn = NULL; + BPy_EnumProperty_Parse options_enum{}; + options_enum.items = rna_enum_property_flag_items; + options_enum.value = 0; + + BPy_EnumProperty_Parse override_enum{}; + override_enum.items = rna_enum_property_override_flag_items; + override_enum.value = 0; + + BPy_EnumProperty_Parse_WithSRNA tags_enum{}; + tags_enum.srna = srna; + + BPy_EnumProperty_Parse subtype_enum{}; + subtype_enum.items = rna_enum_property_subtype_number_array_items; + subtype_enum.value = PROP_NONE; + + PyObject *update_fn = nullptr; + PyObject *get_fn = nullptr; + PyObject *set_fn = nullptr; static const char *_keywords[] = { "attr", "name", "description", "translation_context", "default", "min", "max", "soft_min", "soft_max", "step", "options", "override", "tags", "subtype", "size", "update", - "get", "set", NULL, + "get", "set", nullptr, }; static _PyArg_Parser _parser = { "O&" /* `attr` */ @@ -3398,10 +3410,10 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject &get_fn, &set_fn)) { - return NULL; + return nullptr; } - if (default_py != NULL) { + if (default_py != nullptr) { if (bpy_prop_array_from_py_with_dims(default_value[0], sizeof(*default_value[0]), default_py, @@ -3409,34 +3421,34 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject &PyLong_Type, "IntVectorProperty(default=sequence)") == -1) { - return NULL; + return nullptr; } } if (bpy_prop_callback_check(update_fn, "update", 2) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(get_fn, "get", 1) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(set_fn, "set", 2) == -1) { - return NULL; + return nullptr; } - if (id_data.prop_free_handle != NULL) { + if (id_data.prop_free_handle != nullptr) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); } prop = RNA_def_property(srna, id_data.value, PROP_INT, subtype_enum.value); if (array_len_info.dims_len == 0) { RNA_def_property_array(prop, array_len_info.len_total); - if (default_py != NULL) { + if (default_py != nullptr) { RNA_def_property_int_array_default(prop, default_value[0]); } } else { RNA_def_property_multi_array(prop, array_len_info.dims_len, array_len_info.dims); - if (default_py != NULL) { + if (default_py != nullptr) { RNA_def_property_int_array_default(prop, &default_value[0][0]); } } @@ -3497,52 +3509,51 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) { /* Keep this block first. */ PyObject *deferred_result; srna = bpy_prop_deferred_data_or_srna(self, args, kw, pymeth_FloatProperty, &deferred_result); - if (srna == NULL) { + if (srna == nullptr) { return deferred_result; } } - struct BPy_PropIDParse id_data = { - .srna = srna, - }; - const char *name = NULL, *description = ""; - const char *translation_context = NULL; + BPy_PropIDParse id_data{}; + id_data.srna = srna; + + const char *name = nullptr, *description = ""; + const char *translation_context = nullptr; float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX; float step = 3; float default_value = 0.0f; int precision = 2; PropertyRNA *prop; - struct BPy_EnumProperty_Parse options_enum = { - .items = rna_enum_property_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse override_enum = { - .items = rna_enum_property_override_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { - .srna = srna, - }; - struct BPy_EnumProperty_Parse subtype_enum = { - .items = rna_enum_property_subtype_number_items, - .value = PROP_NONE, - }; - struct BPy_EnumProperty_Parse unit_enum = { - .items = rna_enum_property_unit_items, - .value = PROP_UNIT_NONE, - }; + BPy_EnumProperty_Parse options_enum{}; + options_enum.items = rna_enum_property_flag_items; + options_enum.value = 0; - PyObject *update_fn = NULL; - PyObject *get_fn = NULL; - PyObject *set_fn = NULL; + BPy_EnumProperty_Parse override_enum{}; + override_enum.items = rna_enum_property_override_flag_items; + override_enum.value = 0; + + BPy_EnumProperty_Parse_WithSRNA tags_enum{}; + tags_enum.srna = srna; + + BPy_EnumProperty_Parse subtype_enum{}; + subtype_enum.items = rna_enum_property_subtype_number_items; + subtype_enum.value = PROP_NONE; + + BPy_EnumProperty_Parse unit_enum{}; + unit_enum.items = rna_enum_property_unit_items; + unit_enum.value = PROP_UNIT_NONE; + + PyObject *update_fn = nullptr; + PyObject *get_fn = nullptr; + PyObject *set_fn = nullptr; static const char *_keywords[] = { "attr", "name", "description", "translation_context", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "override", "tags", "subtype", "unit", - "update", "get", "set", NULL, + "update", "get", "set", nullptr, }; static _PyArg_Parser _parser = { "O&" /* `attr` */ @@ -3598,20 +3609,20 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) &get_fn, &set_fn)) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(update_fn, "update", 2) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(get_fn, "get", 1) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(set_fn, "set", 2) == -1) { - return NULL; + return nullptr; } - if (id_data.prop_free_handle != NULL) { + if (id_data.prop_free_handle != nullptr) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); } prop = RNA_def_property(srna, id_data.value, PROP_FLOAT, subtype_enum.value | unit_enum.value); @@ -3678,47 +3689,47 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec PyObject *deferred_result; srna = bpy_prop_deferred_data_or_srna( self, args, kw, pymeth_FloatVectorProperty, &deferred_result); - if (srna == NULL) { + if (srna == nullptr) { return deferred_result; } } - struct BPy_PropIDParse id_data = { - .srna = srna, - }; - const char *name = NULL, *description = ""; - const char *translation_context = NULL; + BPy_PropIDParse id_data{}; + id_data.srna = srna; + + const char *name = nullptr, *description = ""; + const char *translation_context = nullptr; float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX; float step = 3; float default_value[RNA_MAX_ARRAY_DIMENSION][PYRNA_STACK_ARRAY] = {{0.0f}}; int precision = 2; - struct BPyPropArrayLength array_len_info = {.len_total = 3}; + BPyPropArrayLength array_len_info{}; + array_len_info.len_total = 3; PropertyRNA *prop; - PyObject *default_py = NULL; + PyObject *default_py = nullptr; - struct BPy_EnumProperty_Parse options_enum = { - .items = rna_enum_property_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse override_enum = { - .items = rna_enum_property_override_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { - .srna = srna, - }; - struct BPy_EnumProperty_Parse subtype_enum = { - .items = rna_enum_property_subtype_number_array_items, - .value = PROP_NONE, - }; - struct BPy_EnumProperty_Parse unit_enum = { - .items = rna_enum_property_unit_items, - .value = PROP_UNIT_NONE, - }; + BPy_EnumProperty_Parse options_enum{}; + options_enum.items = rna_enum_property_flag_items; + options_enum.value = 0; - PyObject *update_fn = NULL; - PyObject *get_fn = NULL; - PyObject *set_fn = NULL; + BPy_EnumProperty_Parse override_enum{}; + override_enum.items = rna_enum_property_override_flag_items; + override_enum.value = 0; + + BPy_EnumProperty_Parse_WithSRNA tags_enum{}; + tags_enum.srna = srna; + + BPy_EnumProperty_Parse subtype_enum{}; + subtype_enum.items = rna_enum_property_subtype_number_array_items; + subtype_enum.value = PROP_NONE; + + BPy_EnumProperty_Parse unit_enum{}; + unit_enum.items = rna_enum_property_unit_items; + unit_enum.value = PROP_UNIT_NONE; + + PyObject *update_fn = nullptr; + PyObject *get_fn = nullptr; + PyObject *set_fn = nullptr; static const char *_keywords[] = { "attr", "name", "description", "translation_context", @@ -3726,7 +3737,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec "soft_max", "step", "precision", "options", "override", "tags", "subtype", "unit", "size", "update", "get", "set", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "O&" /* `attr` */ @@ -3785,10 +3796,10 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec &get_fn, &set_fn)) { - return NULL; + return nullptr; } - if (default_py != NULL) { + if (default_py != nullptr) { if (bpy_prop_array_from_py_with_dims(default_value[0], sizeof(*default_value[0]), default_py, @@ -3796,7 +3807,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec &PyFloat_Type, "FloatVectorProperty(default=sequence)") == -1) { - return NULL; + return nullptr; } if (bpy_prop_array_is_matrix_compatible_ex(subtype_enum.value, &array_len_info)) { bpy_prop_array_matrix_swap_row_column_vn(&default_value[0][0], &array_len_info); @@ -3804,29 +3815,29 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec } if (bpy_prop_callback_check(update_fn, "update", 2) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(get_fn, "get", 1) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(set_fn, "set", 2) == -1) { - return NULL; + return nullptr; } - if (id_data.prop_free_handle != NULL) { + if (id_data.prop_free_handle != nullptr) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); } prop = RNA_def_property(srna, id_data.value, PROP_FLOAT, subtype_enum.value | unit_enum.value); if (array_len_info.dims_len == 0) { RNA_def_property_array(prop, array_len_info.len_total); - if (default_py != NULL) { + if (default_py != nullptr) { RNA_def_property_float_array_default(prop, default_value[0]); } } else { RNA_def_property_multi_array(prop, array_len_info.dims_len, array_len_info.dims); - if (default_py != NULL) { + if (default_py != nullptr) { RNA_def_property_float_array_default(prop, &default_value[0][0]); } } @@ -3884,42 +3895,41 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw { /* Keep this block first. */ PyObject *deferred_result; srna = bpy_prop_deferred_data_or_srna(self, args, kw, pymeth_StringProperty, &deferred_result); - if (srna == NULL) { + if (srna == nullptr) { return deferred_result; } } - struct BPy_PropIDParse id_data = { - .srna = srna, - }; - const char *name = NULL, *description = ""; - const char *translation_context = NULL, *default_value = ""; + BPy_PropIDParse id_data{}; + id_data.srna = srna; + + const char *name = nullptr, *description = ""; + const char *translation_context = nullptr, *default_value = ""; int maxlen = 0; PropertyRNA *prop; - struct BPy_EnumProperty_Parse options_enum = { - .items = rna_enum_property_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse override_enum = { - .items = rna_enum_property_override_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { - .srna = srna, - }; - struct BPy_EnumProperty_Parse subtype_enum = { - .items = rna_enum_property_subtype_string_items, - .value = PROP_NONE, - }; - PyObject *update_fn = NULL; - PyObject *get_fn = NULL; - PyObject *set_fn = NULL; - PyObject *search_fn = NULL; - static struct BPy_EnumProperty_Parse search_options_enum = { - .items = rna_enum_property_string_search_flag_items, - .value = PROP_STRING_SEARCH_SUGGESTION, - }; + BPy_EnumProperty_Parse options_enum{}; + options_enum.items = rna_enum_property_flag_items; + options_enum.value = 0; + + BPy_EnumProperty_Parse override_enum{}; + override_enum.items = rna_enum_property_override_flag_items; + override_enum.value = 0; + + BPy_EnumProperty_Parse_WithSRNA tags_enum{}; + tags_enum.srna = srna; + + BPy_EnumProperty_Parse subtype_enum{}; + subtype_enum.items = rna_enum_property_subtype_string_items; + subtype_enum.value = PROP_NONE; + + PyObject *update_fn = nullptr; + PyObject *get_fn = nullptr; + PyObject *set_fn = nullptr; + PyObject *search_fn = nullptr; + BPy_EnumProperty_Parse search_options_enum{}; + search_options_enum.items = rna_enum_property_string_search_flag_items; + search_options_enum.value = PROP_STRING_SEARCH_SUGGESTION; static const char *_keywords[] = { "attr", @@ -3937,7 +3947,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw "set", "search", "search_options", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "O&" /* `attr` */ @@ -3985,23 +3995,23 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw pyrna_enum_bitfield_parse_set, &search_options_enum)) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(update_fn, "update", 2) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(get_fn, "get", 1) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(set_fn, "set", 2) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(search_fn, "search", 3) == -1) { - return NULL; + return nullptr; } - if (id_data.prop_free_handle != NULL) { + if (id_data.prop_free_handle != nullptr) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); } prop = RNA_def_property(srna, id_data.value, PROP_STRING, subtype_enum.value); @@ -4028,7 +4038,8 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw bpy_prop_assign_flag_override(prop, override_enum.value); } bpy_prop_callback_assign_update(prop, update_fn); - bpy_prop_callback_assign_string(prop, get_fn, set_fn, search_fn, search_options_enum.value); + bpy_prop_callback_assign_string( + prop, get_fn, set_fn, search_fn, eStringPropertySearchFlag(search_options_enum.value)); RNA_def_property_duplicate_pointers(srna, prop); Py_RETURN_NONE; @@ -4096,37 +4107,37 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) { /* Keep this block first. */ PyObject *deferred_result; srna = bpy_prop_deferred_data_or_srna(self, args, kw, pymeth_EnumProperty, &deferred_result); - if (srna == NULL) { + if (srna == nullptr) { return deferred_result; } } - struct BPy_PropIDParse id_data = { - .srna = srna, - }; - const char *name = NULL, *description = ""; - const char *translation_context = NULL; - PyObject *default_py = NULL; + BPy_PropIDParse id_data{}; + id_data.srna = srna; + + const char *name = nullptr, *description = ""; + const char *translation_context = nullptr; + PyObject *default_py = nullptr; int default_value = 0; PyObject *items, *items_fast; const EnumPropertyItem *eitems; PropertyRNA *prop; - struct BPy_EnumProperty_Parse options_enum = { - .items = rna_enum_property_flag_enum_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse override_enum = { - .items = rna_enum_property_override_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { - .srna = srna, - }; + BPy_EnumProperty_Parse options_enum{}; + options_enum.items = rna_enum_property_flag_enum_items; + options_enum.value = 0; + + BPy_EnumProperty_Parse override_enum{}; + override_enum.items = rna_enum_property_override_flag_items; + override_enum.value = 0; + + BPy_EnumProperty_Parse_WithSRNA tags_enum{}; + tags_enum.srna = srna; + bool is_itemf = false; - PyObject *update_fn = NULL; - PyObject *get_fn = NULL; - PyObject *set_fn = NULL; + PyObject *update_fn = nullptr; + PyObject *get_fn = nullptr; + PyObject *set_fn = nullptr; static const char *_keywords[] = { "attr", @@ -4141,7 +4152,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) "update", "get", "set", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "O&" /* `attr` */ @@ -4181,23 +4192,23 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) &get_fn, &set_fn)) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(update_fn, "update", 2) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(get_fn, "get", 1) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(set_fn, "set", 2) == -1) { - return NULL; + return nullptr; } if (default_py == Py_None) { /* This allows to get same behavior when explicitly passing None as default value, * and not defining a default value at all! */ - default_py = NULL; + default_py = nullptr; } /* Items can be a list or a callable. @@ -4208,7 +4219,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) PyErr_Format(PyExc_ValueError, "EnumProperty(...): expected 'items' function to take 2 arguments, not %d", f_code->co_argcount); - return NULL; + return nullptr; } if (default_py) { @@ -4218,7 +4229,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) PyErr_SetString( PyExc_TypeError, "EnumProperty(...): 'default' can only be an integer when 'items' is a function"); - return NULL; + return nullptr; } } @@ -4231,7 +4242,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) "EnumProperty(...): " "expected a sequence of tuples for the enum items or a function"))) { - return NULL; + return nullptr; } eitems = enum_items_from_py( @@ -4239,11 +4250,11 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) if (!eitems) { Py_DECREF(items_fast); - return NULL; + return nullptr; } } - if (id_data.prop_free_handle != NULL) { + if (id_data.prop_free_handle != nullptr) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); } if (options_enum.value & PROP_ENUM_FLAG) { @@ -4268,7 +4279,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) bpy_prop_assign_flag_override(prop, override_enum.value); } bpy_prop_callback_assign_update(prop, update_fn); - bpy_prop_callback_assign_enum(prop, get_fn, set_fn, (is_itemf ? items : NULL)); + bpy_prop_callback_assign_enum(prop, get_fn, set_fn, (is_itemf ? items : nullptr)); RNA_def_property_duplicate_pointers(srna, prop); if (is_itemf == false) { @@ -4303,7 +4314,7 @@ StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix) error_prefix, Py_TYPE(value)->tp_name); } - return NULL; + return nullptr; } return srna; @@ -4331,32 +4342,32 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) PyObject *deferred_result; srna = bpy_prop_deferred_data_or_srna( self, args, kw, pymeth_PointerProperty, &deferred_result); - if (srna == NULL) { + if (srna == nullptr) { return deferred_result; } } - struct BPy_PropIDParse id_data = { - .srna = srna, - }; - const char *name = NULL, *description = ""; - const char *translation_context = NULL; + BPy_PropIDParse id_data{}; + id_data.srna = srna; + + const char *name = nullptr, *description = ""; + const char *translation_context = nullptr; PropertyRNA *prop; StructRNA *ptype; PyObject *type = Py_None; - struct BPy_EnumProperty_Parse options_enum = { - .items = rna_enum_property_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse override_enum = { - .items = rna_enum_property_override_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { - .srna = srna, - }; - PyObject *update_fn = NULL, *poll_fn = NULL; + BPy_EnumProperty_Parse options_enum{}; + options_enum.items = rna_enum_property_flag_items; + options_enum.value = 0; + + BPy_EnumProperty_Parse override_enum{}; + override_enum.items = rna_enum_property_override_flag_items; + override_enum.value = 0; + + BPy_EnumProperty_Parse_WithSRNA tags_enum{}; + tags_enum.srna = srna; + + PyObject *update_fn = nullptr, *poll_fn = nullptr; static const char *_keywords[] = { "attr", @@ -4369,7 +4380,7 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) "tags", "poll", "update", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "O&" /* `attr` */ @@ -4405,28 +4416,28 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) &poll_fn, &update_fn)) { - return NULL; + return nullptr; } ptype = pointer_type_from_py(type, "PointerProperty(...)"); if (!ptype) { - return NULL; + return nullptr; } if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup) && !RNA_struct_is_ID(ptype)) { PyErr_Format(PyExc_TypeError, "PointerProperty(...) expected an RNA type derived from %.200s or %.200s", RNA_struct_ui_name(&RNA_ID), RNA_struct_ui_name(&RNA_PropertyGroup)); - return NULL; + return nullptr; } if (bpy_prop_callback_check(update_fn, "update", 2) == -1) { - return NULL; + return nullptr; } if (bpy_prop_callback_check(poll_fn, "poll", 2) == -1) { - return NULL; + return nullptr; } - if (id_data.prop_free_handle != NULL) { + if (id_data.prop_free_handle != nullptr) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); } prop = RNA_def_pointer_runtime( @@ -4477,31 +4488,30 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) PyObject *deferred_result; srna = bpy_prop_deferred_data_or_srna( self, args, kw, pymeth_CollectionProperty, &deferred_result); - if (srna == NULL) { + if (srna == nullptr) { return deferred_result; } } - struct BPy_PropIDParse id_data = { - .srna = srna, - }; - const char *name = NULL, *description = ""; - const char *translation_context = NULL; + BPy_PropIDParse id_data{}; + id_data.srna = srna; + + const char *name = nullptr, *description = ""; + const char *translation_context = nullptr; PropertyRNA *prop; StructRNA *ptype; PyObject *type = Py_None; - struct BPy_EnumProperty_Parse options_enum = { - .items = rna_enum_property_flag_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse override_enum = { - .items = rna_enum_property_override_flag_collection_items, - .value = 0, - }; - struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { - .srna = srna, - }; + BPy_EnumProperty_Parse options_enum{}; + options_enum.items = rna_enum_property_flag_items; + options_enum.value = 0; + + BPy_EnumProperty_Parse override_enum{}; + override_enum.items = rna_enum_property_override_flag_collection_items; + override_enum.value = 0; + + BPy_EnumProperty_Parse_WithSRNA tags_enum{}; + tags_enum.srna = srna; static const char *_keywords[] = { "attr", @@ -4512,7 +4522,7 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) "options", "override", "tags", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "O&" /* `attr` */ @@ -4544,22 +4554,22 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) bpy_prop_arg_parse_tag_defines, &tags_enum)) { - return NULL; + return nullptr; } ptype = pointer_type_from_py(type, "CollectionProperty(...):"); if (!ptype) { - return NULL; + return nullptr; } if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup)) { PyErr_Format(PyExc_TypeError, "CollectionProperty(...) expected an RNA type derived from %.200s", RNA_struct_ui_name(&RNA_PropertyGroup)); - return NULL; + return nullptr; } - if (id_data.prop_free_handle != NULL) { + if (id_data.prop_free_handle != nullptr) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); } prop = RNA_def_collection_runtime( @@ -4614,23 +4624,23 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw } if (PyTuple_GET_SIZE(args) > 1) { PyErr_SetString(PyExc_ValueError, "expected one positional arg, one keyword arg"); - return NULL; + return nullptr; } srna = srna_from_self(self, "RemoveProperty(...):"); - if (srna == NULL && PyErr_Occurred()) { - return NULL; /* self's type was compatible but error getting the srna */ + if (srna == nullptr && PyErr_Occurred()) { + return nullptr; /* self's type was compatible but error getting the srna */ } - if (srna == NULL) { + if (srna == nullptr) { PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type"); - return NULL; + return nullptr; } - const char *id = NULL; + const char *id = nullptr; static const char *_keywords[] = { "attr", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "s" /* `attr` */ @@ -4639,12 +4649,12 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw 0, }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &id)) { - return NULL; + return nullptr; } if (RNA_def_property_free_identifier(srna, id) != 1) { PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id); - return NULL; + return nullptr; } Py_RETURN_NONE; @@ -4702,10 +4712,10 @@ static PyMethodDef props_methods[] = { (PyCFunction)BPy_RemoveProperty, METH_VARARGS | METH_KEYWORDS, BPy_RemoveProperty_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; -static int props_visit(PyObject *UNUSED(self), visitproc visit, void *arg) +static int props_visit(PyObject * /*self*/, visitproc visit, void *arg) { LISTBASE_FOREACH (struct BPyPropStore *, prop_store, &g_bpy_prop_store_list) { PyObject **py_data = (PyObject **)&prop_store->py_data; @@ -4716,7 +4726,7 @@ static int props_visit(PyObject *UNUSED(self), visitproc visit, void *arg) return 0; } -static int props_clear(PyObject *UNUSED(self)) +static int props_clear(PyObject * /*self*/) { LISTBASE_FOREACH (struct BPyPropStore *, prop_store, &g_bpy_prop_store_list) { PyObject **py_data = (PyObject **)&prop_store->py_data; @@ -4742,10 +4752,10 @@ static PyModuleDef props_module = { /*m_doc*/ props_module_doc, /*m_size*/ -1, /* multiple "initialization" just copies the module dict. */ /*m_methods*/ props_methods, - /*m_slots*/ NULL, + /*m_slots*/ nullptr, /*m_traverse*/ props_visit, /*m_clear*/ props_clear, - /*m_free*/ NULL, + /*m_free*/ nullptr, }; PyObject *BPY_rna_props(void) @@ -4774,7 +4784,7 @@ PyObject *BPY_rna_props(void) ASSIGN_STATIC(RemoveProperty); if (PyType_Ready(&bpy_prop_deferred_Type) < 0) { - return NULL; + return nullptr; } PyModule_AddType(submodule, &bpy_prop_deferred_Type); @@ -4787,10 +4797,10 @@ PyObject *BPY_rna_props(void) void BPY_rna_props_clear_all(void) { /* Remove all user counts, so this isn't considered a leak from Python's perspective. */ - props_clear(NULL); + props_clear(nullptr); /* Running is harmless, but redundant. */ - RNA_def_property_free_pointers_set_py_data_callback(NULL); + RNA_def_property_free_pointers_set_py_data_callback(nullptr); /* Include as it's correct, in practice this should never be used again. */ BLI_listbase_clear(&g_bpy_prop_store_list); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.cc similarity index 87% rename from source/blender/python/intern/bpy_rna.c rename to source/blender/python/intern/bpy_rna.cc index da0a1dfeec9..63e2b71585d 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.cc @@ -87,7 +87,7 @@ * Even though this is arguably "correct", it's going to cause problems for existing scripts, * so accept having this for the time being. */ -BPy_StructRNA *bpy_context_module = NULL; /* for fast access */ +BPy_StructRNA *bpy_context_module = nullptr; /* for fast access */ static PyObject *pyrna_struct_Subtype(PointerRNA *ptr); static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self); @@ -167,10 +167,10 @@ static void id_release_gc(struct ID *id) #ifdef USE_PYRNA_INVALIDATE_WEAKREF //#define DEBUG_RNA_WEAKREF -struct GHash *id_weakref_pool = NULL; +struct GHash *id_weakref_pool = nullptr; static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref); static PyMethodDef id_free_weakref_cb_def = { - "id_free_weakref_cb", (PyCFunction)id_free_weakref_cb, METH_O, NULL}; + "id_free_weakref_cb", (PyCFunction)id_free_weakref_cb, METH_O, nullptr}; /** * Only used when there are values left on exit (causing memory leaks). @@ -178,14 +178,14 @@ static PyMethodDef id_free_weakref_cb_def = { static void id_weakref_pool_free_value_fn(void *p) { GHash *weakinfo_hash = p; - BLI_ghash_free(weakinfo_hash, NULL, NULL); + BLI_ghash_free(weakinfo_hash, nullptr, nullptr); } /* Adds a reference to the list, remember to decref. */ static GHash *id_weakref_pool_get(ID *id) { GHash *weakinfo_hash = BLI_ghash_lookup(id_weakref_pool, (void *)id); - if (weakinfo_hash == NULL) { + if (weakinfo_hash == nullptr) { /* This could be a set, values are used to keep a reference back to the ID * (all of them are the same). */ weakinfo_hash = BLI_ghash_ptr_new("rna_id"); @@ -205,7 +205,7 @@ static void id_weakref_pool_add(ID *id, BPy_DummyPointerRNA *pyrna) * so we can remove ourself from it. */ GHash *weakinfo_hash = id_weakref_pool_get(id); /* New or existing. */ - weakref_capsule = PyCapsule_New(weakinfo_hash, NULL, NULL); + weakref_capsule = PyCapsule_New(weakinfo_hash, nullptr, nullptr); weakref_cb_py = PyCFunction_New(&id_free_weakref_cb_def, weakref_capsule); Py_DECREF(weakref_capsule); @@ -232,13 +232,13 @@ static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash); static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref) { /* Important to search backwards. */ - GHash *weakinfo_hash = PyCapsule_GetPointer(weakinfo_pair, NULL); + GHash *weakinfo_hash = PyCapsule_GetPointer(weakinfo_pair, nullptr); if (BLI_ghash_len(weakinfo_hash) > 1) { - BLI_ghash_remove(weakinfo_hash, weakref, NULL, NULL); + BLI_ghash_remove(weakinfo_hash, weakref, nullptr, nullptr); } else { /* Get the last id and free it. */ - BLI_ghash_remove(weakinfo_hash, weakref, NULL, value_id_set); + BLI_ghash_remove(weakinfo_hash, weakref, nullptr, value_id_set); id_release_weakref_list(_id_tmp_ptr, weakinfo_hash); } @@ -274,8 +274,8 @@ static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash) BLI_ghashIterator_step(&weakinfo_hash_iter); } - BLI_ghash_remove(id_weakref_pool, (void *)id, NULL, NULL); - BLI_ghash_free(weakinfo_hash, NULL, NULL); + BLI_ghash_remove(id_weakref_pool, (void *)id, nullptr, nullptr); + BLI_ghash_free(weakinfo_hash, nullptr, nullptr); } static void id_release_weakref(struct ID *id) @@ -295,8 +295,8 @@ void BPY_id_release(ID *id) #endif #ifdef USE_PYRNA_INVALIDATE_WEAKREF - /* Check for NULL since this may run before Python has been started. */ - if (id_weakref_pool != NULL) { + /* Check for nullptr since this may run before Python has been started. */ + if (id_weakref_pool != nullptr) { PyGILState_STATE gilstate = PyGILState_Ensure(); id_release_weakref(id); @@ -328,7 +328,7 @@ static bool rna_id_write_error(PointerRNA *ptr, PyObject *key) } /* Make a nice string error. */ - BLI_assert(idtype != NULL); + BLI_assert(idtype != nullptr); PyErr_Format(PyExc_AttributeError, "Writing to ID classes in this context is not allowed: " "%.200s, %.200s datablock, error setting %.200s.%.200s", @@ -359,7 +359,7 @@ bool pyrna_write_check(void) { return true; } -void pyrna_write_set(bool UNUSED(val)) +void pyrna_write_set(bool /*val*/) { /* pass */ } @@ -408,7 +408,7 @@ static int mathutils_rna_vector_get(BaseMathObject *bmo, int subtype) PYRNA_PROP_CHECK_INT(self); - if (self->prop == NULL) { + if (self->prop == nullptr) { return -1; } @@ -417,7 +417,7 @@ static int mathutils_rna_vector_get(BaseMathObject *bmo, int subtype) /* Euler order exception. */ if (subtype == MATHUTILS_CB_SUBTYPE_EUL) { EulerObject *eul = (EulerObject *)bmo; - PropertyRNA *prop_eul_order = NULL; + PropertyRNA *prop_eul_order = nullptr; eul->order = pyrna_rotation_euler_order_get(&self->ptr, eul->order, &prop_eul_order); } @@ -431,12 +431,12 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype) PYRNA_PROP_CHECK_INT(self); - if (self->prop == NULL) { + if (self->prop == nullptr) { return -1; } # ifdef USE_PEDANTIC_WRITE - if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) { + if (rna_disallow_writes && rna_id_write_error(&self->ptr, nullptr)) { return -1; } # endif /* USE_PEDANTIC_WRITE */ @@ -466,7 +466,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype) /* Euler order exception. */ if (subtype == MATHUTILS_CB_SUBTYPE_EUL) { EulerObject *eul = (EulerObject *)bmo; - PropertyRNA *prop_eul_order = NULL; + PropertyRNA *prop_eul_order = nullptr; const short order = pyrna_rotation_euler_order_get(&self->ptr, eul->order, &prop_eul_order); if (order != eul->order) { RNA_property_enum_set(&self->ptr, prop_eul_order, eul->order); @@ -478,13 +478,13 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype) return 0; } -static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int UNUSED(subtype), int index) +static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int /*subtype*/, int index) { BPy_PropertyRNA *self = (BPy_PropertyRNA *)bmo->cb_user; PYRNA_PROP_CHECK_INT(self); - if (self->prop == NULL) { + if (self->prop == nullptr) { return -1; } @@ -492,18 +492,18 @@ static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int UNUSED(subtyp return 0; } -static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtype), int index) +static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int /*subtype*/, int index) { BPy_PropertyRNA *self = (BPy_PropertyRNA *)bmo->cb_user; PYRNA_PROP_CHECK_INT(self); - if (self->prop == NULL) { + if (self->prop == nullptr) { return -1; } # ifdef USE_PEDANTIC_WRITE - if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) { + if (rna_disallow_writes && rna_id_write_error(&self->ptr, nullptr)) { return -1; } # endif /* USE_PEDANTIC_WRITE */ @@ -537,13 +537,13 @@ static Mathutils_Callback mathutils_rna_array_cb = { /* bpyrna matrix callbacks */ static uchar mathutils_rna_matrix_cb_index = -1; /* Index for our callbacks. */ -static int mathutils_rna_matrix_get(BaseMathObject *bmo, int UNUSED(subtype)) +static int mathutils_rna_matrix_get(BaseMathObject *bmo, int /*subtype*/) { BPy_PropertyRNA *self = (BPy_PropertyRNA *)bmo->cb_user; PYRNA_PROP_CHECK_INT(self); - if (self->prop == NULL) { + if (self->prop == nullptr) { return -1; } @@ -551,18 +551,18 @@ static int mathutils_rna_matrix_get(BaseMathObject *bmo, int UNUSED(subtype)) return 0; } -static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype)) +static int mathutils_rna_matrix_set(BaseMathObject *bmo, int /*subtype*/) { BPy_PropertyRNA *self = (BPy_PropertyRNA *)bmo->cb_user; PYRNA_PROP_CHECK_INT(self); - if (self->prop == NULL) { + if (self->prop == nullptr) { return -1; } # ifdef USE_PEDANTIC_WRITE - if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) { + if (rna_disallow_writes && rna_id_write_error(&self->ptr, nullptr)) { return -1; } # endif /* USE_PEDANTIC_WRITE */ @@ -588,8 +588,8 @@ static Mathutils_Callback mathutils_rna_matrix_cb = { mathutils_rna_generic_check, mathutils_rna_matrix_get, mathutils_rna_matrix_set, - NULL, - NULL, + nullptr, + nullptr, }; static short pyrna_rotation_euler_order_get(PointerRNA *ptr, @@ -597,7 +597,7 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **r_prop_eul_order) { /* Attempt to get order. */ - if (*r_prop_eul_order == NULL) { + if (*r_prop_eul_order == nullptr) { *r_prop_eul_order = RNA_struct_find_property(ptr, "rotation_mode"); } @@ -629,7 +629,7 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) { - PyObject *ret = NULL; + PyObject *ret = nullptr; #ifdef USE_MATHUTILS int subtype, totdim; @@ -641,7 +641,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) /* disallow dynamic sized arrays to be wrapped since the size could change * to a size mathutils does not support */ if (flag & PROP_DYNAMIC) { - return NULL; + return nullptr; } len = RNA_property_array_length(ptr, prop); @@ -653,15 +653,15 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) goto thick_wrap_slice; } else { - return NULL; + return nullptr; } } else { - return NULL; + return nullptr; } subtype = RNA_property_subtype(prop); - totdim = RNA_property_array_dimension(ptr, prop, NULL); + totdim = RNA_property_array_dimension(ptr, prop, nullptr); if (totdim == 1 || (totdim == 2 && subtype == PROP_MATRIX)) { if (!is_thick) { @@ -673,7 +673,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_ALL_VECTOR_SUBTYPES: if (len >= 2 && len <= 4) { if (is_thick) { - ret = Vector_CreatePyObject(NULL, len, NULL); + ret = Vector_CreatePyObject(nullptr, len, nullptr); RNA_property_float_get_array(ptr, prop, ((VectorObject *)ret)->vec); } else { @@ -687,7 +687,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_MATRIX: if (len == 16) { if (is_thick) { - ret = Matrix_CreatePyObject(NULL, 4, 4, NULL); + ret = Matrix_CreatePyObject(nullptr, 4, 4, nullptr); RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->matrix); } else { @@ -699,7 +699,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) } else if (len == 9) { if (is_thick) { - ret = Matrix_CreatePyObject(NULL, 3, 3, NULL); + ret = Matrix_CreatePyObject(nullptr, 3, 3, nullptr); RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->matrix); } else { @@ -716,11 +716,11 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) if (is_thick) { /* Attempt to get order, * only needed for thick types since wrapped with update via callbacks. */ - PropertyRNA *prop_eul_order = NULL; + PropertyRNA *prop_eul_order = nullptr; const short order = pyrna_rotation_euler_order_get( ptr, EULER_ORDER_XYZ, &prop_eul_order); - ret = Euler_CreatePyObject(NULL, order, NULL); /* TODO: get order from RNA. */ + ret = Euler_CreatePyObject(nullptr, order, nullptr); /* TODO: get order from RNA. */ RNA_property_float_get_array(ptr, prop, ((EulerObject *)ret)->eul); } else { @@ -734,7 +734,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) } else if (len == 4) { if (is_thick) { - ret = Quaternion_CreatePyObject(NULL, NULL); + ret = Quaternion_CreatePyObject(nullptr, nullptr); RNA_property_float_get_array(ptr, prop, ((QuaternionObject *)ret)->quat); } else { @@ -749,7 +749,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_COLOR_GAMMA: if (len == 3) { /* Color. */ if (is_thick) { - ret = Color_CreatePyObject(NULL, NULL); + ret = Color_CreatePyObject(nullptr, nullptr); RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col); } else { @@ -765,12 +765,12 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) } } - if (ret == NULL) { + if (ret == nullptr) { if (is_thick) { - /* This is an array we can't reference (since it is not thin wrappable) - * and cannot be coerced into a mathutils type, so return as a list. */ + /* This is an array we can't reference (since it is not thin wrappable) + * and cannot be coerced into a mathutils type, so return as a list. */ thick_wrap_slice: - ret = pyrna_prop_array_subscript_slice(NULL, ptr, prop, 0, len, len); + ret = pyrna_prop_array_subscript_slice(nullptr, ptr, prop, 0, len, len); } else { ret = pyrna_prop_CreatePyObject(ptr, prop); /* Owned by the mathutils PyObject. */ @@ -831,7 +831,7 @@ static PyObject *pyrna_struct_richcmp(PyObject *a, PyObject *b, int op) break; default: PyErr_BadArgument(); - return NULL; + return nullptr; } return Py_INCREF_RET(res); @@ -862,7 +862,7 @@ static PyObject *pyrna_prop_richcmp(PyObject *a, PyObject *b, int op) break; default: PyErr_BadArgument(); - return NULL; + return nullptr; } return Py_INCREF_RET(res); @@ -888,7 +888,7 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self) * * Always include the pointer address since it can help identify unique data, * or when data is re-allocated internally. */ - name = RNA_struct_name_get_alloc(&self->ptr, NULL, 0, NULL); + name = RNA_struct_name_get_alloc(&self->ptr, nullptr, 0, nullptr); if (name) { ret = PyUnicode_FromFormat("", RNA_struct_identifier(self->ptr.type), @@ -911,7 +911,7 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self) PyObject *tmp_str; PyObject *ret; - if (id == NULL || !PYRNA_STRUCT_IS_VALID(self) || (DEG_get_original_id(id) != id)) { + if (id == nullptr || !PYRNA_STRUCT_IS_VALID(self) || (DEG_get_original_id(id) != id)) { /* fallback */ return pyrna_struct_str(self); } @@ -924,15 +924,15 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self) } else { const char *path; - ID *real_id = NULL; + ID *real_id = nullptr; path = RNA_path_from_real_ID_to_struct(G_MAIN, &self->ptr, &real_id); - if (path != NULL) { - /* 'real_id' may be NULL in some cases, although the only valid one is evaluated data, + if (path != nullptr) { + /* 'real_id' may be nullptr in some cases, although the only valid one is evaluated data, * which should have already been caught above. * So assert, but handle it without crashing for release builds. */ - BLI_assert(real_id != NULL); + BLI_assert(real_id != nullptr); - if (real_id != NULL) { + if (real_id != nullptr) { Py_DECREF(tmp_str); tmp_str = PyUnicode_FromString(real_id->name + 2); ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s", @@ -968,7 +968,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self) PyObject *ret; PointerRNA ptr; const char *name; - const char *type_id = NULL; + const char *type_id = nullptr; char type_lower[64]; char type_count[16]; int type; @@ -980,7 +980,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self) if (RNA_enum_id_from_value(rna_enum_property_type_items, type, &type_id) == 0) { /* Should never happen. */ PyErr_SetString(PyExc_RuntimeError, "could not use property type, internal error"); - return NULL; + return nullptr; } STRNCPY(type_lower, type_id); @@ -1004,7 +1004,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self) /* If a pointer, try to print name of pointer target too. */ if (type == PROP_POINTER) { ptr = RNA_property_pointer_get(&self->ptr, self->prop); - name = RNA_struct_name_get_alloc(&ptr, NULL, 0, NULL); + name = RNA_struct_name_get_alloc(&ptr, nullptr, 0, nullptr); if (name) { ret = PyUnicode_FromFormat("", @@ -1041,7 +1041,7 @@ static PyObject *pyrna_prop_repr_ex(BPy_PropertyRNA *self, const int index_dim, PYRNA_PROP_CHECK_OBJ(self); - if (id == NULL) { + if (id == nullptr) { /* Fallback. */ return pyrna_prop_str(self); } @@ -1050,7 +1050,7 @@ static PyObject *pyrna_prop_repr_ex(BPy_PropertyRNA *self, const int index_dim, /* Note that using G_MAIN is absolutely not ideal, but we have no access to actual Main DB from * here. */ - ID *real_id = NULL; + ID *real_id = nullptr; path = RNA_path_from_real_ID_to_property_index( G_MAIN, &self->ptr, self->prop, index_dim, index, &real_id); @@ -1108,7 +1108,7 @@ static Py_hash_t pyrna_struct_hash(BPy_StructRNA *self) static long pyrna_prop_hash(BPy_PropertyRNA *self) { long x, y; - if (self->ptr.data == NULL) { + if (self->ptr.data == nullptr) { x = 0; } else { @@ -1148,12 +1148,12 @@ static void pyrna_struct_dealloc(BPy_StructRNA *self) #ifdef PYRNA_FREE_SUPPORT if (self->freeptr && self->ptr.data) { IDP_FreeProperty(self->ptr.data); - self->ptr.data = NULL; + self->ptr.data = nullptr; } #endif /* PYRNA_FREE_SUPPORT */ #ifdef USE_WEAKREFS - if (self->in_weakreflist != NULL) { + if (self->in_weakreflist != nullptr) { PyObject_ClearWeakRefs((PyObject *)self); } #endif @@ -1176,7 +1176,7 @@ static void pyrna_struct_reference_set(BPy_StructRNA *self, PyObject *reference) PyObject_GC_UnTrack(self); Py_CLEAR(self->reference); } - /* Reference is now NULL. */ + /* Reference is now nullptr. */ if (reference) { self->reference = reference; @@ -1191,7 +1191,7 @@ static void pyrna_struct_reference_set(BPy_StructRNA *self, PyObject *reference) static void pyrna_prop_dealloc(BPy_PropertyRNA *self) { #ifdef USE_WEAKREFS - if (self->in_weakreflist != NULL) { + if (self->in_weakreflist != nullptr) { PyObject_ClearWeakRefs((PyObject *)self); } #endif @@ -1202,7 +1202,7 @@ static void pyrna_prop_dealloc(BPy_PropertyRNA *self) static void pyrna_prop_array_dealloc(BPy_PropertyRNA *self) { #ifdef USE_WEAKREFS - if (self->in_weakreflist != NULL) { + if (self->in_weakreflist != nullptr) { PyObject_ClearWeakRefs((PyObject *)self); } #endif @@ -1216,7 +1216,7 @@ static const char *pyrna_enum_as_string(PointerRNA *ptr, PropertyRNA *prop) const char *result; bool free = false; - RNA_property_enum_items(BPY_context_get(), ptr, prop, &item, NULL, &free); + RNA_property_enum_items(BPY_context_get(), ptr, prop, &item, nullptr, &free); if (item) { result = pyrna_enum_repr(item); } @@ -1236,7 +1236,7 @@ static int pyrna_string_to_enum( { const char *param = PyUnicode_AsUTF8(item); - if (param == NULL) { + if (param == nullptr) { PyErr_Format(PyExc_TypeError, "%.200s expected a string enum, not %.200s", error_prefix, @@ -1277,7 +1277,7 @@ static int pyrna_prop_to_enum_bitfield( return -1; } - RNA_property_enum_items(BPY_context_get(), ptr, prop, &item, NULL, &free); + RNA_property_enum_items(BPY_context_get(), ptr, prop, &item, nullptr, &free); if (item) { ret = pyrna_enum_bitfield_from_set(item, value, r_value, error_prefix); @@ -1304,12 +1304,12 @@ static int pyrna_prop_to_enum_bitfield( static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val) { - PyObject *item, *ret = NULL; + PyObject *item, *ret = nullptr; if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { const char *identifier[RNA_ENUM_BITFLAG_SIZE + 1]; - ret = PySet_New(NULL); + ret = PySet_New(nullptr); if (RNA_property_enum_bitflag_identifiers(BPY_context_get(), ptr, prop, val, identifier)) { int index; @@ -1330,13 +1330,13 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val) /* Static, no need to free. */ const EnumPropertyItem *enum_item; bool free_dummy; - RNA_property_enum_items_ex(NULL, ptr, prop, true, &enum_item, NULL, &free_dummy); + RNA_property_enum_items_ex(nullptr, ptr, prop, true, &enum_item, nullptr, &free_dummy); BLI_assert(!free_dummy); /* Do not print warning in case of DummyRNA_NULL_items, * this one will never match any value... */ if (enum_item != DummyRNA_NULL_items) { - const char *ptr_name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); + const char *ptr_name = RNA_struct_name_get_alloc(ptr, nullptr, 0, nullptr); /* Prefer not to fail silently in case of API errors, maybe disable it later. */ CLOG_WARN(BPY_LOG_RNA, @@ -1369,7 +1369,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val) ret = PyUnicode_FromString(""); #if 0 PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val); - ret = NULL; + ret = nullptr; #endif } } @@ -1451,7 +1451,7 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) PyErr_Format(PyExc_TypeError, "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)", type); - ret = NULL; + ret = nullptr; break; } @@ -1465,7 +1465,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, { int error_val = 0; int totkw; - const char *arg_name = NULL; + const char *arg_name = nullptr; PyObject *item; totkw = kw ? PyDict_Size(kw) : 0; @@ -1477,7 +1477,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, continue; } - if (kw == NULL) { + if (kw == nullptr) { PyErr_Format(PyExc_TypeError, "%.200s: no keywords, expected \"%.200s\"", error_prefix, @@ -1488,7 +1488,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, item = PyDict_GetItemString(kw, arg_name); /* Won't set an error. */ - if (item == NULL) { + if (item == nullptr) { if (all_args) { PyErr_Format(PyExc_TypeError, "%.200s: keyword \"%.200s\" missing", @@ -1499,7 +1499,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, } } else { - if (pyrna_py_to_prop(ptr, prop, NULL, item, error_prefix)) { + if (pyrna_py_to_prop(ptr, prop, nullptr, item, error_prefix)) { error_val = -1; break; } @@ -1514,10 +1514,10 @@ int pyrna_pydict_to_props(PointerRNA *ptr, while (PyDict_Next(kw, &pos, &key, &value)) { arg_name = PyUnicode_AsUTF8(key); - if (RNA_struct_find_property(ptr, arg_name) == NULL) { + if (RNA_struct_find_property(ptr, arg_name) == nullptr) { break; } - arg_name = NULL; + arg_name = nullptr; } PyErr_Format(PyExc_TypeError, @@ -1546,7 +1546,7 @@ static int pyrna_py_to_prop( if (RNA_property_array_check(prop)) { /* Done getting the length. */ - if (pyrna_py_to_array(ptr, prop, data, value, error_prefix) == -1) { + if (pyrna_py_to_array(ptr, prop, static_cast(data), value, error_prefix) == -1) { return -1; } } @@ -1656,11 +1656,11 @@ static int pyrna_py_to_prop( *(char *)data = 0; } else { - *((char **)data) = (char *)NULL; + *((char **)data) = (char *)nullptr; } } else { - RNA_property_string_set(ptr, prop, NULL); + RNA_property_string_set(ptr, prop, nullptr); } } else { @@ -1678,7 +1678,7 @@ static int pyrna_py_to_prop( param = PyBytes_AsString(value); - if (param == NULL) { + if (param == nullptr) { if (PyBytes_Check(value)) { /* there was an error assigning a string type, * rather than setting a new error, prefix the existing one @@ -1714,9 +1714,9 @@ static int pyrna_py_to_prop( } } else { - /* Unicode String. */ +/* Unicode String. */ #ifdef USE_STRING_COERCE - PyObject *value_coerce = NULL; + PyObject *value_coerce = nullptr; if (ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) { /* TODO: get size. */ param = PyC_UnicodeAsBytes(value, &value_coerce); @@ -1728,7 +1728,7 @@ static int pyrna_py_to_prop( param = PyUnicode_AsUTF8(value); #endif /* USE_STRING_COERCE */ - if (param == NULL) { + if (param == nullptr) { if (PyUnicode_Check(value)) { /* there was an error assigning a string type, * rather than setting a new error, prefix the existing one @@ -1799,7 +1799,7 @@ static int pyrna_py_to_prop( break; } case PROP_POINTER: { - PyObject *value_new = NULL; + PyObject *value_new = nullptr; StructRNA *ptr_type = RNA_property_pointer_type(ptr, prop); const int flag = RNA_property_flag(prop); @@ -1820,7 +1820,7 @@ static int pyrna_py_to_prop( */ if ((ptr_type == &RNA_AnyType) && BPy_StructRNA_Check(value)) { const StructRNA *base_type = RNA_struct_base_child_of( - ((const BPy_StructRNA *)value)->ptr.type, NULL); + ((const BPy_StructRNA *)value)->ptr.type, nullptr); if (ELEM(base_type, &RNA_Operator, &RNA_Gizmo)) { value = PyObject_GetAttr(value, bpy_intern_str_properties); value_new = value; @@ -1830,7 +1830,7 @@ static int pyrna_py_to_prop( /* if property is an OperatorProperties/GizmoProperties pointer and value is a map, * forward back to pyrna_pydict_to_props */ if (PyDict_Check(value)) { - const StructRNA *base_type = RNA_struct_base_child_of(ptr_type, NULL); + const StructRNA *base_type = RNA_struct_base_child_of(ptr_type, nullptr); if (base_type == &RNA_OperatorProperties) { PointerRNA opptr = RNA_property_pointer_get(ptr, prop); return pyrna_pydict_to_props(&opptr, value, false, error_prefix); @@ -1873,7 +1873,7 @@ static int pyrna_py_to_prop( Py_XDECREF(value_new); return -1; } - param = NULL; + param = nullptr; } else { if (!BPy_StructRNA_Check(value)) { @@ -1890,7 +1890,7 @@ static int pyrna_py_to_prop( param = (BPy_StructRNA *)value; const ID *value_owner_id = ((BPy_StructRNA *)value)->ptr.owner_id; - if (value_owner_id != NULL) { + if (value_owner_id != nullptr) { if ((flag & PROP_ID_SELF_CHECK) && (ptr->owner_id == value_owner_id)) { PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s ID type does not support assignment to itself", @@ -1921,7 +1921,7 @@ static int pyrna_py_to_prop( if (flag_parameter & PARM_RNAPTR) { if (flag & PROP_THICK_WRAP) { - if (param == NULL) { + if (param == nullptr) { memset(data, 0, sizeof(PointerRNA)); } else if (RNA_struct_is_a(param->ptr.type, ptr_type)) { @@ -1935,9 +1935,9 @@ static int pyrna_py_to_prop( /* 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 (param == NULL) { - *((void **)data) = NULL; + BLI_assert(value_new == nullptr); + if (param == nullptr) { + *((void **)data) = nullptr; } else if (RNA_struct_is_a(param->ptr.type, ptr_type)) { *((PointerRNA **)data) = ¶m->ptr; @@ -1947,8 +1947,8 @@ static int pyrna_py_to_prop( } } } - else if (param == NULL) { - *((void **)data) = NULL; + else if (param == nullptr) { + *((void **)data) = nullptr; } else if (RNA_struct_is_a(param->ptr.type, ptr_type)) { *((void **)data) = param->ptr.data; @@ -1958,12 +1958,12 @@ static int pyrna_py_to_prop( } } else { - /* Data == NULL, assign to RNA. */ - if ((param == NULL) || RNA_struct_is_a(param->ptr.type, ptr_type)) { + /* Data == nullptr, assign to RNA. */ + if ((param == nullptr) || RNA_struct_is_a(param->ptr.type, ptr_type)) { ReportList reports; BKE_reports_init(&reports, RPT_STORE); RNA_property_pointer_set( - ptr, prop, (param == NULL) ? PointerRNA_NULL : param->ptr, &reports); + ptr, prop, (param == nullptr) ? PointerRNA_NULL : param->ptr, &reports); const int err = BPy_reports_to_error(&reports, PyExc_RuntimeError, true); if (err == -1) { Py_XDECREF(value_new); @@ -1981,7 +1981,7 @@ static int pyrna_py_to_prop( } else { PointerRNA tmp; - RNA_pointer_create(NULL, ptr_type, NULL, &tmp); + RNA_pointer_create(nullptr, ptr_type, nullptr, &tmp); PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type, not %.200s", error_prefix, @@ -2005,7 +2005,7 @@ static int pyrna_py_to_prop( ListBase *lb; CollectionPointerLink *link; - lb = (data) ? (ListBase *)data : NULL; + lb = (data) ? (ListBase *)data : nullptr; /* Convert a sequence of dict's into a collection. */ if (!PySequence_Check(value)) { @@ -2023,7 +2023,7 @@ static int pyrna_py_to_prop( for (i = 0; i < seq_len; i++) { item = PySequence_GetItem(value, i); - if (item == NULL) { + if (item == nullptr) { PyErr_Format( PyExc_TypeError, "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection", @@ -2048,7 +2048,8 @@ static int pyrna_py_to_prop( } if (lb) { - link = MEM_callocN(sizeof(CollectionPointerLink), "PyCollectionPointerLink"); + link = static_cast( + MEM_callocN(sizeof(CollectionPointerLink), "PyCollectionPointerLink")); link->ptr = itemptr; BLI_addtail(lb, link); } @@ -2110,7 +2111,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P PointerRNA *ptr = &self->ptr; PropertyRNA *prop = self->prop; - const int totdim = RNA_property_array_dimension(ptr, prop, NULL); + const int totdim = RNA_property_array_dimension(ptr, prop, nullptr); if (totdim > 1) { // char error_str[512]; @@ -2180,7 +2181,7 @@ static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self) { PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self); - if (RNA_property_array_dimension(&self->ptr, self->prop, NULL) > 1) { + if (RNA_property_array_dimension(&self->ptr, self->prop, nullptr) > 1) { return RNA_property_multi_array_length(&self->ptr, self->prop, self->arraydim); } @@ -2224,14 +2225,14 @@ static int pyrna_prop_collection_bool(BPy_PropertyRNA *self) (void)0 /** - * \param result: The result of calling a subscription operation on a collection (never NULL). + * \param result: The result of calling a subscription operation on a collection (never nullptr). */ static int pyrna_prop_collection_subscript_is_valid_or_error(const PyObject *value) { if (value != Py_None) { BLI_assert(BPy_StructRNA_Check(value)); const BPy_StructRNA *value_pyrna = (const BPy_StructRNA *)value; - if (UNLIKELY(value_pyrna->ptr.type == NULL)) { + if (UNLIKELY(value_pyrna->ptr.type == nullptr)) { /* It's important to use a `TypeError` as that is what's returned when `__getitem__` is * called on an object that doesn't support item access. */ PyErr_Format(PyExc_TypeError, @@ -2272,7 +2273,7 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s PYRNA_PROP_CHECK_OBJ(self); - PYRNA_PROP_COLLECTION_ABS_INDEX(NULL); + PYRNA_PROP_COLLECTION_ABS_INDEX(nullptr); if (RNA_property_collection_lookup_int_has_fn(self->prop)) { if (RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum_abs, &newptr)) { @@ -2282,7 +2283,7 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s else { /* No callback defined, just iterate and find the nth item. */ const int key = (int)keynum_abs; - PyObject *result = NULL; + PyObject *result = nullptr; bool found = false; CollectionPropertyIterator iter; RNA_property_collection_begin(&self->ptr, self->prop, &iter); @@ -2299,7 +2300,7 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s if (found) { if (result && (pyrna_prop_collection_subscript_is_valid_or_error(result) == -1)) { Py_DECREF(result); - result = NULL; /* The exception has been set. */ + result = nullptr; /* The exception has been set. */ } return result; } @@ -2321,7 +2322,7 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s len); } - return NULL; + return nullptr; } /* Values type must have been already checked. */ @@ -2374,7 +2375,7 @@ static PyObject *pyrna_prop_array_subscript_int(BPy_PropertyArrayRNA *self, Py_s } PyErr_Format(PyExc_IndexError, "bpy_prop_array[index]: index %d out of range", keynum); - return NULL; + return nullptr; } static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, const char *keyname) @@ -2393,7 +2394,7 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons const int key_len = strlen(keyname); char name[256]; int name_len; - PyObject *result = NULL; + PyObject *result = nullptr; bool found = false; CollectionPropertyIterator iter; RNA_property_collection_begin(&self->ptr, self->prop, &iter); @@ -2402,7 +2403,7 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons /* The #RNA_property_collection_lookup_string_has_nameprop check should account for this. * Although it's technically possible a sub-type clears the name property, * this seems unlikely. */ - BLI_assert(nameprop != NULL); + BLI_assert(nameprop != nullptr); char *name_ptr = RNA_property_string_get_alloc( &iter.ptr, nameprop, name, sizeof(name), &name_len); if ((key_len == name_len) && STREQ(name_ptr, keyname)) { @@ -2422,18 +2423,18 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons if (found) { if (result && (pyrna_prop_collection_subscript_is_valid_or_error(result) == -1)) { Py_DECREF(result); - result = NULL; /* The exception has been set. */ + result = nullptr; /* The exception has been set. */ } return result; } } else { pyrna_prop_collection_string_subscript_unsupported_error(self, "bpy_prop_collection[key]"); - return NULL; + return nullptr; } PyErr_Format(PyExc_KeyError, "bpy_prop_collection[key]: key \"%.200s\" not found", keyname); - return NULL; + return nullptr; } // static PyObject *pyrna_prop_array_subscript_str(BPy_PropertyRNA *self, char *keyname) @@ -2471,7 +2472,7 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel RNA_struct_identifier(self->ptr.type)); return -1; } - if ((keyname = PyUnicode_AsUTF8(PyTuple_GET_ITEM(key, 0))) == NULL) { + if ((keyname = PyUnicode_AsUTF8(PyTuple_GET_ITEM(key, 0))) == nullptr) { PyErr_Format(PyExc_KeyError, "%s: id must be a string, not %.200s", err_prefix, @@ -2484,13 +2485,14 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel bool found = false; if (keylib == Py_None) { - lib = NULL; + lib = nullptr; } else if (PyUnicode_Check(keylib)) { - Main *bmain = self->ptr.data; + Main *bmain = static_cast
(self->ptr.data); const char *keylib_str = PyUnicode_AsUTF8(keylib); - lib = BLI_findstring(&bmain->libraries, keylib_str, offsetof(Library, filepath)); - if (lib == NULL) { + lib = static_cast( + BLI_findstring(&bmain->libraries, keylib_str, offsetof(Library, filepath))); + if (lib == nullptr) { if (err_not_found) { PyErr_Format(PyExc_KeyError, "%s: lib filepath '%.1024s' " @@ -2511,11 +2513,11 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel return -1; } - /* lib is either a valid pointer or NULL, + /* lib is either a valid pointer or nullptr, * either way can do direct comparison with id.lib */ RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) { - ID *id = itemptr.data; /* Always an ID. */ + ID *id = static_cast(itemptr.data); /* Always an ID. */ if (id->lib == lib && STREQLEN(keyname, id->name + 2, sizeof(id->name) - 2)) { found = true; if (r_ptr) { @@ -2549,7 +2551,7 @@ static PyObject *pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *s return pyrna_struct_CreatePyObject(&ptr); } - return NULL; + return nullptr; } static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self, @@ -2606,7 +2608,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, tuple = PyTuple_New(stop - start); - totdim = RNA_property_array_dimension(ptr, prop, NULL); + totdim = RNA_property_array_dimension(ptr, prop, nullptr); if (totdim > 1) { for (count = start; count < stop; count++) { @@ -2619,7 +2621,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, float values_stack[PYRNA_STACK_ARRAY]; float *values; if (length > PYRNA_STACK_ARRAY) { - values = PyMem_MALLOC(sizeof(float) * length); + values = static_cast(PyMem_MALLOC(sizeof(float) * length)); } else { values = values_stack; @@ -2639,7 +2641,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, bool values_stack[PYRNA_STACK_ARRAY]; bool *values; if (length > PYRNA_STACK_ARRAY) { - values = PyMem_MALLOC(sizeof(bool) * length); + values = static_cast(PyMem_MALLOC(sizeof(bool) * length)); } else { values = values_stack; @@ -2659,7 +2661,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, int values_stack[PYRNA_STACK_ARRAY]; int *values; if (length > PYRNA_STACK_ARRAY) { - values = PyMem_MALLOC(sizeof(int) * length); + values = static_cast(PyMem_MALLOC(sizeof(int) * length)); } else { values = values_stack; @@ -2680,7 +2682,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PyErr_SetString(PyExc_TypeError, "not an array type"); Py_DECREF(tuple); - tuple = NULL; + tuple = nullptr; break; } } @@ -2697,7 +2699,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject if (PyIndex_Check(key)) { const Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) { - return NULL; + return nullptr; } return pyrna_prop_collection_subscript_int(self, i); @@ -2707,11 +2709,11 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject Py_ssize_t step = 1; if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) { - return NULL; + return nullptr; } if (step != 1) { PyErr_SetString(PyExc_TypeError, "bpy_prop_collection[slice]: slice steps not supported"); - return NULL; + return nullptr; } if (key_slice->start == Py_None && key_slice->stop == Py_None) { return pyrna_prop_collection_subscript_slice(self, 0, PY_SSIZE_T_MAX); @@ -2721,10 +2723,10 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject /* 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; + return nullptr; } if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) { - return NULL; + return nullptr; } if (start < 0 || stop < 0) { @@ -2756,7 +2758,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject "bpy_prop_collection[key]: invalid key, " "must be a string or an int, not %.200s", Py_TYPE(key)->tp_name); - return NULL; + return nullptr; } /* generic check to see if a PyObject is compatible with a collection @@ -2811,7 +2813,7 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self, PYRNA_PROP_CHECK_INT(self); /* Validate the assigned value. */ - if (value == NULL) { + if (value == nullptr) { PyErr_SetString(PyExc_TypeError, "del bpy_prop_collection[key]: not supported"); return -1; } @@ -2839,11 +2841,11 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self, Py_ssize_t step = 1; if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) { - return NULL; + return nullptr; } else if (step != 1) { PyErr_SetString(PyExc_TypeError, "bpy_prop_collection[slice]: slice steps not supported"); - return NULL; + return nullptr; } else if (key_slice->start == Py_None && key_slice->stop == Py_None) { return pyrna_prop_collection_subscript_slice(self, 0, PY_SSIZE_T_MAX); @@ -2853,10 +2855,10 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self, /* 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; + return nullptr; } if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) { - return NULL; + return nullptr; } if (start < 0 || stop < 0) { @@ -2902,7 +2904,7 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject if (PyIndex_Check(key)) { const Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) { - return NULL; + return nullptr; } return pyrna_prop_array_subscript_int(self, i); } @@ -2911,11 +2913,11 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject PySliceObject *key_slice = (PySliceObject *)key; if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) { - return NULL; + return nullptr; } if (step != 1) { PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice]: slice steps not supported"); - return NULL; + return nullptr; } if (key_slice->start == Py_None && key_slice->stop == Py_None) { /* NOTE: no significant advantage with optimizing [:] slice as with collections, @@ -2928,7 +2930,7 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject Py_ssize_t start, stop, slicelength; if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0) { - return NULL; + return nullptr; } if (slicelength <= 0) { @@ -2939,7 +2941,7 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject } PyErr_SetString(PyExc_AttributeError, "bpy_prop_array[key]: invalid key, key must be an int"); - return NULL; + return nullptr; } /** @@ -2953,7 +2955,7 @@ static PyObject *prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, in "bpy_prop_array[slice] = value: " "element in assignment is not a sequence type"))) { - return NULL; + return nullptr; } if (PySequence_Fast_GET_SIZE(value_fast) != length) { Py_DECREF(value_fast); @@ -2961,7 +2963,7 @@ static PyObject *prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, in "bpy_prop_array[slice] = value: " "re-sizing bpy_struct element in arrays isn't supported"); - return NULL; + return nullptr; } return value_fast; @@ -2976,7 +2978,7 @@ static int prop_subscript_ass_array_slice__float_recursive( int i; for (i = 0; i != length; i++) { PyObject *subvalue = prop_subscript_ass_array_slice__as_seq_fast(value_items[i], dimsize[1]); - if (UNLIKELY(subvalue == NULL)) { + if (UNLIKELY(subvalue == nullptr)) { return 0; } @@ -3008,7 +3010,7 @@ static int prop_subscript_ass_array_slice__int_recursive( int i; for (i = 0; i != length; i++) { PyObject *subvalue = prop_subscript_ass_array_slice__as_seq_fast(value_items[i], dimsize[1]); - if (UNLIKELY(subvalue == NULL)) { + if (UNLIKELY(subvalue == nullptr)) { return 0; } @@ -3042,7 +3044,7 @@ static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items int i; for (i = 0; i != length; i++) { PyObject *subvalue = prop_subscript_ass_array_slice__as_seq_fast(value_items[i], dimsize[1]); - if (UNLIKELY(subvalue == NULL)) { + if (UNLIKELY(subvalue == nullptr)) { return 0; } @@ -3075,10 +3077,10 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, { const int length_flat = RNA_property_array_length(ptr, prop); PyObject *value; - void *values_alloc = NULL; + void *values_alloc = nullptr; int ret = 0; - if (value_orig == NULL) { + if (value_orig == nullptr) { PyErr_SetString( PyExc_TypeError, "bpy_prop_array[slice] = value: deleting with list types is not supported by bpy_struct"); @@ -3115,9 +3117,10 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, switch (RNA_property_type(prop)) { case PROP_FLOAT: { float values_stack[PYRNA_STACK_ARRAY]; - float *values = (length_flat > PYRNA_STACK_ARRAY) ? - (values_alloc = PyMem_MALLOC(sizeof(*values) * length_flat)) : - values_stack; + float *values = static_cast( + (length_flat > PYRNA_STACK_ARRAY) ? + (values_alloc = PyMem_MALLOC(sizeof(*values) * length_flat)) : + values_stack); if (start != 0 || stop != length) { /* Partial assignment? - need to get the array. */ RNA_property_float_get_array(ptr, prop, values); @@ -3143,9 +3146,10 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, } case PROP_INT: { int values_stack[PYRNA_STACK_ARRAY]; - int *values = (length_flat > PYRNA_STACK_ARRAY) ? - (values_alloc = PyMem_MALLOC(sizeof(*values) * length_flat)) : - values_stack; + int *values = static_cast( + (length_flat > PYRNA_STACK_ARRAY) ? + (values_alloc = PyMem_MALLOC(sizeof(*values) * length_flat)) : + values_stack); if (start != 0 || stop != length) { /* Partial assignment? - need to get the array. */ RNA_property_int_get_array(ptr, prop, values); @@ -3171,9 +3175,10 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, } case PROP_BOOLEAN: { bool values_stack[PYRNA_STACK_ARRAY]; - bool *values = (length_flat > PYRNA_STACK_ARRAY) ? - (values_alloc = PyMem_MALLOC(sizeof(bool) * length_flat)) : - values_stack; + bool *values = static_cast( + (length_flat > PYRNA_STACK_ARRAY) ? + (values_alloc = PyMem_MALLOC(sizeof(bool) * length_flat)) : + values_stack); if (start != 0 || stop != length) { /* Partial assignment? - need to get the array. */ @@ -3233,7 +3238,7 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self, PyObject *key, PyObject *value) { - // char *keyname = NULL; /* Not supported yet. */ + // char *keyname = nullptr; /* Not supported yet. */ int ret = -1; PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self); @@ -3303,54 +3308,54 @@ static PyMappingMethods pyrna_prop_collection_as_mapping = { /* Only for fast bool's, large structs, assign nb_bool on init. */ static PyNumberMethods pyrna_prop_array_as_number = { - /*nb_add*/ NULL, - /*nb_subtract*/ NULL, - /*nb_multiply*/ NULL, - /*nb_remainder*/ NULL, - /*nb_divmod*/ NULL, - /*nb_power*/ NULL, - /*nb_negative*/ NULL, - /*nb_positive*/ NULL, - /*nb_absolute*/ NULL, + /*nb_add*/ nullptr, + /*nb_subtract*/ nullptr, + /*nb_multiply*/ nullptr, + /*nb_remainder*/ nullptr, + /*nb_divmod*/ nullptr, + /*nb_power*/ nullptr, + /*nb_negative*/ nullptr, + /*nb_positive*/ nullptr, + /*nb_absolute*/ nullptr, /*nb_bool*/ (inquiry)pyrna_prop_array_bool, }; static PyNumberMethods pyrna_prop_collection_as_number = { - /*nb_add*/ NULL, - /*nb_subtract*/ NULL, - /*nb_multiply*/ NULL, - /*nb_remainder*/ NULL, - /*nb_divmod*/ NULL, - /*nb_power*/ NULL, - /*nb_negative*/ NULL, - /*nb_positive*/ NULL, - /*nb_absolute*/ NULL, + /*nb_add*/ nullptr, + /*nb_subtract*/ nullptr, + /*nb_multiply*/ nullptr, + /*nb_remainder*/ nullptr, + /*nb_divmod*/ nullptr, + /*nb_power*/ nullptr, + /*nb_negative*/ nullptr, + /*nb_positive*/ nullptr, + /*nb_absolute*/ nullptr, /*nb_bool*/ (inquiry)pyrna_prop_collection_bool, - /*nb_invert*/ NULL, - /*nb_lshift*/ NULL, - /*nb_rshift*/ NULL, - /*nb_and*/ NULL, - /*nb_xor*/ NULL, - /*nb_or*/ NULL, - /*nb_int*/ NULL, - /*nb_reserved*/ NULL, - /*nb_float*/ NULL, - /*nb_inplace_add*/ NULL, - /*nb_inplace_subtract*/ NULL, - /*nb_inplace_multiply*/ NULL, - /*nb_inplace_remainder*/ NULL, - /*nb_inplace_power*/ NULL, - /*nb_inplace_lshift*/ NULL, - /*nb_inplace_rshift*/ NULL, - /*nb_inplace_and*/ NULL, - /*nb_inplace_xor*/ NULL, - /*nb_inplace_or*/ NULL, - /*nb_floor_divide*/ NULL, - /*nb_true_divide*/ NULL, - /*nb_inplace_floor_divide*/ NULL, - /*nb_inplace_true_divide*/ NULL, - /*nb_index*/ NULL, - /*nb_matrix_multiply*/ NULL, - /*nb_inplace_matrix_multiply*/ NULL, + /*nb_invert*/ nullptr, + /*nb_lshift*/ nullptr, + /*nb_rshift*/ nullptr, + /*nb_and*/ nullptr, + /*nb_xor*/ nullptr, + /*nb_or*/ nullptr, + /*nb_int*/ nullptr, + /*nb_reserved*/ nullptr, + /*nb_float*/ nullptr, + /*nb_inplace_add*/ nullptr, + /*nb_inplace_subtract*/ nullptr, + /*nb_inplace_multiply*/ nullptr, + /*nb_inplace_remainder*/ nullptr, + /*nb_inplace_power*/ nullptr, + /*nb_inplace_lshift*/ nullptr, + /*nb_inplace_rshift*/ nullptr, + /*nb_inplace_and*/ nullptr, + /*nb_inplace_xor*/ nullptr, + /*nb_inplace_or*/ nullptr, + /*nb_floor_divide*/ nullptr, + /*nb_true_divide*/ nullptr, + /*nb_inplace_floor_divide*/ nullptr, + /*nb_inplace_true_divide*/ nullptr, + /*nb_index*/ nullptr, + /*nb_matrix_multiply*/ nullptr, + /*nb_inplace_matrix_multiply*/ nullptr, }; static int pyrna_prop_array_contains(BPy_PropertyRNA *self, PyObject *value) @@ -3365,13 +3370,13 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key) if (PyTuple_Check(key)) { /* Special case, for ID data-blocks. */ return pyrna_prop_collection_subscript_str_lib_pair_ptr( - self, key, "(id, lib) in bpy_prop_collection", false, NULL); + self, key, "(id, lib) in bpy_prop_collection", false, nullptr); } /* Key in dict style check. */ const char *keyname = PyUnicode_AsUTF8(key); - if (keyname == NULL) { + if (keyname == nullptr) { PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.__contains__: expected a string or a tuple of strings"); return -1; @@ -3416,45 +3421,45 @@ static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value) static PySequenceMethods pyrna_prop_array_as_sequence = { /*sq_length*/ (lenfunc)pyrna_prop_array_length, - /*sq_concat*/ NULL, - /*sq_repeat*/ NULL, + /*sq_concat*/ nullptr, + /*sq_repeat*/ nullptr, /* Only set this so `PySequence_Check()` returns True. */ /*sq_item*/ (ssizeargfunc)pyrna_prop_array_subscript_int, - /*sq_slice*/ NULL, + /*sq_slice*/ nullptr, /*sq_ass_item*/ (ssizeobjargproc)prop_subscript_ass_array_int, - /*was_sq_ass_slice*/ NULL, /* DEPRECATED. */ + /*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */ /*sq_contains*/ (objobjproc)pyrna_prop_array_contains, - /*sq_inplace_concat*/ NULL, - /*sq_inplace_repeat*/ NULL, + /*sq_inplace_concat*/ nullptr, + /*sq_inplace_repeat*/ nullptr, }; static PySequenceMethods pyrna_prop_collection_as_sequence = { /*sq_length*/ (lenfunc)pyrna_prop_collection_length, - /*sq_concat*/ NULL, - /*sq_repeat*/ NULL, + /*sq_concat*/ nullptr, + /*sq_repeat*/ nullptr, /* Only set this so PySequence_Check() returns True */ /*sq_item*/ (ssizeargfunc)pyrna_prop_collection_subscript_int, - /*was_sq_slice*/ NULL, /* DEPRECATED. */ + /*was_sq_slice*/ nullptr, /* DEPRECATED. */ /* Let mapping take this one: #pyrna_prop_collection_ass_subscript_int */ - /*sq_ass_item*/ NULL, - /*was_sq_ass_slice*/ NULL, /* DEPRECATED. */ + /*sq_ass_item*/ nullptr, + /*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */ /*sq_contains*/ (objobjproc)pyrna_prop_collection_contains, - /*sq_inplace_concat*/ NULL, - /*sq_inplace_repeat*/ NULL, + /*sq_inplace_concat*/ nullptr, + /*sq_inplace_repeat*/ nullptr, }; static PySequenceMethods pyrna_struct_as_sequence = { - /*sq_length*/ NULL, /* Can't set the len otherwise it can evaluate as false */ - /*sq_concat*/ NULL, - /*sq_repeat*/ NULL, + /*sq_length*/ nullptr, /* Can't set the len otherwise it can evaluate as false */ + /*sq_concat*/ nullptr, + /*sq_repeat*/ nullptr, /* Only set this so `PySequence_Check()` returns True. */ - /*sq_item*/ NULL, - /*was_sq_slice*/ NULL, /* DEPRECATED. */ - /*sq_ass_item */ NULL, - /*was_sq_ass_slice*/ NULL, /* DEPRECATED. */ + /*sq_item*/ nullptr, + /*was_sq_slice*/ nullptr, /* DEPRECATED. */ + /*sq_ass_item */ nullptr, + /*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */ /*sq_contains*/ (objobjproc)pyrna_struct_contains, - /*sq_inplace_concat*/ NULL, - /*sq_inplace_repeat*/ NULL, + /*sq_inplace_concat*/ nullptr, + /*sq_inplace_repeat*/ nullptr, }; static PyObject *pyrna_struct_subscript(BPy_StructRNA *self, PyObject *key) @@ -3466,27 +3471,27 @@ static PyObject *pyrna_struct_subscript(BPy_StructRNA *self, PyObject *key) if (RNA_struct_idprops_check(self->ptr.type) == 0) { PyErr_SetString(PyExc_TypeError, "this type doesn't support IDProperties"); - return NULL; + return nullptr; } - if (name == NULL) { + if (name == nullptr) { PyErr_SetString(PyExc_TypeError, "bpy_struct[key]: only strings are allowed as keys of ID properties"); - return NULL; + return nullptr; } IDProperty *group = RNA_struct_idprops(&self->ptr, 0); - if (group == NULL) { + if (group == nullptr) { PyErr_Format(PyExc_KeyError, "bpy_struct[key]: key \"%s\" not found", name); - return NULL; + return nullptr; } IDProperty *idprop = IDP_GetPropertyFromGroup(group, name); - if (idprop == NULL) { + if (idprop == nullptr) { PyErr_Format(PyExc_KeyError, "bpy_struct[key]: key \"%s\" not found", name); - return NULL; + return nullptr; } return BPy_IDGroup_WrapData(self->ptr.owner_id, idprop, group); @@ -3504,7 +3509,7 @@ static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObje } #endif /* USE_PEDANTIC_WRITE */ - if (group == NULL) { + if (group == nullptr) { PyErr_SetString(PyExc_TypeError, "bpy_struct[key] = val: id properties not supported for this type"); return -1; @@ -3528,7 +3533,7 @@ static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObje } static PyMappingMethods pyrna_struct_as_mapping = { - /*mp_length*/ (lenfunc)NULL, + /*mp_length*/ (lenfunc) nullptr, /*mp_subscript*/ (binaryfunc)pyrna_struct_subscript, /*mp_ass_subscript*/ (objobjargproc)pyrna_struct_ass_subscript, }; @@ -3548,10 +3553,10 @@ static PyObject *pyrna_struct_keys(BPy_StructRNA *self) if (RNA_struct_idprops_check(self->ptr.type) == 0) { PyErr_SetString(PyExc_TypeError, "bpy_struct.keys(): this type doesn't support IDProperties"); - return NULL; + return nullptr; } - /* `group` may be NULL. */ + /* `group` may be nullptr. */ IDProperty *group = RNA_struct_idprops(&self->ptr, 0); return BPy_Wrap_GetKeys_View_WithID(self->ptr.owner_id, group); } @@ -3571,10 +3576,10 @@ static PyObject *pyrna_struct_items(BPy_StructRNA *self) if (RNA_struct_idprops_check(self->ptr.type) == 0) { PyErr_SetString(PyExc_TypeError, "bpy_struct.items(): this type doesn't support IDProperties"); - return NULL; + return nullptr; } - /* `group` may be NULL. */ + /* `group` may be nullptr. */ IDProperty *group = RNA_struct_idprops(&self->ptr, 0); return BPy_Wrap_GetItems_View_WithID(self->ptr.owner_id, group); } @@ -3595,10 +3600,10 @@ static PyObject *pyrna_struct_values(BPy_StructRNA *self) if (RNA_struct_idprops_check(self->ptr.type) == 0) { PyErr_SetString(PyExc_TypeError, "bpy_struct.values(): this type doesn't support IDProperties"); - return NULL; + return nullptr; } - /* `group` may be NULL. */ + /* `group` may be nullptr. */ IDProperty *group = RNA_struct_idprops(&self->ptr, 0); return BPy_Wrap_GetValues_View_WithID(self->ptr.owner_id, group); } @@ -3625,7 +3630,7 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg PYRNA_STRUCT_CHECK_OBJ(self); - static const char *_keywords[] = {"", "ghost", NULL}; + static const char *_keywords[] = {"", "ghost", nullptr}; static _PyArg_Parser _parser = { "s" /* `name` (positional). */ "|$" /* Optional keyword only arguments. */ @@ -3635,15 +3640,15 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg 0, }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &name, PyC_ParseBool, &use_ghost)) { - return NULL; + return nullptr; } - if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) { + if ((prop = RNA_struct_find_property(&self->ptr, name)) == nullptr) { PyErr_Format(PyExc_TypeError, "%.200s.is_property_set(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name); - return NULL; + return nullptr; } return PyBool_FromLong(RNA_property_is_set_ex(&self->ptr, prop, use_ghost)); @@ -3661,15 +3666,15 @@ static PyObject *pyrna_struct_property_unset(BPy_StructRNA *self, PyObject *args PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "s:property_unset", &name)) { - return NULL; + return nullptr; } - if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) { + if ((prop = RNA_struct_find_property(&self->ptr, name)) == nullptr) { PyErr_Format(PyExc_TypeError, "%.200s.property_unset(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name); - return NULL; + return nullptr; } RNA_property_unset(&self->ptr, prop); @@ -3692,15 +3697,15 @@ static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject * PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "s:is_property_hidden", &name)) { - return NULL; + return nullptr; } - if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) { + if ((prop = RNA_struct_find_property(&self->ptr, name)) == nullptr) { PyErr_Format(PyExc_TypeError, "%.200s.is_property_hidden(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name); - return NULL; + return nullptr; } return PyBool_FromLong(RNA_property_flag(prop) & PROP_HIDDEN); @@ -3721,15 +3726,15 @@ static PyObject *pyrna_struct_is_property_readonly(BPy_StructRNA *self, PyObject PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "s:is_property_readonly", &name)) { - return NULL; + return nullptr; } - if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) { + if ((prop = RNA_struct_find_property(&self->ptr, name)) == nullptr) { PyErr_Format(PyExc_TypeError, "%.200s.is_property_readonly(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name); - return NULL; + return nullptr; } return PyBool_FromLong(!RNA_property_editable(&self->ptr, prop)); @@ -3750,15 +3755,15 @@ static PyObject *pyrna_struct_is_property_overridable_library(BPy_StructRNA *sel PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "s:is_property_overridable_library", &name)) { - return NULL; + return nullptr; } - if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) { + if ((prop = RNA_struct_find_property(&self->ptr, name)) == nullptr) { PyErr_Format(PyExc_TypeError, "%.200s.is_property_overridable_library(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name); - return NULL; + return nullptr; } return PyBool_FromLong((long)RNA_property_overridable_get(&self->ptr, prop)); @@ -3780,15 +3785,15 @@ static PyObject *pyrna_struct_property_overridable_library_set(BPy_StructRNA *se PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "sp:property_overridable_library_set", &name, &is_overridable)) { - return NULL; + return nullptr; } - if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) { + if ((prop = RNA_struct_find_property(&self->ptr, name)) == nullptr) { PyErr_Format(PyExc_TypeError, "%.200s.property_overridable_library_set(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name); - return NULL; + return nullptr; } return PyBool_FromLong( @@ -3816,7 +3821,7 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args) PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "s|O!:path_resolve", &path, &PyBool_Type, &coerce)) { - return NULL; + return nullptr; } if (RNA_path_resolve_full_maybe_null(&self->ptr, path, &r_ptr, &r_prop, &index)) { @@ -3827,7 +3832,7 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args) "%.200s.path_resolve(\"%.200s\") index out of range", RNA_struct_identifier(self->ptr.type), path); - return NULL; + return nullptr; } return pyrna_array_index(&r_ptr, r_prop, index); @@ -3847,7 +3852,7 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args) "%.200s.path_resolve(\"%.200s\") could not be resolved", RNA_struct_identifier(self->ptr.type), path); - return NULL; + return nullptr; } PyDoc_STRVAR(pyrna_struct_path_from_id_doc, @@ -3863,7 +3868,7 @@ PyDoc_STRVAR(pyrna_struct_path_from_id_doc, " :rtype: str\n"); static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args) { - const char *name = NULL; + const char *name = nullptr; const char *path; PropertyRNA *prop; PyObject *ret; @@ -3871,17 +3876,17 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args) PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "|s:path_from_id", &name)) { - return NULL; + return nullptr; } if (name) { prop = RNA_struct_find_property(&self->ptr, name); - if (prop == NULL) { + if (prop == nullptr) { PyErr_Format(PyExc_AttributeError, "%.200s.path_from_id(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name); - return NULL; + return nullptr; } path = RNA_path_from_ID_to_property(&self->ptr, prop); @@ -3890,7 +3895,7 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args) path = RNA_path_from_ID_to_struct(&self->ptr); } - if (path == NULL) { + if (path == nullptr) { if (name) { PyErr_Format(PyExc_ValueError, "%.200s.path_from_id(\"%s\") found, but does not support path creation", @@ -3902,7 +3907,7 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args) "%.200s.path_from_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type)); } - return NULL; + return nullptr; } ret = PyUnicode_FromString(path); @@ -3926,12 +3931,12 @@ static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self) path = RNA_path_from_ID_to_property(&self->ptr, self->prop); - if (path == NULL) { + if (path == nullptr) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s.path_from_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(prop)); - return NULL; + return nullptr; } ret = PyUnicode_FromString(path); @@ -3955,7 +3960,7 @@ static PyObject *pyrna_prop_as_bytes(BPy_PropertyRNA *self) "%.200s.%.200s.as_bytes() must be a string", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop)); - return NULL; + return nullptr; } PyObject *ret; @@ -4011,15 +4016,15 @@ static PyObject *pyrna_struct_type_recast(BPy_StructRNA *self) */ static PyObject *pyrna_struct_bl_rna_find_subclass_recursive(PyObject *cls, const char *id) { - PyObject *ret_test = NULL; + PyObject *ret_test = nullptr; PyObject *subclasses = ((PyTypeObject *)cls)->tp_subclasses; if (subclasses) { /* Unfortunately we can't use the dict key because Python class names * don't match the bl_idname used internally. */ BLI_assert(PyDict_CheckExact(subclasses)); - PyObject *key = NULL; + PyObject *key = nullptr; Py_ssize_t pos = 0; - PyObject *value = NULL; + PyObject *value = nullptr; while (PyDict_Next(subclasses, &pos, &key, &value)) { BLI_assert(PyWeakref_CheckRef(value)); PyObject *subcls = PyWeakref_GET_OBJECT(value); @@ -4027,7 +4032,7 @@ static PyObject *pyrna_struct_bl_rna_find_subclass_recursive(PyObject *cls, cons BPy_StructRNA *py_srna = (BPy_StructRNA *)PyDict_GetItem(((PyTypeObject *)subcls)->tp_dict, bpy_intern_str_bl_rna); if (py_srna) { - StructRNA *srna = py_srna->ptr.data; + StructRNA *srna = static_cast(py_srna->ptr.data); if (STREQ(id, RNA_struct_identifier(srna))) { ret_test = subcls; break; @@ -4056,10 +4061,10 @@ static PyObject *pyrna_struct_bl_rna_get_subclass_py(PyObject *cls, PyObject *ar PyObject *ret_default = Py_None; if (!PyArg_ParseTuple(args, "s|O:bl_rna_get_subclass_py", &id, &ret_default)) { - return NULL; + return nullptr; } PyObject *ret = pyrna_struct_bl_rna_find_subclass_recursive(cls, id); - if (ret == NULL) { + if (ret == nullptr) { ret = ret_default; } return Py_INCREF_RET(ret); @@ -4078,16 +4083,16 @@ static PyObject *pyrna_struct_bl_rna_get_subclass(PyObject *cls, PyObject *args) PyObject *ret_default = Py_None; if (!PyArg_ParseTuple(args, "s|O:bl_rna_get_subclass", &id, &ret_default)) { - return NULL; + return nullptr; } const BPy_StructRNA *py_srna = (BPy_StructRNA *)PyDict_GetItem(((PyTypeObject *)cls)->tp_dict, bpy_intern_str_bl_rna); - if (py_srna == NULL) { + if (py_srna == nullptr) { PyErr_SetString(PyExc_ValueError, "Not a registered class"); - return NULL; + return nullptr; } - const StructRNA *srna_base = py_srna->ptr.data; + const StructRNA *srna_base = static_cast(py_srna->ptr.data); PointerRNA ptr; if (srna_base == &RNA_Node) { @@ -4096,7 +4101,7 @@ static PyObject *pyrna_struct_bl_rna_get_subclass(PyObject *cls, PyObject *args) bNodeType *nt = nodeTypeFind(id); if (nt) { - RNA_pointer_create(NULL, &RNA_Struct, nt->rna_ext.srna, &ptr); + RNA_pointer_create(nullptr, &RNA_Struct, nt->rna_ext.srna, &ptr); return pyrna_struct_CreatePyObject(&ptr); } } @@ -4104,7 +4109,7 @@ static PyObject *pyrna_struct_bl_rna_get_subclass(PyObject *cls, PyObject *args) /* TODO: panels, menus etc. */ PyErr_Format( PyExc_ValueError, "Class type \"%.200s\" not supported", RNA_struct_identifier(srna_base)); - return NULL; + return nullptr; } return Py_INCREF_RET(ret_default); @@ -4160,13 +4165,13 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr) PropertyRNA *iterprop; { - RNA_pointer_create(NULL, &RNA_Struct, ptr->type, &tptr); + RNA_pointer_create(nullptr, &RNA_Struct, ptr->type, &tptr); iterprop = RNA_struct_find_property(&tptr, "functions"); RNA_PROP_BEGIN (&tptr, itemptr, iterprop) { - FunctionRNA *func = itemptr.data; + FunctionRNA *func = static_cast(itemptr.data); if (RNA_function_defined(func)) { - idname = RNA_function_identifier(itemptr.data); + idname = RNA_function_identifier(static_cast(itemptr.data)); PyList_APPEND(list, PyUnicode_FromString(idname)); } } @@ -4184,7 +4189,7 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr) RNA_PROP_BEGIN (ptr, itemptr, iterprop) { /* Custom-properties are exposed using `__getitem__`, exclude from `__dir__`. */ - if (RNA_property_is_idprop(itemptr.data)) { + if (RNA_property_is_idprop(static_cast(itemptr.data))) { continue; } name_ptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &name_len); @@ -4218,11 +4223,11 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self) pyrna_dir_members_rna(ret, &self->ptr); if (self->ptr.type == &RNA_Context) { - ListBase lb = CTX_data_dir_get(self->ptr.data); + ListBase lb = CTX_data_dir_get(static_cast(self->ptr.data)); LinkData *link; - for (link = lb.first; link; link = link->next) { - PyList_APPEND(ret, PyUnicode_FromString(link->data)); + for (link = static_cast(lb.first); link; link = link->next) { + PyList_APPEND(ret, PyUnicode_FromString(static_cast(link->data))); } BLI_freelistN(&lb); @@ -4252,21 +4257,21 @@ static PyObject *pyrna_struct_id_properties_ensure(BPy_StructRNA *self) if (RNA_struct_idprops_check(self->ptr.type) == 0) { PyErr_SetString(PyExc_TypeError, "This type doesn't support IDProperties"); - return NULL; + return nullptr; } IDProperty *idprops = RNA_struct_idprops(&self->ptr, true); /* This is a paranoid check that theoretically might not be necessary. * It allows the possibility that some structs can't ensure IDProperties. */ - if (idprops == NULL) { + if (idprops == nullptr) { return Py_None; } BPy_IDProperty *group = PyObject_New(BPy_IDProperty, &BPy_IDGroup_Type); group->owner_id = self->ptr.owner_id; group->prop = idprops; - group->parent = NULL; + group->parent = nullptr; return (PyObject *)group; } @@ -4282,31 +4287,31 @@ static PyObject *pyrna_struct_id_properties_ui(BPy_StructRNA *self, PyObject *ar if (RNA_struct_idprops_check(self->ptr.type) == 0) { PyErr_SetString(PyExc_TypeError, "This type doesn't support IDProperties"); - return NULL; + return nullptr; } const char *key; if (!PyArg_ParseTuple(args, "s:ui_data", &key)) { - return NULL; + return nullptr; } IDProperty *parent_group = RNA_struct_idprops(&self->ptr, true); /* This is a paranoid check that theoretically might not be necessary. * It allows the possibility that some structs can't ensure IDProperties. */ - if (parent_group == NULL) { + if (parent_group == nullptr) { return Py_None; } IDProperty *property = IDP_GetPropertyFromGroup(parent_group, key); - if (property == NULL) { + if (property == nullptr) { PyErr_SetString(PyExc_KeyError, "Property not found in IDProperty group"); - return NULL; + return nullptr; } if (!IDP_ui_data_supported(property)) { PyErr_Format(PyExc_TypeError, "IDProperty \"%s\" does not support UI data", property->name); - return NULL; + return nullptr; } BPy_IDPropertyUIManager *ui_manager = PyObject_New(BPy_IDPropertyUIManager, @@ -4324,14 +4329,14 @@ static PyObject *pyrna_struct_id_properties_clear(BPy_StructRNA *self) if (RNA_struct_idprops_check(self->ptr.type) == 0) { PyErr_SetString(PyExc_TypeError, "This type doesn't support IDProperties"); - return NULL; + return nullptr; } IDProperty **idprops = RNA_struct_idprops_p(&self->ptr); if (*idprops) { IDP_FreeProperty(*idprops); - *idprops = NULL; + *idprops = nullptr; } Py_RETURN_NONE; @@ -4347,9 +4352,9 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) PYRNA_STRUCT_CHECK_OBJ(self); - if (name == NULL) { + if (name == nullptr) { PyErr_SetString(PyExc_AttributeError, "bpy_struct: __getattr__ must be a string"); - ret = NULL; + ret = nullptr; } else if ( /* RNA can't start with a "_", so for __dict__ and similar we can skip using RNA lookups. */ @@ -4359,7 +4364,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) if (STR_ELEM(name, "__getitem__", "__setitem__") && !RNA_struct_idprops_check(self->ptr.type)) { PyErr_SetString(PyExc_AttributeError, "bpy_struct: no __getitem__ support for this type"); - ret = NULL; + ret = nullptr; } else { ret = PyObject_GenericGetAttr((PyObject *)self, pyname); @@ -4373,12 +4378,12 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) ret = pyrna_func_to_py(&self->ptr, func); } else if (self->ptr.type == &RNA_Context) { - bContext *C = self->ptr.data; - if (C == NULL) { + bContext *C = static_cast(self->ptr.data); + if (C == nullptr) { PyErr_Format(PyExc_AttributeError, - "bpy_struct: Context is 'NULL', can't get \"%.200s\" from context", + "bpy_struct: Context is 'nullptr', can't get \"%.200s\" from context", name); - ret = NULL; + ret = nullptr; } else { PointerRNA newptr; @@ -4391,7 +4396,8 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) * without this check `getattr(context, "")` succeeds. */ eContextResult done; if (name[0]) { - done = CTX_data_get(C, name, &newptr, &newlb, &newprop, &newindex, &newtype); + done = eContextResult( + CTX_data_get(C, name, &newptr, &newlb, &newprop, &newindex, &newtype)); } else { /* Fall through to built-in `getattr`. */ @@ -4402,7 +4408,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) if (done == CTX_RESULT_OK) { switch (newtype) { case CTX_DATA_TYPE_POINTER: - if (newptr.data == NULL) { + if (newptr.data == nullptr) { ret = Py_None; Py_INCREF(ret); } @@ -4415,13 +4421,14 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) ret = PyList_New(0); - for (link = newlb.first; link; link = link->next) { + for (link = static_cast(newlb.first); link; link = link->next) + { PyList_APPEND(ret, pyrna_struct_CreatePyObject(&link->ptr)); } break; } case CTX_DATA_TYPE_PROPERTY: { - if (newprop != NULL) { + if (newprop != nullptr) { /* Create pointer to parent ID, and path from ID to property. */ PointerRNA idptr; RNA_id_pointer_create(newptr.owner_id, &idptr); @@ -4449,7 +4456,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context", newtype, name); - ret = NULL; + ret = nullptr; break; } } @@ -4468,7 +4475,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) else { #if 0 PyErr_Format(PyExc_AttributeError, "bpy_struct: attribute \"%.200s\" not found", name); - ret = NULL; + ret = nullptr; #endif /* Include this in case this instance is a subtype of a Python class * In these instances we may want to return a function or variable provided by the subtype @@ -4487,7 +4494,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) static int pyrna_struct_pydict_contains(PyObject *self, PyObject *pyname) { PyObject *dict = *(_PyObject_GetDictPtr((PyObject *)self)); - if (UNLIKELY(dict == NULL)) { + if (UNLIKELY(dict == nullptr)) { return 0; } @@ -4502,24 +4509,24 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr { PyObject *ret = PyType_Type.tp_getattro(cls, attr); - /* Allows: - * >>> bpy.types.Scene.foo = BoolProperty() - * >>> bpy.types.Scene.foo - * - * ...rather than returning the deferred class register tuple - * as checked by BPy_PropDeferred_CheckTypeExact() - * - * Disable for now, - * this is faking internal behavior in a way that's too tricky to maintain well. */ +/* Allows: + * >>> bpy.types.Scene.foo = BoolProperty() + * >>> bpy.types.Scene.foo + * + * ...rather than returning the deferred class register tuple + * as checked by BPy_PropDeferred_CheckTypeExact() + * + * Disable for now, + * this is faking internal behavior in a way that's too tricky to maintain well. */ # if 0 - if ((ret == NULL) /* || BPy_PropDeferred_CheckTypeExact(ret) */ ) { + if ((ret == nullptr) /* || BPy_PropDeferred_CheckTypeExact(ret) */) { StructRNA *srna = srna_from_self(cls, "StructRNA.__getattr__"); if (srna) { PropertyRNA *prop = RNA_struct_type_find_property_no_base(srna, PyUnicode_AsUTF8(attr)); if (prop) { PointerRNA tptr; PyErr_Clear(); /* Clear error from tp_getattro. */ - RNA_pointer_create(NULL, &RNA_Property, prop, &tptr); + RNA_pointer_create(nullptr, &RNA_Property, prop, &tptr); ret = pyrna_struct_CreatePyObject(&tptr); } } @@ -4547,8 +4554,8 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb return -1; } - if (srna == NULL) { - /* Allow setting on unregistered classes which can be registered later on. */ + if (srna == nullptr) { +/* Allow setting on unregistered classes which can be registered later on. */ #if 0 if (value && is_deferred_prop) { PyErr_Format(PyExc_AttributeError, @@ -4597,7 +4604,7 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject *value) { const char *name = PyUnicode_AsUTF8(pyname); - PropertyRNA *prop = NULL; + PropertyRNA *prop = nullptr; PYRNA_STRUCT_CHECK_INT(self); @@ -4607,7 +4614,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject } #endif /* USE_PEDANTIC_WRITE */ - if (name == NULL) { + if (name == nullptr) { PyErr_SetString(PyExc_AttributeError, "bpy_struct: __setattr__ must be a string"); return -1; } @@ -4623,10 +4630,10 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject else if (self->ptr.type == &RNA_Context) { /* Code just raises correct error, context prop's can't be set, * unless it's a part of the py class. */ - bContext *C = self->ptr.data; - if (C == NULL) { + bContext *C = static_cast(self->ptr.data); + if (C == nullptr) { PyErr_Format(PyExc_AttributeError, - "bpy_struct: Context is 'NULL', can't set \"%.200s\" from context", + "bpy_struct: Context is 'nullptr', can't set \"%.200s\" from context", name); return -1; } @@ -4637,8 +4644,8 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject int newindex; short newtype; - const eContextResult done = CTX_data_get( - C, name, &newptr, &newlb, &newprop, &newindex, &newtype); + const eContextResult done = eContextResult( + CTX_data_get(C, name, &newptr, &newlb, &newprop, &newindex, &newtype)); if (done == CTX_RESULT_OK) { PyErr_Format( @@ -4652,11 +4659,11 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject /* pyrna_py_to_prop sets its own exceptions */ if (prop) { - if (value == NULL) { + if (value == nullptr) { PyErr_SetString(PyExc_AttributeError, "bpy_struct: del not supported"); return -1; } - return pyrna_py_to_prop(&self->ptr, prop, NULL, value, "bpy_struct: item.attr = val:"); + return pyrna_py_to_prop(&self->ptr, prop, nullptr, value, "bpy_struct: item.attr = val:"); } return PyObject_GenericSetAttr((PyObject *)self, pyname, value); @@ -4693,9 +4700,9 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject { const char *name = PyUnicode_AsUTF8(pyname); - if (name == NULL) { + if (name == nullptr) { PyErr_SetString(PyExc_AttributeError, "bpy_prop_collection: __getattr__ must be a string"); - return NULL; + return nullptr; } if (name[0] != '_') { PyObject *ret; @@ -4729,7 +4736,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject PyObject *ret = PyObject_GenericGetAttr((PyObject *)self, pyname); - if (ret == NULL && name[0] != '_') { /* Avoid inheriting `__call__` and similar. */ + if (ret == nullptr && name[0] != '_') { /* Avoid inheriting `__call__` and similar. */ /* Since this is least common case, handle it last. */ PointerRNA r_ptr; if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) { @@ -4743,7 +4750,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject Py_DECREF(cls); /* Restore the original error. */ - if (ret == NULL) { + if (ret == nullptr) { PyErr_Restore(error_type, error_value, error_traceback); } else { @@ -4755,7 +4762,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject } else { Py_DECREF(ret); - ret = PyCMethod_New(m, (PyObject *)self, NULL, NULL); + ret = PyCMethod_New(m, (PyObject *)self, nullptr, nullptr); } } } @@ -4780,18 +4787,19 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam } #endif /* USE_PEDANTIC_WRITE */ - if (name == NULL) { + if (name == nullptr) { PyErr_SetString(PyExc_AttributeError, "bpy_prop: __setattr__ must be a string"); return -1; } - if (value == NULL) { + if (value == nullptr) { PyErr_SetString(PyExc_AttributeError, "bpy_prop: del not supported"); return -1; } 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):"); + return pyrna_py_to_prop( + &r_ptr, prop, nullptr, value, "BPy_PropertyRNA - Attribute (setattr):"); } } @@ -4807,8 +4815,8 @@ static PyObject *pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self) PointerRNA r_ptr; #ifdef USE_PEDANTIC_WRITE - if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) { - return NULL; + if (rna_disallow_writes && rna_id_write_error(&self->ptr, nullptr)) { + return nullptr; } #endif /* USE_PEDANTIC_WRITE */ @@ -4816,7 +4824,7 @@ static PyObject *pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self) if (!r_ptr.data) { PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.add(): not supported for this collection"); - return NULL; + return nullptr; } return pyrna_struct_CreatePyObject(&r_ptr); @@ -4827,20 +4835,20 @@ static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyOb const int key = PyLong_AsLong(value); #ifdef USE_PEDANTIC_WRITE - if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) { - return NULL; + if (rna_disallow_writes && rna_id_write_error(&self->ptr, nullptr)) { + return nullptr; } #endif /* USE_PEDANTIC_WRITE */ if (key == -1 && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.remove(): expected one int argument"); - return NULL; + return nullptr; } if (!RNA_property_collection_remove(&self->ptr, self->prop, key)) { PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.remove() not supported for this collection"); - return NULL; + return nullptr; } Py_RETURN_NONE; @@ -4849,8 +4857,8 @@ static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyOb static PyObject *pyrna_prop_collection_idprop_clear(BPy_PropertyRNA *self) { #ifdef USE_PEDANTIC_WRITE - if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) { - return NULL; + if (rna_disallow_writes && rna_id_write_error(&self->ptr, nullptr)) { + return nullptr; } #endif /* USE_PEDANTIC_WRITE */ @@ -4864,20 +4872,20 @@ static PyObject *pyrna_prop_collection_idprop_move(BPy_PropertyRNA *self, PyObje int key = 0, pos = 0; #ifdef USE_PEDANTIC_WRITE - if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) { - return NULL; + if (rna_disallow_writes && rna_id_write_error(&self->ptr, nullptr)) { + return nullptr; } #endif /* USE_PEDANTIC_WRITE */ if (!PyArg_ParseTuple(args, "ii", &key, &pos)) { PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.move(): expected two ints as arguments"); - return NULL; + return nullptr; } if (!RNA_property_collection_move(&self->ptr, self->prop, key, pos)) { PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.move() not supported for this collection"); - return NULL; + return nullptr; } Py_RETURN_NONE; @@ -4909,7 +4917,7 @@ PyDoc_STRVAR(pyrna_struct_get_rna_type_doc, "The property type for introspection static PyObject *pyrna_struct_get_rna_type(BPy_PropertyRNA *self) { PointerRNA tptr; - RNA_pointer_create(NULL, &RNA_Property, self->prop, &tptr); + RNA_pointer_create(nullptr, &RNA_Property, self->prop, &tptr); return pyrna_struct_Subtype(&tptr); } @@ -4920,32 +4928,32 @@ static PyObject *pyrna_struct_get_rna_type(BPy_PropertyRNA *self) static PyGetSetDef pyrna_prop_getseters[] = { {"id_data", (getter)pyrna_struct_get_id_data, - (setter)NULL, + (setter) nullptr, pyrna_struct_get_id_data_doc, - NULL}, - {"data", (getter)pyrna_struct_get_data, (setter)NULL, pyrna_struct_get_data_doc, NULL}, + nullptr}, + {"data", (getter)pyrna_struct_get_data, (setter) nullptr, pyrna_struct_get_data_doc, nullptr}, {"rna_type", (getter)pyrna_struct_get_rna_type, - (setter)NULL, + (setter) nullptr, pyrna_struct_get_rna_type_doc, - NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; static PyGetSetDef pyrna_struct_getseters[] = { {"id_data", (getter)pyrna_struct_get_id_data, - (setter)NULL, + (setter) nullptr, pyrna_struct_get_id_data_doc, - NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; static PyObject *pyrna_func_doc_get(BPy_FunctionRNA *self, void *closure); static PyGetSetDef pyrna_func_getseters[] = { - {"__doc__", (getter)pyrna_func_doc_get, (setter)NULL, NULL, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {"__doc__", (getter)pyrna_func_doc_get, (setter) nullptr, nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; PyDoc_STRVAR(pyrna_prop_collection_keys_doc, @@ -5057,13 +5065,13 @@ static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args) PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) { - return NULL; + return nullptr; } /* Mostly copied from BPy_IDGroup_Map_GetItem. */ if (RNA_struct_idprops_check(self->ptr.type) == 0) { PyErr_SetString(PyExc_TypeError, "this type doesn't support IDProperties"); - return NULL; + return nullptr; } group = RNA_struct_idprops(&self->ptr, 0); @@ -5095,18 +5103,18 @@ static PyObject *pyrna_struct_pop(BPy_StructRNA *self, PyObject *args) IDProperty *group, *idprop; const char *key; - PyObject *def = NULL; + PyObject *def = nullptr; PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) { - return NULL; + return nullptr; } /* Mostly copied from BPy_IDGroup_Map_GetItem. */ if (RNA_struct_idprops_check(self->ptr.type) == 0) { PyErr_SetString(PyExc_TypeError, "this type doesn't support IDProperties"); - return NULL; + return nullptr; } group = RNA_struct_idprops(&self->ptr, 0); @@ -5117,17 +5125,17 @@ static PyObject *pyrna_struct_pop(BPy_StructRNA *self, PyObject *args) /* Don't use #BPy_IDGroup_WrapData as the id-property is being removed from the ID. */ PyObject *ret = BPy_IDGroup_MapDataToPy(idprop); /* Internal error. */ - if (UNLIKELY(ret == NULL)) { - return NULL; + if (UNLIKELY(ret == nullptr)) { + return nullptr; } IDP_FreeFromGroup(group, idprop); return ret; } } - if (def == NULL) { + if (def == nullptr) { PyErr_SetString(PyExc_KeyError, "key not found"); - return NULL; + return nullptr; } return Py_INCREF_RET(def); } @@ -5168,7 +5176,7 @@ static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args PYRNA_PROP_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "O|O:get", &key_ob, &def)) { - return NULL; + return nullptr; } if (PyUnicode_Check(key_ob)) { @@ -5180,7 +5188,7 @@ static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args if (pyrna_prop_collection_string_subscript_supported_or_error(self, "bpy_prop_collection.get") == -1) { - return NULL; + return nullptr; } } else if (PyTuple_Check(key_ob)) { @@ -5400,10 +5408,10 @@ static bool foreach_compat_buffer(RawPropertyType raw_type, int attr_signed, con static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) { - PyObject *item = NULL; + PyObject *item = nullptr; int i = 0, ok = 0; bool buffer_is_compat; - void *array = NULL; + void *array = nullptr; /* Get/set both take the same args currently. */ const char *attr; @@ -5415,7 +5423,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) if (foreach_parse_args( self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) == -1) { - return NULL; + return nullptr; } if (tot == 0) { @@ -5438,7 +5446,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) if (buffer_is_compat) { ok = RNA_property_collection_raw_set( - NULL, &self->ptr, self->prop, attr, buf.buf, raw_type, tot); + nullptr, &self->ptr, self->prop, attr, buf.buf, raw_type, tot); } PyBuffer_Release(&buf); @@ -5480,7 +5488,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) } ok = RNA_property_collection_raw_set( - NULL, &self->ptr, self->prop, attr, array, raw_type, tot); + nullptr, &self->ptr, self->prop, attr, array, raw_type, tot); } } else { @@ -5499,7 +5507,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) if (buffer_is_compat) { ok = RNA_property_collection_raw_get( - NULL, &self->ptr, self->prop, attr, buf.buf, raw_type, tot); + nullptr, &self->ptr, self->prop, attr, buf.buf, raw_type, tot); } PyBuffer_Release(&buf); @@ -5511,7 +5519,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) array = PyMem_Malloc(size * tot); ok = RNA_property_collection_raw_get( - NULL, &self->ptr, self->prop, attr, array, raw_type, tot); + nullptr, &self->ptr, self->prop, attr, array, raw_type, tot); if (!ok) { /* Skip the loop. */ @@ -5561,11 +5569,11 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) /* Maybe we could make our own error. */ PyErr_Print(); PyErr_SetString(PyExc_TypeError, "couldn't access the py sequence"); - return NULL; + return nullptr; } if (!ok) { PyErr_SetString(PyExc_RuntimeError, "internal error setting the array"); - return NULL; + return nullptr; } Py_RETURN_NONE; @@ -5597,9 +5605,9 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, PyObject *args, const bool do_set) { - PyObject *item = NULL; + PyObject *item = nullptr; Py_ssize_t i, seq_size, size; - void *array = NULL; + void *array = nullptr; const PropertyType prop_type = RNA_property_type(self->prop); /* Get/set both take the same args currently. */ @@ -5607,11 +5615,11 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, if (!ELEM(prop_type, PROP_INT, PROP_FLOAT)) { PyErr_Format(PyExc_TypeError, "foreach_get/set available only for int and float"); - return NULL; + return nullptr; } if (!PyArg_ParseTuple(args, "O:foreach_get/set", &seq)) { - return NULL; + return nullptr; } if (!PySequence_Check(seq) && PyObject_CheckBuffer(seq)) { @@ -5619,7 +5627,7 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, PyExc_TypeError, "foreach_get/set expected second argument to be a sequence or buffer, not a %.200s", Py_TYPE(seq)->tp_name); - return NULL; + return nullptr; } size = pyrna_prop_array_length(self); @@ -5627,7 +5635,7 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, if (size != seq_size) { PyErr_Format(PyExc_TypeError, "expected sequence size %d, got %d", size, seq_size); - return NULL; + return nullptr; } Py_buffer buf; @@ -5644,10 +5652,10 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, Py_DECREF(item); } - RNA_property_int_set_array(&self->ptr, self->prop, array); + RNA_property_int_set_array(&self->ptr, self->prop, static_cast(array)); } else { - RNA_property_int_get_array(&self->ptr, self->prop, array); + RNA_property_int_get_array(&self->ptr, self->prop, static_cast(array)); for (i = 0; i < size; i++) { item = PyLong_FromLong((long)((int *)array)[i]); @@ -5666,10 +5674,10 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, Py_DECREF(item); } - RNA_property_float_set_array(&self->ptr, self->prop, array); + RNA_property_float_set_array(&self->ptr, self->prop, static_cast(array)); } else { - RNA_property_float_get_array(&self->ptr, self->prop, array); + RNA_property_float_get_array(&self->ptr, self->prop, static_cast(array)); for (i = 0; i < size; i++) { item = PyFloat_FromDouble((double)((float *)array)[i]); @@ -5694,7 +5702,7 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, /* Maybe we could make our own error. */ PyErr_Print(); PyErr_SetString(PyExc_TypeError, "couldn't access the py sequence"); - return NULL; + return nullptr; } } else { @@ -5704,24 +5712,25 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, { PyBuffer_Release(&buf); PyErr_Format(PyExc_TypeError, "incorrect sequence item type: %s", buf.format); - return NULL; + return nullptr; } switch (prop_type) { case PROP_INT: if (do_set) { - RNA_property_int_set_array(&self->ptr, self->prop, buf.buf); + RNA_property_int_set_array(&self->ptr, self->prop, static_cast(buf.buf)); } else { - RNA_property_int_get_array(&self->ptr, self->prop, buf.buf); + RNA_property_int_get_array(&self->ptr, self->prop, static_cast(buf.buf)); } break; case PROP_FLOAT: if (do_set) { - RNA_property_float_set_array(&self->ptr, self->prop, buf.buf); + RNA_property_float_set_array( + &self->ptr, self->prop, static_cast(buf.buf)); } else { - RNA_property_float_get_array(&self->ptr, self->prop, buf.buf); + RNA_property_float_get_array(&self->ptr, self->prop, static_cast(buf.buf)); } break; case PROP_BOOLEAN: @@ -5768,7 +5777,7 @@ static PyObject *pyrna_prop_array_iter(BPy_PropertyArrayRNA *self) { /* Try get values from a collection. */ PyObject *ret; - PyObject *iter = NULL; + PyObject *iter = nullptr; int len; PYRNA_PROP_CHECK_OBJ((BPy_PropertyRNA *)self); @@ -5777,7 +5786,7 @@ static PyObject *pyrna_prop_array_iter(BPy_PropertyArrayRNA *self) ret = pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, 0, len, len); /* we know this is a list so no need to PyIter_Check - * otherwise it could be NULL (unlikely) if conversion failed */ + * otherwise it could be nullptr (unlikely) if conversion failed */ if (ret) { iter = PyObject_GetIter(ret); Py_DECREF(ret); @@ -5793,11 +5802,11 @@ static PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self) { /* Try get values from a collection. */ PyObject *ret; - PyObject *iter = NULL; + PyObject *iter = nullptr; ret = pyrna_prop_collection_values(self); /* we know this is a list so no need to PyIter_Check - * otherwise it could be NULL (unlikely) if conversion failed */ + * otherwise it could be nullptr (unlikely) if conversion failed */ if (ret) { iter = PyObject_GetIter(ret); Py_DECREF(ret); @@ -5881,7 +5890,7 @@ static PyMethodDef pyrna_struct_methods[] = { (PyCFunction)pyrna_struct_bl_rna_get_subclass, METH_VARARGS | METH_CLASS, pyrna_struct_bl_rna_get_subclass_doc}, - {"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, NULL}, + {"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, nullptr}, {"id_properties_ensure", (PyCFunction)pyrna_struct_id_properties_ensure, METH_NOARGS, @@ -5898,16 +5907,19 @@ static PyMethodDef pyrna_struct_methods[] = { /* experimental */ /* unused for now */ #if 0 - {"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS, NULL}, - {"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS, NULL}, + {"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS, nullptr}, + {"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS, nullptr}, - {"callback_add", (PyCFunction)pyrna_callback_classmethod_add, METH_VARARGS | METH_CLASS, NULL}, + {"callback_add", + (PyCFunction)pyrna_callback_classmethod_add, + METH_VARARGS | METH_CLASS, + nullptr}, {"callback_remove", (PyCFunction)pyrna_callback_classmethod_remove, METH_VARARGS | METH_CLASS, - NULL}, + nullptr}, #endif - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyMethodDef pyrna_prop_methods[] = { @@ -5917,8 +5929,8 @@ static PyMethodDef pyrna_prop_methods[] = { pyrna_prop_path_from_id_doc}, {"as_bytes", (PyCFunction)pyrna_prop_as_bytes, METH_NOARGS, pyrna_prop_as_bytes_doc}, {"update", (PyCFunction)pyrna_prop_update, METH_NOARGS, pyrna_prop_update_doc}, - {"__dir__", (PyCFunction)pyrna_prop_dir, METH_NOARGS, NULL}, - {NULL, NULL, 0, NULL}, + {"__dir__", (PyCFunction)pyrna_prop_dir, METH_NOARGS, nullptr}, + {nullptr, nullptr, 0, nullptr}, }; static PyMethodDef pyrna_prop_array_methods[] = { @@ -5931,7 +5943,7 @@ static PyMethodDef pyrna_prop_array_methods[] = { METH_VARARGS, pyrna_prop_array_foreach_set_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyMethodDef pyrna_prop_collection_methods[] = { @@ -5956,22 +5968,22 @@ static PyMethodDef pyrna_prop_collection_methods[] = { {"get", (PyCFunction)pyrna_prop_collection_get, METH_VARARGS, pyrna_prop_collection_get_doc}, {"find", (PyCFunction)pyrna_prop_collection_find, METH_O, pyrna_prop_collection_find_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyMethodDef pyrna_prop_collection_idprop_methods[] = { - {"add", (PyCFunction)pyrna_prop_collection_idprop_add, METH_NOARGS, NULL}, - {"remove", (PyCFunction)pyrna_prop_collection_idprop_remove, METH_O, NULL}, - {"clear", (PyCFunction)pyrna_prop_collection_idprop_clear, METH_NOARGS, NULL}, - {"move", (PyCFunction)pyrna_prop_collection_idprop_move, METH_VARARGS, NULL}, - {NULL, NULL, 0, NULL}, + {"add", (PyCFunction)pyrna_prop_collection_idprop_add, METH_NOARGS, nullptr}, + {"remove", (PyCFunction)pyrna_prop_collection_idprop_remove, METH_O, nullptr}, + {"clear", (PyCFunction)pyrna_prop_collection_idprop_clear, METH_NOARGS, nullptr}, + {"move", (PyCFunction)pyrna_prop_collection_idprop_move, METH_VARARGS, nullptr}, + {nullptr, nullptr, 0, nullptr}, }; /** * only needed for sub-typing, so a new class gets a valid #BPy_StructRNA * TODO: also accept useful args. */ -static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED(kwds)) +static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject * /*kwds*/) { if (PyTuple_GET_SIZE(args) == 1) { BPy_StructRNA *base = (BPy_StructRNA *)PyTuple_GET_ITEM(args, 0); @@ -6002,7 +6014,7 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject * PyObject_GC_UnTrack(ret); #endif } - /* Pass on exception & NULL if tp_alloc fails. */ + /* Pass on exception & nullptr if tp_alloc fails. */ return (PyObject *)ret; } @@ -6010,23 +6022,23 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject * PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): type '%.200s' is not a subtype of bpy_struct", type->tp_name); - return NULL; + return nullptr; } PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): expected a single argument"); - return NULL; + return nullptr; } /** * Only needed for sub-typing, so a new class gets a valid #BPy_StructRNA * TODO: also accept useful args. */ -static PyObject *pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED(kwds)) +static PyObject *pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject * /*kwds*/) { BPy_PropertyRNA *base; if (!PyArg_ParseTuple(args, "O!:bpy_prop.__new__", &pyrna_prop_Type, &base)) { - return NULL; + return nullptr; } if (type == Py_TYPE(base)) { @@ -6042,7 +6054,7 @@ static PyObject *pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *UN PyErr_Format(PyExc_TypeError, "bpy_prop.__new__(type): type '%.200s' is not a subtype of bpy_prop", type->tp_name); - return NULL; + return nullptr; } static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data) @@ -6056,7 +6068,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat int a, len; if (flag & PROP_DYNAMIC) { - ParameterDynAlloc *data_alloc = data; + ParameterDynAlloc *data_alloc = static_cast(data); len = data_alloc->array_tot; data = data_alloc->array; } @@ -6085,15 +6097,15 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat switch (RNA_property_subtype(prop)) { #ifdef USE_MATHUTILS case PROP_ALL_VECTOR_SUBTYPES: - ret = Vector_CreatePyObject(data, len, NULL); + ret = Vector_CreatePyObject(static_cast(data), len, nullptr); break; case PROP_MATRIX: if (len == 16) { - ret = Matrix_CreatePyObject(data, 4, 4, NULL); + ret = Matrix_CreatePyObject(static_cast(data), 4, 4, nullptr); break; } else if (len == 9) { - ret = Matrix_CreatePyObject(data, 3, 3, NULL); + ret = Matrix_CreatePyObject(static_cast(data), 3, 3, nullptr); break; } ATTR_FALLTHROUGH; @@ -6109,7 +6121,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat default: PyErr_Format( PyExc_TypeError, "RNA Error: unknown array type \"%d\" (pyrna_param_to_py)", type); - ret = NULL; + ret = nullptr; break; } } @@ -6131,17 +6143,17 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat size_t data_ch_len; if (flag & PROP_DYNAMIC) { - ParameterDynAlloc *data_alloc = data; - data_ch = data_alloc->array; + ParameterDynAlloc *data_alloc = static_cast(data); + data_ch = static_cast(data_alloc->array); data_ch_len = data_alloc->array_tot; - BLI_assert((data_ch == NULL) || strlen(data_ch) == data_ch_len); + BLI_assert((data_ch == nullptr) || strlen(data_ch) == data_ch_len); } else { data_ch = (flag & PROP_THICK_WRAP) ? (char *)data : *(char **)data; data_ch_len = data_ch ? strlen(data_ch) : 0; } - if (UNLIKELY(data_ch == NULL)) { + if (UNLIKELY(data_ch == nullptr)) { BLI_assert((flag & PROP_NEVER_NULL) == 0); ret = Py_None; Py_INCREF(ret); @@ -6181,7 +6193,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat } else { if (RNA_struct_is_ID(ptype)) { - RNA_id_pointer_create(*(void **)data, &newptr); + RNA_id_pointer_create(static_cast(*(void **)data), &newptr); } else { /* NOTE: this is taken from the function's ID pointer @@ -6215,7 +6227,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat } default: PyErr_Format(PyExc_TypeError, "RNA Error: unknown type \"%d\" (pyrna_param_to_py)", type); - ret = NULL; + ret = nullptr; break; } } @@ -6230,9 +6242,9 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat */ static PyObject *small_dict_get_item_string(PyObject *dict, const char *key_lookup) { - PyObject *key = NULL; + PyObject *key = nullptr; Py_ssize_t pos = 0; - PyObject *value = NULL; + PyObject *value = nullptr; while (PyDict_Next(dict, &pos, &key, &value)) { if (PyUnicode_Check(key)) { @@ -6242,7 +6254,7 @@ static PyObject *small_dict_get_item_string(PyObject *dict, const char *key_look } } - return NULL; + return nullptr; } /** @@ -6289,8 +6301,8 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject int i, pyargs_len, pykw_len, parms_len, ret_len, flag_parameter, err = 0, kw_tot = 0; bool kw_arg; - PropertyRNA *pret_single = NULL; - void *retdata_single = NULL; + PropertyRNA *pret_single = nullptr; + void *retdata_single = nullptr; /* enable this so all strings are copied and freed after calling. * this exposes bugs where the pointer to the string is held and re-used */ @@ -6301,23 +6313,23 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject #endif /* Should never happen, but it does in rare cases. */ - BLI_assert(self_ptr != NULL); + BLI_assert(self_ptr != nullptr); - if (self_ptr == NULL) { + if (self_ptr == nullptr) { PyErr_SetString(PyExc_RuntimeError, - "RNA functions internal RNA pointer is NULL, this is a bug. aborting"); - return NULL; + "RNA functions internal RNA pointer is nullptr, this is a bug. aborting"); + return nullptr; } - if (self_func == NULL) { + if (self_func == nullptr) { PyErr_Format( PyExc_RuntimeError, - "%.200s.(): RNA function internal function is NULL, this is a bug. aborting", + "%.200s.(): RNA function internal function is nullptr, this is a bug. aborting", RNA_struct_identifier(self_ptr->type)); - return NULL; + return nullptr; } - /* For testing. */ +/* For testing. */ #if 0 { const char *fn; @@ -6363,7 +6375,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject /* Only useful for single argument returns, we'll need another list loop for multiple. */ if (flag_parameter & PARM_OUTPUT) { ret_len++; - if (pret_single == NULL) { + if (pret_single == nullptr) { pret_single = parm; retdata_single = iter.data; } @@ -6371,7 +6383,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject continue; } - item = NULL; + item = nullptr; if (i < pyargs_len) { /* New in 2.8x, optional arguments must be keywords. */ @@ -6388,7 +6400,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject item = PyTuple_GET_ITEM(args, i); kw_arg = false; } - else if (kw != NULL) { + else if (kw != nullptr) { #if 0 item = PyDict_GetItemString(kw, RNA_property_identifier(parm)); /* Borrow reference. */ #else @@ -6401,7 +6413,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject kw_arg = true; } - if (item == NULL) { + if (item == nullptr) { if (flag_parameter & PARM_REQUIRED) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s(): required parameter \"%.200s\" not specified", @@ -6464,7 +6476,8 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject arg_name = PyUnicode_AsUTF8(key); found = false; - if (arg_name == NULL) { /* Unlikely the `arg_name` is not a string, but ignore if it is. */ + if (arg_name == nullptr) + { /* Unlikely the `arg_name` is not a string, but ignore if it is. */ PyErr_Clear(); } else { @@ -6521,7 +6534,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject err = -1; } - ret = NULL; + ret = nullptr; if (err == 0) { /* Call function. */ ReportList reports; @@ -6556,7 +6569,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject } /* Possible there is an error in conversion. */ - if (ret == NULL) { + if (ret == nullptr) { err = -1; } } @@ -6565,12 +6578,9 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject #ifdef DEBUG_STRING_FREE # if 0 - if (PyList_GET_SIZE(string_free_ls)) { - printf("%.200s.%.200s(): has %d strings\n", - RNA_struct_identifier(self_ptr->type), - RNA_function_identifier(self_func), - (int)PyList_GET_SIZE(string_free_ls)); - } +if (PyList_GET_SIZE(string_free_ls)) { +printf("%.200s.%.200s(): has %d strings\n", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), (int)PyList_GET_SIZE(string_free_ls)); +} # endif Py_DECREF(string_free_ls); # undef DEBUG_STRING_FREE @@ -6585,18 +6595,18 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject } if (err == -1) { - return NULL; + return nullptr; } Py_RETURN_NONE; } -static PyObject *pyrna_func_doc_get(BPy_FunctionRNA *self, void *UNUSED(closure)) +static PyObject *pyrna_func_doc_get(BPy_FunctionRNA *self, void * /*closure*/) { PyObject *ret; char *args; - args = RNA_function_as_string_keywords(NULL, self->func, true, true, INT_MAX); + args = RNA_function_as_string_keywords(nullptr, self->func, true, true, INT_MAX); ret = PyUnicode_FromFormat("%.200s.%.200s(%.200s)\n%s", RNA_struct_identifier(self->ptr.type), @@ -6610,97 +6620,97 @@ static PyObject *pyrna_func_doc_get(BPy_FunctionRNA *self, void *UNUSED(closure) } PyTypeObject pyrna_struct_meta_idprop_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy_struct_meta_idprop", /* NOTE: would be `sizeof(PyTypeObject)`, * but sub-types of Type must be #PyHeapTypeObject's. */ /*tp_basicsize*/ sizeof(PyHeapTypeObject), /*tp_itemsize*/ 0, - /*tp_dealloc*/ NULL, + /*tp_dealloc*/ nullptr, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, - /*tp_repr*/ NULL, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, - /*tp_getattro*/ NULL, /* Sub-classed: #pyrna_struct_meta_idprop_getattro. */ + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, + /*tp_repr*/ nullptr, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, + /*tp_getattro*/ nullptr, /* Sub-classed: #pyrna_struct_meta_idprop_getattro. */ /*tp_setattro*/ (setattrofunc)pyrna_struct_meta_idprop_setattro, - /*tp_as_buffer*/ NULL, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - /*tp_doc*/ NULL, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_doc*/ nullptr, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, - /*tp_methods*/ NULL, - /*tp_members*/ NULL, - /*tp_getset*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, + /*tp_methods*/ nullptr, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr, #if defined(_MSC_VER) - /*tp_base*/ NULL, /* Defer assignment. */ + /*tp_base*/ nullptr, /* Defer assignment. */ #else /*tp_base*/ &PyType_Type, #endif - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; /*-----------------------BPy_StructRNA method def------------------------------*/ PyTypeObject pyrna_struct_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy_struct", /*tp_basicsize*/ sizeof(BPy_StructRNA), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)pyrna_struct_dealloc, /*tp_vectorcall_offset */ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, /*tp_repr*/ (reprfunc)pyrna_struct_repr, - /*tp_as_number*/ NULL, + /*tp_as_number*/ nullptr, /*tp_as_sequence*/ &pyrna_struct_as_sequence, /*tp_as_mapping*/ &pyrna_struct_as_mapping, /*tp_hash*/ (hashfunc)pyrna_struct_hash, - /*tp_call*/ NULL, + /*tp_call*/ nullptr, /*tp_str*/ (reprfunc)pyrna_struct_str, /*tp_getattro*/ (getattrofunc)pyrna_struct_getattro, /*tp_setattro*/ (setattrofunc)pyrna_struct_setattro, - /*tp_as_buffer*/ NULL, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE #ifdef USE_PYRNA_STRUCT_REFERENCE | Py_TPFLAGS_HAVE_GC #endif , - /*tp_doc*/ NULL, + /*tp_doc*/ nullptr, #ifdef USE_PYRNA_STRUCT_REFERENCE /*tp_traverse*/ (traverseproc)pyrna_struct_traverse, /*tp_clear*/ (inquiry)pyrna_struct_clear, #else - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, #endif /* !USE_PYRNA_STRUCT_REFERENCE */ /*tp_richcompare*/ (richcmpfunc)pyrna_struct_richcmp, #ifdef USE_WEAKREFS @@ -6708,315 +6718,315 @@ PyTypeObject pyrna_struct_Type = { #else 0, #endif - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ pyrna_struct_methods, - /*tp_members*/ NULL, + /*tp_members*/ nullptr, /*tp_getset*/ pyrna_struct_getseters, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, /*tp_new*/ pyrna_struct_new, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; /*-----------------------BPy_PropertyRNA method def------------------------------*/ PyTypeObject pyrna_prop_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy_prop", /*tp_basicsize*/ sizeof(BPy_PropertyRNA), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)pyrna_prop_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, /*tp_repr*/ (reprfunc)pyrna_prop_repr, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, /*tp_hash*/ (hashfunc)pyrna_prop_hash, - /*tp_call*/ NULL, + /*tp_call*/ nullptr, /*tp_str*/ (reprfunc)pyrna_prop_str, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - /*tp_doc*/ NULL, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, + /*tp_doc*/ nullptr, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, /*tp_richcompare*/ (richcmpfunc)pyrna_prop_richcmp, #ifdef USE_WEAKREFS /*tp_weaklistoffset*/ offsetof(BPy_PropertyRNA, in_weakreflist), #else /*tp_weaklistoffset*/ 0, #endif - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ pyrna_prop_methods, - /*tp_members*/ NULL, + /*tp_members*/ nullptr, /*tp_getset*/ pyrna_prop_getseters, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, /*tp_new*/ pyrna_prop_new, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; PyTypeObject pyrna_prop_array_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy_prop_array", /*tp_basicsize*/ sizeof(BPy_PropertyArrayRNA), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)pyrna_prop_array_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, /*tp_repr*/ (reprfunc)pyrna_prop_array_repr, /*tp_as_number*/ &pyrna_prop_array_as_number, /*tp_as_sequence*/ &pyrna_prop_array_as_sequence, /*tp_as_mapping*/ &pyrna_prop_array_as_mapping, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, /*tp_getattro*/ (getattrofunc)pyrna_prop_array_getattro, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - /*tp_doc*/ NULL, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_doc*/ nullptr, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, #ifdef USE_WEAKREFS /*tp_weaklistoffset*/ offsetof(BPy_PropertyArrayRNA, in_weakreflist), #else /*tp_weaklistoffset*/ 0, #endif /*tp_iter*/ (getiterfunc)pyrna_prop_array_iter, - /*tp_iternext*/ NULL, + /*tp_iternext*/ nullptr, /*tp_methods*/ pyrna_prop_array_methods, - /*tp_members*/ NULL, - /*tp_getset*/ NULL /* Sub-classed: #pyrna_prop_getseters. */, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr /* Sub-classed: #pyrna_prop_getseters. */, /*tp_base*/ &pyrna_prop_Type, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; PyTypeObject pyrna_prop_collection_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy_prop_collection", /*tp_basicsize*/ sizeof(BPy_PropertyRNA), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)pyrna_prop_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, - /*tp_repr*/ NULL, /* Sub-classed, no need to define. */ + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, + /*tp_repr*/ nullptr, /* Sub-classed, no need to define. */ /*tp_as_number*/ &pyrna_prop_collection_as_number, /*tp_as_sequence*/ &pyrna_prop_collection_as_sequence, /*tp_as_mapping*/ &pyrna_prop_collection_as_mapping, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, /*tp_getattro*/ (getattrofunc)pyrna_prop_collection_getattro, /*tp_setattro*/ (setattrofunc)pyrna_prop_collection_setattro, - /*tp_as_buffer*/ NULL, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - /*tp_doc*/ NULL, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_doc*/ nullptr, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, #ifdef USE_WEAKREFS /*tp_weaklistoffset*/ offsetof(BPy_PropertyRNA, in_weakreflist), #else /*tp_weaklistoffset*/ 0, #endif /*tp_iter*/ (getiterfunc)pyrna_prop_collection_iter, - /*tp_iternext*/ NULL, + /*tp_iternext*/ nullptr, /*tp_methods*/ pyrna_prop_collection_methods, - /*tp_members*/ NULL, - /*tp_getset*/ NULL /*Sub-classed: see #pyrna_prop_getseters. */, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr /*Sub-classed: see #pyrna_prop_getseters. */, /*tp_base*/ &pyrna_prop_Type, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; /* only for add/remove/move methods */ static PyTypeObject pyrna_prop_collection_idprop_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy_prop_collection_idprop", /*tp_basicsize*/ sizeof(BPy_PropertyRNA), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)pyrna_prop_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_compare*/ NULL, /* DEPRECATED. */ - /*tp_repr*/ NULL, /* Sub-classed, no need to define. */ - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_compare*/ nullptr, /* DEPRECATED. */ + /*tp_repr*/ nullptr, /* Sub-classed, no need to define. */ + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - /*tp_doc*/ NULL, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_doc*/ nullptr, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, #ifdef USE_WEAKREFS /*tp_weaklistoffset*/ offsetof(BPy_PropertyRNA, in_weakreflist), #else /*tp_weaklistoffset*/ 0, #endif - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ pyrna_prop_collection_idprop_methods, - /*tp_members*/ NULL, - /*tp_getset*/ NULL /* Sub-classed: #pyrna_prop_getseters. */, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr /* Sub-classed: #pyrna_prop_getseters. */, /*tp_base*/ &pyrna_prop_collection_Type, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; /*-----------------------BPy_PropertyRNA method def------------------------------*/ PyTypeObject pyrna_func_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy_func", /*tp_basicsize*/ sizeof(BPy_FunctionRNA), /*tp_itemsize*/ 0, - /*tp_dealloc*/ NULL, + /*tp_dealloc*/ nullptr, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, /*tp_repr*/ (reprfunc)pyrna_func_repr, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, /*tp_call*/ (ternaryfunc)pyrna_func_call, - /*tp_str*/ NULL, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_str*/ nullptr, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT, - /*tp_doc*/ NULL, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_doc*/ nullptr, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, #ifdef USE_WEAKREFS /*tp_weaklistoffset*/ offsetof(BPy_PropertyRNA, in_weakreflist), #else /*tp_weaklistoffset*/ 0, #endif - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, - /*tp_methods*/ NULL, - /*tp_members*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, + /*tp_methods*/ nullptr, + /*tp_members*/ nullptr, /*tp_getset*/ pyrna_func_getseters, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; #ifdef USE_PYRNA_ITER @@ -7032,30 +7042,30 @@ static void pyrna_prop_collection_iter_dealloc(BPy_PropertyCollectionIterRNA *se static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *self); static PyTypeObject pyrna_prop_collection_iter_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy_prop_collection_iter", /*tp_basicsize*/ sizeof(BPy_PropertyCollectionIterRNA), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)pyrna_prop_collection_iter_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, - /*tp_repr*/ NULL, /* No need to define, sub-classed. */ - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, + /*tp_repr*/ nullptr, /* No need to define, sub-classed. */ + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, /*tp_getattro*/ PyObject_GenericGetAttr, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT, - /*tp_doc*/ NULL, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_doc*/ nullptr, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, # ifdef USE_WEAKREFS /*tp_weaklistoffset*/ offsetof(BPy_PropertyCollectionIterRNA, in_weakreflist), # else @@ -7063,28 +7073,28 @@ static PyTypeObject pyrna_prop_collection_iter_Type = { # endif /*tp_iter*/ PyObject_SelfIter, /*tp_iternext*/ (iternextfunc)pyrna_prop_collection_iter_next, - /*tp_methods*/ NULL, - /*tp_members*/ NULL, - /*tp_getset*/ NULL, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_methods*/ nullptr, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; static PyObject *pyrna_prop_collection_iter_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop) @@ -7093,7 +7103,7 @@ static PyObject *pyrna_prop_collection_iter_CreatePyObject(PointerRNA *ptr, Prop &pyrna_prop_collection_iter_Type); # ifdef USE_WEAKREFS - self->in_weakreflist = NULL; + self->in_weakreflist = nullptr; # endif RNA_property_collection_begin(ptr, prop, &self->iter); @@ -7110,7 +7120,7 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA * { if (self->iter.valid == false) { PyErr_SetNone(PyExc_StopIteration); - return NULL; + return nullptr; } BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&self->iter.ptr); @@ -7135,7 +7145,7 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA * static void pyrna_prop_collection_iter_dealloc(BPy_PropertyCollectionIterRNA *self) { # ifdef USE_WEAKREFS - if (self->in_weakreflist != NULL) { + if (self->in_weakreflist != nullptr) { PyObject_ClearWeakRefs((PyObject *)self); } # endif @@ -7156,7 +7166,7 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) Py_INCREF(newclass); if (RNA_struct_py_type_get(srna)) { - PyC_ObSpit("RNA WAS SET - ", RNA_struct_py_type_get(srna)); + PyC_ObSpit("RNA WAS SET - ", static_cast(RNA_struct_py_type_get(srna))); } Py_XDECREF((PyObject *)RNA_struct_py_type_get(srna)); @@ -7167,7 +7177,7 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) * having an instance within a type looks wrong, but this instance _is_ an RNA type. */ /* Python deals with the circular reference. */ - RNA_pointer_create(NULL, &RNA_Struct, srna, &ptr); + RNA_pointer_create(nullptr, &RNA_Struct, srna, &ptr); item = pyrna_struct_CreatePyObject(&ptr); /* NOTE: must set the class not the __dict__ else the internal slots are not updated correctly. @@ -7177,12 +7187,12 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) /* Add `staticmethod` and `classmethod` functions. */ { - const PointerRNA func_ptr = {NULL, srna, NULL}; + const PointerRNA func_ptr = {nullptr, srna, nullptr}; const ListBase *lb; Link *link; lb = RNA_struct_type_functions(srna); - for (link = lb->first; link; link = link->next) { + for (link = static_cast(lb->first); link; link = link->next) { FunctionRNA *func = (FunctionRNA *)link; const int flag = RNA_function_flag(func); if ((flag & FUNC_NO_SELF) && /* Is `staticmethod` or `classmethod`. */ @@ -7207,7 +7217,7 @@ static PyObject *pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dic /* Assume RNA_struct_py_type_get(srna) was already checked. */ StructRNA *base; - PyObject *py_base = NULL; + PyObject *py_base = nullptr; /* Get the base type. */ base = RNA_struct_base(srna); @@ -7218,7 +7228,7 @@ static PyObject *pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dic Py_DECREF(py_base); /* `srna` owns, this is only to pass as an argument. */ } - if (py_base == NULL) { + if (py_base == nullptr) { py_base = (PyObject *)&pyrna_struct_Type; } @@ -7227,21 +7237,21 @@ static PyObject *pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dic /* Check if we have a native Python subclass, use it when it exists * return a borrowed reference. */ -static PyObject *bpy_types_dict = NULL; +static PyObject *bpy_types_dict = nullptr; static PyObject *pyrna_srna_ExternalType(StructRNA *srna) { const char *idname = RNA_struct_identifier(srna); PyObject *newclass; - if (bpy_types_dict == NULL) { - PyObject *bpy_types = PyImport_ImportModuleLevel("bpy_types", NULL, NULL, NULL, 0); + if (bpy_types_dict == nullptr) { + PyObject *bpy_types = PyImport_ImportModuleLevel("bpy_types", nullptr, nullptr, nullptr, 0); - if (bpy_types == NULL) { + if (bpy_types == nullptr) { PyErr_Print(); PyErr_Clear(); CLOG_ERROR(BPY_LOG_RNA, "failed to find 'bpy_types' module"); - return NULL; + return nullptr; } bpy_types_dict = PyModule_GetDict(bpy_types); /* Borrow. */ Py_DECREF(bpy_types); /* Fairly safe to assume the dict is kept. */ @@ -7260,10 +7270,10 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict, bpy_intern_str___slots__); - if (tp_slots == NULL) { + if (tp_slots == nullptr) { CLOG_ERROR( BPY_LOG_RNA, "expected class '%s' to have __slots__ defined, see bpy_types.py", idname); - newclass = NULL; + newclass = nullptr; } else if (PyTuple_GET_SIZE(tp_bases)) { PyObject *base = PyTuple_GET_ITEM(tp_bases, 0); @@ -7275,7 +7285,7 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) "incorrect subclassing of SRNA '%s', expected '%s', see bpy_types.py", idname, pyob_info); - newclass = NULL; + newclass = nullptr; } else { CLOG_INFO(BPY_LOG_RNA, 2, "SRNA sub-classed: '%s'", idname); @@ -7288,13 +7298,13 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) static PyObject *pyrna_srna_Subtype(StructRNA *srna) { - PyObject *newclass = NULL; + PyObject *newclass = nullptr; /* Stupid/simple case. */ - if (srna == NULL) { - newclass = NULL; /* Nothing to do. */ - } /* The class may have already been declared & allocated. */ - else if ((newclass = RNA_struct_py_type_get(srna))) { + if (srna == nullptr) { + newclass = nullptr; /* Nothing to do. */ + } /* The class may have already been declared & allocated. */ + else if ((newclass = static_cast(RNA_struct_py_type_get(srna)))) { Py_INCREF(newclass); } /* Check if bpy_types.py module has the class defined in it. */ else if ((newclass = pyrna_srna_ExternalType(srna))) { @@ -7317,7 +7327,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna) PyObject *metaclass; const char *idname = RNA_struct_identifier(srna); - /* Remove `__doc__` for now because we don't need it to generate docs. */ +/* Remove `__doc__` for now because we don't need it to generate docs. */ #if 0 const char *descr = RNA_struct_ui_description(srna); if (!descr) { @@ -7334,7 +7344,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna) metaclass = (PyObject *)&PyType_Type; } - /* Always use O not N when calling, N causes refcount errors. */ +/* Always use O not N when calling, N causes refcount errors. */ #if 0 newclass = PyObject_CallFunction( metaclass, "s(O) {sss()}", idname, py_base, "__module__", "bpy.types", "__slots__"); @@ -7397,7 +7407,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna) static StructRNA *srna_from_ptr(PointerRNA *ptr) { if (ptr->type == &RNA_Struct) { - return ptr->data; + return static_cast(ptr->data); } return ptr->type; @@ -7413,18 +7423,19 @@ static PyObject *pyrna_struct_Subtype(PointerRNA *ptr) PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr) { - BPy_StructRNA *pyrna = NULL; + BPy_StructRNA *pyrna = nullptr; - /* NOTE: don't rely on this to return None since NULL data with a valid type can often crash. */ - if (ptr->data == NULL && ptr->type == NULL) { /* Operator RNA has NULL data. */ + /* NOTE: don't rely on this to return None since nullptr data with a valid type can often crash. + */ + if (ptr->data == nullptr && ptr->type == nullptr) { /* Operator RNA has nullptr data. */ Py_RETURN_NONE; } /* New in 2.8x, since not many types support instancing * we may want to use a flag to avoid looping over all classes. - campbell */ - void **instance = ptr->data ? RNA_struct_instance(ptr) : NULL; + void **instance = ptr->data ? RNA_struct_instance(ptr) : nullptr; if (instance && *instance) { - pyrna = *instance; + pyrna = static_cast(*instance); /* Refine may have changed types after the first instance was created. */ if (ptr->type == pyrna->ptr.type) { @@ -7434,10 +7445,10 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr) /* Existing users will need to use 'type_recast' method. */ Py_DECREF(pyrna); - *instance = NULL; - /* Continue as if no instance was made. */ + *instance = nullptr; +/* Continue as if no instance was made. */ #if 0 /* No need to assign, will be written to next... */ - pyrna = NULL; + pyrna = nullptr; #endif } @@ -7449,7 +7460,7 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr) #ifdef USE_PYRNA_STRUCT_REFERENCE /* #PyType_GenericAlloc will have set tracking. * We only want tracking when `StructRNA.reference` has been set. */ - if (pyrna != NULL) { + if (pyrna != nullptr) { PyObject_GC_UnTrack(pyrna); } #endif @@ -7465,16 +7476,16 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr) #endif #ifdef USE_WEAKREFS - if (pyrna != NULL) { - pyrna->in_weakreflist = NULL; + if (pyrna != nullptr) { + pyrna->in_weakreflist = nullptr; } #endif } } - if (pyrna == NULL) { + if (pyrna == nullptr) { PyErr_SetString(PyExc_MemoryError, "couldn't create bpy_struct object"); - return NULL; + return nullptr; } /* Blender's instance owns a reference (to avoid Python freeing it). */ @@ -7489,7 +7500,7 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr) #endif #ifdef USE_PYRNA_STRUCT_REFERENCE - pyrna->reference = NULL; + pyrna->reference = nullptr; #endif // PyC_ObSpit("NewStructRNA: ", (PyObject *)pyrna); @@ -7505,19 +7516,19 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr) PyObject *pyrna_struct_CreatePyObject_with_primitive_support(PointerRNA *ptr) { if (ptr->type == &RNA_PrimitiveString) { - const PrimitiveStringRNA *data = ptr->data; + const PrimitiveStringRNA *data = static_cast(ptr->data); return PyC_UnicodeFromBytes(data->value); } if (ptr->type == &RNA_PrimitiveInt) { - const PrimitiveIntRNA *data = ptr->data; + const PrimitiveIntRNA *data = static_cast(ptr->data); return PyLong_FromLong(data->value); } if (ptr->type == &RNA_PrimitiveFloat) { - const PrimitiveFloatRNA *data = ptr->data; + const PrimitiveFloatRNA *data = static_cast(ptr->data); return PyFloat_FromDouble(data->value); } if (ptr->type == &RNA_PrimitiveBoolean) { - const PrimitiveBooleanRNA *data = ptr->data; + const PrimitiveBooleanRNA *data = static_cast(ptr->data); return PyBool_FromLong(data->value); } return pyrna_struct_CreatePyObject(ptr); @@ -7544,7 +7555,7 @@ PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop) pyrna = (BPy_PropertyRNA *)PyObject_NEW(BPy_PropertyRNA, type); #ifdef USE_WEAKREFS - pyrna->in_weakreflist = NULL; + pyrna->in_weakreflist = nullptr; #endif } else { @@ -7552,13 +7563,13 @@ PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop) ((BPy_PropertyArrayRNA *)pyrna)->arraydim = 0; ((BPy_PropertyArrayRNA *)pyrna)->arrayoffset = 0; #ifdef USE_WEAKREFS - ((BPy_PropertyArrayRNA *)pyrna)->in_weakreflist = NULL; + ((BPy_PropertyArrayRNA *)pyrna)->in_weakreflist = nullptr; #endif } - if (pyrna == NULL) { + if (pyrna == nullptr) { PyErr_SetString(PyExc_MemoryError, "couldn't create BPy_rna object"); - return NULL; + return nullptr; } pyrna->ptr = *ptr; @@ -7591,7 +7602,7 @@ bool pyrna_id_FromPyObject(PyObject *obj, ID **id) return true; } - *id = NULL; + *id = nullptr; return false; } @@ -7607,7 +7618,7 @@ void BPY_rna_init(void) mathutils_rna_matrix_cb_index = Mathutils_RegisterCallback(&mathutils_rna_matrix_cb); #endif - /* For some reason MSVC complains of these. */ +/* For some reason MSVC complains of these. */ #if defined(_MSC_VER) pyrna_struct_meta_idprop_Type.tp_base = &PyType_Type; #endif @@ -7648,7 +7659,7 @@ void BPY_rna_init(void) #endif #ifdef USE_PYRNA_INVALIDATE_WEAKREF - BLI_assert(id_weakref_pool == NULL); + BLI_assert(id_weakref_pool == nullptr); id_weakref_pool = BLI_ghash_ptr_new("rna_global_pool"); #endif } @@ -7669,13 +7680,13 @@ void BPY_rna_exit(void) printf("ID: %s\n", id->name); } } - BLI_ghash_free(id_weakref_pool, NULL, id_weakref_pool_free_value_fn); - id_weakref_pool = NULL; + BLI_ghash_free(id_weakref_pool, nullptr, id_weakref_pool_free_value_fn); + id_weakref_pool = nullptr; #endif } /* 'bpy.data' from Python. */ -static PointerRNA *rna_module_ptr = NULL; +static PointerRNA *rna_module_ptr = nullptr; PyObject *BPY_rna_module(void) { BPy_StructRNA *pyrna; @@ -7733,18 +7744,19 @@ struct BPy_TypesModule_State { static PyObject *bpy_types_module_getattro(PyObject *self, PyObject *pyname) { - struct BPy_TypesModule_State *state = PyModule_GetState(self); + struct BPy_TypesModule_State *state = static_cast( + PyModule_GetState(self)); PointerRNA newptr; PyObject *ret; const char *name = PyUnicode_AsUTF8(pyname); - if (name == NULL) { + if (name == nullptr) { PyErr_SetString(PyExc_AttributeError, "bpy.types: __getattr__ must be a string"); - ret = NULL; + ret = nullptr; } else if (RNA_property_collection_lookup_string(&state->ptr, state->prop, name, &newptr)) { ret = pyrna_struct_Subtype(&newptr); - if (ret == NULL) { + if (ret == nullptr) { PyErr_Format(PyExc_RuntimeError, "bpy.types.%.200s subtype could not be generated, this is a bug!", PyUnicode_AsUTF8(pyname)); @@ -7755,7 +7767,7 @@ static PyObject *bpy_types_module_getattro(PyObject *self, PyObject *pyname) PyErr_Format(PyExc_AttributeError, "bpy.types.%.200s RNA_Struct does not exist", PyUnicode_AsUTF8(pyname)); - return NULL; + return nullptr; #endif /* The error raised here will be displayed. */ ret = PyObject_GenericGetAttr((PyObject *)self, pyname); @@ -7766,11 +7778,12 @@ static PyObject *bpy_types_module_getattro(PyObject *self, PyObject *pyname) static PyObject *bpy_types_module_dir(PyObject *self) { - struct BPy_TypesModule_State *state = PyModule_GetState(self); + struct BPy_TypesModule_State *state = static_cast( + PyModule_GetState(self)); PyObject *ret = PyList_New(0); RNA_PROP_BEGIN (&state->ptr, itemptr, state->prop) { - StructRNA *srna = itemptr.data; + StructRNA *srna = static_cast(itemptr.data); PyList_APPEND(ret, PyUnicode_FromString(RNA_struct_identifier(srna))); } RNA_PROP_END; @@ -7786,9 +7799,9 @@ static PyObject *bpy_types_module_dir(PyObject *self) } static PyMethodDef bpy_types_module_methods[] = { - {"__getattr__", (PyCFunction)bpy_types_module_getattro, METH_O, NULL}, - {"__dir__", (PyCFunction)bpy_types_module_dir, METH_NOARGS, NULL}, - {NULL, NULL, 0, NULL}, + {"__getattr__", (PyCFunction)bpy_types_module_getattro, METH_O, nullptr}, + {"__dir__", (PyCFunction)bpy_types_module_dir, METH_NOARGS, nullptr}, + {nullptr, nullptr, 0, nullptr}, }; PyDoc_STRVAR(bpy_types_module_doc, "Access to internal Blender types"); @@ -7798,16 +7811,17 @@ static PyModuleDef bpy_types_module_def = { /*m_doc*/ bpy_types_module_doc, /*m_size*/ sizeof(struct BPy_TypesModule_State), /*m_methods*/ bpy_types_module_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; PyObject *BPY_rna_types(void) { PyObject *submodule = PyModule_Create(&bpy_types_module_def); - struct BPy_TypesModule_State *state = PyModule_GetState(submodule); + struct BPy_TypesModule_State *state = static_cast( + PyModule_GetState(submodule)); RNA_blender_rna_pointer_create(&state->ptr); state->prop = RNA_struct_find_property(&state->ptr, "structs"); @@ -7836,7 +7850,7 @@ PyObject *BPY_rna_types(void) StructRNA *pyrna_struct_as_srna(PyObject *self, const bool parent, const char *error_prefix) { - BPy_StructRNA *py_srna = NULL; + BPy_StructRNA *py_srna = nullptr; StructRNA *srna; /* Unfortunately PyObject_GetAttrString won't look up this types tp_dict first :/ */ @@ -7849,17 +7863,17 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, const bool parent, const char *e if (parent) { /* be very careful with this since it will return a parent classes srna. * modifying this will do confusing stuff! */ - if (py_srna == NULL) { + if (py_srna == nullptr) { py_srna = (BPy_StructRNA *)PyObject_GetAttr(self, bpy_intern_str_bl_rna); } } - if (py_srna == NULL) { + if (py_srna == nullptr) { PyErr_Format(PyExc_RuntimeError, "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)", error_prefix, Py_TYPE(self)->tp_name); - return NULL; + return nullptr; } if (!BPy_StructRNA_Check(py_srna)) { @@ -7869,7 +7883,7 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, const bool parent, const char *e Py_TYPE(py_srna)->tp_name, Py_TYPE(self)->tp_name); Py_DECREF(py_srna); - return NULL; + return nullptr; } if (py_srna->ptr.type != &RNA_Struct) { @@ -7878,10 +7892,10 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, const bool parent, const char *e error_prefix, Py_TYPE(self)->tp_name); Py_DECREF(py_srna); - return NULL; + return nullptr; } - srna = py_srna->ptr.data; + srna = static_cast(py_srna->ptr.data); Py_DECREF(py_srna); return srna; @@ -7895,7 +7909,7 @@ const PointerRNA *pyrna_struct_as_ptr(PyObject *py_obj, const StructRNA *srna) "Expected a \"bpy.types.%.200s\" not a \"%.200s\"", RNA_struct_identifier(srna), Py_TYPE(py_obj)->tp_name); - return NULL; + return nullptr; } PYRNA_STRUCT_CHECK_OBJ(bpy_srna); return &bpy_srna->ptr; @@ -7911,10 +7925,10 @@ const PointerRNA *pyrna_struct_as_ptr_or_null(PyObject *py_obj, const StructRNA int pyrna_struct_as_ptr_parse(PyObject *o, void *p) { - struct BPy_StructRNA_Parse *srna_parse = p; - BLI_assert(srna_parse->type != NULL); + struct BPy_StructRNA_Parse *srna_parse = static_cast(p); + BLI_assert(srna_parse->type != nullptr); srna_parse->ptr = pyrna_struct_as_ptr(o, srna_parse->type); - if (srna_parse->ptr == NULL) { + if (srna_parse->ptr == nullptr) { return 0; } return 1; @@ -7922,10 +7936,10 @@ int pyrna_struct_as_ptr_parse(PyObject *o, void *p) int pyrna_struct_as_ptr_or_null_parse(PyObject *o, void *p) { - struct BPy_StructRNA_Parse *srna_parse = p; - BLI_assert(srna_parse->type != NULL); + struct BPy_StructRNA_Parse *srna_parse = static_cast(p); + BLI_assert(srna_parse->type != nullptr); srna_parse->ptr = pyrna_struct_as_ptr_or_null(o, srna_parse->type); - if (srna_parse->ptr == NULL) { + if (srna_parse->ptr == nullptr) { return 0; } return 1; @@ -7936,14 +7950,14 @@ int pyrna_struct_as_ptr_or_null_parse(PyObject *o, void *p) StructRNA *srna_from_self(PyObject *self, const char *error_prefix) { - if (self == NULL) { - return NULL; + if (self == nullptr) { + return nullptr; } if (PyCapsule_CheckExact(self)) { - return PyCapsule_GetPointer(self, NULL); + return static_cast(PyCapsule_GetPointer(self, nullptr)); } if (PyType_Check(self) == 0) { - return NULL; + return nullptr; } /* These cases above not errors, they just mean the type was not compatible @@ -7971,7 +7985,7 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item /* We only care about results from C which * are for sure types, save some time with error */ - PyObject *py_func = ((BPy_PropDeferred *)item)->fn; + PyObject *py_func = static_cast(((BPy_PropDeferred *)item)->fn); PyObject *py_kw = ((BPy_PropDeferred *)item)->kw; PyObject *py_srna_cobject, *py_ret; @@ -7992,7 +8006,7 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item func_name); return -1; } - py_srna_cobject = PyCapsule_New(srna, NULL, NULL); + py_srna_cobject = PyCapsule_New(srna, nullptr, nullptr); /* Not 100% nice :/, modifies the dict passed, should be ok. */ PyDict_SetItem(py_kw, bpy_intern_str_attr, key); @@ -8049,14 +8063,14 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item */ static int pyrna_deferred_register_class_from_type_hints(StructRNA *srna, PyTypeObject *py_class) { - PyObject *annotations_dict = NULL; + PyObject *annotations_dict = nullptr; /* `typing.get_type_hints(py_class)` */ { - PyObject *typing_mod = PyImport_ImportModuleLevel("typing", NULL, NULL, NULL, 0); - if (typing_mod != NULL) { + PyObject *typing_mod = PyImport_ImportModuleLevel("typing", nullptr, nullptr, nullptr, 0); + if (typing_mod != nullptr) { PyObject *get_type_hints_fn = PyObject_GetAttrString(typing_mod, "get_type_hints"); - if (get_type_hints_fn != NULL) { + if (get_type_hints_fn != nullptr) { PyObject *args = PyTuple_New(1); PyTuple_SET_ITEM(args, 0, (PyObject *)py_class); @@ -8072,7 +8086,7 @@ static int pyrna_deferred_register_class_from_type_hints(StructRNA *srna, PyType } int ret = 0; - if (annotations_dict != NULL) { + if (annotations_dict != nullptr) { if (PyDict_CheckExact(annotations_dict)) { PyObject *item, *key; Py_ssize_t pos = 0; @@ -8193,7 +8207,7 @@ static int rna_function_arg_count(FunctionRNA *func, int *min_count) int count = is_staticmethod ? 0 : 1; bool done_min_count = false; - for (link = lb->first; link; link = link->next) { + for (link = static_cast(lb->first); link; link = link->next) { parm = (PropertyRNA *)link; if (!(RNA_parameter_flag(parm) & PARM_OUTPUT)) { if (!done_min_count && (RNA_parameter_flag(parm) & PARM_PYFUNC_OPTIONAL)) { @@ -8223,7 +8237,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, const char *class_type = RNA_struct_identifier(srna); StructRNA *srna_base = RNA_struct_base(srna); PyObject *py_class = (PyObject *)py_data; - PyObject *base_class = RNA_struct_py_type_get(srna); + PyObject *base_class = static_cast(RNA_struct_py_type_get(srna)); PyObject *item; int i, arg_count, func_arg_count, func_arg_min_count = 0; const char *py_class_name = ((PyTypeObject *)py_class)->tp_name; /* __name__ */ @@ -8247,7 +8261,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, /* Verify callback functions. */ lb = RNA_struct_type_functions(srna); i = 0; - for (link = lb->first; link; link = link->next) { + for (link = static_cast(lb->first); link; link = link->next) { FunctionRNA *func = (FunctionRNA *)link; const int flag = RNA_function_flag(func); if (!(flag & FUNC_REGISTER)) { @@ -8255,10 +8269,10 @@ static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, } item = PyObject_GetAttrString(py_class, RNA_function_identifier(func)); - have_function[i] = (item != NULL); + have_function[i] = (item != nullptr); i++; - if (item == NULL) { + if (item == nullptr) { if ((flag & (FUNC_REGISTER_OPTIONAL & ~FUNC_REGISTER)) == 0) { PyErr_Format(PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", @@ -8354,7 +8368,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, /* Verify properties. */ lb = RNA_struct_type_properties(srna); - for (link = lb->first; link; link = link->next) { + for (link = static_cast(lb->first); link; link = link->next) { const char *identifier; PropertyRNA *prop = (PropertyRNA *)link; const int flag = RNA_property_flag(prop); @@ -8367,7 +8381,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, identifier = RNA_property_identifier(prop); item = PyObject_GetAttrString(py_class, identifier); - if (item == NULL) { + if (item == nullptr) { PyErr_Clear(); /* Sneaky workaround to use the class name as the bl_idname. */ @@ -8375,7 +8389,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, else if (STREQ(identifier, rna_attr)) { \ if ((item = PyObject_GetAttr(py_class, py_attr))) { \ if (item != Py_None) { \ - if (pyrna_py_to_prop(dummy_ptr, prop, NULL, item, "validating class:") != 0) { \ + if (pyrna_py_to_prop(dummy_ptr, prop, nullptr, item, "validating class:") != 0) { \ Py_DECREF(item); \ return -1; \ } \ @@ -8394,7 +8408,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, #undef BPY_REPLACEMENT_STRING - if (item == NULL && ((flag & PROP_REGISTER_OPTIONAL) != PROP_REGISTER_OPTIONAL)) { + if (item == nullptr && ((flag & PROP_REGISTER_OPTIONAL) != PROP_REGISTER_OPTIONAL)) { PyErr_Format(PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, @@ -8406,7 +8420,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, PyErr_Clear(); } else { - if (pyrna_py_to_prop(dummy_ptr, prop, NULL, item, "validating class:") != 0) { + if (pyrna_py_to_prop(dummy_ptr, prop, nullptr, item, "validating class:") != 0) { Py_DECREF(item); return -1; } @@ -8426,7 +8440,7 @@ static int bpy_class_validate(PointerRNA *dummy_ptr, void *py_data, bool *have_f static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) { PyObject *args; - PyObject *ret = NULL, *py_srna = NULL, *py_class_instance = NULL, *parmitem; + PyObject *ret = nullptr, *py_srna = nullptr, *py_class_instance = nullptr, *parmitem; PyTypeObject *py_class; PropertyRNA *parm; ParameterIterator iter; @@ -8436,8 +8450,8 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE); const bool is_classmethod = (flag & FUNC_NO_SELF) && (flag & FUNC_USE_SELF_TYPE); - PropertyRNA *pret_single = NULL; - void *retdata_single = NULL; + PropertyRNA *pret_single = nullptr; + void *retdata_single = nullptr; PyGILState_STATE gilstate; @@ -8449,9 +8463,9 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param const bool is_readonly = !(RNA_function_flag(func) & FUNC_ALLOW_WRITE); #endif - py_class = RNA_struct_py_type_get(ptr->type); + py_class = static_cast(RNA_struct_py_type_get(ptr->type)); /* Rare case. can happen when registering subclasses. */ - if (py_class == NULL) { + if (py_class == nullptr) { CLOG_WARN(BPY_LOG_RNA, "unable to get Python class for RNA struct '%.200s'", RNA_struct_identifier(ptr->type)); @@ -8460,13 +8474,13 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param /* XXX, this is needed because render engine calls without a context * this should be supported at some point, but at the moment it's not! */ - if (C == NULL) { + if (C == nullptr) { C = BPY_context_get(); } - /* Annoying! We need to check if the screen gets set to NULL which is a + /* Annoying! We need to check if the screen gets set to nullptr which is a * hint that the file was actually re-loaded. */ - const bool is_valid_wm = (CTX_wm_manager(C) != NULL); + const bool is_valid_wm = (CTX_wm_manager(C) != nullptr); bpy_context_set(C, &gilstate); @@ -8477,26 +8491,26 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param if (instance) { if (*instance) { - py_class_instance = *instance; + py_class_instance = static_cast(*instance); Py_INCREF(py_class_instance); } } } /* End exception. */ - if (py_class_instance == NULL) { + if (py_class_instance == nullptr) { py_srna = pyrna_struct_CreatePyObject(ptr); } if (py_class_instance) { /* Special case, instance is cached. */ } - else if (py_srna == NULL) { - py_class_instance = NULL; + else if (py_srna == nullptr) { + py_class_instance = nullptr; } else if (py_srna == Py_None) { /* Probably won't ever happen, but possible. */ Py_DECREF(py_srna); - py_class_instance = NULL; + py_class_instance = nullptr; } else { #if 1 @@ -8514,9 +8528,9 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param /* True in most cases even when the class itself doesn't define an __init__ function. */ args = PyTuple_New(0); - if (py_class->tp_init(py_srna, args, NULL) < 0) { + if (py_class->tp_init(py_srna, args, nullptr) < 0) { Py_DECREF(py_srna); - py_srna = NULL; + py_srna = nullptr; /* Err set below. */ } Py_DECREF(args); @@ -8530,11 +8544,11 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param const int prev_write = rna_disallow_writes; rna_disallow_writes = true; - /* 'almost' all the time calling the class isn't needed. - * We could just do... */ +/* 'almost' all the time calling the class isn't needed. + * We could just do... */ # if 0 - py_class_instance = py_srna; - Py_INCREF(py_class_instance); +py_class_instance = py_srna; +Py_INCREF(py_class_instance); # endif /* * This would work fine, but means __init__ functions wouldn't run. @@ -8543,14 +8557,14 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param */ args = PyTuple_New(1); PyTuple_SET_ITEM(args, 0, py_srna); - py_class_instance = PyObject_Call(py_class, args, NULL); + py_class_instance = PyObject_Call(py_class, args, nullptr); Py_DECREF(args); rna_disallow_writes = prev_write; #endif - if (py_class_instance == NULL) { + if (py_class_instance == nullptr) { err = -1; /* So the error is not overridden below. */ } } @@ -8561,7 +8575,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param PyObject *item = PyObject_GetAttrString((PyObject *)py_class, RNA_function_identifier(func)); if (item) { - RNA_pointer_create(NULL, &RNA_Function, func, &funcptr); + RNA_pointer_create(nullptr, &RNA_Function, func, &funcptr); if (is_staticmethod) { arg_count = @@ -8598,7 +8612,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param /* Only useful for single argument returns, we'll need another list loop for multiple. */ if (RNA_parameter_flag(parm) & PARM_OUTPUT) { ret_len++; - if (pret_single == NULL) { + if (pret_single == nullptr) { pret_single = parm; retdata_single = iter.data; } @@ -8620,7 +8634,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param #endif /* *** Main Caller *** */ - ret = PyObject_Call(item, args, NULL); + ret = PyObject_Call(item, args, nullptr); /* *** Done Calling *** */ @@ -8653,7 +8667,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param } } - if (ret == NULL) { /* Covers py_class_instance failing too. */ + if (ret == nullptr) { /* Covers py_class_instance failing too. */ err = -1; } else { @@ -8728,9 +8742,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param ReportList *reports; /* Alert the user, else they won't know unless they see the console. */ if ((!is_staticmethod) && (!is_classmethod) && (ptr->data) && - RNA_struct_is_a(ptr->type, &RNA_Operator) && (is_valid_wm == (CTX_wm_manager(C) != NULL))) + RNA_struct_is_a(ptr->type, &RNA_Operator) && + (is_valid_wm == (CTX_wm_manager(C) != nullptr))) { - wmOperator *op = ptr->data; + wmOperator *op = static_cast(ptr->data); reports = op->reports; } else { @@ -8798,7 +8813,7 @@ void pyrna_alloc_types(void) RNA_PROP_BEGIN (&ptr, itemptr, prop) { PyObject *item = pyrna_struct_Subtype(&itemptr); - if (item == NULL) { + if (item == nullptr) { if (PyErr_Occurred()) { PyErr_Print(); PyErr_Clear(); @@ -8831,7 +8846,7 @@ void pyrna_free_types(void) #if 0 /* XXX: should be able to do this, but makes Python crash on exit. */ bpy_class_free(py_ptr); #endif - RNA_struct_py_type_set(srna, NULL); + RNA_struct_py_type_set(srna, nullptr); } } RNA_PROP_END; @@ -8868,9 +8883,9 @@ PyDoc_STRVAR(pyrna_register_class_doc, " before registration.\n"); PyMethodDef meth_bpy_register_class = { "register_class", pyrna_register_class, METH_O, pyrna_register_class_doc}; -static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class) +static PyObject *pyrna_register_class(PyObject * /*self*/, PyObject *py_class) { - bContext *C = NULL; + bContext *C = nullptr; ReportList reports; StructRegisterFunc reg; StructRNA *srna; @@ -8884,7 +8899,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class "register_class(...): " "expected a class argument, not '%.200s'", Py_TYPE(py_class)->tp_name); - return NULL; + return nullptr; } if (PyDict_GetItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna)) { @@ -8892,7 +8907,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class "register_class(...): " "already registered as a subclass '%.200s'", ((PyTypeObject *)py_class)->tp_name); - return NULL; + return nullptr; } if (!pyrna_write_check()) { @@ -8900,16 +8915,16 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class "register_class(...): " "can't run in readonly state '%.200s'", ((PyTypeObject *)py_class)->tp_name); - return NULL; + return nullptr; } /* WARNING: gets parent classes srna, only for the register function. */ srna = pyrna_struct_as_srna(py_class, true, "register_class(...):"); - if (srna == NULL) { - return NULL; + if (srna == nullptr) { + return nullptr; } - /* Fails in some cases, so can't use this check, but would like to :| */ +/* Fails in some cases, so can't use this check, but would like to :| */ #if 0 if (RNA_struct_py_type_get(srna)) { PyErr_Format(PyExc_ValueError, @@ -8917,7 +8932,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class "is not allowed", ((PyTypeObject *)py_class)->tp_name, RNA_struct_identifier(srna)); - return NULL; + return nullptr; } #endif @@ -8929,7 +8944,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class "register_class(...): expected a subclass of a registerable " "RNA type (%.200s does not support registration)", RNA_struct_identifier(srna)); - return NULL; + return nullptr; } /* Get the context, so register callback can do necessary refreshes. */ @@ -8955,14 +8970,14 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class } BKE_reports_clear(&reports); if (has_error) { - return NULL; + return nullptr; } } /* Python errors validating are not converted into reports so the check above will fail. - * the cause for returning NULL will be printed as an error */ - if (srna_new == NULL) { - return NULL; + * the cause for returning nullptr will be printed as an error */ + if (srna_new == nullptr) { + return nullptr; } /* Takes a reference to 'py_class'. */ @@ -8970,7 +8985,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class /* Old srna still references us, keep the check in case registering somehow can free it. */ if (RNA_struct_py_type_get(srna)) { - RNA_struct_py_type_set(srna, NULL); + RNA_struct_py_type_set(srna, nullptr); #if 0 /* Should be able to do this XXX since the old RNA adds a new ref. */ Py_DECREF(py_class); @@ -8982,25 +8997,25 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class * item = PyObject_GetAttrString(py_class, "__dict__"); */ if (pyrna_deferred_register_class(srna_new, (PyTypeObject *)py_class) != 0) { - return NULL; + return nullptr; } /* Call classed register method. * Note that zero falls through, no attribute, no error. */ switch (_PyObject_LookupAttr(py_class, bpy_intern_str_register, &py_cls_meth)) { case 1: { - PyObject *ret = PyObject_CallObject(py_cls_meth, NULL); + PyObject *ret = PyObject_CallObject(py_cls_meth, nullptr); Py_DECREF(py_cls_meth); if (ret) { Py_DECREF(ret); } else { - return NULL; + return nullptr; } break; } case -1: { - return NULL; + return nullptr; } } @@ -9017,11 +9032,11 @@ static int pyrna_srna_contains_pointer_prop_srna(StructRNA *srna_props, /* Verify properties. */ const ListBase *lb = RNA_struct_type_properties(srna); - for (link = lb->first; link; link = link->next) { + for (link = static_cast(lb->first); link; link = link->next) { prop = (PropertyRNA *)link; if (RNA_property_type(prop) == PROP_POINTER && !RNA_property_builtin(prop)) { PointerRNA tptr; - RNA_pointer_create(NULL, &RNA_Struct, srna_props, &tptr); + RNA_pointer_create(nullptr, &RNA_Struct, srna_props, &tptr); if (RNA_property_pointer_type(&tptr, prop) == srna) { *r_prop_identifier = RNA_property_identifier(prop); @@ -9046,9 +9061,9 @@ PyMethodDef meth_bpy_unregister_class = { METH_O, pyrna_unregister_class_doc, }; -static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_class) +static PyObject *pyrna_unregister_class(PyObject * /*self*/, PyObject *py_class) { - bContext *C = NULL; + bContext *C = nullptr; StructUnregisterFunc unreg; StructRNA *srna; PyObject *py_cls_meth; @@ -9058,14 +9073,14 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla "register_class(...): " "expected a class argument, not '%.200s'", Py_TYPE(py_class)->tp_name); - return NULL; + return nullptr; } #if 0 - if (PyDict_GetItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna) == NULL) { + if (PyDict_GetItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna) == nullptr) { PWM_cursor_wait(false); PyErr_SetString(PyExc_ValueError, "unregister_class(): not a registered as a subclass"); - return NULL; + return nullptr; } #endif @@ -9074,12 +9089,12 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla "unregister_class(...): " "can't run in readonly state '%.200s'", ((PyTypeObject *)py_class)->tp_name); - return NULL; + return nullptr; } srna = pyrna_struct_as_srna(py_class, false, "unregister_class(...):"); - if (srna == NULL) { - return NULL; + if (srna == nullptr) { + return nullptr; } /* Check that we have a unregister callback for this type. */ @@ -9090,25 +9105,25 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla PyExc_ValueError, "unregister_class(...): " "expected a Type subclassed from a registerable RNA type (no unregister supported)"); - return NULL; + return nullptr; } /* Call classed unregister method. * Note that zero falls through, no attribute, no error. */ switch (_PyObject_LookupAttr(py_class, bpy_intern_str_unregister, &py_cls_meth)) { case 1: { - PyObject *ret = PyObject_CallObject(py_cls_meth, NULL); + PyObject *ret = PyObject_CallObject(py_cls_meth, nullptr); Py_DECREF(py_cls_meth); if (ret) { Py_DECREF(ret); } else { - return NULL; + return nullptr; } break; } case -1: { - return NULL; + return nullptr; } } @@ -9118,14 +9133,14 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla StructRNA *srna_iter; PointerRNA ptr_rna; PropertyRNA *prop_rna; - const char *prop_identifier = NULL; + const char *prop_identifier = nullptr; RNA_blender_rna_pointer_create(&ptr_rna); prop_rna = RNA_struct_find_property(&ptr_rna, "structs"); /* Loop over all structs. */ RNA_PROP_BEGIN (&ptr_rna, itemptr, prop_rna) { - srna_iter = itemptr.data; + srna_iter = static_cast(itemptr.data); if (pyrna_srna_contains_pointer_prop_srna(srna_iter, srna, &prop_identifier)) { break; } @@ -9139,7 +9154,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla RNA_struct_identifier(srna), RNA_struct_identifier(srna_iter), prop_identifier); - return NULL; + return nullptr; } } @@ -9151,7 +9166,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla PyDict_DelItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna); if (PyErr_Occurred()) { - PyErr_Clear(); // return NULL; + PyErr_Clear(); // return nullptr; } Py_RETURN_NONE; @@ -9162,8 +9177,8 @@ void pyrna_struct_type_extend_capi(StructRNA *srna, PyMethodDef *method, PyGetSe /* See 'add_methods' in Python's 'typeobject.c'. */ PyTypeObject *type = (PyTypeObject *)pyrna_srna_Subtype(srna); PyObject *dict = type->tp_dict; - if (method != NULL) { - for (; method->ml_name != NULL; method++) { + if (method != nullptr) { + for (; method->ml_name != nullptr; method++) { PyObject *py_method; if (method->ml_flags & METH_CLASS) { @@ -9172,7 +9187,7 @@ void pyrna_struct_type_extend_capi(StructRNA *srna, PyMethodDef *method, PyGetSe Py_DECREF(cfunc); } else if (method->ml_flags & METH_STATIC) { - py_method = PyCFunction_New(method, NULL); + py_method = PyCFunction_New(method, nullptr); } else { py_method = PyDescr_NewMethod(type, method); @@ -9185,11 +9200,11 @@ void pyrna_struct_type_extend_capi(StructRNA *srna, PyMethodDef *method, PyGetSe } } - if (getset != NULL) { - for (; getset->name != NULL; getset++) { + if (getset != nullptr) { + for (; getset->name != nullptr; getset++) { PyObject *descr = PyDescr_NewGetSet(type, getset); /* Ensure we're not overwriting anything that already exists. */ - BLI_assert(PyDict_GetItem(dict, PyDescr_NAME(descr)) == NULL); + BLI_assert(PyDict_GetItem(dict, PyDescr_NAME(descr)) == nullptr); PyDict_SetItem(dict, PyDescr_NAME(descr), descr); Py_DECREF(descr); } @@ -9199,7 +9214,7 @@ void pyrna_struct_type_extend_capi(StructRNA *srna, PyMethodDef *method, PyGetSe /* Access to 'owner_id' internal global. */ -static PyObject *pyrna_bl_owner_id_get(PyObject *UNUSED(self)) +static PyObject *pyrna_bl_owner_id_get(PyObject * /*self*/) { const char *name = RNA_struct_state_owner_get(); if (name) { @@ -9208,11 +9223,11 @@ static PyObject *pyrna_bl_owner_id_get(PyObject *UNUSED(self)) Py_RETURN_NONE; } -static PyObject *pyrna_bl_owner_id_set(PyObject *UNUSED(self), PyObject *value) +static PyObject *pyrna_bl_owner_id_set(PyObject * /*self*/, PyObject *value) { const char *name; if (value == Py_None) { - name = NULL; + name = nullptr; } else if (PyUnicode_Check(value)) { name = PyUnicode_AsUTF8(value); @@ -9222,7 +9237,7 @@ static PyObject *pyrna_bl_owner_id_set(PyObject *UNUSED(self), PyObject *value) "owner_set(...): " "expected None or a string, not '%.200s'", Py_TYPE(value)->tp_name); - return NULL; + return nullptr; } RNA_struct_state_owner_set(name); Py_RETURN_NONE; @@ -9232,11 +9247,11 @@ PyMethodDef meth_bpy_owner_id_get = { "_bl_owner_id_get", (PyCFunction)pyrna_bl_owner_id_get, METH_NOARGS, - NULL, + nullptr, }; PyMethodDef meth_bpy_owner_id_set = { "_bl_owner_id_set", (PyCFunction)pyrna_bl_owner_id_set, METH_O, - NULL, + nullptr, }; diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 71b42986ed6..acb9df35df4 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -109,7 +109,7 @@ typedef struct { PointerRNA ptr; } BPy_DummyPointerRNA; -typedef struct { +typedef struct BPy_StructRNA { PyObject_HEAD /* Required Python macro. */ #ifdef USE_WEAKREFS PyObject *in_weakreflist; diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.cc similarity index 92% rename from source/blender/python/intern/bpy_rna_anim.c rename to source/blender/python/intern/bpy_rna_anim.cc index 5ac6018249c..dbf373ff212 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.cc @@ -62,7 +62,7 @@ static int pyrna_struct_anim_args_parse_ex(PointerRNA *ptr, PropertyRNA *prop; PointerRNA r_ptr; - if (ptr->data == NULL) { + if (ptr->data == nullptr) { PyErr_Format( PyExc_TypeError, "%.200s this struct has no data, can't be animated", error_prefix); return -1; @@ -72,7 +72,7 @@ static int pyrna_struct_anim_args_parse_ex(PointerRNA *ptr, if (is_idbase) { int path_index = -1; if (RNA_path_resolve_property_full(ptr, path, &r_ptr, &prop, &path_index) == false) { - prop = NULL; + prop = nullptr; } else if (path_index != -1) { PyErr_Format(PyExc_ValueError, @@ -91,7 +91,7 @@ static int pyrna_struct_anim_args_parse_ex(PointerRNA *ptr, r_ptr = *ptr; } - if (prop == NULL) { + if (prop == nullptr) { if (r_path_no_validate) { *r_path_no_validate = true; return -1; @@ -142,7 +142,7 @@ static int pyrna_struct_anim_args_parse_ex(PointerRNA *ptr, else { *r_path_full = RNA_path_from_ID_to_property(&r_ptr, prop); - if (*r_path_full == NULL) { + if (*r_path_full == nullptr) { PyErr_Format(PyExc_TypeError, "%.200s could not make path to \"%s\"", error_prefix, path); return -1; } @@ -157,7 +157,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char **r_path_full, int *r_index) { - return pyrna_struct_anim_args_parse_ex(ptr, error_prefix, path, r_path_full, r_index, NULL); + return pyrna_struct_anim_args_parse_ex(ptr, error_prefix, path, r_path_full, r_index, nullptr); } /** @@ -175,7 +175,7 @@ static int pyrna_struct_anim_args_parse_no_resolve(PointerRNA *ptr, } char *path_prefix = RNA_path_from_ID_to_struct(ptr); - if (path_prefix == NULL) { + if (path_prefix == nullptr) { PyErr_Format(PyExc_TypeError, "%.200s could not make path for type %s", error_prefix, @@ -229,8 +229,8 @@ static int pyrna_struct_keyframe_parse(PointerRNA *ptr, const char **r_group_name, int *r_options) { - static const char *kwlist[] = {"data_path", "index", "frame", "group", "options", NULL}; - PyObject *pyoptions = NULL; + static const char *kwlist[] = {"data_path", "index", "frame", "group", "options", nullptr}; + PyObject *pyoptions = nullptr; const char *path; /* NOTE: `parse_str` MUST start with `s|ifsO!`. */ @@ -307,10 +307,10 @@ char pyrna_struct_keyframe_insert_doc[] = PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyObject *kw) { /* args, pyrna_struct_keyframe_parse handles these */ - const char *path_full = NULL; + const char *path_full = nullptr; int index = -1; float cfra = FLT_MAX; - const char *group_name = NULL; + const char *group_name = nullptr; const char keytype = BEZT_KEYTYPE_KEYFRAME; /* XXX: Expose this as a one-off option... */ int options = 0; @@ -327,7 +327,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb &group_name, &options) == -1) { - return NULL; + return nullptr; } ReportList reports; @@ -354,7 +354,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb */ PointerRNA ptr = self->ptr; - PropertyRNA *prop = NULL; + PropertyRNA *prop = nullptr; const char *prop_name; /* Retrieve the property identifier from the full path, since we can't get it any other way */ @@ -364,10 +364,16 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb } if (prop) { - NlaStrip *strip = ptr.data; + NlaStrip *strip = static_cast(ptr.data); FCurve *fcu = BKE_fcurve_find(&strip->fcurves, RNA_property_identifier(prop), index); - result = insert_keyframe_direct( - &reports, ptr, prop, fcu, &anim_eval_context, keytype, NULL, options); + result = insert_keyframe_direct(&reports, + ptr, + prop, + fcu, + &anim_eval_context, + eBezTriple_KeyframeType(keytype), + nullptr, + eInsertKeyFlags(options)); } else { BKE_reportf(&reports, RPT_ERROR, "Could not resolve path (%s)", path_full); @@ -380,24 +386,24 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb result = (insert_keyframe(G_MAIN, &reports, id, - NULL, + nullptr, group_name, path_full, index, &anim_eval_context, - keytype, - NULL, - options) != 0); + eBezTriple_KeyframeType(keytype), + nullptr, + eInsertKeyFlags(options)) != 0); } MEM_freeN((void *)path_full); if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { - return NULL; + return nullptr; } if (result) { - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); } return PyBool_FromLong(result); @@ -425,10 +431,10 @@ char pyrna_struct_keyframe_delete_doc[] = PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyObject *kw) { /* args, pyrna_struct_keyframe_parse handles these */ - const char *path_full = NULL; + const char *path_full = nullptr; int index = -1; float cfra = FLT_MAX; - const char *group_name = NULL; + const char *group_name = nullptr; PYRNA_STRUCT_CHECK_OBJ(self); @@ -441,9 +447,9 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb &index, &cfra, &group_name, - NULL) == -1) + nullptr) == -1) { - return NULL; + return nullptr; } ReportList reports; @@ -458,7 +464,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb */ PointerRNA ptr = self->ptr; - PropertyRNA *prop = NULL; + PropertyRNA *prop = nullptr; const char *prop_name; /* Retrieve the property identifier from the full path, since we can't get it any other way */ @@ -469,11 +475,11 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb if (prop) { ID *id = ptr.owner_id; - NlaStrip *strip = ptr.data; + NlaStrip *strip = static_cast(ptr.data); FCurve *fcu = BKE_fcurve_find(&strip->fcurves, RNA_property_identifier(prop), index); /* NOTE: This should be true, or else we wouldn't be able to get here. */ - BLI_assert(fcu != NULL); + BLI_assert(fcu != nullptr); if (BKE_fcurve_is_protected(fcu)) { BKE_reportf( @@ -508,13 +514,13 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb } else { result = (delete_keyframe( - G.main, &reports, self->ptr.owner_id, NULL, path_full, index, cfra) != 0); + G.main, &reports, self->ptr.owner_id, nullptr, path_full, index, cfra) != 0); } MEM_freeN((void *)path_full); if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { - return NULL; + return nullptr; } return PyBool_FromLong(result); @@ -540,16 +546,16 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args) PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index)) { - return NULL; + return nullptr; } if (pyrna_struct_anim_args_parse( &self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) == -1) { - return NULL; + return nullptr; } - PyObject *ret = NULL; + PyObject *ret = nullptr; ReportList reports; int result; @@ -563,7 +569,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args) DRIVER_TYPE_PYTHON); if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { - return NULL; + return nullptr; } if (result) { @@ -588,7 +594,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args) } bContext *context = BPY_context_get(); - WM_event_add_notifier(BPY_context_get(), NC_ANIMATION | ND_FCURVES_ORDER, NULL); + WM_event_add_notifier(BPY_context_get(), NC_ANIMATION | ND_FCURVES_ORDER, nullptr); DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE); DEG_relations_tag_update(CTX_data_main(context)); } @@ -596,7 +602,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args) /* XXX: should be handled by reports. */ PyErr_SetString(PyExc_TypeError, "bpy_struct.driver_add(): failed because of an internal error"); - return NULL; + return nullptr; } MEM_freeN((void *)path_full); @@ -624,13 +630,13 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args) PYRNA_STRUCT_CHECK_OBJ(self); if (!PyArg_ParseTuple(args, "s|i:driver_remove", &path, &index)) { - return NULL; + return nullptr; } if (pyrna_struct_anim_args_parse_no_resolve_fallback( &self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) { - return NULL; + return nullptr; } short result; @@ -645,11 +651,11 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args) } if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { - return NULL; + return nullptr; } bContext *context = BPY_context_get(); - WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, NULL); + WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, nullptr); DEG_relations_tag_update(CTX_data_main(context)); return PyBool_FromLong(result); diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.cc similarity index 94% rename from source/blender/python/intern/bpy_rna_array.c rename to source/blender/python/intern/bpy_rna_array.cc index 48900726c99..54204ed275b 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.cc @@ -55,10 +55,10 @@ struct ItemConvertArgData { /** * Callback and args needed to apply the value (clamp range for now) */ -typedef struct ItemConvert_FuncArg { +struct ItemConvert_FuncArg { ItemConvertFunc func; struct ItemConvertArgData arg; -} ItemConvert_FuncArg; +}; /* * arr[3][4][5] @@ -105,7 +105,7 @@ static int validate_array_type(PyObject *seq, bool ok = true; item = PySequence_GetItem(seq, i); - if (item == NULL) { + if (item == nullptr) { PyErr_Format(PyExc_TypeError, "%s sequence type '%s' failed to retrieve index %d", error_prefix, @@ -182,7 +182,7 @@ static int validate_array_type(PyObject *seq, for (i = 0; i < seq_size; i++) { PyObject *item = PySequence_GetItem(seq, i); - if (item == NULL) { + if (item == nullptr) { PyErr_Format(PyExc_TypeError, "%s sequence type '%s' failed to retrieve index %d", error_prefix, @@ -194,8 +194,7 @@ static int validate_array_type(PyObject *seq, Py_DECREF(item); #if 0 - SNPRINTF( - error_str, "sequence items should be of type %s", item_type_str); + SNPRINTF(error_str, "sequence items should be of type %s", item_type_str); #endif PyErr_Format(PyExc_TypeError, "%s expected sequence items of type %s, not %s", @@ -429,7 +428,7 @@ static char *copy_value_single(PyObject *item, float fl; int i; } value_buf; - char *value = (void *)&value_buf; + char *value = static_cast((void *)&value_buf); convert_item->func(&convert_item->arg, item, value); rna_set_index(ptr, prop, *index, value); @@ -453,21 +452,21 @@ static char *copy_values(PyObject *seq, const ItemConvert_FuncArg *convert_item, RNA_SetIndexFunc rna_set_index) { - const int totdim = RNA_property_array_dimension(ptr, prop, NULL); + const int totdim = RNA_property_array_dimension(ptr, prop, nullptr); const Py_ssize_t seq_size = PySequence_Size(seq); Py_ssize_t i; /* Regarding PySequence_GetItem() failing. * - * This should never be NULL since we validated it, _but_ some tricky python + * This should never be nullptr since we validated it, _but_ some tricky python * developer could write their own sequence type which succeeds on * validating but fails later somehow, so include checks for safety. */ - /* Note that 'data can be NULL' */ + /* Note that 'data can be nullptr' */ if (seq_size == -1) { - return NULL; + return nullptr; } #ifdef USE_MATHUTILS @@ -502,10 +501,10 @@ static char *copy_values(PyObject *seq, Py_DECREF(item); - /* data may be NULL, but the for loop checks */ + /* data may be nullptr, but the for loop checks */ } else { - return NULL; + return nullptr; } } @@ -525,7 +524,7 @@ static int py_to_array(PyObject *seq, { // int totdim, dim_size[MAX_ARRAY_DIMENSION]; int totitem; - char *data = NULL; + char *data = nullptr; // totdim = RNA_property_array_dimension(ptr, prop, dim_size); /* UNUSED */ const int flag = RNA_property_flag(prop); @@ -556,26 +555,27 @@ static int py_to_array(PyObject *seq, /* freeing param list will free */ param_alloc->array = MEM_callocN(item_size * totitem, "py_to_array dyn"); - data = param_alloc->array; + data = static_cast(param_alloc->array); } else if (param_data) { data = param_data; } else { - data = PyMem_MALLOC(item_size * totitem); + data = static_cast(PyMem_MALLOC(item_size * totitem)); } /* will only fail in very rare cases since we already validated the * python data, the check here is mainly for completeness. */ - if (copy_values(seq, ptr, prop, 0, data, item_size, NULL, convert_item, NULL) != NULL) { - if (param_data == NULL) { - /* NULL can only pass through in case RNA property array-length is 0 (impossible?) */ + if (copy_values(seq, ptr, prop, 0, data, item_size, nullptr, convert_item, nullptr) != nullptr) + { + if (param_data == nullptr) { + /* nullptr can only pass through in case RNA property array-length is 0 (impossible?) */ rna_set_array(ptr, prop, data); PyMem_FREE(data); } } else { - if (param_data == NULL) { + if (param_data == nullptr) { PyMem_FREE(data); } @@ -636,7 +636,7 @@ static int py_to_array_index(PyObject *py, Py_TYPE(py)->tp_name); return -1; } - copy_value_single(py, ptr, prop, NULL, 0, &index, convert_item, rna_set_index); + copy_value_single(py, ptr, prop, nullptr, 0, &index, convert_item, rna_set_index); } else { const bool prop_is_param_dyn_alloc = false; @@ -654,7 +654,7 @@ static int py_to_array_index(PyObject *py, } if (totitem) { - copy_values(py, ptr, prop, lvalue_dim, NULL, 0, &index, convert_item, rna_set_index); + copy_values(py, ptr, prop, lvalue_dim, nullptr, 0, &index, convert_item, rna_set_index); } } return 0; @@ -676,7 +676,7 @@ static void py_to_int(const struct ItemConvertArgData *arg, PyObject *py, char * *(int *)data = value; } -static void py_to_bool(const struct ItemConvertArgData *UNUSED(arg), PyObject *py, char *data) +static void py_to_bool(const struct ItemConvertArgData * /*arg*/, PyObject *py, char *data) { *(bool *)data = (bool)PyObject_IsTrue(py); } @@ -731,8 +731,8 @@ static void convert_item_init_int(PointerRNA *ptr, RNA_property_int_range(ptr, prop, &range[0], &range[1]); } -static void convert_item_init_bool(PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), +static void convert_item_init_bool(PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, ItemConvert_FuncArg *convert_item) { convert_item->func = py_to_bool; @@ -888,7 +888,7 @@ PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index) break; default: PyErr_SetString(PyExc_TypeError, "not an array type"); - item = NULL; + item = nullptr; break; } @@ -905,7 +905,7 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, { PyObject *tuple; int i, len; - int totdim = RNA_property_array_dimension(ptr, prop, NULL); + int totdim = RNA_property_array_dimension(ptr, prop, nullptr); len = RNA_property_multi_array_length(ptr, prop, dim); @@ -924,7 +924,7 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, if (!item) { Py_DECREF(tuple); - return NULL; + return nullptr; } PyTuple_SET_ITEM(tuple, i, item); @@ -940,7 +940,7 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, int index) { int totdim, arraydim, arrayoffset, dimsize[MAX_ARRAY_DIMENSION], i, len; - BPy_PropertyArrayRNA *ret = NULL; + BPy_PropertyArrayRNA *ret = nullptr; arraydim = self ? self->arraydim : 0; arrayoffset = self ? self->arrayoffset : 0; @@ -952,7 +952,7 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, CLOG_WARN(BPY_LOG_RNA, "invalid index %d for array with length=%d", index, len); PyErr_SetString(PyExc_IndexError, "out of range"); - return NULL; + return nullptr; } totdim = RNA_property_array_dimension(ptr, prop, dimsize); @@ -1010,7 +1010,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) return 0; } - if (RNA_property_array_dimension(ptr, prop, NULL) > 1) { + if (RNA_property_array_dimension(ptr, prop, nullptr) > 1) { PyErr_SetString(PyExc_TypeError, "PropertyRNA - multi dimensional arrays not supported yet"); return -1; } @@ -1029,7 +1029,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) float *tmp_arr; if (len * sizeof(float) > sizeof(tmp)) { - tmp_arr = PyMem_MALLOC(len * sizeof(float)); + tmp_arr = static_cast(PyMem_MALLOC(len * sizeof(float))); } else { tmp_arr = tmp; @@ -1062,7 +1062,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) int *tmp_arr; if (len * sizeof(int) > sizeof(tmp)) { - tmp_arr = PyMem_MALLOC(len * sizeof(int)); + tmp_arr = static_cast(PyMem_MALLOC(len * sizeof(int))); } else { tmp_arr = tmp; @@ -1095,7 +1095,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) bool *tmp_arr; if (len * sizeof(bool) > sizeof(tmp)) { - tmp_arr = PyMem_MALLOC(len * sizeof(bool)); + tmp_arr = static_cast(PyMem_MALLOC(len * sizeof(bool))); } else { tmp_arr = tmp; @@ -1104,7 +1104,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) RNA_property_boolean_get_array(ptr, prop, tmp_arr); for (i = 0; i < len; i++) { - if (tmp_arr[i] == value_i) { + if (tmp_arr[i] == bool(value_i)) { break; } } diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.cc similarity index 83% rename from source/blender/python/intern/bpy_rna_callback.c rename to source/blender/python/intern/bpy_rna_callback.cc index 5cb2c42f6d3..0fcee3efe45 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.cc @@ -41,10 +41,10 @@ static const EnumPropertyItem region_draw_mode_items[] = { {REGION_DRAW_POST_VIEW, "POST_VIEW", 0, "Post View", ""}, {REGION_DRAW_PRE_VIEW, "PRE_VIEW", 0, "Pre View", ""}, {REGION_DRAW_BACKDROP, "BACKDROP", 0, "Backdrop", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; -static void cb_region_draw(const bContext *C, ARegion *UNUSED(region), void *customdata) +static void cb_region_draw(const bContext *C, ARegion * /*region*/, void *customdata) { PyObject *cb_func, *cb_args, *result; PyGILState_STATE gilstate; @@ -119,29 +119,26 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args) void *handle; PyObject *cb_func, *cb_args; - char *cb_event_str = NULL; + char *cb_event_str = nullptr; int cb_event; - if (!PyArg_ParseTuple(args, - "OO!|s:bpy_struct.callback_add", - &cb_func, - &PyTuple_Type, - &cb_args, - &cb_event_str)) { - return NULL; + if (!PyArg_ParseTuple( + args, "OO!|s:bpy_struct.callback_add", &cb_func, &PyTuple_Type, &cb_args, &cb_event_str)) + { + return nullptr; } if (!PyCallable_Check(cb_func)) { PyErr_SetString(PyExc_TypeError, "callback_add(): first argument isn't callable"); - return NULL; + return nullptr; } if (RNA_struct_is_a(self->ptr.type, &RNA_Region)) { if (cb_event_str) { if (pyrna_enum_value_from_id( - region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") == - -1) { - return NULL; + region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") == -1) + { + return nullptr; } } else { @@ -154,10 +151,10 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args) } else { PyErr_SetString(PyExc_TypeError, "callback_add(): type does not support callbacks"); - return NULL; + return nullptr; } - return PyCapsule_New((void *)handle, rna_capsual_id, NULL); + return PyCapsule_New((void *)handle, rna_capsual_id, nullptr); } PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args) @@ -167,15 +164,15 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args) void *customdata; if (!PyArg_ParseTuple(args, "O!:callback_remove", &PyCapsule_Type, &py_handle)) { - return NULL; + return nullptr; } handle = PyCapsule_GetPointer(py_handle, rna_capsual_id); - if (handle == NULL) { + if (handle == nullptr) { PyErr_SetString(PyExc_ValueError, - "callback_remove(handle): NULL handle given, invalid or already removed"); - return NULL; + "callback_remove(handle): nullptr handle given, invalid or already removed"); + return nullptr; } if (RNA_struct_is_a(self->ptr.type, &RNA_Region)) { @@ -186,7 +183,7 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args) } else { PyErr_SetString(PyExc_TypeError, "callback_remove(): type does not support callbacks"); - return NULL; + return nullptr; } /* don't allow reuse */ @@ -252,11 +249,11 @@ static eSpace_Type rna_Space_refine_reverse(StructRNA *srna) static void cb_rna_capsule_destructor(PyObject *capsule) { - PyObject *args = PyCapsule_GetContext(capsule); + PyObject *args = static_cast(PyCapsule_GetContext(capsule)); Py_DECREF(args); } -PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) +PyObject *pyrna_callback_classmethod_add(PyObject * /*self*/, PyObject *args) { void *handle; PyObject *cls; @@ -265,17 +262,17 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) if (PyTuple_GET_SIZE(args) < 2) { PyErr_SetString(PyExc_ValueError, "handler_add(handler): expected at least 2 args"); - return NULL; + return nullptr; } cls = PyTuple_GET_ITEM(args, 0); if (!(srna = pyrna_struct_as_srna(cls, false, "handler_add"))) { - return NULL; + return nullptr; } cb_func = PyTuple_GET_ITEM(args, 1); if (!PyCallable_Check(cb_func)) { PyErr_SetString(PyExc_TypeError, "first argument isn't callable"); - return NULL; + return nullptr; } /* class specific callbacks */ @@ -284,10 +281,11 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) struct { struct BPy_EnumProperty_Parse space_type_enum; struct BPy_EnumProperty_Parse region_type_enum; - } params = { - .space_type_enum = {.items = rna_enum_space_type_items, .value = SPACE_TYPE_ANY}, - .region_type_enum = {.items = rna_enum_region_type_items, .value = RGN_TYPE_ANY}, - }; + } params{}; + params.space_type_enum.items = rna_enum_space_type_items; + params.space_type_enum.value = SPACE_TYPE_ANY; + params.region_type_enum.items = rna_enum_region_type_items; + params.region_type_enum.value = RGN_TYPE_ANY; if (!PyArg_ParseTuple(args, "OOO!|O&O&:WindowManager.draw_cursor_add", @@ -300,12 +298,12 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) pyrna_enum_value_parse_string, ¶ms.region_type_enum)) { - return NULL; + return nullptr; } handle = WM_paint_cursor_activate(params.space_type_enum.value, params.region_type_enum.value, - NULL, + nullptr, cb_wm_cursor_draw, (void *)args); } @@ -313,10 +311,9 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) struct { struct BPy_EnumProperty_Parse region_type_enum; struct BPy_EnumProperty_Parse event_enum; - } params = { - .region_type_enum = {.items = rna_enum_region_type_items}, - .event_enum = {.items = region_draw_mode_items}, - }; + } params{}; + params.region_type_enum.items = rna_enum_region_type_items; + params.event_enum.items = region_draw_mode_items; if (!PyArg_ParseTuple(args, "OOO!O&O&:Space.draw_handler_add", @@ -329,35 +326,35 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) pyrna_enum_value_parse_string, ¶ms.event_enum)) { - return NULL; + return nullptr; } 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; + return nullptr; } SpaceType *st = BKE_spacetype_from_id(spaceid); ARegionType *art = BKE_regiontype_from_id(st, params.region_type_enum.value); - if (art == NULL) { + if (art == nullptr) { PyErr_Format( PyExc_TypeError, "region type %R not in space", params.region_type_enum.value_orig); - return NULL; + return nullptr; } handle = ED_region_draw_cb_activate( art, cb_region_draw, (void *)args, params.event_enum.value); } else { PyErr_SetString(PyExc_TypeError, "callback_add(): type does not support callbacks"); - return NULL; + return nullptr; } /* Keep the 'args' reference as long as the callback exists. * This reference is decremented in #BPY_callback_screen_free and #BPY_callback_wm_free. */ Py_INCREF(args); - PyObject *ret = PyCapsule_New((void *)handle, rna_capsual_id, NULL); + PyObject *ret = PyCapsule_New((void *)handle, rna_capsual_id, nullptr); /* Store 'args' in context as well for simple access. */ PyCapsule_SetDestructor(ret, cb_rna_capsule_destructor); @@ -367,7 +364,7 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) return ret; } -PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *args) +PyObject *pyrna_callback_classmethod_remove(PyObject * /*self*/, PyObject *args) { PyObject *cls; PyObject *py_handle; @@ -378,37 +375,36 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar if (PyTuple_GET_SIZE(args) < 2) { PyErr_SetString(PyExc_ValueError, "callback_remove(handler): expected at least 2 args"); - return NULL; + return nullptr; } cls = PyTuple_GET_ITEM(args, 0); if (!(srna = pyrna_struct_as_srna(cls, false, "callback_remove"))) { - return NULL; + return nullptr; } py_handle = PyTuple_GET_ITEM(args, 1); handle = PyCapsule_GetPointer(py_handle, rna_capsual_id); - if (handle == NULL) { + if (handle == nullptr) { PyErr_SetString(PyExc_ValueError, - "callback_remove(handler): NULL handler given, invalid or already removed"); - return NULL; + "callback_remove(handler): nullptr handler given, invalid or already removed"); + return nullptr; } if (srna == &RNA_WindowManager) { if (!PyArg_ParseTuple( args, "OO!:WindowManager.draw_cursor_remove", &cls, &PyCapsule_Type, &py_handle)) { - return NULL; + return nullptr; } - handle_removed = WM_paint_cursor_end(handle); + handle_removed = WM_paint_cursor_end(static_cast(handle)); capsule_clear = true; } else if (RNA_struct_is_a(srna, &RNA_Space)) { const char *error_prefix = "Space.draw_handler_remove"; struct { struct BPy_EnumProperty_Parse region_type_enum; - } params = { - .region_type_enum = {.items = rna_enum_region_type_items}, - }; + } params{}; + params.region_type_enum.items = rna_enum_region_type_items; if (!PyArg_ParseTuple(args, "OO!O&:Space.draw_handler_remove", @@ -418,7 +414,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar pyrna_enum_value_parse_string, ¶ms.region_type_enum)) { - return NULL; + return nullptr; } const eSpace_Type spaceid = rna_Space_refine_reverse(srna); @@ -427,24 +423,24 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar "%s: unknown space type '%.200s'", error_prefix, RNA_struct_identifier(srna)); - return NULL; + return nullptr; } SpaceType *st = BKE_spacetype_from_id(spaceid); ARegionType *art = BKE_regiontype_from_id(st, params.region_type_enum.value); - if (art == NULL) { + if (art == nullptr) { PyErr_Format(PyExc_TypeError, "%s: region type %R not in space", error_prefix, params.region_type_enum.value_orig); - return NULL; + return nullptr; } handle_removed = ED_region_draw_cb_exit(art, handle); capsule_clear = true; } else { PyErr_SetString(PyExc_TypeError, "callback_remove(): type does not support callbacks"); - return NULL; + return nullptr; } /* When `handle_removed == false`: Blender has already freed the data @@ -452,7 +448,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar * This will have already decremented the user, so don't decrement twice. */ if (handle_removed == true) { /* The handle has been removed, so decrement its custom-data. */ - PyObject *handle_args = PyCapsule_GetContext(py_handle); + PyObject *handle_args = static_cast(PyCapsule_GetContext(py_handle)); Py_DECREF(handle_args); } @@ -461,7 +457,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar PyCapsule_Destructor destructor_fn = PyCapsule_GetDestructor(py_handle); if (destructor_fn) { destructor_fn(py_handle); - PyCapsule_SetDestructor(py_handle, NULL); + PyCapsule_SetDestructor(py_handle, nullptr); } PyCapsule_SetName(py_handle, rna_capsual_id_invalid); } @@ -475,7 +471,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar static void cb_customdata_free(void *customdata) { - PyObject *tuple = customdata; + PyObject *tuple = static_cast(customdata); bool use_gil = true; /* !PyC_IsInterpreterActive(); */ PyGILState_STATE gilstate; @@ -492,12 +488,14 @@ static void cb_customdata_free(void *customdata) void BPY_callback_screen_free(ARegionType *art) { - ED_region_draw_cb_remove_by_type(art, cb_region_draw, cb_customdata_free); + ED_region_draw_cb_remove_by_type( + art, reinterpret_cast(cb_region_draw), cb_customdata_free); } void BPY_callback_wm_free(wmWindowManager *wm) { - WM_paint_cursor_remove_by_type(wm, cb_wm_cursor_draw, cb_customdata_free); + WM_paint_cursor_remove_by_type( + wm, reinterpret_cast(cb_wm_cursor_draw), cb_customdata_free); } /** \} */ diff --git a/source/blender/python/intern/bpy_rna_callback.h b/source/blender/python/intern/bpy_rna_callback.h index b83b45aec88..257ee17714b 100644 --- a/source/blender/python/intern/bpy_rna_callback.h +++ b/source/blender/python/intern/bpy_rna_callback.h @@ -9,7 +9,6 @@ */ struct BPy_StructRNA; -struct PyObject; #ifdef __cplusplus extern "C" { diff --git a/source/blender/python/intern/bpy_rna_context.c b/source/blender/python/intern/bpy_rna_context.cc similarity index 77% rename from source/blender/python/intern/bpy_rna_context.c rename to source/blender/python/intern/bpy_rna_context.cc index 0ce6f417896..e7e2c16f0a3 100644 --- a/source/blender/python/intern/bpy_rna_context.c +++ b/source/blender/python/intern/bpy_rna_context.cc @@ -29,16 +29,16 @@ /** \name Temporary Context Override (Python Context Manager) * \{ */ -typedef struct ContextStore { +struct ContextStore { wmWindow *win; bool win_is_set; ScrArea *area; bool area_is_set; ARegion *region; bool region_is_set; -} ContextStore; +}; -typedef struct BPyContextTempOverride { +struct BPyContextTempOverride { PyObject_HEAD /* Required Python macro. */ bContext *context; @@ -55,7 +55,7 @@ typedef struct BPyContextTempOverride { * will overlay the new members on the old members (instead of ignoring them). */ PyObject *py_state_context_dict; -} BPyContextTempOverride; +}; static void bpy_rna_context_temp_override__tp_dealloc(BPyContextTempOverride *self) { @@ -76,32 +76,32 @@ static PyObject *bpy_rna_context_temp_override_enter(BPyContextTempOverride *sel self->ctx_init.region_is_set = (self->ctx_init.region != self->ctx_temp.region); wmWindow *win = self->ctx_temp.win_is_set ? self->ctx_temp.win : self->ctx_init.win; - bScreen *screen = win ? WM_window_get_active_screen(win) : NULL; + bScreen *screen = win ? WM_window_get_active_screen(win) : nullptr; ScrArea *area = self->ctx_temp.area_is_set ? self->ctx_temp.area : self->ctx_init.area; ARegion *region = self->ctx_temp.region_is_set ? self->ctx_temp.region : self->ctx_init.region; /* Sanity check, the region is in the screen/area. */ - if (self->ctx_temp.region_is_set && (region != NULL)) { - if (area == NULL) { - PyErr_SetString(PyExc_TypeError, "Region set with NULL area"); - return NULL; + if (self->ctx_temp.region_is_set && (region != nullptr)) { + if (area == nullptr) { + PyErr_SetString(PyExc_TypeError, "Region set with nullptr area"); + return nullptr; } if ((screen && BLI_findindex(&screen->regionbase, region) == -1) && (BLI_findindex(&area->regionbase, region) == -1)) { PyErr_SetString(PyExc_TypeError, "Region not found in area"); - return NULL; + return nullptr; } } - if (self->ctx_temp.area_is_set && (area != NULL)) { - if (screen == NULL) { - PyErr_SetString(PyExc_TypeError, "Area set with NULL screen"); - return NULL; + if (self->ctx_temp.area_is_set && (area != nullptr)) { + if (screen == nullptr) { + PyErr_SetString(PyExc_TypeError, "Area set with nullptr screen"); + return nullptr; } if (BLI_findindex(&screen->areabase, area) == -1) { PyErr_SetString(PyExc_TypeError, "Area not found in screen"); - return NULL; + return nullptr; } } @@ -119,7 +119,7 @@ static PyObject *bpy_rna_context_temp_override_enter(BPyContextTempOverride *sel } static PyObject *bpy_rna_context_temp_override_exit(BPyContextTempOverride *self, - PyObject *UNUSED(args)) + PyObject * /*args*/) { bContext *C = self->context; @@ -129,7 +129,7 @@ static PyObject *bpy_rna_context_temp_override_exit(BPyContextTempOverride *self if (self->ctx_init.win) { wmWindowManager *wm = CTX_wm_manager(C); if (BLI_findindex(&wm->windows, self->ctx_init.win) == -1) { - CTX_wm_window_set(C, NULL); + CTX_wm_window_set(C, nullptr); do_restore = false; } } @@ -147,7 +147,7 @@ static PyObject *bpy_rna_context_temp_override_exit(BPyContextTempOverride *self } /* A copy may have been made when writing context members, see #BPY_context_dict_clear_members */ - PyObject *context_dict_test = CTX_py_dict_get(C); + PyObject *context_dict_test = static_cast(CTX_py_dict_get(C)); if (context_dict_test && (context_dict_test != self->py_state_context_dict)) { Py_DECREF(context_dict_test); } @@ -160,59 +160,59 @@ static PyObject *bpy_rna_context_temp_override_exit(BPyContextTempOverride *self static PyMethodDef bpy_rna_context_temp_override__tp_methods[] = { {"__enter__", (PyCFunction)bpy_rna_context_temp_override_enter, METH_NOARGS}, {"__exit__", (PyCFunction)bpy_rna_context_temp_override_exit, METH_VARARGS}, - {NULL}, + {nullptr}, }; static PyTypeObject BPyContextTempOverride_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "ContextTempOverride", /*tp_basicsize*/ sizeof(BPyContextTempOverride), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)bpy_rna_context_temp_override__tp_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, - /*tp_repr*/ NULL, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, + /*tp_repr*/ nullptr, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT, - /*tp_doc*/ NULL, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_doc*/ nullptr, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ bpy_rna_context_temp_override__tp_methods, - /*tp_members*/ NULL, - /*tp_getset*/ NULL, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; /** \} */ @@ -257,11 +257,11 @@ PyDoc_STRVAR(bpy_context_temp_override_doc, static PyObject *bpy_context_temp_override(PyObject *self, PyObject *args, PyObject *kwds) { const PointerRNA *context_ptr = pyrna_struct_as_ptr(self, &RNA_Context); - if (context_ptr == NULL) { - return NULL; + if (context_ptr == nullptr) { + return nullptr; } - if (kwds == NULL) { + if (kwds == nullptr) { /* While this is effectively NOP, support having no keywords as it's more involved * to return an alternative (dummy) context manager. */ } @@ -269,21 +269,20 @@ static PyObject *bpy_context_temp_override(PyObject *self, PyObject *args, PyObj /* Needed because the keywords copied into `kwds_parse` could contain anything. * As the types of keys aren't checked. */ if (!PyArg_ValidateKeywordArguments(kwds)) { - return NULL; + return nullptr; } } struct { - struct BPy_StructRNA_Parse window; - struct BPy_StructRNA_Parse area; - struct BPy_StructRNA_Parse region; - } params = { - .window = {.type = &RNA_Window}, - .area = {.type = &RNA_Area}, - .region = {.type = &RNA_Region}, - }; + BPy_StructRNA_Parse window; + BPy_StructRNA_Parse area; + BPy_StructRNA_Parse region; + } params{}; + params.window.type = &RNA_Window; + params.area.type = &RNA_Area; + params.region.type = &RNA_Region; - static const char *const _keywords[] = {"window", "area", "region", NULL}; + static const char *const _keywords[] = {"window", "area", "region", nullptr}; static _PyArg_Parser _parser = { "|$" /* Optional, keyword only arguments. */ "O&" /* `window` */ @@ -309,32 +308,32 @@ static PyObject *bpy_context_temp_override(PyObject *self, PyObject *args, PyObj Py_DECREF(kwds_parse); if (parse_result == -1) { Py_DECREF(kwds); - return NULL; + return nullptr; } } - bContext *C = context_ptr->data; + bContext *C = static_cast(context_ptr->data); { /* Merge existing keys that don't exist in the keywords passed in. * This makes it possible to nest context overrides. */ - PyObject *context_dict_current = CTX_py_dict_get(C); - if (context_dict_current != NULL) { + PyObject *context_dict_current = static_cast(CTX_py_dict_get(C)); + if (context_dict_current != nullptr) { PyDict_Merge(kwds, context_dict_current, 0); } } - ContextStore ctx_temp = {NULL}; - if (params.window.ptr != NULL) { - ctx_temp.win = params.window.ptr->data; + ContextStore ctx_temp = {nullptr}; + if (params.window.ptr != nullptr) { + ctx_temp.win = static_cast(params.window.ptr->data); ctx_temp.win_is_set = true; } - if (params.area.ptr != NULL) { - ctx_temp.area = params.area.ptr->data; + if (params.area.ptr != nullptr) { + ctx_temp.area = static_cast(params.area.ptr->data); ctx_temp.area_is_set = true; } - if (params.region.ptr != NULL) { - ctx_temp.region = params.region.ptr->data; + if (params.region.ptr != nullptr) { + ctx_temp.region = static_cast(params.region.ptr->data); ctx_temp.region_is_set = true; } diff --git a/source/blender/python/intern/bpy_rna_data.c b/source/blender/python/intern/bpy_rna_data.cc similarity index 73% rename from source/blender/python/intern/bpy_rna_data.c rename to source/blender/python/intern/bpy_rna_data.cc index 7b8081aca45..d0879c73c02 100644 --- a/source/blender/python/intern/bpy_rna_data.c +++ b/source/blender/python/intern/bpy_rna_data.cc @@ -28,11 +28,11 @@ #include "bpy_rna.h" #include "bpy_rna_data.h" -typedef struct { +struct BPy_DataContext { PyObject_HEAD /* Required Python macro. */ BPy_StructRNA *data_rna; char filepath[1024]; -} BPy_DataContext; +}; static PyObject *bpy_rna_data_temp_data(PyObject *self, PyObject *args, PyObject *kwds); static PyObject *bpy_rna_data_context_enter(BPy_DataContext *self); @@ -41,7 +41,7 @@ static PyObject *bpy_rna_data_context_exit(BPy_DataContext *self, PyObject *args static PyMethodDef bpy_rna_data_context_methods[] = { {"__enter__", (PyCFunction)bpy_rna_data_context_enter, METH_NOARGS}, {"__exit__", (PyCFunction)bpy_rna_data_context_exit, METH_VARARGS}, - {NULL} /* sentinel */ + {nullptr} /* sentinel */ }; static int bpy_rna_data_context_traverse(BPy_DataContext *self, visitproc visit, void *arg) @@ -63,55 +63,55 @@ static void bpy_rna_data_context_dealloc(BPy_DataContext *self) PyObject_GC_Del(self); } static PyTypeObject bpy_rna_data_context_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "bpy_rna_data_context", /*tp_basicsize*/ sizeof(BPy_DataContext), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)bpy_rna_data_context_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, - /*tp_repr*/ NULL, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, + /*tp_repr*/ nullptr, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, - /*tp_doc*/ NULL, + /*tp_doc*/ nullptr, /*tp_traverse*/ (traverseproc)bpy_rna_data_context_traverse, /*tp_clear*/ (inquiry)bpy_rna_data_context_clear, - /*tp_richcompare*/ NULL, + /*tp_richcompare*/ nullptr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ bpy_rna_data_context_methods, - /*tp_members*/ NULL, - /*tp_getset*/ NULL, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; PyDoc_STRVAR(bpy_rna_data_context_load_doc, @@ -126,11 +126,11 @@ PyDoc_STRVAR(bpy_rna_data_context_load_doc, " :return: Blend file data which is freed once the context exists.\n" " :rtype: :class:`bpy.types.BlendData`\n"); -static PyObject *bpy_rna_data_temp_data(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_rna_data_temp_data(PyObject * /*self*/, PyObject *args, PyObject *kw) { BPy_DataContext *ret; - const char *filepath = NULL; - static const char *_keywords[] = {"filepath", NULL}; + const char *filepath = nullptr; + static const char *_keywords[] = {"filepath", nullptr}; static _PyArg_Parser _parser = { "|$" /* Optional keyword only arguments. */ "z" /* `filepath` */ @@ -139,7 +139,7 @@ static PyObject *bpy_rna_data_temp_data(PyObject *UNUSED(self), PyObject *args, 0, }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &filepath)) { - return NULL; + return nullptr; } ret = PyObject_GC_New(BPy_DataContext, &bpy_rna_data_context_Type); @@ -153,7 +153,7 @@ static PyObject *bpy_rna_data_context_enter(BPy_DataContext *self) { Main *bmain_temp = BKE_main_new(); PointerRNA ptr; - RNA_pointer_create(NULL, &RNA_BlendData, bmain_temp, &ptr); + RNA_pointer_create(nullptr, &RNA_BlendData, bmain_temp, &ptr); self->data_rna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr); @@ -163,9 +163,9 @@ static PyObject *bpy_rna_data_context_enter(BPy_DataContext *self) return (PyObject *)self->data_rna; } -static PyObject *bpy_rna_data_context_exit(BPy_DataContext *self, PyObject *UNUSED(args)) +static PyObject *bpy_rna_data_context_exit(BPy_DataContext *self, PyObject * /*args*/) { - BKE_main_free(self->data_rna->ptr.data); + BKE_main_free(static_cast
(self->data_rna->ptr.data)); RNA_POINTER_INVALIDATE(&self->data_rna->ptr); Py_RETURN_NONE; } diff --git a/source/blender/python/intern/bpy_rna_data.h b/source/blender/python/intern/bpy_rna_data.h index 390946f2671..b2b8d03d985 100644 --- a/source/blender/python/intern/bpy_rna_data.h +++ b/source/blender/python/intern/bpy_rna_data.h @@ -8,6 +8,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + int BPY_rna_data_context_type_ready(void); extern PyMethodDef BPY_rna_data_context_method_def; diff --git a/source/blender/python/intern/bpy_rna_driver.c b/source/blender/python/intern/bpy_rna_driver.cc similarity index 97% rename from source/blender/python/intern/bpy_rna_driver.c rename to source/blender/python/intern/bpy_rna_driver.cc index 172f932c6fd..b36590c4966 100644 --- a/source/blender/python/intern/bpy_rna_driver.c +++ b/source/blender/python/intern/bpy_rna_driver.cc @@ -27,9 +27,9 @@ PyObject *pyrna_driver_get_variable_value(const struct AnimationEvalContext *ani struct DriverVar *dvar, struct DriverTarget *dtar) { - PyObject *driver_arg = NULL; + PyObject *driver_arg = nullptr; PointerRNA ptr; - PropertyRNA *prop = NULL; + PropertyRNA *prop = nullptr; int index; if (driver_get_variable_property(anim_eval_context, driver, dvar, dtar, &ptr, &prop, &index)) { diff --git a/source/blender/python/intern/bpy_rna_gizmo.c b/source/blender/python/intern/bpy_rna_gizmo.cc similarity index 81% rename from source/blender/python/intern/bpy_rna_gizmo.c rename to source/blender/python/intern/bpy_rna_gizmo.cc index e0a6284604b..1702376eeb5 100644 --- a/source/blender/python/intern/bpy_rna_gizmo.c +++ b/source/blender/python/intern/bpy_rna_gizmo.cc @@ -54,17 +54,17 @@ static int py_rna_gizmo_parse(PyObject *o, void *p) BLI_assert(BPy_StructRNA_Check(o)); BLI_assert(RNA_struct_is_a(((const BPy_StructRNA *)o)->ptr.type, &RNA_Gizmo)); - wmGizmo **gz_p = p; - *gz_p = ((const BPy_StructRNA *)o)->ptr.data; + wmGizmo **gz_p = static_cast(p); + *gz_p = static_cast(((const BPy_StructRNA *)o)->ptr.data); return 1; } static int py_rna_gizmo_target_id_parse(PyObject *o, void *p) { - struct BPyGizmoWithTarget *gizmo_with_target = p; + struct BPyGizmoWithTarget *gizmo_with_target = static_cast(p); /* Must be set by `py_rna_gizmo_parse`. */ wmGizmo *gz = gizmo_with_target->gz; - BLI_assert(gz != NULL); + BLI_assert(gz != nullptr); if (!PyUnicode_Check(o)) { PyErr_Format(PyExc_TypeError, "expected a string (got %.200s)", Py_TYPE(o)->tp_name); @@ -72,7 +72,7 @@ static int py_rna_gizmo_target_id_parse(PyObject *o, void *p) } const char *gz_prop_id = PyUnicode_AsUTF8(o); wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, gz_prop_id); - if (gz_prop == NULL) { + if (gz_prop == nullptr) { PyErr_Format(PyExc_ValueError, "Gizmo target property '%s.%s' not found!", gz->type->idname, @@ -88,7 +88,7 @@ static int py_rna_gizmo_target_id_parse_and_ensure_is_valid(PyObject *o, void *p if (py_rna_gizmo_target_id_parse(o, p) == 0) { return 0; } - struct BPyGizmoWithTarget *gizmo_with_target = p; + struct BPyGizmoWithTarget *gizmo_with_target = static_cast(p); wmGizmo *gz = gizmo_with_target->gz; wmGizmoProperty *gz_prop = gizmo_with_target->gz_prop; if (!WM_gizmo_target_property_is_valid(gz_prop)) { @@ -105,10 +105,10 @@ static int py_rna_gizmo_target_id_parse_and_ensure_is_valid(PyObject *o, void *p static int py_rna_gizmo_target_type_id_parse(PyObject *o, void *p) { - struct BPyGizmoWithTargetType *gizmo_with_target = p; + struct BPyGizmoWithTargetType *gizmo_with_target = static_cast(p); /* Must be set first. */ wmGizmo *gz = gizmo_with_target->gz; - BLI_assert(gz != NULL); + BLI_assert(gz != nullptr); if (!PyUnicode_Check(o)) { PyErr_Format(PyExc_TypeError, "expected a string (got %.200s)", Py_TYPE(o)->tp_name); @@ -117,7 +117,7 @@ static int py_rna_gizmo_target_type_id_parse(PyObject *o, void *p) const char *gz_prop_id = PyUnicode_AsUTF8(o); const wmGizmoPropertyType *gz_prop_type = WM_gizmotype_target_property_find(gz->type, gz_prop_id); - if (gz_prop_type == NULL) { + if (gz_prop_type == nullptr) { PyErr_Format(PyExc_ValueError, "Gizmo target property '%s.%s' not found!", gz->type->idname, @@ -146,20 +146,21 @@ struct BPyGizmoHandlerUserData { PyObject *fn_slots[BPY_GIZMO_FN_SLOT_LEN]; }; -static void py_rna_gizmo_handler_get_cb(const wmGizmo *UNUSED(gz), +static void py_rna_gizmo_handler_get_cb(const wmGizmo * /*gz*/, wmGizmoProperty *gz_prop, void *value_p) { const PyGILState_STATE gilstate = PyGILState_Ensure(); - struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data; - PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_GET], NULL); - if (ret == NULL) { + struct BPyGizmoHandlerUserData *data = static_cast( + gz_prop->custom_func.user_data); + PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_GET], nullptr); + if (ret == nullptr) { goto fail; } if (gz_prop->type->data_type == PROP_FLOAT) { - float *value = value_p; + float *value = static_cast(value_p); if (gz_prop->type->array_length == 1) { if ((*value = PyFloat_AsDouble(ret)) == -1.0f && PyErr_Occurred()) { goto fail; @@ -196,18 +197,20 @@ fail: PyGILState_Release(gilstate); } -static void py_rna_gizmo_handler_set_cb(const wmGizmo *UNUSED(gz), +static void py_rna_gizmo_handler_set_cb(const wmGizmo * /*gz*/, wmGizmoProperty *gz_prop, const void *value_p) { const PyGILState_STATE gilstate = PyGILState_Ensure(); - struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data; + struct BPyGizmoHandlerUserData *data = static_cast( + gz_prop->custom_func.user_data); PyObject *args = PyTuple_New(1); + PyObject *ret; if (gz_prop->type->data_type == PROP_FLOAT) { - const float *value = value_p; + const float *value = static_cast(value_p); PyObject *py_value; if (gz_prop->type->array_length == 1) { py_value = PyFloat_FromDouble(*value); @@ -215,7 +218,7 @@ static void py_rna_gizmo_handler_set_cb(const wmGizmo *UNUSED(gz), else { py_value = PyC_Tuple_PackArray_F32(value, gz_prop->type->array_length); } - if (py_value == NULL) { + if (py_value == nullptr) { goto fail; } PyTuple_SET_ITEM(args, 0, py_value); @@ -225,8 +228,8 @@ static void py_rna_gizmo_handler_set_cb(const wmGizmo *UNUSED(gz), goto fail; } - PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_SET], args); - if (ret == NULL) { + ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_SET], args); + if (ret == nullptr) { goto fail; } Py_DECREF(args); @@ -244,16 +247,17 @@ fail: PyGILState_Release(gilstate); } -static void py_rna_gizmo_handler_range_get_cb(const wmGizmo *UNUSED(gz), +static void py_rna_gizmo_handler_range_get_cb(const wmGizmo * /*gz*/, wmGizmoProperty *gz_prop, void *value_p) { - struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data; + struct BPyGizmoHandlerUserData *data = static_cast( + gz_prop->custom_func.user_data); const PyGILState_STATE gilstate = PyGILState_Ensure(); - PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_RANGE_GET], NULL); - if (ret == NULL) { + PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_RANGE_GET], nullptr); + if (ret == nullptr) { goto fail; } @@ -298,9 +302,10 @@ fail: PyGILState_Release(gilstate); } -static void py_rna_gizmo_handler_free_cb(const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop) +static void py_rna_gizmo_handler_free_cb(const wmGizmo * /*gz*/, wmGizmoProperty *gz_prop) { - struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data; + struct BPyGizmoHandlerUserData *data = static_cast( + gz_prop->custom_func.user_data); const PyGILState_STATE gilstate = PyGILState_Ensure(); for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) { @@ -325,7 +330,7 @@ PyDoc_STRVAR( " :type set: callable\n" " :arg range: Function that returns a (min, max) tuple for gizmos that use a range.\n" " :type range: callable\n"); -static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_gizmo_target_set_handler(PyObject * /*self*/, PyObject *args, PyObject *kw) { const PyGILState_STATE gilstate = PyGILState_Ensure(); @@ -333,14 +338,14 @@ static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject * struct BPyGizmoWithTargetType gz_with_target_type; PyObject *py_fn_slots[BPY_GIZMO_FN_SLOT_LEN]; } params = { - .gz_with_target_type = {NULL, NULL}, - .py_fn_slots = {NULL}, + {nullptr, nullptr}, + {nullptr}, }; /* NOTE: this is a counter-part to functions: * 'Gizmo.target_set_prop & target_set_operator' * (see: rna_wm_gizmo_api.cc). conventions should match. */ - static const char *const _keywords[] = {"self", "target", "get", "set", "range", NULL}; + static const char *const _keywords[] = {"self", "target", "get", "set", "range", nullptr}; static _PyArg_Parser _parser = { "O&" /* `self` */ "O&" /* `target` */ @@ -352,6 +357,11 @@ static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject * _keywords, 0, }; + + BPyGizmoHandlerUserData *data; + const wmGizmoPropertyType *gz_prop_type; + wmGizmo *gz; + if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, @@ -369,14 +379,14 @@ static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject * goto fail; } - wmGizmo *gz = params.gz_with_target_type.gz; - const wmGizmoPropertyType *gz_prop_type = params.gz_with_target_type.gz_prop_type; + gz = params.gz_with_target_type.gz; + gz_prop_type = params.gz_with_target_type.gz_prop_type; { const int slots_required = 2; const int slots_start = 2; for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) { - if (params.py_fn_slots[i] == NULL) { + if (params.py_fn_slots[i] == nullptr) { if (i < slots_required) { PyErr_Format(PyExc_ValueError, "Argument '%s' not given", _keywords[slots_start + i]); goto fail; @@ -389,22 +399,22 @@ static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject * } } - struct BPyGizmoHandlerUserData *data = MEM_callocN(sizeof(*data), __func__); + data = static_cast(MEM_callocN(sizeof(*data), __func__)); for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) { data->fn_slots[i] = params.py_fn_slots[i]; Py_XINCREF(params.py_fn_slots[i]); } - WM_gizmo_target_property_def_func_ptr(gz, - gz_prop_type, - &(const wmGizmoPropertyFnParams){ - .value_get_fn = py_rna_gizmo_handler_get_cb, - .value_set_fn = py_rna_gizmo_handler_set_cb, - .range_get_fn = py_rna_gizmo_handler_range_get_cb, - .free_fn = py_rna_gizmo_handler_free_cb, - .user_data = data, - }); + { + wmGizmoPropertyFnParams fn_params{}; + fn_params.value_get_fn = py_rna_gizmo_handler_get_cb; + fn_params.value_set_fn = py_rna_gizmo_handler_set_cb; + fn_params.range_get_fn = py_rna_gizmo_handler_range_get_cb; + fn_params.free_fn = py_rna_gizmo_handler_free_cb; + fn_params.user_data = data; + WM_gizmo_target_property_def_func_ptr(gz, gz_prop_type, &fn_params); + } PyGILState_Release(gilstate); @@ -412,7 +422,7 @@ static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject * fail: PyGILState_Release(gilstate); - return NULL; + return nullptr; } /** \} */ @@ -430,15 +440,15 @@ PyDoc_STRVAR(bpy_gizmo_target_get_value_doc, " :type target: string\n" " :return: The value of the target property.\n" " :rtype: Single value or array based on the target type\n"); -static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_gizmo_target_get_value(PyObject * /*self*/, PyObject *args, PyObject *kw) { struct { struct BPyGizmoWithTarget gz_with_target; } params = { - .gz_with_target = {NULL, NULL}, + {nullptr, nullptr}, }; - static const char *const _keywords[] = {"self", "target", NULL}; + static const char *const _keywords[] = {"self", "target", nullptr}; static _PyArg_Parser _parser = { "O&" /* `self` */ "O&" /* `target` */ @@ -446,6 +456,11 @@ static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *ar _keywords, 0, }; + + int array_len; + wmGizmo *gz; + wmGizmoProperty *gz_prop; + if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, @@ -459,14 +474,14 @@ static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *ar goto fail; } - wmGizmo *gz = params.gz_with_target.gz; - wmGizmoProperty *gz_prop = params.gz_with_target.gz_prop; + gz = params.gz_with_target.gz; + gz_prop = params.gz_with_target.gz_prop; - const int array_len = WM_gizmo_target_property_array_length(gz, gz_prop); + array_len = WM_gizmo_target_property_array_length(gz, gz_prop); switch (gz_prop->type->data_type) { case PROP_FLOAT: { if (array_len != 0) { - float *value = BLI_array_alloca(value, array_len); + float *value = static_cast(BLI_array_alloca(value, array_len)); WM_gizmo_target_property_float_get_array(gz, gz_prop, value); return PyC_Tuple_PackArray_F32(value, array_len); } @@ -483,7 +498,7 @@ static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *ar } fail: - return NULL; + return nullptr; } PyDoc_STRVAR(bpy_gizmo_target_set_value_doc, @@ -493,17 +508,17 @@ PyDoc_STRVAR(bpy_gizmo_target_set_value_doc, "\n" " :arg target: Target property name.\n" " :type target: string\n"); -static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_gizmo_target_set_value(PyObject * /*self*/, PyObject *args, PyObject *kw) { struct { struct BPyGizmoWithTarget gz_with_target; PyObject *value; } params = { - .gz_with_target = {NULL, NULL}, - .value = NULL, + {nullptr, nullptr}, + nullptr, }; - static const char *const _keywords[] = {"self", "target", "value", NULL}; + static const char *const _keywords[] = {"self", "target", "value", nullptr}; static _PyArg_Parser _parser = { "O&" /* `self` */ "O&" /* `target` */ @@ -512,6 +527,11 @@ static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *ar _keywords, 0, }; + + wmGizmo *gz; + wmGizmoProperty *gz_prop; + int array_len; + if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, @@ -527,14 +547,14 @@ static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *ar goto fail; } - wmGizmo *gz = params.gz_with_target.gz; - wmGizmoProperty *gz_prop = params.gz_with_target.gz_prop; + gz = params.gz_with_target.gz; + gz_prop = params.gz_with_target.gz_prop; - const int array_len = WM_gizmo_target_property_array_length(gz, gz_prop); + array_len = WM_gizmo_target_property_array_length(gz, gz_prop); switch (gz_prop->type->data_type) { case PROP_FLOAT: { if (array_len != 0) { - float *value = BLI_array_alloca(value, array_len); + float *value = static_cast(BLI_array_alloca(value, array_len)); if (PyC_AsArray(value, sizeof(*value), params.value, @@ -562,7 +582,7 @@ static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *ar } fail: - return NULL; + return nullptr; } PyDoc_STRVAR(bpy_gizmo_target_get_range_doc, @@ -573,15 +593,15 @@ PyDoc_STRVAR(bpy_gizmo_target_get_range_doc, " :arg target: Target property name.\n" " :return: The range of this property (min, max).\n" " :rtype: tuple pair.\n"); -static PyObject *bpy_gizmo_target_get_range(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_gizmo_target_get_range(PyObject * /*self*/, PyObject *args, PyObject *kw) { struct { struct BPyGizmoWithTarget gz_with_target; } params = { - .gz_with_target = {NULL, NULL}, + {nullptr, nullptr}, }; - static const char *const _keywords[] = {"self", "target", NULL}; + static const char *const _keywords[] = {"self", "target", nullptr}; static _PyArg_Parser _parser = { "O&" /* `self` */ "O&" /* `target` */ @@ -589,6 +609,10 @@ static PyObject *bpy_gizmo_target_get_range(PyObject *UNUSED(self), PyObject *ar _keywords, 0, }; + + wmGizmo *gz; + wmGizmoProperty *gz_prop; + if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, @@ -602,8 +626,8 @@ static PyObject *bpy_gizmo_target_get_range(PyObject *UNUSED(self), PyObject *ar goto fail; } - wmGizmo *gz = params.gz_with_target.gz; - wmGizmoProperty *gz_prop = params.gz_with_target.gz_prop; + gz = params.gz_with_target.gz; + gz_prop = params.gz_with_target.gz_prop; switch (gz_prop->type->data_type) { case PROP_FLOAT: { @@ -618,7 +642,7 @@ static PyObject *bpy_gizmo_target_get_range(PyObject *UNUSED(self), PyObject *ar } fail: - return NULL; + return nullptr; } /** \} */ @@ -653,7 +677,7 @@ bool BPY_rna_gizmo_module(PyObject *mod_par) for (int i = 0; i < ARRAY_SIZE(method_def_array); i++) { PyMethodDef *m = &method_def_array[i]; - PyObject *func = PyCFunction_New(m, NULL); + PyObject *func = PyCFunction_New(m, nullptr); PyObject *func_inst = PyInstanceMethod_New(func); char name_prefix[128]; PyOS_snprintf(name_prefix, sizeof(name_prefix), "_rna_gizmo_%s", m->ml_name); diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.cc similarity index 86% rename from source/blender/python/intern/bpy_rna_id_collection.c rename to source/blender/python/intern/bpy_rna_id_collection.cc index 83e02ee72aa..29f387268d9 100644 --- a/source/blender/python/intern/bpy_rna_id_collection.c +++ b/source/blender/python/intern/bpy_rna_id_collection.cc @@ -43,7 +43,7 @@ #include "bpy_rna.h" -typedef struct IDUserMapData { +struct IDUserMapData { /** We loop over data-blocks that this ID points to (do build a reverse lookup table) */ PyObject *py_id_curr; ID *id_curr; @@ -55,7 +55,7 @@ typedef struct IDUserMapData { PyObject *user_map; /** true when we're only mapping a subset of all the ID's (subset arg is passed). */ bool is_subset; -} IDUserMapData; +}; static int id_code_as_index(const short idcode) { @@ -72,7 +72,7 @@ static int foreach_libblock_id_user_map_callback(LibraryIDLinkCallbackData *cb_d ID **id_p = cb_data->id_pointer; if (*id_p) { - IDUserMapData *data = cb_data->user_data; + IDUserMapData *data = static_cast(cb_data->user_data); const int cb_flag = cb_data->cb_flag; if (data->types_bitmap) { @@ -96,19 +96,19 @@ static int foreach_libblock_id_user_map_callback(LibraryIDLinkCallbackData *cb_d PyObject *key = pyrna_id_CreatePyObject(*id_p); PyObject *set; - if ((set = PyDict_GetItem(data->user_map, key)) == NULL) { + if ((set = PyDict_GetItem(data->user_map, key)) == nullptr) { /* limit to key's added already */ if (data->is_subset) { return IDWALK_RET_NOP; } - set = PySet_New(NULL); + set = PySet_New(nullptr); PyDict_SetItem(data->user_map, key, set); Py_DECREF(set); } Py_DECREF(key); - if (data->py_id_curr == NULL) { + if (data->py_id_curr == nullptr) { data->py_id_curr = pyrna_id_CreatePyObject(data->id_curr); } @@ -137,7 +137,7 @@ PyDoc_STRVAR(bpy_user_map_doc, " :return: dictionary of :class:`bpy.types.ID` instances, with sets of ID's as " "their values.\n" " :rtype: dict\n"); -static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *kwds) +static PyObject *bpy_user_map(PyObject * /*self*/, PyObject *args, PyObject *kwds) { #if 0 /* If someone knows how to get a proper 'self' in that case... */ BPy_StructRNA *pyrna = (BPy_StructRNA *)self; @@ -148,18 +148,18 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * ListBase *lb; ID *id; - PyObject *subset = NULL; + PyObject *subset = nullptr; - PyObject *key_types = NULL; - PyObject *val_types = NULL; - BLI_bitmap *key_types_bitmap = NULL; - BLI_bitmap *val_types_bitmap = NULL; + PyObject *key_types = nullptr; + PyObject *val_types = nullptr; + BLI_bitmap *key_types_bitmap = nullptr; + BLI_bitmap *val_types_bitmap = nullptr; - PyObject *ret = NULL; + PyObject *ret = nullptr; - IDUserMapData data_cb = {NULL}; + IDUserMapData data_cb = {nullptr}; - static const char *_keywords[] = {"subset", "key_types", "value_types", NULL}; + static const char *_keywords[] = {"subset", "key_types", "value_types", nullptr}; static _PyArg_Parser _parser = { "|$" /* Optional keyword only arguments. */ "O" /* `subset` */ @@ -172,13 +172,13 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * if (!_PyArg_ParseTupleAndKeywordsFast( args, kwds, &_parser, &subset, &PySet_Type, &key_types, &PySet_Type, &val_types)) { - return NULL; + return nullptr; } if (key_types) { key_types_bitmap = pyrna_enum_bitmap_from_set( rna_enum_id_type_items, key_types, sizeof(short), true, USHRT_MAX, "key types"); - if (key_types_bitmap == NULL) { + if (key_types_bitmap == nullptr) { goto error; } } @@ -186,14 +186,14 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * if (val_types) { val_types_bitmap = pyrna_enum_bitmap_from_set( rna_enum_id_type_items, val_types, sizeof(short), true, USHRT_MAX, "value types"); - if (val_types_bitmap == NULL) { + if (val_types_bitmap == nullptr) { goto error; } } if (subset) { PyObject *subset_fast = PySequence_Fast(subset, "user_map"); - if (subset_fast == NULL) { + if (subset_fast == nullptr) { goto error; } @@ -203,7 +203,7 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * data_cb.user_map = _PyDict_NewPresized(subset_len); data_cb.is_subset = true; for (; subset_len; subset_array++, subset_len--) { - PyObject *set = PySet_New(NULL); + PyObject *set = PySet_New(nullptr); PyDict_SetItem(data_cb.user_map, *subset_array, set); Py_DECREF(set); } @@ -218,7 +218,7 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb) { FOREACH_MAIN_LISTBASE_ID_BEGIN (lb, id) { /* We cannot skip here in case we have some filter on key types... */ - if (key_types_bitmap == NULL && val_types_bitmap != NULL) { + if (key_types_bitmap == nullptr && val_types_bitmap != nullptr) { if (!id_check_type(id, val_types_bitmap)) { break; } @@ -226,35 +226,35 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * if (!data_cb.is_subset && /* We do not want to pre-add keys of filtered out types. */ - (key_types_bitmap == NULL || id_check_type(id, key_types_bitmap)) && + (key_types_bitmap == nullptr || id_check_type(id, key_types_bitmap)) && /* We do not want to pre-add keys when we have filter on value types, * but not on key types. */ - (val_types_bitmap == NULL || key_types_bitmap != NULL)) + (val_types_bitmap == nullptr || key_types_bitmap != nullptr)) { PyObject *key = pyrna_id_CreatePyObject(id); PyObject *set; /* We have to insert the key now, * otherwise ID unused would be missing from final dict... */ - if ((set = PyDict_GetItem(data_cb.user_map, key)) == NULL) { - set = PySet_New(NULL); + if ((set = PyDict_GetItem(data_cb.user_map, key)) == nullptr) { + set = PySet_New(nullptr); PyDict_SetItem(data_cb.user_map, key, set); Py_DECREF(set); } Py_DECREF(key); } - if (val_types_bitmap != NULL && !id_check_type(id, val_types_bitmap)) { + if (val_types_bitmap != nullptr && !id_check_type(id, val_types_bitmap)) { continue; } data_cb.id_curr = id; BKE_library_foreach_ID_link( - NULL, id, foreach_libblock_id_user_map_callback, &data_cb, IDWALK_CB_NOP); + nullptr, id, foreach_libblock_id_user_map_callback, &data_cb, IDWALK_CB_NOP); if (data_cb.py_id_curr) { Py_DECREF(data_cb.py_id_curr); - data_cb.py_id_curr = NULL; + data_cb.py_id_curr = nullptr; } } FOREACH_MAIN_LISTBASE_ID_END; @@ -264,11 +264,11 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * ret = data_cb.user_map; error: - if (key_types_bitmap != NULL) { + if (key_types_bitmap != nullptr) { MEM_freeN(key_types_bitmap); } - if (val_types_bitmap != NULL) { + if (val_types_bitmap != nullptr) { MEM_freeN(val_types_bitmap); } @@ -289,7 +289,7 @@ PyDoc_STRVAR(bpy_batch_remove_doc, "\n" " :arg ids: Iterables of IDs (types can be mixed).\n" " :type subset: sequence\n"); -static PyObject *bpy_batch_remove(PyObject *UNUSED(self), PyObject *args, PyObject *kwds) +static PyObject *bpy_batch_remove(PyObject * /*self*/, PyObject *args, PyObject *kwds) { #if 0 /* If someone knows how to get a proper 'self' in that case... */ BPy_StructRNA *pyrna = (BPy_StructRNA *)self; @@ -298,11 +298,11 @@ static PyObject *bpy_batch_remove(PyObject *UNUSED(self), PyObject *args, PyObje Main *bmain = G_MAIN; /* XXX Ugly, but should work! */ #endif - PyObject *ids = NULL; + PyObject *ids = nullptr; - PyObject *ret = NULL; + PyObject *ret = nullptr; - static const char *_keywords[] = {"ids", NULL}; + static const char *_keywords[] = {"ids", nullptr}; static _PyArg_Parser _parser = { "O" /* `ids` */ ":batch_remove", @@ -317,7 +317,7 @@ static PyObject *bpy_batch_remove(PyObject *UNUSED(self), PyObject *args, PyObje BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); PyObject *ids_fast = PySequence_Fast(ids, "batch_remove"); - if (ids_fast == NULL) { + if (ids_fast == nullptr) { goto error; } @@ -339,7 +339,7 @@ static PyObject *bpy_batch_remove(PyObject *UNUSED(self), PyObject *args, PyObje BKE_id_multi_tagged_delete(bmain); /* Force full redraw, mandatory to avoid crashes when running this from UI... */ - WM_main_add_notifier(NC_WINDOW, NULL); + WM_main_add_notifier(NC_WINDOW, nullptr); } else { goto error; @@ -365,7 +365,7 @@ PyDoc_STRVAR(bpy_orphans_purge_doc, "remain after a single run of that function, defaults to False\n" " :type do_recursive: bool, optional\n" " :return: The number of deleted IDs.\n"); -static PyObject *bpy_orphans_purge(PyObject *UNUSED(self), PyObject *args, PyObject *kwds) +static PyObject *bpy_orphans_purge(PyObject * /*self*/, PyObject *args, PyObject *kwds) { #if 0 /* If someone knows how to get a proper 'self' in that case... */ BPy_StructRNA *pyrna = (BPy_StructRNA *)self; @@ -380,7 +380,7 @@ static PyObject *bpy_orphans_purge(PyObject *UNUSED(self), PyObject *args, PyObj bool do_linked_ids = true; bool do_recursive_cleanup = false; - static const char *_keywords[] = {"do_local_ids", "do_linked_ids", "do_recursive", NULL}; + static const char *_keywords[] = {"do_local_ids", "do_linked_ids", "do_recursive", nullptr}; static _PyArg_Parser _parser = { "|" /* Optional arguments. */ "O&" /* `do_local_ids` */ @@ -400,7 +400,7 @@ static PyObject *bpy_orphans_purge(PyObject *UNUSED(self), PyObject *args, PyObj PyC_ParseBool, &do_recursive_cleanup)) { - return NULL; + return nullptr; } /* Tag all IDs to delete. */ @@ -413,7 +413,7 @@ static PyObject *bpy_orphans_purge(PyObject *UNUSED(self), PyObject *args, PyObj const size_t num_datablocks_deleted = BKE_id_multi_tagged_delete(bmain); /* Force full redraw, mandatory to avoid crashes when running this from UI... */ - WM_main_add_notifier(NC_WINDOW, NULL); + WM_main_add_notifier(NC_WINDOW, nullptr); return PyLong_FromSize_t(num_datablocks_deleted); } diff --git a/source/blender/python/intern/bpy_rna_operator.c b/source/blender/python/intern/bpy_rna_operator.cc similarity index 84% rename from source/blender/python/intern/bpy_rna_operator.c rename to source/blender/python/intern/bpy_rna_operator.cc index 036934f711f..505de663e87 100644 --- a/source/blender/python/intern/bpy_rna_operator.c +++ b/source/blender/python/intern/bpy_rna_operator.cc @@ -25,11 +25,11 @@ /** \name Operator `poll_message_set` Method * \{ */ -static char *pyop_poll_message_get_fn(bContext *UNUSED(C), void *user_data) +static char *pyop_poll_message_get_fn(bContext * /*C*/, void *user_data) { PyGILState_STATE gilstate = PyGILState_Ensure(); - PyObject *py_args = user_data; + PyObject *py_args = static_cast(user_data); PyObject *py_func_or_msg = PyTuple_GET_ITEM(py_args, 0); if (PyUnicode_Check(py_func_or_msg)) { @@ -40,11 +40,11 @@ static char *pyop_poll_message_get_fn(bContext *UNUSED(C), void *user_data) PyObject *py_msg = PyObject_CallObject(py_func_or_msg, py_args_after_first); Py_DECREF(py_args_after_first); - char *msg = NULL; + char *msg = nullptr; bool error = false; - /* NULL for no string. */ - if (py_msg == NULL) { + /* nullptr for no string. */ + if (py_msg == nullptr) { error = true; } else { @@ -72,7 +72,7 @@ static char *pyop_poll_message_get_fn(bContext *UNUSED(C), void *user_data) return msg; } -static void pyop_poll_message_free_fn(bContext *UNUSED(C), void *user_data) +static void pyop_poll_message_free_fn(bContext * /*C*/, void *user_data) { /* Handles the GIL. */ BPY_DECREF(user_data); @@ -89,13 +89,13 @@ PyDoc_STRVAR(BPY_rna_operator_poll_message_set_doc, " :arg message: The message or a function that returns the message.\n" " :type message: string or a callable that returns a string or None.\n"); -static PyObject *BPY_rna_operator_poll_message_set(PyObject *UNUSED(self), PyObject *args) +static PyObject *BPY_rna_operator_poll_message_set(PyObject * /*self*/, PyObject *args) { const Py_ssize_t args_len = PyTuple_GET_SIZE(args); if (args_len == 0) { PyErr_SetString(PyExc_ValueError, "poll_message_set(message, ...): requires a message argument"); - return NULL; + return nullptr; } PyObject *py_func_or_msg = PyTuple_GET_ITEM(args, 0); @@ -104,7 +104,7 @@ static PyObject *BPY_rna_operator_poll_message_set(PyObject *UNUSED(self), PyObj if (args_len > 1) { PyErr_SetString(PyExc_ValueError, "poll_message_set(message): does not support additional arguments"); - return NULL; + return nullptr; } } else if (PyCallable_Check(py_func_or_msg)) { @@ -115,15 +115,14 @@ static PyObject *BPY_rna_operator_poll_message_set(PyObject *UNUSED(self), PyObj "poll_message_set(message, ...): " "expected at least 1 string or callable argument, got %.200s", Py_TYPE(py_func_or_msg)->tp_name); - return NULL; + return nullptr; } bContext *C = BPY_context_get(); - struct bContextPollMsgDyn_Params params = { - .get_fn = pyop_poll_message_get_fn, - .free_fn = pyop_poll_message_free_fn, - .user_data = Py_INCREF_RET(args), - }; + bContextPollMsgDyn_Params params{}; + params.get_fn = pyop_poll_message_get_fn; + params.free_fn = pyop_poll_message_free_fn; + params.user_data = Py_INCREF_RET(args); CTX_wm_operator_poll_msg_set_dynamic(C, ¶ms); diff --git a/source/blender/python/intern/bpy_rna_text.c b/source/blender/python/intern/bpy_rna_text.cc similarity index 93% rename from source/blender/python/intern/bpy_rna_text.c rename to source/blender/python/intern/bpy_rna_text.cc index 41291348a1c..3f01683f6ba 100644 --- a/source/blender/python/intern/bpy_rna_text.c +++ b/source/blender/python/intern/bpy_rna_text.cc @@ -31,12 +31,12 @@ /** * Struct representing a selection which is extracted from Python arguments. */ -typedef struct TextRegion { +struct TextRegion { int curl; int curc; int sell; int selc; -} TextRegion; +}; /** \} */ @@ -60,11 +60,11 @@ PyDoc_STRVAR(bpy_rna_region_as_string_doc, static PyObject *bpy_rna_region_as_string(PyObject *self, PyObject *args, PyObject *kwds) { BPy_StructRNA *pyrna = (BPy_StructRNA *)self; - Text *text = pyrna->ptr.data; + Text *text = static_cast(pyrna->ptr.data); /* Parse the region range. */ TextRegion region; - static const char *_keywords[] = {"range", NULL}; + static const char *_keywords[] = {"range", nullptr}; static _PyArg_Parser _parser = { "|$" /* Optional keyword only arguments. */ "((ii)(ii))" /* `range` */ @@ -75,7 +75,7 @@ static PyObject *bpy_rna_region_as_string(PyObject *self, PyObject *args, PyObje if (!_PyArg_ParseTupleAndKeywordsFast( args, kwds, &_parser, ®ion.curl, ®ion.curc, ®ion.sell, ®ion.selc)) { - return NULL; + return nullptr; } if (kwds && PyDict_GET_SIZE(kwds) > 0) { @@ -86,7 +86,7 @@ static PyObject *bpy_rna_region_as_string(PyObject *self, PyObject *args, PyObje if (!txt_has_sel(text)) { return PyUnicode_FromString(""); } - char *buf = txt_sel_to_buf(text, NULL); + char *buf = txt_sel_to_buf(text, nullptr); PyObject *sel_text = PyUnicode_FromString(buf); MEM_freeN(buf); /* Return the selected text. */ @@ -115,14 +115,14 @@ PyDoc_STRVAR(bpy_rna_region_from_string_doc, static PyObject *bpy_rna_region_from_string(PyObject *self, PyObject *args, PyObject *kwds) { BPy_StructRNA *pyrna = (BPy_StructRNA *)self; - Text *text = pyrna->ptr.data; + Text *text = static_cast(pyrna->ptr.data); /* Parse the region range. */ const char *buf; Py_ssize_t buf_len; TextRegion region; - static const char *_keywords[] = {"", "range", NULL}; + static const char *_keywords[] = {"", "range", nullptr}; static _PyArg_Parser _parser = { "s#" /* `buf` (positional). */ "|$" /* Optional keyword only arguments. */ @@ -141,7 +141,7 @@ static PyObject *bpy_rna_region_from_string(PyObject *self, PyObject *args, PyOb ®ion.sell, ®ion.selc)) { - return NULL; + return nullptr; } if (kwds && PyDict_GET_SIZE(kwds) > 0) { diff --git a/source/blender/python/intern/bpy_rna_types_capi.c b/source/blender/python/intern/bpy_rna_types_capi.cc similarity index 83% rename from source/blender/python/intern/bpy_rna_types_capi.c rename to source/blender/python/intern/bpy_rna_types_capi.cc index d43d121c459..ccf5289f7c5 100644 --- a/source/blender/python/intern/bpy_rna_types_capi.c +++ b/source/blender/python/intern/bpy_rna_types_capi.cc @@ -47,11 +47,11 @@ * \{ */ static PyMethodDef pyrna_blenddata_methods[] = { - {NULL, NULL, 0, NULL}, /* #BPY_rna_id_collection_user_map_method_def */ - {NULL, NULL, 0, NULL}, /* #BPY_rna_id_collection_batch_remove_method_def */ - {NULL, NULL, 0, NULL}, /* #BPY_rna_id_collection_orphans_purge_method_def */ - {NULL, NULL, 0, NULL}, /* #BPY_rna_data_context_method_def */ - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_id_collection_user_map_method_def */ + {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_id_collection_batch_remove_method_def */ + {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_id_collection_orphans_purge_method_def */ + {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_data_context_method_def */ + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -61,9 +61,9 @@ static PyMethodDef pyrna_blenddata_methods[] = { * \{ */ static PyMethodDef pyrna_blenddatalibraries_methods[] = { - {NULL, NULL, 0, NULL}, /* #BPY_library_load_method_def */ - {NULL, NULL, 0, NULL}, /* #BPY_library_write_method_def */ - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, /* #BPY_library_load_method_def */ + {nullptr, nullptr, 0, nullptr}, /* #BPY_library_write_method_def */ + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -73,8 +73,8 @@ static PyMethodDef pyrna_blenddatalibraries_methods[] = { * \{ */ static PyMethodDef pyrna_uilayout_methods[] = { - {NULL, NULL, 0, NULL}, /* #BPY_rna_uilayout_introspect_method_def */ - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_uilayout_introspect_method_def */ + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -84,8 +84,8 @@ static PyMethodDef pyrna_uilayout_methods[] = { * \{ */ static PyMethodDef pyrna_operator_methods[] = { - {NULL, NULL, 0, NULL}, /* #BPY_rna_operator_poll_message_set */ - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_operator_poll_message_set */ + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -95,9 +95,9 @@ static PyMethodDef pyrna_operator_methods[] = { * \{ */ static PyMethodDef pyrna_text_methods[] = { - {NULL, NULL, 0, NULL}, /* #BPY_rna_region_as_string_method_def */ - {NULL, NULL, 0, NULL}, /* #BPY_rna_region_from_string_method_def */ - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_region_as_string_method_def */ + {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_region_from_string_method_def */ + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -110,25 +110,23 @@ static PyMethodDef pyrna_text_methods[] = { * \{ */ PyDoc_STRVAR(pyrna_WindowManager_clipboard_doc, "Clipboard text storage.\n\n:type: string"); -static PyObject *pyrna_WindowManager_clipboard_get(PyObject *UNUSED(self), void *UNUSED(flag)) +static PyObject *pyrna_WindowManager_clipboard_get(PyObject * /*self*/, void * /*flag*/) { int text_len = 0; /* No need for UTF8 validation as #PyC_UnicodeFromBytesAndSize handles invalid byte sequences. */ char *text = WM_clipboard_text_get(false, false, &text_len); PyObject *result = PyC_UnicodeFromBytesAndSize(text ? text : "", text_len); - if (text != NULL) { + if (text != nullptr) { MEM_freeN(text); } return result; } -static int pyrna_WindowManager_clipboard_set(PyObject *UNUSED(self), - PyObject *value, - void *UNUSED(flag)) +static int pyrna_WindowManager_clipboard_set(PyObject * /*self*/, PyObject *value, void * /*flag*/) { - PyObject *value_coerce = NULL; + PyObject *value_coerce = nullptr; const char *text = PyC_UnicodeAsBytes(value, &value_coerce); - if (text == NULL) { + if (text == nullptr) { return -1; } WM_clipboard_text_set(text, false); @@ -184,7 +182,7 @@ static PyMethodDef pyrna_windowmanager_methods[] = { (PyCFunction)pyrna_callback_classmethod_remove, METH_VARARGS | METH_CLASS, pyrna_draw_cursor_remove_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyGetSetDef pyrna_windowmanager_getset[] = { @@ -192,8 +190,8 @@ static PyGetSetDef pyrna_windowmanager_getset[] = { pyrna_WindowManager_clipboard_get, pyrna_WindowManager_clipboard_set, pyrna_WindowManager_clipboard_doc, - NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; /** \} */ @@ -203,8 +201,8 @@ static PyGetSetDef pyrna_windowmanager_getset[] = { * \{ */ static PyMethodDef pyrna_context_methods[] = { - {NULL, NULL, 0, NULL}, /* #BPY_rna_context_temp_override_method_def */ - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_context_temp_override_method_def */ + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -256,7 +254,7 @@ static PyMethodDef pyrna_space_methods[] = { (PyCFunction)pyrna_callback_classmethod_remove, METH_VARARGS | METH_CLASS, pyrna_draw_handler_remove_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -274,33 +272,34 @@ void BPY_rna_types_extend_capi(void) BPY_rna_id_collection_orphans_purge_method_def, BPY_rna_data_context_method_def); BLI_assert(ARRAY_SIZE(pyrna_blenddata_methods) == 5); - pyrna_struct_type_extend_capi(&RNA_BlendData, pyrna_blenddata_methods, NULL); + pyrna_struct_type_extend_capi(&RNA_BlendData, pyrna_blenddata_methods, nullptr); /* BlendDataLibraries */ ARRAY_SET_ITEMS( pyrna_blenddatalibraries_methods, BPY_library_load_method_def, BPY_library_write_method_def); BLI_assert(ARRAY_SIZE(pyrna_blenddatalibraries_methods) == 3); - pyrna_struct_type_extend_capi(&RNA_BlendDataLibraries, pyrna_blenddatalibraries_methods, NULL); + pyrna_struct_type_extend_capi( + &RNA_BlendDataLibraries, pyrna_blenddatalibraries_methods, nullptr); /* uiLayout */ ARRAY_SET_ITEMS(pyrna_uilayout_methods, BPY_rna_uilayout_introspect_method_def); BLI_assert(ARRAY_SIZE(pyrna_uilayout_methods) == 2); - pyrna_struct_type_extend_capi(&RNA_UILayout, pyrna_uilayout_methods, NULL); + pyrna_struct_type_extend_capi(&RNA_UILayout, pyrna_uilayout_methods, nullptr); /* Space */ - pyrna_struct_type_extend_capi(&RNA_Space, pyrna_space_methods, NULL); + pyrna_struct_type_extend_capi(&RNA_Space, pyrna_space_methods, nullptr); /* Text Editor */ ARRAY_SET_ITEMS(pyrna_text_methods, BPY_rna_region_as_string_method_def, BPY_rna_region_from_string_method_def); BLI_assert(ARRAY_SIZE(pyrna_text_methods) == 3); - pyrna_struct_type_extend_capi(&RNA_Text, pyrna_text_methods, NULL); + pyrna_struct_type_extend_capi(&RNA_Text, pyrna_text_methods, nullptr); /* wmOperator */ ARRAY_SET_ITEMS(pyrna_operator_methods, BPY_rna_operator_poll_message_set_method_def); BLI_assert(ARRAY_SIZE(pyrna_operator_methods) == 2); - pyrna_struct_type_extend_capi(&RNA_Operator, pyrna_operator_methods, NULL); + pyrna_struct_type_extend_capi(&RNA_Operator, pyrna_operator_methods, nullptr); /* WindowManager */ pyrna_struct_type_extend_capi( @@ -310,7 +309,7 @@ void BPY_rna_types_extend_capi(void) bpy_rna_context_types_init(); ARRAY_SET_ITEMS(pyrna_context_methods, BPY_rna_context_temp_override_method_def); - pyrna_struct_type_extend_capi(&RNA_Context, pyrna_context_methods, NULL); + pyrna_struct_type_extend_capi(&RNA_Context, pyrna_context_methods, nullptr); } /** \} */ diff --git a/source/blender/python/intern/bpy_rna_ui.c b/source/blender/python/intern/bpy_rna_ui.cc similarity index 92% rename from source/blender/python/intern/bpy_rna_ui.c rename to source/blender/python/intern/bpy_rna_ui.cc index 37a30076f0d..e435b54f235 100644 --- a/source/blender/python/intern/bpy_rna_ui.c +++ b/source/blender/python/intern/bpy_rna_ui.cc @@ -28,10 +28,10 @@ PyDoc_STRVAR(bpy_rna_uilayout_introspect_doc, static PyObject *bpy_rna_uilayout_introspect(PyObject *self) { BPy_StructRNA *pyrna = (BPy_StructRNA *)self; - uiLayout *layout = pyrna->ptr.data; + uiLayout *layout = static_cast(pyrna->ptr.data); const char *expr = UI_layout_introspect(layout); - PyObject *main_mod = NULL; + PyObject *main_mod = nullptr; PyC_MainModule_Backup(&main_mod); PyObject *py_dict = PyC_DefaultNameSpace(""); PyObject *result = PyRun_String(expr, Py_eval_input, py_dict, py_dict); diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.cc similarity index 91% rename from source/blender/python/intern/bpy_traceback.c rename to source/blender/python/intern/bpy_traceback.cc index bb73d897251..666310fbc0e 100644 --- a/source/blender/python/intern/bpy_traceback.c +++ b/source/blender/python/intern/bpy_traceback.cc @@ -27,8 +27,17 @@ static const char *traceback_filepath(PyTracebackObject *tb, PyObject **coerce) return PyBytes_AS_STRING(*coerce); } -/* Copied from `pythonrun.c`, 3.10.0 */ -_Py_static_string(PyId_string, ""); +#define MAKE_PY_IDENTIFIER_EX(varname, value) static _Py_Identifier varname{value, -1}; +#define MAKE_PY_IDENTIFIER(varname) MAKE_PY_IDENTIFIER_EX(PyId_##varname, #varname) + +MAKE_PY_IDENTIFIER_EX(PyId_string, "") +MAKE_PY_IDENTIFIER(msg); +MAKE_PY_IDENTIFIER(filename); +MAKE_PY_IDENTIFIER(lineno); +MAKE_PY_IDENTIFIER(offset); +MAKE_PY_IDENTIFIER(end_lineno); +MAKE_PY_IDENTIFIER(end_offset); +MAKE_PY_IDENTIFIER(text); static int parse_syntax_error(PyObject *err, PyObject **message, @@ -41,16 +50,9 @@ static int parse_syntax_error(PyObject *err, { Py_ssize_t hold; PyObject *v; - _Py_IDENTIFIER(msg); - _Py_IDENTIFIER(filename); - _Py_IDENTIFIER(lineno); - _Py_IDENTIFIER(offset); - _Py_IDENTIFIER(end_lineno); - _Py_IDENTIFIER(end_offset); - _Py_IDENTIFIER(text); - *message = NULL; - *filename = NULL; + *message = nullptr; + *filename = nullptr; /* new style errors. `err' is an instance */ *message = _PyObject_GetAttrId(err, &PyId_msg); @@ -65,7 +67,7 @@ static int parse_syntax_error(PyObject *err, if (v == Py_None) { Py_DECREF(v); *filename = _PyUnicode_FromId(&PyId_string); - if (*filename == NULL) { + if (*filename == nullptr) { goto finally; } Py_INCREF(*filename); @@ -151,7 +153,7 @@ static int parse_syntax_error(PyObject *err, } if (v == Py_None) { Py_DECREF(v); - *text = NULL; + *text = nullptr; } else { *text = v; @@ -183,7 +185,7 @@ bool python_script_error_jump( *r_offset_end = 0; PyErr_Fetch(&exception, &value, (PyObject **)&tb); - if (exception == NULL) { + if (exception == nullptr) { return false; } diff --git a/source/blender/python/intern/bpy_utils_previews.c b/source/blender/python/intern/bpy_utils_previews.cc similarity index 90% rename from source/blender/python/intern/bpy_utils_previews.c rename to source/blender/python/intern/bpy_utils_previews.cc index 8e6099d827f..2acc387b50b 100644 --- a/source/blender/python/intern/bpy_utils_previews.c +++ b/source/blender/python/intern/bpy_utils_previews.cc @@ -51,18 +51,18 @@ PyDoc_STRVAR( /* This is only true when accessed via 'bpy.utils.previews.ImagePreviewCollection.load', * however this is the public API, allow this minor difference to the internal version here. */ " :raises KeyError: if ``name`` already exists."); -static PyObject *bpy_utils_previews_new(PyObject *UNUSED(self), PyObject *args) +static PyObject *bpy_utils_previews_new(PyObject * /*self*/, PyObject *args) { char *name; PreviewImage *prv; PointerRNA ptr; if (!PyArg_ParseTuple(args, "s:new", &name)) { - return NULL; + return nullptr; } prv = BKE_previewimg_cached_ensure(name); - RNA_pointer_create(NULL, &RNA_ImagePreview, prv, &ptr); + RNA_pointer_create(nullptr, &RNA_ImagePreview, prv, &ptr); return pyrna_struct_CreatePyObject(&ptr); } @@ -88,7 +88,7 @@ PyDoc_STRVAR( /* This is only true when accessed via 'bpy.utils.previews.ImagePreviewCollection.load', * however this is the public API, allow this minor difference to the internal version here. */ " :raises KeyError: if ``name`` already exists."); -static PyObject *bpy_utils_previews_load(PyObject *UNUSED(self), PyObject *args) +static PyObject *bpy_utils_previews_load(PyObject * /*self*/, PyObject *args) { char *name, *path, *path_type_s; int path_type, force_reload = false; @@ -97,7 +97,7 @@ static PyObject *bpy_utils_previews_load(PyObject *UNUSED(self), PyObject *args) PointerRNA ptr; if (!PyArg_ParseTuple(args, "sss|p:load", &name, &path, &path_type_s, &force_reload)) { - return NULL; + return nullptr; } if (STREQ(path_type_s, "IMAGE")) { @@ -121,11 +121,11 @@ static PyObject *bpy_utils_previews_load(PyObject *UNUSED(self), PyObject *args) "] " "are supported", path_type_s); - return NULL; + return nullptr; } prv = BKE_previewimg_cached_thumbnail_read(name, path, path_type, force_reload); - RNA_pointer_create(NULL, &RNA_ImagePreview, prv, &ptr); + RNA_pointer_create(nullptr, &RNA_ImagePreview, prv, &ptr); return pyrna_struct_CreatePyObject(&ptr); } @@ -138,12 +138,12 @@ PyDoc_STRVAR(bpy_utils_previews_release_doc, "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: string\n"); -static PyObject *bpy_utils_previews_release(PyObject *UNUSED(self), PyObject *args) +static PyObject *bpy_utils_previews_release(PyObject * /*self*/, PyObject *args) { char *name; if (!PyArg_ParseTuple(args, "s:release", &name)) { - return NULL; + return nullptr; } BKE_previewimg_cached_release(name); @@ -159,7 +159,7 @@ static PyMethodDef bpy_utils_previews_methods[] = { (PyCFunction)bpy_utils_previews_release, METH_VARARGS, bpy_utils_previews_release_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; PyDoc_STRVAR( @@ -172,10 +172,10 @@ static PyModuleDef bpy_utils_previews_module = { /*m_doc*/ bpy_utils_previews_doc, /*m_size*/ 0, /*m_methods*/ bpy_utils_previews_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; PyObject *BPY_utils_previews_module(void) diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.cc similarity index 92% rename from source/blender/python/intern/bpy_utils_units.c rename to source/blender/python/intern/bpy_utils_units.cc index 8dd4c848ae0..d9ea3883308 100644 --- a/source/blender/python/intern/bpy_utils_units.c +++ b/source/blender/python/intern/bpy_utils_units.cc @@ -34,7 +34,7 @@ static const char *bpyunits_usystem_items[] = { "NONE", "METRIC", "IMPERIAL", - NULL, + nullptr, }; static const char *bpyunits_ucategories_items[] = { @@ -51,7 +51,7 @@ static const char *bpyunits_ucategories_items[] = { "CAMERA", "POWER", "TEMPERATURE", - NULL, + nullptr, }; BLI_STATIC_ASSERT( @@ -96,16 +96,16 @@ static PyObject *py_structseq_from_strings(PyTypeObject *py_type, /* We really populate the contexts' fields here! */ for (str_iter = str_items, desc = py_sseq_desc->fields; *str_iter; str_iter++, desc++) { desc->name = (char *)*str_iter; - desc->doc = NULL; + desc->doc = nullptr; } /* end sentinel */ - desc->name = desc->doc = NULL; + desc->name = desc->doc = nullptr; PyStructSequence_InitType(py_type, py_sseq_desc); /* Initialize the Python type. */ py_struct_seq = PyStructSequence_New(py_type); - BLI_assert(py_struct_seq != NULL); + BLI_assert(py_struct_seq != nullptr); for (str_iter = str_items; *str_iter; str_iter++) { PyStructSequence_SET_ITEM(py_struct_seq, pos++, PyUnicode_FromString(*str_iter)); @@ -159,9 +159,9 @@ PyDoc_STRVAR( " :return: The converted/interpreted value.\n" " :rtype: float\n" " :raises ValueError: if conversion fails to generate a valid Python float value.\n"); -static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpyunits_to_value(PyObject * /*self*/, PyObject *args, PyObject *kw) { - char *usys_str = NULL, *ucat_str = NULL, *inpt = NULL, *uref = NULL; + char *usys_str = nullptr, *ucat_str = nullptr, *inpt = nullptr, *uref = nullptr; const float scale = 1.0f; char *str; @@ -175,7 +175,7 @@ static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObj "unit_category", "str_input", "str_ref_unit", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "s" /* `unit_system` */ @@ -190,20 +190,20 @@ static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObj if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &usys_str, &ucat_str, &inpt, &str_len, &uref)) { - return NULL; + return nullptr; } if (!bpyunits_validate(usys_str, ucat_str, &usys, &ucat)) { - return NULL; + return nullptr; } str_len = str_len * 2 + 64; - str = PyMem_MALLOC(sizeof(*str) * (size_t)str_len); + str = static_cast(PyMem_MALLOC(sizeof(*str) * (size_t)str_len)); BLI_strncpy(str, inpt, (size_t)str_len); BKE_unit_replace_string(str, (int)str_len, uref, scale, usys, ucat); - if (!PyC_RunString_AsNumber(NULL, str, "", &result)) { + if (!PyC_RunString_AsNumber(nullptr, str, "", &result)) { if (PyErr_Occurred()) { PyErr_Print(); PyErr_Clear(); @@ -211,7 +211,7 @@ static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObj PyErr_Format( PyExc_ValueError, "'%.200s' (converted as '%s') could not be evaluated.", inpt, str); - ret = NULL; + ret = nullptr; } else { ret = PyFloat_FromDouble(result); @@ -246,9 +246,9 @@ PyDoc_STRVAR(bpyunits_to_string_doc, " :return: The converted string.\n" " :rtype: str\n" " :raises ValueError: if conversion fails to generate a valid Python string.\n"); -static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpyunits_to_string(PyObject * /*self*/, PyObject *args, PyObject *kw) { - char *usys_str = NULL, *ucat_str = NULL; + char *usys_str = nullptr, *ucat_str = nullptr; double value = 0.0; int precision = 3; bool split_unit = false, compatible_unit = false; @@ -262,7 +262,7 @@ static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyOb "precision", "split_unit", "compatible_unit", - NULL, + nullptr, }; static _PyArg_Parser _parser = { "s" /* `unit_system` */ @@ -288,11 +288,11 @@ static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyOb PyC_ParseBool, &compatible_unit)) { - return NULL; + return nullptr; } if (!bpyunits_validate(usys_str, ucat_str, &usys, &ucat)) { - return NULL; + return nullptr; } { @@ -333,7 +333,7 @@ static PyMethodDef bpyunits_methods[] = { (PyCFunction)bpyunits_to_string, METH_VARARGS | METH_KEYWORDS, bpyunits_to_string_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; PyDoc_STRVAR(bpyunits_doc, "This module contains some data/methods regarding units handling."); @@ -344,10 +344,10 @@ static PyModuleDef bpyunits_module = { /*m_doc*/ bpyunits_doc, /*m_size*/ -1, /* multiple "initialization" just copies the module dict. */ /*m_methods*/ bpyunits_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; PyObject *BPY_utils_units(void) diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c deleted file mode 100644 index c2870d2906b..00000000000 --- a/source/blender/python/intern/stubs.c +++ /dev/null @@ -1,34 +0,0 @@ -/* SPDX-FileCopyrightText: 2007 Blender Foundation - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup pythonintern - */ - -#include "BLI_utildefines.h" - -#include "BPY_extern.h" - -#if defined(__GNUC__) || defined(__clang__) -# pragma GCC diagnostic error "-Wmissing-prototypes" -# pragma GCC diagnostic ignored "-Wunused-parameter" -#elif defined(_MSC_VER) -/* Suppress unreferenced formal parameter warning. */ -# pragma warning(disable : 4100) -#endif - -/* python, will come back */ -// void BPY_script_exec(void) {} -// void BPY_python_start(void) {} -void BPY_pyconstraint_exec(struct bPythonConstraint *con, - struct bConstraintOb *cob, - struct ListBase *targets) -{ -} -void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct) {} -bool BPY_is_pyconstraint(struct Text *text) -{ - return 0; -} -void BPY_pyconstraint_update(struct Object *owner, struct bConstraint *con) {} diff --git a/source/blender/python/intern/stubs.cc b/source/blender/python/intern/stubs.cc new file mode 100644 index 00000000000..3bf10ffd099 --- /dev/null +++ b/source/blender/python/intern/stubs.cc @@ -0,0 +1,28 @@ +/* SPDX-FileCopyrightText: 2007 Blender Foundation + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup pythonintern + */ + +#include "BLI_utildefines.h" + +#include "BPY_extern.h" + +/* python, will come back */ +// void BPY_script_exec(void) {} +// void BPY_python_start(void) {} +void BPY_pyconstraint_exec(struct bPythonConstraint * /*con*/, + struct bConstraintOb * /*cob*/, + struct ListBase * /*targets*/) +{ +} +void BPY_pyconstraint_target(struct bPythonConstraint * /*con*/, struct bConstraintTarget * /*ct*/) +{ +} +bool BPY_is_pyconstraint(struct Text * /*text*/) +{ + return 0; +} +void BPY_pyconstraint_update(struct Object * /*owner*/, struct bConstraint * /*con*/) {} diff --git a/source/blender/python/mathutils/CMakeLists.txt b/source/blender/python/mathutils/CMakeLists.txt index 2a6152b62cc..e32e70d860f 100644 --- a/source/blender/python/mathutils/CMakeLists.txt +++ b/source/blender/python/mathutils/CMakeLists.txt @@ -13,17 +13,17 @@ set(INC_SYS ) set(SRC - mathutils.c - mathutils_Color.c - mathutils_Euler.c - mathutils_Matrix.c - mathutils_Quaternion.c - mathutils_Vector.c + mathutils.cc + mathutils_Color.cc + mathutils_Euler.cc + mathutils_Matrix.cc + mathutils_Quaternion.cc + mathutils_Vector.cc mathutils_bvhtree.cc - mathutils_geometry.c - mathutils_interpolate.c - mathutils_kdtree.c - mathutils_noise.c + mathutils_geometry.cc + mathutils_interpolate.cc + mathutils_kdtree.cc + mathutils_noise.cc mathutils.h mathutils_Color.h diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.cc similarity index 93% rename from source/blender/python/mathutils/mathutils.c rename to source/blender/python/mathutils/mathutils.cc index 7380f5505aa..4a3cbb93a6a 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.cc @@ -77,7 +77,7 @@ Py_hash_t mathutils_array_hash(const float *array, size_t array_len) x = 0x345678UL; i = 0; while (--len >= 0) { - y = _Py_HashDouble(NULL, (double)(array[i++])); + y = _Py_HashDouble(nullptr, (double)(array[i++])); if (y == -1) { return -1; } @@ -138,7 +138,7 @@ int mathutils_array_parse( else #endif { - PyObject *value_fast = NULL; + PyObject *value_fast = nullptr; /* non list/tuple cases */ if (!(value_fast = PySequence_Fast(value, error_prefix))) { @@ -214,15 +214,15 @@ int mathutils_array_parse_alloc(float **array, return -1; } - *array = PyMem_Malloc(num * sizeof(float)); + *array = static_cast(PyMem_Malloc(num * sizeof(float))); memcpy(*array, ((const BaseMathObject *)value)->data, num * sizeof(float)); return num; } #endif - PyObject *value_fast = NULL; - // *array = NULL; + PyObject *value_fast = nullptr; + // *array = nullptr; int ret; /* non list/tuple cases */ @@ -243,7 +243,7 @@ int mathutils_array_parse_alloc(float **array, return -1; } - *array = PyMem_Malloc(num * sizeof(float)); + *array = static_cast(PyMem_Malloc(num * sizeof(float))); ret = mathutils_array_parse_fast(*array, num, value_fast, error_prefix); Py_DECREF(value_fast); @@ -278,14 +278,14 @@ int mathutils_array_parse_alloc_v(float **array, array_dim &= ~MU_ARRAY_FLAGS; - fp = *array = PyMem_Malloc(num * array_dim * sizeof(float)); + fp = *array = static_cast(PyMem_Malloc(num * array_dim * sizeof(float))); for (i = 0; i < num; i++, fp += array_dim) { PyObject *item = value_fast_items[i]; if (mathutils_array_parse(fp, array_dim, array_dim_flag, item, error_prefix) == -1) { PyMem_Free(*array); - *array = NULL; + *array = nullptr; num = -1; break; } @@ -350,14 +350,14 @@ int mathutils_array_parse_alloc_vi(int **array, PyObject **value_fast_items = PySequence_Fast_ITEMS(value_fast); int *ip; - ip = *array = PyMem_Malloc(size * array_dim * sizeof(int)); + ip = *array = static_cast(PyMem_Malloc(size * array_dim * sizeof(int))); for (i = 0; i < size; i++, ip += array_dim) { PyObject *item = value_fast_items[i]; if (mathutils_int_array_parse(ip, array_dim, item, error_prefix) == -1) { PyMem_Free(*array); - *array = NULL; + *array = nullptr; size = -1; break; } @@ -375,9 +375,9 @@ int mathutils_array_parse_alloc_viseq( int i, size, start, subseq_len; int *ip; - *array = NULL; - *start_table = NULL; - *len_table = NULL; + *array = nullptr; + *start_table = nullptr; + *len_table = nullptr; if (!(value_fast = PySequence_Fast(value, error_prefix))) { /* PySequence_Fast sets the error */ return -1; @@ -388,8 +388,8 @@ int mathutils_array_parse_alloc_viseq( if (size != 0) { PyObject **value_fast_items = PySequence_Fast_ITEMS(value_fast); - *start_table = PyMem_Malloc(size * sizeof(int)); - *len_table = PyMem_Malloc(size * sizeof(int)); + *start_table = static_cast(PyMem_Malloc(size * sizeof(int))); + *len_table = static_cast(PyMem_Malloc(size * sizeof(int))); /* First pass to set starts and len, and calculate size of array needed */ start = 0; @@ -401,8 +401,8 @@ int mathutils_array_parse_alloc_viseq( PyMem_Free(*start_table); PyMem_Free(*len_table); Py_DECREF(value_fast); - *start_table = NULL; - *len_table = NULL; + *start_table = nullptr; + *len_table = nullptr; return -1; } (*start_table)[i] = start; @@ -410,7 +410,7 @@ int mathutils_array_parse_alloc_viseq( start += subseq_len; } - ip = *array = PyMem_Malloc(start * sizeof(int)); + ip = *array = static_cast(PyMem_Malloc(start * sizeof(int))); /* Second pass to parse the subsequences into array */ for (i = 0; i < size; i++) { @@ -421,9 +421,9 @@ int mathutils_array_parse_alloc_viseq( PyMem_Free(*array); PyMem_Free(*start_table); PyMem_Free(*len_table); - *array = NULL; - *len_table = NULL; - *start_table = NULL; + *array = nullptr; + *len_table = nullptr; + *start_table = nullptr; size = -1; break; } @@ -531,7 +531,7 @@ int EXPP_VectorsAreEqual(const float *vecA, const float *vecB, int size, int flo PyObject *mathutils_dynstr_to_py(DynStr *ds) { const int ds_len = BLI_dynstr_get_len(ds); /* space for \0 */ - char *ds_buf = PyMem_Malloc(ds_len + 1); + char *ds_buf = static_cast(PyMem_Malloc(ds_len + 1)); PyObject *ret; BLI_dynstr_get_cstring_ex(ds, ds_buf); BLI_dynstr_free(ds); @@ -546,7 +546,7 @@ PyObject *mathutils_dynstr_to_py(DynStr *ds) /* For mathutils internal use only, * eventually should re-alloc but to start with we only have a few users. */ #define MATHUTILS_TOT_CB 17 -static Mathutils_Callback *mathutils_callbacks[MATHUTILS_TOT_CB] = {NULL}; +static Mathutils_Callback *mathutils_callbacks[MATHUTILS_TOT_CB] = {nullptr}; uchar Mathutils_RegisterCallback(Mathutils_Callback *cb) { @@ -577,7 +577,7 @@ int _BaseMathObject_CheckCallback(BaseMathObject *self) int _BaseMathObject_ReadCallback(BaseMathObject *self) { - /* NOTE: use macros to check for NULL. */ + /* NOTE: use macros to check for nullptr. */ Mathutils_Callback *cb = mathutils_callbacks[self->cb_type]; if (LIKELY(cb->get(self, self->cb_subtype) != -1)) { @@ -645,7 +645,7 @@ void _BaseMathObject_RaiseNotFrozenExc(const BaseMathObject *self) /* #BaseMathObject generic functions for all mathutils types. */ char BaseMathObject_owner_doc[] = "The item this is wrapping or None (read-only)."; -PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure)) +PyObject *BaseMathObject_owner_get(BaseMathObject *self, void * /*closure*/) { PyObject *ret = self->cb_user ? self->cb_user : Py_None; return Py_INCREF_RET(ret); @@ -653,21 +653,21 @@ PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure)) char BaseMathObject_is_wrapped_doc[] = "True when this object wraps external data (read-only).\n\n:type: boolean"; -PyObject *BaseMathObject_is_wrapped_get(BaseMathObject *self, void *UNUSED(closure)) +PyObject *BaseMathObject_is_wrapped_get(BaseMathObject *self, void * /*closure*/) { return PyBool_FromLong((self->flag & BASE_MATH_FLAG_IS_WRAP) != 0); } char BaseMathObject_is_frozen_doc[] = "True when this object has been frozen (read-only).\n\n:type: boolean"; -PyObject *BaseMathObject_is_frozen_get(BaseMathObject *self, void *UNUSED(closure)) +PyObject *BaseMathObject_is_frozen_get(BaseMathObject *self, void * /*closure*/) { return PyBool_FromLong((self->flag & BASE_MATH_FLAG_IS_FROZEN) != 0); } char BaseMathObject_is_valid_doc[] = "True when the owner of this data is valid.\n\n:type: boolean"; -PyObject *BaseMathObject_is_valid_get(BaseMathObject *self, void *UNUSED(closure)) +PyObject *BaseMathObject_is_valid_get(BaseMathObject *self, void * /*closure*/) { return PyBool_FromLong(BaseMath_CheckCallback(self) == 0); } @@ -682,9 +682,9 @@ char BaseMathObject_freeze_doc[] = " :return: An instance of this object.\n"; PyObject *BaseMathObject_freeze(BaseMathObject *self) { - if ((self->flag & BASE_MATH_FLAG_IS_WRAP) || (self->cb_user != NULL)) { + if ((self->flag & BASE_MATH_FLAG_IS_WRAP) || (self->cb_user != nullptr)) { PyErr_SetString(PyExc_TypeError, "Cannot freeze wrapped/owned data"); - return NULL; + return nullptr; } self->flag |= BASE_MATH_FLAG_IS_FROZEN; @@ -740,13 +740,13 @@ void BaseMathObject_dealloc(BaseMathObject *self) int BaseMathObject_is_gc(BaseMathObject *self) { - return self->cb_user != NULL; + return self->cb_user != nullptr; } PyObject *_BaseMathObject_new_impl(PyTypeObject *root_type, PyTypeObject *base_type) { PyObject *obj; - if (ELEM(base_type, NULL, root_type)) { + if (ELEM(base_type, nullptr, root_type)) { obj = _PyObject_GC_New(root_type); if (obj) { BLI_assert(BaseMathObject_is_tracked((BaseMathObject *)obj) == false); @@ -768,7 +768,7 @@ PyObject *_BaseMathObject_new_impl(PyTypeObject *root_type, PyTypeObject *base_t /*----------------------------MODULE INIT-------------------------*/ static PyMethodDef M_Mathutils_methods[] = { - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyModuleDef M_Mathutils_module_def = { @@ -777,10 +777,10 @@ static PyModuleDef M_Mathutils_module_def = { /*m_doc*/ M_Mathutils_doc, /*m_size*/ 0, /*m_methods*/ M_Mathutils_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; /* submodules only */ @@ -799,22 +799,22 @@ PyMODINIT_FUNC PyInit_mathutils(void) PyObject *sys_modules = PyImport_GetModuleDict(); if (PyType_Ready(&vector_Type) < 0) { - return NULL; + return nullptr; } if (PyType_Ready(&matrix_Type) < 0) { - return NULL; + return nullptr; } if (PyType_Ready(&matrix_access_Type) < 0) { - return NULL; + return nullptr; } if (PyType_Ready(&euler_Type) < 0) { - return NULL; + return nullptr; } if (PyType_Ready(&quaternion_Type) < 0) { - return NULL; + return nullptr; } if (PyType_Ready(&color_Type) < 0) { - return NULL; + return nullptr; } mod = PyModule_Create(&M_Mathutils_module_def); diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.cc similarity index 89% rename from source/blender/python/mathutils/mathutils_Color.c rename to source/blender/python/mathutils/mathutils_Color.cc index 4b3e8740bc7..4ef4cda8790 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.cc @@ -68,7 +68,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds) PyErr_SetString(PyExc_TypeError, "mathutils.Color(): " "takes no keyword args"); - return NULL; + return nullptr; } switch (PyTuple_GET_SIZE(args)) { @@ -78,14 +78,14 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (mathutils_array_parse( col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()") == -1) { - return NULL; + return nullptr; } break; default: PyErr_SetString(PyExc_TypeError, "mathutils.Color(): " "more than a single arg given"); - return NULL; + return nullptr; } return Color_CreatePyObject(col, type); } @@ -231,7 +231,7 @@ PyDoc_STRVAR(Color_copy_doc, static PyObject *Color_copy(ColorObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return Color_CreatePyObject(self->col, Py_TYPE(self)); @@ -239,7 +239,7 @@ static PyObject *Color_copy(ColorObject *self) static PyObject *Color_deepcopy(ColorObject *self, PyObject *args) { if (!PyC_CheckArgs_DeepCopy(args)) { - return NULL; + return nullptr; } return Color_copy(self); } @@ -255,7 +255,7 @@ static PyObject *Color_repr(ColorObject *self) PyObject *ret, *tuple; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } tuple = Color_to_tuple_ex(self, -1); @@ -272,7 +272,7 @@ static PyObject *Color_str(ColorObject *self) DynStr *ds; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } ds = BLI_dynstr_new(); @@ -300,7 +300,7 @@ static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op) ColorObject *colB = (ColorObject *)b; if (BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1) { - return NULL; + return nullptr; } ok = EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1; @@ -322,7 +322,7 @@ static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op) break; default: PyErr_BadArgument(); - return NULL; + return nullptr; } return Py_INCREF_RET(res); @@ -354,7 +354,7 @@ static Py_hash_t Color_hash(ColorObject *self) * \{ */ /** Sequence length: `len(object)`. */ -static Py_ssize_t Color_len(ColorObject *UNUSED(self)) +static Py_ssize_t Color_len(ColorObject * /*self*/) { return COLOR_SIZE; } @@ -370,11 +370,11 @@ static PyObject *Color_item(ColorObject *self, Py_ssize_t i) PyErr_SetString(PyExc_IndexError, "color[item]: " "array index out of range"); - return NULL; + return nullptr; } if (BaseMath_ReadIndexCallback(self, i) == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(self->col[i]); @@ -424,7 +424,7 @@ static PyObject *Color_slice(ColorObject *self, int begin, int end) int count; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } CLAMP(begin, 0, COLOR_SIZE); @@ -487,7 +487,7 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item) Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) { - return NULL; + return nullptr; } if (i < 0) { i += COLOR_SIZE; @@ -498,7 +498,7 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item) Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) { - return NULL; + return nullptr; } if (slicelength <= 0) { @@ -509,12 +509,12 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item) } PyErr_SetString(PyExc_IndexError, "slice steps not supported with color"); - return NULL; + return nullptr; } PyErr_Format( PyExc_TypeError, "color indices must be integers, not %.200s", Py_TYPE(item)->tp_name); - return NULL; + return nullptr; } /** Sequence generic subscript (set): `object[...] = x`. */ @@ -559,7 +559,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu /** Addition: `object + object`. */ static PyObject *Color_add(PyObject *v1, PyObject *v2) { - ColorObject *color1 = NULL, *color2 = NULL; + ColorObject *color1 = nullptr, *color2 = nullptr; float col[COLOR_SIZE]; if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) { @@ -568,13 +568,13 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2) "invalid type for this operation", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } color1 = (ColorObject *)v1; color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) { - return NULL; + return nullptr; } add_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE); @@ -585,7 +585,7 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2) /** Addition in-place: `object += object`. */ static PyObject *Color_iadd(PyObject *v1, PyObject *v2) { - ColorObject *color1 = NULL, *color2 = NULL; + ColorObject *color1 = nullptr, *color2 = nullptr; if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) { PyErr_Format(PyExc_TypeError, @@ -593,13 +593,13 @@ static PyObject *Color_iadd(PyObject *v1, PyObject *v2) "invalid type for this operation", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } color1 = (ColorObject *)v1; color2 = (ColorObject *)v2; if (BaseMath_ReadCallback_ForWrite(color1) == -1 || BaseMath_ReadCallback(color2) == -1) { - return NULL; + return nullptr; } add_vn_vn(color1->col, color2->col, COLOR_SIZE); @@ -612,7 +612,7 @@ static PyObject *Color_iadd(PyObject *v1, PyObject *v2) /** Subtraction: `object - object`. */ static PyObject *Color_sub(PyObject *v1, PyObject *v2) { - ColorObject *color1 = NULL, *color2 = NULL; + ColorObject *color1 = nullptr, *color2 = nullptr; float col[COLOR_SIZE]; if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) { @@ -621,13 +621,13 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2) "invalid type for this operation", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } color1 = (ColorObject *)v1; color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) { - return NULL; + return nullptr; } sub_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE); @@ -638,7 +638,7 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2) /** Subtraction in-place: `object -= object`. */ static PyObject *Color_isub(PyObject *v1, PyObject *v2) { - ColorObject *color1 = NULL, *color2 = NULL; + ColorObject *color1 = nullptr, *color2 = nullptr; if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) { PyErr_Format(PyExc_TypeError, @@ -646,13 +646,13 @@ static PyObject *Color_isub(PyObject *v1, PyObject *v2) "invalid type for this operation", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } color1 = (ColorObject *)v1; color2 = (ColorObject *)v2; if (BaseMath_ReadCallback_ForWrite(color1) == -1 || BaseMath_ReadCallback(color2) == -1) { - return NULL; + return nullptr; } sub_vn_vn(color1->col, color2->col, COLOR_SIZE); @@ -672,19 +672,19 @@ static PyObject *color_mul_float(ColorObject *color, const float scalar) /** Multiplication: `object * object`. */ static PyObject *Color_mul(PyObject *v1, PyObject *v2) { - ColorObject *color1 = NULL, *color2 = NULL; + ColorObject *color1 = nullptr, *color2 = nullptr; float scalar; if (ColorObject_Check(v1)) { color1 = (ColorObject *)v1; if (BaseMath_ReadCallback(color1) == -1) { - return NULL; + return nullptr; } } if (ColorObject_Check(v2)) { color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color2) == -1) { - return NULL; + return nullptr; } } @@ -711,31 +711,31 @@ static PyObject *Color_mul(PyObject *v1, PyObject *v2) "'%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } /** Division: `object / object`. */ static PyObject *Color_div(PyObject *v1, PyObject *v2) { - ColorObject *color1 = NULL; + ColorObject *color1 = nullptr; float scalar; if (ColorObject_Check(v1)) { color1 = (ColorObject *)v1; if (BaseMath_ReadCallback(color1) == -1) { - return NULL; + return nullptr; } } else { PyErr_SetString(PyExc_TypeError, "Color division not supported in this order"); - return NULL; + return nullptr; } /* make sure v1 is always the vector */ if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR * FLOAT */ if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Color division: divide by zero error"); - return NULL; + return nullptr; } return color_mul_float(color1, 1.0f / scalar); } @@ -745,7 +745,7 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2) "'%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } /** Multiplication in-place: `object *= object`. */ @@ -755,7 +755,7 @@ static PyObject *Color_imul(PyObject *v1, PyObject *v2) float scalar; if (BaseMath_ReadCallback_ForWrite(color) == -1) { - return NULL; + return nullptr; } /* only support color *= float */ @@ -768,7 +768,7 @@ static PyObject *Color_imul(PyObject *v1, PyObject *v2) "invalid type for this operation", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } (void)BaseMath_WriteCallback(color); @@ -783,14 +783,14 @@ static PyObject *Color_idiv(PyObject *v1, PyObject *v2) float scalar; if (BaseMath_ReadCallback_ForWrite(color) == -1) { - return NULL; + return nullptr; } /* only support color /= float */ if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR /= FLOAT */ if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Color division: divide by zero error"); - return NULL; + return nullptr; } mul_vn_fl(color->col, COLOR_SIZE, 1.0f / scalar); @@ -801,7 +801,7 @@ static PyObject *Color_idiv(PyObject *v1, PyObject *v2) "invalid type for this operation", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } (void)BaseMath_WriteCallback(color); @@ -815,7 +815,7 @@ static PyObject *Color_neg(ColorObject *self) float tcol[COLOR_SIZE]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } negate_vn_vn(tcol, self->col, COLOR_SIZE); @@ -830,15 +830,15 @@ static PyObject *Color_neg(ColorObject *self) static PySequenceMethods Color_SeqMethods = { /*sq_length*/ (lenfunc)Color_len, - /*sq_concat*/ NULL, - /*sq_repeat*/ NULL, + /*sq_concat*/ nullptr, + /*sq_repeat*/ nullptr, /*sq_item*/ (ssizeargfunc)Color_item, - /*was_sq_slice*/ NULL, /* DEPRECATED. */ + /*was_sq_slice*/ nullptr, /* DEPRECATED. */ /*sq_ass_item*/ (ssizeobjargproc)Color_ass_item, - /*was_sq_ass_slice*/ NULL, /* DEPRECATED. */ - /*sq_contains*/ NULL, - /*sq_inplace_concat*/ NULL, - /*sq_inplace_repeat*/ NULL, + /*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */ + /*sq_contains*/ nullptr, + /*sq_inplace_concat*/ nullptr, + /*sq_inplace_repeat*/ nullptr, }; static PyMappingMethods Color_AsMapping = { @@ -851,39 +851,39 @@ static PyNumberMethods Color_NumMethods = { /*nb_add*/ (binaryfunc)Color_add, /*nb_subtract*/ (binaryfunc)Color_sub, /*nb_multiply*/ (binaryfunc)Color_mul, - /*nb_remainder*/ NULL, - /*nb_divmod*/ NULL, - /*nb_power*/ NULL, + /*nb_remainder*/ nullptr, + /*nb_divmod*/ nullptr, + /*nb_power*/ nullptr, /*nb_negative*/ (unaryfunc)Color_neg, /*tp_positive*/ (unaryfunc)Color_copy, - /*tp_absolute*/ NULL, - /*tp_bool*/ NULL, - /*nb_invert*/ NULL, - /*nb_lshift*/ NULL, - /*nb_rshift*/ NULL, - /*nb_and*/ NULL, - /*nb_xor*/ NULL, - /*nb_or*/ NULL, - /*nb_int*/ NULL, - /*nb_reserved*/ NULL, - /*nb_float*/ NULL, + /*tp_absolute*/ nullptr, + /*tp_bool*/ nullptr, + /*nb_invert*/ nullptr, + /*nb_lshift*/ nullptr, + /*nb_rshift*/ nullptr, + /*nb_and*/ nullptr, + /*nb_xor*/ nullptr, + /*nb_or*/ nullptr, + /*nb_int*/ nullptr, + /*nb_reserved*/ nullptr, + /*nb_float*/ nullptr, /*nb_inplace_add*/ Color_iadd, /*nb_inplace_subtract*/ Color_isub, /*nb_inplace_multiply*/ Color_imul, - /*nb_inplace_remainder*/ NULL, - /*nb_inplace_power*/ NULL, - /*nb_inplace_lshift*/ NULL, - /*nb_inplace_rshift*/ NULL, - /*nb_inplace_and*/ NULL, - /*nb_inplace_xor*/ NULL, - /*nb_inplace_or*/ NULL, - /*nb_floor_divide*/ NULL, + /*nb_inplace_remainder*/ nullptr, + /*nb_inplace_power*/ nullptr, + /*nb_inplace_lshift*/ nullptr, + /*nb_inplace_rshift*/ nullptr, + /*nb_inplace_and*/ nullptr, + /*nb_inplace_xor*/ nullptr, + /*nb_inplace_or*/ nullptr, + /*nb_floor_divide*/ nullptr, /*nb_true_divide*/ Color_div, - /*nb_inplace_floor_divide*/ NULL, + /*nb_inplace_floor_divide*/ nullptr, /*nb_inplace_true_divide*/ Color_idiv, - /*nb_index*/ NULL, - /*nb_matrix_multiply*/ NULL, - /*nb_inplace_matrix_multiply*/ NULL, + /*nb_index*/ nullptr, + /*nb_matrix_multiply*/ nullptr, + /*nb_inplace_matrix_multiply*/ nullptr, }; /** \} */ @@ -920,7 +920,7 @@ static PyObject *Color_channel_hsv_get(ColorObject *self, void *type) const int i = POINTER_AS_INT(type); if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2])); @@ -959,13 +959,13 @@ static int Color_channel_hsv_set(ColorObject *self, PyObject *value, void *type) PyDoc_STRVAR(Color_hsv_doc, "HSV Values in [0, 1].\n\n:type: float triplet"); /** Color channel HSV (get): `x = color.hsv`. */ -static PyObject *Color_hsv_get(ColorObject *self, void *UNUSED(closure)) +static PyObject *Color_hsv_get(ColorObject *self, void * /*closure*/) { float hsv[3]; PyObject *ret; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2])); @@ -977,7 +977,7 @@ static PyObject *Color_hsv_get(ColorObject *self, void *UNUSED(closure)) } /** Color channel HSV (set): `color.hsv = x`. */ -static int Color_hsv_set(ColorObject *self, PyObject *value, void *UNUSED(closure)) +static int Color_hsv_set(ColorObject *self, PyObject *value, void * /*closure*/) { float hsv[3]; @@ -1030,21 +1030,25 @@ static PyGetSetDef Color_getseters[] = { {"is_wrapped", (getter)BaseMathObject_is_wrapped_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_wrapped_doc, - NULL}, + nullptr}, {"is_frozen", (getter)BaseMathObject_is_frozen_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_frozen_doc, - NULL}, + nullptr}, {"is_valid", (getter)BaseMathObject_is_valid_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_valid_doc, - NULL}, - {"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + nullptr}, + {"owner", + (getter)BaseMathObject_owner_get, + (setter) nullptr, + BaseMathObject_owner_doc, + nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; /** \} */ @@ -1097,7 +1101,7 @@ static PyMethodDef Color_methods[] = { Color_from_rec709_linear_to_scene_linear_doc}, #endif /* MATH_STANDALONE */ - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -1107,7 +1111,7 @@ static PyMethodDef Color_methods[] = { * \{ */ #ifdef MATH_STANDALONE -# define Color_str NULL +# define Color_str nullptr #endif PyDoc_STRVAR( @@ -1123,55 +1127,55 @@ PyDoc_STRVAR( " :arg rgb: (r, g, b) color values\n" " :type rgb: 3d vector\n"); PyTypeObject color_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "Color", /*tp_basicsize*/ sizeof(ColorObject), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)BaseMathObject_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, /*tp_repr*/ (reprfunc)Color_repr, /*tp_as_number*/ &Color_NumMethods, /*tp_as_sequence*/ &Color_SeqMethods, /*tp_as_mapping*/ &Color_AsMapping, /*tp_hash*/ (hashfunc)Color_hash, - /*tp_call*/ NULL, + /*tp_call*/ nullptr, /*tp_str*/ (reprfunc)Color_str, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_doc*/ color_doc, /*tp_traverse*/ (traverseproc)BaseMathObject_traverse, /*tp_clear*/ (inquiry)BaseMathObject_clear, /*tp_richcompare*/ (richcmpfunc)Color_richcmpr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ Color_methods, - /*tp_members*/ NULL, + /*tp_members*/ nullptr, /*tp_getset*/ Color_getseters, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, /*tp_new*/ Color_new, - /*tp_free*/ NULL, + /*tp_free*/ nullptr, /*tp_is_gc*/ (inquiry)BaseMathObject_is_gc, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; #ifdef MATH_STANDALONE @@ -1189,20 +1193,20 @@ PyObject *Color_CreatePyObject(const float col[3], PyTypeObject *base_type) ColorObject *self; float *col_alloc; - col_alloc = PyMem_Malloc(COLOR_SIZE * sizeof(float)); - if (UNLIKELY(col_alloc == NULL)) { + col_alloc = static_cast(PyMem_Malloc(COLOR_SIZE * sizeof(float))); + if (UNLIKELY(col_alloc == nullptr)) { PyErr_SetString(PyExc_MemoryError, "Color(): " "problem allocating data"); - return NULL; + return nullptr; } self = BASE_MATH_NEW(ColorObject, color_Type, base_type); if (self) { self->col = col_alloc; - /* init callbacks as NULL */ - self->cb_user = NULL; + /* init callbacks as nullptr */ + self->cb_user = nullptr; self->cb_type = self->cb_subtype = 0; /* NEW */ @@ -1228,8 +1232,8 @@ PyObject *Color_CreatePyObject_wrap(float col[3], PyTypeObject *base_type) self = BASE_MATH_NEW(ColorObject, color_Type, base_type); if (self) { - /* init callbacks as NULL */ - self->cb_user = NULL; + /* init callbacks as nullptr */ + self->cb_user = nullptr; self->cb_type = self->cb_subtype = 0; /* WRAP */ @@ -1242,7 +1246,7 @@ PyObject *Color_CreatePyObject_wrap(float col[3], PyTypeObject *base_type) PyObject *Color_CreatePyObject_cb(PyObject *cb_user, uchar cb_type, uchar cb_subtype) { - ColorObject *self = (ColorObject *)Color_CreatePyObject(NULL, NULL); + ColorObject *self = (ColorObject *)Color_CreatePyObject(nullptr, nullptr); if (self) { Py_INCREF(cb_user); self->cb_user = cb_user; diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.cc similarity index 88% rename from source/blender/python/mathutils/mathutils_Euler.c rename to source/blender/python/mathutils/mathutils_Euler.cc index 7229bd1561a..84ebb7b8a54 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.cc @@ -96,8 +96,8 @@ static PyObject *Euler_to_tuple_ex(EulerObject *self, int ndigits) static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *seq = NULL; - const char *order_str = NULL; + PyObject *seq = nullptr; + const char *order_str = nullptr; float eul[EULER_SIZE] = {0.0f, 0.0f, 0.0f}; short order = EULER_ORDER_XYZ; @@ -106,11 +106,11 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) PyErr_SetString(PyExc_TypeError, "mathutils.Euler(): " "takes no keyword args"); - return NULL; + return nullptr; } if (!PyArg_ParseTuple(args, "|Os:mathutils.Euler", &seq, &order_str)) { - return NULL; + return nullptr; } switch (PyTuple_GET_SIZE(args)) { @@ -118,12 +118,12 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) break; case 2: if ((order = euler_order_from_string(order_str, "mathutils.Euler()")) == -1) { - return NULL; + return nullptr; } ATTR_FALLTHROUGH; case 1: if (mathutils_array_parse(eul, EULER_SIZE, EULER_SIZE, seq, "mathutils.Euler()") == -1) { - return NULL; + return nullptr; } break; } @@ -148,12 +148,12 @@ static PyObject *Euler_to_quaternion(EulerObject *self) float quat[4]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } eulO_to_quat(quat, self->eul, self->order); - return Quaternion_CreatePyObject(quat, NULL); + return Quaternion_CreatePyObject(quat, nullptr); } PyDoc_STRVAR(Euler_to_matrix_doc, @@ -168,12 +168,12 @@ static PyObject *Euler_to_matrix(EulerObject *self) float mat[9]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } eulO_to_mat3((float(*)[3])mat, self->eul, self->order); - return Matrix_CreatePyObject(mat, 3, 3, NULL); + return Matrix_CreatePyObject(mat, 3, 3, nullptr); } PyDoc_STRVAR(Euler_zero_doc, @@ -183,13 +183,13 @@ PyDoc_STRVAR(Euler_zero_doc, static PyObject *Euler_zero(EulerObject *self) { if (BaseMath_Prepare_ForWrite(self) == -1) { - return NULL; + return nullptr; } zero_v3(self->eul); if (BaseMath_WriteCallback(self) == -1) { - return NULL; + return nullptr; } Py_RETURN_NONE; @@ -214,18 +214,18 @@ static PyObject *Euler_rotate_axis(EulerObject *self, PyObject *args) PyErr_SetString(PyExc_TypeError, "Euler.rotate_axis(): " "expected an axis 'X', 'Y', 'Z' and an angle (float)"); - return NULL; + return nullptr; } if (!ELEM(axis, 'X', 'Y', 'Z')) { PyErr_SetString(PyExc_ValueError, "Euler.rotate_axis(): " "expected axis to be 'X', 'Y' or 'Z'"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } rotate_eulO(self->eul, self->order, (char)axis, angle); @@ -247,11 +247,11 @@ static PyObject *Euler_rotate(EulerObject *self, PyObject *value) float self_rmat[3][3], other_rmat[3][3], rmat[3][3]; if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1) { - return NULL; + return nullptr; } eulO_to_mat3(self_rmat, self->eul, self->order); @@ -275,7 +275,7 @@ static PyObject *Euler_make_compatible(EulerObject *self, PyObject *value) float teul[EULER_SIZE]; if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(teul, @@ -284,7 +284,7 @@ static PyObject *Euler_make_compatible(EulerObject *self, PyObject *value) value, "euler.make_compatible(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } compatible_eul(self->eul, teul); @@ -307,7 +307,7 @@ PyDoc_STRVAR(Euler_copy_doc, static PyObject *Euler_copy(EulerObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return Euler_CreatePyObject(self->eul, self->order, Py_TYPE(self)); @@ -315,7 +315,7 @@ static PyObject *Euler_copy(EulerObject *self) static PyObject *Euler_deepcopy(EulerObject *self, PyObject *args) { if (!PyC_CheckArgs_DeepCopy(args)) { - return NULL; + return nullptr; } return Euler_copy(self); } @@ -331,7 +331,7 @@ static PyObject *Euler_repr(EulerObject *self) PyObject *ret, *tuple; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } tuple = Euler_to_tuple_ex(self, -1); @@ -348,7 +348,7 @@ static PyObject *Euler_str(EulerObject *self) DynStr *ds; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } ds = BLI_dynstr_new(); @@ -380,7 +380,7 @@ static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op) EulerObject *eulB = (EulerObject *)b; if (BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1) { - return NULL; + return nullptr; } ok = ((eulA->order == eulB->order) && @@ -405,7 +405,7 @@ static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op) break; default: PyErr_BadArgument(); - return NULL; + return nullptr; } return Py_INCREF_RET(res); @@ -437,7 +437,7 @@ static Py_hash_t Euler_hash(EulerObject *self) * \{ */ /** Sequence length: `len(object)`. */ -static Py_ssize_t Euler_len(EulerObject *UNUSED(self)) +static Py_ssize_t Euler_len(EulerObject * /*self*/) { return EULER_SIZE; } @@ -453,11 +453,11 @@ static PyObject *Euler_item(EulerObject *self, Py_ssize_t i) PyErr_SetString(PyExc_IndexError, "euler[attribute]: " "array index out of range"); - return NULL; + return nullptr; } if (BaseMath_ReadIndexCallback(self, i) == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(self->eul[i]); @@ -507,7 +507,7 @@ static PyObject *Euler_slice(EulerObject *self, int begin, int end) int count; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } CLAMP(begin, 0, EULER_SIZE); @@ -570,7 +570,7 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item) Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) { - return NULL; + return nullptr; } if (i < 0) { i += EULER_SIZE; @@ -581,7 +581,7 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item) Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) { - return NULL; + return nullptr; } if (slicelength <= 0) { @@ -592,12 +592,12 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item) } PyErr_SetString(PyExc_IndexError, "slice steps not supported with eulers"); - return NULL; + return nullptr; } PyErr_Format( PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name); - return NULL; + return nullptr; } /** Sequence generic subscript (set): `object[...] = x`. */ @@ -641,15 +641,15 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu static PySequenceMethods Euler_SeqMethods = { /*sq_length*/ (lenfunc)Euler_len, - /*sq_concat*/ NULL, - /*sq_repeat*/ NULL, + /*sq_concat*/ nullptr, + /*sq_repeat*/ nullptr, /*sq_item*/ (ssizeargfunc)Euler_item, - /*was_sq_slice*/ NULL, /* DEPRECATED. */ + /*was_sq_slice*/ nullptr, /* DEPRECATED. */ /*sq_ass_item*/ (ssizeobjargproc)Euler_ass_item, - /*was_sq_ass_slice*/ NULL, /* DEPRECATED. */ - /*sq_contains*/ NULL, - /*sq_inplace_concat*/ NULL, - /*sq_inplace_repeat*/ NULL, + /*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */ + /*sq_contains*/ nullptr, + /*sq_inplace_concat*/ nullptr, + /*sq_inplace_repeat*/ nullptr, }; static PyMappingMethods Euler_AsMapping = { @@ -682,17 +682,17 @@ static int Euler_axis_set(EulerObject *self, PyObject *value, void *type) PyDoc_STRVAR( Euler_order_doc, "Euler rotation order.\n\n:type: string in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']"); -static PyObject *Euler_order_get(EulerObject *self, void *UNUSED(closure)) +static PyObject *Euler_order_get(EulerObject *self, void * /*closure*/) { if (BaseMath_ReadCallback(self) == -1) { /* can read order too */ - return NULL; + return nullptr; } return PyUnicode_FromString(euler_order_str(self)); } -static int Euler_order_set(EulerObject *self, PyObject *value, void *UNUSED(closure)) +static int Euler_order_set(EulerObject *self, PyObject *value, void * /*closure*/) { const char *order_str; short order; @@ -701,7 +701,7 @@ static int Euler_order_set(EulerObject *self, PyObject *value, void *UNUSED(clos return -1; } - if (((order_str = PyUnicode_AsUTF8(value)) == NULL) || + if (((order_str = PyUnicode_AsUTF8(value)) == nullptr) || ((order = euler_order_from_string(order_str, "euler.order")) == -1)) { return -1; @@ -722,25 +722,29 @@ static PyGetSetDef Euler_getseters[] = { {"x", (getter)Euler_axis_get, (setter)Euler_axis_set, Euler_axis_doc, (void *)0}, {"y", (getter)Euler_axis_get, (setter)Euler_axis_set, Euler_axis_doc, (void *)1}, {"z", (getter)Euler_axis_get, (setter)Euler_axis_set, Euler_axis_doc, (void *)2}, - {"order", (getter)Euler_order_get, (setter)Euler_order_set, Euler_order_doc, (void *)NULL}, + {"order", (getter)Euler_order_get, (setter)Euler_order_set, Euler_order_doc, (void *)nullptr}, {"is_wrapped", (getter)BaseMathObject_is_wrapped_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_wrapped_doc, - NULL}, + nullptr}, {"is_frozen", (getter)BaseMathObject_is_frozen_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_frozen_doc, - NULL}, + nullptr}, {"is_valid", (getter)BaseMathObject_is_valid_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_valid_doc, - NULL}, - {"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + nullptr}, + {"owner", + (getter)BaseMathObject_owner_get, + (setter) nullptr, + BaseMathObject_owner_doc, + nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; /** \} */ @@ -762,7 +766,7 @@ static PyMethodDef Euler_methods[] = { /* base-math methods */ {"freeze", (PyCFunction)BaseMathObject_freeze, METH_NOARGS, BaseMathObject_freeze_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -772,7 +776,7 @@ static PyMethodDef Euler_methods[] = { * \{ */ #ifdef MATH_STANDALONE -# define Euler_str NULL +# define Euler_str nullptr #endif PyDoc_STRVAR( @@ -788,55 +792,55 @@ PyDoc_STRVAR( " :arg order: Optional order of the angles, a permutation of ``XYZ``.\n" " :type order: str\n"); PyTypeObject euler_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "Euler", /*tp_basicsize*/ sizeof(EulerObject), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)BaseMathObject_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, /*tp_repr*/ (reprfunc)Euler_repr, - /*tp_as_number*/ NULL, + /*tp_as_number*/ nullptr, /*tp_as_sequence*/ &Euler_SeqMethods, /*tp_as_mapping*/ &Euler_AsMapping, /*tp_hash*/ (hashfunc)Euler_hash, - /*tp_call*/ NULL, + /*tp_call*/ nullptr, /*tp_str*/ (reprfunc)Euler_str, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_doc*/ euler_doc, /*tp_traverse*/ (traverseproc)BaseMathObject_traverse, /*tp_clear*/ (inquiry)BaseMathObject_clear, /*tp_richcompare*/ (richcmpfunc)Euler_richcmpr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ Euler_methods, - /*tp_members*/ NULL, + /*tp_members*/ nullptr, /*tp_getset*/ Euler_getseters, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, /*tp_new*/ Euler_new, - /*tp_free*/ NULL, + /*tp_free*/ nullptr, /*tp_is_gc*/ (inquiry)BaseMathObject_is_gc, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; #ifdef MATH_STANDALONE @@ -854,20 +858,20 @@ PyObject *Euler_CreatePyObject(const float eul[3], const short order, PyTypeObje EulerObject *self; float *eul_alloc; - eul_alloc = PyMem_Malloc(EULER_SIZE * sizeof(float)); - if (UNLIKELY(eul_alloc == NULL)) { + eul_alloc = static_cast(PyMem_Malloc(EULER_SIZE * sizeof(float))); + if (UNLIKELY(eul_alloc == nullptr)) { PyErr_SetString(PyExc_MemoryError, "Euler(): " "problem allocating data"); - return NULL; + return nullptr; } self = BASE_MATH_NEW(EulerObject, euler_Type, base_type); if (self) { self->eul = eul_alloc; - /* init callbacks as NULL */ - self->cb_user = NULL; + /* init callbacks as nullptr */ + self->cb_user = nullptr; self->cb_type = self->cb_subtype = 0; if (eul) { @@ -893,8 +897,8 @@ PyObject *Euler_CreatePyObject_wrap(float eul[3], const short order, PyTypeObjec self = BASE_MATH_NEW(EulerObject, euler_Type, base_type); if (self) { - /* init callbacks as NULL */ - self->cb_user = NULL; + /* init callbacks as nullptr */ + self->cb_user = nullptr; self->cb_type = self->cb_subtype = 0; self->eul = eul; @@ -911,7 +915,7 @@ PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, uchar cb_type, uchar cb_subtype) { - EulerObject *self = (EulerObject *)Euler_CreatePyObject(NULL, order, NULL); + EulerObject *self = (EulerObject *)Euler_CreatePyObject(nullptr, order, nullptr); if (self) { Py_INCREF(cb_user); self->cb_user = cb_user; diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.cc similarity index 91% rename from source/blender/python/mathutils/mathutils_Matrix.c rename to source/blender/python/mathutils/mathutils_Matrix.cc index 9a1d4c18ea2..83a0316fb13 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.cc @@ -21,10 +21,10 @@ # include "BLI_string.h" #endif -typedef enum eMatrixAccess_t { +enum eMatrixAccess_t { MAT_ACCESS_ROW, MAT_ACCESS_COL, -} eMatrixAccess_t; +}; static PyObject *Matrix_copy_notest(MatrixObject *self, const float *matrix); static PyObject *Matrix_copy(MatrixObject *self); @@ -285,11 +285,11 @@ static PyObject *matrix__apply_to_copy(PyObject *(*matrix_func)(MatrixObject *), } /* error */ Py_DECREF(ret); - return NULL; + return nullptr; } /* copy may fail if the read callback errors out */ - return NULL; + return nullptr; } static bool matrix_is_identity(MatrixObject *self) @@ -596,12 +596,12 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) PyErr_SetString(PyExc_TypeError, "Matrix(): " "takes no keyword args"); - return NULL; + return nullptr; } switch (PyTuple_GET_SIZE(args)) { case 0: - return Matrix_CreatePyObject(NULL, 4, 4, type); + return Matrix_CreatePyObject(nullptr, 4, 4, type); case 1: { PyObject *arg = PyTuple_GET_ITEM(args, 0); @@ -619,7 +619,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (col_num >= 2 && col_num <= 4) { /* Sane row & col size, new matrix and assign as slice. */ - PyObject *matrix = Matrix_CreatePyObject(NULL, col_num, row_num, type); + PyObject *matrix = Matrix_CreatePyObject(nullptr, col_num, row_num, type); if (Matrix_ass_slice((MatrixObject *)matrix, 0, INT_MAX, arg) == 0) { return matrix; } @@ -635,7 +635,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) PyErr_SetString(PyExc_TypeError, "Matrix(): " "expects no args or a single arg containing 2-4 numeric sequences"); - return NULL; + return nullptr; } /** \} */ @@ -659,17 +659,17 @@ static PyObject *C_Matrix_Identity(PyObject *cls, PyObject *args) int matSize; if (!PyArg_ParseTuple(args, "i:Matrix.Identity", &matSize)) { - return NULL; + return nullptr; } if (matSize < 2 || matSize > 4) { PyErr_SetString(PyExc_RuntimeError, "Matrix.Identity(): " "size must be between 2 and 4"); - return NULL; + return nullptr; } - return Matrix_CreatePyObject(NULL, matSize, matSize, (PyTypeObject *)cls); + return Matrix_CreatePyObject(nullptr, matSize, matSize, (PyTypeObject *)cls); } /** Rotation constructor: `mathutils.Matrix.Rotation()`. */ @@ -689,28 +689,28 @@ PyDoc_STRVAR(C_Matrix_Rotation_doc, " :rtype: :class:`Matrix`\n"); static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) { - PyObject *vec = NULL; - const char *axis = NULL; + PyObject *vec = nullptr; + const char *axis = nullptr; int matSize; double angle; /* Use double because of precision problems at high values. */ float mat[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; if (!PyArg_ParseTuple(args, "di|O:Matrix.Rotation", &angle, &matSize, &vec)) { - return NULL; + return nullptr; } if (vec && PyUnicode_Check(vec)) { axis = PyUnicode_AsUTF8((PyObject *)vec); - if (axis == NULL || axis[0] == '\0' || axis[1] != '\0' || axis[0] < 'X' || axis[0] > 'Z') { + if (axis == nullptr || axis[0] == '\0' || axis[1] != '\0' || axis[0] < 'X' || axis[0] > 'Z') { PyErr_SetString(PyExc_ValueError, "Matrix.Rotation(): " "3rd argument axis value must be a 3D vector " "or a string in 'X', 'Y', 'Z'"); - return NULL; + return nullptr; } /* use the string */ - vec = NULL; + vec = nullptr; } angle = angle_wrap_rad(angle); @@ -719,19 +719,19 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) PyErr_SetString(PyExc_ValueError, "Matrix.Rotation(): " "can only return a 2x2 3x3 or 4x4 matrix"); - return NULL; + return nullptr; } - if (matSize == 2 && (vec != NULL)) { + if (matSize == 2 && (vec != nullptr)) { PyErr_SetString(PyExc_ValueError, "Matrix.Rotation(): " "cannot create a 2x2 rotation matrix around arbitrary axis"); - return NULL; + return nullptr; } - if (ELEM(matSize, 3, 4) && (axis == NULL) && (vec == NULL)) { + if (ELEM(matSize, 3, 4) && (axis == nullptr) && (vec == nullptr)) { PyErr_SetString(PyExc_ValueError, "Matrix.Rotation(): " "axis of rotation for 3d and 4d matrices is required"); - return NULL; + return nullptr; } /* check for valid vector/axis above */ @@ -741,7 +741,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) if (mathutils_array_parse( tvec, 3, 3, vec, "Matrix.Rotation(angle, size, axis), invalid 'axis' arg") == -1) { - return NULL; + return nullptr; } axis_angle_to_mat3((float(*)[3])mat, tvec, angle); @@ -780,7 +780,7 @@ static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value) if (mathutils_array_parse( mat[3], 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1) { - return NULL; + return nullptr; } return Matrix_CreatePyObject(&mat[0][0], 4, 4, (PyTypeObject *)cls); @@ -805,7 +805,7 @@ static PyObject *C_Matrix_Diagonal(PyObject *cls, PyObject *value) vec, 2, 4, value, "mathutils.Matrix.Diagonal(vector), invalid vector arg"); if (size == -1) { - return NULL; + return nullptr; } for (int i = 0; i < size; i++) { @@ -831,7 +831,7 @@ PyDoc_STRVAR(C_Matrix_Scale_doc, " :rtype: :class:`Matrix`\n"); static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) { - PyObject *vec = NULL; + PyObject *vec = nullptr; int vec_num; float tvec[3]; float factor; @@ -839,13 +839,13 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) float mat[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; if (!PyArg_ParseTuple(args, "fi|O:Matrix.Scale", &factor, &matSize, &vec)) { - return NULL; + return nullptr; } if (!ELEM(matSize, 2, 3, 4)) { PyErr_SetString(PyExc_ValueError, "Matrix.Scale(): " "can only return a 2x2 3x3 or 4x4 matrix"); - return NULL; + return nullptr; } if (vec) { vec_num = (matSize == 2 ? 2 : 3); @@ -853,10 +853,10 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) tvec, vec_num, vec_num, vec, "Matrix.Scale(factor, size, axis), invalid 'axis' arg") == -1) { - return NULL; + return nullptr; } } - if (vec == NULL) { /* scaling along axis */ + if (vec == nullptr) { /* scaling along axis */ if (matSize == 2) { mat[0] = factor; mat[3] = factor; @@ -926,13 +926,13 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) float mat[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; if (!PyArg_ParseTuple(args, "Oi:Matrix.OrthoProjection", &axis, &matSize)) { - return NULL; + return nullptr; } if (!ELEM(matSize, 2, 3, 4)) { PyErr_SetString(PyExc_ValueError, "Matrix.OrthoProjection(): " "can only return a 2x2 3x3 or 4x4 matrix"); - return NULL; + return nullptr; } if (PyUnicode_Check(axis)) { /* ortho projection onto cardinal plane */ @@ -950,7 +950,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) "Matrix.OrthoProjection(): " "unknown plane, expected: X, Y, not '%.200s'", plane); - return NULL; + return nullptr; } } else { @@ -971,7 +971,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) "Matrix.OrthoProjection(): " "unknown plane, expected: XY, XZ, YZ, not '%.200s'", plane); - return NULL; + return nullptr; } } } @@ -987,7 +987,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) axis, "Matrix.OrthoProjection(axis, size), invalid 'axis' arg") == -1) { - return NULL; + return nullptr; } /* normalize arbitrary axis */ @@ -1047,13 +1047,13 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) float mat[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; if (!PyArg_ParseTuple(args, "siO:Matrix.Shear", &plane, &matSize, &fac)) { - return NULL; + return nullptr; } if (!ELEM(matSize, 2, 3, 4)) { PyErr_SetString(PyExc_ValueError, "Matrix.Shear(): " "can only return a 2x2 3x3 or 4x4 matrix"); - return NULL; + return nullptr; } if (matSize == 2) { @@ -1063,7 +1063,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) PyErr_SetString(PyExc_TypeError, "Matrix.Shear(): " "the factor to be a float"); - return NULL; + return nullptr; } /* unit */ @@ -1080,7 +1080,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) PyErr_SetString(PyExc_ValueError, "Matrix.Shear(): " "expected: X, Y or wrong matrix size for shearing plane"); - return NULL; + return nullptr; } } else { @@ -1088,7 +1088,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) float factor[2]; if (mathutils_array_parse(factor, 2, 2, fac, "Matrix.Shear()") == -1) { - return NULL; + return nullptr; } /* unit */ @@ -1112,7 +1112,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) PyErr_SetString(PyExc_ValueError, "Matrix.Shear(): " "expected: X, Y, XY, XZ, YZ"); - return NULL; + return nullptr; } } @@ -1146,7 +1146,7 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args) float mat[4][4], loc[3]; if (!PyArg_ParseTuple(args, "OOO:Matrix.LocRotScale", &loc_obj, &rot_obj, &scale_obj)) { - return NULL; + return nullptr; } /* Decode location. */ @@ -1156,7 +1156,7 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args) else if (mathutils_array_parse( loc, 3, 3, loc_obj, "Matrix.LocRotScale(), invalid location argument") == -1) { - return NULL; + return nullptr; } /* Decode rotation. */ @@ -1167,7 +1167,7 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args) QuaternionObject *quat_obj = (QuaternionObject *)rot_obj; if (BaseMath_ReadCallback(quat_obj) == -1) { - return NULL; + return nullptr; } quat_to_mat4(mat, quat_obj->quat); @@ -1176,7 +1176,7 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args) EulerObject *eul_obj = (EulerObject *)rot_obj; if (BaseMath_ReadCallback(eul_obj) == -1) { - return NULL; + return nullptr; } eulO_to_mat4(mat, eul_obj->eul, eul_obj->order); @@ -1185,7 +1185,7 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args) MatrixObject *mat_obj = (MatrixObject *)rot_obj; if (BaseMath_ReadCallback(mat_obj) == -1) { - return NULL; + return nullptr; } if (mat_obj->col_num == 3 && mat_obj->row_num == 3) { @@ -1195,14 +1195,14 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args) PyErr_SetString(PyExc_ValueError, "Matrix.LocRotScale(): " "inappropriate rotation matrix size - expects 3x3 matrix"); - return NULL; + return nullptr; } } else { PyErr_SetString(PyExc_ValueError, "Matrix.LocRotScale(): " "rotation argument must be Matrix, Quaternion, Euler or None"); - return NULL; + return nullptr; } /* Decode scale. */ @@ -1212,7 +1212,7 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args) if (mathutils_array_parse( scale, 3, 3, scale_obj, "Matrix.LocRotScale(), invalid scale argument") == -1) { - return NULL; + return nullptr; } rescale_m4(mat, scale); @@ -1241,7 +1241,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self) float quat[4]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } /* must be 3-4 cols, 3-4 rows, square matrix */ @@ -1249,7 +1249,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self) PyErr_SetString(PyExc_ValueError, "Matrix.to_quat(): " "inappropriate matrix size - expects 3x3 or 4x4 matrix"); - return NULL; + return nullptr; } if (self->row_num == 3) { mat3_to_quat(quat, (const float(*)[3])self->matrix); @@ -1257,7 +1257,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self) else { mat4_to_quat(quat, (const float(*)[4])self->matrix); } - return Quaternion_CreatePyObject(quat, NULL); + return Quaternion_CreatePyObject(quat, nullptr); } /** \} */ @@ -1283,24 +1283,24 @@ PyDoc_STRVAR(Matrix_to_euler_doc, " :rtype: :class:`Euler`\n"); static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) { - const char *order_str = NULL; + const char *order_str = nullptr; short order = EULER_ORDER_XYZ; float eul[3], eul_compatf[3]; - EulerObject *eul_compat = NULL; + EulerObject *eul_compat = nullptr; float mat[3][3]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat)) { - return NULL; + return nullptr; } if (eul_compat) { if (BaseMath_ReadCallback(eul_compat) == -1) { - return NULL; + return nullptr; } copy_v3_v3(eul_compatf, eul_compat->eul); @@ -1317,14 +1317,14 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) PyErr_SetString(PyExc_ValueError, "Matrix.to_euler(): " "inappropriate matrix size - expects 3x3 or 4x4 matrix"); - return NULL; + return nullptr; } if (order_str) { order = euler_order_from_string(order_str, "Matrix.to_euler()"); if (order == -1) { - return NULL; + return nullptr; } } @@ -1347,7 +1347,7 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) } } - return Euler_CreatePyObject(eul, order, NULL); + return Euler_CreatePyObject(eul, order, nullptr); } /** \} */ @@ -1369,21 +1369,22 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self) PyErr_SetString(PyExc_ValueError, "Matrix.resize_4x4(): " "cannot resize wrapped data - make a copy and resize that"); - return NULL; + return nullptr; } if (self->cb_user) { PyErr_SetString(PyExc_ValueError, "Matrix.resize_4x4(): " "cannot resize owned data - make a copy and resize that"); - return NULL; + return nullptr; } - self->matrix = PyMem_Realloc(self->matrix, (sizeof(float) * (MATRIX_MAX_DIM * MATRIX_MAX_DIM))); - if (self->matrix == NULL) { + self->matrix = static_cast( + PyMem_Realloc(self->matrix, (sizeof(float) * (MATRIX_MAX_DIM * MATRIX_MAX_DIM)))); + if (self->matrix == nullptr) { PyErr_SetString(PyExc_MemoryError, "Matrix.resize_4x4(): " "problem allocating pointer space"); - return NULL; + return nullptr; } unit_m4(mat); @@ -1410,7 +1411,7 @@ static PyObject *Matrix_to_NxN(MatrixObject *self, const int col_num, const int { const int mat_size = sizeof(float) * (col_num * row_num); MatrixObject *pymat = (MatrixObject *)Matrix_CreatePyObject_alloc( - PyMem_Malloc(mat_size), col_num, row_num, Py_TYPE(self)); + static_cast(PyMem_Malloc(mat_size)), col_num, row_num, Py_TYPE(self)); if ((self->row_num == row_num) && (self->col_num == col_num)) { memcpy(pymat->matrix, self->matrix, mat_size); @@ -1439,7 +1440,7 @@ PyDoc_STRVAR(Matrix_to_2x2_doc, static PyObject *Matrix_to_2x2(MatrixObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return Matrix_to_NxN(self, 2, 2); } @@ -1454,7 +1455,7 @@ PyDoc_STRVAR(Matrix_to_3x3_doc, static PyObject *Matrix_to_3x3(MatrixObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return Matrix_to_NxN(self, 3, 3); } @@ -1470,7 +1471,7 @@ static PyObject *Matrix_to_4x4(MatrixObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return Matrix_to_NxN(self, 4, 4); } @@ -1491,17 +1492,17 @@ PyDoc_STRVAR(Matrix_to_translation_doc, static PyObject *Matrix_to_translation(MatrixObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if ((self->row_num < 3) || self->col_num < 4) { PyErr_SetString(PyExc_ValueError, "Matrix.to_translation(): " "inappropriate matrix size"); - return NULL; + return nullptr; } - return Vector_CreatePyObject(MATRIX_COL_PTR(self, 3), 3, NULL); + return Vector_CreatePyObject(MATRIX_COL_PTR(self, 3), 3, nullptr); } PyDoc_STRVAR(Matrix_to_scale_doc, @@ -1521,7 +1522,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self) float size[3]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } /* Must be 3-4 cols, 3-4 rows, square matrix. */ @@ -1529,7 +1530,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self) PyErr_SetString(PyExc_ValueError, "Matrix.to_scale(): " "inappropriate matrix size, 3x3 minimum size"); - return NULL; + return nullptr; } matrix_as_3x3(mat, self); @@ -1537,7 +1538,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self) /* compatible mat4_to_loc_rot_size */ mat3_to_rot_size(rot, size, mat); - return Vector_CreatePyObject(size, 3, NULL); + return Vector_CreatePyObject(size, 3, nullptr); } /** \} */ @@ -1613,15 +1614,15 @@ PyDoc_STRVAR( static PyObject *Matrix_invert(MatrixObject *self, PyObject *args) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (matrix_invert_is_compat(self) == false) { - return NULL; + return nullptr; } if (matrix_invert_args_check(self, args, true) == false) { - return NULL; + return nullptr; } if (matrix_invert_internal(self, self->matrix)) { @@ -1632,7 +1633,7 @@ static PyObject *Matrix_invert(MatrixObject *self, PyObject *args) MatrixObject *fallback = (MatrixObject *)PyTuple_GET_ITEM(args, 0); if (BaseMath_ReadCallback(fallback) == -1) { - return NULL; + return nullptr; } if (self != fallback) { @@ -1641,7 +1642,7 @@ static PyObject *Matrix_invert(MatrixObject *self, PyObject *args) } else { matrix_invert_raise_degenerate(); - return NULL; + return nullptr; } } @@ -1664,15 +1665,15 @@ static PyObject *Matrix_inverted(MatrixObject *self, PyObject *args) float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (matrix_invert_args_check(self, args, false) == false) { - return NULL; + return nullptr; } if (matrix_invert_is_compat(self) == false) { - return NULL; + return nullptr; } if (matrix_invert_internal(self, mat)) { @@ -1686,7 +1687,7 @@ static PyObject *Matrix_inverted(MatrixObject *self, PyObject *args) } matrix_invert_raise_degenerate(); - return NULL; + return nullptr; } return Matrix_copy_notest(self, mat); @@ -1695,11 +1696,11 @@ static PyObject *Matrix_inverted(MatrixObject *self, PyObject *args) static PyObject *Matrix_inverted_noargs(MatrixObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (matrix_invert_is_compat(self) == false) { - return NULL; + return nullptr; } if (matrix_invert_internal(self, self->matrix)) { @@ -1707,7 +1708,7 @@ static PyObject *Matrix_inverted_noargs(MatrixObject *self) } else { matrix_invert_raise_degenerate(); - return NULL; + return nullptr; } (void)BaseMath_WriteCallback(self); @@ -1728,11 +1729,11 @@ PyDoc_STRVAR( static PyObject *Matrix_invert_safe(MatrixObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (matrix_invert_is_compat(self) == false) { - return NULL; + return nullptr; } matrix_invert_safe_internal(self, self->matrix); @@ -1756,11 +1757,11 @@ static PyObject *Matrix_inverted_safe(MatrixObject *self) float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (matrix_invert_is_compat(self) == false) { - return NULL; + return nullptr; } matrix_invert_safe_internal(self, mat); @@ -1787,14 +1788,14 @@ PyDoc_STRVAR( static PyObject *Matrix_adjugate(MatrixObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (self->col_num != self->row_num) { PyErr_SetString(PyExc_ValueError, "Matrix.adjugate(d): " "only square matrices are supported"); - return NULL; + return nullptr; } /* calculate the classical adjoint */ @@ -1804,7 +1805,7 @@ static PyObject *Matrix_adjugate(MatrixObject *self) else { PyErr_Format( PyExc_ValueError, "Matrix adjugate(d): size (%d) unsupported", (int)self->col_num); - return NULL; + return nullptr; } (void)BaseMath_WriteCallback(self); @@ -1839,18 +1840,18 @@ static PyObject *Matrix_rotate(MatrixObject *self, PyObject *value) float self_rmat[3][3], other_rmat[3][3], rmat[3][3]; if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (mathutils_any_to_rotmat(other_rmat, value, "matrix.rotate(value)") == -1) { - return NULL; + return nullptr; } if (self->row_num != 3 || self->col_num != 3) { PyErr_SetString(PyExc_ValueError, "Matrix.rotate(): " "must have 3x3 dimensions"); - return NULL; + return nullptr; } matrix_as_3x3(self_rmat, self); @@ -1887,11 +1888,11 @@ static PyObject *Matrix_decompose(MatrixObject *self) PyErr_SetString(PyExc_ValueError, "Matrix.decompose(): " "inappropriate matrix size - expects 4x4 matrix"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } mat4_to_loc_rot_size(loc, rot, size, (const float(*)[4])self->matrix); @@ -1899,9 +1900,9 @@ static PyObject *Matrix_decompose(MatrixObject *self) ret = PyTuple_New(3); PyTuple_SET_ITEMS(ret, - Vector_CreatePyObject(loc, 3, NULL), - Quaternion_CreatePyObject(quat, NULL), - Vector_CreatePyObject(size, 3, NULL)); + Vector_CreatePyObject(loc, 3, nullptr), + Quaternion_CreatePyObject(quat, nullptr), + Vector_CreatePyObject(size, 3, nullptr)); return ret; } @@ -1925,22 +1926,22 @@ PyDoc_STRVAR(Matrix_lerp_doc, " :rtype: :class:`Matrix`\n"); static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) { - MatrixObject *mat2 = NULL; + MatrixObject *mat2 = nullptr; float fac, mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; if (!PyArg_ParseTuple(args, "O!f:lerp", &matrix_Type, &mat2, &fac)) { - return NULL; + return nullptr; } if (self->col_num != mat2->col_num || self->row_num != mat2->row_num) { PyErr_SetString(PyExc_ValueError, "Matrix.lerp(): " "expects both matrix objects of the same dimensions"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1 || BaseMath_ReadCallback(mat2) == -1) { - return NULL; + return nullptr; } /* TODO: different sized matrix. */ @@ -1962,7 +1963,7 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) PyErr_SetString(PyExc_ValueError, "Matrix.lerp(): " "only 3x3 and 4x4 matrices supported"); - return NULL; + return nullptr; } return Matrix_CreatePyObject(mat, self->col_num, self->row_num, Py_TYPE(self)); @@ -1981,14 +1982,14 @@ PyDoc_STRVAR( static PyObject *Matrix_determinant(MatrixObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (self->col_num != self->row_num) { PyErr_SetString(PyExc_ValueError, "Matrix.determinant(): " "only square matrices are supported"); - return NULL; + return nullptr; } return PyFloat_FromDouble((double)matrix_determinant_internal(self)); @@ -2010,14 +2011,14 @@ PyDoc_STRVAR( static PyObject *Matrix_transpose(MatrixObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (self->col_num != self->row_num) { PyErr_SetString(PyExc_ValueError, "Matrix.transpose(d): " "only square matrices are supported"); - return NULL; + return nullptr; } if (self->col_num == 2) { @@ -2061,14 +2062,14 @@ PyDoc_STRVAR(Matrix_normalize_doc, static PyObject *Matrix_normalize(MatrixObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (self->col_num != self->row_num) { PyErr_SetString(PyExc_ValueError, "Matrix.normalize(): " "only square matrices are supported"); - return NULL; + return nullptr; } if (self->col_num == 3) { @@ -2114,13 +2115,13 @@ PyDoc_STRVAR(Matrix_zero_doc, static PyObject *Matrix_zero(MatrixObject *self) { if (BaseMath_Prepare_ForWrite(self) == -1) { - return NULL; + return nullptr; } copy_vn_fl(self->matrix, self->col_num * self->row_num, 0.0f); if (BaseMath_WriteCallback(self) == -1) { - return NULL; + return nullptr; } Py_RETURN_NONE; @@ -2160,20 +2161,20 @@ PyDoc_STRVAR(Matrix_identity_doc, static PyObject *Matrix_identity(MatrixObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (self->col_num != self->row_num) { PyErr_SetString(PyExc_ValueError, "Matrix.identity(): " "only square matrices are supported"); - return NULL; + return nullptr; } matrix_identity_internal(self); if (BaseMath_WriteCallback(self) == -1) { - return NULL; + return nullptr; } Py_RETURN_NONE; @@ -2201,7 +2202,7 @@ PyDoc_STRVAR(Matrix_copy_doc, static PyObject *Matrix_copy(MatrixObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return Matrix_copy_notest(self, self->matrix); @@ -2211,7 +2212,7 @@ static PyObject *Matrix_copy(MatrixObject *self) static PyObject *Matrix_deepcopy(MatrixObject *self, PyObject *args) { if (!PyC_CheckArgs_DeepCopy(args)) { - return NULL; + return nullptr; } return Matrix_copy(self); } @@ -2225,10 +2226,10 @@ static PyObject *Matrix_deepcopy(MatrixObject *self, PyObject *args) static PyObject *Matrix_repr(MatrixObject *self) { int col, row; - PyObject *rows[MATRIX_MAX_DIM] = {NULL}; + PyObject *rows[MATRIX_MAX_DIM] = {nullptr}; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } for (row = 0; row < self->row_num; row++) { @@ -2267,7 +2268,7 @@ static PyObject *Matrix_repr(MatrixObject *self) } Py_FatalError("Matrix(): invalid row size!"); - return NULL; + return nullptr; } #ifndef MATH_STANDALONE @@ -2281,7 +2282,7 @@ static PyObject *Matrix_str(MatrixObject *self) char dummy_buf[64]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } ds = BLI_dynstr_new(); @@ -2325,7 +2326,7 @@ static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op) MatrixObject *matB = (MatrixObject *)b; if (BaseMath_ReadCallback(matA) == -1 || BaseMath_ReadCallback(matB) == -1) { - return NULL; + return nullptr; } ok = ((matA->row_num == matB->row_num) && (matA->col_num == matB->col_num) && @@ -2350,7 +2351,7 @@ static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op) break; default: PyErr_BadArgument(); - return NULL; + return nullptr; } return Py_INCREF_RET(res); @@ -2398,14 +2399,14 @@ static Py_ssize_t Matrix_len(MatrixObject *self) static PyObject *Matrix_item_row(MatrixObject *self, Py_ssize_t row) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (row < 0 || row >= self->row_num) { PyErr_SetString(PyExc_IndexError, "matrix[attribute]: " "array index out of range"); - return NULL; + return nullptr; } return Vector_CreatePyObject_cb( (PyObject *)self, self->col_num, mathutils_matrix_row_cb_index, row); @@ -2417,14 +2418,14 @@ static PyObject *Matrix_item_row(MatrixObject *self, Py_ssize_t row) static PyObject *Matrix_item_col(MatrixObject *self, Py_ssize_t col) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (col < 0 || col >= self->col_num) { PyErr_SetString(PyExc_IndexError, "matrix[attribute]: " "array index out of range"); - return NULL; + return nullptr; } return Vector_CreatePyObject_cb( (PyObject *)self, self->row_num, mathutils_matrix_col_cb_index, col); @@ -2496,7 +2497,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) int count; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } CLAMP(begin, 0, self->row_num); @@ -2582,7 +2583,7 @@ static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item) Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) { - return NULL; + return nullptr; } if (i < 0) { i += self->row_num; @@ -2593,7 +2594,7 @@ static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item) Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx(item, self->row_num, &start, &stop, &step, &slicelength) < 0) { - return NULL; + return nullptr; } if (slicelength <= 0) { @@ -2604,12 +2605,12 @@ static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item) } PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrices"); - return NULL; + return nullptr; } PyErr_Format( PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name); - return NULL; + return nullptr; } /** Sequence generic subscript (set): `object[...] = x`. */ @@ -2655,7 +2656,7 @@ static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *va static PyObject *Matrix_add(PyObject *m1, PyObject *m2) { float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; - MatrixObject *mat1 = NULL, *mat2 = NULL; + MatrixObject *mat1 = nullptr, *mat2 = nullptr; mat1 = (MatrixObject *)m1; mat2 = (MatrixObject *)m2; @@ -2666,18 +2667,18 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2) "invalid type for this operation", Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name); - return NULL; + return nullptr; } if (BaseMath_ReadCallback(mat1) == -1 || BaseMath_ReadCallback(mat2) == -1) { - return NULL; + return nullptr; } if (mat1->col_num != mat2->col_num || mat1->row_num != mat2->row_num) { PyErr_SetString(PyExc_ValueError, "Matrix addition: " "matrices must have the same dimensions for this operation"); - return NULL; + return nullptr; } add_vn_vnvn(mat, mat1->matrix, mat2->matrix, mat1->col_num * mat1->row_num); @@ -2689,7 +2690,7 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2) static PyObject *Matrix_sub(PyObject *m1, PyObject *m2) { float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; - MatrixObject *mat1 = NULL, *mat2 = NULL; + MatrixObject *mat1 = nullptr, *mat2 = nullptr; mat1 = (MatrixObject *)m1; mat2 = (MatrixObject *)m2; @@ -2700,18 +2701,18 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2) "invalid type for this operation", Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name); - return NULL; + return nullptr; } if (BaseMath_ReadCallback(mat1) == -1 || BaseMath_ReadCallback(mat2) == -1) { - return NULL; + return nullptr; } if (mat1->col_num != mat2->col_num || mat1->row_num != mat2->row_num) { PyErr_SetString(PyExc_ValueError, "Matrix addition: " "matrices must have the same dimensions for this operation"); - return NULL; + return nullptr; } sub_vn_vnvn(mat, mat1->matrix, mat2->matrix, mat1->col_num * mat1->row_num); @@ -2731,18 +2732,18 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) { float scalar; - MatrixObject *mat1 = NULL, *mat2 = NULL; + MatrixObject *mat1 = nullptr, *mat2 = nullptr; if (MatrixObject_Check(m1)) { mat1 = (MatrixObject *)m1; if (BaseMath_ReadCallback(mat1) == -1) { - return NULL; + return nullptr; } } if (MatrixObject_Check(m2)) { mat2 = (MatrixObject *)m2; if (BaseMath_ReadCallback(mat2) == -1) { - return NULL; + return nullptr; } } @@ -2754,7 +2755,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) PyErr_SetString(PyExc_ValueError, "matrix1 * matrix2: matrix1 number of rows/columns " "and the matrix2 number of rows/columns must be the same"); - return NULL; + return nullptr; } mul_vn_vnvn(mat, mat1->matrix, mat2->matrix, mat1->col_num * mat1->row_num); @@ -2779,7 +2780,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name); - return NULL; + return nullptr; } /** Multiplication in-place (element-wise): `object *= object`. */ @@ -2787,18 +2788,18 @@ static PyObject *Matrix_imul(PyObject *m1, PyObject *m2) { float scalar; - MatrixObject *mat1 = NULL, *mat2 = NULL; + MatrixObject *mat1 = nullptr, *mat2 = nullptr; if (MatrixObject_Check(m1)) { mat1 = (MatrixObject *)m1; if (BaseMath_ReadCallback(mat1) == -1) { - return NULL; + return nullptr; } } if (MatrixObject_Check(m2)) { mat2 = (MatrixObject *)m2; if (BaseMath_ReadCallback(mat2) == -1) { - return NULL; + return nullptr; } } @@ -2808,7 +2809,7 @@ static PyObject *Matrix_imul(PyObject *m1, PyObject *m2) PyErr_SetString(PyExc_ValueError, "matrix1 *= matrix2: matrix1 number of rows/columns " "and the matrix2 number of rows/columns must be the same"); - return NULL; + return nullptr; } mul_vn_vn(mat1->matrix, mat2->matrix, mat1->col_num * mat1->row_num); @@ -2823,7 +2824,7 @@ static PyObject *Matrix_imul(PyObject *m1, PyObject *m2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name); - return NULL; + return nullptr; } (void)BaseMath_WriteCallback(mat1); @@ -2836,18 +2837,18 @@ static PyObject *Matrix_matmul(PyObject *m1, PyObject *m2) { int vec_num; - MatrixObject *mat1 = NULL, *mat2 = NULL; + MatrixObject *mat1 = nullptr, *mat2 = nullptr; if (MatrixObject_Check(m1)) { mat1 = (MatrixObject *)m1; if (BaseMath_ReadCallback(mat1) == -1) { - return NULL; + return nullptr; } } if (MatrixObject_Check(m2)) { mat2 = (MatrixObject *)m2; if (BaseMath_ReadCallback(mat2) == -1) { - return NULL; + return nullptr; } } @@ -2861,7 +2862,7 @@ static PyObject *Matrix_matmul(PyObject *m1, PyObject *m2) PyErr_SetString(PyExc_ValueError, "matrix1 * matrix2: matrix1 number of columns " "and the matrix2 number of rows must be the same"); - return NULL; + return nullptr; } for (col = 0; col < mat2->col_num; col++) { @@ -2882,10 +2883,10 @@ static PyObject *Matrix_matmul(PyObject *m1, PyObject *m2) VectorObject *vec2 = (VectorObject *)m2; float tvec[MATRIX_MAX_DIM]; if (BaseMath_ReadCallback(vec2) == -1) { - return NULL; + return nullptr; } if (column_vector_multiplication(tvec, vec2, mat1) == -1) { - return NULL; + return nullptr; } if (mat1->col_num == 4 && vec2->vec_num == 3) { @@ -2904,24 +2905,24 @@ static PyObject *Matrix_matmul(PyObject *m1, PyObject *m2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name); - return NULL; + return nullptr; } /** Multiplication in-place (matrix multiply): `object @= object`. */ static PyObject *Matrix_imatmul(PyObject *m1, PyObject *m2) { - MatrixObject *mat1 = NULL, *mat2 = NULL; + MatrixObject *mat1 = nullptr, *mat2 = nullptr; if (MatrixObject_Check(m1)) { mat1 = (MatrixObject *)m1; if (BaseMath_ReadCallback(mat1) == -1) { - return NULL; + return nullptr; } } if (MatrixObject_Check(m2)) { mat2 = (MatrixObject *)m2; if (BaseMath_ReadCallback(mat2) == -1) { - return NULL; + return nullptr; } } @@ -2934,7 +2935,7 @@ static PyObject *Matrix_imatmul(PyObject *m1, PyObject *m2) PyErr_SetString(PyExc_ValueError, "matrix1 * matrix2: matrix1 number of columns " "and the matrix2 number of rows must be the same"); - return NULL; + return nullptr; } for (col = 0; col < mat2->col_num; col++) { @@ -2958,7 +2959,7 @@ static PyObject *Matrix_imatmul(PyObject *m1, PyObject *m2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name); - return NULL; + return nullptr; } (void)BaseMath_WriteCallback(mat1); @@ -2974,15 +2975,15 @@ static PyObject *Matrix_imatmul(PyObject *m1, PyObject *m2) static PySequenceMethods Matrix_SeqMethods = { /*sq_length*/ (lenfunc)Matrix_len, - /*sq_concat*/ NULL, - /*sq_repeat*/ NULL, + /*sq_concat*/ nullptr, + /*sq_repeat*/ nullptr, /*sq_item*/ (ssizeargfunc)Matrix_item_row, - /*was_sq_slice*/ NULL, /* DEPRECATED. */ + /*was_sq_slice*/ nullptr, /* DEPRECATED. */ /*sq_ass_item*/ (ssizeobjargproc)Matrix_ass_item_row, - /*was_sq_ass_slice*/ NULL, /* DEPRECATED. */ - /*sq_contains*/ NULL, - /*sq_inplace_concat*/ NULL, - /*sq_inplace_repeat*/ NULL, + /*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */ + /*sq_contains*/ nullptr, + /*sq_inplace_concat*/ nullptr, + /*sq_inplace_repeat*/ nullptr, }; static PyMappingMethods Matrix_AsMapping = { @@ -2995,37 +2996,37 @@ static PyNumberMethods Matrix_NumMethods = { /*nb_add*/ (binaryfunc)Matrix_add, /*nb_subtract*/ (binaryfunc)Matrix_sub, /*nb_multiply*/ (binaryfunc)Matrix_mul, - /*nb_remainder*/ NULL, - /*nb_divmod*/ NULL, - /*nb_power*/ NULL, - /*nb_negative*/ NULL, - /*tp_positive*/ NULL, - /*tp_absolute*/ NULL, - /*tp_bool*/ NULL, + /*nb_remainder*/ nullptr, + /*nb_divmod*/ nullptr, + /*nb_power*/ nullptr, + /*nb_negative*/ nullptr, + /*tp_positive*/ nullptr, + /*tp_absolute*/ nullptr, + /*tp_bool*/ nullptr, /*nb_invert*/ (unaryfunc)Matrix_inverted_noargs, - /*nb_lshift*/ NULL, - /*nb_rshift*/ NULL, - /*nb_and*/ NULL, - /*nb_xor*/ NULL, - /*nb_or*/ NULL, - /*nb_int*/ NULL, - /*nb_reserved*/ NULL, - /*nb_float*/ NULL, - /*nb_inplace_add*/ NULL, - /*nb_inplace_subtract*/ NULL, + /*nb_lshift*/ nullptr, + /*nb_rshift*/ nullptr, + /*nb_and*/ nullptr, + /*nb_xor*/ nullptr, + /*nb_or*/ nullptr, + /*nb_int*/ nullptr, + /*nb_reserved*/ nullptr, + /*nb_float*/ nullptr, + /*nb_inplace_add*/ nullptr, + /*nb_inplace_subtract*/ nullptr, /*nb_inplace_multiply*/ (binaryfunc)Matrix_imul, - /*nb_inplace_remainder*/ NULL, - /*nb_inplace_power*/ NULL, - /*nb_inplace_lshift*/ NULL, - /*nb_inplace_rshift*/ NULL, - /*nb_inplace_and*/ NULL, - /*nb_inplace_xor*/ NULL, - /*nb_inplace_or*/ NULL, - /*nb_floor_divide*/ NULL, - /*nb_true_divide*/ NULL, - /*nb_inplace_floor_divide*/ NULL, - /*nb_inplace_true_divide*/ NULL, - /*nb_index*/ NULL, + /*nb_inplace_remainder*/ nullptr, + /*nb_inplace_power*/ nullptr, + /*nb_inplace_lshift*/ nullptr, + /*nb_inplace_rshift*/ nullptr, + /*nb_inplace_and*/ nullptr, + /*nb_inplace_xor*/ nullptr, + /*nb_inplace_or*/ nullptr, + /*nb_floor_divide*/ nullptr, + /*nb_true_divide*/ nullptr, + /*nb_inplace_floor_divide*/ nullptr, + /*nb_inplace_true_divide*/ nullptr, + /*nb_index*/ nullptr, /*nb_matrix_multiply*/ (binaryfunc)Matrix_matmul, /*nb_inplace_matrix_multiply*/ (binaryfunc)Matrix_imatmul, }; @@ -3037,12 +3038,12 @@ static PyNumberMethods Matrix_NumMethods = { * \{ */ PyDoc_STRVAR(Matrix_translation_doc, "The translation component of the matrix.\n\n:type: Vector"); -static PyObject *Matrix_translation_get(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_translation_get(MatrixObject *self, void * /*closure*/) { PyObject *ret; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } /* Must be 4x4 square matrix. */ @@ -3050,7 +3051,7 @@ static PyObject *Matrix_translation_get(MatrixObject *self, void *UNUSED(closure PyErr_SetString(PyExc_AttributeError, "Matrix.translation: " "inappropriate matrix size, must be 4x4"); - return NULL; + return nullptr; } ret = (PyObject *)Vector_CreatePyObject_cb( @@ -3059,7 +3060,7 @@ static PyObject *Matrix_translation_get(MatrixObject *self, void *UNUSED(closure return ret; } -static int Matrix_translation_set(MatrixObject *self, PyObject *value, void *UNUSED(closure)) +static int Matrix_translation_set(MatrixObject *self, PyObject *value, void * /*closure*/) { float tvec[3]; @@ -3088,7 +3089,7 @@ static int Matrix_translation_set(MatrixObject *self, PyObject *value, void *UNU PyDoc_STRVAR(Matrix_row_doc, "Access the matrix by rows (default), (read-only).\n\n:type: Matrix Access"); -static PyObject *Matrix_row_get(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_row_get(MatrixObject *self, void * /*closure*/) { return MatrixAccess_CreatePyObject(self, MAT_ACCESS_ROW); } @@ -3096,19 +3097,19 @@ static PyObject *Matrix_row_get(MatrixObject *self, void *UNUSED(closure)) PyDoc_STRVAR( Matrix_col_doc, "Access the matrix by columns, 3x3 and 4x4 only, (read-only).\n\n:type: Matrix Access"); -static PyObject *Matrix_col_get(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_col_get(MatrixObject *self, void * /*closure*/) { return MatrixAccess_CreatePyObject(self, MAT_ACCESS_COL); } PyDoc_STRVAR(Matrix_median_scale_doc, "The average scale applied to each axis (read-only).\n\n:type: float"); -static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_median_scale_get(MatrixObject *self, void * /*closure*/) { float mat[3][3]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } /* Must be 3-4 cols, 3-4 rows, square matrix. */ @@ -3116,7 +3117,7 @@ static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closur PyErr_SetString(PyExc_AttributeError, "Matrix.median_scale: " "inappropriate matrix size, 3x3 minimum"); - return NULL; + return nullptr; } matrix_as_3x3(mat, self); @@ -3126,10 +3127,10 @@ static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closur PyDoc_STRVAR(Matrix_is_identity_doc, "True if this is an identity matrix (read-only).\n\n:type: bool"); -static PyObject *Matrix_is_identity_get(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_is_identity_get(MatrixObject *self, void * /*closure*/) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return PyBool_FromLong(matrix_is_identity(self)); } @@ -3137,10 +3138,10 @@ static PyObject *Matrix_is_identity_get(MatrixObject *self, void *UNUSED(closure PyDoc_STRVAR(Matrix_is_negative_doc, "True if this matrix results in a negative scale, 3x3 and 4x4 only, " "(read-only).\n\n:type: bool"); -static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_is_negative_get(MatrixObject *self, void * /*closure*/) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } /* Must be 3-4 cols, 3-4 rows, square matrix. */ @@ -3154,15 +3155,15 @@ static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure PyErr_SetString(PyExc_AttributeError, "Matrix.is_negative: " "inappropriate matrix size - expects 3x3 or 4x4 matrix"); - return NULL; + return nullptr; } PyDoc_STRVAR(Matrix_is_orthogonal_doc, "True if this matrix is orthogonal, 3x3 and 4x4 only, (read-only).\n\n:type: bool"); -static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void * /*closure*/) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } /* Must be 3-4 cols, 3-4 rows, square matrix. */ @@ -3176,16 +3177,16 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu PyErr_SetString(PyExc_AttributeError, "Matrix.is_orthogonal: " "inappropriate matrix size - expects 3x3 or 4x4 matrix"); - return NULL; + return nullptr; } PyDoc_STRVAR(Matrix_is_orthogonal_axis_vectors_doc, "True if this matrix has got orthogonal axis vectors, 3x3 and 4x4 only, " "(read-only).\n\n:type: bool"); -static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void * /*closure*/) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } /* Must be 3-4 cols, 3-4 rows, square matrix. */ @@ -3199,7 +3200,7 @@ static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void PyErr_SetString(PyExc_AttributeError, "Matrix.is_orthogonal_axis_vectors: " "inappropriate matrix size - expects 3x3 or 4x4 matrix"); - return NULL; + return nullptr; } /** \} */ @@ -3209,43 +3210,59 @@ static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void * \{ */ static PyGetSetDef Matrix_getseters[] = { - {"median_scale", (getter)Matrix_median_scale_get, (setter)NULL, Matrix_median_scale_doc, NULL}, + {"median_scale", + (getter)Matrix_median_scale_get, + (setter) nullptr, + Matrix_median_scale_doc, + nullptr}, {"translation", (getter)Matrix_translation_get, (setter)Matrix_translation_set, Matrix_translation_doc, - NULL}, - {"row", (getter)Matrix_row_get, (setter)NULL, Matrix_row_doc, NULL}, - {"col", (getter)Matrix_col_get, (setter)NULL, Matrix_col_doc, NULL}, - {"is_identity", (getter)Matrix_is_identity_get, (setter)NULL, Matrix_is_identity_doc, NULL}, - {"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, Matrix_is_negative_doc, NULL}, + nullptr}, + {"row", (getter)Matrix_row_get, (setter) nullptr, Matrix_row_doc, nullptr}, + {"col", (getter)Matrix_col_get, (setter) nullptr, Matrix_col_doc, nullptr}, + {"is_identity", + (getter)Matrix_is_identity_get, + (setter) nullptr, + Matrix_is_identity_doc, + nullptr}, + {"is_negative", + (getter)Matrix_is_negative_get, + (setter) nullptr, + Matrix_is_negative_doc, + nullptr}, {"is_orthogonal", (getter)Matrix_is_orthogonal_get, - (setter)NULL, + (setter) nullptr, Matrix_is_orthogonal_doc, - NULL}, + nullptr}, {"is_orthogonal_axis_vectors", (getter)Matrix_is_orthogonal_axis_vectors_get, - (setter)NULL, + (setter) nullptr, Matrix_is_orthogonal_axis_vectors_doc, - NULL}, + nullptr}, {"is_wrapped", (getter)BaseMathObject_is_wrapped_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_wrapped_doc, - NULL}, + nullptr}, {"is_frozen", (getter)BaseMathObject_is_frozen_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_frozen_doc, - NULL}, + nullptr}, {"is_valid", (getter)BaseMathObject_is_valid_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_valid_doc, - NULL}, - {"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + nullptr}, + {"owner", + (getter)BaseMathObject_owner_get, + (setter) nullptr, + BaseMathObject_owner_doc, + nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; /** \} */ @@ -3314,7 +3331,7 @@ static PyMethodDef Matrix_methods[] = { (PyCFunction)C_Matrix_LocRotScale, METH_VARARGS | METH_CLASS, C_Matrix_LocRotScale_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -3324,7 +3341,7 @@ static PyMethodDef Matrix_methods[] = { * \{ */ #ifdef MATH_STANDALONE -# define Matrix_str NULL +# define Matrix_str nullptr #endif PyDoc_STRVAR( @@ -3337,55 +3354,55 @@ PyDoc_STRVAR( " :arg rows: Sequence of rows. When omitted, a 4x4 identity matrix is constructed.\n" " :type rows: 2d number sequence\n"); PyTypeObject matrix_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "Matrix", /*tp_basicsize*/ sizeof(MatrixObject), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)BaseMathObject_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, /*tp_repr*/ (reprfunc)Matrix_repr, /*tp_as_number*/ &Matrix_NumMethods, /*tp_as_sequence*/ &Matrix_SeqMethods, /*tp_as_mapping*/ &Matrix_AsMapping, /*tp_hash*/ (hashfunc)Matrix_hash, - /*tp_call*/ NULL, + /*tp_call*/ nullptr, /*tp_str*/ (reprfunc)Matrix_str, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_doc*/ matrix_doc, /*tp_traverse*/ (traverseproc)BaseMathObject_traverse, /*tp_clear*/ (inquiry)BaseMathObject_clear, /*tp_richcompare*/ (richcmpfunc)Matrix_richcmpr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ Matrix_methods, - /*tp_members*/ NULL, + /*tp_members*/ nullptr, /*tp_getset*/ Matrix_getseters, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, /*tp_new*/ Matrix_new, - /*tp_free*/ NULL, + /*tp_free*/ nullptr, /*tp_is_gc*/ (inquiry)BaseMathObject_is_gc, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; #ifdef MATH_STANDALONE @@ -3411,15 +3428,15 @@ PyObject *Matrix_CreatePyObject(const float *mat, PyErr_SetString(PyExc_RuntimeError, "Matrix(): " "row and column sizes must be between 2 and 4"); - return NULL; + return nullptr; } - mat_alloc = PyMem_Malloc(col_num * row_num * sizeof(float)); - if (UNLIKELY(mat_alloc == NULL)) { + mat_alloc = static_cast(PyMem_Malloc(col_num * row_num * sizeof(float))); + if (UNLIKELY(mat_alloc == nullptr)) { PyErr_SetString(PyExc_MemoryError, "Matrix(): " "problem allocating data"); - return NULL; + return nullptr; } self = BASE_MATH_NEW(MatrixObject, matrix_Type, base_type); @@ -3428,8 +3445,8 @@ PyObject *Matrix_CreatePyObject(const float *mat, self->col_num = col_num; self->row_num = row_num; - /* init callbacks as NULL */ - self->cb_user = NULL; + /* init callbacks as nullptr */ + self->cb_user = nullptr; self->cb_type = self->cb_subtype = 0; if (mat) { /* If a float array passed. */ @@ -3464,7 +3481,7 @@ PyObject *Matrix_CreatePyObject_wrap(float *mat, PyErr_SetString(PyExc_RuntimeError, "Matrix(): " "row and column sizes must be between 2 and 4"); - return NULL; + return nullptr; } self = BASE_MATH_NEW(MatrixObject, matrix_Type, base_type); @@ -3472,8 +3489,8 @@ PyObject *Matrix_CreatePyObject_wrap(float *mat, self->col_num = col_num; self->row_num = row_num; - /* init callbacks as NULL */ - self->cb_user = NULL; + /* init callbacks as nullptr */ + self->cb_user = nullptr; self->cb_type = self->cb_subtype = 0; self->matrix = mat; @@ -3485,7 +3502,7 @@ PyObject *Matrix_CreatePyObject_wrap(float *mat, PyObject *Matrix_CreatePyObject_cb( PyObject *cb_user, const ushort col_num, const ushort row_num, uchar cb_type, uchar cb_subtype) { - MatrixObject *self = (MatrixObject *)Matrix_CreatePyObject(NULL, col_num, row_num, NULL); + MatrixObject *self = (MatrixObject *)Matrix_CreatePyObject(nullptr, col_num, row_num, nullptr); if (self) { Py_INCREF(cb_user); self->cb_user = cb_user; @@ -3536,7 +3553,7 @@ static bool Matrix_ParseCheck(MatrixObject *pymat) int Matrix_ParseAny(PyObject *o, void *p) { - MatrixObject **pymat_p = p; + MatrixObject **pymat_p = static_cast(p); MatrixObject *pymat = (MatrixObject *)o; if (!Matrix_ParseCheck(pymat)) { @@ -3548,7 +3565,7 @@ int Matrix_ParseAny(PyObject *o, void *p) int Matrix_Parse2x2(PyObject *o, void *p) { - MatrixObject **pymat_p = p; + MatrixObject **pymat_p = static_cast(p); MatrixObject *pymat = (MatrixObject *)o; if (!Matrix_ParseCheck(pymat)) { @@ -3565,7 +3582,7 @@ int Matrix_Parse2x2(PyObject *o, void *p) int Matrix_Parse3x3(PyObject *o, void *p) { - MatrixObject **pymat_p = p; + MatrixObject **pymat_p = static_cast(p); MatrixObject *pymat = (MatrixObject *)o; if (!Matrix_ParseCheck(pymat)) { @@ -3582,7 +3599,7 @@ int Matrix_Parse3x3(PyObject *o, void *p) int Matrix_Parse4x4(PyObject *o, void *p) { - MatrixObject **pymat_p = p; + MatrixObject **pymat_p = static_cast(p); MatrixObject *pymat = (MatrixObject *)o; if (!Matrix_ParseCheck(pymat)) { @@ -3603,11 +3620,11 @@ int Matrix_Parse4x4(PyObject *o, void *p) /** \name Matrix-Access Type: Struct & Internal Functions * \{ */ -typedef struct { +struct MatrixAccessObject { PyObject_HEAD /* Required Python macro. */ MatrixObject *matrix_user; eMatrixAccess_t type; -} MatrixAccessObject; +}; static int MatrixAccess_traverse(MatrixAccessObject *self, visitproc visit, void *arg) { @@ -3684,7 +3701,7 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) { - return NULL; + return nullptr; } if (self->type == MAT_ACCESS_ROW) { if (i < 0) { @@ -3703,7 +3720,7 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item if (PySlice_GetIndicesEx(item, MatrixAccess_len(self), &start, &stop, &step, &slicelength) < 0) { - return NULL; + return nullptr; } if (slicelength <= 0) { @@ -3714,12 +3731,12 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item } PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrix accessors"); - return NULL; + return nullptr; } PyErr_Format( PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name); - return NULL; + return nullptr; } static int MatrixAccess_ass_subscript(MatrixAccessObject *self, PyObject *item, PyObject *value) @@ -3755,11 +3772,11 @@ static PyObject *MatrixAccess_iter(MatrixAccessObject *self) { /* Try get values from a collection. */ PyObject *ret; - PyObject *iter = NULL; + PyObject *iter = nullptr; ret = MatrixAccess_slice(self, 0, MATRIX_MAX_DIM); /* We know this is a tuple so no need to #PyIter_Check - * otherwise it could be NULL (unlikely) if conversion failed. */ + * otherwise it could be nullptr (unlikely) if conversion failed. */ if (ret) { iter = PyObject_GetIter(ret); Py_DECREF(ret); @@ -3781,55 +3798,55 @@ static PyMappingMethods MatrixAccess_AsMapping = { * \{ */ PyTypeObject matrix_access_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "MatrixAccess", /*tp_basicsize*/ sizeof(MatrixAccessObject), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)MatrixAccess_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, - /*tp_repr*/ NULL, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL /* &MatrixAccess_SeqMethods */ /* TODO */, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, + /*tp_repr*/ nullptr, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr /* &MatrixAccess_SeqMethods */ /* TODO */, /*tp_as_mapping*/ &MatrixAccess_AsMapping, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, - /*tp_doc*/ NULL, + /*tp_doc*/ nullptr, /*tp_traverse*/ (traverseproc)MatrixAccess_traverse, /*tp_clear*/ (inquiry)MatrixAccess_clear, - /*tp_richcompare*/ NULL /* MatrixAccess_richcmpr */ /* TODO */, + /*tp_richcompare*/ nullptr /* MatrixAccess_richcmpr */ /* TODO */, /*tp_weaklistoffset*/ 0, /*tp_iter*/ (getiterfunc)MatrixAccess_iter, - /*tp_iternext*/ NULL, - /*tp_methods*/ NULL, - /*tp_members*/ NULL, - /*tp_getset*/ NULL, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_iternext*/ nullptr, + /*tp_methods*/ nullptr, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, - /*tp_new*/ NULL, - /*tp_free*/ NULL, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, + /*tp_new*/ nullptr, + /*tp_free*/ nullptr, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; /** \} */ diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.cc similarity index 89% rename from source/blender/python/mathutils/mathutils_Quaternion.c rename to source/blender/python/mathutils/mathutils_Quaternion.cc index 05895377ee1..4fdc67599e9 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.cc @@ -43,7 +43,7 @@ static PyObject *quat__apply_to_copy(PyObject *(*quat_func)(QuaternionObject *), } /* error */ Py_DECREF(ret); - return NULL; + return nullptr; } /** Axis vector suffers from precision errors, use this function to ensure. */ @@ -101,7 +101,7 @@ static PyObject *Quaternion_to_tuple_ext(QuaternionObject *self, int ndigits) static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *seq = NULL; + PyObject *seq = nullptr; double angle = 0.0f; float quat[QUAT_SIZE]; unit_qt(quat); @@ -110,11 +110,11 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw PyErr_SetString(PyExc_TypeError, "mathutils.Quaternion(): " "takes no keyword args"); - return NULL; + return nullptr; } if (!PyArg_ParseTuple(args, "|Od:mathutils.Quaternion", &seq, &angle)) { - return NULL; + return nullptr; } switch (PyTuple_GET_SIZE(args)) { @@ -125,7 +125,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw if ((size = mathutils_array_parse(quat, 3, QUAT_SIZE, seq, "mathutils.Quaternion()")) == -1) { - return NULL; + return nullptr; } if (size == 4) { @@ -142,7 +142,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw case 2: { float axis[3]; if (mathutils_array_parse(axis, 3, 3, seq, "mathutils.Quaternion()") == -1) { - return NULL; + return nullptr; } angle = angle_wrap_rad(angle); /* clamp because of precision issues */ axis_angle_to_quat(quat, axis, angle); @@ -177,23 +177,23 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args) { float tquat[4]; float eul[3]; - const char *order_str = NULL; + const char *order_str = nullptr; short order = EULER_ORDER_XYZ; - EulerObject *eul_compat = NULL; + EulerObject *eul_compat = nullptr; if (!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat)) { - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (order_str) { order = euler_order_from_string(order_str, "Quaternion.to_euler()"); if (order == -1) { - return NULL; + return nullptr; } } @@ -201,7 +201,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args) if (eul_compat) { if (BaseMath_ReadCallback(eul_compat) == -1) { - return NULL; + return nullptr; } if (order == EULER_ORDER_XYZ) { @@ -220,7 +220,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args) } } - return Euler_CreatePyObject(eul, order, NULL); + return Euler_CreatePyObject(eul, order, nullptr); } /** \} */ @@ -241,11 +241,11 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self) float mat[9]; /* all values are set */ if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } quat_to_mat3((float(*)[3])mat, self->quat); - return Matrix_CreatePyObject(mat, 3, 3, NULL); + return Matrix_CreatePyObject(mat, 3, 3, nullptr); } /** \} */ @@ -271,7 +271,7 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject *self) float angle; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } normalize_qt_qt(tquat, self->quat); @@ -280,7 +280,7 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject *self) quat__axis_angle_sanitize(axis, &angle); ret = PyTuple_New(2); - PyTuple_SET_ITEMS(ret, Vector_CreatePyObject(axis, 3, NULL), PyFloat_FromDouble(angle)); + PyTuple_SET_ITEMS(ret, Vector_CreatePyObject(axis, 3, nullptr), PyFloat_FromDouble(angle)); return ret; } @@ -303,7 +303,7 @@ static PyObject *Quaternion_to_swing_twist(QuaternionObject *self, PyObject *axi { PyObject *ret; - const char *axis_str = NULL; + const char *axis_str = nullptr; float swing[4], twist; int axis; @@ -319,14 +319,14 @@ static PyObject *Quaternion_to_swing_twist(QuaternionObject *self, PyObject *axi "Quaternion.to_swing_twist(): " "the axis argument must be " "a string in 'X', 'Y', 'Z'"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } - twist = quat_split_swing_and_twist(self->quat, axis, swing, NULL); + twist = quat_split_swing_and_twist(self->quat, axis, swing, nullptr); ret = PyTuple_New(2); PyTuple_SET_ITEMS( @@ -358,11 +358,11 @@ static PyObject *Quaternion_to_exponential_map(QuaternionObject *self) float expmap[3]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } quat_to_expmap(expmap, self->quat); - return Vector_CreatePyObject(expmap, 3, NULL); + return Vector_CreatePyObject(expmap, 3, nullptr); } /** \} */ @@ -385,14 +385,14 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value) float quat[QUAT_SIZE], tquat[QUAT_SIZE]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse( tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.cross(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } mul_qt_qtqt(quat, self->quat, tquat); @@ -419,13 +419,13 @@ static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value) float tquat[QUAT_SIZE]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse( tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.dot(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(dot_qtqt(self->quat, tquat)); @@ -451,7 +451,7 @@ static PyObject *Quaternion_rotation_difference(QuaternionObject *self, PyObject float tquat[QUAT_SIZE], quat[QUAT_SIZE]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(tquat, @@ -460,7 +460,7 @@ static PyObject *Quaternion_rotation_difference(QuaternionObject *self, PyObject value, "Quaternion.rotation_difference(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } rotation_between_quats_to_quat(quat, self->quat, tquat); @@ -494,25 +494,25 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args) PyErr_SetString(PyExc_TypeError, "quat.slerp(): " "expected Quaternion types and float"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse( tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.slerp(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } if (fac > 1.0f || fac < 0.0f) { PyErr_SetString(PyExc_ValueError, "quat.slerp(): " "interpolation factor must be between 0.0 and 1.0"); - return NULL; + return nullptr; } interp_qt_qtqt(quat, self->quat, tquat, fac); @@ -539,11 +539,11 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value) float tquat[4], length; if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1) { - return NULL; + return nullptr; } length = normalize_qt_qt(tquat, self->quat); @@ -567,7 +567,7 @@ static PyObject *Quaternion_make_compatible(QuaternionObject *self, PyObject *va float tquat[QUAT_SIZE]; if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(tquat, @@ -576,7 +576,7 @@ static PyObject *Quaternion_make_compatible(QuaternionObject *self, PyObject *va value, "Quaternion.make_compatible(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } /* Can only operate on unit length quaternions. */ @@ -605,7 +605,7 @@ PyDoc_STRVAR(Quaternion_normalize_doc, static PyObject *Quaternion_normalize(QuaternionObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } normalize_qt(self->quat); @@ -641,7 +641,7 @@ PyDoc_STRVAR(Quaternion_invert_doc, static PyObject *Quaternion_invert(QuaternionObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } invert_qt(self->quat); @@ -676,7 +676,7 @@ PyDoc_STRVAR(Quaternion_identity_doc, static PyObject *Quaternion_identity(QuaternionObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } unit_qt(self->quat); @@ -700,7 +700,7 @@ PyDoc_STRVAR(Quaternion_negate_doc, static PyObject *Quaternion_negate(QuaternionObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } mul_qt_fl(self->quat, -1.0f); @@ -722,7 +722,7 @@ PyDoc_STRVAR(Quaternion_conjugate_doc, static PyObject *Quaternion_conjugate(QuaternionObject *self) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } conjugate_qt(self->quat); @@ -761,7 +761,7 @@ PyDoc_STRVAR(Quaternion_copy_doc, static PyObject *Quaternion_copy(QuaternionObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return Quaternion_CreatePyObject(self->quat, Py_TYPE(self)); @@ -769,7 +769,7 @@ static PyObject *Quaternion_copy(QuaternionObject *self) static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args) { if (!PyC_CheckArgs_DeepCopy(args)) { - return NULL; + return nullptr; } return Quaternion_copy(self); } @@ -785,7 +785,7 @@ static PyObject *Quaternion_repr(QuaternionObject *self) PyObject *ret, *tuple; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } tuple = Quaternion_to_tuple_ext(self, -1); @@ -802,7 +802,7 @@ static PyObject *Quaternion_str(QuaternionObject *self) DynStr *ds; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } ds = BLI_dynstr_new(); @@ -834,7 +834,7 @@ static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op) QuaternionObject *quatB = (QuaternionObject *)b; if (BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1) { - return NULL; + return nullptr; } ok = EXPP_VectorsAreEqual(quatA->quat, quatB->quat, QUAT_SIZE, 1) ? 0 : -1; @@ -856,7 +856,7 @@ static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op) break; default: PyErr_BadArgument(); - return NULL; + return nullptr; } return Py_INCREF_RET(res); @@ -888,7 +888,7 @@ static Py_hash_t Quaternion_hash(QuaternionObject *self) * \{ */ /** Sequence length: `len(object)`. */ -static Py_ssize_t Quaternion_len(QuaternionObject *UNUSED(self)) +static Py_ssize_t Quaternion_len(QuaternionObject * /*self*/) { return QUAT_SIZE; } @@ -904,11 +904,11 @@ static PyObject *Quaternion_item(QuaternionObject *self, Py_ssize_t i) PyErr_SetString(PyExc_IndexError, "quaternion[attribute]: " "array index out of range"); - return NULL; + return nullptr; } if (BaseMath_ReadIndexCallback(self, i) == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(self->quat[i]); @@ -958,7 +958,7 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end) int count; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } CLAMP(begin, 0, QUAT_SIZE); @@ -1022,7 +1022,7 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item) Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) { - return NULL; + return nullptr; } if (i < 0) { i += QUAT_SIZE; @@ -1033,7 +1033,7 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item) Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) { - return NULL; + return nullptr; } if (slicelength <= 0) { @@ -1044,12 +1044,12 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item) } PyErr_SetString(PyExc_IndexError, "slice steps not supported with quaternions"); - return NULL; + return nullptr; } PyErr_Format( PyExc_TypeError, "quaternion indices must be integers, not %.200s", Py_TYPE(item)->tp_name); - return NULL; + return nullptr; } /** Sequence generic subscript (set): `object[...] = x`. */ @@ -1095,7 +1095,7 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb static PyObject *Quaternion_add(PyObject *q1, PyObject *q2) { float quat[QUAT_SIZE]; - QuaternionObject *quat1 = NULL, *quat2 = NULL; + QuaternionObject *quat1 = nullptr, *quat2 = nullptr; if (!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) { PyErr_Format(PyExc_TypeError, @@ -1103,13 +1103,13 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2) "invalid type for this operation", Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name); - return NULL; + return nullptr; } quat1 = (QuaternionObject *)q1; quat2 = (QuaternionObject *)q2; if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1) { - return NULL; + return nullptr; } add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f); @@ -1121,7 +1121,7 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2) { int x; float quat[QUAT_SIZE]; - QuaternionObject *quat1 = NULL, *quat2 = NULL; + QuaternionObject *quat1 = nullptr, *quat2 = nullptr; if (!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) { PyErr_Format(PyExc_TypeError, @@ -1129,14 +1129,14 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2) "invalid type for this operation", Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name); - return NULL; + return nullptr; } quat1 = (QuaternionObject *)q1; quat2 = (QuaternionObject *)q2; if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1) { - return NULL; + return nullptr; } for (x = 0; x < QUAT_SIZE; x++) { @@ -1158,18 +1158,18 @@ static PyObject *quat_mul_float(QuaternionObject *quat, const float scalar) static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) { float scalar; - QuaternionObject *quat1 = NULL, *quat2 = NULL; + QuaternionObject *quat1 = nullptr, *quat2 = nullptr; if (QuaternionObject_Check(q1)) { quat1 = (QuaternionObject *)q1; if (BaseMath_ReadCallback(quat1) == -1) { - return NULL; + return nullptr; } } if (QuaternionObject_Check(q2)) { quat2 = (QuaternionObject *)q2; if (BaseMath_ReadCallback(quat2) == -1) { - return NULL; + return nullptr; } } @@ -1195,25 +1195,25 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name); - return NULL; + return nullptr; } /** Multiplication in-place (element-wise or scalar): `object *= object`. */ static PyObject *Quaternion_imul(PyObject *q1, PyObject *q2) { float scalar; - QuaternionObject *quat1 = NULL, *quat2 = NULL; + QuaternionObject *quat1 = nullptr, *quat2 = nullptr; if (QuaternionObject_Check(q1)) { quat1 = (QuaternionObject *)q1; if (BaseMath_ReadCallback(quat1) == -1) { - return NULL; + return nullptr; } } if (QuaternionObject_Check(q2)) { quat2 = (QuaternionObject *)q2; if (BaseMath_ReadCallback(quat2) == -1) { - return NULL; + return nullptr; } } @@ -1230,7 +1230,7 @@ static PyObject *Quaternion_imul(PyObject *q1, PyObject *q2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name); - return NULL; + return nullptr; } (void)BaseMath_WriteCallback(quat1); @@ -1242,18 +1242,18 @@ static PyObject *Quaternion_imul(PyObject *q1, PyObject *q2) static PyObject *Quaternion_matmul(PyObject *q1, PyObject *q2) { float quat[QUAT_SIZE]; - QuaternionObject *quat1 = NULL, *quat2 = NULL; + QuaternionObject *quat1 = nullptr, *quat2 = nullptr; if (QuaternionObject_Check(q1)) { quat1 = (QuaternionObject *)q1; if (BaseMath_ReadCallback(quat1) == -1) { - return NULL; + return nullptr; } } if (QuaternionObject_Check(q2)) { quat2 = (QuaternionObject *)q2; if (BaseMath_ReadCallback(quat2) == -1) { - return NULL; + return nullptr; } } @@ -1272,10 +1272,10 @@ static PyObject *Quaternion_matmul(PyObject *q1, PyObject *q2) "Vector multiplication: " "only 3D vector rotations (with quats) " "currently supported"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback(vec2) == -1) { - return NULL; + return nullptr; } copy_v3_v3(tvec, vec2->vec); @@ -1290,25 +1290,25 @@ static PyObject *Quaternion_matmul(PyObject *q1, PyObject *q2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name); - return NULL; + return nullptr; } /** Multiplication in-place (quaternion multiply): `object @= object`. */ static PyObject *Quaternion_imatmul(PyObject *q1, PyObject *q2) { float quat[QUAT_SIZE]; - QuaternionObject *quat1 = NULL, *quat2 = NULL; + QuaternionObject *quat1 = nullptr, *quat2 = nullptr; if (QuaternionObject_Check(q1)) { quat1 = (QuaternionObject *)q1; if (BaseMath_ReadCallback(quat1) == -1) { - return NULL; + return nullptr; } } if (QuaternionObject_Check(q2)) { quat2 = (QuaternionObject *)q2; if (BaseMath_ReadCallback(quat2) == -1) { - return NULL; + return nullptr; } } @@ -1322,7 +1322,7 @@ static PyObject *Quaternion_imatmul(PyObject *q1, PyObject *q2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name); - return NULL; + return nullptr; } (void)BaseMath_WriteCallback(quat1); @@ -1336,7 +1336,7 @@ static PyObject *Quaternion_neg(QuaternionObject *self) float tquat[QUAT_SIZE]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } negate_v4_v4(tquat, self->quat); @@ -1351,15 +1351,15 @@ static PyObject *Quaternion_neg(QuaternionObject *self) static PySequenceMethods Quaternion_SeqMethods = { /*sq_length*/ (lenfunc)Quaternion_len, - /*sq_concat*/ NULL, - /*sq_repeat*/ NULL, + /*sq_concat*/ nullptr, + /*sq_repeat*/ nullptr, /*sq_item*/ (ssizeargfunc)Quaternion_item, - /*was_sq_slice*/ NULL, /* DEPRECATED. */ + /*was_sq_slice*/ nullptr, /* DEPRECATED. */ /*sq_ass_item*/ (ssizeobjargproc)Quaternion_ass_item, - /*was_sq_ass_slice*/ NULL, /* DEPRECATED. */ - /*sq_contains*/ NULL, - /*sq_inplace_concat*/ NULL, - /*sq_inplace_repeat*/ NULL, + /*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */ + /*sq_contains*/ nullptr, + /*sq_inplace_concat*/ nullptr, + /*sq_inplace_repeat*/ nullptr, }; static PyMappingMethods Quaternion_AsMapping = { @@ -1372,37 +1372,37 @@ static PyNumberMethods Quaternion_NumMethods = { /*nb_add*/ (binaryfunc)Quaternion_add, /*nb_subtract*/ (binaryfunc)Quaternion_sub, /*nb_multiply*/ (binaryfunc)Quaternion_mul, - /*nb_remainder*/ NULL, - /*nb_divmod*/ NULL, - /*nb_power*/ NULL, + /*nb_remainder*/ nullptr, + /*nb_divmod*/ nullptr, + /*nb_power*/ nullptr, /*nb_negative*/ (unaryfunc)Quaternion_neg, /*tp_positive*/ (unaryfunc)Quaternion_copy, - /*tp_absolute*/ NULL, - /*tp_bool*/ NULL, - /*nb_invert*/ NULL, - /*nb_lshift*/ NULL, - /*nb_rshift*/ NULL, - /*nb_and*/ NULL, - /*nb_xor*/ NULL, - /*nb_or*/ NULL, - /*nb_int*/ NULL, - /*nb_reserved*/ NULL, - /*nb_float*/ NULL, - /*nb_inplace_add*/ NULL, - /*nb_inplace_subtract*/ NULL, + /*tp_absolute*/ nullptr, + /*tp_bool*/ nullptr, + /*nb_invert*/ nullptr, + /*nb_lshift*/ nullptr, + /*nb_rshift*/ nullptr, + /*nb_and*/ nullptr, + /*nb_xor*/ nullptr, + /*nb_or*/ nullptr, + /*nb_int*/ nullptr, + /*nb_reserved*/ nullptr, + /*nb_float*/ nullptr, + /*nb_inplace_add*/ nullptr, + /*nb_inplace_subtract*/ nullptr, /*nb_inplace_multiply*/ (binaryfunc)Quaternion_imul, - /*nb_inplace_remainder*/ NULL, - /*nb_inplace_power*/ NULL, - /*nb_inplace_lshift*/ NULL, - /*nb_inplace_rshift*/ NULL, - /*nb_inplace_and*/ NULL, - /*nb_inplace_xor*/ NULL, - /*nb_inplace_or*/ NULL, - /*nb_floor_divide*/ NULL, - /*nb_true_divide*/ NULL, - /*nb_inplace_floor_divide*/ NULL, - /*nb_inplace_true_divide*/ NULL, - /*nb_index*/ NULL, + /*nb_inplace_remainder*/ nullptr, + /*nb_inplace_power*/ nullptr, + /*nb_inplace_lshift*/ nullptr, + /*nb_inplace_rshift*/ nullptr, + /*nb_inplace_and*/ nullptr, + /*nb_inplace_xor*/ nullptr, + /*nb_inplace_or*/ nullptr, + /*nb_floor_divide*/ nullptr, + /*nb_true_divide*/ nullptr, + /*nb_inplace_floor_divide*/ nullptr, + /*nb_inplace_true_divide*/ nullptr, + /*nb_index*/ nullptr, /*nb_matrix_multiply*/ (binaryfunc)Quaternion_matmul, /*nb_inplace_matrix_multiply*/ (binaryfunc)Quaternion_imatmul, }; @@ -1425,35 +1425,35 @@ static int Quaternion_axis_set(QuaternionObject *self, PyObject *value, void *ty } PyDoc_STRVAR(Quaternion_magnitude_doc, "Size of the quaternion (read-only).\n\n:type: float"); -static PyObject *Quaternion_magnitude_get(QuaternionObject *self, void *UNUSED(closure)) +static PyObject *Quaternion_magnitude_get(QuaternionObject *self, void * /*closure*/) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(sqrtf(dot_qtqt(self->quat, self->quat))); } PyDoc_STRVAR(Quaternion_angle_doc, "Angle of the quaternion.\n\n:type: float"); -static PyObject *Quaternion_angle_get(QuaternionObject *self, void *UNUSED(closure)) +static PyObject *Quaternion_angle_get(QuaternionObject *self, void * /*closure*/) { float tquat[4]; float angle; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } normalize_qt_qt(tquat, self->quat); angle = 2.0f * saacos(tquat[0]); - quat__axis_angle_sanitize(NULL, &angle); + quat__axis_angle_sanitize(nullptr, &angle); return PyFloat_FromDouble(angle); } -static int Quaternion_angle_set(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) +static int Quaternion_angle_set(QuaternionObject *self, PyObject *value, void * /*closure*/) { float tquat[4]; float len; @@ -1490,7 +1490,7 @@ static int Quaternion_angle_set(QuaternionObject *self, PyObject *value, void *U } PyDoc_STRVAR(Quaternion_axis_vector_doc, "Quaternion axis as a vector.\n\n:type: :class:`Vector`"); -static PyObject *Quaternion_axis_vector_get(QuaternionObject *self, void *UNUSED(closure)) +static PyObject *Quaternion_axis_vector_get(QuaternionObject *self, void * /*closure*/) { float tquat[4]; @@ -1498,20 +1498,18 @@ static PyObject *Quaternion_axis_vector_get(QuaternionObject *self, void *UNUSED float angle_dummy; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } normalize_qt_qt(tquat, self->quat); quat_to_axis_angle(axis, &angle_dummy, tquat); - quat__axis_angle_sanitize(axis, NULL); + quat__axis_angle_sanitize(axis, nullptr); - return Vector_CreatePyObject(axis, 3, NULL); + return Vector_CreatePyObject(axis, 3, nullptr); } -static int Quaternion_axis_vector_set(QuaternionObject *self, - PyObject *value, - void *UNUSED(closure)) +static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, void * /*closure*/) { float tquat[4]; float len; @@ -1569,34 +1567,42 @@ static PyGetSetDef Quaternion_getseters[] = { (setter)Quaternion_axis_set, Quaternion_axis_doc, (void *)3}, - {"magnitude", (getter)Quaternion_magnitude_get, (setter)NULL, Quaternion_magnitude_doc, NULL}, + {"magnitude", + (getter)Quaternion_magnitude_get, + (setter) nullptr, + Quaternion_magnitude_doc, + nullptr}, {"angle", (getter)Quaternion_angle_get, (setter)Quaternion_angle_set, Quaternion_angle_doc, - NULL}, + nullptr}, {"axis", (getter)Quaternion_axis_vector_get, (setter)Quaternion_axis_vector_set, Quaternion_axis_vector_doc, - NULL}, + nullptr}, {"is_wrapped", (getter)BaseMathObject_is_wrapped_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_wrapped_doc, - NULL}, + nullptr}, {"is_frozen", (getter)BaseMathObject_is_frozen_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_frozen_doc, - NULL}, + nullptr}, {"is_valid", (getter)BaseMathObject_is_valid_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_valid_doc, - NULL}, - {"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + nullptr}, + {"owner", + (getter)BaseMathObject_owner_get, + (setter) nullptr, + BaseMathObject_owner_doc, + nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; /** \} */ @@ -1656,7 +1662,7 @@ static PyMethodDef Quaternion_methods[] = { {"copy", (PyCFunction)Quaternion_copy, METH_NOARGS, Quaternion_copy_doc}, {"__copy__", (PyCFunction)Quaternion_copy, METH_NOARGS, Quaternion_copy_doc}, {"__deepcopy__", (PyCFunction)Quaternion_deepcopy, METH_VARARGS, Quaternion_copy_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -1666,7 +1672,7 @@ static PyMethodDef Quaternion_methods[] = { * \{ */ #ifdef MATH_STANDALONE -# define Quaternion_str NULL +# define Quaternion_str nullptr #endif PyDoc_STRVAR(quaternion_doc, @@ -1694,55 +1700,55 @@ PyDoc_STRVAR(quaternion_doc, "\n" " .. seealso:: :meth:`to_axis_angle`\n"); PyTypeObject quaternion_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "Quaternion", /*tp_basicsize*/ sizeof(QuaternionObject), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)BaseMathObject_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, /*tp_repr*/ (reprfunc)Quaternion_repr, /*tp_as_number*/ &Quaternion_NumMethods, /*tp_as_sequence*/ &Quaternion_SeqMethods, /*tp_as_mapping*/ &Quaternion_AsMapping, /*tp_hash*/ (hashfunc)Quaternion_hash, - /*tp_call*/ NULL, + /*tp_call*/ nullptr, /*tp_str*/ (reprfunc)Quaternion_str, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_doc*/ quaternion_doc, /*tp_traverse*/ (traverseproc)BaseMathObject_traverse, /*tp_clear*/ (inquiry)BaseMathObject_clear, /*tp_richcompare*/ (richcmpfunc)Quaternion_richcmpr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ Quaternion_methods, - /*tp_members*/ NULL, + /*tp_members*/ nullptr, /*tp_getset*/ Quaternion_getseters, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, /*tp_new*/ Quaternion_new, - /*tp_free*/ NULL, + /*tp_free*/ nullptr, /*tp_is_gc*/ (inquiry)BaseMathObject_is_gc, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; #ifdef MATH_STANDALONE @@ -1760,19 +1766,19 @@ PyObject *Quaternion_CreatePyObject(const float quat[4], PyTypeObject *base_type QuaternionObject *self; float *quat_alloc; - quat_alloc = PyMem_Malloc(QUAT_SIZE * sizeof(float)); - if (UNLIKELY(quat_alloc == NULL)) { + quat_alloc = static_cast(PyMem_Malloc(QUAT_SIZE * sizeof(float))); + if (UNLIKELY(quat_alloc == nullptr)) { PyErr_SetString(PyExc_MemoryError, "Quaternion(): " "problem allocating data"); - return NULL; + return nullptr; } self = BASE_MATH_NEW(QuaternionObject, quaternion_Type, base_type); if (self) { self->quat = quat_alloc; - /* init callbacks as NULL */ - self->cb_user = NULL; + /* init callbacks as nullptr */ + self->cb_user = nullptr; self->cb_type = self->cb_subtype = 0; /* NEW */ @@ -1797,8 +1803,8 @@ PyObject *Quaternion_CreatePyObject_wrap(float quat[4], PyTypeObject *base_type) self = BASE_MATH_NEW(QuaternionObject, quaternion_Type, base_type); if (self) { - /* init callbacks as NULL */ - self->cb_user = NULL; + /* init callbacks as nullptr */ + self->cb_user = nullptr; self->cb_type = self->cb_subtype = 0; /* WRAP */ @@ -1810,7 +1816,7 @@ PyObject *Quaternion_CreatePyObject_wrap(float quat[4], PyTypeObject *base_type) PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user, uchar cb_type, uchar cb_subtype) { - QuaternionObject *self = (QuaternionObject *)Quaternion_CreatePyObject(NULL, NULL); + QuaternionObject *self = (QuaternionObject *)Quaternion_CreatePyObject(nullptr, nullptr); if (self) { Py_INCREF(cb_user); self->cb_user = cb_user; diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.cc similarity index 68% rename from source/blender/python/mathutils/mathutils_Vector.c rename to source/blender/python/mathutils/mathutils_Vector.cc index 8599f4bdb6f..780d2288a96 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.cc @@ -98,7 +98,7 @@ static PyObject *vec__apply_to_copy(PyObject *(*vec_func)(VectorObject *), Vecto } /* error */ Py_DECREF(ret); - return NULL; + return nullptr; } /** \note #BaseMath_ReadCallback must be called beforehand. */ @@ -135,25 +135,25 @@ static PyObject *Vector_to_tuple_ex(VectorObject *self, int ndigits) */ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - float *vec = NULL; + float *vec = nullptr; int vec_num = 3; /* default to a 3D vector */ if (kwds && PyDict_Size(kwds)) { PyErr_SetString(PyExc_TypeError, "Vector(): " "takes no keyword args"); - return NULL; + return nullptr; } switch (PyTuple_GET_SIZE(args)) { case 0: - vec = PyMem_Malloc(vec_num * sizeof(float)); + vec = static_cast(PyMem_Malloc(vec_num * sizeof(float))); - if (vec == NULL) { + if (vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector(): " "problem allocating pointer space"); - return NULL; + return nullptr; } copy_vn_fl(vec, vec_num, 0.0f); @@ -162,14 +162,14 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if ((vec_num = mathutils_array_parse_alloc( &vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) { - return NULL; + return nullptr; } break; default: PyErr_SetString(PyExc_TypeError, "mathutils.Vector(): " "more than a single arg given"); - return NULL; + return nullptr; } return Vector_CreatePyObject_alloc(vec, vec_num, type); } @@ -196,21 +196,21 @@ static PyObject *C_Vector_Fill(PyObject *cls, PyObject *args) float fill = 0.0f; if (!PyArg_ParseTuple(args, "i|f:Vector.Fill", &vec_num, &fill)) { - return NULL; + return nullptr; } if (vec_num < 2) { PyErr_SetString(PyExc_RuntimeError, "Vector(): invalid size"); - return NULL; + return nullptr; } - vec = PyMem_Malloc(vec_num * sizeof(float)); + vec = static_cast(PyMem_Malloc(vec_num * sizeof(float))); - if (vec == NULL) { + if (vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector.Fill(): " "problem allocating pointer space"); - return NULL; + return nullptr; } copy_vn_fl(vec, vec_num, fill); @@ -237,7 +237,7 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) int step = 1; if (!PyArg_ParseTuple(args, "i|ii:Vector.Range", &start, &stop, &step)) { - return NULL; + return nullptr; } switch (PyTuple_GET_SIZE(args)) { @@ -250,7 +250,7 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) PyErr_SetString(PyExc_RuntimeError, "Start value is larger " "than the stop value"); - return NULL; + return nullptr; } vec_num = stop - start; @@ -260,7 +260,7 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) PyErr_SetString(PyExc_RuntimeError, "Start value is larger " "than the stop value"); - return NULL; + return nullptr; } vec_num = (stop - start); @@ -276,16 +276,16 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) if (vec_num < 2) { PyErr_SetString(PyExc_RuntimeError, "Vector(): invalid size"); - return NULL; + return nullptr; } - vec = PyMem_Malloc(vec_num * sizeof(float)); + vec = static_cast(PyMem_Malloc(vec_num * sizeof(float))); - if (vec == NULL) { + if (vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector.Range(): " "problem allocating pointer space"); - return NULL; + return nullptr; } range_vn_fl(vec, vec_num, (float)start, (float)step); @@ -312,23 +312,23 @@ static PyObject *C_Vector_Linspace(PyObject *cls, PyObject *args) float start, end, step; if (!PyArg_ParseTuple(args, "ffi:Vector.Linspace", &start, &end, &vec_num)) { - return NULL; + return nullptr; } if (vec_num < 2) { PyErr_SetString(PyExc_RuntimeError, "Vector.Linspace(): invalid size"); - return NULL; + return nullptr; } step = (end - start) / (float)(vec_num - 1); - vec = PyMem_Malloc(vec_num * sizeof(float)); + vec = static_cast(PyMem_Malloc(vec_num * sizeof(float))); - if (vec == NULL) { + if (vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector.Linspace(): " "problem allocating pointer space"); - return NULL; + return nullptr; } range_vn_fl(vec, vec_num, start, step); @@ -349,40 +349,40 @@ PyDoc_STRVAR( static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) { float *vec; - float *iter_vec = NULL; + float *iter_vec = nullptr; int i, vec_num, value_num; PyObject *value; if (!PyArg_ParseTuple(args, "Oi:Vector.Repeat", &value, &vec_num)) { - return NULL; + return nullptr; } if (vec_num < 2) { PyErr_SetString(PyExc_RuntimeError, "Vector.Repeat(): invalid vec_num"); - return NULL; + return nullptr; } if ((value_num = mathutils_array_parse_alloc( &iter_vec, 2, value, "Vector.Repeat(vector, vec_num), invalid 'vector' arg")) == -1) { - return NULL; + return nullptr; } - if (iter_vec == NULL) { + if (iter_vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector.Repeat(): " "problem allocating pointer space"); - return NULL; + return nullptr; } - vec = PyMem_Malloc(vec_num * sizeof(float)); + vec = static_cast(PyMem_Malloc(vec_num * sizeof(float))); - if (vec == NULL) { + if (vec == nullptr) { PyMem_Free(iter_vec); PyErr_SetString(PyExc_MemoryError, "Vector.Repeat(): " "problem allocating pointer space"); - return NULL; + return nullptr; } i = 0; @@ -409,13 +409,13 @@ PyDoc_STRVAR(Vector_zero_doc, static PyObject *Vector_zero(VectorObject *self) { if (BaseMath_Prepare_ForWrite(self) == -1) { - return NULL; + return nullptr; } copy_vn_fl(self->vec, self->vec_num, 0.0f); if (BaseMath_WriteCallback(self) == -1) { - return NULL; + return nullptr; } Py_RETURN_NONE; @@ -440,7 +440,7 @@ static PyObject *Vector_normalize(VectorObject *self) { const int vec_num = (self->vec_num == 4 ? 3 : self->vec_num); if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } normalize_vn(self->vec, vec_num); @@ -478,33 +478,33 @@ static PyObject *Vector_resize(VectorObject *self, PyObject *value) PyErr_SetString(PyExc_TypeError, "Vector.resize(): " "cannot resize wrapped data - only Python vectors"); - return NULL; + return nullptr; } if (self->cb_user) { PyErr_SetString(PyExc_TypeError, "Vector.resize(): " "cannot resize a vector that has an owner"); - return NULL; + return nullptr; } if ((vec_num = PyC_Long_AsI32(value)) == -1) { PyErr_SetString(PyExc_TypeError, "Vector.resize(size): " "expected size argument to be an integer"); - return NULL; + return nullptr; } if (vec_num < 2) { PyErr_SetString(PyExc_RuntimeError, "Vector.resize(): invalid size"); - return NULL; + return nullptr; } - self->vec = PyMem_Realloc(self->vec, (vec_num * sizeof(float))); - if (self->vec == NULL) { + self->vec = static_cast(PyMem_Realloc(self->vec, (vec_num * sizeof(float)))); + if (self->vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector.resize(): " "problem allocating pointer space"); - return NULL; + return nullptr; } /* If the vector has increased in length, set all new elements to 0.0f */ @@ -529,27 +529,27 @@ static PyObject *Vector_resized(VectorObject *self, PyObject *value) float *vec; if ((vec_num = PyLong_AsLong(value)) == -1) { - return NULL; + return nullptr; } if (vec_num < 2) { PyErr_SetString(PyExc_RuntimeError, "Vector.resized(): invalid size"); - return NULL; + return nullptr; } - vec = PyMem_Malloc(vec_num * sizeof(float)); + vec = static_cast(PyMem_Malloc(vec_num * sizeof(float))); - if (vec == NULL) { + if (vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector.resized(): " "problem allocating pointer space"); - return NULL; + return nullptr; } copy_vn_fl(vec, vec_num, 0.0f); memcpy(vec, self->vec, self->vec_num * sizeof(float)); - return Vector_CreatePyObject_alloc(vec, vec_num, NULL); + return Vector_CreatePyObject_alloc(vec, vec_num, nullptr); } PyDoc_STRVAR(Vector_resize_2d_doc, @@ -562,21 +562,21 @@ static PyObject *Vector_resize_2d(VectorObject *self) PyErr_SetString(PyExc_TypeError, "Vector.resize_2d(): " "cannot resize wrapped data - only Python vectors"); - return NULL; + return nullptr; } if (self->cb_user) { PyErr_SetString(PyExc_TypeError, "Vector.resize_2d(): " "cannot resize a vector that has an owner"); - return NULL; + return nullptr; } - self->vec = PyMem_Realloc(self->vec, sizeof(float[2])); - if (self->vec == NULL) { + self->vec = static_cast(PyMem_Realloc(self->vec, sizeof(float[2]))); + if (self->vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_2d(): " "problem allocating pointer space"); - return NULL; + return nullptr; } self->vec_num = 2; @@ -593,21 +593,21 @@ static PyObject *Vector_resize_3d(VectorObject *self) PyErr_SetString(PyExc_TypeError, "Vector.resize_3d(): " "cannot resize wrapped data - only Python vectors"); - return NULL; + return nullptr; } if (self->cb_user) { PyErr_SetString(PyExc_TypeError, "Vector.resize_3d(): " "cannot resize a vector that has an owner"); - return NULL; + return nullptr; } - self->vec = PyMem_Realloc(self->vec, sizeof(float[3])); - if (self->vec == NULL) { + self->vec = static_cast(PyMem_Realloc(self->vec, sizeof(float[3]))); + if (self->vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_3d(): " "problem allocating pointer space"); - return NULL; + return nullptr; } if (self->vec_num == 2) { @@ -628,21 +628,21 @@ static PyObject *Vector_resize_4d(VectorObject *self) PyErr_SetString(PyExc_TypeError, "Vector.resize_4d(): " "cannot resize wrapped data - only Python vectors"); - return NULL; + return nullptr; } if (self->cb_user) { PyErr_SetString(PyExc_TypeError, "Vector.resize_4d(): " "cannot resize a vector that has an owner"); - return NULL; + return nullptr; } - self->vec = PyMem_Realloc(self->vec, sizeof(float[4])); - if (self->vec == NULL) { + self->vec = static_cast(PyMem_Realloc(self->vec, sizeof(float[4]))); + if (self->vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_4d(): " "problem allocating pointer space"); - return NULL; + return nullptr; } if (self->vec_num == 2) { @@ -672,7 +672,7 @@ PyDoc_STRVAR(Vector_to_2d_doc, static PyObject *Vector_to_2d(VectorObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return Vector_CreatePyObject(self->vec, 2, Py_TYPE(self)); @@ -689,7 +689,7 @@ static PyObject *Vector_to_3d(VectorObject *self) float tvec[3] = {0.0f}; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } memcpy(tvec, self->vec, sizeof(float) * MIN2(self->vec_num, 3)); @@ -707,7 +707,7 @@ static PyObject *Vector_to_4d(VectorObject *self) float tvec[4] = {0.0f, 0.0f, 0.0f, 1.0f}; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } memcpy(tvec, self->vec, sizeof(float) * MIN2(self->vec_num, 4)); @@ -734,14 +734,14 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args) int ndigits = 0; if (!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits)) { - return NULL; + return nullptr; } if (ndigits > 22 || ndigits < 0) { PyErr_SetString(PyExc_ValueError, "Vector.to_tuple(ndigits): " "ndigits must be between 0 and 21"); - return NULL; + return nullptr; } if (PyTuple_GET_SIZE(args) == 0) { @@ -749,7 +749,7 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args) } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return Vector_to_tuple_ex(self, ndigits); @@ -775,23 +775,23 @@ PyDoc_STRVAR(Vector_to_track_quat_doc, static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) { float vec[3], quat[4]; - const char *strack = NULL; - const char *sup = NULL; + const char *strack = nullptr; + const char *sup = nullptr; short track = 2, up = 1; if (!PyArg_ParseTuple(args, "|ss:to_track_quat", &strack, &sup)) { - return NULL; + return nullptr; } if (self->vec_num != 3) { PyErr_SetString(PyExc_TypeError, "Vector.to_track_quat(): " "only for 3D vectors"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (strack) { @@ -811,12 +811,12 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) break; default: PyErr_SetString(PyExc_ValueError, axis_err_msg); - return NULL; + return nullptr; } } else { PyErr_SetString(PyExc_ValueError, axis_err_msg); - return NULL; + return nullptr; } } else if (strlen(strack) == 1) { @@ -833,12 +833,12 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) break; default: PyErr_SetString(PyExc_ValueError, axis_err_msg); - return NULL; + return nullptr; } } else { PyErr_SetString(PyExc_ValueError, axis_err_msg); - return NULL; + return nullptr; } } @@ -857,18 +857,18 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) break; default: PyErr_SetString(PyExc_ValueError, axis_err_msg); - return NULL; + return nullptr; } } else { PyErr_SetString(PyExc_ValueError, axis_err_msg); - return NULL; + return nullptr; } } if (track == up) { PyErr_SetString(PyExc_ValueError, "Can't have the same axis for track and up"); - return NULL; + return nullptr; } /* Flip vector around, since #vec_to_quat expect a vector from target to tracking object @@ -877,7 +877,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) vec_to_quat(quat, vec, track, up); - return Quaternion_CreatePyObject(quat, NULL); + return Quaternion_CreatePyObject(quat, nullptr); } /** \} */ @@ -904,11 +904,11 @@ static PyObject *Vector_orthogonal(VectorObject *self) PyErr_SetString(PyExc_TypeError, "Vector.orthogonal(): " "Vector must be 3D or 2D"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (self->vec_num == 3) { @@ -947,18 +947,18 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value) float tvec[MAX_DIMENSIONS]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if ((value_num = mathutils_array_parse( tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) { - return NULL; + return nullptr; } if (self->vec_num < 2 || self->vec_num > 4) { PyErr_SetString(PyExc_ValueError, "Vector must be 2D, 3D or 4D"); - return NULL; + return nullptr; } mirror[0] = tvec[0]; @@ -998,23 +998,23 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value) float tvec[3]; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (self->vec_num > 3) { PyErr_SetString(PyExc_ValueError, "Vector must be 2D or 3D"); - return NULL; + return nullptr; } if (mathutils_array_parse( tvec, self->vec_num, self->vec_num, value, "Vector.cross(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } if (self->vec_num == 3) { - ret = Vector_CreatePyObject(NULL, 3, Py_TYPE(self)); + ret = Vector_CreatePyObject(nullptr, 3, Py_TYPE(self)); cross_v3_v3v3(((VectorObject *)ret)->vec, self->vec, tvec); } else { @@ -1045,13 +1045,13 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value) PyObject *ret; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse_alloc( &tvec, self->vec_num, value, "Vector.dot(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } ret = PyFloat_FromDouble(dot_vn_vn(self->vec, tvec, self->vec_num)); @@ -1085,14 +1085,14 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) PyObject *value; double dot = 0.0f, dot_self = 0.0f, dot_other = 0.0f; int x; - PyObject *fallback = NULL; + PyObject *fallback = nullptr; if (!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback)) { - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } /* don't use clamped size, rule of thumb is vector sizes must match, @@ -1101,12 +1101,12 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) tvec, self->vec_num, self->vec_num, value, "Vector.angle(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } if (self->vec_num > 4) { PyErr_SetString(PyExc_ValueError, "Vector must be 2D, 3D or 4D"); - return NULL; + return nullptr; } for (x = 0; x < vec_num; x++) { @@ -1125,7 +1125,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) PyErr_SetString(PyExc_ValueError, "Vector.angle(other): " "zero length vectors have no valid angle"); - return NULL; + return nullptr; } return PyFloat_FromDouble(saacos(dot / (sqrt(dot_self) * sqrt(dot_other)))); @@ -1155,25 +1155,25 @@ static PyObject *Vector_angle_signed(VectorObject *self, PyObject *args) float tvec[2]; PyObject *value; - PyObject *fallback = NULL; + PyObject *fallback = nullptr; if (!PyArg_ParseTuple(args, "O|O:angle_signed", &value, &fallback)) { - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse( tvec, 2, 2, value, "Vector.angle_signed(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } if (self->vec_num != 2) { PyErr_SetString(PyExc_ValueError, "Vector must be 2D"); - return NULL; + return nullptr; } if (is_zero_v2(self->vec) || is_zero_v2(tvec)) { @@ -1186,7 +1186,7 @@ static PyObject *Vector_angle_signed(VectorObject *self, PyObject *args) PyErr_SetString(PyExc_ValueError, "Vector.angle_signed(other): " "zero length vectors have no valid angle"); - return NULL; + return nullptr; } return PyFloat_FromDouble(angle_signed_v2v2(self->vec, tvec)); @@ -1218,17 +1218,17 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value) PyErr_SetString(PyExc_ValueError, "vec.difference(value): " "expects both vectors to be size 3 or 4"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse( vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } normalize_v3_v3(vec_a, self->vec); @@ -1236,7 +1236,7 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value) rotation_between_vecs_to_quat(quat, vec_a, vec_b); - return Quaternion_CreatePyObject(quat, NULL); + return Quaternion_CreatePyObject(quat, nullptr); } /** \} */ @@ -1262,13 +1262,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value) int x; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse_alloc( &tvec, vec_num, value, "Vector.project(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } /* get dot products */ @@ -1304,22 +1304,22 @@ PyDoc_STRVAR(Vector_lerp_doc, static PyObject *Vector_lerp(VectorObject *self, PyObject *args) { const int vec_num = self->vec_num; - PyObject *value = NULL; + PyObject *value = nullptr; float fac; float *tvec; if (!PyArg_ParseTuple(args, "Of:lerp", &value, &fac)) { - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse_alloc( &tvec, vec_num, value, "Vector.lerp(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } interp_vn_vn(tvec, self->vec, 1.0f - fac, vec_num); @@ -1351,30 +1351,30 @@ PyDoc_STRVAR(Vector_slerp_doc, static PyObject *Vector_slerp(VectorObject *self, PyObject *args) { const int vec_num = self->vec_num; - PyObject *value = NULL; + PyObject *value = nullptr; float fac, cosom, w[2]; float self_vec[3], other_vec[3], ret_vec[3]; float self_len_sq, other_len_sq; int x; - PyObject *fallback = NULL; + PyObject *fallback = nullptr; if (!PyArg_ParseTuple(args, "Of|O:slerp", &value, &fac, &fallback)) { - return NULL; + return nullptr; } if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } if (self->vec_num > 3) { PyErr_SetString(PyExc_ValueError, "Vector must be 2D or 3D"); - return NULL; + return nullptr; } if (mathutils_array_parse( other_vec, vec_num, vec_num, value, "Vector.slerp(other), invalid 'other' arg") == -1) { - return NULL; + return nullptr; } self_len_sq = normalize_vn_vn(self_vec, self->vec, vec_num); @@ -1391,7 +1391,7 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args) PyErr_SetString(PyExc_ValueError, "Vector.slerp(): " "zero length vectors unsupported"); - return NULL; + return nullptr; } /* We have sane state, execute slerp */ @@ -1408,7 +1408,7 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args) PyErr_SetString(PyExc_ValueError, "Vector.slerp(): " "opposite vectors unsupported"); - return NULL; + return nullptr; } interp_dot_slerp(fac, cosom, w); @@ -1439,7 +1439,7 @@ PyDoc_STRVAR( static PyObject *Vector_rotate(VectorObject *self, PyObject *value) { if (BaseMath_ReadCallback_ForWrite(self) == -1) { - return NULL; + return nullptr; } if (self->vec_num == 2) { @@ -1447,7 +1447,7 @@ static PyObject *Vector_rotate(VectorObject *self, PyObject *value) float other_rmat[2][2]; MatrixObject *pymat; if (!Matrix_Parse2x2(value, &pymat)) { - return NULL; + return nullptr; } normalize_m2_m2(other_rmat, (const float(*)[2])pymat->matrix); /* Equivalent to a rotation along the Z axis. */ @@ -1457,7 +1457,7 @@ static PyObject *Vector_rotate(VectorObject *self, PyObject *value) float other_rmat[3][3]; if (mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1) { - return NULL; + return nullptr; } mul_m3_v3(other_rmat, self->vec); @@ -1480,7 +1480,7 @@ PyDoc_STRVAR(Vector_negate_doc, static PyObject *Vector_negate(VectorObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } negate_vn(self->vec, self->vec_num); @@ -1508,7 +1508,7 @@ PyDoc_STRVAR(Vector_copy_doc, static PyObject *Vector_copy(VectorObject *self) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return Vector_CreatePyObject(self->vec, self->vec_num, Py_TYPE(self)); @@ -1516,7 +1516,7 @@ static PyObject *Vector_copy(VectorObject *self) static PyObject *Vector_deepcopy(VectorObject *self, PyObject *args) { if (!PyC_CheckArgs_DeepCopy(args)) { - return NULL; + return nullptr; } return Vector_copy(self); } @@ -1532,7 +1532,7 @@ static PyObject *Vector_repr(VectorObject *self) PyObject *ret, *tuple; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } tuple = Vector_to_tuple_ex(self, -1); @@ -1549,7 +1549,7 @@ static PyObject *Vector_str(VectorObject *self) DynStr *ds; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } ds = BLI_dynstr_new(); @@ -1574,7 +1574,7 @@ static PyObject *Vector_str(VectorObject *self) static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type) { - VectorObject *vecA = NULL, *vecB = NULL; + VectorObject *vecA = nullptr, *vecB = nullptr; int result = 0; const double epsilon = 0.000001f; double lenA, lenB; @@ -1590,7 +1590,7 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa vecB = (VectorObject *)objectB; if (BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1) { - return NULL; + return nullptr; } if (vecA->vec_num != vecB->vec_num) { @@ -1700,11 +1700,11 @@ static PyObject *vector_item_internal(VectorObject *self, int i, const bool is_a else { PyErr_SetString(PyExc_IndexError, "vector[index]: out of range"); } - return NULL; + return nullptr; } if (BaseMath_ReadIndexCallback(self, i) == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(self->vec[i]); @@ -1771,7 +1771,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end) int count; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } CLAMP(begin, 0, self->vec_num); @@ -1793,7 +1793,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end) static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *seq) { int vec_num = 0; - float *vec = NULL; + float *vec = nullptr; if (BaseMath_ReadCallback_ForWrite(self) == -1) { return -1; @@ -1808,7 +1808,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se return -1; } - if (vec == NULL) { + if (vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "vec[:] = seq: " "problem allocating pointer space"); @@ -1834,7 +1834,7 @@ static PyObject *Vector_subscript(VectorObject *self, PyObject *item) Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) { - return NULL; + return nullptr; } if (i < 0) { i += self->vec_num; @@ -1845,7 +1845,7 @@ static PyObject *Vector_subscript(VectorObject *self, PyObject *item) Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx(item, self->vec_num, &start, &stop, &step, &slicelength) < 0) { - return NULL; + return nullptr; } if (slicelength <= 0) { @@ -1856,12 +1856,12 @@ static PyObject *Vector_subscript(VectorObject *self, PyObject *item) } PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors"); - return NULL; + return nullptr; } PyErr_Format( PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name); - return NULL; + return nullptr; } /** Sequence generic subscript (set): `object[...] = x`. */ @@ -1906,8 +1906,8 @@ static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *va /** Addition: `object + object`. */ static PyObject *Vector_add(PyObject *v1, PyObject *v2) { - VectorObject *vec1 = NULL, *vec2 = NULL; - float *vec = NULL; + VectorObject *vec1 = nullptr, *vec2 = nullptr; + float *vec = nullptr; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { PyErr_Format(PyExc_AttributeError, @@ -1915,13 +1915,13 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2) "invalid type for this operation", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } vec1 = (VectorObject *)v1; vec2 = (VectorObject *)v2; if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) { - return NULL; + return nullptr; } /* VECTOR + VECTOR. */ @@ -1929,15 +1929,15 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2) PyErr_SetString(PyExc_AttributeError, "Vector addition: " "vectors must have the same dimensions for this operation"); - return NULL; + return nullptr; } - vec = PyMem_Malloc(vec1->vec_num * sizeof(float)); - if (vec == NULL) { + vec = static_cast(PyMem_Malloc(vec1->vec_num * sizeof(float))); + if (vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector(): " "problem allocating pointer space"); - return NULL; + return nullptr; } add_vn_vnvn(vec, vec1->vec, vec2->vec, vec1->vec_num); @@ -1948,7 +1948,7 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2) /** Addition in-place: `object += object`. */ static PyObject *Vector_iadd(PyObject *v1, PyObject *v2) { - VectorObject *vec1 = NULL, *vec2 = NULL; + VectorObject *vec1 = nullptr, *vec2 = nullptr; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { PyErr_Format(PyExc_AttributeError, @@ -1956,7 +1956,7 @@ static PyObject *Vector_iadd(PyObject *v1, PyObject *v2) "invalid type for this operation", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } vec1 = (VectorObject *)v1; vec2 = (VectorObject *)v2; @@ -1965,11 +1965,11 @@ static PyObject *Vector_iadd(PyObject *v1, PyObject *v2) PyErr_SetString(PyExc_AttributeError, "Vector addition: " "vectors must have the same dimensions for this operation"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback_ForWrite(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) { - return NULL; + return nullptr; } add_vn_vn(vec1->vec, vec2->vec, vec1->vec_num); @@ -1982,7 +1982,7 @@ static PyObject *Vector_iadd(PyObject *v1, PyObject *v2) /** Subtraction: `object - object`. */ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) { - VectorObject *vec1 = NULL, *vec2 = NULL; + VectorObject *vec1 = nullptr, *vec2 = nullptr; float *vec; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { @@ -1991,28 +1991,28 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) "invalid type for this operation", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } vec1 = (VectorObject *)v1; vec2 = (VectorObject *)v2; if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) { - return NULL; + return nullptr; } if (vec1->vec_num != vec2->vec_num) { PyErr_SetString(PyExc_AttributeError, "Vector subtraction: " "vectors must have the same dimensions for this operation"); - return NULL; + return nullptr; } - vec = PyMem_Malloc(vec1->vec_num * sizeof(float)); - if (vec == NULL) { + vec = static_cast(PyMem_Malloc(vec1->vec_num * sizeof(float))); + if (vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "Vector(): " "problem allocating pointer space"); - return NULL; + return nullptr; } sub_vn_vnvn(vec, vec1->vec, vec2->vec, vec1->vec_num); @@ -2023,7 +2023,7 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) /** Subtraction in-place: `object -= object`. */ static PyObject *Vector_isub(PyObject *v1, PyObject *v2) { - VectorObject *vec1 = NULL, *vec2 = NULL; + VectorObject *vec1 = nullptr, *vec2 = nullptr; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { PyErr_Format(PyExc_AttributeError, @@ -2031,7 +2031,7 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2) "invalid type for this operation", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } vec1 = (VectorObject *)v1; vec2 = (VectorObject *)v2; @@ -2040,11 +2040,11 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2) PyErr_SetString(PyExc_AttributeError, "Vector subtraction: " "vectors must have the same dimensions for this operation"); - return NULL; + return nullptr; } if (BaseMath_ReadCallback_ForWrite(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) { - return NULL; + return nullptr; } sub_vn_vn(vec1->vec, vec2->vec, vec1->vec_num); @@ -2091,12 +2091,12 @@ int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec, static PyObject *vector_mul_float(VectorObject *vec, const float scalar) { - float *tvec = PyMem_Malloc(vec->vec_num * sizeof(float)); - if (tvec == NULL) { + float *tvec = static_cast(PyMem_Malloc(vec->vec_num * sizeof(float))); + if (tvec == nullptr) { PyErr_SetString(PyExc_MemoryError, "vec * float: " "problem allocating pointer space"); - return NULL; + return nullptr; } mul_vn_vn_fl(tvec, vec->vec, vec->vec_num, scalar); @@ -2105,12 +2105,12 @@ static PyObject *vector_mul_float(VectorObject *vec, const float scalar) static PyObject *vector_mul_vec(VectorObject *vec1, VectorObject *vec2) { - float *tvec = PyMem_Malloc(vec1->vec_num * sizeof(float)); - if (tvec == NULL) { + float *tvec = static_cast(PyMem_Malloc(vec1->vec_num * sizeof(float))); + if (tvec == nullptr) { PyErr_SetString(PyExc_MemoryError, "vec * vec: " "problem allocating pointer space"); - return NULL; + return nullptr; } mul_vn_vnvn(tvec, vec1->vec, vec2->vec, vec1->vec_num); @@ -2120,19 +2120,19 @@ static PyObject *vector_mul_vec(VectorObject *vec1, VectorObject *vec2) /** Multiplication (element-wise or scalar): `object * object`. */ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) { - VectorObject *vec1 = NULL, *vec2 = NULL; + VectorObject *vec1 = nullptr, *vec2 = nullptr; float scalar; if (VectorObject_Check(v1)) { vec1 = (VectorObject *)v1; if (BaseMath_ReadCallback(vec1) == -1) { - return NULL; + return nullptr; } } if (VectorObject_Check(v2)) { vec2 = (VectorObject *)v2; if (BaseMath_ReadCallback(vec2) == -1) { - return NULL; + return nullptr; } } @@ -2144,7 +2144,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "vectors must have the same dimensions for this operation"); - return NULL; + return nullptr; } /* element-wise product */ @@ -2166,30 +2166,30 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } /** Multiplication in-place (element-wise or scalar): `object *= object`. */ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) { - VectorObject *vec1 = NULL, *vec2 = NULL; + VectorObject *vec1 = nullptr, *vec2 = nullptr; float scalar; if (VectorObject_Check(v1)) { vec1 = (VectorObject *)v1; if (BaseMath_ReadCallback(vec1) == -1) { - return NULL; + return nullptr; } } if (VectorObject_Check(v2)) { vec2 = (VectorObject *)v2; if (BaseMath_ReadCallback(vec2) == -1) { - return NULL; + return nullptr; } } if (BaseMath_ReadCallback_ForWrite(vec1) == -1) { - return NULL; + return nullptr; } /* Intentionally don't support (Quaternion, Matrix) here, uses reverse order instead. */ @@ -2199,7 +2199,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "vectors must have the same dimensions for this operation"); - return NULL; + return nullptr; } /* Element-wise product in-place. */ @@ -2215,7 +2215,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } (void)BaseMath_WriteCallback(vec1); @@ -2226,19 +2226,19 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) /** Multiplication (matrix multiply): `object @ object`. */ static PyObject *Vector_matmul(PyObject *v1, PyObject *v2) { - VectorObject *vec1 = NULL, *vec2 = NULL; + VectorObject *vec1 = nullptr, *vec2 = nullptr; int vec_num; if (VectorObject_Check(v1)) { vec1 = (VectorObject *)v1; if (BaseMath_ReadCallback(vec1) == -1) { - return NULL; + return nullptr; } } if (VectorObject_Check(v2)) { vec2 = (VectorObject *)v2; if (BaseMath_ReadCallback(vec2) == -1) { - return NULL; + return nullptr; } } @@ -2250,7 +2250,7 @@ static PyObject *Vector_matmul(PyObject *v1, PyObject *v2) PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "vectors must have the same dimensions for this operation"); - return NULL; + return nullptr; } /* Dot product. */ @@ -2262,10 +2262,10 @@ static PyObject *Vector_matmul(PyObject *v1, PyObject *v2) float tvec[MAX_DIMENSIONS]; if (BaseMath_ReadCallback((MatrixObject *)v2) == -1) { - return NULL; + return nullptr; } if (row_vector_multiplication(tvec, vec1, (MatrixObject *)v2) == -1) { - return NULL; + return nullptr; } if (((MatrixObject *)v2)->row_num == 4 && vec1->vec_num == 3) { @@ -2284,7 +2284,7 @@ static PyObject *Vector_matmul(PyObject *v1, PyObject *v2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } /** Multiplication in-place (matrix multiply): `object @= object`. */ @@ -2295,25 +2295,25 @@ static PyObject *Vector_imatmul(PyObject *v1, PyObject *v2) "not supported between '%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); - return NULL; + return nullptr; } /** Division: `object / object`. */ static PyObject *Vector_div(PyObject *v1, PyObject *v2) { - float *vec = NULL, scalar; - VectorObject *vec1 = NULL; + float *vec = nullptr, scalar; + VectorObject *vec1 = nullptr; if (!VectorObject_Check(v1)) { /* not a vector */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); - return NULL; + return nullptr; } vec1 = (VectorObject *)v1; /* vector */ if (BaseMath_ReadCallback(vec1) == -1) { - return NULL; + return nullptr; } if ((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { @@ -2321,23 +2321,23 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); - return NULL; + return nullptr; } if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: " "divide by zero error"); - return NULL; + return nullptr; } - vec = PyMem_Malloc(vec1->vec_num * sizeof(float)); + vec = static_cast(PyMem_Malloc(vec1->vec_num * sizeof(float))); - if (vec == NULL) { + if (vec == nullptr) { PyErr_SetString(PyExc_MemoryError, "vec / value: " "problem allocating pointer space"); - return NULL; + return nullptr; } mul_vn_vn_fl(vec, vec1->vec, vec1->vec_num, 1.0f / scalar); @@ -2352,7 +2352,7 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2) VectorObject *vec1 = (VectorObject *)v1; if (BaseMath_ReadCallback_ForWrite(vec1) == -1) { - return NULL; + return nullptr; } if ((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { @@ -2360,14 +2360,14 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2) PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); - return NULL; + return nullptr; } if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: " "divide by zero error"); - return NULL; + return nullptr; } mul_vn_fl(vec1->vec, vec1->vec_num, 1.0f / scalar); @@ -2384,10 +2384,10 @@ static PyObject *Vector_neg(VectorObject *self) float *tvec; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } - tvec = PyMem_Malloc(self->vec_num * sizeof(float)); + tvec = static_cast(PyMem_Malloc(self->vec_num * sizeof(float))); negate_vn_vn(tvec, self->vec, self->vec_num); return Vector_CreatePyObject_alloc(tvec, self->vec_num, Py_TYPE(self)); } @@ -2400,15 +2400,15 @@ static PyObject *Vector_neg(VectorObject *self) static PySequenceMethods Vector_SeqMethods = { /*sq_length*/ (lenfunc)Vector_len, - /*sq_concat*/ NULL, - /*sq_repeat*/ NULL, + /*sq_concat*/ nullptr, + /*sq_repeat*/ nullptr, /*sq_item*/ (ssizeargfunc)Vector_item, - /*was_sq_slice*/ NULL, /* DEPRECATED. */ + /*was_sq_slice*/ nullptr, /* DEPRECATED. */ /*sq_ass_item*/ (ssizeobjargproc)Vector_ass_item, - /*was_sq_ass_slice*/ NULL, /* DEPRECATED. */ - /*sq_contains*/ NULL, - /*sq_inplace_concat */ NULL, - /*sq_inplace_repeat */ NULL, + /*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */ + /*sq_contains*/ nullptr, + /*sq_inplace_concat */ nullptr, + /*sq_inplace_repeat */ nullptr, }; static PyMappingMethods Vector_AsMapping = { @@ -2421,37 +2421,37 @@ static PyNumberMethods Vector_NumMethods = { /*nb_add*/ (binaryfunc)Vector_add, /*nb_subtract*/ (binaryfunc)Vector_sub, /*nb_multiply*/ (binaryfunc)Vector_mul, - /*nb_remainder*/ NULL, - /*nb_divmod*/ NULL, - /*nb_power*/ NULL, + /*nb_remainder*/ nullptr, + /*nb_divmod*/ nullptr, + /*nb_power*/ nullptr, /*nb_negative*/ (unaryfunc)Vector_neg, /*tp_positive*/ (unaryfunc)Vector_copy, - /*tp_absolute*/ NULL, - /*tp_bool*/ NULL, - /*nb_invert*/ NULL, - /*nb_lshift*/ NULL, - /*nb_rshift*/ NULL, - /*nb_and*/ NULL, - /*nb_xor*/ NULL, - /*nb_or*/ NULL, - /*nb_int*/ NULL, - /*nb_reserved*/ NULL, - /*nb_float*/ NULL, + /*tp_absolute*/ nullptr, + /*tp_bool*/ nullptr, + /*nb_invert*/ nullptr, + /*nb_lshift*/ nullptr, + /*nb_rshift*/ nullptr, + /*nb_and*/ nullptr, + /*nb_xor*/ nullptr, + /*nb_or*/ nullptr, + /*nb_int*/ nullptr, + /*nb_reserved*/ nullptr, + /*nb_float*/ nullptr, /*nb_inplace_add*/ Vector_iadd, /*nb_inplace_subtract*/ Vector_isub, /*nb_inplace_multiply*/ Vector_imul, - /*nb_inplace_remainder*/ NULL, - /*nb_inplace_power*/ NULL, - /*nb_inplace_lshift*/ NULL, - /*nb_inplace_rshift*/ NULL, - /*nb_inplace_and*/ NULL, - /*nb_inplace_xor*/ NULL, - /*nb_inplace_or*/ NULL, - /*nb_floor_divide*/ NULL, + /*nb_inplace_remainder*/ nullptr, + /*nb_inplace_power*/ nullptr, + /*nb_inplace_lshift*/ nullptr, + /*nb_inplace_rshift*/ nullptr, + /*nb_inplace_and*/ nullptr, + /*nb_inplace_xor*/ nullptr, + /*nb_inplace_or*/ nullptr, + /*nb_floor_divide*/ nullptr, /*nb_true_divide*/ Vector_div, - /*nb_inplace_floor_divide*/ NULL, + /*nb_inplace_floor_divide*/ nullptr, /*nb_inplace_true_divide*/ Vector_idiv, - /*nb_index*/ NULL, + /*nb_index*/ nullptr, /*nb_matrix_multiply*/ (binaryfunc)Vector_matmul, /*nb_inplace_matrix_multiply*/ (binaryfunc)Vector_imatmul, }; @@ -2482,10 +2482,10 @@ static int Vector_axis_set(VectorObject *self, PyObject *value, void *type) /* `Vector.length`. */ PyDoc_STRVAR(Vector_length_doc, "Vector Length.\n\n:type: float"); -static PyObject *Vector_length_get(VectorObject *self, void *UNUSED(closure)) +static PyObject *Vector_length_get(VectorObject *self, void * /*closure*/) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(sqrt(dot_vn_vn(self->vec, self->vec, self->vec_num))); @@ -2537,10 +2537,10 @@ static int Vector_length_set(VectorObject *self, PyObject *value) /* `Vector.length_squared`. */ PyDoc_STRVAR(Vector_length_squared_doc, "Vector length squared (v.dot(v)).\n\n:type: float"); -static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(closure)) +static PyObject *Vector_length_squared_get(VectorObject *self, void * /*closure*/) { if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(dot_vn_vn(self->vec, self->vec, self->vec_num)); @@ -2593,9 +2593,9 @@ static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(clos * unique = set() * for key, val in items: * num = eval(val) - * set_str = 'Vector_swizzle_set' if (len(set(key)) == len(key)) else 'NULL' + * set_str = 'Vector_swizzle_set' if (len(set(key)) == len(key)) else 'nullptr' * key_args = ', '.join(["'%s'" % c for c in key.upper()]) - * print('\t{"%s", %s(getter)Vector_swizzle_get, (setter)%s, NULL, SWIZZLE%d(%s)},' % + * print('\t{"%s", %s(getter)Vector_swizzle_get, (setter)%s, nullptr, SWIZZLE%d(%s)},' % * (key, (' ' * (4 - len(key))), set_str, len(key), key_args)) * unique.add(num) * @@ -2615,7 +2615,7 @@ static PyObject *Vector_swizzle_get(VectorObject *self, void *closure) uint swizzleClosure; if (BaseMath_ReadCallback(self) == -1) { - return NULL; + return nullptr; } /* Unpack the axes from the closure into an array. */ @@ -2627,7 +2627,7 @@ static PyObject *Vector_swizzle_get(VectorObject *self, void *closure) PyErr_SetString(PyExc_AttributeError, "Vector swizzle: " "specified axis not present"); - return NULL; + return nullptr; } vec[axis_to] = self->vec[axis_from]; @@ -2754,367 +2754,471 @@ static PyGetSetDef Vector_getseters[] = { {"y", (getter)Vector_axis_get, (setter)Vector_axis_set, Vector_axis_y_doc, (void *)1}, {"z", (getter)Vector_axis_get, (setter)Vector_axis_set, Vector_axis_z_doc, (void *)2}, {"w", (getter)Vector_axis_get, (setter)Vector_axis_set, Vector_axis_w_doc, (void *)3}, - {"length", (getter)Vector_length_get, (setter)Vector_length_set, Vector_length_doc, NULL}, + {"length", (getter)Vector_length_get, (setter)Vector_length_set, Vector_length_doc, nullptr}, {"length_squared", (getter)Vector_length_squared_get, - (setter)NULL, + (setter) nullptr, Vector_length_squared_doc, - NULL}, - {"magnitude", (getter)Vector_length_get, (setter)Vector_length_set, Vector_length_doc, NULL}, + nullptr}, + {"magnitude", + (getter)Vector_length_get, + (setter)Vector_length_set, + Vector_length_doc, + nullptr}, {"is_wrapped", (getter)BaseMathObject_is_wrapped_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_wrapped_doc, - NULL}, + nullptr}, {"is_frozen", (getter)BaseMathObject_is_frozen_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_frozen_doc, - NULL}, + nullptr}, {"is_valid", (getter)BaseMathObject_is_valid_get, - (setter)NULL, + (setter) nullptr, BaseMathObject_is_valid_doc, - NULL}, - {"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, + nullptr}, + {"owner", + (getter)BaseMathObject_owner_get, + (setter) nullptr, + BaseMathObject_owner_doc, + nullptr}, /* Auto-generated swizzle attributes, see Python script above. */ - {"xx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE2(0, 0)}, - {"xxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 0, 0)}, - {"xxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 0, 0)}, - {"xxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 0, 1)}, - {"xxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 0, 2)}, - {"xxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 0, 3)}, - {"xxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 0, 1)}, - {"xxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 1, 0)}, - {"xxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 1, 1)}, - {"xxyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 1, 2)}, - {"xxyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 1, 3)}, - {"xxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 0, 2)}, - {"xxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 2, 0)}, - {"xxzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 2, 1)}, - {"xxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 2, 2)}, - {"xxzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 2, 3)}, - {"xxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 0, 3)}, - {"xxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 3, 0)}, - {"xxwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 3, 1)}, - {"xxwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 3, 2)}, - {"xxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 3, 3)}, - {"xy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(0, 1)}, - {"xyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 1, 0)}, - {"xyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 0, 0)}, - {"xyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 0, 1)}, - {"xyxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 0, 2)}, - {"xyxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 0, 3)}, - {"xyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 1, 1)}, - {"xyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 1, 0)}, - {"xyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 1, 1)}, - {"xyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 1, 2)}, - {"xyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 1, 3)}, - {"xyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 1, 2)}, - {"xyzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 2, 0)}, - {"xyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 2, 1)}, - {"xyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 2, 2)}, - {"xyzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 1, 2, 3)}, - {"xyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 1, 3)}, - {"xywx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 3, 0)}, - {"xywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 3, 1)}, - {"xywz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 1, 3, 2)}, - {"xyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 3, 3)}, - {"xz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(0, 2)}, - {"xzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 2, 0)}, - {"xzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 0, 0)}, - {"xzxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 0, 1)}, - {"xzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 0, 2)}, - {"xzxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 0, 3)}, - {"xzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 2, 1)}, - {"xzyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 1, 0)}, - {"xzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 1, 1)}, - {"xzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 1, 2)}, - {"xzyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 2, 1, 3)}, - {"xzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 2, 2)}, - {"xzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 2, 0)}, - {"xzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 2, 1)}, - {"xzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 2, 2)}, - {"xzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 2, 3)}, - {"xzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 2, 3)}, - {"xzwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 3, 0)}, - {"xzwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 2, 3, 1)}, - {"xzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 3, 2)}, - {"xzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 3, 3)}, - {"xw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(0, 3)}, - {"xwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 3, 0)}, - {"xwxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 0, 0)}, - {"xwxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 0, 1)}, - {"xwxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 0, 2)}, - {"xwxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 0, 3)}, - {"xwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 3, 1)}, - {"xwyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 1, 0)}, - {"xwyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 1, 1)}, - {"xwyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 3, 1, 2)}, - {"xwyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 1, 3)}, - {"xwz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 3, 2)}, - {"xwzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 2, 0)}, - {"xwzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 3, 2, 1)}, - {"xwzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 2, 2)}, - {"xwzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 2, 3)}, - {"xww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 3, 3)}, - {"xwwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 3, 0)}, - {"xwwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 3, 1)}, - {"xwwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 3, 2)}, - {"xwww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 3, 3)}, - {"yx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(1, 0)}, - {"yxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 0, 0)}, - {"yxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 0, 0)}, - {"yxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 0, 1)}, - {"yxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 0, 2)}, - {"yxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 0, 3)}, - {"yxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 0, 1)}, - {"yxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 1, 0)}, - {"yxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 1, 1)}, - {"yxyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 1, 2)}, - {"yxyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 1, 3)}, - {"yxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 0, 2)}, - {"yxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 2, 0)}, - {"yxzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 2, 1)}, - {"yxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 2, 2)}, - {"yxzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 0, 2, 3)}, - {"yxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 0, 3)}, - {"yxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 3, 0)}, - {"yxwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 3, 1)}, - {"yxwz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 0, 3, 2)}, - {"yxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 3, 3)}, - {"yy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE2(1, 1)}, - {"yyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 1, 0)}, - {"yyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 0, 0)}, - {"yyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 0, 1)}, - {"yyxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 0, 2)}, - {"yyxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 0, 3)}, - {"yyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 1, 1)}, - {"yyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 1, 0)}, - {"yyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 1, 1)}, - {"yyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 1, 2)}, - {"yyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 1, 3)}, - {"yyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 1, 2)}, - {"yyzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 2, 0)}, - {"yyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 2, 1)}, - {"yyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 2, 2)}, - {"yyzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 2, 3)}, - {"yyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 1, 3)}, - {"yywx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 3, 0)}, - {"yywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 3, 1)}, - {"yywz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 3, 2)}, - {"yyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 3, 3)}, - {"yz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(1, 2)}, - {"yzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 2, 0)}, - {"yzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 0, 0)}, - {"yzxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 0, 1)}, - {"yzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 0, 2)}, - {"yzxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 2, 0, 3)}, - {"yzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 2, 1)}, - {"yzyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 1, 0)}, - {"yzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 1, 1)}, - {"yzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 1, 2)}, - {"yzyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 1, 3)}, - {"yzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 2, 2)}, - {"yzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 2, 0)}, - {"yzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 2, 1)}, - {"yzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 2, 2)}, - {"yzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 2, 3)}, - {"yzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 2, 3)}, - {"yzwx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 2, 3, 0)}, - {"yzwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 3, 1)}, - {"yzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 3, 2)}, - {"yzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 3, 3)}, - {"yw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(1, 3)}, - {"ywx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 3, 0)}, - {"ywxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 0, 0)}, - {"ywxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 0, 1)}, - {"ywxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 3, 0, 2)}, - {"ywxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 0, 3)}, - {"ywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 3, 1)}, - {"ywyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 1, 0)}, - {"ywyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 1, 1)}, - {"ywyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 1, 2)}, - {"ywyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 1, 3)}, - {"ywz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 3, 2)}, - {"ywzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 3, 2, 0)}, - {"ywzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 2, 1)}, - {"ywzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 2, 2)}, - {"ywzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 2, 3)}, - {"yww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 3, 3)}, - {"ywwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 3, 0)}, - {"ywwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 3, 1)}, - {"ywwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 3, 2)}, - {"ywww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 3, 3)}, - {"zx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(2, 0)}, - {"zxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 0, 0)}, - {"zxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 0, 0)}, - {"zxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 0, 1)}, - {"zxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 0, 2)}, - {"zxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 0, 3)}, - {"zxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 0, 1)}, - {"zxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 1, 0)}, - {"zxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 1, 1)}, - {"zxyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 1, 2)}, - {"zxyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 0, 1, 3)}, - {"zxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 0, 2)}, - {"zxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 2, 0)}, - {"zxzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 2, 1)}, - {"zxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 2, 2)}, - {"zxzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 2, 3)}, - {"zxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 0, 3)}, - {"zxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 3, 0)}, - {"zxwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 0, 3, 1)}, - {"zxwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 3, 2)}, - {"zxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 3, 3)}, - {"zy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(2, 1)}, - {"zyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 1, 0)}, - {"zyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 0, 0)}, - {"zyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 0, 1)}, - {"zyxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 0, 2)}, - {"zyxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 1, 0, 3)}, - {"zyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 1, 1)}, - {"zyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 1, 0)}, - {"zyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 1, 1)}, - {"zyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 1, 2)}, - {"zyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 1, 3)}, - {"zyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 1, 2)}, - {"zyzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 2, 0)}, - {"zyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 2, 1)}, - {"zyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 2, 2)}, - {"zyzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 2, 3)}, - {"zyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 1, 3)}, - {"zywx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 1, 3, 0)}, - {"zywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 3, 1)}, - {"zywz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 3, 2)}, - {"zyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 3, 3)}, - {"zz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE2(2, 2)}, - {"zzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 2, 0)}, - {"zzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 0, 0)}, - {"zzxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 0, 1)}, - {"zzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 0, 2)}, - {"zzxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 0, 3)}, - {"zzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 2, 1)}, - {"zzyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 1, 0)}, - {"zzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 1, 1)}, - {"zzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 1, 2)}, - {"zzyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 1, 3)}, - {"zzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 2, 2)}, - {"zzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 2, 0)}, - {"zzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 2, 1)}, - {"zzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 2, 2)}, - {"zzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 2, 3)}, - {"zzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 2, 3)}, - {"zzwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 3, 0)}, - {"zzwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 3, 1)}, - {"zzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 3, 2)}, - {"zzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 3, 3)}, - {"zw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(2, 3)}, - {"zwx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 3, 0)}, - {"zwxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 0, 0)}, - {"zwxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 3, 0, 1)}, - {"zwxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 0, 2)}, - {"zwxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 0, 3)}, - {"zwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 3, 1)}, - {"zwyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 3, 1, 0)}, - {"zwyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 1, 1)}, - {"zwyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 1, 2)}, - {"zwyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 1, 3)}, - {"zwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 3, 2)}, - {"zwzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 2, 0)}, - {"zwzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 2, 1)}, - {"zwzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 2, 2)}, - {"zwzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 2, 3)}, - {"zww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 3, 3)}, - {"zwwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 3, 0)}, - {"zwwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 3, 1)}, - {"zwwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 3, 2)}, - {"zwww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 3, 3)}, - {"wx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(3, 0)}, - {"wxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 0, 0)}, - {"wxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 0, 0)}, - {"wxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 0, 1)}, - {"wxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 0, 2)}, - {"wxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 0, 3)}, - {"wxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 0, 1)}, - {"wxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 1, 0)}, - {"wxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 1, 1)}, - {"wxyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 0, 1, 2)}, - {"wxyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 1, 3)}, - {"wxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 0, 2)}, - {"wxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 2, 0)}, - {"wxzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 0, 2, 1)}, - {"wxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 2, 2)}, - {"wxzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 2, 3)}, - {"wxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 0, 3)}, - {"wxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 3, 0)}, - {"wxwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 3, 1)}, - {"wxwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 3, 2)}, - {"wxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 3, 3)}, - {"wy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(3, 1)}, - {"wyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 1, 0)}, - {"wyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 0, 0)}, - {"wyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 0, 1)}, - {"wyxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 1, 0, 2)}, - {"wyxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 0, 3)}, - {"wyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 1, 1)}, - {"wyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 1, 0)}, - {"wyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 1, 1)}, - {"wyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 1, 2)}, - {"wyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 1, 3)}, - {"wyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 1, 2)}, - {"wyzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 1, 2, 0)}, - {"wyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 2, 1)}, - {"wyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 2, 2)}, - {"wyzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 2, 3)}, - {"wyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 1, 3)}, - {"wywx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 3, 0)}, - {"wywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 3, 1)}, - {"wywz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 3, 2)}, - {"wyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 3, 3)}, - {"wz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(3, 2)}, - {"wzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 2, 0)}, - {"wzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 0, 0)}, - {"wzxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 2, 0, 1)}, - {"wzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 0, 2)}, - {"wzxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 0, 3)}, - {"wzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 2, 1)}, - {"wzyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 2, 1, 0)}, - {"wzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 1, 1)}, - {"wzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 1, 2)}, - {"wzyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 1, 3)}, - {"wzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 2, 2)}, - {"wzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 2, 0)}, - {"wzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 2, 1)}, - {"wzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 2, 2)}, - {"wzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 2, 3)}, - {"wzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 2, 3)}, - {"wzwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 3, 0)}, - {"wzwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 3, 1)}, - {"wzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 3, 2)}, - {"wzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 3, 3)}, - {"ww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE2(3, 3)}, - {"wwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 3, 0)}, - {"wwxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 0, 0)}, - {"wwxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 0, 1)}, - {"wwxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 0, 2)}, - {"wwxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 0, 3)}, - {"wwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 3, 1)}, - {"wwyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 1, 0)}, - {"wwyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 1, 1)}, - {"wwyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 1, 2)}, - {"wwyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 1, 3)}, - {"wwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 3, 2)}, - {"wwzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 2, 0)}, - {"wwzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 2, 1)}, - {"wwzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 2, 2)}, - {"wwzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 2, 3)}, - {"www", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 3, 3)}, - {"wwwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 3, 0)}, - {"wwwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 3, 1)}, - {"wwwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 3, 2)}, - {"wwww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 3, 3)}, + {"xx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE2(0, 0)}, + {"xxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(0, 0, 0)}, + {"xxxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 0, 0)}, + {"xxxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 0, 1)}, + {"xxxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 0, 2)}, + {"xxxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 0, 3)}, + {"xxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(0, 0, 1)}, + {"xxyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 1, 0)}, + {"xxyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 1, 1)}, + {"xxyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 1, 2)}, + {"xxyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 1, 3)}, + {"xxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(0, 0, 2)}, + {"xxzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 2, 0)}, + {"xxzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 2, 1)}, + {"xxzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 2, 2)}, + {"xxzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 2, 3)}, + {"xxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(0, 0, 3)}, + {"xxwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 3, 0)}, + {"xxwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 3, 1)}, + {"xxwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 3, 2)}, + {"xxww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 0, 3, 3)}, + {"xy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(0, 1)}, + {"xyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(0, 1, 0)}, + {"xyxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 0, 0)}, + {"xyxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 0, 1)}, + {"xyxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 0, 2)}, + {"xyxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 0, 3)}, + {"xyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(0, 1, 1)}, + {"xyyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 1, 0)}, + {"xyyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 1, 1)}, + {"xyyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 1, 2)}, + {"xyyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 1, 3)}, + {"xyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(0, 1, 2)}, + {"xyzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 2, 0)}, + {"xyzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 2, 1)}, + {"xyzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 2, 2)}, + {"xyzw", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(0, 1, 2, 3)}, + {"xyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(0, 1, 3)}, + {"xywx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 3, 0)}, + {"xywy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 3, 1)}, + {"xywz", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(0, 1, 3, 2)}, + {"xyww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 1, 3, 3)}, + {"xz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(0, 2)}, + {"xzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(0, 2, 0)}, + {"xzxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 0, 0)}, + {"xzxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 0, 1)}, + {"xzxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 0, 2)}, + {"xzxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 0, 3)}, + {"xzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(0, 2, 1)}, + {"xzyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 1, 0)}, + {"xzyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 1, 1)}, + {"xzyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 1, 2)}, + {"xzyw", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(0, 2, 1, 3)}, + {"xzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(0, 2, 2)}, + {"xzzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 2, 0)}, + {"xzzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 2, 1)}, + {"xzzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 2, 2)}, + {"xzzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 2, 3)}, + {"xzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(0, 2, 3)}, + {"xzwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 3, 0)}, + {"xzwy", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(0, 2, 3, 1)}, + {"xzwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 3, 2)}, + {"xzww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 2, 3, 3)}, + {"xw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(0, 3)}, + {"xwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(0, 3, 0)}, + {"xwxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 0, 0)}, + {"xwxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 0, 1)}, + {"xwxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 0, 2)}, + {"xwxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 0, 3)}, + {"xwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(0, 3, 1)}, + {"xwyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 1, 0)}, + {"xwyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 1, 1)}, + {"xwyz", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(0, 3, 1, 2)}, + {"xwyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 1, 3)}, + {"xwz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(0, 3, 2)}, + {"xwzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 2, 0)}, + {"xwzy", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(0, 3, 2, 1)}, + {"xwzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 2, 2)}, + {"xwzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 2, 3)}, + {"xww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(0, 3, 3)}, + {"xwwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 3, 0)}, + {"xwwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 3, 1)}, + {"xwwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 3, 2)}, + {"xwww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(0, 3, 3, 3)}, + {"yx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(1, 0)}, + {"yxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(1, 0, 0)}, + {"yxxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 0, 0)}, + {"yxxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 0, 1)}, + {"yxxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 0, 2)}, + {"yxxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 0, 3)}, + {"yxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(1, 0, 1)}, + {"yxyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 1, 0)}, + {"yxyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 1, 1)}, + {"yxyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 1, 2)}, + {"yxyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 1, 3)}, + {"yxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(1, 0, 2)}, + {"yxzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 2, 0)}, + {"yxzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 2, 1)}, + {"yxzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 2, 2)}, + {"yxzw", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(1, 0, 2, 3)}, + {"yxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(1, 0, 3)}, + {"yxwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 3, 0)}, + {"yxwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 3, 1)}, + {"yxwz", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(1, 0, 3, 2)}, + {"yxww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 0, 3, 3)}, + {"yy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE2(1, 1)}, + {"yyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(1, 1, 0)}, + {"yyxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 0, 0)}, + {"yyxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 0, 1)}, + {"yyxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 0, 2)}, + {"yyxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 0, 3)}, + {"yyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(1, 1, 1)}, + {"yyyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 1, 0)}, + {"yyyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 1, 1)}, + {"yyyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 1, 2)}, + {"yyyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 1, 3)}, + {"yyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(1, 1, 2)}, + {"yyzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 2, 0)}, + {"yyzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 2, 1)}, + {"yyzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 2, 2)}, + {"yyzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 2, 3)}, + {"yyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(1, 1, 3)}, + {"yywx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 3, 0)}, + {"yywy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 3, 1)}, + {"yywz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 3, 2)}, + {"yyww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 1, 3, 3)}, + {"yz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(1, 2)}, + {"yzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(1, 2, 0)}, + {"yzxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 0, 0)}, + {"yzxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 0, 1)}, + {"yzxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 0, 2)}, + {"yzxw", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(1, 2, 0, 3)}, + {"yzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(1, 2, 1)}, + {"yzyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 1, 0)}, + {"yzyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 1, 1)}, + {"yzyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 1, 2)}, + {"yzyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 1, 3)}, + {"yzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(1, 2, 2)}, + {"yzzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 2, 0)}, + {"yzzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 2, 1)}, + {"yzzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 2, 2)}, + {"yzzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 2, 3)}, + {"yzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(1, 2, 3)}, + {"yzwx", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(1, 2, 3, 0)}, + {"yzwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 3, 1)}, + {"yzwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 3, 2)}, + {"yzww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 2, 3, 3)}, + {"yw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(1, 3)}, + {"ywx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(1, 3, 0)}, + {"ywxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 0, 0)}, + {"ywxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 0, 1)}, + {"ywxz", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(1, 3, 0, 2)}, + {"ywxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 0, 3)}, + {"ywy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(1, 3, 1)}, + {"ywyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 1, 0)}, + {"ywyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 1, 1)}, + {"ywyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 1, 2)}, + {"ywyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 1, 3)}, + {"ywz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(1, 3, 2)}, + {"ywzx", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(1, 3, 2, 0)}, + {"ywzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 2, 1)}, + {"ywzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 2, 2)}, + {"ywzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 2, 3)}, + {"yww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(1, 3, 3)}, + {"ywwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 3, 0)}, + {"ywwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 3, 1)}, + {"ywwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 3, 2)}, + {"ywww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(1, 3, 3, 3)}, + {"zx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(2, 0)}, + {"zxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(2, 0, 0)}, + {"zxxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 0, 0)}, + {"zxxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 0, 1)}, + {"zxxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 0, 2)}, + {"zxxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 0, 3)}, + {"zxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(2, 0, 1)}, + {"zxyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 1, 0)}, + {"zxyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 1, 1)}, + {"zxyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 1, 2)}, + {"zxyw", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(2, 0, 1, 3)}, + {"zxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(2, 0, 2)}, + {"zxzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 2, 0)}, + {"zxzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 2, 1)}, + {"zxzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 2, 2)}, + {"zxzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 2, 3)}, + {"zxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(2, 0, 3)}, + {"zxwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 3, 0)}, + {"zxwy", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(2, 0, 3, 1)}, + {"zxwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 3, 2)}, + {"zxww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 0, 3, 3)}, + {"zy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(2, 1)}, + {"zyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(2, 1, 0)}, + {"zyxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 0, 0)}, + {"zyxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 0, 1)}, + {"zyxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 0, 2)}, + {"zyxw", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(2, 1, 0, 3)}, + {"zyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(2, 1, 1)}, + {"zyyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 1, 0)}, + {"zyyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 1, 1)}, + {"zyyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 1, 2)}, + {"zyyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 1, 3)}, + {"zyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(2, 1, 2)}, + {"zyzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 2, 0)}, + {"zyzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 2, 1)}, + {"zyzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 2, 2)}, + {"zyzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 2, 3)}, + {"zyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(2, 1, 3)}, + {"zywx", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(2, 1, 3, 0)}, + {"zywy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 3, 1)}, + {"zywz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 3, 2)}, + {"zyww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 1, 3, 3)}, + {"zz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE2(2, 2)}, + {"zzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(2, 2, 0)}, + {"zzxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 0, 0)}, + {"zzxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 0, 1)}, + {"zzxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 0, 2)}, + {"zzxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 0, 3)}, + {"zzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(2, 2, 1)}, + {"zzyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 1, 0)}, + {"zzyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 1, 1)}, + {"zzyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 1, 2)}, + {"zzyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 1, 3)}, + {"zzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(2, 2, 2)}, + {"zzzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 2, 0)}, + {"zzzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 2, 1)}, + {"zzzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 2, 2)}, + {"zzzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 2, 3)}, + {"zzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(2, 2, 3)}, + {"zzwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 3, 0)}, + {"zzwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 3, 1)}, + {"zzwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 3, 2)}, + {"zzww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 2, 3, 3)}, + {"zw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(2, 3)}, + {"zwx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(2, 3, 0)}, + {"zwxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 0, 0)}, + {"zwxy", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(2, 3, 0, 1)}, + {"zwxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 0, 2)}, + {"zwxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 0, 3)}, + {"zwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(2, 3, 1)}, + {"zwyx", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(2, 3, 1, 0)}, + {"zwyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 1, 1)}, + {"zwyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 1, 2)}, + {"zwyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 1, 3)}, + {"zwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(2, 3, 2)}, + {"zwzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 2, 0)}, + {"zwzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 2, 1)}, + {"zwzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 2, 2)}, + {"zwzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 2, 3)}, + {"zww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(2, 3, 3)}, + {"zwwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 3, 0)}, + {"zwwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 3, 1)}, + {"zwwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 3, 2)}, + {"zwww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(2, 3, 3, 3)}, + {"wx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(3, 0)}, + {"wxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(3, 0, 0)}, + {"wxxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 0, 0)}, + {"wxxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 0, 1)}, + {"wxxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 0, 2)}, + {"wxxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 0, 3)}, + {"wxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(3, 0, 1)}, + {"wxyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 1, 0)}, + {"wxyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 1, 1)}, + {"wxyz", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(3, 0, 1, 2)}, + {"wxyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 1, 3)}, + {"wxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(3, 0, 2)}, + {"wxzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 2, 0)}, + {"wxzy", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(3, 0, 2, 1)}, + {"wxzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 2, 2)}, + {"wxzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 2, 3)}, + {"wxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(3, 0, 3)}, + {"wxwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 3, 0)}, + {"wxwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 3, 1)}, + {"wxwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 3, 2)}, + {"wxww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 0, 3, 3)}, + {"wy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(3, 1)}, + {"wyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(3, 1, 0)}, + {"wyxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 0, 0)}, + {"wyxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 0, 1)}, + {"wyxz", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(3, 1, 0, 2)}, + {"wyxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 0, 3)}, + {"wyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(3, 1, 1)}, + {"wyyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 1, 0)}, + {"wyyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 1, 1)}, + {"wyyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 1, 2)}, + {"wyyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 1, 3)}, + {"wyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(3, 1, 2)}, + {"wyzx", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(3, 1, 2, 0)}, + {"wyzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 2, 1)}, + {"wyzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 2, 2)}, + {"wyzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 2, 3)}, + {"wyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(3, 1, 3)}, + {"wywx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 3, 0)}, + {"wywy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 3, 1)}, + {"wywz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 3, 2)}, + {"wyww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 1, 3, 3)}, + {"wz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE2(3, 2)}, + {"wzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(3, 2, 0)}, + {"wzxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 0, 0)}, + {"wzxy", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(3, 2, 0, 1)}, + {"wzxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 0, 2)}, + {"wzxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 0, 3)}, + {"wzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, nullptr, SWIZZLE3(3, 2, 1)}, + {"wzyx", + (getter)Vector_swizzle_get, + (setter)Vector_swizzle_set, + nullptr, + SWIZZLE4(3, 2, 1, 0)}, + {"wzyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 1, 1)}, + {"wzyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 1, 2)}, + {"wzyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 1, 3)}, + {"wzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(3, 2, 2)}, + {"wzzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 2, 0)}, + {"wzzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 2, 1)}, + {"wzzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 2, 2)}, + {"wzzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 2, 3)}, + {"wzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(3, 2, 3)}, + {"wzwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 3, 0)}, + {"wzwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 3, 1)}, + {"wzwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 3, 2)}, + {"wzww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 2, 3, 3)}, + {"ww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE2(3, 3)}, + {"wwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(3, 3, 0)}, + {"wwxx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 0, 0)}, + {"wwxy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 0, 1)}, + {"wwxz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 0, 2)}, + {"wwxw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 0, 3)}, + {"wwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(3, 3, 1)}, + {"wwyx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 1, 0)}, + {"wwyy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 1, 1)}, + {"wwyz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 1, 2)}, + {"wwyw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 1, 3)}, + {"wwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(3, 3, 2)}, + {"wwzx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 2, 0)}, + {"wwzy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 2, 1)}, + {"wwzz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 2, 2)}, + {"wwzw", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 2, 3)}, + {"www", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE3(3, 3, 3)}, + {"wwwx", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 3, 0)}, + {"wwwy", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 3, 1)}, + {"wwwz", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 3, 2)}, + {"wwww", (getter)Vector_swizzle_get, (setter) nullptr, nullptr, SWIZZLE4(3, 3, 3, 3)}, #undef AXIS_FROM_CHAR #undef SWIZZLE1 @@ -3126,7 +3230,7 @@ static PyGetSetDef Vector_getseters[] = { #undef _SWIZZLE3 #undef _SWIZZLE4 - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; /** \} */ @@ -3181,9 +3285,9 @@ static PyMethodDef Vector_methods[] = { {"freeze", (PyCFunction)BaseMathObject_freeze, METH_NOARGS, BaseMathObject_freeze_doc}, {"copy", (PyCFunction)Vector_copy, METH_NOARGS, Vector_copy_doc}, - {"__copy__", (PyCFunction)Vector_copy, METH_NOARGS, NULL}, - {"__deepcopy__", (PyCFunction)Vector_deepcopy, METH_VARARGS, NULL}, - {NULL, NULL, 0, NULL}, + {"__copy__", (PyCFunction)Vector_copy, METH_NOARGS, nullptr}, + {"__deepcopy__", (PyCFunction)Vector_deepcopy, METH_VARARGS, nullptr}, + {nullptr, nullptr, 0, nullptr}, }; /** \} */ @@ -3197,7 +3301,7 @@ static PyMethodDef Vector_methods[] = { * \{ */ #ifdef MATH_STANDALONE -# define Vector_str NULL +# define Vector_str nullptr #endif PyDoc_STRVAR(vector_doc, @@ -3208,59 +3312,59 @@ PyDoc_STRVAR(vector_doc, " :arg seq: Components of the vector, must be a sequence of at least two\n" " :type seq: sequence of numbers\n"); PyTypeObject vector_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "Vector", /*tp_basicsize*/ sizeof(VectorObject), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)BaseMathObject_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, /*tp_repr*/ (reprfunc)Vector_repr, /*tp_as_number*/ &Vector_NumMethods, /*tp_as_sequence*/ &Vector_SeqMethods, /*tp_as_mapping*/ &Vector_AsMapping, /*tp_hash*/ (hashfunc)Vector_hash, - /*tp_call*/ NULL, + /*tp_call*/ nullptr, /*tp_str*/ (reprfunc)Vector_str, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_doc*/ vector_doc, /*tp_traverse*/ (traverseproc)BaseMathObject_traverse, /*tp_clear*/ (inquiry)BaseMathObject_clear, /*tp_richcompare*/ (richcmpfunc)Vector_richcmpr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ Vector_methods, - /*tp_members*/ NULL, + /*tp_members*/ nullptr, /*tp_getset*/ Vector_getseters, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, - /*tp_init*/ NULL, - /*tp_alloc*/ NULL, + /*tp_init*/ nullptr, + /*tp_alloc*/ nullptr, /*tp_new*/ Vector_new, - /*tp_free*/ NULL, + /*tp_free*/ nullptr, /*tp_is_gc*/ (inquiry)BaseMathObject_is_gc, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ NULL, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; #ifdef MATH_STANDALONE -# undef Vector_str NULL +# undef Vector_str nullptr #endif /** \} */ @@ -3276,15 +3380,15 @@ PyObject *Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObjec if (vec_num < 2) { PyErr_SetString(PyExc_RuntimeError, "Vector(): invalid size"); - return NULL; + return nullptr; } - vec_alloc = PyMem_Malloc(vec_num * sizeof(float)); - if (UNLIKELY(vec_alloc == NULL)) { + vec_alloc = static_cast(PyMem_Malloc(vec_num * sizeof(float))); + if (UNLIKELY(vec_alloc == nullptr)) { PyErr_SetString(PyExc_MemoryError, "Vector(): " "problem allocating data"); - return NULL; + return nullptr; } self = BASE_MATH_NEW(VectorObject, vector_Type, base_type); @@ -3292,8 +3396,8 @@ PyObject *Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObjec self->vec = vec_alloc; self->vec_num = vec_num; - /* Initialize callbacks as NULL. */ - self->cb_user = NULL; + /* Initialize callbacks as nullptr. */ + self->cb_user = nullptr; self->cb_type = self->cb_subtype = 0; if (vec) { @@ -3320,15 +3424,15 @@ PyObject *Vector_CreatePyObject_wrap(float *vec, const int vec_num, PyTypeObject if (vec_num < 2) { PyErr_SetString(PyExc_RuntimeError, "Vector(): invalid size"); - return NULL; + return nullptr; } self = BASE_MATH_NEW(VectorObject, vector_Type, base_type); if (self) { self->vec_num = vec_num; - /* Initialize callbacks as NULL. */ - self->cb_user = NULL; + /* Initialize callbacks as nullptr. */ + self->cb_user = nullptr; self->cb_type = self->cb_subtype = 0; self->vec = vec; @@ -3339,7 +3443,7 @@ PyObject *Vector_CreatePyObject_wrap(float *vec, const int vec_num, PyTypeObject PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int vec_num, uchar cb_type, uchar cb_subtype) { - VectorObject *self = (VectorObject *)Vector_CreatePyObject(NULL, vec_num, NULL); + VectorObject *self = (VectorObject *)Vector_CreatePyObject(nullptr, vec_num, nullptr); if (self) { Py_INCREF(cb_user); self->cb_user = cb_user; diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.cc similarity index 89% rename from source/blender/python/mathutils/mathutils_geometry.c rename to source/blender/python/mathutils/mathutils_geometry.cc index d7e4f8133e0..20aa3632b15 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.cc @@ -54,7 +54,7 @@ PyDoc_STRVAR(M_Geometry_intersect_ray_tri_doc, " :type clip: boolean\n" " :return: The point of intersection or None if no intersection is found\n" " :rtype: :class:`mathutils.Vector` or None\n"); -static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_ray_tri(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_ray_tri"; PyObject *py_ray, *py_ray_off, *py_tri[3]; @@ -71,7 +71,7 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject * PyC_ParseBool, &clip)) { - return NULL; + return nullptr; } if (((mathutils_array_parse(dir, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_ray, error_prefix) != @@ -79,14 +79,14 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject * (mathutils_array_parse( orig, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_ray_off, error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } for (i = 0; i < ARRAY_SIZE(tri); i++) { if (mathutils_array_parse( tri[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_tri[i], error_prefix) == -1) { - return NULL; + return nullptr; } } @@ -138,7 +138,7 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject * mul_v3_fl(dir, t); add_v3_v3v3(pvec, orig, dir); - return Vector_CreatePyObject(pvec, 3, NULL); + return Vector_CreatePyObject(pvec, 3, nullptr); } /* Line-Line intersection using algorithm from mathworld.wolfram.com */ @@ -157,7 +157,7 @@ PyDoc_STRVAR(M_Geometry_intersect_line_line_doc, " :arg v4: Second point of the second line\n" " :type v4: :class:`mathutils.Vector`\n" " :rtype: tuple of :class:`mathutils.Vector`'s\n"); -static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_line_line(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_line_line"; PyObject *tuple; @@ -167,7 +167,7 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject int result; if (!PyArg_ParseTuple(args, "OOOO:intersect_line_line", UNPACK4_EX(&, py_lines, ))) { - return NULL; + return nullptr; } if ((((ix_vec_num = mathutils_array_parse( @@ -188,7 +188,7 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject py_lines[3], error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } /* Zero 3rd axis of 2D vectors. */ @@ -212,8 +212,8 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject tuple = PyTuple_New(2); PyTuple_SET_ITEMS(tuple, - Vector_CreatePyObject(i1, ix_vec_num, NULL), - Vector_CreatePyObject(i2, ix_vec_num, NULL)); + Vector_CreatePyObject(i1, ix_vec_num, nullptr), + Vector_CreatePyObject(i2, ix_vec_num, nullptr)); return tuple; } @@ -234,7 +234,7 @@ PyDoc_STRVAR( " :arg radius_b: Radius of the second circle\n" " :type radius_b: float\n" " :rtype: tuple of :class:`mathutils.Vector`'s or None when there is no intersection\n"); -static PyObject *M_Geometry_intersect_sphere_sphere_2d(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_sphere_sphere_2d(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_sphere_sphere_2d"; PyObject *ret; @@ -246,13 +246,13 @@ static PyObject *M_Geometry_intersect_sphere_sphere_2d(PyObject *UNUSED(self), P if (!PyArg_ParseTuple(args, "OfOf:intersect_sphere_sphere_2d", &py_v_a, &rad_a, &py_v_b, &rad_b)) { - return NULL; + return nullptr; } if (((mathutils_array_parse(v_a, 2, 2, py_v_a, error_prefix) != -1) && (mathutils_array_parse(v_b, 2, 2, py_v_b, error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } ret = PyTuple_New(2); @@ -285,7 +285,8 @@ static PyObject *M_Geometry_intersect_sphere_sphere_2d(PyObject *UNUSED(self), P i2[0] = i_cent[0] - h * v_ab[1] / dist; i2[1] = i_cent[1] + h * v_ab[0] / dist; - PyTuple_SET_ITEMS(ret, Vector_CreatePyObject(i1, 2, NULL), Vector_CreatePyObject(i2, 2, NULL)); + PyTuple_SET_ITEMS( + ret, Vector_CreatePyObject(i1, 2, nullptr), Vector_CreatePyObject(i2, 2, nullptr)); } return ret; @@ -297,7 +298,7 @@ PyDoc_STRVAR(M_Geometry_intersect_tri_tri_2d_doc, " Check if two 2D triangles intersect.\n" "\n" " :rtype: bool\n"); -static PyObject *M_Geometry_intersect_tri_tri_2d(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_tri_tri_2d(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_tri_tri_2d"; PyObject *tri_pair_py[2][3]; @@ -312,7 +313,7 @@ static PyObject *M_Geometry_intersect_tri_tri_2d(PyObject *UNUSED(self), PyObjec &tri_pair_py[1][1], &tri_pair_py[1][2])) { - return NULL; + return nullptr; } for (int i = 0; i < 2; i++) { @@ -320,7 +321,7 @@ static PyObject *M_Geometry_intersect_tri_tri_2d(PyObject *UNUSED(self), PyObjec if (mathutils_array_parse( tri_pair[i][j], 2, 2 | MU_ARRAY_SPILL, tri_pair_py[i][j], error_prefix) == -1) { - return NULL; + return nullptr; } } } @@ -337,12 +338,12 @@ PyDoc_STRVAR(M_Geometry_normal_doc, " :arg vectors: Vectors to calculate normals with\n" " :type vectors: sequence of 3 or more 3d vector\n" " :rtype: :class:`mathutils.Vector`\n"); -static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_normal(PyObject * /*self*/, PyObject *args) { float(*coords)[3]; int coords_len; float n[3]; - PyObject *ret = NULL; + PyObject *ret = nullptr; /* use */ if (PyTuple_GET_SIZE(args) == 1) { @@ -352,7 +353,7 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject *args) if ((coords_len = mathutils_array_parse_alloc_v( (float **)&coords, 3 | MU_ARRAY_SPILL, args, "normal")) == -1) { - return NULL; + return nullptr; } if (coords_len < 3) { @@ -361,7 +362,7 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject *args) } normal_poly_v3(n, coords, coords_len); - ret = Vector_CreatePyObject(n, 3, NULL); + ret = Vector_CreatePyObject(n, 3, nullptr); finally: PyMem_Free(coords); @@ -382,7 +383,7 @@ PyDoc_STRVAR(M_Geometry_area_tri_doc, " :arg v3: Point3\n" " :type v3: :class:`mathutils.Vector`\n" " :rtype: float\n"); -static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_area_tri(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "area_tri"; PyObject *py_tri[3]; @@ -390,14 +391,14 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject *args) int len; if (!PyArg_ParseTuple(args, "OOO:area_tri", UNPACK3_EX(&, py_tri, ))) { - return NULL; + return nullptr; } if ((((len = mathutils_array_parse(tri[0], 2, 3, py_tri[0], error_prefix)) != -1) && (mathutils_array_parse(tri[1], len, len, py_tri[1], error_prefix) != -1) && (mathutils_array_parse(tri[2], len, len, py_tri[2], error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } return PyFloat_FromDouble((len == 3 ? area_tri_v3 : area_tri_v2)(UNPACK3(tri))); @@ -417,7 +418,7 @@ PyDoc_STRVAR(M_Geometry_volume_tetrahedron_doc, " :arg v4: Point4\n" " :type v4: :class:`mathutils.Vector`\n" " :rtype: float\n"); -static PyObject *M_Geometry_volume_tetrahedron(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_volume_tetrahedron(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "volume_tetrahedron"; PyObject *py_tet[4]; @@ -425,12 +426,12 @@ static PyObject *M_Geometry_volume_tetrahedron(PyObject *UNUSED(self), PyObject int i; if (!PyArg_ParseTuple(args, "OOOO:volume_tetrahedron", UNPACK4_EX(&, py_tet, ))) { - return NULL; + return nullptr; } for (i = 0; i < ARRAY_SIZE(tet); i++) { if (mathutils_array_parse(tet[i], 3, 3 | MU_ARRAY_SPILL, py_tet[i], error_prefix) == -1) { - return NULL; + return nullptr; } } @@ -456,7 +457,7 @@ PyDoc_STRVAR( " :type lineB_p2: :class:`mathutils.Vector`\n" " :return: The point of intersection or None when not found\n" " :rtype: :class:`mathutils.Vector` or None\n"); -static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_line_line_2d(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_line_line_2d"; PyObject *py_lines[4]; @@ -465,17 +466,17 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj int i; if (!PyArg_ParseTuple(args, "OOOO:intersect_line_line_2d", UNPACK4_EX(&, py_lines, ))) { - return NULL; + return nullptr; } for (i = 0; i < ARRAY_SIZE(lines); i++) { if (mathutils_array_parse(lines[i], 2, 2 | MU_ARRAY_SPILL, py_lines[i], error_prefix) == -1) { - return NULL; + return nullptr; } } if (isect_seg_seg_v2_point(UNPACK4(lines), vi) == 1) { - return Vector_CreatePyObject(vi, 2, NULL); + return Vector_CreatePyObject(vi, 2, nullptr); } Py_RETURN_NONE; @@ -498,7 +499,7 @@ PyDoc_STRVAR( " :type plane_no: :class:`mathutils.Vector`\n" " :return: The point of intersection or None when not found\n" " :rtype: :class:`mathutils.Vector` or None\n"); -static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_line_plane(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_line_plane"; PyObject *py_line_a, *py_line_b, *py_plane_co, *py_plane_no; @@ -515,7 +516,7 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec PyC_ParseBool, &no_flip)) { - return NULL; + return nullptr; } if (((mathutils_array_parse(line_a, 3, 3 | MU_ARRAY_SPILL, py_line_a, error_prefix) != -1) && @@ -524,12 +525,12 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec (mathutils_array_parse(plane_no, 3, 3 | MU_ARRAY_SPILL, py_plane_no, error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } /* TODO: implements no_flip */ if (isect_line_plane_v3(isect, line_a, line_b, plane_co, plane_no) == 1) { - return Vector_CreatePyObject(isect, 3, NULL); + return Vector_CreatePyObject(isect, 3, nullptr); } Py_RETURN_NONE; @@ -552,7 +553,7 @@ PyDoc_STRVAR( " :return: The line of the intersection represented as a point and a vector\n" " :rtype: tuple pair of :class:`mathutils.Vector` or None if the intersection can't be " "calculated\n"); -static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_plane_plane(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_plane_plane"; PyObject *ret, *ret_co, *ret_no; @@ -570,7 +571,7 @@ static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObje &py_plane_b_co, &py_plane_b_no)) { - return NULL; + return nullptr; } if (((mathutils_array_parse(plane_a_co, 3, 3 | MU_ARRAY_SPILL, py_plane_a_co, error_prefix) != @@ -582,7 +583,7 @@ static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObje (mathutils_array_parse(plane_b_no, 3, 3 | MU_ARRAY_SPILL, py_plane_b_no, error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } plane_from_point_normal_v3(plane_a, plane_a_co, plane_a_no); @@ -591,8 +592,8 @@ static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObje if (isect_plane_plane_v3(plane_a, plane_b, isect_co, isect_no)) { normalize_v3(isect_no); - ret_co = Vector_CreatePyObject(isect_co, 3, NULL); - ret_no = Vector_CreatePyObject(isect_no, 3, NULL); + ret_co = Vector_CreatePyObject(isect_co, 3, nullptr); + ret_no = Vector_CreatePyObject(isect_no, 3, nullptr); } else { ret_co = Py_INCREF_RET(Py_None); @@ -622,7 +623,7 @@ PyDoc_STRVAR( " :return: The intersection points as a pair of vectors or None when there is no " "intersection\n" " :rtype: A tuple pair containing :class:`mathutils.Vector` or None\n"); -static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_line_sphere(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_line_sphere"; PyObject *py_line_a, *py_line_b, *py_sphere_co; @@ -642,7 +643,7 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje PyC_ParseBool, &clip)) { - return NULL; + return nullptr; } if (((mathutils_array_parse(line_a, 3, 3 | MU_ARRAY_SPILL, py_line_a, error_prefix) != -1) && @@ -650,7 +651,7 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje (mathutils_array_parse(sphere_co, 3, 3 | MU_ARRAY_SPILL, py_sphere_co, error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } bool use_a = true; @@ -687,8 +688,8 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje } PyTuple_SET_ITEMS(ret, - use_a ? Vector_CreatePyObject(isect_a, 3, NULL) : Py_INCREF_RET(Py_None), - use_b ? Vector_CreatePyObject(isect_b, 3, NULL) : Py_INCREF_RET(Py_None)); + use_a ? Vector_CreatePyObject(isect_a, 3, nullptr) : Py_INCREF_RET(Py_None), + use_b ? Vector_CreatePyObject(isect_b, 3, nullptr) : Py_INCREF_RET(Py_None)); return ret; } @@ -712,7 +713,7 @@ PyDoc_STRVAR( " :return: The intersection points as a pair of vectors or None when there is no " "intersection\n" " :rtype: A tuple pair containing :class:`mathutils.Vector` or None\n"); -static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_line_sphere_2d"; PyObject *py_line_a, *py_line_b, *py_sphere_co; @@ -732,7 +733,7 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO PyC_ParseBool, &clip)) { - return NULL; + return nullptr; } if (((mathutils_array_parse(line_a, 2, 2 | MU_ARRAY_SPILL, py_line_a, error_prefix) != -1) && @@ -740,7 +741,7 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO (mathutils_array_parse(sphere_co, 2, 2 | MU_ARRAY_SPILL, py_sphere_co, error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } bool use_a = true; @@ -777,8 +778,8 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO } PyTuple_SET_ITEMS(ret, - use_a ? Vector_CreatePyObject(isect_a, 2, NULL) : Py_INCREF_RET(Py_None), - use_b ? Vector_CreatePyObject(isect_b, 2, NULL) : Py_INCREF_RET(Py_None)); + use_a ? Vector_CreatePyObject(isect_a, 2, nullptr) : Py_INCREF_RET(Py_None), + use_b ? Vector_CreatePyObject(isect_b, 2, nullptr) : Py_INCREF_RET(Py_None)); return ret; } @@ -797,7 +798,7 @@ PyDoc_STRVAR( " :arg line_p1: Second point of the line\n" " :type line_p1: :class:`mathutils.Vector`\n" " :rtype: (:class:`mathutils.Vector`, float)\n"); -static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_point_line(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_point_line"; PyObject *py_pt, *py_line_a, *py_line_b; @@ -807,7 +808,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec int pt_num = 2; if (!PyArg_ParseTuple(args, "OOO:intersect_point_line", &py_pt, &py_line_a, &py_line_b)) { - return NULL; + return nullptr; } /* accept 2d verts */ @@ -818,14 +819,15 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec (mathutils_array_parse( line_b, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_line_b, error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } /* do the calculation */ lambda = closest_to_line_v3(pt_out, pt, line_a, line_b); ret = PyTuple_New(2); - PyTuple_SET_ITEMS(ret, Vector_CreatePyObject(pt_out, pt_num, NULL), PyFloat_FromDouble(lambda)); + PyTuple_SET_ITEMS( + ret, Vector_CreatePyObject(pt_out, pt_num, nullptr), PyFloat_FromDouble(lambda)); return ret; } @@ -845,7 +847,7 @@ PyDoc_STRVAR(M_Geometry_intersect_point_tri_doc, " :type tri_p3: :class:`mathutils.Vector`\n" " :return: Point on the triangles plane or None if its outside the triangle\n" " :rtype: :class:`mathutils.Vector` or None\n"); -static PyObject *M_Geometry_intersect_point_tri(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_point_tri(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_point_tri"; PyObject *py_pt, *py_tri[3]; @@ -854,23 +856,23 @@ static PyObject *M_Geometry_intersect_point_tri(PyObject *UNUSED(self), PyObject int i; if (!PyArg_ParseTuple(args, "OOOO:intersect_point_tri", &py_pt, UNPACK3_EX(&, py_tri, ))) { - return NULL; + return nullptr; } if (mathutils_array_parse(pt, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_pt, error_prefix) == -1) { - return NULL; + return nullptr; } for (i = 0; i < ARRAY_SIZE(tri); i++) { if (mathutils_array_parse( tri[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_tri[i], error_prefix) == -1) { - return NULL; + return nullptr; } } if (isect_point_tri_v3(pt, UNPACK3(tri), vi)) { - return Vector_CreatePyObject(vi, 3, NULL); + return Vector_CreatePyObject(vi, 3, nullptr); } Py_RETURN_NONE; @@ -891,7 +893,7 @@ PyDoc_STRVAR(M_Geometry_closest_point_on_tri_doc, " :type tri_p3: :class:`mathutils.Vector`\n" " :return: The closest point of the triangle.\n" " :rtype: :class:`mathutils.Vector`\n"); -static PyObject *M_Geometry_closest_point_on_tri(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_closest_point_on_tri(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "closest_point_on_tri"; PyObject *py_pt, *py_tri[3]; @@ -900,24 +902,24 @@ static PyObject *M_Geometry_closest_point_on_tri(PyObject *UNUSED(self), PyObjec int i; if (!PyArg_ParseTuple(args, "OOOO:closest_point_on_tri", &py_pt, UNPACK3_EX(&, py_tri, ))) { - return NULL; + return nullptr; } if (mathutils_array_parse(pt, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_pt, error_prefix) == -1) { - return NULL; + return nullptr; } for (i = 0; i < ARRAY_SIZE(tri); i++) { if (mathutils_array_parse( tri[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_tri[i], error_prefix) == -1) { - return NULL; + return nullptr; } } closest_on_tri_to_point_v3(vi, pt, UNPACK3(tri)); - return Vector_CreatePyObject(vi, 3, NULL); + return Vector_CreatePyObject(vi, 3, nullptr); } PyDoc_STRVAR( @@ -936,7 +938,7 @@ PyDoc_STRVAR( " :arg tri_p3: Third point of the triangle\n" " :type tri_p3: :class:`mathutils.Vector`\n" " :rtype: int\n"); -static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_point_tri_2d(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_point_tri_2d"; PyObject *py_pt, *py_tri[3]; @@ -944,15 +946,15 @@ static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObj int i; if (!PyArg_ParseTuple(args, "OOOO:intersect_point_tri_2d", &py_pt, UNPACK3_EX(&, py_tri, ))) { - return NULL; + return nullptr; } if (mathutils_array_parse(pt, 2, 2 | MU_ARRAY_SPILL, py_pt, error_prefix) == -1) { - return NULL; + return nullptr; } for (i = 0; i < ARRAY_SIZE(tri); i++) { if (mathutils_array_parse(tri[i], 2, 2 | MU_ARRAY_SPILL, py_tri[i], error_prefix) == -1) { - return NULL; + return nullptr; } } @@ -979,7 +981,7 @@ PyDoc_STRVAR(M_Geometry_intersect_point_quad_2d_doc, " :arg quad_p4: Fourth point of the quad\n" " :type quad_p4: :class:`mathutils.Vector`\n" " :rtype: int\n"); -static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_intersect_point_quad_2d(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "intersect_point_quad_2d"; PyObject *py_pt, *py_quad[4]; @@ -987,15 +989,15 @@ static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyOb int i; if (!PyArg_ParseTuple(args, "OOOOO:intersect_point_quad_2d", &py_pt, UNPACK4_EX(&, py_quad, ))) { - return NULL; + return nullptr; } if (mathutils_array_parse(pt, 2, 2 | MU_ARRAY_SPILL, py_pt, error_prefix) == -1) { - return NULL; + return nullptr; } for (i = 0; i < ARRAY_SIZE(quad); i++) { if (mathutils_array_parse(quad[i], 2, 2 | MU_ARRAY_SPILL, py_quad[i], error_prefix) == -1) { - return NULL; + return nullptr; } } @@ -1015,7 +1017,7 @@ PyDoc_STRVAR(M_Geometry_distance_point_to_plane_doc, " :arg plane_no: The direction the plane is facing\n" " :type plane_no: :class:`mathutils.Vector`\n" " :rtype: float\n"); -static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_distance_point_to_plane(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "distance_point_to_plane"; PyObject *py_pt, *py_plane_co, *py_plane_no; @@ -1023,7 +1025,7 @@ static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyOb float plane[4]; if (!PyArg_ParseTuple(args, "OOO:distance_point_to_plane", &py_pt, &py_plane_co, &py_plane_no)) { - return NULL; + return nullptr; } if (((mathutils_array_parse(pt, 3, 3 | MU_ARRAY_SPILL, py_pt, error_prefix) != -1) && @@ -1031,7 +1033,7 @@ static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyOb (mathutils_array_parse(plane_no, 3, 3 | MU_ARRAY_SPILL, py_plane_no, error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } plane_from_point_normal_v3(plane, plane_co, plane_no); @@ -1060,7 +1062,7 @@ PyDoc_STRVAR( " :type tri_b3: :class:`mathutils.Vector`\n" " :return: The transformed point\n" " :rtype: :class:`mathutils.Vector`'s\n"); -static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_barycentric_transform(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "barycentric_transform"; PyObject *py_pt_src, *py_tri_src[3], *py_tri_dst[3]; @@ -1073,11 +1075,11 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje UNPACK3_EX(&, py_tri_src, ), UNPACK3_EX(&, py_tri_dst, ))) { - return NULL; + return nullptr; } if (mathutils_array_parse(pt_src, 3, 3 | MU_ARRAY_SPILL, py_pt_src, error_prefix) == -1) { - return NULL; + return nullptr; } for (i = 0; i < ARRAY_SIZE(tri_src); i++) { if (((mathutils_array_parse(tri_src[i], 3, 3 | MU_ARRAY_SPILL, py_tri_src[i], error_prefix) != @@ -1085,13 +1087,13 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje (mathutils_array_parse(tri_dst[i], 3, 3 | MU_ARRAY_SPILL, py_tri_dst[i], error_prefix) != -1)) == 0) { - return NULL; + return nullptr; } } transform_point_by_tri_v3(pt_dst, pt_src, UNPACK3(tri_dst), UNPACK3(tri_src)); - return Vector_CreatePyObject(pt_dst, 3, NULL); + return Vector_CreatePyObject(pt_dst, 3, nullptr); } struct PointsInPlanes_UserData { @@ -1101,8 +1103,8 @@ struct PointsInPlanes_UserData { static void points_in_planes_fn(const float co[3], int i, int j, int k, void *user_data_p) { - struct PointsInPlanes_UserData *user_data = user_data_p; - PyList_APPEND(user_data->py_verts, Vector_CreatePyObject(co, 3, NULL)); + struct PointsInPlanes_UserData *user_data = static_cast(user_data_p); + PyList_APPEND(user_data->py_verts, Vector_CreatePyObject(co, 3, nullptr)); user_data->planes_used[i] = true; user_data->planes_used[j] = true; user_data->planes_used[k] = true; @@ -1119,28 +1121,27 @@ PyDoc_STRVAR(M_Geometry_points_in_planes_doc, " :return: two lists, once containing the vertices inside the planes, another " "containing the plane indices used\n" " :rtype: pair of lists\n"); -static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_points_in_planes(PyObject * /*self*/, PyObject *args) { PyObject *py_planes; float(*planes)[4]; uint planes_len; if (!PyArg_ParseTuple(args, "O:points_in_planes", &py_planes)) { - return NULL; + return nullptr; } if ((planes_len = mathutils_array_parse_alloc_v( (float **)&planes, 4, py_planes, "points_in_planes")) == -1) { - return NULL; + return nullptr; } /* NOTE: this could be refactored into plain C easy - py bits are noted. */ - struct PointsInPlanes_UserData user_data = { - .py_verts = PyList_New(0), - .planes_used = PyMem_Malloc(sizeof(char) * planes_len), - }; + PointsInPlanes_UserData user_data{}; + user_data.py_verts = PyList_New(0); + user_data.planes_used = static_cast(PyMem_Malloc(sizeof(char) * planes_len)); /* python */ PyObject *py_plane_index = PyList_New(0); @@ -1190,7 +1191,7 @@ PyDoc_STRVAR(M_Geometry_interpolate_bezier_doc, " :type resolution: int\n" " :return: The interpolated points\n" " :rtype: list of :class:`mathutils.Vector`'s\n"); -static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_interpolate_bezier(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "interpolate_bezier"; PyObject *py_data[4]; @@ -1202,7 +1203,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject PyObject *list; if (!PyArg_ParseTuple(args, "OOOOi:interpolate_bezier", UNPACK4_EX(&, py_data, ), &resolu)) { - return NULL; + return nullptr; } for (i = 0; i < 4; i++) { @@ -1210,17 +1211,17 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject if ((dims_tmp = mathutils_array_parse( data[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_data[i], error_prefix)) == -1) { - return NULL; + return nullptr; } dims = max_ii(dims, dims_tmp); } if (resolu <= 1) { PyErr_SetString(PyExc_ValueError, "resolution must be 2 or over"); - return NULL; + return nullptr; } - coord_array = MEM_callocN(dims * (resolu) * sizeof(float), error_prefix); + coord_array = static_cast(MEM_callocN(dims * (resolu) * sizeof(float), error_prefix)); for (i = 0; i < dims; i++) { BKE_curve_forward_diff_bezier( UNPACK4_EX(, data, [i]), coord_array + i, resolu - 1, sizeof(float) * dims); @@ -1229,7 +1230,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject list = PyList_New(resolu); fp = coord_array; for (i = 0; i < resolu; i++, fp = fp + dims) { - PyList_SET_ITEM(list, i, Vector_CreatePyObject(fp, dims, NULL)); + PyList_SET_ITEM(list, i, Vector_CreatePyObject(fp, dims, nullptr)); } MEM_freeN(coord_array); return list; @@ -1245,7 +1246,7 @@ PyDoc_STRVAR(M_Geometry_tessellate_polygon_doc, " :arg veclist_list: list of polylines\n" " :rtype: list\n"); /* PolyFill function, uses Blenders scan-fill to fill multiple poly lines. */ -static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject *polyLineSeq) +static PyObject *M_Geometry_tessellate_polygon(PyObject * /*self*/, PyObject *polyLineSeq) { PyObject *tri_list; /* Return this list of tri's */ PyObject *polyLine, *polyVec; @@ -1254,14 +1255,14 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject bool is_2d = true; /* Display #ListBase. */ - ListBase dispbase = {NULL, NULL}; + ListBase dispbase = {nullptr, nullptr}; DispList *dl; float *fp; /* Pointer to the array of malloced dl->verts to set the points from the vectors. */ int totpoints = 0; if (!PySequence_Check(polyLineSeq)) { PyErr_SetString(PyExc_TypeError, "expected a sequence of poly lines"); - return NULL; + return nullptr; } len_polylines = PySequence_Size(polyLineSeq); @@ -1273,20 +1274,21 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject Py_XDECREF(polyLine); /* May be null so use #Py_XDECREF. */ PyErr_SetString(PyExc_TypeError, "One or more of the polylines is not a sequence of mathutils.Vector's"); - return NULL; + return nullptr; } len_polypoints = PySequence_Size(polyLine); if (len_polypoints > 0) { /* don't bother adding edges as polylines */ - dl = MEM_callocN(sizeof(DispList), "poly disp"); + dl = static_cast(MEM_callocN(sizeof(DispList), "poly disp")); BLI_addtail(&dispbase, dl); dl->type = DL_INDEX3; dl->nr = len_polypoints; dl->type = DL_POLY; dl->parts = 1; /* no faces, 1 edge loop */ dl->col = 0; /* no material */ - dl->verts = fp = MEM_mallocN(sizeof(float[3]) * len_polypoints, "dl verts"); - dl->index = MEM_callocN(sizeof(int[3]) * len_polypoints, "dl index"); + dl->verts = fp = static_cast( + MEM_mallocN(sizeof(float[3]) * len_polypoints, "dl verts")); + dl->index = static_cast(MEM_callocN(sizeof(int[3]) * len_polypoints, "dl index")); for (int index = 0; index < len_polypoints; index++, fp += 3) { polyVec = PySequence_GetItem(polyLine, index); @@ -1312,26 +1314,27 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject if (list_parse_error) { BKE_displist_free(&dispbase); /* possible some dl was allocated */ - return NULL; + return nullptr; } if (totpoints) { /* now make the list to return */ - BKE_displist_fill(&dispbase, &dispbase, is_2d ? ((const float[3]){0, 0, -1}) : NULL, false); + float down_vec[3] = {0, 0, -1}; + BKE_displist_fill(&dispbase, &dispbase, is_2d ? down_vec : nullptr, false); /* The faces are stored in a new DisplayList * that's added to the head of the #ListBase. */ - dl = dispbase.first; + dl = static_cast(dispbase.first); tri_list = PyList_New(dl->parts); if (!tri_list) { BKE_displist_free(&dispbase); PyErr_SetString(PyExc_RuntimeError, "failed to make a new list"); - return NULL; + return nullptr; } int *dl_face = dl->index; for (int index = 0; index < dl->parts; index++) { - PyList_SET_ITEM(tri_list, index, PyC_Tuple_Pack_I32(dl_face[0], dl_face[1], dl_face[2])); + PyList_SET_ITEM(tri_list, index, PyC_Tuple_Pack_I32({dl_face[0], dl_face[1], dl_face[2]})); dl_face += 3; } BKE_displist_free(&dispbase); @@ -1359,7 +1362,7 @@ static int boxPack_FromPyObject(PyObject *value, BoxPack **r_boxarray) len = PyList_GET_SIZE(value); - boxarray = MEM_mallocN(sizeof(BoxPack) * len, __func__); + boxarray = static_cast(MEM_mallocN(sizeof(BoxPack) * len, __func__)); for (i = 0; i < len; i++) { list_item = PyList_GET_ITEM(value, i); @@ -1419,7 +1422,7 @@ PyDoc_STRVAR(M_Geometry_box_pack_2d_doc, " :type boxes: list\n" " :return: the width and height of the packed bounding box\n" " :rtype: tuple, pair of floats\n"); -static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlist) +static PyObject *M_Geometry_box_pack_2d(PyObject * /*self*/, PyObject *boxlist) { float tot_width = 0.0f, tot_height = 0.0f; Py_ssize_t len; @@ -1428,14 +1431,14 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis if (!PyList_Check(boxlist)) { PyErr_SetString(PyExc_TypeError, "expected a list of boxes [[x, y, w, h], ... ]"); - return NULL; + return nullptr; } len = PyList_GET_SIZE(boxlist); if (len) { - BoxPack *boxarray = NULL; + BoxPack *boxarray = nullptr; if (boxPack_FromPyObject(boxlist, &boxarray) == -1) { - return NULL; /* exception set */ + return nullptr; /* exception set */ } const bool sort_boxes = true; /* Caution: BLI_box_pack_2d sorting is non-deterministic. */ @@ -1460,7 +1463,7 @@ PyDoc_STRVAR(M_Geometry_box_fit_2d_doc, " :type points: list\n" " :return: angle\n" " :rtype: float\n"); -static PyObject *M_Geometry_box_fit_2d(PyObject *UNUSED(self), PyObject *pointlist) +static PyObject *M_Geometry_box_fit_2d(PyObject * /*self*/, PyObject *pointlist) { float(*points)[2]; Py_ssize_t len; @@ -1469,7 +1472,7 @@ static PyObject *M_Geometry_box_fit_2d(PyObject *UNUSED(self), PyObject *pointli len = mathutils_array_parse_alloc_v(((float **)&points), 2, pointlist, "box_fit_2d"); if (len == -1) { - return NULL; + return nullptr; } if (len) { @@ -1491,7 +1494,7 @@ PyDoc_STRVAR(M_Geometry_convex_hull_2d_doc, " :type points: list\n" " :return: a list of indices\n" " :rtype: list of ints\n"); -static PyObject *M_Geometry_convex_hull_2d(PyObject *UNUSED(self), PyObject *pointlist) +static PyObject *M_Geometry_convex_hull_2d(PyObject * /*self*/, PyObject *pointlist) { float(*points)[2]; Py_ssize_t len; @@ -1500,14 +1503,14 @@ static PyObject *M_Geometry_convex_hull_2d(PyObject *UNUSED(self), PyObject *poi len = mathutils_array_parse_alloc_v(((float **)&points), 2, pointlist, "convex_hull_2d"); if (len == -1) { - return NULL; + return nullptr; } if (len) { int *index_map; Py_ssize_t len_ret, i; - index_map = MEM_mallocN(sizeof(*index_map) * len, __func__); + index_map = static_cast(MEM_mallocN(sizeof(*index_map) * len, __func__)); /* Non Python function */ len_ret = BLI_convexhull_2d(points, len, index_map); @@ -1540,7 +1543,7 @@ static PyObject *list_of_lists_from_arrays(const int *array, PyObject *ret, *sublist; int i, j, sublist_len, sublist_start, val; - if (array == NULL) { + if (array == nullptr) { return PyList_New(0); } ret = PyList_New(toplevel_len); @@ -1600,28 +1603,28 @@ PyDoc_STRVAR( "list of list of int, " "list of list of int)\n" "\n"); -static PyObject *M_Geometry_delaunay_2d_cdt(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Geometry_delaunay_2d_cdt(PyObject * /*self*/, PyObject *args) { const char *error_prefix = "delaunay_2d_cdt"; PyObject *vert_coords, *edges, *faces, *item; int output_type; float epsilon; bool need_ids = true; - float(*in_coords)[2] = NULL; - int(*in_edges)[2] = NULL; - int *in_faces = NULL; - int *in_faces_start_table = NULL; - int *in_faces_len_table = NULL; + float(*in_coords)[2] = nullptr; + int(*in_edges)[2] = nullptr; + int *in_faces = nullptr; + int *in_faces_start_table = nullptr; + int *in_faces_len_table = nullptr; Py_ssize_t vert_coords_len, edges_len, faces_len; CDT_input in; - CDT_result *res = NULL; - PyObject *out_vert_coords = NULL; - PyObject *out_edges = NULL; - PyObject *out_faces = NULL; - PyObject *out_orig_verts = NULL; - PyObject *out_orig_edges = NULL; - PyObject *out_orig_faces = NULL; - PyObject *ret_value = NULL; + CDT_result *res = nullptr; + PyObject *out_vert_coords = nullptr; + PyObject *out_edges = nullptr; + PyObject *out_faces = nullptr; + PyObject *out_orig_verts = nullptr; + PyObject *out_orig_edges = nullptr; + PyObject *out_orig_faces = nullptr; + PyObject *ret_value = nullptr; int i; if (!PyArg_ParseTuple(args, @@ -1633,13 +1636,13 @@ static PyObject *M_Geometry_delaunay_2d_cdt(PyObject *UNUSED(self), PyObject *ar &epsilon, &need_ids)) { - return NULL; + return nullptr; } vert_coords_len = mathutils_array_parse_alloc_v( (float **)&in_coords, 2, vert_coords, error_prefix); if (vert_coords_len == -1) { - return NULL; + return nullptr; } edges_len = mathutils_array_parse_alloc_vi((int **)&in_edges, 2, edges, error_prefix); @@ -1664,14 +1667,14 @@ static PyObject *M_Geometry_delaunay_2d_cdt(PyObject *UNUSED(self), PyObject *ar in.epsilon = epsilon; in.need_ids = need_ids; - res = BLI_delaunay_2d_cdt_calc(&in, output_type); + res = BLI_delaunay_2d_cdt_calc(&in, CDT_output_type(output_type)); ret_value = PyTuple_New(6); out_vert_coords = PyList_New(res->verts_len); for (i = 0; i < res->verts_len; i++) { - item = Vector_CreatePyObject(res->vert_coords[i], 2, NULL); - if (item == NULL) { + item = Vector_CreatePyObject(res->vert_coords[i], 2, nullptr); + if (item == nullptr) { Py_DECREF(ret_value); Py_DECREF(out_vert_coords); goto exit_cdt; @@ -1706,19 +1709,19 @@ static PyObject *M_Geometry_delaunay_2d_cdt(PyObject *UNUSED(self), PyObject *ar PyTuple_SET_ITEM(ret_value, 5, out_orig_faces); exit_cdt: - if (in_coords != NULL) { + if (in_coords != nullptr) { PyMem_Free(in_coords); } - if (in_edges != NULL) { + if (in_edges != nullptr) { PyMem_Free(in_edges); } - if (in_faces != NULL) { + if (in_faces != nullptr) { PyMem_Free(in_faces); } - if (in_faces_start_table != NULL) { + if (in_faces_start_table != nullptr) { PyMem_Free(in_faces_start_table); } - if (in_faces_len_table != NULL) { + if (in_faces_len_table != nullptr) { PyMem_Free(in_faces_len_table); } if (res) { @@ -1824,7 +1827,7 @@ static PyMethodDef M_Geometry_methods[] = { {"box_fit_2d", (PyCFunction)M_Geometry_box_fit_2d, METH_O, M_Geometry_box_fit_2d_doc}, {"box_pack_2d", (PyCFunction)M_Geometry_box_pack_2d, METH_O, M_Geometry_box_pack_2d_doc}, #endif - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyModuleDef M_Geometry_module_def = { @@ -1833,10 +1836,10 @@ static PyModuleDef M_Geometry_module_def = { /*m_doc*/ M_Geometry_doc, /*m_size*/ 0, /*m_methods*/ M_Geometry_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; /*----------------------------MODULE INIT-------------------------*/ diff --git a/source/blender/python/mathutils/mathutils_interpolate.c b/source/blender/python/mathutils/mathutils_interpolate.cc similarity index 86% rename from source/blender/python/mathutils/mathutils_interpolate.c rename to source/blender/python/mathutils/mathutils_interpolate.cc index 63642251c94..ee6a6cbb5b2 100644 --- a/source/blender/python/mathutils/mathutils_interpolate.c +++ b/source/blender/python/mathutils/mathutils_interpolate.cc @@ -33,7 +33,7 @@ PyDoc_STRVAR(M_Interpolate_poly_3d_calc_doc, " :arg veclist: list of vectors\n" " :arg pt: point" " :rtype: list of per-vector weights\n"); -static PyObject *M_Interpolate_poly_3d_calc(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Interpolate_poly_3d_calc(PyObject * /*self*/, PyObject *args) { float fp[3]; float(*vecs)[3]; @@ -43,22 +43,22 @@ static PyObject *M_Interpolate_poly_3d_calc(PyObject *UNUSED(self), PyObject *ar int i; if (!PyArg_ParseTuple(args, "OO:poly_3d_calc", &veclist, &point)) { - return NULL; + return nullptr; } if (mathutils_array_parse( fp, 2, 3 | MU_ARRAY_ZERO, point, "pt must be a 2-3 dimensional vector") == -1) { - return NULL; + return nullptr; } len = mathutils_array_parse_alloc_v(((float **)&vecs), 3, veclist, __func__); if (len == -1) { - return NULL; + return nullptr; } if (len) { - float *weights = MEM_mallocN(sizeof(float) * len, __func__); + float *weights = static_cast(MEM_mallocN(sizeof(float) * len, __func__)); interp_weights_poly_v3(weights, vecs, len, fp); @@ -87,7 +87,7 @@ static PyMethodDef M_Interpolate_methods[] = { METH_VARARGS, M_Interpolate_poly_3d_calc_doc}, #endif - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyModuleDef M_Interpolate_module_def = { @@ -96,10 +96,10 @@ static PyModuleDef M_Interpolate_module_def = { /*m_doc*/ M_Interpolate_doc, /*m_size*/ 0, /*m_methods*/ M_Interpolate_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; /*----------------------------MODULE INIT-------------------------*/ diff --git a/source/blender/python/mathutils/mathutils_kdtree.c b/source/blender/python/mathutils/mathutils_kdtree.cc similarity index 82% rename from source/blender/python/mathutils/mathutils_kdtree.c rename to source/blender/python/mathutils/mathutils_kdtree.cc index 100a52558a1..19bee981e15 100644 --- a/source/blender/python/mathutils/mathutils_kdtree.c +++ b/source/blender/python/mathutils/mathutils_kdtree.cc @@ -24,13 +24,13 @@ #include "BLI_strict_flags.h" -typedef struct { +struct PyKDTree { PyObject_HEAD KDTree_3d *obj; uint maxsize; uint count; uint count_balance; /* size when we last balanced */ -} PyKDTree; +}; /* -------------------------------------------------------------------- */ /* Utility helper functions */ @@ -41,7 +41,7 @@ static void kdtree_nearest_to_py_tuple(const KDTreeNearest_3d *nearest, PyObject BLI_assert(PyTuple_GET_SIZE(py_retval) == 3); PyTuple_SET_ITEMS(py_retval, - Vector_CreatePyObject(nearest->co, 3, NULL), + Vector_CreatePyObject(nearest->co, 3, nullptr), PyLong_FromLong(nearest->index), PyFloat_FromDouble(nearest->dist)); } @@ -82,7 +82,7 @@ static PyObject *kdtree_nearest_to_py_and_check(const KDTreeNearest_3d *nearest) static int PyKDTree__tp_init(PyKDTree *self, PyObject *args, PyObject *kwargs) { uint maxsize; - const char *keywords[] = {"size", NULL}; + const char *keywords[] = {"size", nullptr}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "I:KDTree", (char **)keywords, &maxsize)) { return -1; @@ -121,24 +121,24 @@ static PyObject *py_kdtree_insert(PyKDTree *self, PyObject *args, PyObject *kwar PyObject *py_co; float co[3]; int index; - const char *keywords[] = {"co", "index", NULL}; + const char *keywords[] = {"co", "index", nullptr}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi:insert", (char **)keywords, &py_co, &index)) { - return NULL; + return nullptr; } if (mathutils_array_parse(co, 3, 3, py_co, "insert: invalid 'co' arg") == -1) { - return NULL; + return nullptr; } if (index < 0) { PyErr_SetString(PyExc_ValueError, "negative index given"); - return NULL; + return nullptr; } if (self->count >= self->maxsize) { PyErr_SetString(PyExc_RuntimeError, "Trying to insert more items than KDTree has room for"); - return NULL; + return nullptr; } BLI_kdtree_3d_insert(self->obj, index, co); @@ -171,7 +171,7 @@ static int py_find_nearest_cb(void *user_data, int index, const float co[3], flo { UNUSED_VARS(co, dist_sq); - struct PyKDTree_NearestData *data = user_data; + struct PyKDTree_NearestData *data = static_cast(user_data); PyObject *py_args = PyTuple_New(1); PyTuple_SET_ITEM(py_args, 0, PyLong_FromLong(index)); @@ -205,28 +205,28 @@ PyDoc_STRVAR(py_kdtree_find_doc, " :rtype: :class:`tuple`\n"); static PyObject *py_kdtree_find(PyKDTree *self, PyObject *args, PyObject *kwargs) { - PyObject *py_co, *py_filter = NULL; + PyObject *py_co, *py_filter = nullptr; float co[3]; KDTreeNearest_3d nearest; - const char *keywords[] = {"co", "filter", NULL}; + const char *keywords[] = {"co", "filter", nullptr}; if (!PyArg_ParseTupleAndKeywords( args, kwargs, "O|$O:find", (char **)keywords, &py_co, &py_filter)) { - return NULL; + return nullptr; } if (mathutils_array_parse(co, 3, 3, py_co, "find: invalid 'co' arg") == -1) { - return NULL; + return nullptr; } if (self->count != self->count_balance) { PyErr_SetString(PyExc_RuntimeError, "KDTree must be balanced before calling find()"); - return NULL; + return nullptr; } nearest.index = -1; - if (py_filter == NULL) { + if (py_filter == nullptr) { BLI_kdtree_3d_find_nearest(self->obj, co, &nearest); } else { @@ -238,7 +238,7 @@ static PyObject *py_kdtree_find(PyKDTree *self, PyObject *args, PyObject *kwargs BLI_kdtree_3d_find_nearest_cb(self->obj, co, py_find_nearest_cb, &data, &nearest); if (data.is_error) { - return NULL; + return nullptr; } } @@ -264,27 +264,27 @@ static PyObject *py_kdtree_find_n(PyKDTree *self, PyObject *args, PyObject *kwar KDTreeNearest_3d *nearest; uint n; int i, found; - const char *keywords[] = {"co", "n", NULL}; + const char *keywords[] = {"co", "n", nullptr}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OI:find_n", (char **)keywords, &py_co, &n)) { - return NULL; + return nullptr; } if (mathutils_array_parse(co, 3, 3, py_co, "find_n: invalid 'co' arg") == -1) { - return NULL; + return nullptr; } if (UINT_IS_NEG(n)) { PyErr_SetString(PyExc_RuntimeError, "negative 'n' given"); - return NULL; + return nullptr; } if (self->count != self->count_balance) { PyErr_SetString(PyExc_RuntimeError, "KDTree must be balanced before calling find_n()"); - return NULL; + return nullptr; } - nearest = MEM_mallocN(sizeof(KDTreeNearest_3d) * n, __func__); + nearest = static_cast(MEM_mallocN(sizeof(KDTreeNearest_3d) * n, __func__)); found = BLI_kdtree_3d_find_nearest_n(self->obj, co, nearest, n); @@ -315,30 +315,30 @@ static PyObject *py_kdtree_find_range(PyKDTree *self, PyObject *args, PyObject * PyObject *py_list; PyObject *py_co; float co[3]; - KDTreeNearest_3d *nearest = NULL; + KDTreeNearest_3d *nearest = nullptr; float radius; int i, found; - const char *keywords[] = {"co", "radius", NULL}; + const char *keywords[] = {"co", "radius", nullptr}; if (!PyArg_ParseTupleAndKeywords( args, kwargs, "Of:find_range", (char **)keywords, &py_co, &radius)) { - return NULL; + return nullptr; } if (mathutils_array_parse(co, 3, 3, py_co, "find_range: invalid 'co' arg") == -1) { - return NULL; + return nullptr; } if (radius < 0.0f) { PyErr_SetString(PyExc_RuntimeError, "negative radius given"); - return NULL; + return nullptr; } if (self->count != self->count_balance) { PyErr_SetString(PyExc_RuntimeError, "KDTree must be balanced before calling find_range()"); - return NULL; + return nullptr; } found = BLI_kdtree_3d_range_search(self->obj, co, &nearest, radius); @@ -365,7 +365,7 @@ static PyMethodDef PyKDTree_methods[] = { (PyCFunction)py_kdtree_find_range, METH_VARARGS | METH_KEYWORDS, py_kdtree_find_range_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; PyDoc_STRVAR(py_KDtree_doc, @@ -377,55 +377,55 @@ PyDoc_STRVAR(py_KDtree_doc, "methods.\n"); PyTypeObject PyKDTree_Type = { - /*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0) + /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) /*tp_name*/ "KDTree", /*tp_basicsize*/ sizeof(PyKDTree), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)PyKDTree__tp_dealloc, /*tp_vectorcall_offset*/ 0, - /*tp_getattr*/ NULL, - /*tp_setattr*/ NULL, - /*tp_as_async*/ NULL, - /*tp_repr*/ NULL, - /*tp_as_number*/ NULL, - /*tp_as_sequence*/ NULL, - /*tp_as_mapping*/ NULL, - /*tp_hash*/ NULL, - /*tp_call*/ NULL, - /*tp_str*/ NULL, - /*tp_getattro*/ NULL, - /*tp_setattro*/ NULL, - /*tp_as_buffer*/ NULL, + /*tp_getattr*/ nullptr, + /*tp_setattr*/ nullptr, + /*tp_as_async*/ nullptr, + /*tp_repr*/ nullptr, + /*tp_as_number*/ nullptr, + /*tp_as_sequence*/ nullptr, + /*tp_as_mapping*/ nullptr, + /*tp_hash*/ nullptr, + /*tp_call*/ nullptr, + /*tp_str*/ nullptr, + /*tp_getattro*/ nullptr, + /*tp_setattro*/ nullptr, + /*tp_as_buffer*/ nullptr, /*tp_flags*/ Py_TPFLAGS_DEFAULT, /*tp_doc*/ py_KDtree_doc, - /*tp_traverse*/ NULL, - /*tp_clear*/ NULL, - /*tp_richcompare*/ NULL, + /*tp_traverse*/ nullptr, + /*tp_clear*/ nullptr, + /*tp_richcompare*/ nullptr, /*tp_weaklistoffset*/ 0, - /*tp_iter*/ NULL, - /*tp_iternext*/ NULL, + /*tp_iter*/ nullptr, + /*tp_iternext*/ nullptr, /*tp_methods*/ (PyMethodDef *)PyKDTree_methods, - /*tp_members*/ NULL, - /*tp_getset*/ NULL, - /*tp_base*/ NULL, - /*tp_dict*/ NULL, - /*tp_descr_get*/ NULL, - /*tp_descr_set*/ NULL, + /*tp_members*/ nullptr, + /*tp_getset*/ nullptr, + /*tp_base*/ nullptr, + /*tp_dict*/ nullptr, + /*tp_descr_get*/ nullptr, + /*tp_descr_set*/ nullptr, /*tp_dictoffset*/ 0, /*tp_init*/ (initproc)PyKDTree__tp_init, /*tp_alloc*/ (allocfunc)PyType_GenericAlloc, /*tp_new*/ (newfunc)PyType_GenericNew, /*tp_free*/ (freefunc)0, - /*tp_is_gc*/ NULL, - /*tp_bases*/ NULL, - /*tp_mro*/ NULL, - /*tp_cache*/ NULL, - /*tp_subclasses*/ NULL, - /*tp_weaklist*/ NULL, - /*tp_del*/ (destructor)NULL, + /*tp_is_gc*/ nullptr, + /*tp_bases*/ nullptr, + /*tp_mro*/ nullptr, + /*tp_cache*/ nullptr, + /*tp_subclasses*/ nullptr, + /*tp_weaklist*/ nullptr, + /*tp_del*/ (destructor) nullptr, /*tp_version_tag*/ 0, - /*tp_finalize*/ NULL, - /*tp_vectorcall*/ NULL, + /*tp_finalize*/ nullptr, + /*tp_vectorcall*/ nullptr, }; PyDoc_STRVAR(py_kdtree_doc, "Generic 3-dimensional kd-tree to perform spatial searches."); @@ -434,24 +434,24 @@ static PyModuleDef kdtree_moduledef = { /*m_name*/ "mathutils.kdtree", /*m_doc*/ py_kdtree_doc, /*m_size*/ 0, - /*m_methods*/ NULL, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_methods*/ nullptr, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; PyMODINIT_FUNC PyInit_mathutils_kdtree(void) { PyObject *m = PyModule_Create(&kdtree_moduledef); - if (m == NULL) { - return NULL; + if (m == nullptr) { + return nullptr; } /* Register the 'KDTree' class */ if (PyType_Ready(&PyKDTree_Type)) { - return NULL; + return nullptr; } PyModule_AddType(m, &PyKDTree_Type); diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.cc similarity index 90% rename from source/blender/python/mathutils/mathutils_noise.c rename to source/blender/python/mathutils/mathutils_noise.cc index 732811a0fde..dfac59c871d 100644 --- a/source/blender/python/mathutils/mathutils_noise.c +++ b/source/blender/python/mathutils/mathutils_noise.cc @@ -115,7 +115,7 @@ static void next_state(void) static void setRndSeed(int seed) { if (seed == 0) { - init_genrand(time(NULL)); + init_genrand(time(nullptr)); } else { init_genrand(seed); @@ -172,7 +172,7 @@ static PyC_FlagSet bpy_noise_types[] = { {TEX_VORONOI_F2F1, "VORONOI_F2F1"}, {TEX_VORONOI_CRACKLE, "VORONOI_CRACKLE"}, {TEX_CELLNOISE, "CELLNOISE"}, - {0, NULL}, + {0, nullptr}, }; /* Metric basis enum */ @@ -186,7 +186,7 @@ static PyC_FlagSet bpy_noise_metrics[] = { {TEX_MINKOVSKY, "MINKOVSKY"}, {TEX_MINKOVSKY_HALF, "MINKOVSKY_HALF"}, {TEX_MINKOVSKY_FOUR, "MINKOVSKY_FOUR"}, - {0, NULL}, + {0, nullptr}, }; /* Fills an array of length size with random numbers in the range (-1, 1). */ @@ -288,7 +288,7 @@ PyDoc_STRVAR(M_Noise_random_doc, "\n" " :return: The random number.\n" " :rtype: float\n"); -static PyObject *M_Noise_random(PyObject *UNUSED(self)) +static PyObject *M_Noise_random(PyObject * /*self*/) { return PyFloat_FromDouble(frand()); } @@ -302,21 +302,21 @@ PyDoc_STRVAR(M_Noise_random_unit_vector_doc, " :type size: int\n" " :return: The random unit vector.\n" " :rtype: :class:`mathutils.Vector`\n"); -static PyObject *M_Noise_random_unit_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_random_unit_vector(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"size", NULL}; + static const char *kwlist[] = {"size", nullptr}; float vec[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float norm = 2.0f; int vec_num = 3; if (!PyArg_ParseTupleAndKeywords(args, kw, "|$i:random_unit_vector", (char **)kwlist, &vec_num)) { - return NULL; + return nullptr; } if (vec_num > 4 || vec_num < 2) { PyErr_SetString(PyExc_ValueError, "Vector(): invalid size"); - return NULL; + return nullptr; } while (norm == 0.0f || norm > 1.0f) { @@ -324,7 +324,7 @@ static PyObject *M_Noise_random_unit_vector(PyObject *UNUSED(self), PyObject *ar norm = normalize_vn(vec, vec_num); } - return Vector_CreatePyObject(vec, vec_num, NULL); + return Vector_CreatePyObject(vec, vec_num, nullptr); } PyDoc_STRVAR(M_Noise_random_vector_doc, @@ -336,26 +336,26 @@ PyDoc_STRVAR(M_Noise_random_vector_doc, " :type size: int\n" " :return: The random vector.\n" " :rtype: :class:`mathutils.Vector`\n"); -static PyObject *M_Noise_random_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_random_vector(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"size", NULL}; - float *vec = NULL; + static const char *kwlist[] = {"size", nullptr}; + float *vec = nullptr; int vec_num = 3; if (!PyArg_ParseTupleAndKeywords(args, kw, "|$i:random_vector", (char **)kwlist, &vec_num)) { - return NULL; + return nullptr; } if (vec_num < 2) { PyErr_SetString(PyExc_ValueError, "Vector(): invalid size"); - return NULL; + return nullptr; } vec = PyMem_New(float, vec_num); rand_vn(vec, vec_num); - return Vector_CreatePyObject_alloc(vec, vec_num, NULL); + return Vector_CreatePyObject_alloc(vec, vec_num, nullptr); } PyDoc_STRVAR(M_Noise_seed_set_doc, @@ -366,11 +366,11 @@ PyDoc_STRVAR(M_Noise_seed_set_doc, " :arg seed: Seed used for the random generator.\n" " When seed is zero, the current time will be used instead.\n" " :type seed: int\n"); -static PyObject *M_Noise_seed_set(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Noise_seed_set(PyObject * /*self*/, PyObject *args) { int s; if (!PyArg_ParseTuple(args, "i:seed_set", &s)) { - return NULL; + return nullptr; } setRndSeed(s); Py_RETURN_NONE; @@ -385,18 +385,18 @@ PyDoc_STRVAR(M_Noise_noise_doc, " :type position: :class:`mathutils.Vector`\n" BPY_NOISE_BASIS_ENUM_DOC " :return: The noise value.\n" " :rtype: float\n"); -static PyObject *M_Noise_noise(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_noise(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"", "noise_basis", NULL}; + static const char *kwlist[] = {"", "noise_basis", nullptr}; PyObject *value; float vec[3]; - const char *noise_basis_str = NULL; + const char *noise_basis_str = nullptr; int noise_basis_enum = DEFAULT_NOISE_TYPE; if (!PyArg_ParseTupleAndKeywords( args, kw, "O|$s:noise", (char **)kwlist, &value, &noise_basis_str)) { - return NULL; + return nullptr; } if (!noise_basis_str) { @@ -405,11 +405,11 @@ static PyObject *M_Noise_noise(PyObject *UNUSED(self), PyObject *args, PyObject else if (PyC_FlagSet_ValueFromID(bpy_noise_types, noise_basis_str, &noise_basis_enum, "noise") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "noise: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble( @@ -426,18 +426,18 @@ PyDoc_STRVAR(M_Noise_noise_vector_doc, " :type position: :class:`mathutils.Vector`\n" BPY_NOISE_BASIS_ENUM_DOC " :return: The noise vector.\n" " :rtype: :class:`mathutils.Vector`\n"); -static PyObject *M_Noise_noise_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_noise_vector(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"", "noise_basis", NULL}; + static const char *kwlist[] = {"", "noise_basis", nullptr}; PyObject *value; float vec[3], r_vec[3]; - const char *noise_basis_str = NULL; + const char *noise_basis_str = nullptr; int noise_basis_enum = DEFAULT_NOISE_TYPE; if (!PyArg_ParseTupleAndKeywords( args, kw, "O|$s:noise_vector", (char **)kwlist, &value, &noise_basis_str)) { - return NULL; + return nullptr; } if (!noise_basis_str) { @@ -446,16 +446,16 @@ static PyObject *M_Noise_noise_vector(PyObject *UNUSED(self), PyObject *args, Py else if (PyC_FlagSet_ValueFromID( bpy_noise_types, noise_basis_str, &noise_basis_enum, "noise_vector") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "noise_vector: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } noise_vector(vec[0], vec[1], vec[2], noise_basis_enum, r_vec); - return Vector_CreatePyObject(r_vec, 3, NULL); + return Vector_CreatePyObject(r_vec, 3, nullptr); } PyDoc_STRVAR(M_Noise_turbulence_doc, @@ -477,13 +477,13 @@ PyDoc_STRVAR(M_Noise_turbulence_doc, " :type frequency_scale: float\n" " :return: The turbulence value.\n" " :rtype: float\n"); -static PyObject *M_Noise_turbulence(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_turbulence(PyObject * /*self*/, PyObject *args, PyObject *kw) { static const char *kwlist[] = { - "", "", "", "noise_basis", "amplitude_scale", "frequency_scale", NULL}; + "", "", "", "noise_basis", "amplitude_scale", "frequency_scale", nullptr}; PyObject *value; float vec[3]; - const char *noise_basis_str = NULL; + const char *noise_basis_str = nullptr; int oct, hd, noise_basis_enum = DEFAULT_NOISE_TYPE; float as = 0.5f, fs = 2.0f; @@ -498,7 +498,7 @@ static PyObject *M_Noise_turbulence(PyObject *UNUSED(self), PyObject *args, PyOb &as, &fs)) { - return NULL; + return nullptr; } if (!noise_basis_str) { @@ -507,11 +507,11 @@ static PyObject *M_Noise_turbulence(PyObject *UNUSED(self), PyObject *args, PyOb else if (PyC_FlagSet_ValueFromID( bpy_noise_types, noise_basis_str, &noise_basis_enum, "turbulence") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "turbulence: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(turb(vec[0], vec[1], vec[2], oct, hd, noise_basis_enum, as, fs)); @@ -536,13 +536,13 @@ PyDoc_STRVAR(M_Noise_turbulence_vector_doc, " :type frequency_scale: float\n" " :return: The turbulence vector.\n" " :rtype: :class:`mathutils.Vector`\n"); -static PyObject *M_Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_turbulence_vector(PyObject * /*self*/, PyObject *args, PyObject *kw) { static const char *kwlist[] = { - "", "", "", "noise_basis", "amplitude_scale", "frequency_scale", NULL}; + "", "", "", "noise_basis", "amplitude_scale", "frequency_scale", nullptr}; PyObject *value; float vec[3], r_vec[3]; - const char *noise_basis_str = NULL; + const char *noise_basis_str = nullptr; int oct, hd, noise_basis_enum = DEFAULT_NOISE_TYPE; float as = 0.5f, fs = 2.0f; @@ -557,7 +557,7 @@ static PyObject *M_Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *arg &as, &fs)) { - return NULL; + return nullptr; } if (!noise_basis_str) { @@ -566,16 +566,16 @@ static PyObject *M_Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *arg else if (PyC_FlagSet_ValueFromID( bpy_noise_types, noise_basis_str, &noise_basis_enum, "turbulence_vector") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "turbulence_vector: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } vTurb(vec[0], vec[1], vec[2], oct, hd, noise_basis_enum, as, fs, r_vec); - return Vector_CreatePyObject(r_vec, 3, NULL); + return Vector_CreatePyObject(r_vec, 3, nullptr); } /* F. Kenton Musgrave's fractal functions */ @@ -596,19 +596,19 @@ PyDoc_STRVAR( " :type octaves: int\n" BPY_NOISE_BASIS_ENUM_DOC " :return: The fractal Brownian motion noise value.\n" " :rtype: float\n"); -static PyObject *M_Noise_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_fractal(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"", "", "", "", "noise_basis", NULL}; + static const char *kwlist[] = {"", "", "", "", "noise_basis", nullptr}; PyObject *value; float vec[3]; - const char *noise_basis_str = NULL; + const char *noise_basis_str = nullptr; float H, lac, oct; int noise_basis_enum = DEFAULT_NOISE_TYPE; if (!PyArg_ParseTupleAndKeywords( args, kw, "Offf|$s:fractal", (char **)kwlist, &value, &H, &lac, &oct, &noise_basis_str)) { - return NULL; + return nullptr; } if (!noise_basis_str) { @@ -617,11 +617,11 @@ static PyObject *M_Noise_fractal(PyObject *UNUSED(self), PyObject *args, PyObjec else if (PyC_FlagSet_ValueFromID( bpy_noise_types, noise_basis_str, &noise_basis_enum, "fractal") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "fractal: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble( @@ -645,12 +645,12 @@ PyDoc_STRVAR( " :type octaves: int\n" BPY_NOISE_BASIS_ENUM_DOC " :return: The multifractal noise value.\n" " :rtype: float\n"); -static PyObject *M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_multi_fractal(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"", "", "", "", "noise_basis", NULL}; + static const char *kwlist[] = {"", "", "", "", "noise_basis", nullptr}; PyObject *value; float vec[3]; - const char *noise_basis_str = NULL; + const char *noise_basis_str = nullptr; float H, lac, oct; int noise_basis_enum = DEFAULT_NOISE_TYPE; @@ -664,7 +664,7 @@ static PyObject *M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args, P &oct, &noise_basis_str)) { - return NULL; + return nullptr; } if (!noise_basis_str) { @@ -673,11 +673,11 @@ static PyObject *M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args, P else if (PyC_FlagSet_ValueFromID( bpy_noise_types, noise_basis_str, &noise_basis_enum, "multi_fractal") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "multi_fractal: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble( @@ -707,12 +707,12 @@ PyDoc_STRVAR(M_Noise_variable_lacunarity_doc, " :type noise_type2: string\n" " :return: The variable lacunarity noise value.\n" " :rtype: float\n"); -static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_variable_lacunarity(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"", "", "noise_type1", "noise_type2", NULL}; + static const char *kwlist[] = {"", "", "noise_type1", "noise_type2", nullptr}; PyObject *value; float vec[3]; - const char *noise_type1_str = NULL, *noise_type2_str = NULL; + const char *noise_type1_str = nullptr, *noise_type2_str = nullptr; float d; int noise_type1_enum = DEFAULT_NOISE_TYPE, noise_type2_enum = DEFAULT_NOISE_TYPE; @@ -725,7 +725,7 @@ static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *a &noise_type1_str, &noise_type2_str)) { - return NULL; + return nullptr; } if (!noise_type1_str) { @@ -734,7 +734,7 @@ static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *a else if (PyC_FlagSet_ValueFromID( bpy_noise_types, noise_type1_str, &noise_type1_enum, "variable_lacunarity") == -1) { - return NULL; + return nullptr; } if (!noise_type2_str) { @@ -743,12 +743,12 @@ static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *a else if (PyC_FlagSet_ValueFromID( bpy_noise_types, noise_type2_str, &noise_type2_enum, "variable_lacunarity") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "variable_lacunarity: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(BLI_noise_mg_variable_lacunarity( @@ -774,12 +774,12 @@ PyDoc_STRVAR( " :type offset: float\n" BPY_NOISE_BASIS_ENUM_DOC " :return: The heterogeneous terrain value.\n" " :rtype: float\n"); -static PyObject *M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_hetero_terrain(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"", "", "", "", "", "noise_basis", NULL}; + static const char *kwlist[] = {"", "", "", "", "", "noise_basis", nullptr}; PyObject *value; float vec[3]; - const char *noise_basis_str = NULL; + const char *noise_basis_str = nullptr; float H, lac, oct, ofs; int noise_basis_enum = DEFAULT_NOISE_TYPE; @@ -794,7 +794,7 @@ static PyObject *M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args, &ofs, &noise_basis_str)) { - return NULL; + return nullptr; } if (!noise_basis_str) { @@ -803,11 +803,11 @@ static PyObject *M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args, else if (PyC_FlagSet_ValueFromID( bpy_noise_types, noise_basis_str, &noise_basis_enum, "hetero_terrain") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "hetero_terrain: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble( @@ -835,12 +835,12 @@ PyDoc_STRVAR( " :type gain: float\n" BPY_NOISE_BASIS_ENUM_DOC " :return: The hybrid multifractal value.\n" " :rtype: float\n"); -static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_hybrid_multi_fractal(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"", "", "", "", "", "", "noise_basis", NULL}; + static const char *kwlist[] = {"", "", "", "", "", "", "noise_basis", nullptr}; PyObject *value; float vec[3]; - const char *noise_basis_str = NULL; + const char *noise_basis_str = nullptr; float H, lac, oct, ofs, gn; int noise_basis_enum = DEFAULT_NOISE_TYPE; @@ -856,7 +856,7 @@ static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject * &gn, &noise_basis_str)) { - return NULL; + return nullptr; } if (!noise_basis_str) { @@ -865,12 +865,12 @@ static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject * else if (PyC_FlagSet_ValueFromID( bpy_noise_types, noise_basis_str, &noise_basis_enum, "hybrid_multi_fractal") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "hybrid_multi_fractal: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(BLI_noise_mg_hybrid_multi_fractal( @@ -898,12 +898,12 @@ PyDoc_STRVAR( " :type gain: float\n" BPY_NOISE_BASIS_ENUM_DOC " :return: The ridged multifractal value.\n" " :rtype: float\n"); -static PyObject *M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_ridged_multi_fractal(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"", "", "", "", "", "", "noise_basis", NULL}; + static const char *kwlist[] = {"", "", "", "", "", "", "noise_basis", nullptr}; PyObject *value; float vec[3]; - const char *noise_basis_str = NULL; + const char *noise_basis_str = nullptr; float H, lac, oct, ofs, gn; int noise_basis_enum = DEFAULT_NOISE_TYPE; @@ -919,7 +919,7 @@ static PyObject *M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject * &gn, &noise_basis_str)) { - return NULL; + return nullptr; } if (!noise_basis_str) { @@ -928,12 +928,12 @@ static PyObject *M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject * else if (PyC_FlagSet_ValueFromID( bpy_noise_types, noise_basis_str, &noise_basis_enum, "ridged_multi_fractal") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "ridged_multi_fractal: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(BLI_noise_mg_ridged_multi_fractal( @@ -951,14 +951,14 @@ PyDoc_STRVAR(M_Noise_voronoi_doc, " :type exponent: float\n" " :return: A list of distances to the four closest features and their locations.\n" " :rtype: list of four floats, list of four :class:`mathutils.Vector` types\n"); -static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *M_Noise_voronoi(PyObject * /*self*/, PyObject *args, PyObject *kw) { - static const char *kwlist[] = {"", "distance_metric", "exponent", NULL}; + static const char *kwlist[] = {"", "distance_metric", "exponent", nullptr}; PyObject *value; PyObject *list; PyObject *ret; float vec[3]; - const char *metric_str = NULL; + const char *metric_str = nullptr; float da[4], pa[12]; int metric_enum = DEFAULT_METRIC_TYPE; float me = 2.5f; /* default minkowski exponent */ @@ -968,18 +968,18 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args, PyObjec if (!PyArg_ParseTupleAndKeywords( args, kw, "O|$sf:voronoi", (char **)kwlist, &value, &metric_str, &me)) { - return NULL; + return nullptr; } if (!metric_str) { /* pass through */ } else if (PyC_FlagSet_ValueFromID(bpy_noise_metrics, metric_str, &metric_enum, "voronoi") == -1) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "voronoi: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } list = PyList_New(4); @@ -987,7 +987,7 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args, PyObjec BLI_noise_voronoi(vec[0], vec[1], vec[2], da, pa, me, metric_enum); for (i = 0; i < 4; i++) { - PyObject *v = Vector_CreatePyObject(pa + 3 * i, 3, NULL); + PyObject *v = Vector_CreatePyObject(pa + 3 * i, 3, nullptr); PyList_SET_ITEM(list, i, v); } @@ -1005,17 +1005,17 @@ PyDoc_STRVAR(M_Noise_cell_doc, " :type position: :class:`mathutils.Vector`\n" " :return: The cell noise value.\n" " :rtype: float\n"); -static PyObject *M_Noise_cell(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Noise_cell(PyObject * /*self*/, PyObject *args) { PyObject *value; float vec[3]; if (!PyArg_ParseTuple(args, "O:cell", &value)) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "cell: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } return PyFloat_FromDouble(BLI_noise_cell(vec[0], vec[1], vec[2])); @@ -1030,21 +1030,21 @@ PyDoc_STRVAR(M_Noise_cell_vector_doc, " :type position: :class:`mathutils.Vector`\n" " :return: The cell noise vector.\n" " :rtype: :class:`mathutils.Vector`\n"); -static PyObject *M_Noise_cell_vector(PyObject *UNUSED(self), PyObject *args) +static PyObject *M_Noise_cell_vector(PyObject * /*self*/, PyObject *args) { PyObject *value; float vec[3], r_vec[3]; if (!PyArg_ParseTuple(args, "O:cell_vector", &value)) { - return NULL; + return nullptr; } if (mathutils_array_parse(vec, 3, 3, value, "cell_vector: invalid 'position' arg") == -1) { - return NULL; + return nullptr; } BLI_noise_cell_v3(vec[0], vec[1], vec[2], r_vec); - return Vector_CreatePyObject(r_vec, 3, NULL); + return Vector_CreatePyObject(r_vec, 3, nullptr); } static PyMethodDef M_Noise_methods[] = { @@ -1095,7 +1095,7 @@ static PyMethodDef M_Noise_methods[] = { {"voronoi", (PyCFunction)M_Noise_voronoi, METH_VARARGS | METH_KEYWORDS, M_Noise_voronoi_doc}, {"cell", (PyCFunction)M_Noise_cell, METH_VARARGS, M_Noise_cell_doc}, {"cell_vector", (PyCFunction)M_Noise_cell_vector, METH_VARARGS, M_Noise_cell_vector_doc}, - {NULL, NULL, 0, NULL}, + {nullptr, nullptr, 0, nullptr}, }; static PyModuleDef M_Noise_module_def = { @@ -1104,10 +1104,10 @@ static PyModuleDef M_Noise_module_def = { /*m_doc*/ M_Noise_doc, /*m_size*/ 0, /*m_methods*/ M_Noise_methods, - /*m_slots*/ NULL, - /*m_traverse*/ NULL, - /*m_clear*/ NULL, - /*m_free*/ NULL, + /*m_slots*/ nullptr, + /*m_traverse*/ nullptr, + /*m_clear*/ nullptr, + /*m_free*/ nullptr, }; /*----------------------------MODULE INIT-------------------------*/