27 #include "RNA_prototypes.h"
43 const char *p = *path;
44 while (*p && !
ELEM(*p,
'.',
'[')) {
55 char *buf = (
len + 1 < fixedlen) ? fixedbuf :
57 memcpy(buf, *path,
sizeof(
char) *
len);
94 const char *p = *path;
116 while (*p && (*p !=
']')) {
132 char *buf = (
len + 1 < fixedlen) ? fixedbuf :
140 p = (*path) +
len + 1;
143 memcpy(buf, *path,
sizeof(
char) *
len);
202 intkey = atoi(token);
203 if (intkey == 0 && (token[0] !=
'0' || token[1] !=
'\0')) {
214 if (token != fixedbuf) {
249 for (i = 0; i < dim; i++) {
268 temp_index = atoi(token);
270 if (temp_index == 0 && (token[0] !=
'0' || token[1] !=
'\0')) {
271 if (token != fixedbuf) {
293 if (token != fixedbuf) {
298 if (temp_index < 0 || temp_index >=
len[i]) {
302 index_arr[i] = temp_index;
316 for (i = dim - 1; i >= 0; i--) {
317 flat_index += index_arr[i] * totdim;
321 *r_index = flat_index;
355 const bool eval_pointer)
364 const bool do_item_ptr = r_item_ptr !=
NULL && !eval_pointer;
373 if (path ==
NULL || *path ==
'\0') {
382 const bool use_id_prop = (*path ==
'[');
391 char *token = use_id_prop ?
401 if (group && quoted) {
409 if (token != fixedbuf) {
418 prop_elem = MEM_cnew<PropertyElemRNA>(__func__);
419 prop_elem->
ptr = curptr;
420 prop_elem->
prop = prop;
421 prop_elem->
index = -1;
435 if (do_item_ptr || eval_pointer || *path !=
'\0') {
439 if (eval_pointer || *path !=
'\0') {
456 if (eval_pointer || *path !=
'\0') {
465 if (r_index || prop_elem) {
471 prop_elem->
index = index;
487 if (r_item_ptr && do_item_ptr) {
488 *r_item_ptr = nextptr;
491 if (prop_elem && (prop_elem->
ptr.
data != curptr.
data || prop_elem->
prop != prop ||
492 prop_elem->
index != index)) {
493 prop_elem = MEM_cnew<PropertyElemRNA>(__func__);
494 prop_elem->
ptr = curptr;
495 prop_elem->
prop = prop;
496 prop_elem->
index = index;
605 const bool has_key = (intkey > -1) || (strkey !=
nullptr);
611 const int strkey_esc_max_size = (strlen(strkey) * 2) + 1;
612 char *strkey_esc =
static_cast<char *
>(
BLI_array_alloca(strkey_esc, strkey_esc_max_size));
620 BLI_snprintf(appendstr,
sizeof(appendstr),
"%d", intkey);
638 const char *previous, *current;
659 if (token != fixedbuf) {
666 if (token && token != fixedbuf) {
685 if (i > 0 &&
result[i - 1] ==
'.') {
695 if (array_prop !=
NULL) {
707 if (
UNLIKELY(rna_path[0] ==
'\0')) {
710 size_t rna_path_len = (size_t)strlen(rna_path) - 1;
711 if (rna_path[rna_path_len] !=
']') {
715 const char *last_valid_index_token_start =
NULL;
716 while (rna_path_len--) {
717 switch (rna_path[rna_path_len]) {
719 if (rna_path_len <= 0 || rna_path[rna_path_len - 1] !=
']') {
720 return &rna_path[rna_path_len];
722 last_valid_index_token_start = &rna_path[rna_path_len];
737 return last_valid_index_token_start;
740 return last_valid_index_token_start;
757 bool is_first =
true;
767 link->
up = link_prev;
773 for (link = link_prev; link; link = link->
up) {
775 if (link->
index >= 0) {
809 link.
up = parent_link;
815 iter = iter->
next, i++) {
816 if (needle == iter) {
853 if ((path =
rna_idp_path(&child_ptr, iter, needle, &link))) {
869 for (j = 0; j < iter->
len; j++,
array++) {
933 *r_path =
"node_tree";
936 *r_path =
"collection";
947 return id_type->
owner_get(bmain,
id,
nullptr);
952 if (r_real_id !=
NULL) {
959 if (r_real_id !=
NULL) {
960 *r_real_id = real_id;
964 char *new_path =
NULL;
968 new_path =
BLI_sprintfN(
"%s%s%s", prefix, path[0] ==
'[' ?
"" :
".", path);
983 char *ptrpath =
NULL;
1033 const int index_dim,
1038 int i = totdims - 1;
1039 dimsize_step[i + 1] = 1;
1040 dimsize_step[i] = dimsize[i];
1042 dimsize_step[i] = dimsize[i] * dimsize_step[i + 1];
1044 while (++i != index_dim) {
1045 int index_round =
index / dimsize_step[i + 1];
1046 r_index_multi[i] = index_round;
1047 index -= (index_round * dimsize_step[i + 1]);
1065 for (
int i = 0,
offset = 0; (i < index_dim) && (
offset < index_str_len); i++) {
1067 &index_str[
offset], index_str_len -
offset,
"[%d]", index_multi[i]);
1077 const char *propname;
1078 char *ptrpath, *path;
1091 if (index_dim == 0) {
1092 index_str[0] =
'\0';
1096 ptr, prop, index_dim,
index, index_str,
sizeof(index_str));
1101 path =
BLI_sprintfN(
"%s.%s%s", ptrpath, propname, index_str);
1106 path =
BLI_sprintfN(
"%s[\"%s\"]%s", ptrpath, propname_esc, index_str);
1117 path =
BLI_sprintfN(
"[\"%s\"]%s", propname_esc, index_str);
1157 if (full_path ==
NULL) {
1168 path =
BLI_strdup(full_path + strlen(ref_path) + 1);
1194 char lib_filepath_esc[(
sizeof(
id->lib->filepath) * 2) + 4];
1197 memcpy(lib_filepath_esc,
", \"", 3);
1200 memcpy(lib_filepath_esc + ofs,
"\"", 2);
1203 lib_filepath_esc[0] =
'\0';
1206 char id_esc[(
sizeof(
id->name) - 2) * 2];
1249 const char *data_delim;
1250 const char *data_path;
1251 bool data_path_free;
1264 data_delim = (data_path[0] ==
'[') ?
"" :
".";
1265 data_path_free =
true;
1271 data_delim =
" ... ";
1276 data_path_free =
false;
1286 if (data_path_free) {
1310 if (data_path ==
NULL) {
#define IDP_IDPArray(prop)
struct IDProperty * IDP_GetPropertyFromGroup(const struct IDProperty *prop, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
const char * BKE_idtype_idcode_to_name_plural(short idcode)
const struct IDTypeInfo * BKE_idtype_get_info_from_id(const struct ID *id)
#define BLI_array_alloca(arr, realsize)
#define BLI_assert_msg(a, msg)
A dynamically sized string ADT.
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
#define LISTBASE_FOREACH_BACKWARD(type, var, list)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
size_t BLI_str_unescape(char *__restrict dst, const char *__restrict src, size_t src_maxncpy) ATTR_NONNULL()
size_t BLI_snprintf_rlen(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
const char * BLI_str_escape_find_quote(const char *str) ATTR_NONNULL()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
size_t size_t char size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL()
ID and Library types, which are fundamental for sdna.
#define ID_IS_LINKED(_id)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
#define RNA_POINTER_INVALIDATE(ptr)
#define RNA_MAX_ARRAY_LENGTH
#define RNA_MAX_ARRAY_DIMENSION
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
bool RNA_property_array_check(PropertyRNA *prop)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
bool RNA_struct_is_ID(const StructRNA *type)
const char * RNA_property_identifier(const PropertyRNA *prop)
PropertyRNA * rna_struct_find_nested(PointerRNA *ptr, StructRNA *srna)
PropertyType RNA_property_type(PropertyRNA *prop)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
IDProperty * RNA_struct_idprops(PointerRNA *ptr, bool create)
int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr)
int RNA_property_array_dimension(const PointerRNA *ptr, PropertyRNA *prop, int length[])
bool RNA_pointer_is_null(const PointerRNA *ptr)
bool RNA_property_collection_type_get(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
int RNA_property_array_item_index(PropertyRNA *prop, char name)
StructRNA RNA_PropertyGroup
char * RNA_path_full_struct_py(Main *bmain, const PointerRNA *ptr)
static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, PropertyRNA *prop, int *r_index)
static char * rna_path_token_in_brackets(const char **path, char *fixedbuf, int fixedlen, bool *r_quoted)
static bool rna_path_parse(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index, PointerRNA *r_item_ptr, ListBase *r_elements, const bool eval_pointer)
bool RNA_path_resolve_elements(PointerRNA *ptr, const char *path, ListBase *r_elements)
char * RNA_path_from_ID_to_struct(const PointerRNA *ptr)
static UNUSED_FUNCTION_WITH_RETURN_TYPE(char *, RNA_path_back)(const char *path)
char * RNA_path_append(const char *path, const PointerRNA *UNUSED(ptr), PropertyRNA *prop, int intkey, const char *strkey)
char * RNA_path_struct_property_py(PointerRNA *ptr, PropertyRNA *prop, int index)
bool RNA_path_resolve_full_maybe_null(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
char * RNA_path_from_ID_to_property_index(const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index)
char * RNA_path_full_property_py(Main *bmain, const PointerRNA *ptr, PropertyRNA *prop, int index)
char * RNA_path_from_struct_to_idproperty(PointerRNA *ptr, IDProperty *needle)
char * RNA_path_resolve_from_type_to_property(const PointerRNA *ptr, PropertyRNA *prop, const StructRNA *type)
ID * RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path)
bool RNA_path_resolve_property_and_item_pointer(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, PointerRNA *r_item_ptr)
static char * rna_path_from_ID_to_idpgroup(const PointerRNA *ptr)
char * RNA_path_full_ID_py(Main *bmain, ID *id)
static char * rna_idp_path_create(IDP_Chain *child_link)
bool RNA_path_resolve_full(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
static char * rna_path_token(const char **path, char *fixedbuf, int fixedlen)
static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_nextptr)
char * RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop)
static char * rna_prepend_real_ID_path(Main *bmain, ID *id, char *path, ID **r_real_id)
char * RNA_path_property_py(const PointerRNA *UNUSED(ptr), PropertyRNA *prop, int index)
struct IDP_Chain IDP_Chain
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
static void rna_path_array_multi_string_from_flat_index(const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index, char *index_str, int index_str_len)
bool RNA_path_resolve_property_full(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
char * RNA_path_from_real_ID_to_property_index(Main *bmain, const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index, ID **r_real_id)
static char * rna_idp_path(PointerRNA *ptr, IDProperty *haystack, IDProperty *needle, IDP_Chain *parent_link)
bool RNA_path_resolve_property_and_item_pointer_full(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index, PointerRNA *r_item_ptr)
const char * RNA_path_array_index_token_find(const char *rna_path, const PropertyRNA *array_prop)
char * RNA_path_from_real_ID_to_struct(Main *bmain, const PointerRNA *ptr, struct ID **r_real)
char * RNA_path_full_property_py_ex(Main *bmain, const PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback)
bool RNA_path_resolve(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
static void rna_path_array_multi_from_flat_index(const int dimsize[RNA_MAX_ARRAY_LENGTH], const int totdims, const int index_dim, int index, int r_index_multi[RNA_MAX_ARRAY_LENGTH])
IDTypeEmbeddedOwnerGetFunction owner_get
unsigned int arraydimension
struct StructRNA * nested