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