diff options
author | Jacques Lucke <jacques@blender.org> | 2022-06-22 11:56:21 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-06-22 11:56:21 +0300 |
commit | 2d0dc88209e166159bd0b68dc54103280b09193c (patch) | |
tree | 3875e9554c810d14fa3a490cbdf003472bd7ee3c /source/blender/python/intern/bpy_props.c | |
parent | c57ed65cc88418e290401599e28d51f1acb5dfd9 (diff) | |
parent | a3d0f77ded1c982da93d61fac6942cfc67c9e599 (diff) |
Merge branch 'master' into deform-curves-with-surface
Diffstat (limited to 'source/blender/python/intern/bpy_props.c')
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 421 |
1 files changed, 256 insertions, 165 deletions
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index a6aa1f46b0c..3f2154189e8 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -45,150 +45,32 @@ /** \name Shared Enums & Doc-Strings * \{ */ -static const EnumPropertyItem property_flag_items[] = { - {PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""}, - {PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", ""}, - {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""}, - {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", ""}, - {PROP_PROPORTIONAL, "PROPORTIONAL", 0, "Adjust values proportionally to eachother", ""}, - {PROP_TEXTEDIT_UPDATE, - "TEXTEDIT_UPDATE", - 0, - "Update on every keystroke in textedit 'mode'", - ""}, - {0, NULL, 0, NULL, NULL}, -}; - #define BPY_PROPDEF_OPTIONS_DOC \ - " :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE', 'LIBRARY_EDITABLE', " \ - "'PROPORTIONAL'," \ - "'TEXTEDIT_UPDATE'].\n" \ + " :arg options: Enumerator in :ref:`rna_enum_property_flag_items`.\n" \ " :type options: set\n" -static const EnumPropertyItem property_flag_enum_items[] = { - {PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""}, - {PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", ""}, - {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""}, - {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", ""}, - {PROP_ENUM_FLAG, "ENUM_FLAG", 0, "Enum Flag", ""}, - {0, NULL, 0, NULL, NULL}, -}; - #define BPY_PROPDEF_OPTIONS_ENUM_DOC \ - " :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE', 'ENUM_FLAG', " \ - "'LIBRARY_EDITABLE'].\n" \ + " :arg options: Enumerator in :ref:`rna_enum_property_flag_enum_items`.\n" \ " :type options: set\n" -static const EnumPropertyItem property_flag_override_items[] = { - {PROPOVERRIDE_OVERRIDABLE_LIBRARY, - "LIBRARY_OVERRIDABLE", - 0, - "Library Overridable", - "Make that property editable in library overrides of linked data-blocks"}, - {0, NULL, 0, NULL, NULL}, -}; - #define BPY_PROPDEF_OPTIONS_OVERRIDE_DOC \ - " :arg override: Enumerator in ['LIBRARY_OVERRIDABLE'].\n" \ + " :arg override: Enumerator in :ref:`rna_enum_property_override_flag_items`.\n" \ " :type override: 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"}, - {PROPOVERRIDE_LIBRARY_INSERTION, - "USE_INSERTION", - 0, - "Use Insertion", - "Allow users to add new items in that collection in library overrides"}, - {0, NULL, 0, NULL, NULL}, -}; - #define BPY_PROPDEF_OPTIONS_OVERRIDE_COLLECTION_DOC \ - " :arg override: Enumerator in ['LIBRARY_OVERRIDABLE', 'NO_PROPERTY_NAME', " \ - "'USE_INSERTION'].\n" \ + " :arg override: Enumerator in :ref:`rna_enum_property_override_flag_collection_items`.\n" \ " :type override: set\n" -/* subtypes */ -/* Keep in sync with RNA_types.h PropertySubType and rna_rna.c's rna_enum_property_subtype_items */ -static const EnumPropertyItem property_subtype_string_items[] = { - {PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""}, - {PROP_DIRPATH, "DIR_PATH", 0, "Directory Path", ""}, - {PROP_FILENAME, "FILE_NAME", 0, "Filename", ""}, - {PROP_BYTESTRING, "BYTE_STRING", 0, "Byte String", ""}, - {PROP_PASSWORD, "PASSWORD", 0, "Password", "A string that is displayed hidden ('********')"}, - - {PROP_NONE, "NONE", 0, "None", ""}, - {0, NULL, 0, NULL, NULL}, -}; - #define BPY_PROPDEF_SUBTYPE_STRING_DOC \ - " :arg subtype: Enumerator in ['FILE_PATH', 'DIR_PATH', 'FILE_NAME', 'BYTE_STRING', " \ - "'PASSWORD', 'NONE'].\n" \ + " :arg subtype: Enumerator in :ref:`rna_enum_property_subtype_string_items`.\n" \ " :type subtype: string\n" -static const EnumPropertyItem property_subtype_number_items[] = { - {PROP_PIXEL, "PIXEL", 0, "Pixel", ""}, - {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned", ""}, - {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, - {PROP_FACTOR, "FACTOR", 0, "Factor", ""}, - {PROP_ANGLE, "ANGLE", 0, "Angle", ""}, - {PROP_TIME, - "TIME", - 0, - "Time (Scene Relative)", - "Time specified in frames, converted to seconds based on scene frame rate"}, - {PROP_TIME_ABSOLUTE, - "TIME_ABSOLUTE", - 0, - "Time (Absolute)", - "Time specified in seconds, independent of the scene"}, - {PROP_DISTANCE, "DISTANCE", 0, "Distance", ""}, - {PROP_DISTANCE_CAMERA, "DISTANCE_CAMERA", 0, "Camera Distance", ""}, - {PROP_POWER, "POWER", 0, "Power", ""}, - {PROP_TEMPERATURE, "TEMPERATURE", 0, "Temperature", ""}, - - {PROP_NONE, "NONE", 0, "None", ""}, - {0, NULL, 0, NULL, NULL}, -}; - #define BPY_PROPDEF_SUBTYPE_NUMBER_DOC \ - " :arg subtype: Enumerator in ['PIXEL', 'UNSIGNED', 'PERCENTAGE', 'FACTOR', 'ANGLE', " \ - "'TIME', 'DISTANCE', 'DISTANCE_CAMERA', 'POWER', 'TEMPERATURE', 'NONE'].\n" \ + " :arg subtype: Enumerator in :ref:`rna_enum_property_subtype_number_items`.\n" \ " :type subtype: string\n" -static const EnumPropertyItem property_subtype_array_items[] = { - {PROP_COLOR, "COLOR", 0, "Color", ""}, - {PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, - {PROP_DIRECTION, "DIRECTION", 0, "Direction", ""}, - {PROP_VELOCITY, "VELOCITY", 0, "Velocity", ""}, - {PROP_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""}, - {PROP_MATRIX, "MATRIX", 0, "Matrix", ""}, - {PROP_EULER, "EULER", 0, "Euler", ""}, - {PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""}, - {PROP_AXISANGLE, "AXISANGLE", 0, "Axis Angle", ""}, - {PROP_XYZ, "XYZ", 0, "XYZ", ""}, - {PROP_XYZ_LENGTH, "XYZ_LENGTH", 0, "XYZ Length", ""}, - {PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Color Gamma", ""}, - {PROP_COORDS, "COORDINATES", 0, "Vector Coordinates", ""}, - {PROP_LAYER, "LAYER", 0, "Layer", ""}, - {PROP_LAYER_MEMBER, "LAYER_MEMBER", 0, "Layer Member", ""}, - - {PROP_NONE, "NONE", 0, "None", ""}, - {0, NULL, 0, NULL, NULL}, -}; - -#define BPY_PROPDEF_SUBTYPE_ARRAY_DOC \ - " :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', " \ - "'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', " \ - "'XYZ', 'XYZ_LENGTH', 'COLOR_GAMMA', 'COORDINATES', 'LAYER', 'LAYER_MEMBER', 'NONE'].\n" \ +#define BPY_PROPDEF_SUBTYPE_NUMBER_ARRAY_DOC \ + " :arg subtype: Enumerator in :ref:`rna_enum_property_subtype_number_array_items`.\n" \ " :type subtype: string\n" /** \} */ @@ -257,6 +139,11 @@ struct BPyPropStore { /** Wrap: #RNA_def_property_poll_runtime */ PyObject *poll_fn; } pointer_data; + /** #PROP_STRING type. */ + struct { + /** Wrap: #RNA_def_property_string_search_func_runtime */ + PyObject *search_fn; + } string_data; }; } py_data; }; @@ -1672,6 +1559,163 @@ static void bpy_prop_string_set_fn(struct PointerRNA *ptr, } } +static bool bpy_prop_string_visit_fn_call(PyObject *py_func, + PyObject *item, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data) +{ + const char *text; + const char *info = NULL; + + if (PyTuple_CheckExact(item)) { + /* Positional only. */ + static const char *_keywords[] = { + "", + "", + NULL, + }; + static _PyArg_Parser _parser = { + "s" /* `text` */ + "s" /* `info` */ + ":search", + _keywords, + 0, + }; + if (!_PyArg_ParseTupleAndKeywordsFast(item, NULL, &_parser, &text, &info)) { + PyC_Err_PrintWithFunc(py_func); + return false; + } + } + else { + text = PyUnicode_AsUTF8(item); + if (UNLIKELY(text == NULL)) { + PyErr_Clear(); + PyErr_Format(PyExc_TypeError, + "expected sequence of strings or tuple pairs of strings, not %.200s", + Py_TYPE(item)->tp_name); + PyC_Err_PrintWithFunc(py_func); + return false; + } + } + + StringPropertySearchVisitParams visit_params = {NULL}; + visit_params.text = text; + visit_params.info = info; + visit_fn(visit_user_data, &visit_params); + return true; +} + +static void bpy_prop_string_visit_for_search_fn(const struct bContext *C, + struct PointerRNA *ptr, + struct PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data) +{ + struct BPyPropStore *prop_store = RNA_property_py_data_get(prop); + PyObject *py_func; + PyObject *args; + PyObject *self; + PyObject *ret; + PyGILState_STATE gilstate; + PyObject *py_edit_text; + + BLI_assert(prop_store != NULL); + + if (C) { + bpy_context_set((struct bContext *)C, &gilstate); + } + else { + gilstate = PyGILState_Ensure(); + } + + py_func = prop_store->py_data.string_data.search_fn; + + args = PyTuple_New(3); + self = pyrna_struct_as_instance(ptr); + PyTuple_SET_ITEM(args, 0, self); + + Py_INCREF(bpy_context_module); + PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module); + + py_edit_text = PyUnicode_FromString(edit_text); + PyTuple_SET_ITEM(args, 2, py_edit_text); + + ret = PyObject_CallObject(py_func, args); + + Py_DECREF(args); + + if (ret == NULL) { + PyC_Err_PrintWithFunc(py_func); + } + else { + if (PyIter_Check(ret)) { + /* Iterators / generator types. */ + PyObject *it; + PyObject *(*iternext)(PyObject *); + it = PyObject_GetIter(ret); + if (it == NULL) { + PyC_Err_PrintWithFunc(py_func); + } + else { + iternext = *Py_TYPE(it)->tp_iternext; + for (;;) { + PyObject *py_text = iternext(it); + if (py_text == NULL) { + break; + } + const bool ok = bpy_prop_string_visit_fn_call( + py_func, py_text, visit_fn, visit_user_data); + Py_DECREF(py_text); + if (!ok) { + break; + } + } + Py_DECREF(it); + if (PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_StopIteration)) { + PyErr_Clear(); + } + else { + PyC_Err_PrintWithFunc(py_func); + } + } + } + } + else { + /* Sequence (typically list/tuple). */ + PyObject *ret_fast = PySequence_Fast( + ret, + "StringProperty(...): " + "return value from search callback was not a sequence, iterator or generator"); + if (ret_fast == NULL) { + PyC_Err_PrintWithFunc(py_func); + } + else { + const Py_ssize_t ret_num = PySequence_Fast_GET_SIZE(ret_fast); + PyObject **ret_fast_items = PySequence_Fast_ITEMS(ret_fast); + for (Py_ssize_t i = 0; i < ret_num; i++) { + const bool ok = bpy_prop_string_visit_fn_call( + py_func, ret_fast_items[i], visit_fn, visit_user_data); + if (!ok) { + break; + } + } + Py_DECREF(ret_fast); + } + } + + Py_DECREF(ret); + } + + if (C) { + bpy_context_clear((struct bContext *)C, &gilstate); + } + else { + PyGILState_Release(gilstate); + } +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -2352,11 +2396,14 @@ static void bpy_prop_callback_assign_float_array(struct PropertyRNA *prop, static void bpy_prop_callback_assign_string(struct PropertyRNA *prop, PyObject *get_fn, - PyObject *set_fn) + PyObject *set_fn, + 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; if (get_fn && get_fn != Py_None) { struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); @@ -2372,8 +2419,17 @@ static void bpy_prop_callback_assign_string(struct PropertyRNA *prop, rna_set_fn = bpy_prop_string_set_fn; ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn); } + if (search_fn) { + struct BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop); + + rna_search_fn = bpy_prop_string_visit_for_search_fn; + ASSIGN_PYOBJECT_INCREF(prop_store->py_data.string_data.search_fn, search_fn); + } RNA_def_property_string_funcs_runtime(prop, rna_get_fn, rna_length_fn, rna_set_fn); + if (rna_search_fn) { + RNA_def_property_string_search_func_runtime(prop, rna_search_fn, search_flag); + } } static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, @@ -2565,8 +2621,7 @@ static int bpy_prop_arg_parse_tag_defines(PyObject *o, void *p) " :type description: string\n" #define BPY_PROPDEF_UNIT_DOC \ - " :arg unit: Enumerator in ['NONE', 'LENGTH', 'AREA', 'VOLUME', 'ROTATION', 'TIME', " \ - "'VELOCITY', 'ACCELERATION', 'MASS', 'CAMERA', 'POWER'].\n" \ + " :arg unit: Enumerator in :ref:`rna_enum_property_unit_items`.\n" \ " :type unit: string\n" #define BPY_PROPDEF_NUM_MIN_DOC \ @@ -2628,6 +2683,24 @@ static int bpy_prop_arg_parse_tag_defines(PyObject *o, void *p) " This function must take 2 values (self, value) and return None.\n" \ " :type set: function\n" +#define BPY_PROPDEF_SEARCH_DOC \ + " :arg search: Function to be called to show candidates for this string (shown in the UI).\n" \ + " This function must take 3 values (self, context, edit_text)\n" \ + " and return a sequence, iterator or generator where each item must be:\n" \ + "\n" \ + " - A single string (representing a candidate to display).\n" \ + " - A tuple-pair of strings, where the first is a candidate and the second\n" \ + " is additional information about the candidate.\n" \ + " :type search: function\n" \ + " :arg search_options: Set of strings in:\n" \ + "\n" \ + " - 'SORT' sorts the resulting items.\n" \ + " - 'SUGGESTION' lets the user enter values not found in search candidates.\n" \ + " **WARNING** disabling this flag causes the search callback to run on redraw,\n" \ + " so only disable this flag if it's not likely to cause performance issues.\n" \ + "\n" \ + " :type search_options: set\n" + #define BPY_PROPDEF_POINTER_TYPE_DOC \ " :arg type: A subclass of :class:`bpy.types.PropertyGroup` or :class:`bpy.types.ID`.\n" \ " :type type: class\n" @@ -2697,18 +2770,18 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) bool default_value = false; PropertyRNA *prop; struct BPy_EnumProperty_Parse options_enum = { - .items = property_flag_items, + .items = rna_enum_property_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse override_enum = { - .items = property_flag_override_items, + .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 = property_subtype_number_items, + .items = rna_enum_property_subtype_number_items, .value = PROP_NONE, }; @@ -2822,7 +2895,7 @@ PyDoc_STRVAR( "\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_TAGS_DOC BPY_PROPDEF_SUBTYPE_NUMBER_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) { @@ -2845,18 +2918,18 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject PropertyRNA *prop; PyObject *default_py = NULL; struct BPy_EnumProperty_Parse options_enum = { - .items = property_flag_items, + .items = rna_enum_property_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse override_enum = { - .items = property_flag_override_items, + .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 = property_subtype_array_items, + .items = rna_enum_property_subtype_number_array_items, .value = PROP_NONE, }; PyObject *update_fn = NULL; @@ -3021,18 +3094,18 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) PropertyRNA *prop; struct BPy_EnumProperty_Parse options_enum = { - .items = property_flag_items, + .items = rna_enum_property_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse override_enum = { - .items = property_flag_override_items, + .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 = property_subtype_number_items, + .items = rna_enum_property_subtype_number_items, .value = PROP_NONE, }; PyObject *update_fn = NULL; @@ -3168,8 +3241,8 @@ PyDoc_STRVAR(BPy_IntVectorProperty_doc, " :type soft_min: int\n" BPY_PROPDEF_NUM_SOFTMAX_DOC " :type soft_max: int\n" BPY_PROPDEF_INT_STEP_DOC 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); + BPY_PROPDEF_SUBTYPE_NUMBER_ARRAY_DOC BPY_PROPDEF_VECSIZE_DOC + BPY_PROPDEF_UPDATE_DOC BPY_PROPDEF_GET_DOC BPY_PROPDEF_SET_DOC); static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw) { StructRNA *srna; @@ -3194,18 +3267,18 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject PyObject *default_py = NULL; struct BPy_EnumProperty_Parse options_enum = { - .items = property_flag_items, + .items = rna_enum_property_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse override_enum = { - .items = property_flag_override_items, + .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 = property_subtype_array_items, + .items = rna_enum_property_subtype_number_array_items, .value = PROP_NONE, }; PyObject *update_fn = NULL; @@ -3391,18 +3464,18 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) PropertyRNA *prop; struct BPy_EnumProperty_Parse options_enum = { - .items = property_flag_items, + .items = rna_enum_property_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse override_enum = { - .items = property_flag_override_items, + .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 = property_subtype_number_items, + .items = rna_enum_property_subtype_number_items, .value = PROP_NONE, }; struct BPy_EnumProperty_Parse unit_enum = { @@ -3536,8 +3609,9 @@ PyDoc_STRVAR(BPy_FloatVectorProperty_doc, " :type soft_min: float\n" BPY_PROPDEF_NUM_SOFTMAX_DOC " :type soft_max: float\n" BPY_PROPDEF_OPTIONS_DOC BPY_PROPDEF_OPTIONS_OVERRIDE_DOC BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_FLOAT_STEP_DOC BPY_PROPDEF_FLOAT_PREC_DOC - BPY_PROPDEF_SUBTYPE_ARRAY_DOC BPY_PROPDEF_UNIT_DOC BPY_PROPDEF_VECSIZE_DOC - BPY_PROPDEF_UPDATE_DOC BPY_PROPDEF_GET_DOC BPY_PROPDEF_SET_DOC); + BPY_PROPDEF_SUBTYPE_NUMBER_ARRAY_DOC BPY_PROPDEF_UNIT_DOC + BPY_PROPDEF_VECSIZE_DOC BPY_PROPDEF_UPDATE_DOC BPY_PROPDEF_GET_DOC + BPY_PROPDEF_SET_DOC); static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw) { StructRNA *srna; @@ -3563,18 +3637,18 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec PyObject *default_py = NULL; struct BPy_EnumProperty_Parse options_enum = { - .items = property_flag_items, + .items = rna_enum_property_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse override_enum = { - .items = property_flag_override_items, + .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 = property_subtype_array_items, + .items = rna_enum_property_subtype_number_array_items, .value = PROP_NONE, }; struct BPy_EnumProperty_Parse unit_enum = { @@ -3721,7 +3795,9 @@ PyDoc_STRVAR(BPy_StringProperty_doc, "subtype='NONE', " "update=None, " "get=None, " - "set=None)\n" + "set=None, " + "search=None, " + "search_options={'SUGGESTION'})\n" "\n" " Returns a new string property definition.\n" "\n" BPY_PROPDEF_NAME_DOC BPY_PROPDEF_DESC_DOC @@ -3730,7 +3806,7 @@ PyDoc_STRVAR(BPy_StringProperty_doc, " :arg maxlen: maximum length of the string.\n" " :type maxlen: int\n" BPY_PROPDEF_OPTIONS_DOC BPY_PROPDEF_OPTIONS_OVERRIDE_DOC BPY_PROPDEF_TAGS_DOC BPY_PROPDEF_SUBTYPE_STRING_DOC BPY_PROPDEF_UPDATE_DOC - BPY_PROPDEF_GET_DOC BPY_PROPDEF_SET_DOC); + BPY_PROPDEF_GET_DOC BPY_PROPDEF_SET_DOC BPY_PROPDEF_SEARCH_DOC); static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) { StructRNA *srna; @@ -3750,23 +3826,28 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw PropertyRNA *prop; struct BPy_EnumProperty_Parse options_enum = { - .items = property_flag_items, + .items = rna_enum_property_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse override_enum = { - .items = property_flag_override_items, + .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 = property_subtype_string_items, + .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, + }; static const char *_keywords[] = { "attr", @@ -3781,6 +3862,8 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw "update", "get", "set", + "search", + "search_options", NULL, }; static _PyArg_Parser _parser = { @@ -3797,6 +3880,8 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw "O" /* `update` */ "O" /* `get` */ "O" /* `set` */ + "O" /* `search` */ + "O&" /* `search_options` */ ":StringProperty", _keywords, 0, @@ -3820,7 +3905,10 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw &subtype_enum, &update_fn, &get_fn, - &set_fn)) { + &set_fn, + &search_fn, + pyrna_enum_bitfield_parse_set, + &search_options_enum)) { return NULL; } @@ -3833,6 +3921,9 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw if (bpy_prop_callback_check(set_fn, "set", 2) == -1) { return NULL; } + if (bpy_prop_callback_check(search_fn, "search", 3) == -1) { + return NULL; + } if (id_data.prop_free_handle != NULL) { RNA_def_property_free_identifier_deferred_finish(srna, id_data.prop_free_handle); @@ -3858,7 +3949,7 @@ 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); + bpy_prop_callback_assign_string(prop, get_fn, set_fn, search_fn, search_options_enum.value); RNA_def_property_duplicate_pointers(srna, prop); Py_RETURN_NONE; @@ -3941,11 +4032,11 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) PropertyRNA *prop; struct BPy_EnumProperty_Parse options_enum = { - .items = property_flag_enum_items, + .items = rna_enum_property_flag_enum_items, .value = 0, }; struct BPy_EnumProperty_Parse override_enum = { - .items = property_flag_override_items, + .items = rna_enum_property_override_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { @@ -4164,11 +4255,11 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) PyObject *type = Py_None; struct BPy_EnumProperty_Parse options_enum = { - .items = property_flag_items, + .items = rna_enum_property_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse override_enum = { - .items = property_flag_override_items, + .items = rna_enum_property_override_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { @@ -4301,11 +4392,11 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) PyObject *type = Py_None; struct BPy_EnumProperty_Parse options_enum = { - .items = property_flag_items, + .items = rna_enum_property_flag_items, .value = 0, }; struct BPy_EnumProperty_Parse override_enum = { - .items = property_flag_override_collection_items, + .items = rna_enum_property_override_flag_collection_items, .value = 0, }; struct BPy_EnumProperty_Parse_WithSRNA tags_enum = { |