Blender  V3.3
rna_rna.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <stdlib.h>
8 
9 #include <CLG_log.h>
10 
11 #include "DNA_ID.h"
12 
13 #include "BLI_utildefines.h"
14 
15 #include "RNA_access.h"
16 #include "RNA_define.h"
17 #include "RNA_enum_types.h"
18 
19 #include "rna_internal.h"
20 
21 /* -------------------------------------------------------------------- */
25 /* Reuse for dynamic types. */
27  {0, NULL, 0, NULL, NULL},
28 };
29 
30 /* Reuse for dynamic types with default value */
32  {0, "DEFAULT", 0, "Default", ""},
33  {0, NULL, 0, NULL, NULL},
34 };
35 
38 /* -------------------------------------------------------------------- */
43  {PROP_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
44  {PROP_INT, "INT", 0, "Integer", ""},
45  {PROP_FLOAT, "FLOAT", 0, "Float", ""},
46  {PROP_STRING, "STRING", 0, "String", ""},
47  {PROP_ENUM, "ENUM", 0, "Enumeration", ""},
48  {PROP_POINTER, "POINTER", 0, "Pointer", ""},
49  {PROP_COLLECTION, "COLLECTION", 0, "Collection", ""},
50  {0, NULL, 0, NULL, NULL},
51 };
52 
53 /* Wraps multiple enums onto a single line in a way that is difficult to read.
54  * NOTE: these enums are split up based on their use in `bpy.props` Python module. */
55 
56 /* clang-format off */
57 #define RNA_ENUM_PROPERTY_SUBTYPE_STRING_ITEMS \
58  {PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""}, \
59  {PROP_DIRPATH, "DIR_PATH", 0, "Directory Path", ""}, \
60  {PROP_FILENAME, "FILE_NAME", 0, "File Name", ""}, \
61  {PROP_BYTESTRING, "BYTE_STRING", 0, "Byte String", ""}, \
62  {PROP_PASSWORD, "PASSWORD", 0, "Password", "A string that is displayed hidden ('********')"}
63 
64 #define RNA_ENUM_PROPERTY_SUBTYPE_NUMBER_ITEMS \
65  {PROP_PIXEL, "PIXEL", 0, "Pixel", ""}, \
66  {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned", ""}, \
67  {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, \
68  {PROP_FACTOR, "FACTOR", 0, "Factor", ""}, \
69  {PROP_ANGLE, "ANGLE", 0, "Angle", ""}, \
70  {PROP_TIME, "TIME", 0, "Time (Scene Relative)", \
71  "Time specified in frames, converted to seconds based on scene frame rate"}, \
72  {PROP_TIME_ABSOLUTE, "TIME_ABSOLUTE", 0, "Time (Absolute)", \
73  "Time specified in seconds, independent of the scene"}, \
74  {PROP_DISTANCE, "DISTANCE", 0, "Distance", ""}, \
75  {PROP_DISTANCE_CAMERA, "DISTANCE_CAMERA", 0, "Camera Distance", ""}, \
76  {PROP_POWER, "POWER", 0, "Power", ""}, \
77  {PROP_TEMPERATURE, "TEMPERATURE", 0, "Temperature", ""}
78 
79 #define RNA_ENUM_PROPERTY_SUBTYPE_NUMBER_ARRAY_ITEMS \
80  {PROP_COLOR, "COLOR", 0, "Color", ""}, \
81  {PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, \
82  {PROP_DIRECTION, "DIRECTION", 0, "Direction", ""}, \
83  {PROP_VELOCITY, "VELOCITY", 0, "Velocity", ""}, \
84  {PROP_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""}, \
85  {PROP_MATRIX, "MATRIX", 0, "Matrix", ""}, \
86  {PROP_EULER, "EULER", 0, "Euler Angles", ""}, \
87  {PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""}, \
88  {PROP_AXISANGLE, "AXISANGLE", 0, "Axis-Angle", ""}, \
89  {PROP_XYZ, "XYZ", 0, "XYZ", ""}, \
90  {PROP_XYZ_LENGTH, "XYZ_LENGTH", 0, "XYZ Length", ""}, \
91  {PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Color", ""}, \
92  {PROP_COORDS, "COORDINATES", 0, "Coordinates", ""}, \
93  /* Boolean. */ \
94  {PROP_LAYER, "LAYER", 0, "Layer", ""}, \
95  {PROP_LAYER_MEMBER, "LAYER_MEMBER", 0, "Layer Member", ""}
96 
97 /* clang-format on */
98 
101 
102  {PROP_NONE, "NONE", 0, "None", ""},
103  {0, NULL, 0, NULL, NULL},
104 };
105 
108 
109  {PROP_NONE, "NONE", 0, "None", ""},
110  {0, NULL, 0, NULL, NULL},
111 };
112 
115 
116  {PROP_NONE, "NONE", 0, "None", ""},
117  {0, NULL, 0, NULL, NULL},
118 };
119 
121  {PROP_NONE, "NONE", 0, "None", ""},
122 
123  /* String. */
125 
126  /* Number. */
128 
129  /* Number array. */
131 
132  {0, NULL, 0, NULL, NULL},
133 };
134 
136  {PROP_UNIT_NONE, "NONE", 0, "None", ""},
137  {PROP_UNIT_LENGTH, "LENGTH", 0, "Length", ""},
138  {PROP_UNIT_AREA, "AREA", 0, "Area", ""},
139  {PROP_UNIT_VOLUME, "VOLUME", 0, "Volume", ""},
140  {PROP_UNIT_ROTATION, "ROTATION", 0, "Rotation", ""},
141  {PROP_UNIT_TIME, "TIME", 0, "Time (Scene Relative)", ""},
142  {PROP_UNIT_TIME_ABSOLUTE, "TIME_ABSOLUTE", 0, "Time (Absolute)", ""},
143  {PROP_UNIT_VELOCITY, "VELOCITY", 0, "Velocity", ""},
144  {PROP_UNIT_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""},
145  {PROP_UNIT_MASS, "MASS", 0, "Mass", ""},
146  {PROP_UNIT_CAMERA, "CAMERA", 0, "Camera", ""},
147  {PROP_UNIT_POWER, "POWER", 0, "Power", ""},
148  {PROP_UNIT_TEMPERATURE, "TEMPERATURE", 0, "Temperature", ""},
149  {0, NULL, 0, NULL, NULL},
150 };
151 
153  {PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""},
154  {PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", ""},
155  {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""},
156  {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", ""},
157  {PROP_PROPORTIONAL, "PROPORTIONAL", 0, "Adjust values proportionally to each other", ""},
159  "TEXTEDIT_UPDATE",
160  0,
161  "Update on every keystroke in textedit 'mode'",
162  ""},
163  {0, NULL, 0, NULL, NULL},
164 };
165 
168  {PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""},
169  {PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", ""},
170  {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""},
171  {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", ""},
172  {PROP_ENUM_FLAG, "ENUM_FLAG", 0, "Enum Flag", ""},
173  {0, NULL, 0, NULL, NULL},
174 };
175 
178  "LIBRARY_OVERRIDABLE",
179  0,
180  "Library Overridable",
181  "Make that property editable in library overrides of linked data-blocks"},
182  {0, NULL, 0, NULL, NULL},
183 };
184 
187  "LIBRARY_OVERRIDABLE",
188  0,
189  "Library Overridable",
190  "Make that property editable in library overrides of linked data-blocks"},
192  "NO_PROPERTY_NAME",
193  0,
194  "No Name",
195  "Do not use the names of the items, only their indices in the collection"},
197  "USE_INSERTION",
198  0,
199  "Use Insertion",
200  "Allow users to add new items in that collection in library overrides"},
201  {0, NULL, 0, NULL, NULL},
202 };
203 
205  {PROP_STRING_SEARCH_SORT, "SORT", 0, "Sort Search Results", ""},
207  "SUGGESTION",
208  0,
209  "Suggestion",
210  "Search results are suggestions (other values may be entered)"},
211 
212  {0, NULL, 0, NULL, NULL},
213 };
214 
217 #ifdef RNA_RUNTIME
218 # include "BLI_ghash.h"
219 # include "BLI_string.h"
220 # include "MEM_guardedalloc.h"
221 
222 # include "BKE_idprop.h"
223 # include "BKE_lib_override.h"
224 
225 static CLG_LogRef LOG_COMPARE_OVERRIDE = {"rna.rna_compare_override"};
226 
227 /* Struct */
228 
229 static void rna_Struct_identifier_get(PointerRNA *ptr, char *value)
230 {
231  strcpy(value, ((StructRNA *)ptr->data)->identifier);
232 }
233 
234 static int rna_Struct_identifier_length(PointerRNA *ptr)
235 {
236  return strlen(((StructRNA *)ptr->data)->identifier);
237 }
238 
239 static void rna_Struct_description_get(PointerRNA *ptr, char *value)
240 {
241  strcpy(value, ((StructRNA *)ptr->data)->description);
242 }
243 
244 static int rna_Struct_description_length(PointerRNA *ptr)
245 {
246  return strlen(((StructRNA *)ptr->data)->description);
247 }
248 
249 static void rna_Struct_name_get(PointerRNA *ptr, char *value)
250 {
251  strcpy(value, ((StructRNA *)ptr->data)->name);
252 }
253 
254 static int rna_Struct_name_length(PointerRNA *ptr)
255 {
256  return strlen(((StructRNA *)ptr->data)->name);
257 }
258 
259 static void rna_Struct_translation_context_get(PointerRNA *ptr, char *value)
260 {
261  strcpy(value, ((StructRNA *)ptr->data)->translation_context);
262 }
263 
264 static int rna_Struct_translation_context_length(PointerRNA *ptr)
265 {
266  return strlen(((StructRNA *)ptr->data)->translation_context);
267 }
268 
269 static PointerRNA rna_Struct_base_get(PointerRNA *ptr)
270 {
271  return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((StructRNA *)ptr->data)->base);
272 }
273 
274 static PointerRNA rna_Struct_nested_get(PointerRNA *ptr)
275 {
276  return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((StructRNA *)ptr->data)->nested);
277 }
278 
279 static PointerRNA rna_Struct_name_property_get(PointerRNA *ptr)
280 {
281  return rna_pointer_inherit_refine(ptr, &RNA_Property, ((StructRNA *)ptr->data)->nameproperty);
282 }
283 
284 /* Struct property iteration. This is quite complicated, the purpose is to
285  * iterate over properties of all inheritance levels, and for each struct to
286  * also iterator over id properties not known by RNA. */
287 
288 static int rna_idproperty_known(CollectionPropertyIterator *iter, void *data)
289 {
290  IDProperty *idprop = (IDProperty *)data;
291  PropertyRNA *prop;
292  StructRNA *ptype = iter->builtin_parent.type;
293 
294  /* function to skip any id properties that are already known by RNA,
295  * for the second loop where we go over unknown id properties */
296  do {
297  for (prop = ptype->cont.properties.first; prop; prop = prop->next) {
298  if ((prop->flag_internal & PROP_INTERN_BUILTIN) == 0 &&
299  STREQ(prop->identifier, idprop->name)) {
300  return 1;
301  }
302  }
303  } while ((ptype = ptype->base));
304 
305  return 0;
306 }
307 
308 static int rna_property_builtin(CollectionPropertyIterator *UNUSED(iter), void *data)
309 {
310  PropertyRNA *prop = (PropertyRNA *)data;
311 
312  /* function to skip builtin rna properties */
313 
314  return (prop->flag_internal & PROP_INTERN_BUILTIN);
315 }
316 
317 static int rna_function_builtin(CollectionPropertyIterator *UNUSED(iter), void *data)
318 {
319  FunctionRNA *func = (FunctionRNA *)data;
320 
321  /* function to skip builtin rna functions */
322 
323  return (func->flag & FUNC_BUILTIN);
324 }
325 
326 static void rna_inheritance_next_level_restart(CollectionPropertyIterator *iter,
327  IteratorSkipFunc skip,
328  int funcs)
329 {
330  /* RNA struct inheritance */
331  while (!iter->valid && iter->level > 0) {
332  StructRNA *srna;
333  int i;
334 
335  srna = (StructRNA *)iter->parent.data;
336  iter->level--;
337  for (i = iter->level; i > 0; i--) {
338  srna = srna->base;
339  }
340 
342 
343  if (funcs) {
344  rna_iterator_listbase_begin(iter, &srna->functions, skip);
345  }
346  else {
347  rna_iterator_listbase_begin(iter, &srna->cont.properties, skip);
348  }
349  }
350 }
351 
352 static void rna_inheritance_properties_listbase_begin(CollectionPropertyIterator *iter,
353  ListBase *lb,
354  IteratorSkipFunc skip)
355 {
356  rna_iterator_listbase_begin(iter, lb, skip);
357  rna_inheritance_next_level_restart(iter, skip, 0);
358 }
359 
360 static void rna_inheritance_properties_listbase_next(CollectionPropertyIterator *iter,
361  IteratorSkipFunc skip)
362 {
364  rna_inheritance_next_level_restart(iter, skip, 0);
365 }
366 
367 static void rna_inheritance_functions_listbase_begin(CollectionPropertyIterator *iter,
368  ListBase *lb,
369  IteratorSkipFunc skip)
370 {
371  rna_iterator_listbase_begin(iter, lb, skip);
372  rna_inheritance_next_level_restart(iter, skip, 1);
373 }
374 
375 static void rna_inheritance_functions_listbase_next(CollectionPropertyIterator *iter,
376  IteratorSkipFunc skip)
377 {
379  rna_inheritance_next_level_restart(iter, skip, 1);
380 }
381 
382 static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
383 {
384  ListBaseIterator *internal = &iter->internal.listbase;
385  IDProperty *group;
386 
387  if (internal->flag) {
388  /* id properties */
390  }
391  else {
392  /* regular properties */
393  rna_inheritance_properties_listbase_next(iter, rna_property_builtin);
394 
395  /* try id properties */
396  if (!iter->valid) {
397  group = RNA_struct_idprops(&iter->builtin_parent, 0);
398 
399  if (group) {
401  rna_iterator_listbase_begin(iter, &group->data.group, rna_idproperty_known);
402  internal = &iter->internal.listbase;
403  internal->flag = 1;
404  }
405  }
406  }
407 }
408 
409 static void rna_Struct_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
410 {
411  StructRNA *srna;
412 
413  /* here ptr->data should always be the same as iter->parent.type */
414  srna = (StructRNA *)ptr->data;
415 
416  while (srna->base) {
417  iter->level++;
418  srna = srna->base;
419  }
420 
421  rna_inheritance_properties_listbase_begin(iter, &srna->cont.properties, rna_property_builtin);
422 }
423 
424 static PointerRNA rna_Struct_properties_get(CollectionPropertyIterator *iter)
425 {
426  ListBaseIterator *internal = &iter->internal.listbase;
427 
428  /* we return either PropertyRNA* or IDProperty*, the rna_access.c
429  * functions can handle both as PropertyRNA* with some tricks */
430  return rna_pointer_inherit_refine(&iter->parent, &RNA_Property, internal->link);
431 }
432 
433 static void rna_Struct_functions_next(CollectionPropertyIterator *iter)
434 {
435  rna_inheritance_functions_listbase_next(iter, rna_function_builtin);
436 }
437 
438 static void rna_Struct_functions_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
439 {
440  StructRNA *srna;
441 
442  /* here ptr->data should always be the same as iter->parent.type */
443  srna = (StructRNA *)ptr->data;
444 
445  while (srna->base) {
446  iter->level++;
447  srna = srna->base;
448  }
449 
450  rna_inheritance_functions_listbase_begin(iter, &srna->functions, rna_function_builtin);
451 }
452 
453 static PointerRNA rna_Struct_functions_get(CollectionPropertyIterator *iter)
454 {
455  ListBaseIterator *internal = &iter->internal.listbase;
456 
457  /* we return either PropertyRNA* or IDProperty*, the rna_access.c
458  * functions can handle both as PropertyRNA* with some tricks */
459  return rna_pointer_inherit_refine(&iter->parent, &RNA_Function, internal->link);
460 }
461 
462 static void rna_Struct_property_tags_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
463 {
464  /* here ptr->data should always be the same as iter->parent.type */
465  StructRNA *srna = (StructRNA *)ptr->data;
466  const EnumPropertyItem *tag_defines = RNA_struct_property_tag_defines(srna);
467  unsigned int tag_count = tag_defines ? RNA_enum_items_count(tag_defines) : 0;
468 
470  iter, (void *)tag_defines, sizeof(EnumPropertyItem), tag_count, 0, NULL);
471 }
472 
473 /* Builtin properties iterator re-uses the Struct properties iterator, only
474  * difference is that we need to set the ptr data to the type of the struct
475  * whose properties we want to iterate over. */
476 
478 {
479  PointerRNA newptr;
480 
481  /* we create a new pointer with the type as the data */
482  newptr.type = &RNA_Struct;
483  newptr.data = ptr->type;
484 
485  if (ptr->type->flag & STRUCT_ID) {
486  newptr.owner_id = ptr->data;
487  }
488  else {
489  newptr.owner_id = NULL;
490  }
491 
492  iter->parent = newptr;
493  iter->builtin_parent = *ptr;
494 
495  rna_Struct_properties_begin(iter, &newptr);
496 }
497 
499 {
500  rna_Struct_properties_next(iter);
501 }
502 
504 {
505  return rna_Struct_properties_get(iter);
506 }
507 
508 int rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
509 {
510  StructRNA *srna;
511  PropertyRNA *prop;
512  PointerRNA propptr = {NULL};
513 
514  srna = ptr->type;
515 
516  do {
517  if (srna->cont.prophash) {
518  prop = BLI_ghash_lookup(srna->cont.prophash, (void *)key);
519 
520  if (prop) {
521  propptr.type = &RNA_Property;
522  propptr.data = prop;
523 
524  *r_ptr = propptr;
525  return true;
526  }
527  }
528  else {
529  for (prop = srna->cont.properties.first; prop; prop = prop->next) {
530  if (!(prop->flag_internal & PROP_INTERN_BUILTIN) && STREQ(prop->identifier, key)) {
531  propptr.type = &RNA_Property;
532  propptr.data = prop;
533 
534  *r_ptr = propptr;
535  return true;
536  }
537  }
538  }
539  } while ((srna = srna->base));
540  return false;
541 }
542 
544 {
545  return rna_pointer_inherit_refine(ptr, &RNA_Struct, ptr->type);
546 }
547 
548 /* Property */
549 
550 static StructRNA *rna_Property_refine(PointerRNA *ptr)
551 {
552  PropertyRNA *prop = (PropertyRNA *)ptr->data;
553 
554  switch (RNA_property_type(prop)) {
555  case PROP_BOOLEAN:
556  return &RNA_BoolProperty;
557  case PROP_INT:
558  return &RNA_IntProperty;
559  case PROP_FLOAT:
560  return &RNA_FloatProperty;
561  case PROP_STRING:
562  return &RNA_StringProperty;
563  case PROP_ENUM:
564  return &RNA_EnumProperty;
565  case PROP_POINTER:
566  return &RNA_PointerProperty;
567  case PROP_COLLECTION:
568  return &RNA_CollectionProperty;
569  default:
570  return &RNA_Property;
571  }
572 }
573 
574 static void rna_Property_identifier_get(PointerRNA *ptr, char *value)
575 {
576  PropertyRNA *prop = (PropertyRNA *)ptr->data;
577  strcpy(value, RNA_property_identifier(prop));
578 }
579 
580 static int rna_Property_identifier_length(PointerRNA *ptr)
581 {
582  PropertyRNA *prop = (PropertyRNA *)ptr->data;
583  return strlen(RNA_property_identifier(prop));
584 }
585 
586 static void rna_Property_name_get(PointerRNA *ptr, char *value)
587 {
588  PropertyRNA *prop = (PropertyRNA *)ptr->data;
589  const char *name = RNA_property_ui_name_raw(prop);
590  strcpy(value, name ? name : "");
591 }
592 
593 static int rna_Property_name_length(PointerRNA *ptr)
594 {
595  PropertyRNA *prop = (PropertyRNA *)ptr->data;
596  const char *name = RNA_property_ui_name_raw(prop);
597  return name ? strlen(name) : 0;
598 }
599 
600 static void rna_Property_description_get(PointerRNA *ptr, char *value)
601 {
602  PropertyRNA *prop = (PropertyRNA *)ptr->data;
603  const char *description = RNA_property_ui_description_raw(prop);
604  strcpy(value, description ? description : "");
605 }
606 static int rna_Property_description_length(PointerRNA *ptr)
607 {
608  PropertyRNA *prop = (PropertyRNA *)ptr->data;
609  const char *description = RNA_property_ui_description_raw(prop);
610  return description ? strlen(description) : 0;
611 }
612 
613 static void rna_Property_translation_context_get(PointerRNA *ptr, char *value)
614 {
615  PropertyRNA *prop = (PropertyRNA *)ptr->data;
616  strcpy(value, RNA_property_translation_context(prop));
617 }
618 
619 static int rna_Property_translation_context_length(PointerRNA *ptr)
620 {
621  PropertyRNA *prop = (PropertyRNA *)ptr->data;
622  return strlen(RNA_property_translation_context(prop));
623 }
624 
625 static int rna_Property_type_get(PointerRNA *ptr)
626 {
627  PropertyRNA *prop = (PropertyRNA *)ptr->data;
628  return RNA_property_type(prop);
629 }
630 
631 static int rna_Property_subtype_get(PointerRNA *ptr)
632 {
633  PropertyRNA *prop = (PropertyRNA *)ptr->data;
634  return RNA_property_subtype(prop);
635 }
636 
637 static PointerRNA rna_Property_srna_get(PointerRNA *ptr)
638 {
639  PropertyRNA *prop = (PropertyRNA *)ptr->data;
640  prop = rna_ensure_property(prop);
641  return rna_pointer_inherit_refine(ptr, &RNA_Struct, prop->srna);
642 }
643 
644 static int rna_Property_unit_get(PointerRNA *ptr)
645 {
646  PropertyRNA *prop = (PropertyRNA *)ptr->data;
647  return RNA_property_unit(prop);
648 }
649 
650 static int rna_Property_icon_get(PointerRNA *ptr)
651 {
652  PropertyRNA *prop = (PropertyRNA *)ptr->data;
653  return RNA_property_ui_icon(prop);
654 }
655 
656 static bool rna_Property_readonly_get(PointerRNA *ptr)
657 {
658  PropertyRNA *prop = (PropertyRNA *)ptr->data;
659 
660  /* don't use this because it will call functions that check the internal
661  * data for introspection we only need to know if it can be edited so the
662  * flag is better for this */
663  /* return RNA_property_editable(ptr, prop); */
664  return (prop->flag & PROP_EDITABLE) == 0;
665 }
666 
667 static bool rna_Property_animatable_get(PointerRNA *ptr)
668 {
669  PropertyRNA *prop = (PropertyRNA *)ptr->data;
670 
671  return (prop->flag & PROP_ANIMATABLE) != 0;
672 }
673 
674 static bool rna_Property_overridable_get(PointerRNA *ptr)
675 {
676  PropertyRNA *prop = (PropertyRNA *)ptr->data;
677 
678  IDProperty *idprop = rna_idproperty_check(&prop, ptr);
679 
680  return idprop != NULL ? (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0 :
682 }
683 
684 static bool rna_Property_use_output_get(PointerRNA *ptr)
685 {
686  PropertyRNA *prop = (PropertyRNA *)ptr->data;
687  return (prop->flag_parameter & PARM_OUTPUT) != 0;
688 }
689 
690 static bool rna_Property_is_required_get(PointerRNA *ptr)
691 {
692  PropertyRNA *prop = (PropertyRNA *)ptr->data;
693  return (prop->flag_parameter & PARM_REQUIRED) != 0;
694 }
695 
696 static bool rna_Property_is_argument_optional_get(PointerRNA *ptr)
697 {
698  PropertyRNA *prop = (PropertyRNA *)ptr->data;
700 }
701 
702 static bool rna_Property_is_never_none_get(PointerRNA *ptr)
703 {
704  PropertyRNA *prop = (PropertyRNA *)ptr->data;
705  return (prop->flag & PROP_NEVER_NULL) != 0;
706 }
707 
708 static bool rna_Property_is_hidden_get(PointerRNA *ptr)
709 {
710  PropertyRNA *prop = (PropertyRNA *)ptr->data;
711  return (prop->flag & PROP_HIDDEN) != 0;
712 }
713 
714 static bool rna_Property_is_skip_save_get(PointerRNA *ptr)
715 {
716  PropertyRNA *prop = (PropertyRNA *)ptr->data;
717  return (prop->flag & PROP_SKIP_SAVE) != 0;
718 }
719 
720 static bool rna_Property_is_enum_flag_get(PointerRNA *ptr)
721 {
722  PropertyRNA *prop = (PropertyRNA *)ptr->data;
723  return (prop->flag & PROP_ENUM_FLAG) != 0;
724 }
725 
726 static bool rna_Property_is_library_editable_flag_get(PointerRNA *ptr)
727 {
728  PropertyRNA *prop = (PropertyRNA *)ptr->data;
729  return (prop->flag & PROP_LIB_EXCEPTION) != 0;
730 }
731 
732 static int rna_Property_tags_get(PointerRNA *ptr)
733 {
734  return RNA_property_tags(ptr->data);
735 }
736 
737 static const EnumPropertyItem *rna_Property_tags_itemf(bContext *UNUSED(C),
738  PointerRNA *ptr,
739  PropertyRNA *UNUSED(prop),
740  bool *r_free)
741 {
742  PropertyRNA *this_prop = (PropertyRNA *)ptr->data;
743  const StructRNA *srna = RNA_property_pointer_type(ptr, this_prop);
744  EnumPropertyItem *prop_tags;
745  EnumPropertyItem tmp = {0, "", 0, "", ""};
746  int totitem = 0;
747 
748  for (const EnumPropertyItem *struct_tags = RNA_struct_property_tag_defines(srna);
749  struct_tags != NULL && struct_tags->identifier != NULL;
750  struct_tags++) {
751  memcpy(&tmp, struct_tags, sizeof(tmp));
752  RNA_enum_item_add(&prop_tags, &totitem, &tmp);
753  }
754  RNA_enum_item_end(&prop_tags, &totitem);
755  *r_free = true;
756 
757  return prop_tags;
758 }
759 
760 static int rna_Property_array_length_get(PointerRNA *ptr)
761 {
762  PropertyRNA *prop = (PropertyRNA *)ptr->data;
763  prop = rna_ensure_property(prop);
764  return prop->totarraylength;
765 }
766 
767 static void rna_Property_array_dimensions_get(PointerRNA *ptr,
768  int dimensions[RNA_MAX_ARRAY_DIMENSION])
769 {
770  PropertyRNA *prop = (PropertyRNA *)ptr->data;
771  prop = rna_ensure_property(prop);
772 
773  if (prop->arraydimension > 1) {
774  for (int i = RNA_MAX_ARRAY_DIMENSION; i--;) {
775  dimensions[i] = (i >= prop->arraydimension) ? 0 : prop->arraylength[i];
776  }
777  }
778  else {
779  memset(dimensions, 0, sizeof(*dimensions) * RNA_MAX_ARRAY_DIMENSION);
780  dimensions[0] = prop->totarraylength;
781  }
782 }
783 
784 static bool rna_Property_is_registered_get(PointerRNA *ptr)
785 {
786  PropertyRNA *prop = (PropertyRNA *)ptr->data;
787  return (prop->flag & PROP_REGISTER) != 0;
788 }
789 
790 static bool rna_Property_is_registered_optional_get(PointerRNA *ptr)
791 {
792  PropertyRNA *prop = (PropertyRNA *)ptr->data;
793  return (prop->flag & PROP_REGISTER_OPTIONAL) != 0;
794 }
795 
796 static bool rna_Property_is_runtime_get(PointerRNA *ptr)
797 {
798  PropertyRNA *prop = (PropertyRNA *)ptr->data;
800 }
801 
802 static bool rna_BoolProperty_default_get(PointerRNA *ptr)
803 {
804  PropertyRNA *prop = (PropertyRNA *)ptr->data;
805  prop = rna_ensure_property(prop);
806  return ((BoolPropertyRNA *)prop)->defaultvalue;
807 }
808 
809 static int rna_IntProperty_default_get(PointerRNA *ptr)
810 {
811  PropertyRNA *prop = (PropertyRNA *)ptr->data;
812  prop = rna_ensure_property(prop);
813  return ((IntPropertyRNA *)prop)->defaultvalue;
814 }
815 /* int/float/bool */
816 static int rna_NumberProperty_default_array_get_length(const PointerRNA *ptr,
818 {
819  PropertyRNA *prop = (PropertyRNA *)ptr->data;
820  prop = rna_ensure_property(prop);
821 
822  length[0] = prop->totarraylength;
823 
824  return length[0];
825 }
826 static bool rna_NumberProperty_is_array_get(PointerRNA *ptr)
827 {
828  PropertyRNA *prop = (PropertyRNA *)ptr->data;
829 
830  return RNA_property_array_check(prop);
831 }
832 
833 static void rna_IntProperty_default_array_get(PointerRNA *ptr, int *values)
834 {
835  PropertyRNA *prop = (PropertyRNA *)ptr->data;
836  prop = rna_ensure_property(prop);
837  if (prop->totarraylength > 0) {
838  PointerRNA null_ptr = PointerRNA_NULL;
839  RNA_property_int_get_default_array(&null_ptr, prop, values);
840  }
841 }
842 
843 static void rna_BoolProperty_default_array_get(PointerRNA *ptr, bool *values)
844 {
845  PropertyRNA *prop = (PropertyRNA *)ptr->data;
846  prop = rna_ensure_property(prop);
847  if (prop->totarraylength > 0) {
848  PointerRNA null_ptr = PointerRNA_NULL;
849  RNA_property_boolean_get_default_array(&null_ptr, prop, values);
850  }
851 }
852 
853 static void rna_FloatProperty_default_array_get(PointerRNA *ptr, float *values)
854 {
855  PropertyRNA *prop = (PropertyRNA *)ptr->data;
856  prop = rna_ensure_property(prop);
857  if (prop->totarraylength > 0) {
858  PointerRNA null_ptr = PointerRNA_NULL;
859  RNA_property_float_get_default_array(&null_ptr, prop, values);
860  }
861 }
862 
863 static int rna_IntProperty_hard_min_get(PointerRNA *ptr)
864 {
865  PropertyRNA *prop = (PropertyRNA *)ptr->data;
866  prop = rna_ensure_property(prop);
867  return ((IntPropertyRNA *)prop)->hardmin;
868 }
869 
870 static int rna_IntProperty_hard_max_get(PointerRNA *ptr)
871 {
872  PropertyRNA *prop = (PropertyRNA *)ptr->data;
873  prop = rna_ensure_property(prop);
874  return ((IntPropertyRNA *)prop)->hardmax;
875 }
876 
877 static int rna_IntProperty_soft_min_get(PointerRNA *ptr)
878 {
879  PropertyRNA *prop = (PropertyRNA *)ptr->data;
880  prop = rna_ensure_property(prop);
881  return ((IntPropertyRNA *)prop)->softmin;
882 }
883 
884 static int rna_IntProperty_soft_max_get(PointerRNA *ptr)
885 {
886  PropertyRNA *prop = (PropertyRNA *)ptr->data;
887  prop = rna_ensure_property(prop);
888  return ((IntPropertyRNA *)prop)->softmax;
889 }
890 
891 static int rna_IntProperty_step_get(PointerRNA *ptr)
892 {
893  PropertyRNA *prop = (PropertyRNA *)ptr->data;
894  prop = rna_ensure_property(prop);
895  return ((IntPropertyRNA *)prop)->step;
896 }
897 
898 static float rna_FloatProperty_default_get(PointerRNA *ptr)
899 {
900  PropertyRNA *prop = (PropertyRNA *)ptr->data;
901  prop = rna_ensure_property(prop);
902  return ((FloatPropertyRNA *)prop)->defaultvalue;
903 }
904 static float rna_FloatProperty_hard_min_get(PointerRNA *ptr)
905 {
906  PropertyRNA *prop = (PropertyRNA *)ptr->data;
907  prop = rna_ensure_property(prop);
908  return ((FloatPropertyRNA *)prop)->hardmin;
909 }
910 
911 static float rna_FloatProperty_hard_max_get(PointerRNA *ptr)
912 {
913  PropertyRNA *prop = (PropertyRNA *)ptr->data;
914  prop = rna_ensure_property(prop);
915  return ((FloatPropertyRNA *)prop)->hardmax;
916 }
917 
918 static float rna_FloatProperty_soft_min_get(PointerRNA *ptr)
919 {
920  PropertyRNA *prop = (PropertyRNA *)ptr->data;
921  prop = rna_ensure_property(prop);
922  return ((FloatPropertyRNA *)prop)->softmin;
923 }
924 
925 static float rna_FloatProperty_soft_max_get(PointerRNA *ptr)
926 {
927  PropertyRNA *prop = (PropertyRNA *)ptr->data;
928  prop = rna_ensure_property(prop);
929  return ((FloatPropertyRNA *)prop)->softmax;
930 }
931 
932 static float rna_FloatProperty_step_get(PointerRNA *ptr)
933 {
934  PropertyRNA *prop = (PropertyRNA *)ptr->data;
935  prop = rna_ensure_property(prop);
936  return ((FloatPropertyRNA *)prop)->step;
937 }
938 
939 static int rna_FloatProperty_precision_get(PointerRNA *ptr)
940 {
941  PropertyRNA *prop = (PropertyRNA *)ptr->data;
942  prop = rna_ensure_property(prop);
943  return ((FloatPropertyRNA *)prop)->precision;
944 }
945 
946 static void rna_StringProperty_default_get(PointerRNA *ptr, char *value)
947 {
948  PropertyRNA *prop = (PropertyRNA *)ptr->data;
949  prop = rna_ensure_property(prop);
950  strcpy(value, ((StringPropertyRNA *)prop)->defaultvalue);
951 }
952 static int rna_StringProperty_default_length(PointerRNA *ptr)
953 {
954  PropertyRNA *prop = (PropertyRNA *)ptr->data;
955  prop = rna_ensure_property(prop);
956  return strlen(((StringPropertyRNA *)prop)->defaultvalue);
957 }
958 
959 static int rna_StringProperty_max_length_get(PointerRNA *ptr)
960 {
961  PropertyRNA *prop = (PropertyRNA *)ptr->data;
962  prop = rna_ensure_property(prop);
963  return ((StringPropertyRNA *)prop)->maxlength;
964 }
965 
966 static const EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C,
967  PointerRNA *ptr,
968  PropertyRNA *prop_parent,
969  bool *r_free)
970 {
971  PropertyRNA *prop = (PropertyRNA *)ptr->data;
972  EnumPropertyRNA *eprop;
973 
974  prop = rna_ensure_property(prop);
975  eprop = (EnumPropertyRNA *)prop;
976 
977  /* incompatible default attributes */
978  if ((prop_parent->flag & PROP_ENUM_FLAG) != (prop->flag & PROP_ENUM_FLAG)) {
979  return DummyRNA_NULL_items;
980  }
981 
982  if ((eprop->item_fn == NULL) || (eprop->item_fn == rna_EnumProperty_default_itemf) ||
983  (ptr->type == &RNA_EnumProperty) || (C == NULL)) {
984  if (eprop->item) {
985  return eprop->item;
986  }
987  }
988 
989  return eprop->item_fn(C, ptr, prop, r_free);
990 }
991 
992 /* XXX: not sure this is needed? */
993 static int rna_EnumProperty_default_get(PointerRNA *ptr)
994 {
995  PropertyRNA *prop = (PropertyRNA *)ptr->data;
996  prop = rna_ensure_property(prop);
997  return ((EnumPropertyRNA *)prop)->defaultvalue;
998 }
999 
1000 static int rna_enum_check_separator(CollectionPropertyIterator *UNUSED(iter), void *data)
1001 {
1003 
1004  return (item->identifier[0] == 0);
1005 }
1006 
1007 static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1008 {
1009  PropertyRNA *prop = (PropertyRNA *)ptr->data;
1010  /* EnumPropertyRNA *eprop; */ /* UNUSED */
1011  const EnumPropertyItem *item = NULL;
1012  int totitem;
1013  bool free;
1014 
1015  prop = rna_ensure_property(prop);
1016  /* eprop = (EnumPropertyRNA *)prop; */
1017 
1019  NULL, ptr, prop, STREQ(iter->prop->identifier, "enum_items_static"), &item, &totitem, &free);
1021  iter, (void *)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator);
1022 }
1023 
1024 static void rna_EnumPropertyItem_identifier_get(PointerRNA *ptr, char *value)
1025 {
1026  strcpy(value, ((EnumPropertyItem *)ptr->data)->identifier);
1027 }
1028 
1029 static int rna_EnumPropertyItem_identifier_length(PointerRNA *ptr)
1030 {
1031  return strlen(((EnumPropertyItem *)ptr->data)->identifier);
1032 }
1033 
1034 static void rna_EnumPropertyItem_name_get(PointerRNA *ptr, char *value)
1035 {
1036  const EnumPropertyItem *eprop = ptr->data;
1037  /* Name can be NULL in the case of separators
1038  * which are exposed via `_bpy.rna_enum_items_static`. */
1039  if (eprop->name) {
1040  strcpy(value, eprop->name);
1041  }
1042  else {
1043  value[0] = '\0';
1044  }
1045 }
1046 
1047 static int rna_EnumPropertyItem_name_length(PointerRNA *ptr)
1048 {
1049  const EnumPropertyItem *eprop = ptr->data;
1050  if (eprop->name) {
1051  return strlen(eprop->name);
1052  }
1053  return 0;
1054 }
1055 
1056 static void rna_EnumPropertyItem_description_get(PointerRNA *ptr, char *value)
1057 {
1058  const EnumPropertyItem *eprop = ptr->data;
1059 
1060  if (eprop->description) {
1061  strcpy(value, eprop->description);
1062  }
1063  else {
1064  value[0] = '\0';
1065  }
1066 }
1067 
1068 static int rna_EnumPropertyItem_description_length(PointerRNA *ptr)
1069 {
1071 
1072  if (eprop->description) {
1073  return strlen(eprop->description);
1074  }
1075  return 0;
1076 }
1077 
1078 static int rna_EnumPropertyItem_value_get(PointerRNA *ptr)
1079 {
1080  return ((EnumPropertyItem *)ptr->data)->value;
1081 }
1082 
1083 static int rna_EnumPropertyItem_icon_get(PointerRNA *ptr)
1084 {
1085  return ((EnumPropertyItem *)ptr->data)->icon;
1086 }
1087 
1088 static PointerRNA rna_PointerProperty_fixed_type_get(PointerRNA *ptr)
1089 {
1090  PropertyRNA *prop = (PropertyRNA *)ptr->data;
1091  prop = rna_ensure_property(prop);
1092  return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((PointerPropertyRNA *)prop)->type);
1093 }
1094 
1095 static PointerRNA rna_CollectionProperty_fixed_type_get(PointerRNA *ptr)
1096 {
1097  PropertyRNA *prop = (PropertyRNA *)ptr->data;
1098  prop = rna_ensure_property(prop);
1099  return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((CollectionPropertyRNA *)prop)->item_type);
1100 }
1101 
1102 /* Function */
1103 
1104 static void rna_Function_identifier_get(PointerRNA *ptr, char *value)
1105 {
1106  strcpy(value, ((FunctionRNA *)ptr->data)->identifier);
1107 }
1108 
1109 static int rna_Function_identifier_length(PointerRNA *ptr)
1110 {
1111  return strlen(((FunctionRNA *)ptr->data)->identifier);
1112 }
1113 
1114 static void rna_Function_description_get(PointerRNA *ptr, char *value)
1115 {
1116  strcpy(value, ((FunctionRNA *)ptr->data)->description);
1117 }
1118 
1119 static int rna_Function_description_length(PointerRNA *ptr)
1120 {
1121  return strlen(((FunctionRNA *)ptr->data)->description);
1122 }
1123 
1124 static void rna_Function_parameters_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1125 {
1127  iter, &((FunctionRNA *)ptr->data)->cont.properties, rna_property_builtin);
1128 }
1129 
1130 static bool rna_Function_registered_get(PointerRNA *ptr)
1131 {
1132  FunctionRNA *func = (FunctionRNA *)ptr->data;
1133  return 0 != (func->flag & FUNC_REGISTER);
1134 }
1135 
1136 static bool rna_Function_registered_optional_get(PointerRNA *ptr)
1137 {
1138  FunctionRNA *func = (FunctionRNA *)ptr->data;
1139  return 0 != (func->flag & (FUNC_REGISTER_OPTIONAL & ~FUNC_REGISTER));
1140 }
1141 
1142 static bool rna_Function_no_self_get(PointerRNA *ptr)
1143 {
1144  FunctionRNA *func = (FunctionRNA *)ptr->data;
1145  return !(func->flag & FUNC_NO_SELF);
1146 }
1147 
1148 static int rna_Function_use_self_type_get(PointerRNA *ptr)
1149 {
1150  FunctionRNA *func = (FunctionRNA *)ptr->data;
1151  return 0 != (func->flag & FUNC_USE_SELF_TYPE);
1152 }
1153 
1154 /* Blender RNA */
1155 
1156 static int rna_struct_is_publc(CollectionPropertyIterator *UNUSED(iter), void *data)
1157 {
1158  StructRNA *srna = data;
1159 
1160  return !(srna->flag & STRUCT_PUBLIC_NAMESPACE);
1161 }
1162 
1163 static void rna_BlenderRNA_structs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1164 {
1165  BlenderRNA *brna = ptr->data;
1166  rna_iterator_listbase_begin(iter, &brna->structs, rna_struct_is_publc);
1167 }
1168 
1169 /* optional, for faster lookups */
1170 static int rna_BlenderRNA_structs_length(PointerRNA *ptr)
1171 {
1172  BlenderRNA *brna = ptr->data;
1174  return brna->structs_len;
1175 }
1176 static int rna_BlenderRNA_structs_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
1177 {
1178  BlenderRNA *brna = ptr->data;
1179  StructRNA *srna = index < brna->structs_len ? BLI_findlink(&brna->structs, index) : NULL;
1180  if (srna != NULL) {
1181  RNA_pointer_create(NULL, &RNA_Struct, srna, r_ptr);
1182  return true;
1183  }
1184  else {
1185  return false;
1186  }
1187 }
1188 static int rna_BlenderRNA_structs_lookup_string(PointerRNA *ptr,
1189  const char *key,
1190  PointerRNA *r_ptr)
1191 {
1192  BlenderRNA *brna = ptr->data;
1193  StructRNA *srna = BLI_ghash_lookup(brna->structs_map, (void *)key);
1194  if (srna != NULL) {
1195  RNA_pointer_create(NULL, &RNA_Struct, srna, r_ptr);
1196  return true;
1197  }
1198 
1199  return false;
1200 }
1201 
1202 /* Default override (and compare) callbacks. */
1203 
1204 /* Ensures it makes sense to go inside the pointers to compare their content
1205  * (if they are IDs, or have different names or RNA type, then this would be meaningless). */
1206 static bool rna_property_override_diff_propptr_validate_diffing(PointerRNA *propptr_a,
1207  PointerRNA *propptr_b,
1208  const bool no_ownership,
1209  const bool no_prop_name,
1210  bool *r_is_id,
1211  bool *r_is_null,
1212  bool *r_is_type_diff,
1213  char **r_propname_a,
1214  char *propname_a_buff,
1215  size_t propname_a_buff_size,
1216  char **r_propname_b,
1217  char *propname_b_buff,
1218  size_t propname_b_buff_size)
1219 {
1220  BLI_assert(propptr_a != NULL);
1221 
1222  bool is_valid_for_diffing = true;
1223  const bool do_force_name = !no_prop_name && r_propname_a != NULL;
1224 
1225  if (do_force_name) {
1226  BLI_assert(r_propname_a != NULL);
1227  BLI_assert(r_propname_b != NULL);
1228  }
1229 
1230  *r_is_id = *r_is_null = *r_is_type_diff = false;
1231 
1232  /* Beware, PointerRNA_NULL has no type and is considered a 'blank page'! */
1233  if (ELEM(NULL, propptr_a->type, propptr_a->data)) {
1234  if (ELEM(NULL, propptr_b, propptr_b->type, propptr_b->data)) {
1235  *r_is_null = true;
1236  }
1237  else {
1238  *r_is_id = RNA_struct_is_ID(propptr_b->type);
1239  *r_is_null = true;
1240  *r_is_type_diff = propptr_a->type != propptr_b->type;
1241  }
1242  is_valid_for_diffing = false;
1243  }
1244  else {
1245  *r_is_id = RNA_struct_is_ID(propptr_a->type);
1246  *r_is_null = (ELEM(NULL, propptr_b, propptr_b->type, propptr_b->data));
1247  *r_is_type_diff = (propptr_b == NULL || propptr_b->type != propptr_a->type);
1248  is_valid_for_diffing = !((*r_is_id && no_ownership) || *r_is_null);
1249  }
1250 
1251  if (propptr_b == NULL || propptr_a->type != propptr_b->type) {
1252  *r_is_type_diff = true;
1253  is_valid_for_diffing = false;
1254  // printf("%s: different pointer RNA types\n", rna_path ? rna_path : "<UNKNOWN>");
1255  }
1256 
1257  /* We do a generic quick first comparison checking for "name" and/or "type" properties.
1258  * We assume that is any of those are false, then we are not handling the same data.
1259  * This helps a lot in library override case, especially to detect inserted items in collections.
1260  */
1261  if (!no_prop_name && (is_valid_for_diffing || do_force_name)) {
1262  PropertyRNA *nameprop_a = (propptr_a->type != NULL) ?
1263  RNA_struct_name_property(propptr_a->type) :
1264  NULL;
1265  PropertyRNA *nameprop_b = (propptr_b != NULL && propptr_b->type != NULL) ?
1266  RNA_struct_name_property(propptr_b->type) :
1267  NULL;
1268 
1269  int propname_a_len = 0, propname_b_len = 0;
1270  char *propname_a = NULL;
1271  char *propname_b = NULL;
1272  char buff_a[4096];
1273  char buff_b[4096];
1274  if (nameprop_a != NULL) {
1275  if (r_propname_a == NULL && propname_a_buff == NULL) {
1276  propname_a_buff = buff_a;
1277  propname_a_buff_size = sizeof(buff_a);
1278  }
1279 
1280  propname_a = RNA_property_string_get_alloc(
1281  propptr_a, nameprop_a, propname_a_buff, propname_a_buff_size, &propname_a_len);
1282  // printf("propname_a = %s\n", propname_a ? propname_a : "<NONE>");
1283 
1284  if (r_propname_a != NULL) {
1285  *r_propname_a = propname_a;
1286  }
1287  }
1288  // else printf("item of type %s a has no name property!\n", propptr_a->type->name);
1289  if (nameprop_b != NULL) {
1290  if (r_propname_b == NULL && propname_b_buff == NULL) {
1291  propname_b_buff = buff_b;
1292  propname_b_buff_size = sizeof(buff_b);
1293  }
1294 
1295  propname_b = RNA_property_string_get_alloc(
1296  propptr_b, nameprop_b, propname_b_buff, propname_b_buff_size, &propname_b_len);
1297 
1298  if (r_propname_b != NULL) {
1299  *r_propname_b = propname_b;
1300  }
1301  }
1302  if (propname_a != NULL && propname_b != NULL) {
1303  if (propname_a_len != propname_b_len || propname_a[0] != propname_b[0] ||
1304  !STREQ(propname_a, propname_b)) {
1305  is_valid_for_diffing = false;
1306  // printf("%s: different names\n", rna_path ? rna_path : "<UNKNOWN>");
1307  }
1308  }
1309  }
1310 
1311  if (*r_is_id) {
1312  BLI_assert(propptr_a->data == propptr_a->owner_id && propptr_b->data == propptr_b->owner_id);
1313  }
1314 
1315  return is_valid_for_diffing;
1316 }
1317 
1318 /* Used for both Pointer and Collection properties. */
1319 static int rna_property_override_diff_propptr(Main *bmain,
1320  ID *owner_id_a,
1321  ID *owner_id_b,
1322  PointerRNA *propptr_a,
1323  PointerRNA *propptr_b,
1324  eRNACompareMode mode,
1325  const bool no_ownership,
1326  const bool no_prop_name,
1327  IDOverrideLibrary *override,
1328  const char *rna_path,
1329  size_t rna_path_len,
1330  const uint property_type,
1331  const char *rna_itemname_a,
1332  const char *rna_itemname_b,
1333  const int rna_itemindex_a,
1334  const int rna_itemindex_b,
1335  const int flags,
1336  bool *r_override_changed)
1337 {
1338  BLI_assert(ELEM(property_type, PROP_POINTER, PROP_COLLECTION));
1339 
1340  const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 &&
1341  rna_path != NULL;
1342 
1343  bool is_id = false;
1344  bool is_null = false;
1345  bool is_type_diff = false;
1346  /* If false, it means that the whole data itself is different,
1347  * so no point in going inside of it at all! */
1348  bool is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(propptr_a,
1349  propptr_b,
1350  no_ownership,
1351  no_prop_name,
1352  &is_id,
1353  &is_null,
1354  &is_type_diff,
1355  NULL,
1356  NULL,
1357  0,
1358  NULL,
1359  NULL,
1360  0);
1361 
1362  if (is_id) {
1363  /* Owned IDs (the ones we want to actually compare in depth, instead of just comparing pointer
1364  * values) should be always properly tagged as 'virtual' overrides. */
1365  ID *id = propptr_a->owner_id;
1366  if (id != NULL && !ID_IS_OVERRIDE_LIBRARY(id)) {
1367  id = propptr_b->owner_id;
1368  if (id != NULL && !ID_IS_OVERRIDE_LIBRARY(id)) {
1369  id = NULL;
1370  }
1371  }
1372 
1373  BLI_assert(no_ownership || id == NULL || ID_IS_OVERRIDE_LIBRARY_VIRTUAL(id));
1374  UNUSED_VARS_NDEBUG(id);
1375  }
1376 
1377  if (override) {
1378  if (no_ownership || is_null || is_type_diff || !is_valid_for_diffing) {
1379  /* In case this pointer prop does not own its data (or one is NULL), do not compare structs!
1380  * This is a quite safe path to infinite loop, among other nasty issues.
1381  * Instead, just compare pointers themselves. */
1382  const int comp = (propptr_a->data != propptr_b->data);
1383 
1384  if (do_create && comp != 0) {
1385  bool created = false;
1387  override, rna_path, &created);
1388 
1389  /* If not yet overridden, or if we are handling sub-items (inside a collection)... */
1390  if (op != NULL) {
1391  if (created || op->rna_prop_type == 0) {
1392  op->rna_prop_type = property_type;
1393  }
1394  else {
1395  BLI_assert(op->rna_prop_type == property_type);
1396  }
1397 
1399  if (created || rna_itemname_a != NULL || rna_itemname_b != NULL ||
1400  rna_itemindex_a != -1 || rna_itemindex_b != -1) {
1403  rna_itemname_b,
1404  rna_itemname_a,
1405  rna_itemindex_b,
1406  rna_itemindex_a,
1407  true,
1408  NULL,
1409  &created);
1410  /* Do not use BKE_lib_override_library_operations_tag here, we do not want to validate
1411  * as used all of its operations. */
1414  if (r_override_changed) {
1415  *r_override_changed = created;
1416  }
1417  }
1418  else {
1420  }
1421 
1422  if (is_id && no_ownership) {
1423  if (opop == NULL) {
1425  rna_itemname_b,
1426  rna_itemname_a,
1427  rna_itemindex_b,
1428  rna_itemindex_a,
1429  true,
1430  NULL);
1431  BLI_assert(opop != NULL);
1432  }
1433 
1434  BLI_assert(propptr_a->data == propptr_a->owner_id);
1435  BLI_assert(propptr_b->data == propptr_b->owner_id);
1436  ID *id_a = propptr_a->data;
1437  ID *id_b = propptr_b->data;
1438  if (ELEM(NULL, id_a, id_b)) {
1439  /* In case one of the pointer is NULL and not the other, we consider that the
1440  * override is not matching its reference anymore. */
1442  }
1443  else if ((owner_id_a->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) != 0 ||
1444  (owner_id_b->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) != 0) {
1445  /* In case one of the owner of the checked property is tagged as needing resync, do
1446  * not change the 'match reference' status of its ID pointer properties overrides,
1447  * since many non-matching ones are likely due to missing resync. */
1448  CLOG_INFO(&LOG_COMPARE_OVERRIDE,
1449  4,
1450  "Not checking matching ID pointer properties, since owner %s is tagged as "
1451  "needing resync.\n",
1452  id_a->name);
1453  }
1454  else if (id_a->override_library != NULL && id_a->override_library->reference == id_b) {
1456  }
1457  else if (id_b->override_library != NULL && id_b->override_library->reference == id_a) {
1459  }
1460  else {
1462  }
1463  }
1464  }
1465  }
1466 
1467  return comp;
1468  }
1469  else {
1470  /* In case we got some array/collection like items identifiers, now is the time to generate a
1471  * proper rna path from those. */
1472 # define RNA_PATH_BUFFSIZE 8192
1473 
1474  char extended_rna_path_buffer[RNA_PATH_BUFFSIZE];
1475  char *extended_rna_path = extended_rna_path_buffer;
1476  size_t extended_rna_path_len = 0;
1477 
1478  /* There may be a propname defined in some cases, while no actual name set
1479  * (e.g. happens with point cache), in that case too we want to fall back to index.
1480  * Note that we do not need the RNA path for insertion operations. */
1481  if (rna_path) {
1482  if ((rna_itemname_a != NULL && rna_itemname_a[0] != '\0') &&
1483  (rna_itemname_b != NULL && rna_itemname_b[0] != '\0')) {
1484  BLI_assert(STREQ(rna_itemname_a, rna_itemname_b));
1485 
1486  char esc_item_name[RNA_PATH_BUFFSIZE];
1487  const size_t esc_item_name_len = BLI_str_escape(
1488  esc_item_name, rna_itemname_a, RNA_PATH_BUFFSIZE);
1489  extended_rna_path_len = rna_path_len + 2 + esc_item_name_len + 2;
1490  if (extended_rna_path_len >= RNA_PATH_BUFFSIZE) {
1491  extended_rna_path = MEM_mallocN(extended_rna_path_len + 1, __func__);
1492  }
1493 
1494  memcpy(extended_rna_path, rna_path, rna_path_len);
1495  extended_rna_path[rna_path_len] = '[';
1496  extended_rna_path[rna_path_len + 1] = '"';
1497  memcpy(extended_rna_path + rna_path_len + 2, esc_item_name, esc_item_name_len);
1498  extended_rna_path[rna_path_len + 2 + esc_item_name_len] = '"';
1499  extended_rna_path[rna_path_len + 2 + esc_item_name_len + 1] = ']';
1500  extended_rna_path[extended_rna_path_len] = '\0';
1501  }
1502  else if (rna_itemindex_a != -1) { /* Based on index... */
1503  BLI_assert(rna_itemindex_a == rna_itemindex_b);
1504 
1505  /* low-level specific highly-efficient conversion of positive integer to string. */
1506  char item_index_buff[32];
1507  size_t item_index_buff_len = 0;
1508  if (rna_itemindex_a == 0) {
1509  item_index_buff[0] = '0';
1510  item_index_buff_len = 1;
1511  }
1512  else {
1513  uint index;
1514  for (index = rna_itemindex_a;
1515  index > 0 && item_index_buff_len < sizeof(item_index_buff);
1516  index /= 10) {
1517  item_index_buff[item_index_buff_len++] = '0' + (char)(index % 10);
1518  }
1519  BLI_assert(index == 0);
1520  }
1521 
1522  extended_rna_path_len = rna_path_len + item_index_buff_len + 2;
1523  if (extended_rna_path_len >= RNA_PATH_BUFFSIZE) {
1524  extended_rna_path = MEM_mallocN(extended_rna_path_len + 1, __func__);
1525  }
1526 
1527  memcpy(extended_rna_path, rna_path, rna_path_len);
1528  extended_rna_path[rna_path_len] = '[';
1529  for (size_t i = 1; i <= item_index_buff_len; i++) {
1530  /* The first loop above generated inverted string representation of our index number.
1531  */
1532  extended_rna_path[rna_path_len + i] = item_index_buff[item_index_buff_len - i];
1533  }
1534  extended_rna_path[rna_path_len + 1 + item_index_buff_len] = ']';
1535  extended_rna_path[extended_rna_path_len] = '\0';
1536  }
1537  else {
1538  extended_rna_path = (char *)rna_path;
1539  extended_rna_path_len = rna_path_len;
1540  }
1541  }
1542 
1543  eRNAOverrideMatchResult report_flags = 0;
1544  const bool match = RNA_struct_override_matches(bmain,
1545  propptr_a,
1546  propptr_b,
1547  extended_rna_path,
1548  extended_rna_path_len,
1549  override,
1550  flags,
1551  &report_flags);
1552  if (r_override_changed && (report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) != 0) {
1553  *r_override_changed = true;
1554  }
1555 
1556  if (!ELEM(extended_rna_path, extended_rna_path_buffer, rna_path)) {
1557  MEM_freeN(extended_rna_path);
1558  }
1559 
1560 # undef RNA_PATH_BUFFSIZE
1561 
1562  return !match;
1563  }
1564  }
1565  else {
1566  /* We could also use is_diff_pointer, but then we potentially lose the greater-than/less-than
1567  * info - and don't think performances are critical here for now anyway. */
1568  return !RNA_struct_equals(bmain, propptr_a, propptr_b, mode);
1569  }
1570 }
1571 
1572 # define RNA_PROPERTY_GET_SINGLE(_typename, _ptr, _prop, _index) \
1573  (is_array ? RNA_property_##_typename##_get_index((_ptr), (_prop), (_index)) : \
1574  RNA_property_##_typename##_get((_ptr), (_prop)))
1575 # define RNA_PROPERTY_SET_SINGLE(_typename, _ptr, _prop, _index, _value) \
1576  (is_array ? RNA_property_##_typename##_set_index((_ptr), (_prop), (_index), (_value)) : \
1577  RNA_property_##_typename##_set((_ptr), (_prop), (_value)))
1578 
1585  PropertyRNAOrID *prop_a,
1586  PropertyRNAOrID *prop_b,
1587  const int mode,
1588  IDOverrideLibrary *override,
1589  const char *rna_path,
1590  const size_t rna_path_len,
1591  const int flags,
1592  bool *r_override_changed)
1593 {
1594  PointerRNA *ptr_a = &prop_a->ptr;
1595  PointerRNA *ptr_b = &prop_b->ptr;
1596  PropertyRNA *rawprop_a = prop_a->rawprop;
1597  PropertyRNA *rawprop_b = prop_b->rawprop;
1598  const uint len_a = prop_a->array_len;
1599  const uint len_b = prop_b->array_len;
1600 
1601  BLI_assert(len_a == len_b);
1602 
1603  /* NOTE: at this point, we are sure that when len_a is zero,
1604  * we are not handling an (empty) array. */
1605 
1606  const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 &&
1607  rna_path != NULL;
1608 
1609  const bool no_ownership = (prop_a->rnaprop->flag & PROP_PTR_NO_OWNERSHIP) != 0;
1610 
1611  /* NOTE: we assume we only insert in ptr_a (i.e. we can only get new items in ptr_a),
1612  * and that we never remove anything. */
1613  const bool use_collection_insertion = (prop_a->rnaprop->flag_override &
1615  do_create;
1616 
1617  const uint rna_prop_type = RNA_property_type(prop_a->rnaprop);
1618  bool created = false;
1620 
1621  switch (rna_prop_type) {
1622  case PROP_BOOLEAN: {
1623  if (len_a) {
1624  bool array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
1625  bool *array_a, *array_b;
1626 
1627  array_a = (len_a > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(bool) * len_a, "RNA equals") :
1628  array_stack_a;
1629  array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(bool) * len_b, "RNA equals") :
1630  array_stack_b;
1631 
1632  RNA_property_boolean_get_array(ptr_a, rawprop_a, array_a);
1633  RNA_property_boolean_get_array(ptr_b, rawprop_b, array_b);
1634 
1635  const int comp = memcmp(array_a, array_b, sizeof(bool) * len_a);
1636 
1637  if (do_create && comp != 0) {
1638  /* XXX TODO: this will have to be refined to handle array items. */
1639  op = BKE_lib_override_library_property_get(override, rna_path, &created);
1640 
1641  if (op != NULL && created) {
1643  op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
1644  if (r_override_changed) {
1645  *r_override_changed = created;
1646  }
1647  }
1648  else {
1649  /* Already overridden prop, we'll have to check arrays items etc. */
1650  }
1651  }
1652 
1653  if (array_a != array_stack_a) {
1654  MEM_freeN(array_a);
1655  }
1656  if (array_b != array_stack_b) {
1657  MEM_freeN(array_b);
1658  }
1659 
1660  return comp;
1661  }
1662  else {
1663  const bool value_a = RNA_property_boolean_get(ptr_a, rawprop_a);
1664  const bool value_b = RNA_property_boolean_get(ptr_b, rawprop_b);
1665  const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0;
1666 
1667  if (do_create && comp != 0) {
1668  op = BKE_lib_override_library_property_get(override, rna_path, &created);
1669 
1670  if (op != NULL && created) { /* If not yet overridden... */
1672  op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
1673  if (r_override_changed) {
1674  *r_override_changed = created;
1675  }
1676  }
1677  }
1678 
1679  return comp;
1680  }
1681  }
1682 
1683  case PROP_INT: {
1684  if (len_a) {
1685  int array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
1686  int *array_a, *array_b;
1687 
1688  array_a = (len_a > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(int) * len_a, "RNA equals") :
1689  array_stack_a;
1690  array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(int) * len_b, "RNA equals") :
1691  array_stack_b;
1692 
1693  RNA_property_int_get_array(ptr_a, rawprop_a, array_a);
1694  RNA_property_int_get_array(ptr_b, rawprop_b, array_b);
1695 
1696  const int comp = memcmp(array_a, array_b, sizeof(int) * len_a);
1697 
1698  if (do_create && comp != 0) {
1699  /* XXX TODO: this will have to be refined to handle array items. */
1700  op = BKE_lib_override_library_property_get(override, rna_path, &created);
1701 
1702  if (op != NULL && created) {
1704  op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
1705  if (r_override_changed) {
1706  *r_override_changed = created;
1707  }
1708  }
1709  else {
1710  /* Already overridden prop, we'll have to check arrays items etc. */
1711  }
1712  }
1713 
1714  if (array_a != array_stack_a) {
1715  MEM_freeN(array_a);
1716  }
1717  if (array_b != array_stack_b) {
1718  MEM_freeN(array_b);
1719  }
1720 
1721  return comp;
1722  }
1723  else {
1724  const int value_a = RNA_property_int_get(ptr_a, rawprop_a);
1725  const int value_b = RNA_property_int_get(ptr_b, rawprop_b);
1726  const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0;
1727 
1728  if (do_create && comp != 0) {
1729  op = BKE_lib_override_library_property_get(override, rna_path, &created);
1730 
1731  if (op != NULL && created) { /* If not yet overridden... */
1733  op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
1734  if (r_override_changed) {
1735  *r_override_changed = created;
1736  }
1737  }
1738  }
1739 
1740  return comp;
1741  }
1742  }
1743 
1744  case PROP_FLOAT: {
1745  if (len_a) {
1746  float array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
1747  float *array_a, *array_b;
1748 
1749  array_a = (len_a > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(float) * len_a, "RNA equals") :
1750  array_stack_a;
1751  array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(float) * len_b, "RNA equals") :
1752  array_stack_b;
1753 
1754  RNA_property_float_get_array(ptr_a, rawprop_a, array_a);
1755  RNA_property_float_get_array(ptr_b, rawprop_b, array_b);
1756 
1757  const int comp = memcmp(array_a, array_b, sizeof(float) * len_a);
1758 
1759  if (do_create && comp != 0) {
1760  /* XXX TODO: this will have to be refined to handle array items. */
1761  op = BKE_lib_override_library_property_get(override, rna_path, &created);
1762 
1763  if (op != NULL && created) {
1765  op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
1766  if (r_override_changed) {
1767  *r_override_changed = created;
1768  }
1769  }
1770  else {
1771  /* Already overridden prop, we'll have to check arrays items etc. */
1772  }
1773  }
1774 
1775  if (array_a != array_stack_a) {
1776  MEM_freeN(array_a);
1777  }
1778  if (array_b != array_stack_b) {
1779  MEM_freeN(array_b);
1780  }
1781 
1782  return comp;
1783  }
1784  else {
1785  const float value_a = RNA_property_float_get(ptr_a, rawprop_a);
1786  const float value_b = RNA_property_float_get(ptr_b, rawprop_b);
1787  const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0;
1788 
1789  if (do_create && comp != 0) {
1790  op = BKE_lib_override_library_property_get(override, rna_path, &created);
1791 
1792  if (op != NULL && created) { /* If not yet overridden... */
1794  op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
1795  if (r_override_changed) {
1796  *r_override_changed = created;
1797  }
1798  }
1799  }
1800 
1801  return comp;
1802  }
1803  }
1804 
1805  case PROP_ENUM: {
1806  const int value_a = RNA_property_enum_get(ptr_a, rawprop_a);
1807  const int value_b = RNA_property_enum_get(ptr_b, rawprop_b);
1808  const int comp = value_a != value_b;
1809 
1810  if (do_create && comp != 0) {
1811  op = BKE_lib_override_library_property_get(override, rna_path, &created);
1812 
1813  if (op != NULL && created) { /* If not yet overridden... */
1815  op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
1816  if (r_override_changed) {
1817  *r_override_changed = created;
1818  }
1819  }
1820  }
1821 
1822  return comp;
1823  }
1824 
1825  case PROP_STRING: {
1826  char fixed_a[4096], fixed_b[4096];
1827  int len_str_a, len_str_b;
1828  char *value_a = RNA_property_string_get_alloc(
1829  ptr_a, rawprop_a, fixed_a, sizeof(fixed_a), &len_str_a);
1830  char *value_b = RNA_property_string_get_alloc(
1831  ptr_b, rawprop_b, fixed_b, sizeof(fixed_b), &len_str_b);
1832  /* TODO: we could do a check on length too,
1833  * but then we would not have a 'real' string comparison...
1834  * Maybe behind a eRNAOverrideMatch flag? */
1835 # if 0
1836  const int comp = len_str_a < len_str_b ?
1837  -1 :
1838  len_str_a > len_str_b ? 1 : strcmp(value_a, value_b);
1839 # endif
1840  const int comp = strcmp(value_a, value_b);
1841 
1842  if (do_create && comp != 0) {
1843  op = BKE_lib_override_library_property_get(override, rna_path, &created);
1844 
1845  if (op != NULL && created) { /* If not yet overridden... */
1847  op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
1848  if (r_override_changed) {
1849  *r_override_changed = created;
1850  }
1851  }
1852  }
1853 
1854  if (value_a != fixed_a) {
1855  MEM_freeN(value_a);
1856  }
1857  if (value_b != fixed_b) {
1858  MEM_freeN(value_b);
1859  }
1860 
1861  return comp;
1862  }
1863 
1864  case PROP_POINTER: {
1865  /* Using property name check only makes sense for items of a collection, not for a single
1866  * pointer.
1867  * Doing this here avoids having to manually specify `PROPOVERRIDE_NO_PROP_NAME` to things
1868  * like ShapeKey pointers. */
1869  const bool no_prop_name = true;
1870  if (STREQ(prop_a->identifier, "rna_type")) {
1871  /* Dummy 'pass' answer, this is a meta-data and must be ignored... */
1872  return 0;
1873  }
1874  else {
1875  PointerRNA propptr_a = RNA_property_pointer_get(ptr_a, rawprop_a);
1876  PointerRNA propptr_b = RNA_property_pointer_get(ptr_b, rawprop_b);
1877  return rna_property_override_diff_propptr(bmain,
1878  ptr_a->owner_id,
1879  ptr_b->owner_id,
1880  &propptr_a,
1881  &propptr_b,
1882  mode,
1883  no_ownership,
1884  no_prop_name,
1885  override,
1886  rna_path,
1887  rna_path_len,
1888  PROP_POINTER,
1889  NULL,
1890  NULL,
1891  -1,
1892  -1,
1893  flags,
1894  r_override_changed);
1895  }
1896  break;
1897  }
1898 
1899  case PROP_COLLECTION: {
1900  const bool no_prop_name = (prop_a->rnaprop->flag_override & PROPOVERRIDE_NO_PROP_NAME) != 0;
1901 
1902  bool equals = true;
1903  bool abort = false;
1904  int idx_a = 0;
1905  int idx_b = 0;
1906 
1907  CollectionPropertyIterator iter_a, iter_b;
1908  RNA_property_collection_begin(ptr_a, rawprop_a, &iter_a);
1909  RNA_property_collection_begin(ptr_b, rawprop_b, &iter_b);
1910 
1911  char buff_a[4096];
1912  char buff_prev_a[4096] = {0};
1913  char buff_b[4096];
1914  char *propname_a = NULL;
1915  char *prev_propname_a = buff_prev_a;
1916  char *propname_b = NULL;
1917 
1918  if (use_collection_insertion) {
1919  /* We need to clean up all possible existing insertion operations, and then re-generate
1920  * them, otherwise we'd end up with a mess of opop's every time something changes. */
1921  op = BKE_lib_override_library_property_find(override, rna_path);
1922  if (op != NULL) {
1924  if (ELEM(opop->operation,
1928  }
1929  }
1930  op = NULL;
1931  }
1932  }
1933 
1934  for (; iter_a.valid && !abort;) {
1935  bool is_valid_for_diffing;
1936  bool is_valid_for_insertion;
1937  do {
1938  bool is_id = false, is_null = false, is_type_diff = false;
1939 
1940  is_valid_for_insertion = use_collection_insertion;
1941 
1942  /* If false, it means that the whole data itself is different,
1943  * so no point in going inside of it at all! */
1944  if (iter_b.valid) {
1945  is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(
1946  &iter_a.ptr,
1947  &iter_b.ptr,
1948  no_ownership,
1949  no_prop_name,
1950  &is_id,
1951  &is_null,
1952  &is_type_diff,
1953  &propname_a,
1954  buff_a,
1955  sizeof(buff_a),
1956  &propname_b,
1957  buff_b,
1958  sizeof(buff_b));
1959  }
1960  else {
1961  is_valid_for_diffing = false;
1962  if (is_valid_for_insertion) {
1963  /* We still need propname from 'a' item... */
1964  rna_property_override_diff_propptr_validate_diffing(&iter_a.ptr,
1965  NULL,
1966  no_ownership,
1967  no_prop_name,
1968  &is_id,
1969  &is_null,
1970  &is_type_diff,
1971  &propname_a,
1972  buff_a,
1973  sizeof(buff_a),
1974  &propname_b,
1975  buff_b,
1976  sizeof(buff_b));
1977  }
1978  }
1979 
1980  /* We do not support insertion of IDs for now, neither handle NULL pointers. */
1981  if (is_id || is_valid_for_diffing) {
1982  is_valid_for_insertion = false;
1983  }
1984 
1985 # if 0
1986  if (rna_path) {
1987  printf(
1988  "Checking %s, %s [%d] vs %s [%d]; is_id: %d, diffing: %d; "
1989  "insert: %d (could be used: %d, do_create: %d)\n",
1990  rna_path,
1991  propname_a ? propname_a : "",
1992  idx_a,
1993  propname_b ? propname_b : "",
1994  idx_b,
1995  is_id,
1996  is_valid_for_diffing,
1997  is_valid_for_insertion,
1998  use_collection_insertion,
1999  do_create);
2000  }
2001 # endif
2002 
2003  if (!(is_id || is_valid_for_diffing || is_valid_for_insertion)) {
2004  /* Differences we cannot handle, we can break here. */
2005  equals = false;
2006  abort = true;
2007  break;
2008  }
2009 
2010  /* Collections do not support replacement of their data (except for collections of ID
2011  * pointers), since they do not support removing, only in *some* cases, insertion. We
2012  * also assume then that _a data is the one where things are inserted.
2013  *
2014  * NOTE: In insertion case, both 'local' and 'reference' (aka anchor) sub-item
2015  * identifiers refer to collection items in the local override. The 'reference' may match
2016  * an item in the linked reference data, but it can also be another local-only item added
2017  * by a previous INSERT operation. */
2018  if (is_valid_for_insertion && use_collection_insertion) {
2019  op = BKE_lib_override_library_property_get(override, rna_path, &created);
2020 
2023  no_prop_name ? NULL : prev_propname_a,
2024  no_prop_name ? NULL : propname_a,
2025  idx_a - 1,
2026  idx_a,
2027  true,
2028  NULL,
2029  NULL);
2030 # if 0
2031  printf("%s: Adding insertion op override after '%s'/%d\n",
2032  rna_path,
2033  prev_propname_a,
2034  idx_a - 1);
2035 # endif
2036  op = NULL;
2037 
2038  equals = false;
2039  }
2040  else if (is_id || is_valid_for_diffing) {
2041  if (equals || do_create) {
2042  const int comp = rna_property_override_diff_propptr(bmain,
2043  ptr_a->owner_id,
2044  ptr_b->owner_id,
2045  &iter_a.ptr,
2046  &iter_b.ptr,
2047  mode,
2048  no_ownership,
2049  no_prop_name,
2050  override,
2051  rna_path,
2052  rna_path_len,
2054  propname_a,
2055  propname_b,
2056  idx_a,
2057  idx_b,
2058  flags,
2059  r_override_changed);
2060  equals = equals && (comp == 0);
2061  }
2062  }
2063 
2064  if (prev_propname_a != buff_prev_a) {
2065  MEM_freeN(prev_propname_a);
2066  prev_propname_a = buff_prev_a;
2067  }
2068  prev_propname_a[0] = '\0';
2069  if (propname_a != NULL &&
2070  BLI_strncpy_rlen(prev_propname_a, propname_a, sizeof(buff_prev_a)) >=
2071  sizeof(buff_prev_a) - 1) {
2072  prev_propname_a = BLI_strdup(propname_a);
2073  }
2074  if (propname_a != buff_a) {
2075  MEM_SAFE_FREE(propname_a);
2076  propname_a = buff_a;
2077  }
2078  propname_a[0] = '\0';
2079  if (propname_b != buff_b) {
2080  MEM_SAFE_FREE(propname_b);
2081  propname_b = buff_b;
2082  }
2083  propname_b[0] = '\0';
2084 
2085  if (!do_create && !equals) {
2086  abort = true; /* Early out in case we do not want to loop over whole collection. */
2087  break;
2088  }
2089 
2090  if (!(use_collection_insertion && !(is_id || is_valid_for_diffing))) {
2091  break;
2092  }
2093 
2094  if (iter_a.valid) {
2096  idx_a++;
2097  }
2098  } while (iter_a.valid);
2099 
2100  if (iter_a.valid) {
2102  idx_a++;
2103  }
2104  if (iter_b.valid) {
2106  idx_b++;
2107  }
2108  }
2109 
2110  /* Not same number of items in both collections. */
2111  equals = equals && !(iter_a.valid || iter_b.valid) && !abort;
2112  RNA_property_collection_end(&iter_a);
2113  RNA_property_collection_end(&iter_b);
2114 
2115  return (equals == false);
2116  }
2117 
2118  default:
2119  break;
2120  }
2121 
2122  if (op != NULL) {
2123  /* In theory, if the liboverride operation already existed, it should already be of the right
2124  * type. However, in some rare cases a same exact RNA path can end up pointing at different
2125  * data of a different path than when the liboverride property was created, so just always
2126  * ensure the type is now valid. */
2127  op->rna_prop_type = rna_prop_type;
2128  }
2129 
2130  return 0;
2131 }
2132 
2134  PointerRNA *ptr_local,
2135  PointerRNA *ptr_reference,
2136  PointerRNA *ptr_storage,
2137  PropertyRNA *prop_local,
2138  PropertyRNA *prop_reference,
2139  PropertyRNA *prop_storage,
2140  const int len_local,
2141  const int len_reference,
2142  const int len_storage,
2144 {
2145  BLI_assert(len_local == len_reference && (!ptr_storage || len_local == len_storage));
2146  UNUSED_VARS_NDEBUG(len_reference, len_storage);
2147 
2148  bool changed = false;
2149  const bool is_array = len_local > 0;
2150  const int index = is_array ? opop->subitem_reference_index : 0;
2151 
2152  if (!ELEM(opop->operation,
2156  return changed;
2157  }
2158 
2159  /* XXX TODO: About range limits.
2160  * Ideally, it would be great to get rid of RNA range in that specific case.
2161  * However, this won't be that easy and will add yet another layer of complexity in
2162  * generated code, not to mention that we could most likely *not* bypass custom setters anyway.
2163  * So for now, if needed second operand value is not in valid range, we simply fall back
2164  * to a mere REPLACE operation.
2165  * Time will say whether this is acceptable limitation or not. */
2166  switch (RNA_property_type(prop_local)) {
2167  case PROP_BOOLEAN:
2168  /* TODO: support boolean ops? Really doubt this would ever be useful though. */
2169  BLI_assert_msg(0, "Boolean properties support no override diff operation");
2170  break;
2171  case PROP_INT: {
2172  int prop_min, prop_max;
2173  RNA_property_int_range(ptr_local, prop_local, &prop_min, &prop_max);
2174 
2175  if (is_array && index == -1) {
2176  int array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
2177  int *array_a, *array_b;
2178 
2179  array_a = (len_local > RNA_STACK_ARRAY) ?
2180  MEM_mallocN(sizeof(*array_a) * len_local, __func__) :
2181  array_stack_a;
2182  RNA_property_int_get_array(ptr_reference, prop_reference, array_a);
2183 
2184  switch (opop->operation) {
2187  const int fac = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? 1 : -1;
2188  const int other_op = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ?
2191  bool do_set = true;
2192  array_b = (len_local > RNA_STACK_ARRAY) ?
2193  MEM_mallocN(sizeof(*array_b) * len_local, __func__) :
2194  array_stack_b;
2195  RNA_property_int_get_array(ptr_local, prop_local, array_b);
2196  for (int i = len_local; i--;) {
2197  array_b[i] = fac * (array_b[i] - array_a[i]);
2198  if (array_b[i] < prop_min || array_b[i] > prop_max) {
2199  opop->operation = other_op;
2200  for (int j = len_local; j--;) {
2201  array_b[j] = j >= i ? -array_b[j] : fac * (array_a[j] - array_b[j]);
2202  if (array_b[j] < prop_min || array_b[j] > prop_max) {
2203  /* We failed to find a suitable diff op,
2204  * fall back to plain REPLACE one. */
2206  do_set = false;
2207  break;
2208  }
2209  }
2210  break;
2211  }
2212  }
2213  if (do_set) {
2214  changed = true;
2215  RNA_property_int_set_array(ptr_storage, prop_storage, array_b);
2216  }
2217  if (array_b != array_stack_b) {
2218  MEM_freeN(array_b);
2219  }
2220  break;
2221  }
2222  default:
2223  BLI_assert_msg(0, "Unsupported RNA override diff operation on integer");
2224  break;
2225  }
2226 
2227  if (array_a != array_stack_a) {
2228  MEM_freeN(array_a);
2229  }
2230  }
2231  else {
2232  const int value = RNA_PROPERTY_GET_SINGLE(int, ptr_reference, prop_reference, index);
2233 
2234  switch (opop->operation) {
2237  const int fac = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? 1 : -1;
2238  const int other_op = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ?
2241  int b = fac * (RNA_PROPERTY_GET_SINGLE(int, ptr_local, prop_local, index) - value);
2242  if (b < prop_min || b > prop_max) {
2243  opop->operation = other_op;
2244  b = -b;
2245  if (b < prop_min || b > prop_max) {
2247  break;
2248  }
2249  }
2250  changed = true;
2251  RNA_PROPERTY_SET_SINGLE(int, ptr_storage, prop_storage, index, b);
2252  break;
2253  }
2254  default:
2255  BLI_assert_msg(0, "Unsupported RNA override diff operation on integer");
2256  break;
2257  }
2258  }
2259  break;
2260  }
2261  case PROP_FLOAT: {
2262  float prop_min, prop_max;
2263  RNA_property_float_range(ptr_local, prop_local, &prop_min, &prop_max);
2264 
2265  if (is_array && index == -1) {
2266  float array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
2267  float *array_a, *array_b;
2268 
2269  array_a = (len_local > RNA_STACK_ARRAY) ?
2270  MEM_mallocN(sizeof(*array_a) * len_local, __func__) :
2271  array_stack_a;
2272 
2273  RNA_property_float_get_array(ptr_reference, prop_reference, array_a);
2274  switch (opop->operation) {
2277  const float fac = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? 1.0 : -1.0;
2278  const int other_op = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ?
2281  bool do_set = true;
2282  array_b = (len_local > RNA_STACK_ARRAY) ?
2283  MEM_mallocN(sizeof(*array_b) * len_local, __func__) :
2284  array_stack_b;
2285  RNA_property_float_get_array(ptr_local, prop_local, array_b);
2286  for (int i = len_local; i--;) {
2287  array_b[i] = fac * (array_b[i] - array_a[i]);
2288  if (array_b[i] < prop_min || array_b[i] > prop_max) {
2289  opop->operation = other_op;
2290  for (int j = len_local; j--;) {
2291  array_b[j] = j >= i ? -array_b[j] : fac * (array_a[j] - array_b[j]);
2292  if (array_b[j] < prop_min || array_b[j] > prop_max) {
2293  /* We failed to find a suitable diff op,
2294  * fall back to plain REPLACE one. */
2296  do_set = false;
2297  break;
2298  }
2299  }
2300  break;
2301  }
2302  }
2303  if (do_set) {
2304  changed = true;
2305  RNA_property_float_set_array(ptr_storage, prop_storage, array_b);
2306  }
2307  if (array_b != array_stack_b) {
2308  MEM_freeN(array_b);
2309  }
2310  break;
2311  }
2313  bool do_set = true;
2314  array_b = (len_local > RNA_STACK_ARRAY) ?
2315  MEM_mallocN(sizeof(*array_b) * len_local, __func__) :
2316  array_stack_b;
2317  RNA_property_float_get_array(ptr_local, prop_local, array_b);
2318  for (int i = len_local; i--;) {
2319  array_b[i] = array_a[i] == 0.0f ? array_b[i] : array_b[i] / array_a[i];
2320  if (array_b[i] < prop_min || array_b[i] > prop_max) {
2322  do_set = false;
2323  break;
2324  }
2325  }
2326  if (do_set) {
2327  changed = true;
2328  RNA_property_float_set_array(ptr_storage, prop_storage, array_b);
2329  }
2330  if (array_b != array_stack_b) {
2331  MEM_freeN(array_b);
2332  }
2333  break;
2334  }
2335  default:
2336  BLI_assert_msg(0, "Unsupported RNA override diff operation on float");
2337  break;
2338  }
2339 
2340  if (array_a != array_stack_a) {
2341  MEM_freeN(array_a);
2342  }
2343  }
2344  else {
2345  const float value = RNA_PROPERTY_GET_SINGLE(float, ptr_reference, prop_reference, index);
2346 
2347  switch (opop->operation) {
2350  const float fac = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? 1.0f : -1.0f;
2351  const int other_op = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ?
2354  float b = fac * (RNA_PROPERTY_GET_SINGLE(float, ptr_local, prop_local, index) - value);
2355  if (b < prop_min || b > prop_max) {
2356  opop->operation = other_op;
2357  b = -b;
2358  if (b < prop_min || b > prop_max) {
2360  break;
2361  }
2362  }
2363  changed = true;
2364  RNA_PROPERTY_SET_SINGLE(float, ptr_storage, prop_storage, index, b);
2365  break;
2366  }
2368  const float b = RNA_property_float_get_index(ptr_local, prop_local, index) /
2369  (value == 0.0f ? 1.0f : value);
2370  if (b < prop_min || b > prop_max) {
2372  break;
2373  }
2374  changed = true;
2375  RNA_property_float_set_index(ptr_storage, prop_storage, index, b);
2376  break;
2377  }
2378  default:
2379  BLI_assert_msg(0, "Unsupported RNA override diff operation on float");
2380  break;
2381  }
2382  }
2383  return true;
2384  }
2385  case PROP_ENUM:
2386  /* TODO: support add/sub, for bitflags? */
2387  BLI_assert_msg(0, "Enum properties support no override diff operation");
2388  break;
2389  case PROP_POINTER:
2390  BLI_assert_msg(0, "Pointer properties support no override diff operation");
2391  break;
2392  case PROP_STRING:
2393  BLI_assert_msg(0, "String properties support no override diff operation");
2394  break;
2395  case PROP_COLLECTION:
2396  /* XXX TODO: support this of course... */
2397  BLI_assert_msg(0, "Collection properties support no override diff operation");
2398  break;
2399  default:
2400  break;
2401  }
2402 
2403  return changed;
2404 }
2405 
2407  PointerRNA *ptr_dst,
2408  PointerRNA *ptr_src,
2409  PointerRNA *ptr_storage,
2410  PropertyRNA *prop_dst,
2411  PropertyRNA *prop_src,
2412  PropertyRNA *prop_storage,
2413  const int len_dst,
2414  const int len_src,
2415  const int len_storage,
2416  PointerRNA *UNUSED(ptr_item_dst),
2417  PointerRNA *UNUSED(ptr_item_src),
2418  PointerRNA *UNUSED(ptr_item_storage),
2420 {
2421  const PropertyType prop_src_type = RNA_property_type(prop_src);
2422  const PropertyType prop_dst_type = RNA_property_type(prop_dst);
2423 
2424  /* It is possible that a same exact RNA path points to a different property of a different type
2425  * (due to changes in the program, or in some custom data...). */
2426  if (prop_src_type != prop_dst_type ||
2427  (prop_storage && prop_src_type != RNA_property_type(prop_storage))) {
2428  CLOG_WARN(&LOG_COMPARE_OVERRIDE,
2429  "%s.%s: Inconsistency between stored property type (%d) and linked reference one "
2430  "(%d), skipping liboverride apply",
2431  ptr_dst->owner_id->name,
2432  "<unknown RNA path>",
2433  prop_src_type,
2434  prop_dst_type);
2435  /* Keep the liboverride property, its type will be updated to the new actual one by caller
2436  * code. */
2437  return false;
2438  }
2439 
2440  BLI_assert(len_dst == len_src && (!prop_storage || len_dst == len_storage));
2441  UNUSED_VARS_NDEBUG(len_src, len_storage);
2442 
2443  const bool is_array = len_dst > 0;
2444  const int index = is_array ? opop->subitem_reference_index : 0;
2445  const short override_op = opop->operation;
2446 
2447  bool ret_success = true;
2448 
2449  switch (RNA_property_type(prop_dst)) {
2450  case PROP_BOOLEAN:
2451  if (is_array && index == -1) {
2452  bool array_stack_a[RNA_STACK_ARRAY];
2453  bool *array_a;
2454 
2455  array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) :
2456  array_stack_a;
2457 
2458  RNA_property_boolean_get_array(ptr_src, prop_src, array_a);
2459 
2460  switch (override_op) {
2462  RNA_property_boolean_set_array(ptr_dst, prop_dst, array_a);
2463  break;
2464  default:
2465  BLI_assert_msg(0, "Unsupported RNA override operation on boolean");
2466  return false;
2467  }
2468 
2469  if (array_a != array_stack_a) {
2470  MEM_freeN(array_a);
2471  }
2472  }
2473  else {
2474  const bool value = RNA_PROPERTY_GET_SINGLE(boolean, ptr_src, prop_src, index);
2475 
2476  switch (override_op) {
2478  RNA_PROPERTY_SET_SINGLE(boolean, ptr_dst, prop_dst, index, value);
2479  break;
2480  default:
2481  BLI_assert_msg(0, "Unsupported RNA override operation on boolean");
2482  return false;
2483  }
2484  }
2485  break;
2486  case PROP_INT:
2487  if (is_array && index == -1) {
2488  int array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
2489  int *array_a, *array_b;
2490 
2491  array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) :
2492  array_stack_a;
2493 
2494  switch (override_op) {
2496  RNA_property_int_get_array(ptr_src, prop_src, array_a);
2497  RNA_property_int_set_array(ptr_dst, prop_dst, array_a);
2498  break;
2501  RNA_property_int_get_array(ptr_dst, prop_dst, array_a);
2502  array_b = (len_dst > RNA_STACK_ARRAY) ?
2503  MEM_mallocN(sizeof(*array_b) * len_dst, __func__) :
2504  array_stack_b;
2505  RNA_property_int_get_array(ptr_storage, prop_storage, array_b);
2506  if (override_op == IDOVERRIDE_LIBRARY_OP_ADD) {
2507  for (int i = len_dst; i--;) {
2508  array_a[i] += array_b[i];
2509  }
2510  }
2511  else {
2512  for (int i = len_dst; i--;) {
2513  array_a[i] -= array_b[i];
2514  }
2515  }
2516  RNA_property_int_set_array(ptr_dst, prop_dst, array_a);
2517  if (array_b != array_stack_b) {
2518  MEM_freeN(array_b);
2519  }
2520  break;
2521  default:
2522  BLI_assert_msg(0, "Unsupported RNA override operation on integer");
2523  return false;
2524  }
2525 
2526  if (array_a != array_stack_a) {
2527  MEM_freeN(array_a);
2528  }
2529  }
2530  else {
2531  const int storage_value = ptr_storage ? RNA_PROPERTY_GET_SINGLE(
2532  int, ptr_storage, prop_storage, index) :
2533  0;
2534 
2535  switch (override_op) {
2537  RNA_PROPERTY_SET_SINGLE(int,
2538  ptr_dst,
2539  prop_dst,
2540  index,
2541  RNA_PROPERTY_GET_SINGLE(int, ptr_src, prop_src, index));
2542  break;
2544  RNA_PROPERTY_SET_SINGLE(int,
2545  ptr_dst,
2546  prop_dst,
2547  index,
2548  RNA_PROPERTY_GET_SINGLE(int, ptr_dst, prop_dst, index) -
2549  storage_value);
2550  break;
2552  RNA_PROPERTY_SET_SINGLE(int,
2553  ptr_dst,
2554  prop_dst,
2555  index,
2556  RNA_PROPERTY_GET_SINGLE(int, ptr_dst, prop_dst, index) -
2557  storage_value);
2558  break;
2559  default:
2560  BLI_assert_msg(0, "Unsupported RNA override operation on integer");
2561  return false;
2562  }
2563  }
2564  break;
2565  case PROP_FLOAT:
2566  if (is_array && index == -1) {
2567  float array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
2568  float *array_a, *array_b;
2569 
2570  array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) :
2571  array_stack_a;
2572 
2573  switch (override_op) {
2575  RNA_property_float_get_array(ptr_src, prop_src, array_a);
2576  RNA_property_float_set_array(ptr_dst, prop_dst, array_a);
2577  break;
2581  RNA_property_float_get_array(ptr_dst, prop_dst, array_a);
2582  array_b = (len_dst > RNA_STACK_ARRAY) ?
2583  MEM_mallocN(sizeof(*array_b) * len_dst, __func__) :
2584  array_stack_b;
2585  RNA_property_float_get_array(ptr_storage, prop_storage, array_b);
2586  if (override_op == IDOVERRIDE_LIBRARY_OP_ADD) {
2587  for (int i = len_dst; i--;) {
2588  array_a[i] += array_b[i];
2589  }
2590  }
2591  else if (override_op == IDOVERRIDE_LIBRARY_OP_SUBTRACT) {
2592  for (int i = len_dst; i--;) {
2593  array_a[i] -= array_b[i];
2594  }
2595  }
2596  else {
2597  for (int i = len_dst; i--;) {
2598  array_a[i] *= array_b[i];
2599  }
2600  }
2601  RNA_property_float_set_array(ptr_dst, prop_dst, array_a);
2602  if (array_b != array_stack_b) {
2603  MEM_freeN(array_b);
2604  }
2605  break;
2606  default:
2607  BLI_assert_msg(0, "Unsupported RNA override operation on float");
2608  return false;
2609  }
2610 
2611  if (array_a != array_stack_a) {
2612  MEM_freeN(array_a);
2613  }
2614  }
2615  else {
2616  const float storage_value = ptr_storage ? RNA_PROPERTY_GET_SINGLE(
2617  float, ptr_storage, prop_storage, index) :
2618  0.0f;
2619 
2620  switch (override_op) {
2622  RNA_PROPERTY_SET_SINGLE(float,
2623  ptr_dst,
2624  prop_dst,
2625  index,
2626  RNA_PROPERTY_GET_SINGLE(float, ptr_src, prop_src, index));
2627  break;
2629  RNA_PROPERTY_SET_SINGLE(float,
2630  ptr_dst,
2631  prop_dst,
2632  index,
2633  RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) +
2634  storage_value);
2635  break;
2637  RNA_PROPERTY_SET_SINGLE(float,
2638  ptr_dst,
2639  prop_dst,
2640  index,
2641  RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) -
2642  storage_value);
2643  break;
2645  RNA_PROPERTY_SET_SINGLE(float,
2646  ptr_dst,
2647  prop_dst,
2648  index,
2649  RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) *
2650  storage_value);
2651  break;
2652  default:
2653  BLI_assert_msg(0, "Unsupported RNA override operation on float");
2654  return false;
2655  }
2656  }
2657  break;
2658  case PROP_ENUM: {
2659  const int value = RNA_property_enum_get(ptr_src, prop_src);
2660 
2661  switch (override_op) {
2663  RNA_property_enum_set(ptr_dst, prop_dst, value);
2664  break;
2665  /* TODO: support add/sub, for bitflags? */
2666  default:
2667  BLI_assert_msg(0, "Unsupported RNA override operation on enum");
2668  return false;
2669  }
2670  break;
2671  }
2672  case PROP_POINTER: {
2673  PointerRNA value = RNA_property_pointer_get(ptr_src, prop_src);
2674 
2675  switch (override_op) {
2677  RNA_property_pointer_set(ptr_dst, prop_dst, value, NULL);
2678  break;
2679  default:
2680  BLI_assert_msg(0, "Unsupported RNA override operation on pointer");
2681  return false;
2682  }
2683  break;
2684  }
2685  case PROP_STRING: {
2686  char buff[256];
2687  char *value = RNA_property_string_get_alloc(ptr_src, prop_src, buff, sizeof(buff), NULL);
2688 
2689  switch (override_op) {
2691  RNA_property_string_set(ptr_dst, prop_dst, value);
2692  break;
2693  default:
2694  BLI_assert_msg(0, "Unsupported RNA override operation on string");
2695  return false;
2696  }
2697 
2698  if (value != buff) {
2699  MEM_freeN(value);
2700  }
2701  break;
2702  }
2703  case PROP_COLLECTION: {
2704  /* We only support IDProperty-based collection insertion here. */
2705  const bool is_src_idprop = (prop_src->magic != RNA_MAGIC) ||
2706  (prop_src->flag & PROP_IDPROPERTY) != 0;
2707  const bool is_dst_idprop = (prop_dst->magic != RNA_MAGIC) ||
2708  (prop_dst->flag & PROP_IDPROPERTY) != 0;
2709  if (!(is_src_idprop && is_dst_idprop)) {
2710  BLI_assert_msg(0, "You need to define a specific override apply callback for collections");
2711  return false;
2712  }
2713 
2714  switch (override_op) {
2716  PointerRNA item_ptr_src, item_ptr_ref, item_ptr_dst;
2717  int item_index_dst;
2718  bool is_valid = false;
2719  if (opop->subitem_local_name != NULL && opop->subitem_local_name[0] != '\0') {
2720  /* Find from name. */
2721  int item_index_src, item_index_ref;
2723  ptr_src, prop_src, opop->subitem_local_name, &item_ptr_src, &item_index_src) &&
2725  prop_dst,
2726  opop->subitem_reference_name,
2727  &item_ptr_ref,
2728  &item_index_ref)) {
2729  is_valid = true;
2730  item_index_dst = item_index_ref + 1;
2731  }
2732  }
2733  if (!is_valid && opop->subitem_local_index >= 0) {
2734  /* Find from index. */
2736  ptr_src, prop_src, opop->subitem_local_index, &item_ptr_src) &&
2738  ptr_dst, prop_dst, opop->subitem_reference_index, &item_ptr_ref)) {
2739  item_index_dst = opop->subitem_reference_index + 1;
2740  is_valid = true;
2741  }
2742  }
2743  if (!is_valid) {
2744  /* Assume it is inserted in first position. */
2745  if (RNA_property_collection_lookup_int(ptr_src, prop_src, 0, &item_ptr_src)) {
2746  item_index_dst = 0;
2747  is_valid = true;
2748  }
2749  }
2750  if (!is_valid) {
2751  return false;
2752  }
2753 
2754  RNA_property_collection_add(ptr_dst, prop_dst, &item_ptr_dst);
2755  const int item_index_added = RNA_property_collection_length(ptr_dst, prop_dst) - 1;
2756  BLI_assert(item_index_added >= 0);
2757 
2758  /* This is the section of code that makes it specific to IDProperties (the rest could be
2759  * used with some regular RNA/DNA data too, if `RNA_property_collection_add` where
2760  * actually implemented for those).
2761  * Currently it is close to impossible to copy arbitrary 'real' RNA data between
2762  * Collection items. */
2763  IDProperty *item_idprop_src = item_ptr_src.data;
2764  IDProperty *item_idprop_dst = item_ptr_dst.data;
2765  IDP_CopyPropertyContent(item_idprop_dst, item_idprop_src);
2766 
2767  ret_success = RNA_property_collection_move(
2768  ptr_dst, prop_dst, item_index_added, item_index_dst);
2769  break;
2770  }
2771  default:
2772  BLI_assert_msg(0, "Unsupported RNA override operation on collection");
2773  return false;
2774  }
2775  break;
2776  }
2777  default:
2779  return false;
2780  }
2781 
2782  /* Default apply callback always call property update. */
2783  if (ret_success) {
2784  RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
2785  }
2786 
2787  return ret_success;
2788 }
2789 
2790 # undef RNA_PROPERTY_GET_SINGLE
2791 # undef RNA_PROPERTY_SET_SINGLE
2792 
2793 #else
2794 
2795 static void rna_def_struct(BlenderRNA *brna)
2796 {
2797  StructRNA *srna;
2798  PropertyRNA *prop;
2799 
2800  srna = RNA_def_struct(brna, "Struct", NULL);
2801  RNA_def_struct_ui_text(srna, "Struct Definition", "RNA structure definition");
2802  RNA_def_struct_ui_icon(srna, ICON_RNA);
2803 
2804  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2806  RNA_def_property_string_funcs(prop, "rna_Struct_name_get", "rna_Struct_name_length", NULL);
2807  RNA_def_property_ui_text(prop, "Name", "Human readable name");
2808 
2809  prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
2812  prop, "rna_Struct_identifier_get", "rna_Struct_identifier_length", NULL);
2813  RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting");
2814  RNA_def_struct_name_property(srna, prop);
2815 
2816  prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
2819  prop, "rna_Struct_description_get", "rna_Struct_description_length", NULL);
2820  RNA_def_property_ui_text(prop, "Description", "Description of the Struct's purpose");
2821 
2822  prop = RNA_def_property(srna, "translation_context", PROP_STRING, PROP_NONE);
2825  prop, "rna_Struct_translation_context_get", "rna_Struct_translation_context_length", NULL);
2827  prop, "Translation Context", "Translation context of the struct's name");
2828 
2829  prop = RNA_def_property(srna, "base", PROP_POINTER, PROP_NONE);
2831  RNA_def_property_struct_type(prop, "Struct");
2832  RNA_def_property_pointer_funcs(prop, "rna_Struct_base_get", NULL, NULL, NULL);
2833  RNA_def_property_ui_text(prop, "Base", "Struct definition this is derived from");
2834 
2835  prop = RNA_def_property(srna, "nested", PROP_POINTER, PROP_NONE);
2837  RNA_def_property_struct_type(prop, "Struct");
2838  RNA_def_property_pointer_funcs(prop, "rna_Struct_nested_get", NULL, NULL, NULL);
2840  prop,
2841  "Nested",
2842  "Struct in which this struct is always nested, and to which it logically belongs");
2843 
2844  prop = RNA_def_property(srna, "name_property", PROP_POINTER, PROP_NONE);
2846  RNA_def_property_struct_type(prop, "StringProperty");
2847  RNA_def_property_pointer_funcs(prop, "rna_Struct_name_property_get", NULL, NULL, NULL);
2848  RNA_def_property_ui_text(prop, "Name Property", "Property that gives the name of the struct");
2849 
2850  prop = RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
2852  RNA_def_property_struct_type(prop, "Property");
2854  "rna_Struct_properties_begin",
2855  "rna_Struct_properties_next",
2856  "rna_iterator_listbase_end",
2857  "rna_Struct_properties_get",
2858  NULL,
2859  NULL,
2860  NULL,
2861  NULL);
2862  RNA_def_property_ui_text(prop, "Properties", "Properties in the struct");
2863 
2864  prop = RNA_def_property(srna, "functions", PROP_COLLECTION, PROP_NONE);
2866  RNA_def_property_struct_type(prop, "Function");
2868  "rna_Struct_functions_begin",
2869  "rna_Struct_functions_next",
2870  "rna_iterator_listbase_end",
2871  "rna_Struct_functions_get",
2872  NULL,
2873  NULL,
2874  NULL,
2875  NULL);
2876  RNA_def_property_ui_text(prop, "Functions", "");
2877 
2878  prop = RNA_def_property(srna, "property_tags", PROP_COLLECTION, PROP_NONE);
2880  RNA_def_property_struct_type(prop, "EnumPropertyItem");
2882  "rna_Struct_property_tags_begin",
2883  "rna_iterator_array_next",
2884  "rna_iterator_array_end",
2885  "rna_iterator_array_get",
2886  NULL,
2887  NULL,
2888  NULL,
2889  NULL);
2891  prop, "Property Tags", "Tags that properties can use to influence behavior");
2892 }
2893 
2894 static void rna_def_property(BlenderRNA *brna)
2895 {
2896  StructRNA *srna;
2897  PropertyRNA *prop;
2898  EnumPropertyItem dummy_prop_tags[] = {
2899  {0, NULL, 0, NULL, NULL},
2900  };
2901 
2902  srna = RNA_def_struct(brna, "Property", NULL);
2903  RNA_def_struct_ui_text(srna, "Property Definition", "RNA property definition");
2904  RNA_def_struct_refine_func(srna, "rna_Property_refine");
2905  RNA_def_struct_ui_icon(srna, ICON_RNA);
2906 
2907  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2909  RNA_def_property_string_funcs(prop, "rna_Property_name_get", "rna_Property_name_length", NULL);
2910  RNA_def_property_ui_text(prop, "Name", "Human readable name");
2911 
2912  prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
2915  prop, "rna_Property_identifier_get", "rna_Property_identifier_length", NULL);
2916  RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting");
2917  RNA_def_struct_name_property(srna, prop);
2918 
2919  prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
2922  prop, "rna_Property_description_get", "rna_Property_description_length", NULL);
2923  RNA_def_property_ui_text(prop, "Description", "Description of the property for tooltips");
2924 
2925  prop = RNA_def_property(srna, "translation_context", PROP_STRING, PROP_NONE);
2928  "rna_Property_translation_context_get",
2929  "rna_Property_translation_context_length",
2930  NULL);
2932  prop, "Translation Context", "Translation context of the property's name");
2933 
2934  prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2937  RNA_def_property_enum_funcs(prop, "rna_Property_type_get", NULL, NULL);
2938  RNA_def_property_ui_text(prop, "Type", "Data type of the property");
2939 
2940  prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE);
2943  RNA_def_property_enum_funcs(prop, "rna_Property_subtype_get", NULL, NULL);
2944  RNA_def_property_ui_text(prop, "Subtype", "Semantic interpretation of the property");
2945 
2946  prop = RNA_def_property(srna, "srna", PROP_POINTER, PROP_NONE);
2948  RNA_def_property_struct_type(prop, "Struct");
2949  RNA_def_property_pointer_funcs(prop, "rna_Property_srna_get", NULL, NULL, NULL);
2951  prop, "Base", "Struct definition used for properties assigned to this item");
2952 
2953  prop = RNA_def_property(srna, "unit", PROP_ENUM, PROP_NONE);
2956  RNA_def_property_enum_funcs(prop, "rna_Property_unit_get", NULL, NULL);
2957  RNA_def_property_ui_text(prop, "Unit", "Type of units for this property");
2958 
2959  prop = RNA_def_property(srna, "icon", PROP_ENUM, PROP_NONE);
2962  RNA_def_property_enum_funcs(prop, "rna_Property_icon_get", NULL, NULL);
2963  RNA_def_property_ui_text(prop, "Icon", "Icon of the item");
2964 
2965  prop = RNA_def_property(srna, "is_readonly", PROP_BOOLEAN, PROP_NONE);
2967  RNA_def_property_boolean_funcs(prop, "rna_Property_readonly_get", NULL);
2968  RNA_def_property_ui_text(prop, "Read Only", "Property is editable through RNA");
2969 
2970  prop = RNA_def_property(srna, "is_animatable", PROP_BOOLEAN, PROP_NONE);
2972  RNA_def_property_boolean_funcs(prop, "rna_Property_animatable_get", NULL);
2973  RNA_def_property_ui_text(prop, "Animatable", "Property is animatable through RNA");
2974 
2975  prop = RNA_def_property(srna, "is_overridable", PROP_BOOLEAN, PROP_NONE);
2977  RNA_def_property_boolean_funcs(prop, "rna_Property_overridable_get", NULL);
2978  RNA_def_property_ui_text(prop, "Overridable", "Property is overridable through RNA");
2979 
2980  prop = RNA_def_property(srna, "is_required", PROP_BOOLEAN, PROP_NONE);
2982  RNA_def_property_boolean_funcs(prop, "rna_Property_is_required_get", NULL);
2984  prop, "Required", "False when this property is an optional argument in an RNA function");
2985 
2986  prop = RNA_def_property(srna, "is_argument_optional", PROP_BOOLEAN, PROP_NONE);
2988  RNA_def_property_boolean_funcs(prop, "rna_Property_is_argument_optional_get", NULL);
2990  prop,
2991  "Optional Argument",
2992  "True when the property is optional in a Python function implementing an RNA function");
2993 
2994  prop = RNA_def_property(srna, "is_never_none", PROP_BOOLEAN, PROP_NONE);
2996  RNA_def_property_boolean_funcs(prop, "rna_Property_is_never_none_get", NULL);
2997  RNA_def_property_ui_text(prop, "Never None", "True when this value can't be set to None");
2998 
2999  prop = RNA_def_property(srna, "is_hidden", PROP_BOOLEAN, PROP_NONE);
3001  RNA_def_property_boolean_funcs(prop, "rna_Property_is_hidden_get", NULL);
3002  RNA_def_property_ui_text(prop, "Hidden", "True when the property is hidden");
3003 
3004  prop = RNA_def_property(srna, "is_skip_save", PROP_BOOLEAN, PROP_NONE);
3006  RNA_def_property_boolean_funcs(prop, "rna_Property_is_skip_save_get", NULL);
3007  RNA_def_property_ui_text(prop, "Skip Save", "True when the property is not saved in presets");
3008 
3009  prop = RNA_def_property(srna, "is_output", PROP_BOOLEAN, PROP_NONE);
3011  RNA_def_property_boolean_funcs(prop, "rna_Property_use_output_get", NULL);
3013  prop, "Return", "True when this property is an output value from an RNA function");
3014 
3015  prop = RNA_def_property(srna, "is_registered", PROP_BOOLEAN, PROP_NONE);
3017  RNA_def_property_boolean_funcs(prop, "rna_Property_is_registered_get", NULL);
3019  prop, "Registered", "Property is registered as part of type registration");
3020 
3021  prop = RNA_def_property(srna, "is_registered_optional", PROP_BOOLEAN, PROP_NONE);
3023  RNA_def_property_boolean_funcs(prop, "rna_Property_is_registered_optional_get", NULL);
3025  "Registered Optionally",
3026  "Property is optionally registered as part of type registration");
3027 
3028  prop = RNA_def_property(srna, "is_runtime", PROP_BOOLEAN, PROP_NONE);
3030  RNA_def_property_boolean_funcs(prop, "rna_Property_is_runtime_get", NULL);
3031  RNA_def_property_ui_text(prop, "Runtime", "Property has been dynamically created at runtime");
3032 
3033  prop = RNA_def_property(srna, "is_enum_flag", PROP_BOOLEAN, PROP_NONE);
3035  RNA_def_property_boolean_funcs(prop, "rna_Property_is_enum_flag_get", NULL);
3036  RNA_def_property_ui_text(prop, "Enum Flag", "True when multiple enums ");
3037 
3038  prop = RNA_def_property(srna, "is_library_editable", PROP_BOOLEAN, PROP_NONE);
3040  RNA_def_property_boolean_funcs(prop, "rna_Property_is_library_editable_flag_get", NULL);
3042  prop, "Library Editable", "Property is editable from linked instances (changes not saved)");
3043 
3044  prop = RNA_def_property(srna, "tags", PROP_ENUM, PROP_NONE);
3046  RNA_def_property_enum_items(prop, dummy_prop_tags);
3047  RNA_def_property_enum_funcs(prop, "rna_Property_tags_get", NULL, "rna_Property_tags_itemf");
3050  prop, "Tags", "Subset of tags (defined in parent struct) that are set for this property");
3051 }
3052 
3053 static void rna_def_function(BlenderRNA *brna)
3054 {
3055  StructRNA *srna;
3056  PropertyRNA *prop;
3057 
3058  srna = RNA_def_struct(brna, "Function", NULL);
3059  RNA_def_struct_ui_text(srna, "Function Definition", "RNA function definition");
3060  RNA_def_struct_ui_icon(srna, ICON_RNA);
3061 
3062  prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
3065  prop, "rna_Function_identifier_get", "rna_Function_identifier_length", NULL);
3066  RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting");
3067  RNA_def_struct_name_property(srna, prop);
3068 
3069  prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
3072  prop, "rna_Function_description_get", "rna_Function_description_length", NULL);
3073  RNA_def_property_ui_text(prop, "Description", "Description of the Function's purpose");
3074 
3075  prop = RNA_def_property(srna, "parameters", PROP_COLLECTION, PROP_NONE);
3076  // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3077  RNA_def_property_struct_type(prop, "Property");
3079  "rna_Function_parameters_begin",
3080  "rna_iterator_listbase_next",
3081  "rna_iterator_listbase_end",
3082  "rna_iterator_listbase_get",
3083  NULL,
3084  NULL,
3085  NULL,
3086  NULL);
3087  RNA_def_property_ui_text(prop, "Parameters", "Parameters for the function");
3088 
3089  prop = RNA_def_property(srna, "is_registered", PROP_BOOLEAN, PROP_NONE);
3091  RNA_def_property_boolean_funcs(prop, "rna_Function_registered_get", NULL);
3093  prop, "Registered", "Function is registered as callback as part of type registration");
3094 
3095  prop = RNA_def_property(srna, "is_registered_optional", PROP_BOOLEAN, PROP_NONE);
3097  RNA_def_property_boolean_funcs(prop, "rna_Function_registered_optional_get", NULL);
3099  prop,
3100  "Registered Optionally",
3101  "Function is optionally registered as callback part of type registration");
3102 
3103  prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE);
3105  RNA_def_property_boolean_funcs(prop, "rna_Function_no_self_get", NULL);
3107  prop,
3108  "No Self",
3109  "Function does not pass itself as an argument (becomes a static method in python)");
3110 
3111  prop = RNA_def_property(srna, "use_self_type", PROP_BOOLEAN, PROP_NONE);
3113  RNA_def_property_boolean_funcs(prop, "rna_Function_use_self_type_get", NULL);
3115  "Use Self Type",
3116  "Function passes itself type as an argument (becomes a class method "
3117  "in python if use_self is false)");
3118 }
3119 
3121 {
3122  PropertyRNA *prop;
3123 
3124  prop = RNA_def_property(srna, "default", type, PROP_NONE);
3126  RNA_def_property_ui_text(prop, "Default", "Default value for this number");
3127 
3128  switch (type) {
3129  case PROP_BOOLEAN:
3130  RNA_def_property_boolean_funcs(prop, "rna_BoolProperty_default_get", NULL);
3131  break;
3132  case PROP_INT:
3133  RNA_def_property_int_funcs(prop, "rna_IntProperty_default_get", NULL, NULL);
3134  break;
3135  case PROP_FLOAT:
3136  RNA_def_property_float_funcs(prop, "rna_FloatProperty_default_get", NULL, NULL);
3137  break;
3138  default:
3139  break;
3140  }
3141 
3142  prop = RNA_def_property(srna, "default_array", type, PROP_NONE);
3144 
3145  /* no fixed default length, important its not 0 though. */
3147 
3150  prop, "rna_NumberProperty_default_array_get_length"); /* same for all types */
3151 
3152  switch (type) {
3153  case PROP_BOOLEAN:
3154  RNA_def_property_boolean_funcs(prop, "rna_BoolProperty_default_array_get", NULL);
3155  break;
3156  case PROP_INT:
3157  RNA_def_property_int_funcs(prop, "rna_IntProperty_default_array_get", NULL, NULL);
3158  break;
3159  case PROP_FLOAT:
3160  RNA_def_property_float_funcs(prop, "rna_FloatProperty_default_array_get", NULL, NULL);
3161  break;
3162  default:
3163  break;
3164  }
3165  RNA_def_property_ui_text(prop, "Default Array", "Default value for this array");
3166 
3167  prop = RNA_def_property(srna, "array_length", PROP_INT, PROP_UNSIGNED);
3169  RNA_def_property_int_funcs(prop, "rna_Property_array_length_get", NULL, NULL);
3170  RNA_def_property_ui_text(prop, "Array Length", "Maximum length of the array, 0 means unlimited");
3171 
3172  prop = RNA_def_property(srna, "array_dimensions", PROP_INT, PROP_UNSIGNED);
3175  RNA_def_property_int_funcs(prop, "rna_Property_array_dimensions_get", NULL, NULL);
3176  RNA_def_property_ui_text(prop, "Array Dimensions", "Length of each dimension of the array");
3177 
3178  prop = RNA_def_property(srna, "is_array", PROP_BOOLEAN, PROP_NONE);
3180  RNA_def_property_boolean_funcs(prop, "rna_NumberProperty_is_array_get", NULL);
3181  RNA_def_property_ui_text(prop, "Is Array", "");
3182 
3183  if (type == PROP_BOOLEAN) {
3184  return;
3185  }
3186 
3187  prop = RNA_def_property(srna, "hard_min", type, PROP_NONE);
3189  if (type == PROP_INT) {
3190  RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_min_get", NULL, NULL);
3191  }
3192  else {
3193  RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_min_get", NULL, NULL);
3194  }
3195  RNA_def_property_ui_text(prop, "Hard Minimum", "Minimum value used by buttons");
3196 
3197  prop = RNA_def_property(srna, "hard_max", type, PROP_NONE);
3199  if (type == PROP_INT) {
3200  RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_max_get", NULL, NULL);
3201  }
3202  else {
3203  RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_max_get", NULL, NULL);
3204  }
3205  RNA_def_property_ui_text(prop, "Hard Maximum", "Maximum value used by buttons");
3206 
3207  prop = RNA_def_property(srna, "soft_min", type, PROP_NONE);
3209  if (type == PROP_INT) {
3210  RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_min_get", NULL, NULL);
3211  }
3212  else {
3213  RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_min_get", NULL, NULL);
3214  }
3215  RNA_def_property_ui_text(prop, "Soft Minimum", "Minimum value used by buttons");
3216 
3217  prop = RNA_def_property(srna, "soft_max", type, PROP_NONE);
3219  if (type == PROP_INT) {
3220  RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_max_get", NULL, NULL);
3221  }
3222  else {
3223  RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_max_get", NULL, NULL);
3224  }
3225  RNA_def_property_ui_text(prop, "Soft Maximum", "Maximum value used by buttons");
3226 
3227  prop = RNA_def_property(srna, "step", type, PROP_UNSIGNED);
3229  if (type == PROP_INT) {
3230  RNA_def_property_int_funcs(prop, "rna_IntProperty_step_get", NULL, NULL);
3231  }
3232  else {
3233  RNA_def_property_float_funcs(prop, "rna_FloatProperty_step_get", NULL, NULL);
3234  }
3236  prop, "Step", "Step size used by number buttons, for floats 1/100th of the step size");
3237 
3238  if (type == PROP_FLOAT) {
3239  prop = RNA_def_property(srna, "precision", PROP_INT, PROP_UNSIGNED);
3241  RNA_def_property_int_funcs(prop, "rna_FloatProperty_precision_get", NULL, NULL);
3243  "Precision",
3244  "Number of digits after the dot used by buttons. Fraction is "
3245  "automatically hidden for exact integer values of fields with unit "
3246  "'NONE' or 'TIME' (frame count) and step divisible by 100");
3247  }
3248 }
3249 
3251 {
3252  PropertyRNA *prop;
3253 
3254  prop = RNA_def_property(srna, "default", PROP_STRING, PROP_NONE);
3257  prop, "rna_StringProperty_default_get", "rna_StringProperty_default_length", NULL);
3258  RNA_def_property_ui_text(prop, "Default", "String default value");
3259 
3260  prop = RNA_def_property(srna, "length_max", PROP_INT, PROP_UNSIGNED);
3262  RNA_def_property_int_funcs(prop, "rna_StringProperty_max_length_get", NULL, NULL);
3264  prop, "Maximum Length", "Maximum length of the string, 0 means unlimited");
3265 }
3266 
3267 static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna)
3268 {
3269  PropertyRNA *prop;
3270 
3271  /* the itemf func is used instead, keep blender happy */
3272  static const EnumPropertyItem default_dummy_items[] = {
3273  {PROP_NONE, "DUMMY", 0, "Dummy", ""},
3274  {0, NULL, 0, NULL, NULL},
3275  };
3276 
3277  prop = RNA_def_property(srna, "default", PROP_ENUM, PROP_NONE);
3279  RNA_def_property_enum_items(prop, default_dummy_items);
3281  prop, "rna_EnumProperty_default_get", NULL, "rna_EnumProperty_default_itemf");
3282  RNA_def_property_ui_text(prop, "Default", "Default value for this enum");
3283 
3284  /* same 'default' but uses 'PROP_ENUM_FLAG' */
3285  prop = RNA_def_property(srna, "default_flag", PROP_ENUM, PROP_NONE);
3288  RNA_def_property_enum_items(prop, default_dummy_items);
3290  prop, "rna_EnumProperty_default_get", NULL, "rna_EnumProperty_default_itemf");
3291  RNA_def_property_ui_text(prop, "Default", "Default value for this enum");
3292 
3293  prop = RNA_def_property(srna, "enum_items", PROP_COLLECTION, PROP_NONE);
3295  RNA_def_property_struct_type(prop, "EnumPropertyItem");
3297  "rna_EnumProperty_items_begin",
3298  "rna_iterator_array_next",
3299  "rna_iterator_array_end",
3300  "rna_iterator_array_get",
3301  NULL,
3302  NULL,
3303  NULL,
3304  NULL);
3305  RNA_def_property_ui_text(prop, "Items", "Possible values for the property");
3306 
3307  prop = RNA_def_property(srna, "enum_items_static", PROP_COLLECTION, PROP_NONE);
3309  RNA_def_property_struct_type(prop, "EnumPropertyItem");
3311  "rna_EnumProperty_items_begin",
3312  "rna_iterator_array_next",
3313  "rna_iterator_array_end",
3314  "rna_iterator_array_get",
3315  NULL,
3316  NULL,
3317  NULL,
3318  NULL);
3320  prop,
3321  "Static Items",
3322  "Possible values for the property (never calls optional dynamic generation of those)");
3323 
3324  srna = RNA_def_struct(brna, "EnumPropertyItem", NULL);
3326  srna, "Enum Item Definition", "Definition of a choice in an RNA enum property");
3327  RNA_def_struct_ui_icon(srna, ICON_RNA);
3328 
3329  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
3332  prop, "rna_EnumPropertyItem_name_get", "rna_EnumPropertyItem_name_length", NULL);
3333  RNA_def_property_ui_text(prop, "Name", "Human readable name");
3334 
3335  prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
3338  "rna_EnumPropertyItem_description_get",
3339  "rna_EnumPropertyItem_description_length",
3340  NULL);
3341  RNA_def_property_ui_text(prop, "Description", "Description of the item's purpose");
3342 
3343  prop = RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
3346  prop, "rna_EnumPropertyItem_identifier_get", "rna_EnumPropertyItem_identifier_length", NULL);
3347  RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting");
3348  RNA_def_struct_name_property(srna, prop);
3349 
3350  prop = RNA_def_property(srna, "value", PROP_INT, PROP_UNSIGNED);
3352  RNA_def_property_int_funcs(prop, "rna_EnumPropertyItem_value_get", NULL, NULL);
3353  RNA_def_property_ui_text(prop, "Value", "Value of the item");
3354 
3355  prop = RNA_def_property(srna, "icon", PROP_ENUM, PROP_NONE);
3358  RNA_def_property_enum_funcs(prop, "rna_EnumPropertyItem_icon_get", NULL, NULL);
3359  RNA_def_property_ui_text(prop, "Icon", "Icon of the item");
3360 }
3361 
3363 {
3364  PropertyRNA *prop;
3365 
3366  prop = RNA_def_property(srna, "fixed_type", PROP_POINTER, PROP_NONE);
3368  RNA_def_property_struct_type(prop, "Struct");
3369  if (type == PROP_POINTER) {
3370  RNA_def_property_pointer_funcs(prop, "rna_PointerProperty_fixed_type_get", NULL, NULL, NULL);
3371  }
3372  else {
3374  prop, "rna_CollectionProperty_fixed_type_get", NULL, NULL, NULL);
3375  }
3376  RNA_def_property_ui_text(prop, "Pointer Type", "Fixed pointer type, empty if variable type");
3377 }
3378 
3380 {
3381  StructRNA *srna;
3382  PropertyRNA *prop;
3383 
3384  /* Struct */
3385  rna_def_struct(brna);
3386 
3387  /* Property */
3388  rna_def_property(brna);
3389 
3390  /* BoolProperty */
3391  srna = RNA_def_struct(brna, "BoolProperty", "Property");
3392  RNA_def_struct_ui_text(srna, "Boolean Definition", "RNA boolean property definition");
3394 
3395  /* IntProperty */
3396  srna = RNA_def_struct(brna, "IntProperty", "Property");
3397  RNA_def_struct_ui_text(srna, "Int Definition", "RNA integer number property definition");
3399 
3400  /* FloatProperty */
3401  srna = RNA_def_struct(brna, "FloatProperty", "Property");
3403  "Float Definition",
3404  "RNA floating-point number (single precision) property definition");
3406 
3407  /* StringProperty */
3408  srna = RNA_def_struct(brna, "StringProperty", "Property");
3409  RNA_def_struct_ui_text(srna, "String Definition", "RNA text string property definition");
3411 
3412  /* EnumProperty */
3413  srna = RNA_def_struct(brna, "EnumProperty", "Property");
3415  srna,
3416  "Enum Definition",
3417  "RNA enumeration property definition, to choose from a number of predefined options");
3418  rna_def_enum_property(brna, srna);
3419 
3420  /* PointerProperty */
3421  srna = RNA_def_struct(brna, "PointerProperty", "Property");
3423  srna, "Pointer Definition", "RNA pointer property to point to another RNA struct");
3425 
3426  /* CollectionProperty */
3427  srna = RNA_def_struct(brna, "CollectionProperty", "Property");
3429  "Collection Definition",
3430  "RNA collection property to define lists, arrays and mappings");
3432 
3433  /* Function */
3434  rna_def_function(brna);
3435 
3436  /* Blender RNA */
3437  srna = RNA_def_struct(brna, "BlenderRNA", NULL);
3438  RNA_def_struct_ui_text(srna, "Blender RNA", "Blender RNA structure definitions");
3439  RNA_def_struct_ui_icon(srna, ICON_RNA);
3440 
3441  prop = RNA_def_property(srna, "structs", PROP_COLLECTION, PROP_NONE);
3443  RNA_def_property_struct_type(prop, "Struct");
3445  "rna_BlenderRNA_structs_begin",
3446  "rna_iterator_listbase_next",
3447  "rna_iterator_listbase_end",
3448  "rna_iterator_listbase_get",
3449  /* included for speed, can be removed */
3450 # if 0
3451  NULL,
3452  NULL,
3453  NULL,
3454  NULL);
3455 # else
3456  "rna_BlenderRNA_structs_length",
3457  "rna_BlenderRNA_structs_lookup_int",
3458  "rna_BlenderRNA_structs_lookup_string",
3459  NULL);
3460 # endif
3461 
3462  RNA_def_property_ui_text(prop, "Structs", "");
3463 }
3464 
3465 #endif
void IDP_CopyPropertyContent(struct IDProperty *dst, struct IDProperty *src) ATTR_NONNULL()
Definition: idprop.c:769
struct IDOverrideLibraryProperty * BKE_lib_override_library_property_get(struct IDOverrideLibrary *override, const char *rna_path, bool *r_created)
struct IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_find(struct IDOverrideLibraryProperty *override_property, const char *subitem_refname, const char *subitem_locname, int subitem_refindex, int subitem_locindex, bool strict, bool *r_strict)
struct IDOverrideLibraryProperty * BKE_lib_override_library_property_find(struct IDOverrideLibrary *override, const char *rna_path)
void BKE_lib_override_library_operations_tag(struct IDOverrideLibraryProperty *override_property, short tag, bool do_set)
struct IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_get(struct IDOverrideLibraryProperty *override_property, short operation, const char *subitem_refname, const char *subitem_locname, int subitem_refindex, int subitem_locindex, bool strict, bool *r_strict, bool *r_created)
void BKE_lib_override_library_property_operation_delete(struct IDOverrideLibraryProperty *override_property, struct IDOverrideLibraryPropertyOperation *override_property_operation)
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:734
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:102
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:354
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:120
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:42
size_t size_t char size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL()
Definition: string.c:250
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNUSED_VARS_NDEBUG(...)
#define UNUSED(x)
#define ELEM(...)
#define STREQ(a, b)
#define CLOG_WARN(clg_ref,...)
Definition: CLG_log.h:189
#define CLOG_INFO(clg_ref, level,...)
Definition: CLG_log.h:187
ID and Library types, which are fundamental for sdna.
#define ID_IS_OVERRIDE_LIBRARY_VIRTUAL(_id)
Definition: DNA_ID.h:585
@ IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE
Definition: DNA_ID.h:244
@ IDP_FLAG_OVERRIDABLE_LIBRARY
Definition: DNA_ID.h:172
@ IDOVERRIDE_LIBRARY_OP_MULTIPLY
Definition: DNA_ID.h:227
@ IDOVERRIDE_LIBRARY_OP_INSERT_AFTER
Definition: DNA_ID.h:230
@ IDOVERRIDE_LIBRARY_OP_SUBTRACT
Definition: DNA_ID.h:225
@ IDOVERRIDE_LIBRARY_OP_ADD
Definition: DNA_ID.h:223
@ IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE
Definition: DNA_ID.h:231
@ IDOVERRIDE_LIBRARY_OP_REPLACE
Definition: DNA_ID.h:220
@ LIB_TAG_LIB_OVERRIDE_NEED_RESYNC
Definition: DNA_ID.h:762
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition: DNA_ID.h:588
@ IDOVERRIDE_LIBRARY_TAG_UNUSED
Definition: DNA_ID.h:275
_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 MEM_SAFE_FREE(v)
@ RNA_OVERRIDE_COMPARE_CREATE
Definition: RNA_access.h:800
eRNACompareMode
Definition: RNA_access.h:768
eRNAOverrideMatchResult
Definition: RNA_access.h:805
@ RNA_OVERRIDE_MATCH_RESULT_CREATED
Definition: RNA_access.h:810
#define RNA_MAX_ARRAY_DIMENSION
Definition: RNA_define.h:28
@ PARM_PYFUNC_OPTIONAL
Definition: RNA_types.h:362
@ PARM_REQUIRED
Definition: RNA_types.h:352
@ PARM_OUTPUT
Definition: RNA_types.h:353
#define RNA_STACK_ARRAY
Definition: RNA_types.h:119
@ FUNC_USE_SELF_TYPE
Definition: RNA_types.h:658
@ FUNC_BUILTIN
Definition: RNA_types.h:682
@ FUNC_NO_SELF
Definition: RNA_types.h:656
@ FUNC_REGISTER
Definition: RNA_types.h:670
@ FUNC_REGISTER_OPTIONAL
Definition: RNA_types.h:672
@ STRUCT_PUBLIC_NAMESPACE
Definition: RNA_types.h:721
@ STRUCT_ID
Definition: RNA_types.h:705
@ PROP_STRING_SEARCH_SUGGESTION
Definition: RNA_types.h:561
@ PROP_STRING_SEARCH_SORT
Definition: RNA_types.h:554
PropertyType
Definition: RNA_types.h:58
@ PROP_FLOAT
Definition: RNA_types.h:61
@ PROP_BOOLEAN
Definition: RNA_types.h:59
@ PROP_ENUM
Definition: RNA_types.h:63
@ PROP_INT
Definition: RNA_types.h:60
@ PROP_STRING
Definition: RNA_types.h:62
@ PROP_POINTER
Definition: RNA_types.h:64
@ PROP_COLLECTION
Definition: RNA_types.h:65
@ PROP_UNIT_VOLUME
Definition: RNA_types.h:73
@ PROP_UNIT_POWER
Definition: RNA_types.h:81
@ PROP_UNIT_ROTATION
Definition: RNA_types.h:75
@ PROP_UNIT_VELOCITY
Definition: RNA_types.h:78
@ PROP_UNIT_LENGTH
Definition: RNA_types.h:71
@ PROP_UNIT_NONE
Definition: RNA_types.h:70
@ PROP_UNIT_ACCELERATION
Definition: RNA_types.h:79
@ PROP_UNIT_AREA
Definition: RNA_types.h:72
@ PROP_UNIT_TIME
Definition: RNA_types.h:76
@ PROP_UNIT_CAMERA
Definition: RNA_types.h:80
@ PROP_UNIT_TEMPERATURE
Definition: RNA_types.h:82
@ PROP_UNIT_MASS
Definition: RNA_types.h:74
@ PROP_UNIT_TIME_ABSOLUTE
Definition: RNA_types.h:77
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition: RNA_types.h:312
@ PROPOVERRIDE_LIBRARY_INSERTION
Definition: RNA_types.h:337
@ PROPOVERRIDE_NO_PROP_NAME
Definition: RNA_types.h:344
@ PROP_DYNAMIC
Definition: RNA_types.h:290
@ PROP_ANIMATABLE
Definition: RNA_types.h:202
@ PROP_PROPORTIONAL
Definition: RNA_types.h:223
@ PROP_EDITABLE
Definition: RNA_types.h:189
@ PROP_ENUM_FLAG
Definition: RNA_types.h:266
@ PROP_LIB_EXCEPTION
Definition: RNA_types.h:195
@ PROP_REGISTER_OPTIONAL
Definition: RNA_types.h:274
@ PROP_NEVER_NULL
Definition: RNA_types.h:239
@ PROP_REGISTER
Definition: RNA_types.h:273
@ PROP_PTR_NO_OWNERSHIP
Definition: RNA_types.h:257
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
@ PROP_TEXTEDIT_UPDATE
Definition: RNA_types.h:209
@ PROP_HIDDEN
Definition: RNA_types.h:216
@ PROP_IDPROPERTY
Definition: RNA_types.h:288
int(* IteratorSkipFunc)(struct CollectionPropertyIterator *iter, void *data)
Definition: RNA_types.h:367
@ PROP_NONE
Definition: RNA_types.h:126
@ PROP_UNSIGNED
Definition: RNA_types.h:142
#define C
Definition: RandGen.cpp:25
return(oflags[bm->toolflag_index].f &oflag) !=0
bool is_valid
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
T length(const vec_base< T, Size > &a)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2767
void RNA_property_float_get_default_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
Definition: rna_access.c:3095
bool RNA_property_array_check(PropertyRNA *prop)
Definition: rna_access.c:1080
int RNA_property_collection_lookup_string_index(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr, int *r_index)
Definition: rna_access.c:4130
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
Definition: rna_access.c:2879
PropertyRNA * rna_ensure_property(PropertyRNA *prop)
Definition: rna_access.c:524
IDProperty * rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr)
Definition: rna_access.c:502
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
bool RNA_struct_is_ID(const StructRNA *type)
Definition: rna_access.c:655
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1000
const char * RNA_property_ui_description_raw(const PropertyRNA *prop)
Definition: rna_access.c:1890
void RNA_property_float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, float value)
Definition: rna_access.c:3036
PropertyUnit RNA_property_unit(PropertyRNA *prop)
Definition: rna_access.c:1032
int RNA_property_ui_icon(const PropertyRNA *prop)
Definition: rna_access.c:1900
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: rna_access.c:2954
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
Definition: rna_access.c:3532
void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter)
Definition: rna_access.c:3675
void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax)
Definition: rna_access.c:1274
void rna_iterator_listbase_end(CollectionPropertyIterator *UNUSED(iter))
Definition: rna_access.c:4768
void RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, bool *values)
Definition: rna_access.c:2242
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1010
const PointerRNA PointerRNA_NULL
Definition: rna_access.c:61
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
Definition: rna_access.c:3421
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3493
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
Definition: rna_access.c:4097
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
Definition: rna_access.c:4729
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2153
char * RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len)
Definition: rna_access.c:3178
void RNA_property_boolean_get_default_array(PointerRNA *ptr, PropertyRNA *prop, bool *values)
Definition: rna_access.c:2390
unsigned int RNA_enum_items_count(const EnumPropertyItem *item)
Definition: rna_access.c:1747
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, bool free_ptr, IteratorSkipFunc skip)
Definition: rna_access.c:4781
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2429
IDProperty * RNA_struct_idprops(PointerRNA *ptr, bool create)
Definition: rna_access.c:251
void RNA_property_collection_next(CollectionPropertyIterator *iter)
Definition: rna_access.c:3709
const char * RNA_property_translation_context(const PropertyRNA *prop)
Definition: rna_access.c:1895
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:1405
void RNA_property_update_main(Main *bmain, Scene *scene, PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2143
void rna_iterator_listbase_next(CollectionPropertyIterator *iter)
Definition: rna_access.c:4745
PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *data)
Definition: rna_access.c:186
const EnumPropertyItem * RNA_struct_property_tag_defines(const StructRNA *type)
Definition: rna_access.c:629
PropertyRNA * RNA_struct_name_property(const StructRNA *type)
Definition: rna_access.c:624
void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
Definition: rna_access.c:3835
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
Definition: rna_access.c:2978
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
Definition: rna_access.c:2605
void RNA_property_int_get_default_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
Definition: rna_access.c:2707
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3402
void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
Definition: rna_access.c:2512
bool RNA_property_collection_move(PointerRNA *ptr, PropertyRNA *prop, int key, int pos)
Definition: rna_access.c:3983
PropertySubType RNA_property_subtype(PropertyRNA *prop)
Definition: rna_access.c:1015
void RNA_property_int_range(PointerRNA *ptr, PropertyRNA *prop, int *hardmin, int *hardmax)
Definition: rna_access.c:1190
int RNA_property_tags(PropertyRNA *prop)
Definition: rna_access.c:1060
void RNA_property_collection_end(CollectionPropertyIterator *iter)
Definition: rna_access.c:3750
void RNA_property_enum_items_ex(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const bool use_static, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
Definition: rna_access.c:1452
const char * RNA_property_ui_name_raw(const PropertyRNA *prop)
Definition: rna_access.c:1880
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3762
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const bool *values)
Definition: rna_access.c:2304
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
Definition: rna_access.c:3239
bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACompareMode mode)
#define RNA_PATH_BUFFSIZE
bool RNA_struct_override_matches(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, const char *root_path, const size_t root_path_len, IDOverrideLibrary *override, const eRNAOverrideMatch flags, eRNAOverrideMatchResult *r_report_flags)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
Definition: rna_define.c:1148
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
Definition: rna_define.c:3285
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3126
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1645
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
Definition: rna_define.c:3420
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1237
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
Definition: rna_define.c:2944
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
Definition: rna_define.c:2926
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1872
void RNA_def_property_array(PropertyRNA *prop, int length)
Definition: rna_define.c:1539
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1772
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
Definition: rna_define.c:3224
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1257
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
Definition: rna_define.c:4487
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
Definition: rna_define.c:1103
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1495
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
Definition: rna_define.c:3385
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1028
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
Definition: rna_define.c:4436
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3028
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1245
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
int rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
PointerRNA rna_builtin_properties_get(struct CollectionPropertyIterator *iter)
void rna_builtin_properties_next(struct CollectionPropertyIterator *iter)
bool rna_property_override_store_default(struct Main *bmain, struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_local, struct PropertyRNA *prop_reference, struct PropertyRNA *prop_storage, int len_local, int len_reference, int len_storage, struct IDOverrideLibraryPropertyOperation *opop)
int rna_property_override_diff_default(struct Main *bmain, struct PropertyRNAOrID *prop_a, struct PropertyRNAOrID *prop_b, int mode, struct IDOverrideLibrary *override, const char *rna_path, size_t rna_path_len, int flags, bool *r_override_changed)
void rna_builtin_properties_begin(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr)
#define RNA_MAGIC
Definition: rna_internal.h:21
bool rna_property_override_apply_default(struct Main *bmain, struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage, int len_dst, int len_src, int len_storage, struct PointerRNA *ptr_item_dst, struct PointerRNA *ptr_item_src, struct PointerRNA *ptr_item_storage, struct IDOverrideLibraryPropertyOperation *opop)
PointerRNA rna_builtin_type_get(struct PointerRNA *ptr)
@ PROP_INTERN_BUILTIN
@ PROP_INTERN_RUNTIME
void RNA_def_rna(BlenderRNA *brna)
Definition: rna_rna.c:3379
const EnumPropertyItem rna_enum_property_type_items[]
Definition: rna_rna.c:42
const EnumPropertyItem rna_enum_property_override_flag_collection_items[]
Definition: rna_rna.c:185
static void rna_def_pointer_property(StructRNA *srna, PropertyType type)
Definition: rna_rna.c:3362
const EnumPropertyItem rna_enum_property_subtype_number_array_items[]
Definition: rna_rna.c:113
const EnumPropertyItem DummyRNA_DEFAULT_items[]
Definition: rna_rna.c:31
static void rna_def_number_property(StructRNA *srna, PropertyType type)
Definition: rna_rna.c:3120
static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna)
Definition: rna_rna.c:3267
static void rna_def_property(BlenderRNA *brna)
Definition: rna_rna.c:2894
const EnumPropertyItem rna_enum_property_unit_items[]
Definition: rna_rna.c:135
const EnumPropertyItem rna_enum_property_subtype_number_items[]
Definition: rna_rna.c:106
static void rna_def_string_property(StructRNA *srna)
Definition: rna_rna.c:3250
const EnumPropertyItem rna_enum_property_string_search_flag_items[]
Definition: rna_rna.c:204
#define RNA_ENUM_PROPERTY_SUBTYPE_STRING_ITEMS
Definition: rna_rna.c:57
const EnumPropertyItem rna_enum_property_override_flag_items[]
Definition: rna_rna.c:176
static void rna_def_struct(BlenderRNA *brna)
Definition: rna_rna.c:2795
const EnumPropertyItem rna_enum_property_subtype_items[]
Definition: rna_rna.c:120
const EnumPropertyItem rna_enum_property_subtype_string_items[]
Definition: rna_rna.c:99
#define RNA_ENUM_PROPERTY_SUBTYPE_NUMBER_ARRAY_ITEMS
Definition: rna_rna.c:79
static void rna_def_function(BlenderRNA *brna)
Definition: rna_rna.c:3053
const EnumPropertyItem DummyRNA_NULL_items[]
Definition: rna_rna.c:26
const EnumPropertyItem rna_enum_property_flag_items[]
Definition: rna_rna.c:152
#define RNA_ENUM_PROPERTY_SUBTYPE_NUMBER_ITEMS
Definition: rna_rna.c:64
const EnumPropertyItem rna_enum_property_flag_enum_items[]
Definition: rna_rna.c:167
const EnumPropertyItem rna_enum_icon_items[]
Definition: rna_ui_api.c:30
struct GHash * structs_map
unsigned int structs_len
ListBaseIterator listbase
Definition: RNA_types.h:409
union CollectionPropertyIterator::@1147 internal
struct PropertyRNA * prop
Definition: RNA_types.h:406
struct GHash * prophash
const char * identifier
Definition: RNA_types.h:461
const char * name
Definition: RNA_types.h:465
const char * description
Definition: RNA_types.h:467
unsigned int rna_prop_type
Definition: DNA_ID.h:269
struct ID * reference
Definition: DNA_ID.h:294
ListBase group
Definition: DNA_ID.h:101
short flag
Definition: DNA_ID.h:109
char name[64]
Definition: DNA_ID.h:111
IDPropertyData data
Definition: DNA_ID.h:117
Definition: DNA_ID.h:368
int tag
Definition: DNA_ID.h:387
IDOverrideLibrary * override_library
Definition: DNA_ID.h:412
char name[66]
Definition: DNA_ID.h:378
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
struct StructRNA * type
Definition: RNA_types.h:37
void * data
Definition: RNA_types.h:38
struct ID * owner_id
Definition: RNA_types.h:36
const char * identifier
PropertyRNA * rawprop
PropertyRNA * rnaprop
unsigned int arraydimension
struct PropertyRNA * next
struct StructRNA * srna
unsigned int arraylength[RNA_MAX_ARRAY_DIMENSION]
unsigned int totarraylength
const char * identifier
ContainerRNA cont
struct StructRNA * base
ListBase functions
PointerRNA * ptr
Definition: wm_files.c:3480