Commit: c2304d2f029cf4610c33c0e9cbf5afe519b770b8 Author: Bastien Montagne Date: Fri Jul 10 15:29:03 2020 +0200 Branches: master https://developer.blender.org/rBc2304d2f029cf4610c33c0e9cbf5afe519b770b8
Expose override flags to python RNA properties definition. Time will tell whether we need to expose more RNA override flags here. Implements/Fix T78534. Differential Revision: https://developer.blender.org/D8250 =================================================================== M source/blender/python/intern/bpy_props.c =================================================================== diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 3df0d805c5b..a1f9d4afc51 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -88,6 +88,37 @@ static const EnumPropertyItem property_flag_enum_items[] = { "'LIBRARY_EDITABLE'].\n" \ " :type options: set\n" +static const EnumPropertyItem property_flag_override_items[] = { + {PROPOVERRIDE_OVERRIDABLE_LIBRARY, + "LIBRARY_OVERRIDABLE", + 0, + "Library Overridable", + "Allow that property to be overridable from library linked data-blocks"}, + {0, NULL, 0, NULL, NULL}, +}; + +#define BPY_PROPDEF_OPTIONS_OVERRIDE_DOC \ + " :arg options: Enumerator in ['LIBRARY_OVERRIDE'].\n" \ + " :type options: set\n" + +static const EnumPropertyItem property_flag_override_collection_items[] = { + {PROPOVERRIDE_OVERRIDABLE_LIBRARY, + "LIBRARY_OVERRIDABLE", + 0, + "Library Overridable", + "Make that property editable in library overrides of linked data-blocks"}, + {PROPOVERRIDE_NO_PROP_NAME, + "NO_PROPERTY_NAME", + 0, + "No Name", + "Do not use the names of the items, only their indices in the collection"}, + {0, NULL, 0, NULL, NULL}, +}; + +#define BPY_PROPDEF_OPTIONS_OVERRIDE_COLLECTION_DOC \ + " :arg options: Enumerator in ['LIBRARY_OVERRIDE', 'NO_PROPERTY_NAME'].\n" \ + " :type options: set\n" + /* subtypes */ /* XXX Keep in sync with rna_rna.c's rna_enum_property_subtype_items ??? * Currently it is not... @@ -202,6 +233,11 @@ static void bpy_prop_assign_flag(PropertyRNA *prop, const int flag) } } +static void bpy_prop_assign_flag_override(PropertyRNA *prop, const int flag_override) +{ + RNA_def_property_override_flag(prop, flag_override); +} + /* operators and classes use this so it can store the args given but defer * running it until the operator runs where these values are used to setup * the default args for that operator instance */ @@ -1959,7 +1995,7 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, /* terse macros for error checks shared between all funcs cant use function * calls because of static strings passed to pyrna_set_to_enum_bitfield */ -#define BPY_PROPDEF_CHECK(_func, _property_flag_items) \ +#define BPY_PROPDEF_CHECK(_func, _property_flag_items, _property_flag_override_items) \ if (UNLIKELY(id_len >= MAX_IDPROP_NAME)) { \ PyErr_Format(PyExc_TypeError, \ #_func "(): '%.200s' too long, max length is %d", \ @@ -1975,6 +2011,12 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, _property_flag_items, pyopts, &opts, #_func "(options={ ...}):"))) { \ return NULL; \ } \ + if (UNLIKELY(pyopts_override && pyrna_set_to_enum_bitfield(_property_flag_override_items, \ + pyopts_override, \ + &opts_override, \ + #_func "(override={ ...}):"))) { \ + return NULL; \ + } \ { \ const EnumPropertyItem *tag_defines = RNA_struct_property_tag_defines(srna); \ if (py_tags && !tag_defines) { \ @@ -1990,8 +2032,9 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, } \ (void)0 -#define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \ - BPY_PROPDEF_CHECK(_func, _property_flag_items); \ +#define BPY_PROPDEF_SUBTYPE_CHECK( \ + _func, _property_flag_items, _property_flag_override_items, _subtype) \ + BPY_PROPDEF_CHECK(_func, _property_flag_items, _property_flag_override_items); \ if (UNLIKELY(pysubtype && RNA_enum_value_from_id(_subtype, pysubtype, &subtype) == 0)) { \ const char *enum_str = BPy_enum_as_string(_subtype); \ PyErr_Format(PyExc_TypeError, \ @@ -2099,7 +2142,8 @@ PyDoc_STRVAR(BPy_BoolProperty_doc, "description=\"\", " "default=False, " "options={'ANIMATABLE'}, " - "tags={}, " + "override=set(), " + "tags=set(), " "subtype='NONE', " "update=None, " "get=None, " @@ -2107,8 +2151,9 @@ PyDoc_STRVAR(BPy_BoolProperty_doc, "\n" " Returns a new boolean property definition.\n" "\n" 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 BPY_PROPDEF_SET_DOC); + BPY_PROPDEF_OPTIONS_OVERRIDE_DOC BPY_PROPDEF_TAGS_DOC + BPY_PROPDEF_SUBTYPE_NUMBER_DOC BPY_PROPDEF_UPDATE_DOC BPY_PROPDEF_GET_DOC + BPY_PROPDEF_SET_DOC); static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) { StructRNA *srna; @@ -2121,7 +2166,9 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) bool def = false; PropertyRNA *prop; PyObject *pyopts = NULL; + PyObject *pyopts_override = NULL; int opts = 0; + int opts_override = 0; int prop_tags = 0; const char *pysubtype = NULL; int subtype = PROP_NONE; @@ -2136,6 +2183,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) "description", "default", "options", + "override", "tags", "subtype", "update", @@ -2143,7 +2191,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) "set", NULL, }; - static _PyArg_Parser _parser = {"s#|ssO&O!O!sOOO:BoolProperty", _keywords, 0}; + static _PyArg_Parser _parser = {"s#|ssO&O!O!O!sOOO:BoolProperty", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, @@ -2156,6 +2204,8 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) &PySet_Type, &pyopts, &PySet_Type, + &pyopts_override, + &PySet_Type, &py_tags, &pysubtype, &update_cb, @@ -2164,7 +2214,10 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - BPY_PROPDEF_SUBTYPE_CHECK(BoolProperty, property_flag_items, property_subtype_number_items); + BPY_PROPDEF_SUBTYPE_CHECK(BoolProperty, + property_flag_items, + property_flag_override_items, + property_subtype_number_items); if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { return NULL; @@ -2186,6 +2239,9 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) if (pyopts) { bpy_prop_assign_flag(prop, opts); } + if (pyopts_override) { + bpy_prop_assign_flag_override(prop, opts_override); + } bpy_prop_callback_assign_update(prop, update_cb); bpy_prop_callback_assign_boolean(prop, get_cb, set_cb); RNA_def_property_duplicate_pointers(srna, prop); @@ -2194,24 +2250,26 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) Py_RETURN_NONE; } -PyDoc_STRVAR(BPy_BoolVectorProperty_doc, - ".. function:: BoolVectorProperty(name=\"\", " - "description=\"\", " - "default=(False, False, False), " - "options={'ANIMATABLE'}, " - "tags={}, " - "subtype='NONE', " - "size=3, " - "update=None, " - "get=None, " - "set=None)\n" - "\n" - " Returns a new vector boolean property definition.\n" - "\n" BPY_PROPDEF_NAME_DOC 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 - BPY_PROPDEF_GET_DOC BPY_PROPDEF_SET_DOC); +PyDoc_STRVAR( + BPy_BoolVectorProperty_doc, + ".. function:: BoolVectorProperty(name=\"\", " + "description=\"\", " + "default=(False, False, False), " + "options={'ANIMATABLE'}, " + "override=set(), " + "tags=set(), " + "subtype='NONE', " + "size=3, " + "update=None, " + "get=None, " + "set=None)\n" + "\n" + " Returns a new vector boolean property definition.\n" + "\n" BPY_PROPDEF_NAME_DOC BPY_PROPDEF_DESC_DOC + " :arg default: sequence of booleans the length of *size*.\n" + " :type default: sequence\n" BPY_PROPDEF_OPTIONS_DOC BPY_PROPDEF_OPTIONS_OVERRIDE_DOC + BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_SUBTYPE_ARRAY_DOC BPY_PROPDEF_VECSIZE_DOC + BPY_PROPDEF_UPDATE_DOC BPY_PROPDEF_GET_DOC BPY_PROPDEF_SET_DOC); static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw) { StructRNA *srna; @@ -2226,7 +2284,9 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject PropertyRNA *prop; PyObject *pydef = NULL; PyObject *pyopts = NULL; + PyObject *pyopts_override = NULL; int opts = 0; + int opts_override = 0; int prop_tags = 0; const char *pysubtype = NULL; int subtype = PROP_NONE; @@ -2241,6 +2301,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject "description", "default", "options", + "override", "tags", "subtype", "size", @@ -2249,7 +2310,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject "set", NULL, }; - static _PyArg_Parser _parser = {"s#|ssOO!O!siOOO:BoolVector @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] https://lists.blender.org/mailman/listinfo/bf-blender-cvs
