From 778542fd8fe80f87286d36bb4005314a8343e038 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 29 Apr 2019 19:59:13 +1000 Subject: Cleanup: comments (long lines) in python --- source/blender/python/bmesh/bmesh_py_types.c | 18 ++++-- source/blender/python/generic/idprop_py_api.c | 3 +- source/blender/python/generic/py_capi_utils.c | 12 ++-- source/blender/python/generic/python_utildefines.h | 3 +- source/blender/python/gpu/gpu_py_batch.c | 3 +- source/blender/python/intern/bpy.c | 3 +- source/blender/python/intern/bpy_app_ocio.c | 10 +-- .../blender/python/intern/bpy_app_translations.c | 22 ++++--- source/blender/python/intern/bpy_driver.c | 16 +++-- source/blender/python/intern/bpy_gizmo_wrap.c | 5 +- source/blender/python/intern/bpy_interface.c | 3 +- source/blender/python/intern/bpy_operator.c | 5 +- source/blender/python/intern/bpy_operator_wrap.c | 8 ++- source/blender/python/intern/bpy_props.c | 5 +- source/blender/python/intern/bpy_rna.c | 74 ++++++++++++++-------- source/blender/python/intern/bpy_rna.h | 11 +++- source/blender/python/intern/bpy_rna_array.c | 8 ++- .../blender/python/intern/bpy_rna_id_collection.c | 15 +++-- source/blender/python/intern/bpy_utils_units.c | 12 ++-- source/blender/python/mathutils/mathutils.c | 18 ++++-- source/blender/python/mathutils/mathutils_Matrix.c | 3 +- source/blender/python/mathutils/mathutils_Vector.c | 7 +- .../blender/python/mathutils/mathutils_geometry.c | 8 ++- 23 files changed, 182 insertions(+), 90 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index f540b2e102c..eb611e6566a 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -875,10 +875,20 @@ static PyGetSetDef bpy_bmface_getseters[] = { }; static PyGetSetDef bpy_bmloop_getseters[] = { - /* generic */ - /* flags are available but not used for loops. */ - // {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT}, - // {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN}, +/* generic */ +/* flags are available but not used for loops. */ +#if 0 + {(char *)"select", + (getter)bpy_bm_elem_hflag_get, + (setter)bpy_bm_elem_hflag_set, + (char *)bpy_bm_elem_select_doc, + (void *)BM_ELEM_SELECT}, + {(char *)"hide", + (getter)bpy_bm_elem_hflag_get, + (setter)bpy_bm_elem_hflag_set, + (char *)bpy_bm_elem_hide_doc, + (void *)BM_ELEM_HIDDEN}, +#endif {(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 056e3a33b6e..dd5baaa661c 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -164,7 +164,8 @@ PyObject *BPy_IDGroup_WrapData(ID *id, IDProperty *prop, IDProperty *parent) } } -#if 0 /* UNUSED, currently assignment overwrites into new properties, rather than setting in-place */ +/* UNUSED, currently assignment overwrites into new properties, rather than setting in-place. */ +#if 0 static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject *value) { switch (prop->type) { diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 191863a862d..25549c95896 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -37,7 +37,8 @@ #include "BLI_string.h" #ifndef MATH_STANDALONE -/* only for BLI_strncpy_wchar_from_utf8, should replace with py funcs but too late in release now */ +/* Only for BLI_strncpy_wchar_from_utf8, + * should replace with py funcs but too late in release now. */ # include "BLI_string_utf8.h" #endif @@ -273,7 +274,8 @@ void PyC_ObSpitStr(char *result, size_t result_len, PyObject *var) const PyTypeObject *type = Py_TYPE(var); PyObject *var_str = PyObject_Repr(var); if (var_str == NULL) { - /* We could print error here, but this may be used for generating errors - so don't for now. */ + /* We could print error here, + * but this may be used for generating errors - so don't for now. */ PyErr_Clear(); } BLI_snprintf(result, @@ -765,7 +767,8 @@ void PyC_MainModule_Restore(PyObject *main_mod) Py_XDECREF(main_mod); } -/* must be called before Py_Initialize, expects output of BKE_appdir_folder_id(BLENDER_PYTHON, NULL) */ +/* Must be called before Py_Initialize, + * expects output of BKE_appdir_folder_id(BLENDER_PYTHON, NULL). */ void PyC_SetHomePath(const char *py_path_bundle) { if (py_path_bundle == NULL) { @@ -803,7 +806,8 @@ void PyC_SetHomePath(const char *py_path_bundle) { static wchar_t py_path_bundle_wchar[1024]; - /* cant use this, on linux gives bug: #23018, TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 22008 */ + /* Can't use this, on linux gives bug: #23018, + * TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 2008 */ /* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */ BLI_strncpy_wchar_from_utf8( diff --git a/source/blender/python/generic/python_utildefines.h b/source/blender/python/generic/python_utildefines.h index 40cec436dea..653122c9c33 100644 --- a/source/blender/python/generic/python_utildefines.h +++ b/source/blender/python/generic/python_utildefines.h @@ -45,7 +45,8 @@ Py_LOCAL_INLINE(PyObject *) Py_INCREF_RET(PyObject *op) return op; } -/* append & transfer ownership to the list, avoids inline Py_DECREF all over (which is quite a large macro) */ +/* Append & transfer ownership to the list, + * avoids inline Py_DECREF all over (which is quite a large macro). */ Py_LOCAL_INLINE(int) PyList_APPEND(PyObject *op, PyObject *v) { int ret = PyList_Append(op, v); diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c index 094052b724f..a9e65413767 100644 --- a/source/blender/python/gpu/gpu_py_batch.c +++ b/source/blender/python/gpu/gpu_py_batch.c @@ -127,7 +127,8 @@ PyDoc_STRVAR(bpygpu_Batch_vertbuf_add_doc, " Add another vertex buffer to the Batch.\n" " It is not possible to add more vertices to the batch using this method.\n" " Instead it can be used to add more attributes to the existing vertices.\n" -" A good use case would be when you have a separate vertex buffer for vertex positions and vertex normals.\n" +" A good use case would be when you have a separate\n" +" vertex buffer for vertex positions and vertex normals.\n" " Current a batch can have at most " STRINGIFY(GPU_BATCH_VBO_MAX_LEN) " vertex buffers.\n" "\n" " :param buf: The vertex buffer that will be added to the batch.\n" diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 08f4df543a8..92ba7704b19 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -177,7 +177,8 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj return NULL; } - /* same logic as BKE_appdir_folder_id_create(), but best leave it up to the script author to create */ + /* same logic as BKE_appdir_folder_id_create(), + * but best leave it up to the script author to create */ path = BKE_appdir_folder_id_user_notest(folder_id, subdir); return PyC_UnicodeFromByte(path ? path : ""); diff --git a/source/blender/python/intern/bpy_app_ocio.c b/source/blender/python/intern/bpy_app_ocio.c index 2a56075e00e..9dcadbac2af 100644 --- a/source/blender/python/intern/bpy_app_ocio.c +++ b/source/blender/python/intern/bpy_app_ocio.c @@ -40,10 +40,12 @@ static PyStructSequence_Field app_ocio_info_fields[] = { }; static PyStructSequence_Desc app_ocio_info_desc = { - (char *)"bpy.app.ocio", /* name */ - (char - *)"This module contains information about OpenColorIO blender is linked against", /* doc */ - app_ocio_info_fields, /* fields */ + /* name */ + (char *)"bpy.app.ocio", + /* doc */ + (char *)"This module contains information about OpenColorIO blender is linked against", + /* fields */ + app_ocio_info_fields, ARRAY_SIZE(app_ocio_info_fields) - 1, }; diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index 56de6dd1405..a48cd742448 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -47,13 +47,16 @@ typedef struct { PyObject_HEAD - /* The string used to separate context from actual message in PY_TRANSLATE RNA props. */ + /** The string used to separate context from actual message in PY_TRANSLATE RNA props. */ const char *context_separator; - /* A "named tuple" (StructSequence actually...) containing all C-defined contexts. */ + /** A "named tuple" (StructSequence actually...) containing all C-defined contexts. */ PyObject *contexts; - /* A readonly mapping {C context id: python id} (actually, a MappingProxy). */ + /** A readonly mapping {C context id: python id} (actually, a MappingProxy). */ PyObject *contexts_C_to_py; - /* A py dict containing all registered py dicts (order is more or less random, first match wins!). */ + /** + * A py dict containing all registered py dicts + * (order is more or less random, first match wins!). + */ PyObject *py_messages; } BlenderAppTranslations; @@ -111,8 +114,8 @@ static void _ghashutil_keyfree(void *ptr) /***** Python's messages cache *****/ /* We cache all messages available for a given locale from all py dicts into a single ghash. - * Changing of locale is not so common, while looking for a message translation is, so let's try to optimize - * the later as much as we can! + * Changing of locale is not so common, while looking for a message translation is, + * 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; @@ -148,7 +151,8 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale) printf("\n"); # endif - /* Try to get first complete locale, then language+country, then language+variant, then only language */ + /* Try to get first complete locale, then language+country, + * then language+variant, then only language. */ lang_dict = PyDict_GetItemString(uuid_dict, locale); if (!lang_dict && language_country) { lang_dict = PyDict_GetItemString(uuid_dict, language_country); @@ -393,8 +397,8 @@ static PyTypeObject BlenderAppTranslationsContextsType; 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! - */ + * 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_Desc app_translations_contexts_desc = { diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 3457e614708..726599ff06e 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -54,7 +54,10 @@ extern void BPY_update_rna_module(void); # include #endif -/* for pydrivers (drivers using one-line Python expressions to express relationships between targets) */ +/** + * For PyDrivers + * (drivers using one-line Python expressions to express relationships between targets). + */ PyObject *bpy_pydriver_Dict = NULL; #ifdef USE_BYTECODE_WHITELIST @@ -399,8 +402,10 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, { PyObject *driver_vars = NULL; PyObject *retval = NULL; - PyObject * - expr_vars; /* speed up by pre-hashing string & avoids re-converting unicode strings for every execution */ + + /* Speed up by pre-hashing string & avoids re-converting unicode strings for every execution. */ + PyObject *expr_vars; + PyObject *expr_code; PyGILState_STATE gilstate; bool use_gil; @@ -475,8 +480,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 0, expr_code); driver_orig->flag &= ~DRIVER_FLAG_RECOMPILE; - driver_orig->flag |= - DRIVER_FLAG_RENAMEVAR; /* maybe this can be removed but for now best keep until were sure */ + + /* Maybe this can be removed but for now best keep until were sure. */ + driver_orig->flag |= DRIVER_FLAG_RENAMEVAR; #ifdef USE_BYTECODE_WHITELIST is_recompile = true; #endif diff --git a/source/blender/python/intern/bpy_gizmo_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.c index 41ff630753f..c66cad5f4a3 100644 --- a/source/blender/python/intern/bpy_gizmo_wrap.c +++ b/source/blender/python/intern/bpy_gizmo_wrap.c @@ -116,8 +116,9 @@ static void gizmo_properties_init(wmGizmoType *gzt) /* Extract target property definitions from 'bl_target_properties' */ { - /* picky developers will notice that 'bl_targets' won't work with inheritance - * get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */ + /* Picky developers will notice that 'bl_targets' won't work with inheritance + * get direct from the dict to avoid raising a load of attribute errors + * (yes this isnt ideal) - campbell. */ PyObject *py_class_dict = py_class->tp_dict; PyObject *bl_target_properties = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_target_properties); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 90dfdcd33b7..ebcb4085597 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -80,7 +80,8 @@ CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_RNA, "bpy.rna"); /* for internal use, when starting and ending python scripts */ -/* in case a python script triggers another python call, stop bpy_context_clear from invalidating */ +/* In case a python script triggers another python call, + * stop bpy_context_clear from invalidating. */ static int py_call_level = 0; // #define TIME_PY_RUN // simple python tests. prints on exit. diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 0f66a9cbeb9..aef4ab6667a 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -314,8 +314,9 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) return NULL; } - /* when calling bpy.ops.wm.read_factory_settings() bpy.data's main pointer is freed by clear_globals(), - * further access will crash blender. setting context is not needed in this case, only calling because this + /* When calling bpy.ops.wm.read_factory_settings() bpy.data's main pointer + * is freed by clear_globals(), further access will crash blender. + * Setting context is not needed in this case, only calling because this * function corrects bpy.data (internal Main pointer) */ BPY_modules_update(C); diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 976ed4611b0..8f2f08c7c37 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -45,7 +45,8 @@ static void operator_properties_init(wmOperatorType *ot) /* Only call this so pyrna_deferred_register_class gives a useful error * WM_operatortype_append_ptr will call RNA_def_struct_identifier later. * - * Note the 'no_struct_map' function is used since the actual struct name is already used by the operator. + * Note the 'no_struct_map' function is used since the actual struct name + * is already used by the operator. */ RNA_def_struct_identifier_no_struct_map(ot->srna, ot->idname); @@ -56,8 +57,9 @@ static void operator_properties_init(wmOperatorType *ot) /* set the default property: ot->prop */ { - /* picky developers will notice that 'bl_property' won't work with inheritance - * get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */ + /* Picky developers will notice that 'bl_property' won't work with inheritance + * get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) + * - campbell. */ PyObject *py_class_dict = py_class->tp_dict; PyObject *bl_property = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_property); const char *prop_id; diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index a0a6c73fe1f..074d72f094f 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -2277,7 +2277,10 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject return NULL; } - // prop = RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name ? name : id, description); +#if 0 + prop = RNA_def_boolean_array( + srna, id, size, pydef ? def : NULL, name ? name : id, description); +#endif prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype); RNA_def_property_array(prop, size); if (pydef) { diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 0ca96071ee0..98124464835 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -189,7 +189,8 @@ static void id_weakref_pool_add(ID *id, BPy_DummyPointerRNA *pyrna) PyObject *weakref_capsule; PyObject *weakref_cb_py; - /* create a new function instance and insert the list as 'self' so we can remove ourself from it */ + /* Create a new function instance and insert the list as 'self' + * 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); @@ -704,7 +705,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_QUATERNION: if (len == 3) { /* euler */ if (is_thick) { - /* attempt to get order, only needed for thick types since wrapped with update via callbacks */ + /* Attempt to get order, + * only needed for thick types since wrapped with update via callbacks. */ PropertyRNA *prop_eul_order = NULL; short order = pyrna_rotation_euler_order_get(ptr, EULER_ORDER_XYZ, &prop_eul_order); @@ -1433,7 +1435,8 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val) RNA_property_enum_items_ex(NULL, ptr, prop, true, &enum_item, NULL, &free_dummy); BLI_assert(!free_dummy); - /* Do not print warning in case of DummyRNA_NULL_items, this one will never match any value... */ + /* 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); @@ -1846,7 +1849,8 @@ static int pyrna_py_to_prop( } else { /* same as bytes */ - /* XXX, this is suspect but needed for function calls, need to see if theres a better way */ + /* XXX, this is suspect but needed for function calls, + * need to see if theres a better way. */ if (data) { *((char **)data) = (char *)param; } @@ -1902,7 +1906,8 @@ static int pyrna_py_to_prop( * if the prop is not an operator type and the pyobject is an operator, * use its properties in place of its self. * - * this is so bad that its almost a good reason to do away with fake 'self.properties -> self' + * This is so bad that its almost a good reason to do away with fake + * 'self.properties -> self' * class mixing if this causes problems in the future it should be removed. */ if ((ptr_type == &RNA_AnyType) && (BPy_StructRNA_Check(value))) { @@ -1997,8 +2002,9 @@ static int pyrna_py_to_prop( } } else { - /* for function calls, we sometimes want to pass the 'ptr' directly, - * watch out that it remains valid!, possibly we could support this later if needed */ + /* For function calls, we sometimes want to pass the 'ptr' directly, + * watch out that it remains valid!, + * possibly we could support this later if needed. */ BLI_assert(value_new == NULL); if (value == Py_None) { *((void **)data) = NULL; @@ -4187,8 +4193,8 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) ret = NULL; } else if ( - name[0] == - '_') { /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */ + /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */ + name[0] == '_') { /* annoying exception, maybe we need to have different types for this... */ if (STR_ELEM(name, "__getitem__", "__setitem__") && !RNA_struct_idprops_check(self->ptr.type)) { @@ -4312,9 +4318,11 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr * >>> bpy.types.Scene.foo = BoolProperty() * >>> bpy.types.Scene.foo * - * ...rather than returning the deferred class register tuple as checked by pyrna_is_deferred_prop() + * ...rather than returning the deferred class register tuple + * as checked by pyrna_is_deferred_prop() * - * Disable for now, this is faking internal behavior in a way that's too tricky to maintain well. */ + * Disable for now, + * this is faking internal behavior in a way that's too tricky to maintain well. */ # if 0 if (ret == NULL) { // || pyrna_is_deferred_prop(ret) StructRNA *srna = srna_from_self(cls, "StructRNA.__getattr__"); @@ -4424,7 +4432,8 @@ 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 cant be set, unless its apart of the py class */ + /* Code just raises correct error, context prop's cant be set, + * unless its apart of the py class. */ bContext *C = self->ptr.data; if (C == NULL) { PyErr_Format(PyExc_AttributeError, @@ -5105,7 +5114,8 @@ static int foreach_parse_args(BPy_PropertyRNA *self, } *size = RNA_raw_type_sizeof(*raw_type); -#if 0 /* works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks */ +#if 0 /* works fine but not strictly needed, + * we could allow RNA_property_collection_raw_* to do the checks */ if ((*attr_tot) < 1) { *attr_tot = 1; } @@ -5130,8 +5140,9 @@ static int foreach_parse_args(BPy_PropertyRNA *self, #endif } - /* check 'attr_tot' otherwise we don't know if any values were set - * this isn't ideal because it means running on an empty list may fail silently when its not compatible. */ + /* Check 'attr_tot' otherwise we don't know if any values were set + * this isn't ideal because it means running on an empty list may + * fail silently when its not compatible. */ if (*size == 0 && *attr_tot != 0) { PyErr_SetString(PyExc_AttributeError, "attribute does not support foreach method"); return -1; @@ -5997,7 +6008,8 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject /* Check if we gave args that don't exist in the function * printing the error is slow but it should only happen when developing. * the if below is quick, checking if it passed less keyword args then we gave. - * (Don't overwrite the error if we have one, otherwise can skip important messages and confuse with args) + * (Don't overwrite the error if we have one, + * otherwise can skip important messages and confuse with args). */ if (err == 0 && kw && (pykw_len > kw_tot)) { PyObject *key, *value; @@ -6894,7 +6906,8 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA * if ((PyObject *)pyrna != Py_None) { /* hold a reference to the iterator since it may have * allocated memory 'pyrna' needs. eg: introspecting dynamic enum's */ - /* TODO, we could have an api call to know if this is needed since most collections don't */ + /* TODO, we could have an api call to know if this is + * needed since most collections don't */ pyrna_struct_reference_set(pyrna, (PyObject *)self); } } @@ -7025,8 +7038,10 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) /* sanity check, could skip this unless in debug mode */ if (newclass) { PyObject *base_compare = pyrna_srna_PyBase(srna); - //PyObject *slots = PyObject_GetAttrString(newclass, "__slots__"); // cant do this because it gets superclasses values! - //PyObject *bases = PyObject_GetAttrString(newclass, "__bases__"); // can do this but faster not to. + /* Can't do this because it gets superclasses values! */ + // PyObject *slots = PyObject_GetAttrString(newclass, "__slots__"); + /* Can do this but faster not to. */ + // PyObject *bases = PyObject_GetAttrString(newclass, "__bases__"); PyObject *tp_bases = ((PyTypeObject *)newclass)->tp_bases; PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict, bpy_intern_str___slots__); @@ -7077,7 +7092,10 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna) /* subclass equivalents * - class myClass(myBase): * some = 'value' # or ... - * - myClass = type(name='myClass', bases=(myBase,), dict={'__module__': 'bpy.types', '__slots__': ()}) + * - myClass = type( + * name='myClass', + * bases=(myBase,), dict={'__module__': 'bpy.types', '__slots__': ()} + * ) */ /* Assume RNA_struct_py_type_get(srna) was already checked */ @@ -7132,7 +7150,8 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna) } #endif - /* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */ + /* Newclass will now have 2 ref's, ???, + * probably 1 is internal since decrefing here segfaults. */ /* PyC_ObSpit("new class ref", newclass); */ @@ -7884,7 +7903,8 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, const int flag = RNA_function_flag(func); /* TODO(campbell): this is used for classmethod's too, * even though class methods should have 'FUNC_USE_SELF_TYPE' set, see Operator.poll for eg. - * Keep this as-is since its working but we should be using 'FUNC_USE_SELF_TYPE' for many functions. */ + * Keep this as-is since its working but we should be using + * 'FUNC_USE_SELF_TYPE' for many functions. */ const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE); if (!(flag & FUNC_REGISTER)) { @@ -7909,8 +7929,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, PyErr_Clear(); } else { - Py_DECREF( - item); /* no need to keep a ref, the class owns it (technically we should keep a ref but...) */ + /* No need to keep a ref, the class owns it (technically we should keep a ref but...). */ + Py_DECREF(item); + if (is_staticmethod) { if (PyMethod_Check(item) == 0) { PyErr_Format(PyExc_TypeError, @@ -8198,7 +8219,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param else { arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount; } - // args = PyTuple_New(rna_function_arg_count(func)); /* first arg is included in 'item' */ +#if 0 + /* First arg is included in 'item'. */ + args = PyTuple_New(rna_function_arg_count(func)); +#endif args = PyTuple_New(arg_count); /* first arg is included in 'item' */ if (is_staticmethod) { diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 588c3cbf171..cf6bd54d8a5 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -24,7 +24,10 @@ /* --- bpy build options --- */ #ifdef WITH_PYTHON_SAFETY -/* play it safe and keep optional for now, need to test further now this affects looping on 10000's of verts for eg. */ +/** + * Play it safe and keep optional for now, + * need to test further now this affects looping on 10000's of verts for eg. + */ # define USE_WEAKREFS /* method to invalidate removed py data, XXX, slow to remove objects, otherwise no overhead */ @@ -146,8 +149,10 @@ typedef struct { PropertyRNA *prop; /* Arystan: this is a hack to allow sub-item r/w access like: face.uv[n][m] */ - int arraydim; /* array dimension, e.g: 0 for face.uv, 2 for face.uv[n][m], etc. */ - int arrayoffset; /* array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n */ + /** Array dimension, e.g: 0 for face.uv, 2 for face.uv[n][m], etc. */ + int arraydim; + /** Array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n. */ + int arrayoffset; } BPy_PropertyArrayRNA; typedef struct { diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index 847ecde354a..9d8fff5dfe4 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -86,7 +86,8 @@ typedef struct ItemConvert_FuncArg { */ /* arr[3] = x, self->arraydim is 0, lvalue_dim is 1 */ -/* Ensures that a python sequence has expected number of items/sub-items and items are of desired type. */ +/* Ensures that a python sequence has expected number of + * items/sub-items and items are of desired type. */ static int validate_array_type(PyObject *seq, int dim, int totdim, @@ -203,7 +204,10 @@ static int validate_array_type(PyObject *seq, else if (!check_item_type(item)) { Py_DECREF(item); - /* BLI_snprintf(error_str, error_str_size, "sequence items should be of type %s", item_type_str); */ +#if 0 + BLI_snprintf( + error_str, error_str_size, "sequence items should be of type %s", item_type_str); +#endif PyErr_Format(PyExc_TypeError, "%s expected sequence items of type %s, not %s", error_prefix, diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c index 78dae50efe6..dfd7624bd3d 100644 --- a/source/blender/python/intern/bpy_rna_id_collection.c +++ b/source/blender/python/intern/bpy_rna_id_collection.c @@ -34,7 +34,8 @@ #include "BKE_main.h" #include "DNA_ID.h" -/* Those folowing are only to support hack of not listing some internal 'backward' pointers in generated user_map... */ +/* Those folowing are only to support hack of not listing some internal + * 'backward' pointers in generated user_map. */ #include "DNA_object_types.h" #include "DNA_key_types.h" @@ -97,11 +98,13 @@ static int foreach_libblock_id_user_map_callback(void *user_data, } if ((GS(self_id->name) == ID_OB) && (id_p == (ID **)&((Object *)self_id)->proxy_from)) { - /* We skip proxy_from here, since it's some internal pointer which is not relevant info for py/API level. */ + /* We skip proxy_from here, + * since it's some internal pointer which is not relevant info for py/API level. */ return IDWALK_RET_NOP; } else if ((GS(self_id->name) == ID_KE) && (id_p == (ID **)&((Key *)self_id)->from)) { - /* We skip from here, since it's some internal pointer which is not relevant info for py/API level. */ + /* We skip from here, + * since it's some internal pointer which is not relevant info for py/API level. */ return IDWALK_RET_NOP; } @@ -245,14 +248,16 @@ 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 flitered out types. */ (key_types_bitmap == NULL || 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. */ + /* 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)) { PyObject *key = data_cb.py_id_key_lookup_only; PyObject *set; RNA_id_pointer_create(id, &((BPy_StructRNA *)key)->ptr); - /* We have to insert the key now, otherwise ID unused would be missing from final dict... */ + /* 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) { /* Cannot use our placeholder key here! */ key = pyrna_id_CreatePyObject(id); diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c index b80ea50dd09..645b7e1c7af 100644 --- a/source/blender/python/intern/bpy_utils_units.c +++ b/source/blender/python/intern/bpy_utils_units.c @@ -66,8 +66,8 @@ static const char *bpyunits_ucategorie_items[] = { /** * These fields are just empty placeholders, actual values get set in initializations functions. - * This allows us to avoid many handwriting, and above all, to keep all systems/categories definition stuff in - * ``BKE_unit.h``. + * This allows us to avoid many handwriting, and above all, + * to keep all systems/categories definition stuff in ``BKE_unit.h``. */ static PyStructSequence_Field bpyunits_systems_fields[ARRAY_SIZE(bpyunits_usystem_items)]; static PyStructSequence_Field bpyunits_categories_fields[ARRAY_SIZE(bpyunits_ucategorie_items)]; @@ -281,9 +281,11 @@ static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyOb { /* Maximum expected length of string result: - * - number itself: precision + decimal dot + up to four 'above dot' digits. - * - unit: up to ten chars (six currently, let's be conservative, also because we use some utf8 chars). - * This can be repeated twice (e.g. 1m20cm), and we add ten more spare chars (spaces, trailing '\0'...). + * - Number itself: precision + decimal dot + up to four 'above dot' digits. + * - Unit: up to ten chars + * (six currently, let's be conservative, also because we use some utf8 chars). + * This can be repeated twice (e.g. 1m20cm), and we add ten more spare chars + * (spaces, trailing '\0'...). * So in practice, 64 should be more than enough. */ char buf1[64], buf2[64], *str; diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 32ffa4ad2da..d0fa9f5c565 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -381,13 +381,16 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error /* LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon */ /* XXX We may want to use 'safer' BLI's compare_ff_relative ultimately? - * LomontRRDCompare4() is an optimized version of Dawson's AlmostEqual2sComplement() (see [1] and [2]). - * Dawson himself now claims this is not a 'safe' thing to do (pushing ULP method beyond its limits), - * an recommends using work from [3] instead, which is done in BLI func... + * LomontRRDCompare4() is an optimized version of Dawson's AlmostEqual2sComplement() + * (see [1] and [2]). + * Dawson himself now claims this is not a 'safe' thing to do + * (pushing ULP method beyond its limits), + * an recommends using work from [3] instead, which is done in BLI func... * - * [1] http://www.randydillon.org/Papers/2007/everfast.htm - * [2] http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm - * [3] https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ instead + * [1] http://www.randydillon.org/Papers/2007/everfast.htm + * [2] http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm + * [3] https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ + * instead. */ #define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31)) @@ -437,7 +440,8 @@ PyObject *mathutils_dynstr_to_py(struct DynStr *ds) /* Mathutils Callbacks */ -/* for mathutils internal use only, eventually should re-alloc but to start with we only have a few users */ +/* 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}; diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 6ccb3c2a291..7cc9ba50d90 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -1072,7 +1072,8 @@ static void matrix_invert_safe_internal(const MatrixObject *self, float *r_mat) if (det == 0.0f) { const float eps = PSEUDOINVERSE_EPSILON; - /* We will copy self->matrix into r_mat (if needed), and modify it in place to add diagonal epsilon. */ + /* We will copy self->matrix into r_mat (if needed), + * and modify it in place to add diagonal epsilon. */ in_mat = r_mat; switch (self->num_col) { diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 7d73f165c1e..29861c56dc0 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -2377,12 +2377,15 @@ static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(clos * '((%s | SWIZZLE_VALID_AXIS) | ' * '((%s | SWIZZLE_VALID_AXIS) << SWIZZLE_BITS_PER_AXIS) | ' * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)) | ' - * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3))) ' % + * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3))) ' + * % * (axis_0_pos, axis_1_pos, axis_2_pos, axis_3_pos)) * * axises = axises[:-1] * items = list(axis_dict.items()) - * items.sort(key=lambda a: a[0].replace('x', '0').replace('y', '1').replace('z', '2').replace('w', '3')) + * items.sort( + * key=lambda a: a[0].replace('x', '0').replace('y', '1').replace('z', '2').replace('w', '3') + * ) * * unique = set() * for key, val in items: diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 5fe3536d899..c39954713b1 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1043,7 +1043,13 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a if (len_squared_v3(n3n1) > eps) { const float quotient = dot_v3v3(N1, n2n3); if (fabsf(quotient) > eps) { - /* potentialVertex = (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) * (-1.0 / quotient); */ + /** + *
+                   * potentialVertex = (
+                   *     (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) *
+                   *     (-1.0 / quotient));
+                   * 
+ */ const float quotient_ninv = -1.0f / quotient; potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) + (n1n2[0] * N3[3])) * -- cgit v1.2.3