diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-11-29 05:52:06 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-11-29 05:53:34 +0300 |
commit | ad625acda82281461267a3379c57ce76d54325a1 (patch) | |
tree | 22b2b7c583ba35c33cfec4aac7608f5f62e6e2c8 /source/blender/python/intern/bpy_props.c | |
parent | 0b325ba201269b3c8aab6e61c70f15c1758737d8 (diff) |
RNA: Allow structs to define tags for their properties
Adds support for defining a number of tags as part of the rna-struct
definition, which its properties can set similar to property-flags.
BPY supports setting these tags when defining custom properties too.
* To define tags for a struct (which its properties can use then), define the tags in an `EnumPropertyItem` array, and assign them to the struct using `RNA_def_struct_property_tags(...)`.
* To set tags for an RNA-property in C, use the new `RNA_def_property_tags(...)`.
* To set tags for an RNA-property in Python, use the newly added tags parameter. E.g. `bpy.props.FloatProperty(name="Some Float", tags={'SOME_TAG', 'ANOTHER_TAG'})`.
Diffstat (limited to 'source/blender/python/intern/bpy_props.c')
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 161 |
1 files changed, 129 insertions, 32 deletions
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index e4e21587c79..abeaeb27d88 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1858,7 +1858,22 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, PyObject *ge #_func"(options={ ...}):"))) \ { \ return NULL; \ - } (void)0 + } \ + { \ + const EnumPropertyItem *tag_defines = RNA_struct_property_tag_defines(srna); \ + if (py_tags && !tag_defines) { \ + PyErr_Format(PyExc_TypeError, \ + #_func"(): property-tags not available for '%s'", \ + RNA_struct_identifier(srna)); \ + return NULL; \ + } \ + if (UNLIKELY(py_tags && pyrna_set_to_enum_bitfield( \ + tag_defines, py_tags, \ + &prop_tags, #_func"(tags={ ...}):"))) \ + { \ + return NULL; \ + } \ + }(void)0 #define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \ BPY_PROPDEF_CHECK(_func, _property_flag_items); \ @@ -1941,6 +1956,10 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, PyObject *ge " :arg type: A subclass of :class:`bpy.types.PropertyGroup` or :class:`bpy.types.ID`.\n" \ " :type type: class\n" \ +#define BPY_PROPDEF_TAGS_DOC \ +" :arg tags: Enumerator of tags that are defined by parent class.\n" \ +" :type tags: set\n" \ + #if 0 static int bpy_struct_id_used(StructRNA *srna, char *identifier) { @@ -1959,6 +1978,7 @@ PyDoc_STRVAR(BPy_BoolProperty_doc, "description=\"\", " "default=False, " "options={'ANIMATABLE'}, " + "tags={}, " "subtype='NONE', " "update=None, " "get=None, " @@ -1969,6 +1989,7 @@ PyDoc_STRVAR(BPy_BoolProperty_doc, BPY_PROPDEF_NAME_DOC BPY_PROPDEF_DESC_DOC BPY_PROPDEF_OPTIONS_DOC +BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_SUBTYPE_NUMBER_DOC BPY_PROPDEF_UPDATE_DOC BPY_PROPDEF_GET_DOC @@ -1987,22 +2008,25 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) PropertyRNA *prop; PyObject *pyopts = NULL; int opts = 0; + int prop_tags = 0; const char *pysubtype = NULL; int subtype = PROP_NONE; PyObject *update_cb = NULL; PyObject *get_cb = NULL; PyObject *set_cb = NULL; + PyObject *py_tags = NULL; static const char *_keywords[] = { "attr", "name", "description", "default", - "options", "subtype", "update", "get", "set", NULL, + "options", "tags", "subtype", + "update", "get", "set", NULL, }; - static _PyArg_Parser _parser = {"s#|ssO&O!sOOO:BoolProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#|ssO&O!O!sOOO:BoolProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &id, &id_len, &name, &description, PyC_ParseBool, &def, - &PySet_Type, &pyopts, &pysubtype, + &PySet_Type, &pyopts, &PySet_Type, &py_tags, &pysubtype, &update_cb, &get_cb, &set_cb)) { return NULL; @@ -2024,6 +2048,9 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) RNA_def_property_boolean_default(prop, def); RNA_def_property_ui_text(prop, name ? name : id, description); + if (py_tags) { + RNA_def_property_tags(prop, prop_tags); + } if (pyopts) { bpy_prop_assign_flag(prop, opts); } @@ -2040,6 +2067,7 @@ PyDoc_STRVAR(BPy_BoolVectorProperty_doc, "description=\"\", " "default=(False, False, False), " "options={'ANIMATABLE'}, " + "tags={}, " "subtype='NONE', " "size=3, " "update=None, " @@ -2053,6 +2081,7 @@ BPY_PROPDEF_DESC_DOC " :arg default: sequence of booleans the length of *size*.\n" " :type default: sequence\n" BPY_PROPDEF_OPTIONS_DOC +BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_SUBTYPE_ARRAY_DOC BPY_PROPDEF_VECSIZE_DOC BPY_PROPDEF_UPDATE_DOC @@ -2074,22 +2103,26 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject PyObject *pydef = NULL; PyObject *pyopts = NULL; int opts = 0; + int prop_tags = 0; const char *pysubtype = NULL; int subtype = PROP_NONE; PyObject *update_cb = NULL; PyObject *get_cb = NULL; PyObject *set_cb = NULL; + PyObject *py_tags = NULL; static const char *_keywords[] = { "attr", "name", "description", "default", - "options", "subtype", "size", "update", "get", "set", NULL, + "options", "tags", "subtype", "size", + "update", "get", "set", NULL, }; - static _PyArg_Parser _parser = {"s#|ssOO!siOOO:BoolVectorProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#|ssOO!O!siOOO:BoolVectorProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &id, &id_len, &name, &description, &pydef, - &PySet_Type, &pyopts, &pysubtype, &size, + &PySet_Type, &pyopts, &PySet_Type, &py_tags, + &pysubtype, &size, &update_cb, &get_cb, &set_cb)) { return NULL; @@ -2123,6 +2156,9 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject if (pydef) RNA_def_property_boolean_array_default(prop, def); RNA_def_property_ui_text(prop, name ? name : id, description); + if (py_tags) { + RNA_def_property_tags(prop, prop_tags); + } if (pyopts) { bpy_prop_assign_flag(prop, opts); } @@ -2142,6 +2178,7 @@ PyDoc_STRVAR(BPy_IntProperty_doc, "soft_min=-2**31, soft_max=2**31-1, " "step=1, " "options={'ANIMATABLE'}, " + "tags={}, " "subtype='NONE', " "update=None, " "get=None, " @@ -2161,6 +2198,7 @@ BPY_PROPDEF_NUM_SOFTMIN_DOC " :type soft_max: int\n" BPY_PROPDEF_INT_STEP_DOC BPY_PROPDEF_OPTIONS_DOC +BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_SUBTYPE_NUMBER_DOC BPY_PROPDEF_UPDATE_DOC BPY_PROPDEF_GET_DOC @@ -2179,24 +2217,27 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) PropertyRNA *prop; PyObject *pyopts = NULL; int opts = 0; + int prop_tags = 0; const char *pysubtype = NULL; int subtype = PROP_NONE; PyObject *update_cb = NULL; PyObject *get_cb = NULL; PyObject *set_cb = NULL; + PyObject *py_tags = NULL; static const char *_keywords[] = { "attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", - "step", "options", "subtype", "update", "get", "set", NULL, + "step", "options", "tags", "subtype", + "update", "get", "set", NULL, }; - static _PyArg_Parser _parser = {"s#|ssiiiiiiO!sOOO:IntProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#|ssiiiiiiO!O!sOOO:IntProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &id, &id_len, &name, &description, &def, &min, &max, &soft_min, &soft_max, - &step, &PySet_Type, &pyopts, &pysubtype, + &step, &PySet_Type, &pyopts, &PySet_Type, &py_tags, &pysubtype, &update_cb, &get_cb, &set_cb)) { return NULL; @@ -2220,6 +2261,9 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) RNA_def_property_range(prop, min, max); RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3); + if (py_tags) { + RNA_def_property_tags(prop, prop_tags); + } if (pyopts) { bpy_prop_assign_flag(prop, opts); } @@ -2238,6 +2282,7 @@ PyDoc_STRVAR(BPy_IntVectorProperty_doc, "soft_max=2**31-1, " "step=1, " "options={'ANIMATABLE'}, " + "tags={}, " "subtype='NONE', " "size=3, " "update=None, " @@ -2260,6 +2305,7 @@ BPY_PROPDEF_NUM_SOFTMAX_DOC " :type soft_max: int\n" BPY_PROPDEF_INT_STEP_DOC BPY_PROPDEF_OPTIONS_DOC +BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_SUBTYPE_ARRAY_DOC BPY_PROPDEF_VECSIZE_DOC BPY_PROPDEF_UPDATE_DOC @@ -2282,24 +2328,27 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject PyObject *pydef = NULL; PyObject *pyopts = NULL; int opts = 0; + int prop_tags = 0; const char *pysubtype = NULL; int subtype = PROP_NONE; PyObject *update_cb = NULL; PyObject *get_cb = NULL; PyObject *set_cb = NULL; + PyObject *py_tags = NULL; static const char *_keywords[] = { "attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", - "step", "options", "subtype", "size", "update", "get", "set", NULL, + "step", "options", "tags", "subtype", "size", + "update", "get", "set", NULL, }; - static _PyArg_Parser _parser = {"s#|ssOiiiiiO!siOOO:IntVectorProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#|ssOiiiiiO!O!siOOO:IntVectorProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &id, &id_len, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, - &step, &PySet_Type, &pyopts, + &step, &PySet_Type, &pyopts, &PySet_Type, &py_tags, &pysubtype, &size, &update_cb, &get_cb, &set_cb)) { @@ -2335,6 +2384,9 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject RNA_def_property_ui_text(prop, name ? name : id, description); RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3); + if (py_tags) { + RNA_def_property_tags(prop, prop_tags); + } if (pyopts) { bpy_prop_assign_flag(prop, opts); } @@ -2355,6 +2407,7 @@ PyDoc_STRVAR(BPy_FloatProperty_doc, "step=3, " "precision=2, " "options={'ANIMATABLE'}, " + "tags={}, " "subtype='NONE', " "unit='NONE', " "update=None, " @@ -2376,6 +2429,7 @@ BPY_PROPDEF_NUM_SOFTMAX_DOC BPY_PROPDEF_FLOAT_STEP_DOC BPY_PROPDEF_FLOAT_PREC_DOC BPY_PROPDEF_OPTIONS_DOC +BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_SUBTYPE_NUMBER_DOC BPY_PROPDEF_UNIT_DOC BPY_PROPDEF_UPDATE_DOC @@ -2396,6 +2450,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) PropertyRNA *prop; PyObject *pyopts = NULL; int opts = 0; + int prop_tags = 0; const char *pysubtype = NULL; int subtype = PROP_NONE; const char *pyunit = NULL; @@ -2403,21 +2458,22 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) PyObject *update_cb = NULL; PyObject *get_cb = NULL; PyObject *set_cb = NULL; + PyObject *py_tags = NULL; static const char *_keywords[] = { "attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", - "step", "precision", "options", "subtype", + "step", "precision", "options", "tags", "subtype", "unit", "update", "get", "set", NULL, }; - static _PyArg_Parser _parser = {"s#|ssffffffiO!ssOOO:FloatProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#|ssffffffiO!O!ssOOO:FloatProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &id, &id_len, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, - &pyopts, &pysubtype, &pyunit, + &pyopts, &PySet_Type, &py_tags, &pysubtype, &pyunit, &update_cb, &get_cb, &set_cb)) { return NULL; @@ -2446,6 +2502,9 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) RNA_def_property_ui_text(prop, name ? name : id, description); RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); + if (py_tags) { + RNA_def_property_tags(prop, prop_tags); + } if (pyopts) { bpy_prop_assign_flag(prop, opts); } @@ -2465,6 +2524,7 @@ PyDoc_STRVAR(BPy_FloatVectorProperty_doc, "step=3, " "precision=2, " "options={'ANIMATABLE'}, " + "tags={}, " "subtype='NONE', " "unit='NONE', " "size=3, " @@ -2487,6 +2547,7 @@ BPY_PROPDEF_NUM_SOFTMIN_DOC BPY_PROPDEF_NUM_SOFTMAX_DOC " :type soft_max: float\n" BPY_PROPDEF_OPTIONS_DOC +BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_FLOAT_STEP_DOC BPY_PROPDEF_FLOAT_PREC_DOC BPY_PROPDEF_SUBTYPE_ARRAY_DOC @@ -2512,6 +2573,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec PyObject *pydef = NULL; PyObject *pyopts = NULL; int opts = 0; + int prop_tags = 0; const char *pysubtype = NULL; int subtype = PROP_NONE; const char *pyunit = NULL; @@ -2519,21 +2581,22 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec PyObject *update_cb = NULL; PyObject *get_cb = NULL; PyObject *set_cb = NULL; + PyObject *py_tags = NULL; static const char *_keywords[] = { "attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", - "step", "precision", "options", "subtype", + "step", "precision", "options", "tags", "subtype", "unit", "size", "update", "get", "set", NULL, }; - static _PyArg_Parser _parser = {"s#|ssOfffffiO!ssiOOO:FloatVectorProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#|ssOfffffiO!O!ssiOOO:FloatVectorProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &id, &id_len, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, - &pyopts, &pysubtype, &pyunit, &size, + &pyopts, &PySet_Type, &py_tags, &pysubtype, &pyunit, &size, &update_cb, &get_cb, &set_cb)) { return NULL; @@ -2573,6 +2636,9 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec RNA_def_property_ui_text(prop, name ? name : id, description); RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); + if (py_tags) { + RNA_def_property_tags(prop, prop_tags); + } if (pyopts) { bpy_prop_assign_flag(prop, opts); } @@ -2589,6 +2655,7 @@ PyDoc_STRVAR(BPy_StringProperty_doc, "default=\"\", " "maxlen=0, " "options={'ANIMATABLE'}, " + "tags={}, " "subtype='NONE', " "update=None, " "get=None, " @@ -2603,6 +2670,7 @@ BPY_PROPDEF_DESC_DOC " :arg maxlen: maximum length of the string.\n" " :type maxlen: int\n" BPY_PROPDEF_OPTIONS_DOC +BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_SUBTYPE_STRING_DOC BPY_PROPDEF_UPDATE_DOC BPY_PROPDEF_GET_DOC @@ -2621,22 +2689,25 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw PropertyRNA *prop; PyObject *pyopts = NULL; int opts = 0; + int prop_tags = 0; const char *pysubtype = NULL; int subtype = PROP_NONE; PyObject *update_cb = NULL; PyObject *get_cb = NULL; PyObject *set_cb = NULL; + PyObject *py_tags = NULL; static const char *_keywords[] = { "attr", "name", "description", "default", - "maxlen", "options", "subtype", "update", "get", "set", NULL, + "maxlen", "options", "tags", "subtype", + "update", "get", "set", NULL, }; - static _PyArg_Parser _parser = {"s#|sssiO!sOOO:StringProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#|sssiO!O!sOOO:StringProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &id, &id_len, &name, &description, &def, - &maxlen, &PySet_Type, &pyopts, &pysubtype, + &maxlen, &PySet_Type, &pyopts, &PySet_Type, &py_tags, &pysubtype, &update_cb, &get_cb, &set_cb)) { return NULL; @@ -2659,6 +2730,9 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw if (def && def[0]) RNA_def_property_string_default(prop, def); RNA_def_property_ui_text(prop, name ? name : id, description); + if (py_tags) { + RNA_def_property_tags(prop, prop_tags); + } if (pyopts) { bpy_prop_assign_flag(prop, opts); } @@ -2675,6 +2749,7 @@ PyDoc_STRVAR(BPy_EnumProperty_doc, "description=\"\", " "default=None, " "options={'ANIMATABLE'}, " + "tags={}, " "update=None, " "get=None, " "set=None)\n" @@ -2716,6 +2791,7 @@ BPY_PROPDEF_DESC_DOC " (i.e. if a callback function is given as *items* parameter).\n" " :type default: string or set\n" BPY_PROPDEF_OPTIONS_ENUM_DOC +BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_UPDATE_DOC BPY_PROPDEF_GET_DOC BPY_PROPDEF_SET_DOC @@ -2736,21 +2812,23 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) PropertyRNA *prop; PyObject *pyopts = NULL; int opts = 0; + int prop_tags = 0; bool is_itemf = false; PyObject *update_cb = NULL; PyObject *get_cb = NULL; PyObject *set_cb = NULL; + PyObject *py_tags = NULL; static const char *_keywords[] = { "attr", "items", "name", "description", "default", - "options", "update", "get", "set", NULL, + "options", "tags", "update", "get", "set", NULL, }; - static _PyArg_Parser _parser = {"s#O|ssOO!OOO:EnumProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#O|ssOO!O!OOO:EnumProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &id, &id_len, &items, &name, &description, - &def, &PySet_Type, &pyopts, + &def, &PySet_Type, &pyopts, &PySet_Type, &py_tags, &update_cb, &get_cb, &set_cb)) { return NULL; @@ -2813,6 +2891,9 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) if (opts & PROP_ENUM_FLAG) prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name ? name : id, description); else prop = RNA_def_enum(srna, id, eitems, defvalue, name ? name : id, description); + if (py_tags) { + RNA_def_property_tags(prop, prop_tags); + } if (pyopts) { bpy_prop_assign_flag(prop, opts); } @@ -2861,6 +2942,7 @@ PyDoc_STRVAR(BPy_PointerProperty_doc, "name=\"\", " "description=\"\", " "options={'ANIMATABLE'}, " + "tags={}, " "poll=None, " "update=None)\n" "\n" @@ -2870,6 +2952,7 @@ BPY_PROPDEF_TYPE_DOC BPY_PROPDEF_NAME_DOC BPY_PROPDEF_DESC_DOC BPY_PROPDEF_OPTIONS_DOC +BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_POLL_DOC BPY_PROPDEF_UPDATE_DOC ); @@ -2886,18 +2969,21 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) StructRNA *ptype; PyObject *type = Py_None; PyObject *pyopts = NULL; + PyObject *py_tags = NULL; int opts = 0; + int prop_tags = 0; PyObject *update_cb = NULL, *poll_cb = NULL; static const char *_keywords[] = { - "attr", "type", "name", "description", "options", "poll", "update", NULL, + "attr", "type", "name", "description", "options", + "tags", "poll", "update", NULL, }; - static _PyArg_Parser _parser = {"s#O|ssO!OO:PointerProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#O|ssO!O!OO:PointerProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &id, &id_len, &type, &name, &description, - &PySet_Type, &pyopts, + &PySet_Type, &pyopts, &PySet_Type, &py_tags, &poll_cb, &update_cb)) { return NULL; @@ -2921,6 +3007,9 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } prop = RNA_def_pointer_runtime(srna, id, ptype, name ? name : id, description); + if (py_tags) { + RNA_def_property_tags(prop, prop_tags); + } if (pyopts) { bpy_prop_assign_flag(prop, opts); } @@ -2941,7 +3030,8 @@ PyDoc_STRVAR(BPy_CollectionProperty_doc, ".. function:: CollectionProperty(type=None, " "name=\"\", " "description=\"\", " - "options={'ANIMATABLE'})\n" + "options={'ANIMATABLE'}, " + "tags={})\n" "\n" " Returns a new collection property definition.\n" "\n" @@ -2949,6 +3039,7 @@ BPY_PROPDEF_TYPE_DOC BPY_PROPDEF_NAME_DOC BPY_PROPDEF_DESC_DOC BPY_PROPDEF_OPTIONS_DOC +BPY_PROPDEF_TAGS_DOC ); PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) { @@ -2963,17 +3054,20 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) StructRNA *ptype; PyObject *type = Py_None; PyObject *pyopts = NULL; + PyObject *py_tags = NULL; int opts = 0; + int prop_tags = 0; static const char *_keywords[] = { - "attr", "type", "name", "description", "options", NULL, + "attr", "type", "name", "description", + "options", "tags", NULL, }; - static _PyArg_Parser _parser = {"s#O|ssO!:CollectionProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#O|ssO!O!:CollectionProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, &id, &id_len, &type, &name, &description, - &PySet_Type, &pyopts)) + &PySet_Type, &pyopts, &PySet_Type, &py_tags)) { return NULL; } @@ -2992,6 +3086,9 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) } prop = RNA_def_collection_runtime(srna, id, ptype, name ? name : id, description); + if (py_tags) { + RNA_def_property_tags(prop, prop_tags); + } if (pyopts) { bpy_prop_assign_flag(prop, opts); } |