diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/python/intern/bpy_rna.h | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/python/intern/bpy_rna.h')
-rw-r--r-- | source/blender/python/intern/bpy_rna.h | 170 |
1 files changed, 101 insertions, 69 deletions
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index c4c6944d46d..588c3cbf171 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -25,31 +25,30 @@ #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. */ -#define USE_WEAKREFS +# define USE_WEAKREFS /* method to invalidate removed py data, XXX, slow to remove objects, otherwise no overhead */ /* #define USE_PYRNA_INVALIDATE_GC */ /* different method */ -#define USE_PYRNA_INVALIDATE_WEAKREF +# define USE_PYRNA_INVALIDATE_WEAKREF /* support for inter references, currently only needed for corner case */ -#define USE_PYRNA_STRUCT_REFERENCE +# define USE_PYRNA_STRUCT_REFERENCE #else /* WITH_PYTHON_SAFETY */ - /* default, no defines! */ +/* default, no defines! */ #endif /* !WITH_PYTHON_SAFETY */ - /* sanity checks on above defs */ #if defined(USE_PYRNA_INVALIDATE_WEAKREF) && !defined(USE_WEAKREFS) -#define USE_WEAKREFS +# define USE_WEAKREFS #endif #if defined(USE_PYRNA_INVALIDATE_GC) && defined(USE_PYRNA_INVALIDATE_WEAKREF) -#error "Only 1 reference check method at a time!" +# error "Only 1 reference check method at a time!" #endif /* only used by operator introspection get_rna(), this is only used for doc gen @@ -72,86 +71,102 @@ extern PyTypeObject pyrna_prop_array_Type; extern PyTypeObject pyrna_prop_collection_Type; extern PyTypeObject pyrna_func_Type; -#define BPy_StructRNA_Check(v) (PyObject_TypeCheck(v, &pyrna_struct_Type)) -#define BPy_StructRNA_CheckExact(v) (Py_TYPE(v) == &pyrna_struct_Type) -#define BPy_PropertyRNA_Check(v) (PyObject_TypeCheck(v, &pyrna_prop_Type)) -#define BPy_PropertyRNA_CheckExact(v) (Py_TYPE(v) == &pyrna_prop_Type) - -#define PYRNA_STRUCT_CHECK_OBJ(obj) if (UNLIKELY(pyrna_struct_validity_check(obj) == -1)) { return NULL; } (void)0 -#define PYRNA_STRUCT_CHECK_INT(obj) if (UNLIKELY(pyrna_struct_validity_check(obj) == -1)) { return -1; } (void)0 - -#define PYRNA_PROP_CHECK_OBJ(obj) if (UNLIKELY(pyrna_prop_validity_check(obj) == -1)) { return NULL; } (void)0 -#define PYRNA_PROP_CHECK_INT(obj) if (UNLIKELY(pyrna_prop_validity_check(obj) == -1)) { return -1; } (void)0 +#define BPy_StructRNA_Check(v) (PyObject_TypeCheck(v, &pyrna_struct_Type)) +#define BPy_StructRNA_CheckExact(v) (Py_TYPE(v) == &pyrna_struct_Type) +#define BPy_PropertyRNA_Check(v) (PyObject_TypeCheck(v, &pyrna_prop_Type)) +#define BPy_PropertyRNA_CheckExact(v) (Py_TYPE(v) == &pyrna_prop_Type) + +#define PYRNA_STRUCT_CHECK_OBJ(obj) \ + if (UNLIKELY(pyrna_struct_validity_check(obj) == -1)) { \ + return NULL; \ + } \ + (void)0 +#define PYRNA_STRUCT_CHECK_INT(obj) \ + if (UNLIKELY(pyrna_struct_validity_check(obj) == -1)) { \ + return -1; \ + } \ + (void)0 + +#define PYRNA_PROP_CHECK_OBJ(obj) \ + if (UNLIKELY(pyrna_prop_validity_check(obj) == -1)) { \ + return NULL; \ + } \ + (void)0 +#define PYRNA_PROP_CHECK_INT(obj) \ + if (UNLIKELY(pyrna_prop_validity_check(obj) == -1)) { \ + return -1; \ + } \ + (void)0 #define PYRNA_STRUCT_IS_VALID(pysrna) (LIKELY(((BPy_StructRNA *)(pysrna))->ptr.type != NULL)) -#define PYRNA_PROP_IS_VALID(pysrna) (LIKELY(((BPy_PropertyRNA *)(pysrna))->ptr.type != NULL)) +#define PYRNA_PROP_IS_VALID(pysrna) (LIKELY(((BPy_PropertyRNA *)(pysrna))->ptr.type != NULL)) /* 'in_weakreflist' MUST be aligned */ typedef struct { - PyObject_HEAD /* required python macro */ + PyObject_HEAD /* required python macro */ #ifdef USE_WEAKREFS - PyObject *in_weakreflist; + PyObject *in_weakreflist; #endif - PointerRNA ptr; + PointerRNA ptr; } BPy_DummyPointerRNA; typedef struct { - PyObject_HEAD /* required python macro */ + PyObject_HEAD /* required python macro */ #ifdef USE_WEAKREFS - PyObject *in_weakreflist; + PyObject *in_weakreflist; #endif - PointerRNA ptr; + PointerRNA ptr; #ifdef USE_PYRNA_STRUCT_REFERENCE - /* generic PyObject we hold a reference to, example use: - * hold onto the collection iterator to prevent it from freeing allocated data we may use */ - PyObject *reference; + /* generic PyObject we hold a reference to, example use: + * hold onto the collection iterator to prevent it from freeing allocated data we may use */ + PyObject *reference; #endif /* !USE_PYRNA_STRUCT_REFERENCE */ #ifdef PYRNA_FREE_SUPPORT - bool freeptr; /* needed in some cases if ptr.data is created on the fly, free when deallocing */ -#endif /* PYRNA_FREE_SUPPORT */ + bool freeptr; /* needed in some cases if ptr.data is created on the fly, free when deallocing */ +#endif /* PYRNA_FREE_SUPPORT */ } BPy_StructRNA; typedef struct { - PyObject_HEAD /* required python macro */ + PyObject_HEAD /* required python macro */ #ifdef USE_WEAKREFS - PyObject *in_weakreflist; + PyObject *in_weakreflist; #endif - PointerRNA ptr; - PropertyRNA *prop; + PointerRNA ptr; + PropertyRNA *prop; } BPy_PropertyRNA; typedef struct { - PyObject_HEAD /* required python macro */ + PyObject_HEAD /* required python macro */ #ifdef USE_WEAKREFS - PyObject *in_weakreflist; + PyObject *in_weakreflist; #endif - PointerRNA ptr; - PropertyRNA *prop; + PointerRNA ptr; + 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 */ + /* 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 */ } BPy_PropertyArrayRNA; typedef struct { - PyObject_HEAD /* required python macro */ + PyObject_HEAD /* required python macro */ #ifdef USE_WEAKREFS - PyObject *in_weakreflist; + PyObject *in_weakreflist; #endif - /* collection iterator specific parts */ - CollectionPropertyIterator iter; + /* collection iterator specific parts */ + CollectionPropertyIterator iter; } BPy_PropertyCollectionIterRNA; typedef struct { - PyObject_HEAD /* required python macro */ + PyObject_HEAD /* required python macro */ #ifdef USE_WEAKREFS - PyObject *in_weakreflist; + PyObject *in_weakreflist; #endif - PointerRNA ptr; - FunctionRNA *func; + PointerRNA ptr; + FunctionRNA *func; } BPy_FunctionRNA; /* cheap trick */ @@ -160,37 +175,44 @@ typedef struct { StructRNA *srna_from_self(PyObject *self, const char *error_prefix); StructRNA *pyrna_struct_as_srna(PyObject *self, const bool parent, const char *error_prefix); -void BPY_rna_init(void); +void BPY_rna_init(void); PyObject *BPY_rna_module(void); -void BPY_update_rna_module(void); +void BPY_update_rna_module(void); /*PyObject *BPY_rna_doc(void);*/ PyObject *BPY_rna_types(void); -void BPY_rna_register_cb(void); +void BPY_rna_register_cb(void); PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr); PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop); /* extern'd by other modules which don't deal closely with RNA */ PyObject *pyrna_id_CreatePyObject(struct ID *id); -bool pyrna_id_FromPyObject(PyObject *obj, struct ID **id); -bool pyrna_id_CheckPyObject(PyObject *obj); +bool pyrna_id_FromPyObject(PyObject *obj, struct ID **id); +bool pyrna_id_CheckPyObject(PyObject *obj); /* operators also need this to set args */ -int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, const bool all_args, const char *error_prefix); +int pyrna_pydict_to_props(PointerRNA *ptr, + PyObject *kw, + const bool all_args, + const char *error_prefix); PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop); -unsigned int *pyrna_set_to_enum_bitmap( - const struct EnumPropertyItem *items, PyObject *value, - int type_size, bool type_convert_sign, - int bitmap_size, - const char *error_prefix); -PyObject *pyrna_enum_bitfield_to_py( - const struct EnumPropertyItem *items, int value); -int pyrna_set_to_enum_bitfield( - const struct EnumPropertyItem *items, PyObject *value, int *r_value, const char *error_prefix); - -int pyrna_enum_value_from_id( - const EnumPropertyItem *item, const char *identifier, int *value, const char *error_prefix); +unsigned int *pyrna_set_to_enum_bitmap(const struct EnumPropertyItem *items, + PyObject *value, + int type_size, + bool type_convert_sign, + int bitmap_size, + const char *error_prefix); +PyObject *pyrna_enum_bitfield_to_py(const struct EnumPropertyItem *items, int value); +int pyrna_set_to_enum_bitfield(const struct EnumPropertyItem *items, + PyObject *value, + int *r_value, + const char *error_prefix); + +int pyrna_enum_value_from_id(const EnumPropertyItem *item, + const char *identifier, + int *value, + const char *error_prefix); int pyrna_deferred_register_class(struct StructRNA *srna, PyTypeObject *py_class); @@ -199,12 +221,22 @@ void pyrna_alloc_types(void); void pyrna_free_types(void); /* primitive type conversion */ -int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, char *param_data, PyObject *py, const char *error_prefix); -int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix); +int pyrna_py_to_array( + PointerRNA *ptr, PropertyRNA *prop, char *param_data, PyObject *py, const char *error_prefix); +int pyrna_py_to_array_index(PointerRNA *ptr, + PropertyRNA *prop, + int arraydim, + int arrayoffset, + int index, + PyObject *py, + const char *error_prefix); PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index); PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop); -PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int index); +PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, + PointerRNA *ptr, + PropertyRNA *prop, + int index); PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop); int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value); |