diff options
Diffstat (limited to 'source/blender/makesrna/RNA_access.h')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 95 |
1 files changed, 69 insertions, 26 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index e1e655fad4b..67605201a9f 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -177,7 +177,7 @@ int RNA_property_multi_array_length(PointerRNA *ptr, PropertyRNA *prop, int dime /** * Used by BPY to make an array from the python object. */ -int RNA_property_array_dimension(PointerRNA *ptr, PropertyRNA *prop, int length[]); +int RNA_property_array_dimension(const PointerRNA *ptr, PropertyRNA *prop, int length[]); char RNA_property_array_item_char(PropertyRNA *prop, int index); int RNA_property_array_item_index(PropertyRNA *prop, char name); @@ -284,7 +284,7 @@ bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, const int i */ bool RNA_property_editable_flag(PointerRNA *ptr, PropertyRNA *prop); -bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop); +bool RNA_property_animateable(const PointerRNA *ptr, PropertyRNA *prop); bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop); /** * \note Does not take into account editable status, this has to be checked separately @@ -358,6 +358,21 @@ char *RNA_property_string_get_alloc( PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len); void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value); void RNA_property_string_set_bytes(PointerRNA *ptr, PropertyRNA *prop, const char *value, int len); + +eStringPropertySearchFlag RNA_property_string_search_flag(PropertyRNA *prop); +/** + * Search candidates for string `prop` by calling `visit_fn` with each string. + * Typically these strings are collected in `visit_user_data` in a format defined by the caller. + * + * See #PropStringSearchFunc for details. + */ +void RNA_property_string_search(const struct bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data); + /** * \return the length without `\0` terminator. */ @@ -402,7 +417,9 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop); * without having to iterate over items in the collection (needed for some kinds of collections). */ bool RNA_property_collection_is_empty(PointerRNA *ptr, PropertyRNA *prop); -int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *t_ptr); +int RNA_property_collection_lookup_index(PointerRNA *ptr, + PropertyRNA *prop, + const PointerRNA *t_ptr); int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, @@ -468,11 +485,23 @@ bool RNA_property_assign_default(PointerRNA *ptr, PropertyRNA *prop); * UI code or Actions, though efficiency is a concern. */ char *RNA_path_append( - const char *path, PointerRNA *ptr, PropertyRNA *prop, int intkey, const char *strkey); + const char *path, const PointerRNA *ptr, PropertyRNA *prop, int intkey, const char *strkey); #if 0 /* UNUSED. */ char *RNA_path_back(const char *path); #endif +/** + * Search for the start of the 'rna array index' part of the given `rna_path`. + * + * Given the root RNA pointer and resolved RNA property, and the RNA path, return the first + * character in `rna_path` that is part of the array index for the given property. Return NULL if + * none can be found, e.g. because the property is not an RNA array. + * + * \param array_prop if not NULL, the PropertyRNA assumed to be the last one from the RNA path. + * Only used to ensure it is a valid array property. + */ +const char *RNA_path_array_index_token_find(const char *rna_path, const PropertyRNA *array_prop); + /* RNA_path_resolve() variants only ensure that a valid pointer (and optionally property) exist. */ /** @@ -486,7 +515,10 @@ char *RNA_path_back(const char *path); * \note Assumes all pointers provided are valid * \return True if path can be resolved to a valid "pointer + property" OR "pointer only" */ -bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop); +bool RNA_path_resolve(const PointerRNA *ptr, + const char *path, + PointerRNA *r_ptr, + PropertyRNA **r_prop); /** * Resolve the given RNA Path to find the pointer and/or property + array index @@ -495,16 +527,22 @@ bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prop * \note Assumes all pointers provided are valid. * \return True if path can be resolved to a valid "pointer + property" OR "pointer only" */ -bool RNA_path_resolve_full( - PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index); +bool RNA_path_resolve_full(const PointerRNA *ptr, + const char *path, + PointerRNA *r_ptr, + PropertyRNA **r_prop, + int *r_index); /** * A version of #RNA_path_resolve_full doesn't check the value of #PointerRNA.data. * * \note While it's correct to ignore the value of #PointerRNA.data * most callers need to know if the resulting pointer was found and not null. */ -bool RNA_path_resolve_full_maybe_null( - PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index); +bool RNA_path_resolve_full_maybe_null(const PointerRNA *ptr, + const char *path, + PointerRNA *r_ptr, + PropertyRNA **r_prop, + int *r_index); /* RNA_path_resolve_property() variants ensure that pointer + property both exist. */ @@ -516,7 +554,7 @@ bool RNA_path_resolve_full_maybe_null( * \note Assumes all pointers provided are valid * \return True only if both a valid pointer and property are found after resolving the path */ -bool RNA_path_resolve_property(PointerRNA *ptr, +bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop); @@ -529,8 +567,11 @@ bool RNA_path_resolve_property(PointerRNA *ptr, * \note Assumes all pointers provided are valid * \return True only if both a valid pointer and property are found after resolving the path */ -bool RNA_path_resolve_property_full( - PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index); +bool RNA_path_resolve_property_full(const PointerRNA *ptr, + const char *path, + PointerRNA *r_ptr, + PropertyRNA **r_prop, + int *r_index); /* RNA_path_resolve_property_and_item_pointer() variants ensure that pointer + property both exist, * and resolve last Pointer value if possible (Pointer prop or item of a Collection prop). */ @@ -547,7 +588,7 @@ bool RNA_path_resolve_property_full( * You must check for its validity before use! * \return True only if both a valid pointer and property are found after resolving the path */ -bool RNA_path_resolve_property_and_item_pointer(PointerRNA *ptr, +bool RNA_path_resolve_property_and_item_pointer(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, @@ -566,7 +607,7 @@ bool RNA_path_resolve_property_and_item_pointer(PointerRNA *ptr, * You must check for its validity before use! * \return True only if both a valid pointer and property are found after resolving the path */ -bool RNA_path_resolve_property_and_item_pointer_full(PointerRNA *ptr, +bool RNA_path_resolve_property_and_item_pointer_full(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, @@ -614,21 +655,23 @@ struct ID *RNA_find_real_ID_and_path(struct Main *bmain, struct ID *id, const ch char *RNA_path_from_ID_to_struct(const PointerRNA *ptr); -char *RNA_path_from_real_ID_to_struct(struct Main *bmain, PointerRNA *ptr, struct ID **r_real); +char *RNA_path_from_real_ID_to_struct(struct Main *bmain, + const PointerRNA *ptr, + struct ID **r_real); -char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop); +char *RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop); /** * \param index_dim: The dimension to show, 0 disables. 1 for 1d array, 2 for 2d. etc. * \param index: The *flattened* index to use when \a `index_dim > 0`, * this is expanded when used with multi-dimensional arrays. */ -char *RNA_path_from_ID_to_property_index(PointerRNA *ptr, +char *RNA_path_from_ID_to_property_index(const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index); char *RNA_path_from_real_ID_to_property_index(struct Main *bmain, - PointerRNA *ptr, + const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index, @@ -638,8 +681,8 @@ char *RNA_path_from_real_ID_to_property_index(struct Main *bmain, * \return the path to given ptr/prop from the closest ancestor of given type, * if any (else return NULL). */ -char *RNA_path_resolve_from_type_to_property(struct PointerRNA *ptr, - struct PropertyRNA *prop, +char *RNA_path_resolve_from_type_to_property(const PointerRNA *ptr, + PropertyRNA *prop, const struct StructRNA *type); /** @@ -651,27 +694,27 @@ char *RNA_path_full_ID_py(struct Main *bmain, struct ID *id); * Get the ID.struct as a python representation, eg: * bpy.data.foo["bar"].some_struct */ -char *RNA_path_full_struct_py(struct Main *bmain, struct PointerRNA *ptr); +char *RNA_path_full_struct_py(struct Main *bmain, const PointerRNA *ptr); /** * Get the ID.struct.property as a python representation, eg: * bpy.data.foo["bar"].some_struct.some_prop[10] */ char *RNA_path_full_property_py_ex( - struct Main *bmain, PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback); + struct Main *bmain, const PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback); char *RNA_path_full_property_py(struct Main *bmain, - struct PointerRNA *ptr, - struct PropertyRNA *prop, + const PointerRNA *ptr, + PropertyRNA *prop, int index); /** * Get the struct.property as a python representation, eg: * some_struct.some_prop[10] */ -char *RNA_path_struct_property_py(struct PointerRNA *ptr, struct PropertyRNA *prop, int index); +char *RNA_path_struct_property_py(PointerRNA *ptr, PropertyRNA *prop, int index); /** * Get the struct.property as a python representation, eg: * some_prop[10] */ -char *RNA_path_property_py(const struct PointerRNA *ptr, struct PropertyRNA *prop, int index); +char *RNA_path_property_py(const PointerRNA *ptr, PropertyRNA *prop, int index); /* Quick name based property access * |