Blender  V3.3
rna_define.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <ctype.h>
8 #include <float.h>
9 #include <limits.h>
10 #include <stddef.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 
15 #include "BLI_utildefines.h"
16 #include "MEM_guardedalloc.h"
17 
18 #include "DNA_defaults.h"
19 #include "DNA_genfile.h"
20 #include "DNA_sdna_types.h"
21 
22 #include "BLI_ghash.h"
23 #include "BLI_listbase.h"
24 
25 #include "BLT_translation.h"
26 
27 #include "UI_interface.h" /* For things like UI_PRECISION_FLOAT_MAX... */
28 
29 #include "RNA_define.h"
30 
31 #include "rna_internal.h"
32 
33 #include "CLG_log.h"
34 
35 static CLG_LogRef LOG = {"rna.define"};
36 
37 #ifdef DEBUG
38 # define ASSERT_SOFT_HARD_LIMITS \
39  if (softmin < hardmin || softmax > hardmax) { \
40  CLOG_ERROR(&LOG, "error with soft/hard limits: %s.%s", CONTAINER_RNA_ID(cont), identifier); \
41  BLI_assert_msg(0, "invalid soft/hard limits"); \
42  } \
43  (void)0
44 #else
45 # define ASSERT_SOFT_HARD_LIMITS (void)0
46 #endif
47 
48 /* Global used during defining */
49 
51  .sdna = NULL,
52  .structs = {NULL, NULL},
53  .allocs = {NULL, NULL},
54  .laststruct = NULL,
55  .error = 0,
56  .silent = false,
57  .preprocess = false,
58  .verify = true,
59  .animate = true,
60  .make_overridable = false,
61 };
62 
63 #ifndef RNA_RUNTIME
64 static struct {
67 #endif
68 
69 #ifndef RNA_RUNTIME
74 static bool debugSRNA_defaults = false;
75 
76 static void print_default_info(const PropertyDefRNA *dp)
77 {
78  fprintf(stderr,
79  "dna_type=%s, dna_offset=%d, dna_struct=%s, dna_name=%s, id=%s\n",
80  dp->dnatype,
81  dp->dnaoffset,
82  dp->dnastructname,
83  dp->dnaname,
84  dp->prop->identifier);
85 }
86 #endif /* RNA_RUNTIME */
87 
88 /* Duplicated code since we can't link in blenkernel or blenlib */
89 
90 /* pedantic check for final '.', note '...' are allowed though. */
91 #ifndef NDEBUG
92 # define DESCR_CHECK(description, id1, id2) \
93  if (description && (description)[0]) { \
94  int i = strlen(description); \
95  if (i > 3 && (description)[i - 1] == '.' && (description)[i - 3] != '.') { \
96  CLOG_WARN(&LOG, \
97  "'%s' description from '%s' '%s' ends with a '.' !", \
98  description, \
99  id1 ? id1 : "", \
100  id2 ? id2 : ""); \
101  } \
102  } \
103  (void)0
104 
105 #else
106 # define DESCR_CHECK(description, id1, id2)
107 #endif
108 
109 void rna_addtail(ListBase *listbase, void *vlink)
110 {
111  Link *link = vlink;
112 
113  link->next = NULL;
114  link->prev = listbase->last;
115 
116  if (listbase->last) {
117  ((Link *)listbase->last)->next = link;
118  }
119  if (listbase->first == NULL) {
120  listbase->first = link;
121  }
122  listbase->last = link;
123 }
124 
125 static void rna_remlink(ListBase *listbase, void *vlink)
126 {
127  Link *link = vlink;
128 
129  if (link->next) {
130  link->next->prev = link->prev;
131  }
132  if (link->prev) {
133  link->prev->next = link->next;
134  }
135 
136  if (listbase->last == link) {
137  listbase->last = link->prev;
138  }
139  if (listbase->first == link) {
140  listbase->first = link->next;
141  }
142 }
143 
144 PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier)
145 {
146  Link *link;
147 
148  for (link = listbase->first; link; link = link->next) {
149  PropertyRNA *prop = ((PropertyDefRNA *)link)->prop;
150  if (prop && (STREQ(prop->identifier, identifier))) {
151  return (PropertyDefRNA *)link;
152  }
153  }
154 
155  return NULL;
156 }
157 
158 void rna_freelinkN(ListBase *listbase, void *vlink)
159 {
160  rna_remlink(listbase, vlink);
161  MEM_freeN(vlink);
162 }
163 
164 void rna_freelistN(ListBase *listbase)
165 {
166  Link *link, *next;
167 
168  for (link = listbase->first; link; link = next) {
169  next = link->next;
170  MEM_freeN(link);
171  }
172 
173  listbase->first = listbase->last = NULL;
174 }
175 
176 static void rna_brna_structs_add(BlenderRNA *brna, StructRNA *srna)
177 {
178  rna_addtail(&brna->structs, srna);
179  brna->structs_len += 1;
180 
181  /* This exception is only needed for pre-processing.
182  * otherwise we don't allow empty names. */
183  if ((srna->flag & STRUCT_PUBLIC_NAMESPACE) && (srna->identifier[0] != '\0')) {
184  BLI_ghash_insert(brna->structs_map, (void *)srna->identifier, srna);
185  }
186 }
187 
188 #ifdef RNA_RUNTIME
189 static void rna_brna_structs_remove_and_free(BlenderRNA *brna, StructRNA *srna)
190 {
191  if ((srna->flag & STRUCT_PUBLIC_NAMESPACE) && brna->structs_map) {
192  if (srna->identifier[0] != '\0') {
193  BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
194  }
195  }
196 
198 
199  if (srna->flag & STRUCT_RUNTIME) {
200  rna_freelinkN(&brna->structs, srna);
201  }
202  brna->structs_len -= 1;
203 }
204 #endif
205 
206 static int DNA_struct_find_nr_wrapper(const struct SDNA *sdna, const char *struct_name)
207 {
208  struct_name = DNA_struct_rename_legacy_hack_static_from_alias(struct_name);
209 #ifdef RNA_RUNTIME
210  /* We may support this at some point but for now we don't. */
212 #else
213  struct_name = BLI_ghash_lookup_default(
214  g_version_data.struct_map_static_from_alias, struct_name, (void *)struct_name);
215 #endif
216  return DNA_struct_find_nr(sdna, struct_name);
217 }
218 
220 {
221  StructDefRNA *dsrna;
222 
223  if (!DefRNA.preprocess) {
224  /* we should never get here */
225  CLOG_ERROR(&LOG, "only at preprocess time.");
226  return NULL;
227  }
228 
229  dsrna = DefRNA.structs.last;
230  for (; dsrna; dsrna = dsrna->cont.prev) {
231  if (dsrna->srna == srna) {
232  return dsrna;
233  }
234  }
235 
236  return NULL;
237 }
238 
240 {
241  StructDefRNA *dsrna;
242  PropertyDefRNA *dprop;
243 
244  if (!DefRNA.preprocess) {
245  /* we should never get here */
246  CLOG_ERROR(&LOG, "only at preprocess time.");
247  return NULL;
248  }
249 
250  dsrna = rna_find_struct_def(srna);
251  dprop = dsrna->cont.properties.last;
252  for (; dprop; dprop = dprop->prev) {
253  if (dprop->prop == prop) {
254  return dprop;
255  }
256  }
257 
258  dsrna = DefRNA.structs.last;
259  for (; dsrna; dsrna = dsrna->cont.prev) {
260  dprop = dsrna->cont.properties.last;
261  for (; dprop; dprop = dprop->prev) {
262  if (dprop->prop == prop) {
263  return dprop;
264  }
265  }
266  }
267 
268  return NULL;
269 }
270 
271 #if 0
272 static PropertyDefRNA *rna_find_property_def(PropertyRNA *prop)
273 {
274  PropertyDefRNA *dprop;
275 
276  if (!DefRNA.preprocess) {
277  /* we should never get here */
278  CLOG_ERROR(&LOG, "only at preprocess time.");
279  return NULL;
280  }
281 
283  if (dprop) {
284  return dprop;
285  }
286 
287  dprop = rna_find_parameter_def(prop);
288  if (dprop) {
289  return dprop;
290  }
291 
292  return NULL;
293 }
294 #endif
295 
297 {
298  StructDefRNA *dsrna;
299  FunctionDefRNA *dfunc;
300 
301  if (!DefRNA.preprocess) {
302  /* we should never get here */
303  CLOG_ERROR(&LOG, "only at preprocess time.");
304  return NULL;
305  }
306 
308  dfunc = dsrna->functions.last;
309  for (; dfunc; dfunc = dfunc->cont.prev) {
310  if (dfunc->func == func) {
311  return dfunc;
312  }
313  }
314 
315  dsrna = DefRNA.structs.last;
316  for (; dsrna; dsrna = dsrna->cont.prev) {
317  dfunc = dsrna->functions.last;
318  for (; dfunc; dfunc = dfunc->cont.prev) {
319  if (dfunc->func == func) {
320  return dfunc;
321  }
322  }
323  }
324 
325  return NULL;
326 }
327 
329 {
330  StructDefRNA *dsrna;
331  FunctionDefRNA *dfunc;
332  PropertyDefRNA *dparm;
333 
334  if (!DefRNA.preprocess) {
335  /* we should never get here */
336  CLOG_ERROR(&LOG, "only at preprocess time.");
337  return NULL;
338  }
339 
341  dfunc = dsrna->functions.last;
342  for (; dfunc; dfunc = dfunc->cont.prev) {
343  dparm = dfunc->cont.properties.last;
344  for (; dparm; dparm = dparm->prev) {
345  if (dparm->prop == parm) {
346  return dparm;
347  }
348  }
349  }
350 
351  dsrna = DefRNA.structs.last;
352  for (; dsrna; dsrna = dsrna->cont.prev) {
353  dfunc = dsrna->functions.last;
354  for (; dfunc; dfunc = dfunc->cont.prev) {
355  dparm = dfunc->cont.properties.last;
356  for (; dparm; dparm = dparm->prev) {
357  if (dparm->prop == parm) {
358  return dparm;
359  }
360  }
361  }
362  }
363 
364  return NULL;
365 }
366 
368 {
369  StructDefRNA *ds;
370  FunctionDefRNA *dfunc;
371 
372  if (!DefRNA.preprocess) {
373  /* we should never get here */
374  CLOG_ERROR(&LOG, "only at preprocess time.");
375  return NULL;
376  }
377 
378  ds = rna_find_struct_def((StructRNA *)cont);
379  if (ds) {
380  return &ds->cont;
381  }
382 
383  dfunc = rna_find_function_def((FunctionRNA *)cont);
384  if (dfunc) {
385  return &dfunc->cont;
386  }
387 
388  return NULL;
389 }
390 
391 /* DNA utility function for looking up members */
392 
393 typedef struct DNAStructMember {
394  const char *type;
395  const char *name;
398  int offset;
399  int size;
401 
402 static int rna_member_cmp(const char *name, const char *oname)
403 {
404  int a = 0;
405 
406  /* compare without pointer or array part */
407  while (name[0] == '*') {
408  name++;
409  }
410  while (oname[0] == '*') {
411  oname++;
412  }
413 
414  while (1) {
415  if (name[a] == '[' && oname[a] == 0) {
416  return 1;
417  }
418  if (name[a] == '[' && oname[a] == '[') {
419  return 1;
420  }
421  if (name[a] == 0) {
422  break;
423  }
424  if (name[a] != oname[a]) {
425  return 0;
426  }
427  a++;
428  }
429  if (name[a] == 0 && oname[a] == '.') {
430  return 2;
431  }
432  if (name[a] == 0 && oname[a] == '-' && oname[a + 1] == '>') {
433  return 3;
434  }
435 
436  return (name[a] == oname[a]);
437 }
438 
439 static int rna_find_sdna_member(SDNA *sdna,
440  const char *structname,
441  const char *membername,
442  DNAStructMember *smember,
443  int *offset)
444 {
445  const char *dnaname;
446  int b, structnr, cmp;
447 
448  if (!DefRNA.preprocess) {
449  CLOG_ERROR(&LOG, "only during preprocessing.");
450  return 0;
451  }
452  structnr = DNA_struct_find_nr_wrapper(sdna, structname);
453 
454  smember->offset = -1;
455  if (structnr == -1) {
456  if (offset) {
457  *offset = -1;
458  }
459  return 0;
460  }
461 
462  const SDNA_Struct *struct_info = sdna->structs[structnr];
463  for (int a = 0; a < struct_info->members_len; a++) {
464  const SDNA_StructMember *member = &struct_info->members[a];
465  const int size = DNA_elem_size_nr(sdna, member->type, member->name);
466  dnaname = sdna->alias.names[member->name];
467  cmp = rna_member_cmp(dnaname, membername);
468 
469  if (cmp == 1) {
470  smember->type = sdna->alias.types[member->type];
471  smember->name = dnaname;
472  smember->offset = *offset;
473  smember->size = size;
474 
475  if (strstr(membername, "[")) {
476  smember->arraylength = 0;
477  }
478  else {
479  smember->arraylength = DNA_elem_array_size(smember->name);
480  }
481 
482  smember->pointerlevel = 0;
483  for (b = 0; dnaname[b] == '*'; b++) {
484  smember->pointerlevel++;
485  }
486 
487  return 1;
488  }
489  if (cmp == 2) {
490  smember->type = "";
491  smember->name = dnaname;
492  smember->offset = *offset;
493  smember->size = size;
494  smember->pointerlevel = 0;
495  smember->arraylength = 0;
496 
497  membername = strstr(membername, ".") + strlen(".");
498  rna_find_sdna_member(sdna, sdna->alias.types[member->type], membername, smember, offset);
499 
500  return 1;
501  }
502  if (cmp == 3) {
503  smember->type = "";
504  smember->name = dnaname;
505  smember->offset = *offset;
506  smember->size = size;
507  smember->pointerlevel = 0;
508  smember->arraylength = 0;
509 
510  if (offset) {
511  *offset = -1;
512  }
513  membername = strstr(membername, "->") + strlen("->");
514  rna_find_sdna_member(sdna, sdna->alias.types[member->type], membername, smember, offset);
515 
516  return 1;
517  }
518 
519  if (offset && *offset != -1) {
520  *offset += size;
521  }
522  }
523 
524  return 0;
525 }
526 
527 static int rna_validate_identifier(const char *identifier, char *error, bool property)
528 {
529  int a = 0;
530 
539  static const char *kwlist[] = {
540  /* "False", "None", "True", */
541  "and", "as", "assert", "async", "await", "break", "class", "continue", "def",
542  "del", "elif", "else", "except", "finally", "for", "from", "global", "if",
543  "import", "in", "is", "lambda", "nonlocal", "not", "or", "pass", "raise",
544  "return", "try", "while", "with", "yield", NULL,
545  };
546 
547  if (!isalpha(identifier[0])) {
548  strcpy(error, "first character failed isalpha() check");
549  return 0;
550  }
551 
552  for (a = 0; identifier[a]; a++) {
553  if (DefRNA.preprocess && property) {
554  if (isalpha(identifier[a]) && isupper(identifier[a])) {
555  strcpy(error, "property names must contain lower case characters only");
556  return 0;
557  }
558  }
559 
560  if (identifier[a] == '_') {
561  continue;
562  }
563 
564  if (identifier[a] == ' ') {
565  strcpy(error, "spaces are not okay in identifier names");
566  return 0;
567  }
568 
569  if (isalnum(identifier[a]) == 0) {
570  strcpy(error, "one of the characters failed an isalnum() check and is not an underscore");
571  return 0;
572  }
573  }
574 
575  for (a = 0; kwlist[a]; a++) {
576  if (STREQ(identifier, kwlist[a])) {
577  strcpy(error, "this keyword is reserved by python");
578  return 0;
579  }
580  }
581 
582  if (property) {
583  static const char *kwlist_prop[] = {
584  /* not keywords but reserved all the same because py uses */
585  "keys",
586  "values",
587  "items",
588  "get",
589  NULL,
590  };
591 
592  for (a = 0; kwlist_prop[a]; a++) {
593  if (STREQ(identifier, kwlist_prop[a])) {
594  strcpy(error, "this keyword is reserved by python");
595  return 0;
596  }
597  }
598  }
599 
600  return 1;
601 }
602 
603 void RNA_identifier_sanitize(char *identifier, int property)
604 {
605  int a = 0;
606 
607  /* list from http://docs.python.org/py3k/reference/lexical_analysis.html#keywords */
608  static const char *kwlist[] = {
609  /* "False", "None", "True", */
610  "and", "as", "assert", "break", "class", "continue", "def", "del",
611  "elif", "else", "except", "finally", "for", "from", "global", "if",
612  "import", "in", "is", "lambda", "nonlocal", "not", "or", "pass",
613  "raise", "return", "try", "while", "with", "yield", NULL,
614  };
615 
616  if (!isalpha(identifier[0])) {
617  /* first character failed isalpha() check */
618  identifier[0] = '_';
619  }
620 
621  for (a = 0; identifier[a]; a++) {
622  if (DefRNA.preprocess && property) {
623  if (isalpha(identifier[a]) && isupper(identifier[a])) {
624  /* property names must contain lower case characters only */
625  identifier[a] = tolower(identifier[a]);
626  }
627  }
628 
629  if (identifier[a] == '_') {
630  continue;
631  }
632 
633  if (identifier[a] == ' ') {
634  /* spaces are not okay in identifier names */
635  identifier[a] = '_';
636  }
637 
638  if (isalnum(identifier[a]) == 0) {
639  /* one of the characters failed an isalnum() check and is not an underscore */
640  identifier[a] = '_';
641  }
642  }
643 
644  for (a = 0; kwlist[a]; a++) {
645  if (STREQ(identifier, kwlist[a])) {
646  /* this keyword is reserved by python.
647  * just replace the last character by '_' to keep it readable.
648  */
649  identifier[strlen(identifier) - 1] = '_';
650  break;
651  }
652  }
653 
654  if (property) {
655  static const char *kwlist_prop[] = {
656  /* not keywords but reserved all the same because py uses */
657  "keys",
658  "values",
659  "items",
660  "get",
661  NULL,
662  };
663 
664  for (a = 0; kwlist_prop[a]; a++) {
665  if (STREQ(identifier, kwlist_prop[a])) {
666  /* this keyword is reserved by python.
667  * just replace the last character by '_' to keep it readable.
668  */
669  identifier[strlen(identifier) - 1] = '_';
670  break;
671  }
672  }
673  }
674 }
675 
676 /* Blender Data Definition */
677 
679 {
680  BlenderRNA *brna;
681 
682  brna = MEM_callocN(sizeof(BlenderRNA), "BlenderRNA");
683  const char *error_message = NULL;
684 
686  brna->structs_map = BLI_ghash_str_new_ex(__func__, 2048);
687 
688  DefRNA.error = false;
689  DefRNA.preprocess = true;
690 
691  DefRNA.sdna = DNA_sdna_from_data(DNAstr, DNAlen, false, false, &error_message);
692  if (DefRNA.sdna == NULL) {
693  CLOG_ERROR(&LOG, "Failed to decode SDNA: %s.", error_message);
694  DefRNA.error = true;
695  }
696 
697  /* We need both alias and static (on-disk) DNA names. */
699 
700 #ifndef RNA_RUNTIME
701  DNA_alias_maps(DNA_RENAME_STATIC_FROM_ALIAS, &g_version_data.struct_map_static_from_alias, NULL);
702 #endif
703 
704  return brna;
705 }
706 
708 {
709  StructDefRNA *ds;
710  FunctionDefRNA *dfunc;
711  AllocDefRNA *alloc;
712 
713  for (alloc = DefRNA.allocs.first; alloc; alloc = alloc->next) {
714  MEM_freeN(alloc->mem);
715  }
717 
718  for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
719  for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) {
720  rna_freelistN(&dfunc->cont.properties);
721  }
722 
724  rna_freelistN(&ds->functions);
725  }
726 
728 
729  if (DefRNA.sdna) {
731  DefRNA.sdna = NULL;
732  }
733 
734  DefRNA.error = false;
735 }
736 
737 void RNA_define_verify_sdna(bool verify)
738 {
739  DefRNA.verify = verify;
740 }
741 
742 void RNA_define_lib_overridable(const bool make_overridable)
743 {
744  DefRNA.make_overridable = make_overridable;
745 }
746 
747 #ifndef RNA_RUNTIME
748 void RNA_define_animate_sdna(bool animate)
749 {
750  DefRNA.animate = animate;
751 }
752 #endif
753 
754 #ifndef RNA_RUNTIME
755 void RNA_define_fallback_property_update(int noteflag, const char *updatefunc)
756 {
757  DefRNA.fallback.property_update.noteflag = noteflag;
758  DefRNA.fallback.property_update.updatefunc = updatefunc;
759 }
760 #endif
761 
763 {
764 #ifdef RNA_RUNTIME
765  rna_ext->free(rna_ext->data); /* decref's the PyObject that the srna owns */
766  RNA_struct_blender_type_set(srna, NULL); /* FIXME: this gets accessed again. */
767 
768  /* NULL the srna's value so RNA_struct_free won't complain of a leak */
770 
771 #else
772  (void)srna;
773  (void)rna_ext;
774 #endif
775 }
776 
778 {
779 #ifdef RNA_RUNTIME
780  FunctionRNA *func, *nextfunc;
781  PropertyRNA *prop, *nextprop;
782  PropertyRNA *parm, *nextparm;
783 
784 # if 0
785  if (srna->flag & STRUCT_RUNTIME) {
786  if (RNA_struct_py_type_get(srna)) {
787  fprintf(stderr, "%s '%s' freed while holding a python reference.", srna->identifier);
788  }
789  }
790 # endif
791 
792  for (prop = srna->cont.properties.first; prop; prop = nextprop) {
793  nextprop = prop->next;
794 
796 
797  if (prop->flag_internal & PROP_INTERN_RUNTIME) {
798  rna_freelinkN(&srna->cont.properties, prop);
799  }
800  }
801 
802  for (func = srna->functions.first; func; func = nextfunc) {
803  nextfunc = func->cont.next;
804 
805  for (parm = func->cont.properties.first; parm; parm = nextparm) {
806  nextparm = parm->next;
807 
809 
810  if (parm->flag_internal & PROP_INTERN_RUNTIME) {
811  rna_freelinkN(&func->cont.properties, parm);
812  }
813  }
814 
816 
817  if (func->flag & FUNC_RUNTIME) {
818  rna_freelinkN(&srna->functions, func);
819  }
820  }
821 
822  rna_brna_structs_remove_and_free(brna, srna);
823 #else
824  UNUSED_VARS(brna, srna);
825 #endif
826 }
827 
828 void RNA_free(BlenderRNA *brna)
829 {
830  StructRNA *srna, *nextsrna;
831  FunctionRNA *func;
832 
834  brna->structs_map = NULL;
835 
836  if (DefRNA.preprocess) {
837  RNA_define_free(brna);
838 
839  for (srna = brna->structs.first; srna; srna = srna->cont.next) {
840  for (func = srna->functions.first; func; func = func->cont.next) {
841  rna_freelistN(&func->cont.properties);
842  }
843 
844  rna_freelistN(&srna->cont.properties);
845  rna_freelistN(&srna->functions);
846  }
847 
848  rna_freelistN(&brna->structs);
849 
850  MEM_freeN(brna);
851  }
852  else {
853  for (srna = brna->structs.first; srna; srna = nextsrna) {
854  nextsrna = srna->cont.next;
855  RNA_struct_free(brna, srna);
856  }
857  }
858 
859 #ifndef RNA_RUNTIME
860  BLI_ghash_free(g_version_data.struct_map_static_from_alias, NULL, NULL);
861  g_version_data.struct_map_static_from_alias = NULL;
862 #endif
863 }
864 
866 {
867  switch (type) {
868  case PROP_BOOLEAN:
869  return sizeof(BoolPropertyRNA);
870  case PROP_INT:
871  return sizeof(IntPropertyRNA);
872  case PROP_FLOAT:
873  return sizeof(FloatPropertyRNA);
874  case PROP_STRING:
875  return sizeof(StringPropertyRNA);
876  case PROP_ENUM:
877  return sizeof(EnumPropertyRNA);
878  case PROP_POINTER:
879  return sizeof(PointerPropertyRNA);
880  case PROP_COLLECTION:
881  return sizeof(CollectionPropertyRNA);
882  default:
883  return 0;
884  }
885 }
886 
888 {
889  StructDefRNA *ds;
890 
891  for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
892  if (ds->srna == srna) {
893  return ds;
894  }
895  }
896 
897  return NULL;
898 }
899 
900 StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
901 {
902  StructRNA *srna;
903  StructDefRNA *ds = NULL, *dsfrom = NULL;
904  PropertyRNA *prop;
905 
906  if (DefRNA.preprocess) {
907  char error[512];
908 
909  if (rna_validate_identifier(identifier, error, false) == 0) {
910  CLOG_ERROR(&LOG, "struct identifier \"%s\" error - %s", identifier, error);
911  DefRNA.error = true;
912  }
913  }
914 
915  srna = MEM_callocN(sizeof(StructRNA), "StructRNA");
916  DefRNA.laststruct = srna;
917 
918  if (srnafrom) {
919  /* copy from struct to derive stuff, a bit clumsy since we can't
920  * use MEM_dupallocN, data structs may not be alloced but builtin */
921  memcpy(srna, srnafrom, sizeof(StructRNA));
922  srna->cont.prophash = NULL;
925  srna->py_type = NULL;
926 
927  srna->base = srnafrom;
928 
929  if (DefRNA.preprocess) {
930  dsfrom = rna_find_def_struct(srnafrom);
931  }
932  else {
933  if (srnafrom->flag & STRUCT_PUBLIC_NAMESPACE_INHERIT) {
935  }
936  else {
938  }
939  }
940  }
941 
942  srna->identifier = identifier;
943  srna->name = identifier; /* may be overwritten later RNA_def_struct_ui_text */
944  srna->description = "";
945  /* may be overwritten later RNA_def_struct_translation_context */
947  if (!srnafrom) {
948  srna->icon = ICON_DOT;
949  srna->flag |= STRUCT_UNDO;
950  }
951 
952  if (DefRNA.preprocess) {
953  srna->flag |= STRUCT_PUBLIC_NAMESPACE;
954  }
955 
956  rna_brna_structs_add(brna, srna);
957 
958  if (DefRNA.preprocess) {
959  ds = MEM_callocN(sizeof(StructDefRNA), "StructDefRNA");
960  ds->srna = srna;
961  rna_addtail(&DefRNA.structs, ds);
962 
963  if (dsfrom) {
964  ds->dnafromname = dsfrom->dnaname;
965  }
966  }
967 
968  /* in preprocess, try to find sdna */
969  if (DefRNA.preprocess) {
970  RNA_def_struct_sdna(srna, srna->identifier);
971  }
972  else {
973  srna->flag |= STRUCT_RUNTIME;
974  }
975 
976  if (srnafrom) {
977  srna->nameproperty = srnafrom->nameproperty;
978  srna->iteratorproperty = srnafrom->iteratorproperty;
979  }
980  else {
981  /* define some builtin properties */
982  prop = RNA_def_property(&srna->cont, "rna_properties", PROP_COLLECTION, PROP_NONE);
984  RNA_def_property_ui_text(prop, "Properties", "RNA property collection");
985 
986  if (DefRNA.preprocess) {
987  RNA_def_property_struct_type(prop, "Property");
989  "rna_builtin_properties_begin",
990  "rna_builtin_properties_next",
991  "rna_iterator_listbase_end",
992  "rna_builtin_properties_get",
993  NULL,
994  NULL,
995  "rna_builtin_properties_lookup_string",
996  NULL);
997  }
998  else {
999 #ifdef RNA_RUNTIME
1004  cprop->item_type = &RNA_Property;
1005 #endif
1006  }
1007 
1008  prop = RNA_def_property(&srna->cont, "rna_type", PROP_POINTER, PROP_NONE);
1010  RNA_def_property_ui_text(prop, "RNA", "RNA type definition");
1011 
1012  if (DefRNA.preprocess) {
1013  RNA_def_property_struct_type(prop, "Struct");
1014  RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL, NULL, NULL);
1015  }
1016  else {
1017 #ifdef RNA_RUNTIME
1018  PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
1019  pprop->get = rna_builtin_type_get;
1020  pprop->type = &RNA_Struct;
1021 #endif
1022  }
1023  }
1024 
1025  return srna;
1026 }
1027 
1028 StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
1029 {
1030  StructRNA *srnafrom = NULL;
1031 
1032  /* only use RNA_def_struct() while pre-processing, otherwise use RNA_def_struct_ptr() */
1034 
1035  if (from) {
1036  /* find struct to derive from */
1037  /* Inline RNA_struct_find(...) because it won't link from here. */
1038  srnafrom = BLI_ghash_lookup(brna->structs_map, from);
1039  if (!srnafrom) {
1040  CLOG_ERROR(&LOG, "struct %s not found to define %s.", from, identifier);
1041  DefRNA.error = true;
1042  }
1043  }
1044 
1045  return RNA_def_struct_ptr(brna, identifier, srnafrom);
1046 }
1047 
1048 void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
1049 {
1050  StructDefRNA *ds;
1051 
1052  if (!DefRNA.preprocess) {
1053  CLOG_ERROR(&LOG, "only during preprocessing.");
1054  return;
1055  }
1056 
1057  ds = rna_find_def_struct(srna);
1058 
1059  /* There are far too many structs which initialize without valid DNA struct names,
1060  * this can't be checked without adding an option to disable
1061  * (tested this and it means changes all over - Campbell) */
1062 #if 0
1063  if (DNA_struct_find_nr_wrapper(DefRNA.sdna, structname) == -1) {
1064  if (!DefRNA.silent) {
1065  CLOG_ERROR(&LOG, "%s not found.", structname);
1066  DefRNA.error = true;
1067  }
1068  return;
1069  }
1070 #endif
1071 
1072  ds->dnaname = structname;
1073 }
1074 
1075 void RNA_def_struct_sdna_from(StructRNA *srna, const char *structname, const char *propname)
1076 {
1077  StructDefRNA *ds;
1078 
1079  if (!DefRNA.preprocess) {
1080  CLOG_ERROR(&LOG, "only during preprocessing.");
1081  return;
1082  }
1083 
1084  ds = rna_find_def_struct(srna);
1085 
1086  if (!ds->dnaname) {
1087  CLOG_ERROR(&LOG, "%s base struct must know DNA already.", structname);
1088  return;
1089  }
1090 
1091  if (DNA_struct_find_nr_wrapper(DefRNA.sdna, structname) == -1) {
1092  if (!DefRNA.silent) {
1093  CLOG_ERROR(&LOG, "%s not found.", structname);
1094  DefRNA.error = true;
1095  }
1096  return;
1097  }
1098 
1099  ds->dnafromprop = propname;
1100  ds->dnaname = structname;
1101 }
1102 
1103 void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
1104 {
1105  if (prop->type != PROP_STRING) {
1106  CLOG_ERROR(&LOG, "\"%s.%s\", must be a string property.", srna->identifier, prop->identifier);
1107  DefRNA.error = true;
1108  }
1109  else if (srna->nameproperty != NULL) {
1110  CLOG_ERROR(
1111  &LOG, "\"%s.%s\", name property is already set.", srna->identifier, prop->identifier);
1112  DefRNA.error = true;
1113  }
1114  else {
1115  srna->nameproperty = prop;
1116  }
1117 }
1118 
1119 void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
1120 {
1121  StructRNA *srnafrom;
1122 
1123  /* find struct to derive from */
1124  srnafrom = BLI_ghash_lookup(brna->structs_map, structname);
1125  if (!srnafrom) {
1126  CLOG_ERROR(&LOG, "struct %s not found for %s.", structname, srna->identifier);
1127  DefRNA.error = true;
1128  }
1129 
1130  srna->nested = srnafrom;
1131 }
1132 
1133 void RNA_def_struct_flag(StructRNA *srna, int flag)
1134 {
1135  srna->flag |= flag;
1136 }
1137 
1139 {
1140  srna->flag &= ~flag;
1141 }
1142 
1143 void RNA_def_struct_property_tags(StructRNA *srna, const EnumPropertyItem *prop_tag_defines)
1144 {
1145  srna->prop_tag_defines = prop_tag_defines;
1146 }
1147 
1148 void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
1149 {
1150  if (!DefRNA.preprocess) {
1151  CLOG_ERROR(&LOG, "only during preprocessing.");
1152  return;
1153  }
1154 
1155  if (refine) {
1156  srna->refine = (StructRefineFunc)refine;
1157  }
1158 }
1159 
1160 void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
1161 {
1162  if (!DefRNA.preprocess) {
1163  CLOG_ERROR(&LOG, "only during preprocessing.");
1164  return;
1165  }
1166 
1167  if (idproperties) {
1168  srna->idproperties = (IDPropertiesFunc)idproperties;
1169  }
1170 }
1171 
1173  const char *reg,
1174  const char *unreg,
1175  const char *instance)
1176 {
1177  if (!DefRNA.preprocess) {
1178  CLOG_ERROR(&LOG, "only during preprocessing.");
1179  return;
1180  }
1181 
1182  if (reg) {
1183  srna->reg = (StructRegisterFunc)reg;
1184  }
1185  if (unreg) {
1186  srna->unreg = (StructUnregisterFunc)unreg;
1187  }
1188  if (instance) {
1190  }
1191 }
1192 
1193 void RNA_def_struct_path_func(StructRNA *srna, const char *path)
1194 {
1195  if (!DefRNA.preprocess) {
1196  CLOG_ERROR(&LOG, "only during preprocessing.");
1197  return;
1198  }
1199 
1200  if (path) {
1201  srna->path = (StructPathFunc)path;
1202  }
1203 }
1204 
1205 void RNA_def_struct_identifier(BlenderRNA *brna, StructRNA *srna, const char *identifier)
1206 {
1207  if (DefRNA.preprocess) {
1208  CLOG_ERROR(&LOG, "only at runtime.");
1209  return;
1210  }
1211 
1212  /* Operator registration may set twice, see: operator_properties_init */
1213  if (srna->flag & STRUCT_PUBLIC_NAMESPACE) {
1214  if (identifier != srna->identifier) {
1215  if (srna->identifier[0] != '\0') {
1216  BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
1217  }
1218  if (identifier[0] != '\0') {
1219  BLI_ghash_insert(brna->structs_map, (void *)identifier, srna);
1220  }
1221  }
1222  }
1223 
1224  srna->identifier = identifier;
1225 }
1226 
1227 void RNA_def_struct_identifier_no_struct_map(StructRNA *srna, const char *identifier)
1228 {
1229  if (DefRNA.preprocess) {
1230  CLOG_ERROR(&LOG, "only at runtime.");
1231  return;
1232  }
1233 
1234  srna->identifier = identifier;
1235 }
1236 
1237 void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
1238 {
1239  DESCR_CHECK(description, srna->identifier, NULL);
1240 
1241  srna->name = name;
1242  srna->description = description;
1243 }
1244 
1245 void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
1246 {
1247  srna->icon = icon;
1248 }
1249 
1251 {
1253 }
1254 
1255 /* Property Definition */
1256 
1258  const char *identifier,
1259  int type,
1260  int subtype)
1261 {
1262  // StructRNA *srna = DefRNA.laststruct; /* Invalid for Python defined props. */
1263  ContainerRNA *cont = cont_;
1264  ContainerDefRNA *dcont;
1265  PropertyDefRNA *dprop = NULL;
1266  PropertyRNA *prop;
1267 
1268  if (DefRNA.preprocess) {
1269  char error[512];
1270 
1271  if (rna_validate_identifier(identifier, error, true) == 0) {
1272  CLOG_ERROR(
1273  &LOG, "property identifier \"%s.%s\" - %s", CONTAINER_RNA_ID(cont), identifier, error);
1274  DefRNA.error = true;
1275  }
1276 
1277  dcont = rna_find_container_def(cont);
1278 
1279  /* TODO: detect super-type collisions. */
1280  if (rna_findlink(&dcont->properties, identifier)) {
1281  CLOG_ERROR(&LOG, "duplicate identifier \"%s.%s\"", CONTAINER_RNA_ID(cont), identifier);
1282  DefRNA.error = true;
1283  }
1284 
1285  dprop = MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA");
1286  rna_addtail(&dcont->properties, dprop);
1287  }
1288  else {
1289 #ifndef NDEBUG
1290  char error[512];
1291  if (rna_validate_identifier(identifier, error, true) == 0) {
1292  CLOG_ERROR(&LOG,
1293  "runtime property identifier \"%s.%s\" - %s",
1294  CONTAINER_RNA_ID(cont),
1295  identifier,
1296  error);
1297  DefRNA.error = true;
1298  }
1299 #endif
1300  }
1301 
1302  prop = MEM_callocN(rna_property_type_sizeof(type), "PropertyRNA");
1303 
1304  switch (type) {
1305  case PROP_BOOLEAN:
1306  if (DefRNA.preprocess) {
1307  if ((subtype & ~PROP_LAYER_MEMBER) != PROP_NONE) {
1308  CLOG_ERROR(&LOG,
1309  "subtype does not apply to 'PROP_BOOLEAN' \"%s.%s\"",
1310  CONTAINER_RNA_ID(cont),
1311  identifier);
1312  DefRNA.error = true;
1313  }
1314  }
1315  break;
1316  case PROP_INT: {
1317  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
1318 
1319 #ifndef RNA_RUNTIME
1320  if (subtype == PROP_DISTANCE) {
1321  CLOG_ERROR(&LOG,
1322  "subtype does not apply to 'PROP_INT' \"%s.%s\"",
1323  CONTAINER_RNA_ID(cont),
1324  identifier);
1325  DefRNA.error = true;
1326  }
1327 #endif
1328 
1329  iprop->hardmin = (subtype == PROP_UNSIGNED) ? 0 : INT_MIN;
1330  iprop->hardmax = INT_MAX;
1331 
1332  iprop->softmin = (subtype == PROP_UNSIGNED) ? 0 : -10000; /* rather arbitrary. */
1333  iprop->softmax = 10000;
1334  iprop->step = 1;
1335  break;
1336  }
1337  case PROP_FLOAT: {
1338  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
1339 
1340  fprop->hardmin = (subtype == PROP_UNSIGNED) ? 0.0f : -FLT_MAX;
1341  fprop->hardmax = FLT_MAX;
1342 
1343  if (ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) {
1344  fprop->softmin = fprop->hardmin = 0.0f;
1345  fprop->softmax = 1.0f;
1346  }
1347  else if (subtype == PROP_FACTOR) {
1348  fprop->softmin = fprop->hardmin = 0.0f;
1349  fprop->softmax = fprop->hardmax = 1.0f;
1350  }
1351  else {
1352  fprop->softmin = (subtype == PROP_UNSIGNED) ? 0.0f : -10000.0f; /* rather arbitrary. */
1353  fprop->softmax = 10000.0f;
1354  }
1355  fprop->step = 10;
1356  fprop->precision = 3;
1357  break;
1358  }
1359  case PROP_STRING: {
1360  StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
1361  /* By default don't allow NULL string args, callers may clear. */
1363  sprop->defaultvalue = "";
1364  break;
1365  }
1366  case PROP_POINTER:
1367  prop->flag |= PROP_THICK_WRAP; /* needed for default behavior when PARM_RNAPTR is set */
1368  break;
1369  case PROP_ENUM:
1370  case PROP_COLLECTION:
1371  break;
1372  default:
1373  CLOG_ERROR(&LOG, "\"%s.%s\", invalid property type.", CONTAINER_RNA_ID(cont), identifier);
1374  DefRNA.error = true;
1375  return NULL;
1376  }
1377 
1378  if (DefRNA.preprocess) {
1379  dprop->cont = cont;
1380  dprop->prop = prop;
1381  }
1382 
1383  prop->magic = RNA_MAGIC;
1384  prop->identifier = identifier;
1385  prop->type = type;
1386  prop->subtype = subtype;
1387  prop->name = identifier;
1388  prop->description = "";
1390  /* a priori not raw editable */
1391  prop->rawtype = -1;
1392 
1394  prop->flag = PROP_EDITABLE;
1395 
1396  if (type != PROP_STRING) {
1397 #ifdef RNA_RUNTIME
1398  prop->flag |= PROP_ANIMATABLE;
1399 #else
1400  if (DefRNA.animate) {
1401  prop->flag |= PROP_ANIMATABLE;
1402  }
1403 #endif
1404  }
1405  }
1406 
1407 #ifndef RNA_RUNTIME
1408  if (DefRNA.make_overridable) {
1410  }
1411 #endif
1412 
1413  if (type == PROP_STRING) {
1414  /* used so generated 'get/length/set' functions skip a NULL check
1415  * in some cases we want it */
1417  }
1418 
1419  if (DefRNA.preprocess) {
1420  switch (type) {
1421  case PROP_BOOLEAN:
1422  DefRNA.silent = true;
1423  RNA_def_property_boolean_sdna(prop, NULL, identifier, 0);
1424  DefRNA.silent = false;
1425  break;
1426  case PROP_INT: {
1427  DefRNA.silent = true;
1428  RNA_def_property_int_sdna(prop, NULL, identifier);
1429  DefRNA.silent = false;
1430  break;
1431  }
1432  case PROP_FLOAT: {
1433  DefRNA.silent = true;
1434  RNA_def_property_float_sdna(prop, NULL, identifier);
1435  DefRNA.silent = false;
1436  break;
1437  }
1438  case PROP_STRING: {
1439  DefRNA.silent = true;
1440  RNA_def_property_string_sdna(prop, NULL, identifier);
1441  DefRNA.silent = false;
1442  break;
1443  }
1444  case PROP_ENUM:
1445  DefRNA.silent = true;
1446  RNA_def_property_enum_sdna(prop, NULL, identifier);
1447  DefRNA.silent = false;
1448  break;
1449  case PROP_POINTER:
1450  DefRNA.silent = true;
1451  RNA_def_property_pointer_sdna(prop, NULL, identifier);
1452  DefRNA.silent = false;
1453  break;
1454  case PROP_COLLECTION:
1455  DefRNA.silent = true;
1456  RNA_def_property_collection_sdna(prop, NULL, identifier, NULL);
1457  DefRNA.silent = false;
1458  break;
1459  }
1460  }
1461  else {
1462  prop->flag |= PROP_IDPROPERTY;
1464 #ifdef RNA_RUNTIME
1465  if (cont->prophash) {
1466  BLI_ghash_insert(cont->prophash, (void *)prop->identifier, prop);
1467  }
1468 #endif
1469  }
1470 
1471  /* Override handling. */
1472  if (DefRNA.preprocess) {
1473  prop->override_diff = (RNAPropOverrideDiff) "rna_property_override_diff_default";
1474  prop->override_store = (RNAPropOverrideStore) "rna_property_override_store_default";
1475  prop->override_apply = (RNAPropOverrideApply) "rna_property_override_apply_default";
1476  }
1477  /* TODO: do we want that for runtime-defined stuff too? I’d say no, but... maybe yes :/ */
1478 
1479 #ifndef RNA_RUNTIME
1480  /* Both are typically cleared. */
1482  prop, DefRNA.fallback.property_update.noteflag, DefRNA.fallback.property_update.updatefunc);
1483 #endif
1484 
1485  rna_addtail(&cont->properties, prop);
1486 
1487  return prop;
1488 }
1489 
1491 {
1492  prop->flag |= flag;
1493 }
1494 
1496 {
1497  prop->flag &= ~flag;
1498  if (flag & PROP_PTR_NO_OWNERSHIP) {
1500  }
1501 }
1502 
1504 {
1505  prop->flag_override |= flag;
1506 }
1507 
1509 {
1510  prop->flag_override &= ~flag;
1511 }
1512 
1513 void RNA_def_property_tags(PropertyRNA *prop, int tags)
1514 {
1515  prop->tags |= tags;
1516 }
1517 
1519  PropertyFlag flag_property,
1520  ParameterFlag flag_parameter)
1521 {
1522  prop->flag |= flag_property;
1523  prop->flag_parameter |= flag_parameter;
1524 }
1525 
1527  PropertyFlag flag_property,
1528  ParameterFlag flag_parameter)
1529 {
1530  prop->flag &= ~flag_property;
1531  prop->flag_parameter &= ~flag_parameter;
1532 }
1533 
1535 {
1536  prop->subtype = subtype;
1537 }
1538 
1540 {
1541  StructRNA *srna = DefRNA.laststruct;
1542 
1543  if (length < 0) {
1544  CLOG_ERROR(&LOG,
1545  "\"%s.%s\", array length must be zero of greater.",
1546  srna->identifier,
1547  prop->identifier);
1548  DefRNA.error = true;
1549  return;
1550  }
1551 
1552  if (length > RNA_MAX_ARRAY_LENGTH) {
1553  CLOG_ERROR(&LOG,
1554  "\"%s.%s\", array length must be smaller than %d.",
1555  srna->identifier,
1556  prop->identifier,
1558  DefRNA.error = true;
1559  return;
1560  }
1561 
1562  if (prop->arraydimension > 1) {
1563  CLOG_ERROR(&LOG,
1564  "\"%s.%s\", array dimensions has been set to %u but would be overwritten as 1.",
1565  srna->identifier,
1566  prop->identifier,
1567  prop->arraydimension);
1568  DefRNA.error = true;
1569  return;
1570  }
1571 
1572  switch (prop->type) {
1573  case PROP_BOOLEAN:
1574  case PROP_INT:
1575  case PROP_FLOAT:
1576  prop->arraylength[0] = length;
1577  prop->totarraylength = length;
1578  prop->arraydimension = 1;
1579  break;
1580  default:
1581  CLOG_ERROR(&LOG,
1582  "\"%s.%s\", only boolean/int/float can be array.",
1583  srna->identifier,
1584  prop->identifier);
1585  DefRNA.error = true;
1586  break;
1587  }
1588 }
1589 
1590 const float rna_default_quaternion[4] = {1, 0, 0, 0};
1591 const float rna_default_axis_angle[4] = {0, 0, 1, 0};
1592 const float rna_default_scale_3d[3] = {1, 1, 1};
1593 
1594 const int rna_matrix_dimsize_3x3[] = {3, 3};
1595 const int rna_matrix_dimsize_4x4[] = {4, 4};
1596 const int rna_matrix_dimsize_4x2[] = {4, 2};
1597 
1598 void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
1599 {
1600  StructRNA *srna = DefRNA.laststruct;
1601  int i;
1602 
1603  if (dimension < 1 || dimension > RNA_MAX_ARRAY_DIMENSION) {
1604  CLOG_ERROR(&LOG,
1605  "\"%s.%s\", array dimension must be between 1 and %d.",
1606  srna->identifier,
1607  prop->identifier,
1609  DefRNA.error = true;
1610  return;
1611  }
1612 
1613  switch (prop->type) {
1614  case PROP_BOOLEAN:
1615  case PROP_INT:
1616  case PROP_FLOAT:
1617  break;
1618  default:
1619  CLOG_ERROR(&LOG,
1620  "\"%s.%s\", only boolean/int/float can be array.",
1621  srna->identifier,
1622  prop->identifier);
1623  DefRNA.error = true;
1624  break;
1625  }
1626 
1627  prop->arraydimension = dimension;
1628  prop->totarraylength = 0;
1629 
1630  if (length) {
1631  memcpy(prop->arraylength, length, sizeof(int) * dimension);
1632 
1633  prop->totarraylength = length[0];
1634  for (i = 1; i < dimension; i++) {
1635  prop->totarraylength *= length[i];
1636  }
1637  }
1638  else {
1639  memset(prop->arraylength, 0, sizeof(prop->arraylength));
1640  }
1641 
1642  /* TODO: make sure `arraylength` values are sane. */
1643 }
1644 
1645 void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
1646 {
1647  DESCR_CHECK(description, prop->identifier, NULL);
1648 
1649  prop->name = name;
1650  prop->description = description;
1651 }
1652 
1653 void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
1654 {
1655  prop->icon = icon;
1656  if (consecutive != 0) {
1657  prop->flag |= PROP_ICONS_CONSECUTIVE;
1658  }
1659  if (consecutive < 0) {
1660  prop->flag |= PROP_ICONS_REVERSE;
1661  }
1662 }
1663 
1665  PropertyRNA *prop, double min, double max, double step, int precision)
1666 {
1667  StructRNA *srna = DefRNA.laststruct;
1668 
1669 #ifndef NDEBUG
1670  if (min > max) {
1671  CLOG_ERROR(&LOG, "\"%s.%s\", min > max.", srna->identifier, prop->identifier);
1672  DefRNA.error = true;
1673  }
1674 
1675  if (step < 0 || step > 100) {
1676  CLOG_ERROR(&LOG, "\"%s.%s\", step outside range.", srna->identifier, prop->identifier);
1677  DefRNA.error = true;
1678  }
1679 
1680  if (step == 0) {
1681  CLOG_ERROR(&LOG, "\"%s.%s\", step is zero.", srna->identifier, prop->identifier);
1682  DefRNA.error = true;
1683  }
1684 
1685  if (precision < -1 || precision > UI_PRECISION_FLOAT_MAX) {
1686  CLOG_ERROR(&LOG, "\"%s.%s\", precision outside range.", srna->identifier, prop->identifier);
1687  DefRNA.error = true;
1688  }
1689 #endif
1690 
1691  switch (prop->type) {
1692  case PROP_INT: {
1693  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
1694  iprop->softmin = (int)min;
1695  iprop->softmax = (int)max;
1696  iprop->step = (int)step;
1697  break;
1698  }
1699  case PROP_FLOAT: {
1700  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
1701  fprop->softmin = (float)min;
1702  fprop->softmax = (float)max;
1703  fprop->step = (float)step;
1704  fprop->precision = (int)precision;
1705  break;
1706  }
1707  default:
1708  CLOG_ERROR(
1709  &LOG, "\"%s.%s\", invalid type for ui range.", srna->identifier, prop->identifier);
1710  DefRNA.error = true;
1711  break;
1712  }
1713 }
1714 
1716 {
1717  StructRNA *srna = DefRNA.laststruct;
1718 
1719  switch (prop->type) {
1720  case PROP_INT: {
1721  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
1722  iprop->ui_scale_type = ui_scale_type;
1723  break;
1724  }
1725  case PROP_FLOAT: {
1726  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
1727  fprop->ui_scale_type = ui_scale_type;
1728  break;
1729  }
1730  default:
1731  CLOG_ERROR(&LOG, "\"%s.%s\", invalid type for scale.", srna->identifier, prop->identifier);
1732  DefRNA.error = true;
1733  break;
1734  }
1735 }
1736 
1737 void RNA_def_property_range(PropertyRNA *prop, double min, double max)
1738 {
1739  StructRNA *srna = DefRNA.laststruct;
1740 
1741 #ifdef DEBUG
1742  if (min > max) {
1743  CLOG_ERROR(&LOG, "\"%s.%s\", min > max.", srna->identifier, prop->identifier);
1744  DefRNA.error = true;
1745  }
1746 #endif
1747 
1748  switch (prop->type) {
1749  case PROP_INT: {
1750  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
1751  iprop->hardmin = (int)min;
1752  iprop->hardmax = (int)max;
1753  iprop->softmin = MAX2((int)min, iprop->hardmin);
1754  iprop->softmax = MIN2((int)max, iprop->hardmax);
1755  break;
1756  }
1757  case PROP_FLOAT: {
1758  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
1759  fprop->hardmin = (float)min;
1760  fprop->hardmax = (float)max;
1761  fprop->softmin = MAX2((float)min, fprop->hardmin);
1762  fprop->softmax = MIN2((float)max, fprop->hardmax);
1763  break;
1764  }
1765  default:
1766  CLOG_ERROR(&LOG, "\"%s.%s\", invalid type for range.", srna->identifier, prop->identifier);
1767  DefRNA.error = true;
1768  break;
1769  }
1770 }
1771 
1773 {
1774  StructRNA *srna = DefRNA.laststruct;
1775 
1776  if (!DefRNA.preprocess) {
1777  fprintf(stderr, "\"%s.%s\": only during preprocessing.", srna->identifier, prop->identifier);
1778  return;
1779  }
1780 
1781  switch (prop->type) {
1782  case PROP_POINTER: {
1783  PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
1784  pprop->type = (StructRNA *)type;
1785  break;
1786  }
1787  case PROP_COLLECTION: {
1789  cprop->item_type = (StructRNA *)type;
1790  break;
1791  }
1792  default:
1793  CLOG_ERROR(
1794  &LOG, "\"%s.%s\", invalid type for struct type.", srna->identifier, prop->identifier);
1795  DefRNA.error = true;
1796  break;
1797  }
1798 }
1799 
1801 {
1802  /* Never valid when defined from python. */
1803  StructRNA *srna = DefRNA.laststruct;
1804 
1805  if (DefRNA.preprocess) {
1806  CLOG_ERROR(&LOG, "only at runtime.");
1807  return;
1808  }
1809 
1810  const bool is_id_type = (type->flag & STRUCT_ID) != 0;
1811 
1812  switch (prop->type) {
1813  case PROP_POINTER: {
1814  PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
1815  pprop->type = type;
1816 
1817  /* Check between `cont` and `srna` is mandatory, since when defined from python
1818  * `DefRNA.laststruct` is not valid.
1819  * This is not an issue as bpy code already checks for this case on its own. */
1820  if (cont == srna && (srna->flag & STRUCT_NO_DATABLOCK_IDPROPERTIES) != 0 && is_id_type) {
1821  CLOG_ERROR(&LOG,
1822  "\"%s.%s\", this struct type (probably an Operator, Keymap or UserPreference) "
1823  "does not accept ID pointer properties.",
1824  CONTAINER_RNA_ID(cont),
1825  prop->identifier);
1826  DefRNA.error = true;
1827  return;
1828  }
1829 
1830  if (type && (type->flag & STRUCT_ID_REFCOUNT)) {
1831  prop->flag |= PROP_ID_REFCOUNT;
1832  }
1833 
1834  break;
1835  }
1836  case PROP_COLLECTION: {
1838  cprop->item_type = type;
1839  break;
1840  }
1841  default:
1842  CLOG_ERROR(&LOG,
1843  "\"%s.%s\", invalid type for struct type.",
1844  CONTAINER_RNA_ID(cont),
1845  prop->identifier);
1846  DefRNA.error = true;
1847  return;
1848  }
1849 
1850  if (is_id_type) {
1851  prop->flag |= PROP_PTR_NO_OWNERSHIP;
1852  }
1853 }
1854 
1855 void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type)
1856 {
1857  StructRNA *srna = DefRNA.laststruct;
1858  switch (prop->type) {
1859  case PROP_ENUM: {
1860  EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
1861  eprop->native_enum_type = native_enum_type;
1862  break;
1863  }
1864  default:
1865  CLOG_ERROR(
1866  &LOG, "\"%s.%s\", invalid type for struct type.", srna->identifier, prop->identifier);
1867  DefRNA.error = true;
1868  break;
1869  }
1870 }
1871 
1873 {
1874  StructRNA *srna = DefRNA.laststruct;
1875  int i, defaultfound = 0;
1876 
1877  switch (prop->type) {
1878  case PROP_ENUM: {
1879  EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
1880  eprop->item = (EnumPropertyItem *)item;
1881  eprop->totitem = 0;
1882  for (i = 0; item[i].identifier; i++) {
1883  eprop->totitem++;
1884 
1885  if (item[i].identifier[0]) {
1886  /* Don't allow spaces in internal enum items (it's fine for Python ones). */
1887  if (DefRNA.preprocess && strstr(item[i].identifier, " ")) {
1888  CLOG_ERROR(&LOG,
1889  "\"%s.%s\", enum identifiers must not contain spaces.",
1890  srna->identifier,
1891  prop->identifier);
1892  DefRNA.error = true;
1893  break;
1894  }
1895  if (item[i].value == eprop->defaultvalue) {
1896  defaultfound = 1;
1897  }
1898  }
1899  }
1900 
1901  if (!defaultfound) {
1902  for (i = 0; item[i].identifier; i++) {
1903  if (item[i].identifier[0]) {
1904  eprop->defaultvalue = item[i].value;
1905  break;
1906  }
1907  }
1908  }
1909 
1910  break;
1911  }
1912  default:
1913  CLOG_ERROR(
1914  &LOG, "\"%s.%s\", invalid type for struct type.", srna->identifier, prop->identifier);
1915  DefRNA.error = true;
1916  break;
1917  }
1918 }
1919 
1921 {
1922  StructRNA *srna = DefRNA.laststruct;
1923 
1924  switch (prop->type) {
1925  case PROP_STRING: {
1926  StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
1927  sprop->maxlength = maxlength;
1928  break;
1929  }
1930  default:
1931  CLOG_ERROR(&LOG, "\"%s.%s\", type is not string.", srna->identifier, prop->identifier);
1932  DefRNA.error = true;
1933  break;
1934  }
1935 }
1936 
1938 {
1939  StructRNA *srna = DefRNA.laststruct;
1940 
1941  switch (prop->type) {
1942  case PROP_BOOLEAN: {
1943  BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
1944  BLI_assert(ELEM(value, false, true));
1945 #ifndef RNA_RUNTIME
1946  /* Default may be set from items. */
1947  if (bprop->defaultvalue) {
1948  CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
1949  }
1950 #endif
1951  bprop->defaultvalue = value;
1952  break;
1953  }
1954  default:
1955  CLOG_ERROR(&LOG, "\"%s.%s\", type is not boolean.", srna->identifier, prop->identifier);
1956  DefRNA.error = true;
1957  break;
1958  }
1959 }
1960 
1962 {
1963  StructRNA *srna = DefRNA.laststruct;
1964 
1965  switch (prop->type) {
1966  case PROP_BOOLEAN: {
1967  BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
1968  bprop->defaultarray = array;
1969  break;
1970  }
1971  default:
1972  CLOG_ERROR(&LOG, "\"%s.%s\", type is not boolean.", srna->identifier, prop->identifier);
1973  DefRNA.error = true;
1974  break;
1975  }
1976 }
1977 
1979 {
1980  StructRNA *srna = DefRNA.laststruct;
1981 
1982  switch (prop->type) {
1983  case PROP_INT: {
1984  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
1985 #ifndef RNA_RUNTIME
1986  if (iprop->defaultvalue != 0) {
1987  CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
1988  }
1989 #endif
1990  iprop->defaultvalue = value;
1991  break;
1992  }
1993  default:
1994  CLOG_ERROR(&LOG, "\"%s.%s\", type is not int.", srna->identifier, prop->identifier);
1995  DefRNA.error = true;
1996  break;
1997  }
1998 }
1999 
2001 {
2002  StructRNA *srna = DefRNA.laststruct;
2003 
2004  switch (prop->type) {
2005  case PROP_INT: {
2006  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
2007 #ifndef RNA_RUNTIME
2008  if (iprop->defaultarray != NULL) {
2009  CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
2010  }
2011 #endif
2012  iprop->defaultarray = array;
2013  break;
2014  }
2015  default:
2016  CLOG_ERROR(&LOG, "\"%s.%s\", type is not int.", srna->identifier, prop->identifier);
2017  DefRNA.error = true;
2018  break;
2019  }
2020 }
2021 
2023 {
2024  StructRNA *srna = DefRNA.laststruct;
2025 
2026  switch (prop->type) {
2027  case PROP_FLOAT: {
2028  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
2029 #ifndef RNA_RUNTIME
2030  if (fprop->defaultvalue != 0) {
2031  CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
2032  }
2033 #endif
2034  fprop->defaultvalue = value;
2035  break;
2036  }
2037  default:
2038  CLOG_ERROR(&LOG, "\"%s.%s\", type is not float.", srna->identifier, prop->identifier);
2039  DefRNA.error = true;
2040  break;
2041  }
2042 }
2044 {
2045  StructRNA *srna = DefRNA.laststruct;
2046 
2047  switch (prop->type) {
2048  case PROP_FLOAT: {
2049  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
2050 #ifndef RNA_RUNTIME
2051  if (fprop->defaultarray != NULL) {
2052  CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
2053  }
2054 #endif
2055  fprop->defaultarray = array; /* WARNING, this array must not come from the stack and lost */
2056  break;
2057  }
2058  default:
2059  CLOG_ERROR(&LOG, "\"%s.%s\", type is not float.", srna->identifier, prop->identifier);
2060  DefRNA.error = true;
2061  break;
2062  }
2063 }
2064 
2065 void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
2066 {
2067  StructRNA *srna = DefRNA.laststruct;
2068 
2069  switch (prop->type) {
2070  case PROP_STRING: {
2071  StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
2072 
2073  if (value == NULL) {
2074  CLOG_ERROR(&LOG,
2075  "\"%s.%s\", NULL string passed (don't call in this case).",
2076  srna->identifier,
2077  prop->identifier);
2078  DefRNA.error = true;
2079  break;
2080  }
2081 
2082  if (!value[0]) {
2083  CLOG_ERROR(&LOG,
2084  "\"%s.%s\", empty string passed (don't call in this case).",
2085  srna->identifier,
2086  prop->identifier);
2087  DefRNA.error = true;
2088  // BLI_assert(0);
2089  break;
2090  }
2091 #ifndef RNA_RUNTIME
2092  if (sprop->defaultvalue != NULL && sprop->defaultvalue[0]) {
2093  CLOG_ERROR(&LOG, "\"%s.%s\", set from DNA.", srna->identifier, prop->identifier);
2094  }
2095 #endif
2096  sprop->defaultvalue = value;
2097  break;
2098  }
2099  default:
2100  CLOG_ERROR(&LOG, "\"%s.%s\", type is not string.", srna->identifier, prop->identifier);
2101  DefRNA.error = true;
2102  break;
2103  }
2104 }
2105 
2107 {
2108  StructRNA *srna = DefRNA.laststruct;
2109  int i, defaultfound = 0;
2110 
2111  switch (prop->type) {
2112  case PROP_ENUM: {
2113  EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
2114  eprop->defaultvalue = value;
2115 
2116  if (prop->flag & PROP_ENUM_FLAG) {
2117  /* check all bits are accounted for */
2118  int totflag = 0;
2119  for (i = 0; i < eprop->totitem; i++) {
2120  if (eprop->item[i].identifier[0]) {
2121  totflag |= eprop->item[i].value;
2122  }
2123  }
2124 
2125  if (eprop->defaultvalue & ~totflag) {
2126  CLOG_ERROR(&LOG,
2127  "\"%s.%s\", default includes unused bits (%d).",
2128  srna->identifier,
2129  prop->identifier,
2130  eprop->defaultvalue & ~totflag);
2131  DefRNA.error = true;
2132  }
2133  }
2134  else {
2135  for (i = 0; i < eprop->totitem; i++) {
2136  if (eprop->item[i].identifier[0] && eprop->item[i].value == eprop->defaultvalue) {
2137  defaultfound = 1;
2138  }
2139  }
2140 
2141  if (!defaultfound && eprop->totitem) {
2142  if (value == 0) {
2143  eprop->defaultvalue = eprop->item[0].value;
2144  }
2145  else {
2146  CLOG_ERROR(
2147  &LOG, "\"%s.%s\", default is not in items.", srna->identifier, prop->identifier);
2148  DefRNA.error = true;
2149  }
2150  }
2151  }
2152 
2153  break;
2154  }
2155  default:
2156  CLOG_ERROR(&LOG, "\"%s.%s\", type is not enum.", srna->identifier, prop->identifier);
2157  DefRNA.error = true;
2158  break;
2159  }
2160 }
2161 
2162 /* SDNA */
2163 
2165  const char *structname,
2166  const char *propname)
2167 {
2168  DNAStructMember smember;
2169  StructDefRNA *ds;
2170  PropertyDefRNA *dp;
2171 
2173  if (dp == NULL) {
2174  return NULL;
2175  }
2176 
2177  ds = rna_find_struct_def((StructRNA *)dp->cont);
2178 
2179  if (!structname) {
2180  structname = ds->dnaname;
2181  }
2182  if (!propname) {
2183  propname = prop->identifier;
2184  }
2185 
2186  int dnaoffset = 0;
2187  if (!rna_find_sdna_member(DefRNA.sdna, structname, propname, &smember, &dnaoffset)) {
2188  if (DefRNA.silent) {
2189  return NULL;
2190  }
2191  if (!DefRNA.verify) {
2192  /* some basic values to survive even with sdna info */
2193  dp->dnastructname = structname;
2194  dp->dnaname = propname;
2195  if (prop->type == PROP_BOOLEAN) {
2196  dp->dnaarraylength = 1;
2197  }
2198  if (prop->type == PROP_POINTER) {
2199  dp->dnapointerlevel = 1;
2200  }
2201  dp->dnaoffset = smember.offset;
2202  return dp;
2203  }
2204  CLOG_ERROR(&LOG,
2205  "\"%s.%s\" (identifier \"%s\") not found. Struct must be in DNA.",
2206  structname,
2207  propname,
2208  prop->identifier);
2209  DefRNA.error = true;
2210  return NULL;
2211  }
2212 
2213  if (smember.arraylength > 1) {
2214  prop->arraylength[0] = smember.arraylength;
2215  prop->totarraylength = smember.arraylength;
2216  prop->arraydimension = 1;
2217  }
2218  else {
2219  prop->arraydimension = 0;
2220  prop->totarraylength = 0;
2221  }
2222 
2223  dp->dnastructname = structname;
2224  dp->dnastructfromname = ds->dnafromname;
2225  dp->dnastructfromprop = ds->dnafromprop;
2226  dp->dnaname = propname;
2227  dp->dnatype = smember.type;
2228  dp->dnaarraylength = smember.arraylength;
2229  dp->dnapointerlevel = smember.pointerlevel;
2230  dp->dnaoffset = smember.offset;
2231  dp->dnasize = smember.size;
2232 
2233  return dp;
2234 }
2235 
2237  const char *structname,
2238  const char *propname,
2239  int64_t bit)
2240 {
2241  PropertyDefRNA *dp;
2242  BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
2243  StructRNA *srna = DefRNA.laststruct;
2244 
2245  if (!DefRNA.preprocess) {
2246  CLOG_ERROR(&LOG, "only during preprocessing.");
2247  return;
2248  }
2249 
2250  if (prop->type != PROP_BOOLEAN) {
2251  CLOG_ERROR(&LOG, "\"%s.%s\", type is not boolean.", srna->identifier, prop->identifier);
2252  DefRNA.error = true;
2253  return;
2254  }
2255 
2256  if ((dp = rna_def_property_sdna(prop, structname, propname))) {
2257 
2258  if (!DefRNA.silent) {
2259  /* error check to ensure floats are not wrapped as ints/bools */
2260  if (dp->dnatype && *dp->dnatype && IS_DNATYPE_BOOLEAN_COMPAT(dp->dnatype) == 0) {
2261  CLOG_ERROR(&LOG,
2262  "%s.%s is a '%s' but wrapped as type '%s'.",
2263  srna->identifier,
2264  prop->identifier,
2265  dp->dnatype,
2266  RNA_property_typename(prop->type));
2267  DefRNA.error = true;
2268  return;
2269  }
2270  }
2271 
2272  dp->booleanbit = bit;
2273 
2274 #ifndef RNA_RUNTIME
2275  /* Set the default if possible. */
2276  if (dp->dnaoffset != -1) {
2278  if (SDNAnr != -1) {
2279  const void *default_data = DNA_default_table[SDNAnr];
2280  if (default_data) {
2281  default_data = POINTER_OFFSET(default_data, dp->dnaoffset);
2282  bool has_default = true;
2283  if (prop->totarraylength > 0) {
2284  has_default = false;
2285  if (debugSRNA_defaults) {
2286  fprintf(stderr, "%s default: unsupported boolean array default\n", __func__);
2287  }
2288  }
2289  else {
2290  if (STREQ(dp->dnatype, "char")) {
2291  bprop->defaultvalue = *(const char *)default_data & bit;
2292  }
2293  else if (STREQ(dp->dnatype, "short")) {
2294  bprop->defaultvalue = *(const short *)default_data & bit;
2295  }
2296  else if (STREQ(dp->dnatype, "int")) {
2297  bprop->defaultvalue = *(const int *)default_data & bit;
2298  }
2299  else {
2300  has_default = false;
2301  if (debugSRNA_defaults) {
2302  fprintf(
2303  stderr, "%s default: unsupported boolean type (%s)\n", __func__, dp->dnatype);
2304  }
2305  }
2306 
2307  if (has_default) {
2308  if (dp->booleannegative) {
2309  bprop->defaultvalue = !bprop->defaultvalue;
2310  }
2311 
2312  if (debugSRNA_defaults) {
2313  fprintf(stderr, "value=%d, ", bprop->defaultvalue);
2314  print_default_info(dp);
2315  }
2316  }
2317  }
2318  }
2319  }
2320  }
2321 #else
2322  UNUSED_VARS(bprop);
2323 #endif
2324  }
2325 }
2326 
2328  const char *structname,
2329  const char *propname,
2330  int64_t booleanbit)
2331 {
2332  PropertyDefRNA *dp;
2333 
2334  RNA_def_property_boolean_sdna(prop, structname, propname, booleanbit);
2335 
2337 
2338  if (dp) {
2339  dp->booleannegative = true;
2340  }
2341 }
2342 
2343 void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
2344 {
2345  PropertyDefRNA *dp;
2346  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
2347  StructRNA *srna = DefRNA.laststruct;
2348 
2349  if (!DefRNA.preprocess) {
2350  CLOG_ERROR(&LOG, "only during preprocessing.");
2351  return;
2352  }
2353 
2354  if (prop->type != PROP_INT) {
2355  CLOG_ERROR(&LOG, "\"%s.%s\", type is not int.", srna->identifier, prop->identifier);
2356  DefRNA.error = true;
2357  return;
2358  }
2359 
2360  if ((dp = rna_def_property_sdna(prop, structname, propname))) {
2361 
2362  /* error check to ensure floats are not wrapped as ints/bools */
2363  if (!DefRNA.silent) {
2364  if (dp->dnatype && *dp->dnatype && IS_DNATYPE_INT_COMPAT(dp->dnatype) == 0) {
2365  CLOG_ERROR(&LOG,
2366  "%s.%s is a '%s' but wrapped as type '%s'.",
2367  srna->identifier,
2368  prop->identifier,
2369  dp->dnatype,
2370  RNA_property_typename(prop->type));
2371  DefRNA.error = true;
2372  return;
2373  }
2374  }
2375 
2376  /* SDNA doesn't pass us unsigned unfortunately. */
2377  if (dp->dnatype && STREQ(dp->dnatype, "char")) {
2378  iprop->hardmin = iprop->softmin = CHAR_MIN;
2379  iprop->hardmax = iprop->softmax = CHAR_MAX;
2380  }
2381  else if (dp->dnatype && STREQ(dp->dnatype, "short")) {
2382  iprop->hardmin = iprop->softmin = SHRT_MIN;
2383  iprop->hardmax = iprop->softmax = SHRT_MAX;
2384  }
2385  else if (dp->dnatype && STREQ(dp->dnatype, "int")) {
2386  iprop->hardmin = INT_MIN;
2387  iprop->hardmax = INT_MAX;
2388 
2389  iprop->softmin = -10000; /* rather arbitrary. */
2390  iprop->softmax = 10000;
2391  }
2392  else if (dp->dnatype && STREQ(dp->dnatype, "int8_t")) {
2393  iprop->hardmin = iprop->softmin = INT8_MIN;
2394  iprop->hardmax = iprop->softmax = INT8_MAX;
2395  }
2396 
2398  iprop->hardmin = iprop->softmin = 0;
2399  }
2400 
2401 #ifndef RNA_RUNTIME
2402  /* Set the default if possible. */
2403  if (dp->dnaoffset != -1) {
2405  if (SDNAnr != -1) {
2406  const void *default_data = DNA_default_table[SDNAnr];
2407  if (default_data) {
2408  default_data = POINTER_OFFSET(default_data, dp->dnaoffset);
2409  /* NOTE: Currently doesn't store sign, assume chars are unsigned because
2410  * we build with this enabled, otherwise check 'PROP_UNSIGNED'. */
2411  bool has_default = true;
2412  if (prop->totarraylength > 0) {
2413  const void *default_data_end = POINTER_OFFSET(default_data, dp->dnasize);
2414  const int size_final = sizeof(int) * prop->totarraylength;
2415  if (STREQ(dp->dnatype, "char")) {
2416  int *defaultarray = rna_calloc(size_final);
2417  for (int i = 0; i < prop->totarraylength && default_data < default_data_end; i++) {
2418  defaultarray[i] = *(const char *)default_data;
2419  default_data = POINTER_OFFSET(default_data, sizeof(char));
2420  }
2421  iprop->defaultarray = defaultarray;
2422  }
2423  else if (STREQ(dp->dnatype, "short")) {
2424 
2425  int *defaultarray = rna_calloc(size_final);
2426  for (int i = 0; i < prop->totarraylength && default_data < default_data_end; i++) {
2427  defaultarray[i] = (prop->subtype != PROP_UNSIGNED) ? *(const short *)default_data :
2428  *(const ushort *)default_data;
2429  default_data = POINTER_OFFSET(default_data, sizeof(short));
2430  }
2431  iprop->defaultarray = defaultarray;
2432  }
2433  else if (STREQ(dp->dnatype, "int")) {
2434  int *defaultarray = rna_calloc(size_final);
2435  memcpy(defaultarray, default_data, MIN2(size_final, dp->dnasize));
2436  iprop->defaultarray = defaultarray;
2437  }
2438  else {
2439  has_default = false;
2440  if (debugSRNA_defaults) {
2441  fprintf(stderr,
2442  "%s default: unsupported int array type (%s)\n",
2443  __func__,
2444  dp->dnatype);
2445  }
2446  }
2447 
2448  if (has_default) {
2449  if (debugSRNA_defaults) {
2450  fprintf(stderr, "value=(");
2451  for (int i = 0; i < prop->totarraylength; i++) {
2452  fprintf(stderr, "%d, ", iprop->defaultarray[i]);
2453  }
2454  fprintf(stderr, "), ");
2455  print_default_info(dp);
2456  }
2457  }
2458  }
2459  else {
2460  if (STREQ(dp->dnatype, "char")) {
2461  iprop->defaultvalue = *(const char *)default_data;
2462  }
2463  else if (STREQ(dp->dnatype, "short")) {
2464  iprop->defaultvalue = (prop->subtype != PROP_UNSIGNED) ?
2465  *(const short *)default_data :
2466  *(const ushort *)default_data;
2467  }
2468  else if (STREQ(dp->dnatype, "int")) {
2469  iprop->defaultvalue = (prop->subtype != PROP_UNSIGNED) ? *(const int *)default_data :
2470  *(const uint *)default_data;
2471  }
2472  else {
2473  has_default = false;
2474  if (debugSRNA_defaults) {
2475  fprintf(stderr, "%s default: unsupported int type (%s)\n", __func__, dp->dnatype);
2476  }
2477  }
2478 
2479  if (has_default) {
2480  if (debugSRNA_defaults) {
2481  fprintf(stderr, "value=%d, ", iprop->defaultvalue);
2482  print_default_info(dp);
2483  }
2484  }
2485  }
2486  }
2487  }
2488  }
2489 #endif
2490  }
2491 }
2492 
2493 void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
2494 {
2495  PropertyDefRNA *dp;
2496  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
2497  StructRNA *srna = DefRNA.laststruct;
2498 
2499  if (!DefRNA.preprocess) {
2500  CLOG_ERROR(&LOG, "only during preprocessing.");
2501  return;
2502  }
2503 
2504  if (prop->type != PROP_FLOAT) {
2505  CLOG_ERROR(&LOG, "\"%s.%s\", type is not float.", srna->identifier, prop->identifier);
2506  DefRNA.error = true;
2507  return;
2508  }
2509 
2510  if ((dp = rna_def_property_sdna(prop, structname, propname))) {
2511  /* silent is for internal use */
2512  if (!DefRNA.silent) {
2513  if (dp->dnatype && *dp->dnatype && IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0) {
2514  /* Colors are an exception. these get translated. */
2515  if (prop->subtype != PROP_COLOR_GAMMA) {
2516  CLOG_ERROR(&LOG,
2517  "%s.%s is a '%s' but wrapped as type '%s'.",
2518  srna->identifier,
2519  prop->identifier,
2520  dp->dnatype,
2521  RNA_property_typename(prop->type));
2522  DefRNA.error = true;
2523  return;
2524  }
2525  }
2526  }
2527 
2528  if (dp->dnatype && STREQ(dp->dnatype, "char")) {
2529  fprop->hardmin = fprop->softmin = 0.0f;
2530  fprop->hardmax = fprop->softmax = 1.0f;
2531  }
2532 
2533 #ifndef RNA_RUNTIME
2534  /* Set the default if possible. */
2535  if (dp->dnaoffset != -1) {
2537  if (SDNAnr != -1) {
2538  const void *default_data = DNA_default_table[SDNAnr];
2539  if (default_data) {
2540  default_data = POINTER_OFFSET(default_data, dp->dnaoffset);
2541  bool has_default = true;
2542  if (prop->totarraylength > 0) {
2543  if (STREQ(dp->dnatype, "float")) {
2544  const int size_final = sizeof(float) * prop->totarraylength;
2545  float *defaultarray = rna_calloc(size_final);
2546  memcpy(defaultarray, default_data, MIN2(size_final, dp->dnasize));
2547  fprop->defaultarray = defaultarray;
2548  }
2549  else {
2550  has_default = false;
2551  if (debugSRNA_defaults) {
2552  fprintf(stderr,
2553  "%s default: unsupported float array type (%s)\n",
2554  __func__,
2555  dp->dnatype);
2556  }
2557  }
2558 
2559  if (has_default) {
2560  if (debugSRNA_defaults) {
2561  fprintf(stderr, "value=(");
2562  for (int i = 0; i < prop->totarraylength; i++) {
2563  fprintf(stderr, "%g, ", fprop->defaultarray[i]);
2564  }
2565  fprintf(stderr, "), ");
2566  print_default_info(dp);
2567  }
2568  }
2569  }
2570  else {
2571  if (STREQ(dp->dnatype, "float")) {
2572  fprop->defaultvalue = *(const float *)default_data;
2573  }
2574  else if (STREQ(dp->dnatype, "char")) {
2575  fprop->defaultvalue = (float)*(const char *)default_data * (1.0f / 255.0f);
2576  }
2577  else {
2578  has_default = false;
2579  if (debugSRNA_defaults) {
2580  fprintf(
2581  stderr, "%s default: unsupported float type (%s)\n", __func__, dp->dnatype);
2582  }
2583  }
2584 
2585  if (has_default) {
2586  if (debugSRNA_defaults) {
2587  fprintf(stderr, "value=%g, ", fprop->defaultvalue);
2588  print_default_info(dp);
2589  }
2590  }
2591  }
2592  }
2593  }
2594  }
2595 #endif
2596  }
2597 
2598  rna_def_property_sdna(prop, structname, propname);
2599 }
2600 
2601 void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
2602 {
2603  PropertyDefRNA *dp;
2604  EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
2605  StructRNA *srna = DefRNA.laststruct;
2606 
2607  if (!DefRNA.preprocess) {
2608  CLOG_ERROR(&LOG, "only during preprocessing.");
2609  return;
2610  }
2611 
2612  if (prop->type != PROP_ENUM) {
2613  CLOG_ERROR(&LOG, "\"%s.%s\", type is not enum.", srna->identifier, prop->identifier);
2614  DefRNA.error = true;
2615  return;
2616  }
2617 
2618  if ((dp = rna_def_property_sdna(prop, structname, propname))) {
2619  if (prop->arraydimension) {
2620  prop->arraydimension = 0;
2621  prop->totarraylength = 0;
2622 
2623  if (!DefRNA.silent) {
2624  CLOG_ERROR(&LOG, "\"%s.%s\", array not supported for enum type.", structname, propname);
2625  DefRNA.error = true;
2626  }
2627  }
2628 
2629 #ifndef RNA_RUNTIME
2630  /* Set the default if possible. */
2631  if (dp->dnaoffset != -1) {
2633  if (SDNAnr != -1) {
2634  const void *default_data = DNA_default_table[SDNAnr];
2635  if (default_data) {
2636  default_data = POINTER_OFFSET(default_data, dp->dnaoffset);
2637  bool has_default = true;
2638  if (STREQ(dp->dnatype, "char")) {
2639  eprop->defaultvalue = *(const char *)default_data;
2640  }
2641  else if (STREQ(dp->dnatype, "short")) {
2642  eprop->defaultvalue = *(const short *)default_data;
2643  }
2644  else if (STREQ(dp->dnatype, "int")) {
2645  eprop->defaultvalue = *(const int *)default_data;
2646  }
2647  else {
2648  has_default = false;
2649  if (debugSRNA_defaults) {
2650  fprintf(stderr, "%s default: unsupported enum type (%s)\n", __func__, dp->dnatype);
2651  }
2652  }
2653 
2654  if (has_default) {
2655  if (debugSRNA_defaults) {
2656  fprintf(stderr, "value=%d, ", eprop->defaultvalue);
2657  print_default_info(dp);
2658  }
2659  }
2660  }
2661  }
2662  }
2663 #else
2664  UNUSED_VARS(eprop);
2665 #endif
2666  }
2667 }
2668 
2670  const char *structname,
2671  const char *propname)
2672 {
2673  PropertyDefRNA *dp;
2674 
2675  RNA_def_property_enum_sdna(prop, structname, propname);
2676 
2678 
2679  if (dp) {
2680  dp->enumbitflags = 1;
2681 
2682 #ifndef RNA_RUNTIME
2683  int defaultvalue_mask = 0;
2684  EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
2685  for (int i = 0; i < eprop->totitem; i++) {
2686  if (eprop->item[i].identifier[0]) {
2687  defaultvalue_mask |= eprop->defaultvalue & eprop->item[i].value;
2688  }
2689  }
2690  eprop->defaultvalue = defaultvalue_mask;
2691 #endif
2692  }
2693 }
2694 
2695 void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
2696 {
2697  PropertyDefRNA *dp;
2698  StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
2699  StructRNA *srna = DefRNA.laststruct;
2700 
2701  if (!DefRNA.preprocess) {
2702  CLOG_ERROR(&LOG, "only during preprocessing.");
2703  return;
2704  }
2705 
2706  if (prop->type != PROP_STRING) {
2707  CLOG_ERROR(&LOG, "\"%s.%s\", type is not string.", srna->identifier, prop->identifier);
2708  DefRNA.error = true;
2709  return;
2710  }
2711 
2712  if ((dp = rna_def_property_sdna(prop, structname, propname))) {
2713  if (prop->arraydimension) {
2714  sprop->maxlength = prop->totarraylength;
2715  prop->arraydimension = 0;
2716  prop->totarraylength = 0;
2717  }
2718 
2719 #ifndef RNA_RUNTIME
2720  /* Set the default if possible. */
2721  if ((dp->dnaoffset != -1) && (dp->dnapointerlevel != 0)) {
2723  if (SDNAnr != -1) {
2724  const void *default_data = DNA_default_table[SDNAnr];
2725  if (default_data) {
2726  default_data = POINTER_OFFSET(default_data, dp->dnaoffset);
2727  sprop->defaultvalue = default_data;
2728 
2729  if (debugSRNA_defaults) {
2730  fprintf(stderr, "value=\"%s\", ", sprop->defaultvalue);
2731  print_default_info(dp);
2732  }
2733  }
2734  }
2735  }
2736 #endif
2737  }
2738 }
2739 
2740 void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
2741 {
2742  /* PropertyDefRNA *dp; */
2743  StructRNA *srna = DefRNA.laststruct;
2744 
2745  if (!DefRNA.preprocess) {
2746  CLOG_ERROR(&LOG, "only during preprocessing.");
2747  return;
2748  }
2749 
2750  if (prop->type != PROP_POINTER) {
2751  CLOG_ERROR(&LOG, "\"%s.%s\", type is not pointer.", srna->identifier, prop->identifier);
2752  DefRNA.error = true;
2753  return;
2754  }
2755 
2756  if ((/* dp= */ rna_def_property_sdna(prop, structname, propname))) {
2757  if (prop->arraydimension) {
2758  prop->arraydimension = 0;
2759  prop->totarraylength = 0;
2760 
2761  if (!DefRNA.silent) {
2762  CLOG_ERROR(&LOG, "\"%s.%s\", array not supported for pointer type.", structname, propname);
2763  DefRNA.error = true;
2764  }
2765  }
2766  }
2767 }
2768 
2770  const char *structname,
2771  const char *propname,
2772  const char *lengthpropname)
2773 {
2774  PropertyDefRNA *dp;
2776  StructRNA *srna = DefRNA.laststruct;
2777 
2778  if (!DefRNA.preprocess) {
2779  CLOG_ERROR(&LOG, "only during preprocessing.");
2780  return;
2781  }
2782 
2783  if (prop->type != PROP_COLLECTION) {
2784  CLOG_ERROR(&LOG, "\"%s.%s\", type is not collection.", srna->identifier, prop->identifier);
2785  DefRNA.error = true;
2786  return;
2787  }
2788 
2789  if ((dp = rna_def_property_sdna(prop, structname, propname))) {
2790  if (prop->arraydimension && !lengthpropname) {
2791  prop->arraydimension = 0;
2792  prop->totarraylength = 0;
2793 
2794  if (!DefRNA.silent) {
2795  CLOG_ERROR(&LOG, "\"%s.%s\", array of collections not supported.", structname, propname);
2796  DefRNA.error = true;
2797  }
2798  }
2799 
2800  if (dp->dnatype && STREQ(dp->dnatype, "ListBase")) {
2801  cprop->next = (PropCollectionNextFunc) "rna_iterator_listbase_next";
2802  cprop->get = (PropCollectionGetFunc) "rna_iterator_listbase_get";
2803  cprop->end = (PropCollectionEndFunc) "rna_iterator_listbase_end";
2804  }
2805  }
2806 
2807  if (dp && lengthpropname) {
2808  DNAStructMember smember;
2810 
2811  if (!structname) {
2812  structname = ds->dnaname;
2813  }
2814 
2815  int dnaoffset = 0;
2816  if (lengthpropname[0] == 0 ||
2817  rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember, &dnaoffset)) {
2818  if (lengthpropname[0] == 0) {
2819  dp->dnalengthfixed = prop->totarraylength;
2820  prop->arraydimension = 0;
2821  prop->totarraylength = 0;
2822  }
2823  else {
2824  dp->dnalengthstructname = structname;
2825  dp->dnalengthname = lengthpropname;
2826  prop->totarraylength = 0;
2827  }
2828 
2829  cprop->next = (PropCollectionNextFunc) "rna_iterator_array_next";
2830  cprop->end = (PropCollectionEndFunc) "rna_iterator_array_end";
2831 
2832  if (dp->dnapointerlevel >= 2) {
2833  cprop->get = (PropCollectionGetFunc) "rna_iterator_array_dereference_get";
2834  }
2835  else {
2836  cprop->get = (PropCollectionGetFunc) "rna_iterator_array_get";
2837  }
2838  }
2839  else {
2840  if (!DefRNA.silent) {
2841  CLOG_ERROR(&LOG, "\"%s.%s\" not found.", structname, lengthpropname);
2842  DefRNA.error = true;
2843  }
2844  }
2845  }
2846 }
2847 
2849 {
2851 }
2852 
2853 /* Functions */
2854 
2855 void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
2856 {
2857  if (!DefRNA.preprocess) {
2858  CLOG_ERROR(&LOG, "only during preprocessing.");
2859  return;
2860  }
2861 
2862  if (editable) {
2863  prop->editable = (EditableFunc)editable;
2864  }
2865 }
2866 
2867 void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editable)
2868 {
2869  if (!DefRNA.preprocess) {
2870  CLOG_ERROR(&LOG, "only during preprocessing.");
2871  return;
2872  }
2873 
2874  if (editable) {
2875  prop->itemeditable = (ItemEditableFunc)editable;
2876  }
2877 }
2878 
2880  const char *diff,
2881  const char *store,
2882  const char *apply)
2883 {
2884  if (!DefRNA.preprocess) {
2885  CLOG_ERROR(&LOG, "only during preprocessing.");
2886  return;
2887  }
2888 
2889  if (diff) {
2891  }
2892  if (store) {
2893  prop->override_store = (RNAPropOverrideStore)store;
2894  }
2895  if (apply) {
2896  prop->override_apply = (RNAPropOverrideApply)apply;
2897  }
2898 }
2899 
2900 void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
2901 {
2902  if (!DefRNA.preprocess) {
2903  CLOG_ERROR(&LOG, "only during preprocessing.");
2904  return;
2905  }
2906 
2907  prop->noteflag = noteflag;
2908  prop->update = (UpdateFunc)func;
2909 }
2910 
2911 void RNA_def_property_update_runtime(PropertyRNA *prop, const void *func)
2912 {
2913  prop->update = (void *)func;
2914 }
2915 
2916 void RNA_def_property_poll_runtime(PropertyRNA *prop, const void *func)
2917 {
2918  if (prop->type == PROP_POINTER) {
2919  ((PointerPropertyRNA *)prop)->poll = (void *)func;
2920  }
2921  else {
2922  CLOG_ERROR(&LOG, "%s is not a Pointer Property.", prop->identifier);
2923  }
2924 }
2925 
2926 void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
2927 {
2928  if (!DefRNA.preprocess) {
2929  CLOG_ERROR(&LOG, "only during preprocessing.");
2930  return;
2931  }
2932 
2933  if (!(prop->flag & PROP_DYNAMIC)) {
2934  CLOG_ERROR(&LOG, "property is a not dynamic array.");
2935  DefRNA.error = true;
2936  return;
2937  }
2938 
2939  if (getlength) {
2940  prop->getlength = (PropArrayLengthGetFunc)getlength;
2941  }
2942 }
2943 
2944 void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
2945 {
2946  StructRNA *srna = DefRNA.laststruct;
2947 
2948  if (!DefRNA.preprocess) {
2949  CLOG_ERROR(&LOG, "only during preprocessing.");
2950  return;
2951  }
2952 
2953  switch (prop->type) {
2954  case PROP_BOOLEAN: {
2955  BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
2956 
2957  if (prop->arraydimension) {
2958  if (get) {
2959  bprop->getarray = (PropBooleanArrayGetFunc)get;
2960  }
2961  if (set) {
2962  bprop->setarray = (PropBooleanArraySetFunc)set;
2963  }
2964  }
2965  else {
2966  if (get) {
2967  bprop->get = (PropBooleanGetFunc)get;
2968  }
2969  if (set) {
2970  bprop->set = (PropBooleanSetFunc)set;
2971  }
2972  }
2973  break;
2974  }
2975  default:
2976  CLOG_ERROR(&LOG, "\"%s.%s\", type is not boolean.", srna->identifier, prop->identifier);
2977  DefRNA.error = true;
2978  break;
2979  }
2980 }
2981 
2983  BooleanPropertyGetFunc getfunc,
2984  BooleanPropertySetFunc setfunc)
2985 {
2986  BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
2987 
2988  if (getfunc) {
2989  bprop->get_ex = getfunc;
2990  }
2991  if (setfunc) {
2992  bprop->set_ex = setfunc;
2993  }
2994 
2995  if (getfunc || setfunc) {
2996  /* don't save in id properties */
2997  prop->flag &= ~PROP_IDPROPERTY;
2998 
2999  if (!setfunc) {
3000  prop->flag &= ~PROP_EDITABLE;
3001  }
3002  }
3003 }
3004 
3008 {
3009  BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
3010 
3011  if (getfunc) {
3012  bprop->getarray_ex = getfunc;
3013  }
3014  if (setfunc) {
3015  bprop->setarray_ex = setfunc;
3016  }
3017 
3018  if (getfunc || setfunc) {
3019  /* don't save in id properties */
3020  prop->flag &= ~PROP_IDPROPERTY;
3021 
3022  if (!setfunc) {
3023  prop->flag &= ~PROP_EDITABLE;
3024  }
3025  }
3026 }
3027 
3029  const char *get,
3030  const char *set,
3031  const char *range)
3032 {
3033  StructRNA *srna = DefRNA.laststruct;
3034 
3035  if (!DefRNA.preprocess) {
3036  CLOG_ERROR(&LOG, "only during preprocessing.");
3037  return;
3038  }
3039 
3040  switch (prop->type) {
3041  case PROP_INT: {
3042  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
3043 
3044  if (prop->arraydimension) {
3045  if (get) {
3046  iprop->getarray = (PropIntArrayGetFunc)get;
3047  }
3048  if (set) {
3049  iprop->setarray = (PropIntArraySetFunc)set;
3050  }
3051  }
3052  else {
3053  if (get) {
3054  iprop->get = (PropIntGetFunc)get;
3055  }
3056  if (set) {
3057  iprop->set = (PropIntSetFunc)set;
3058  }
3059  }
3060  if (range) {
3061  iprop->range = (PropIntRangeFunc)range;
3062  }
3063  break;
3064  }
3065  default:
3066  CLOG_ERROR(&LOG, "\"%s.%s\", type is not int.", srna->identifier, prop->identifier);
3067  DefRNA.error = true;
3068  break;
3069  }
3070 }
3071 
3073  IntPropertyGetFunc getfunc,
3074  IntPropertySetFunc setfunc,
3075  IntPropertyRangeFunc rangefunc)
3076 {
3077  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
3078 
3079  if (getfunc) {
3080  iprop->get_ex = getfunc;
3081  }
3082  if (setfunc) {
3083  iprop->set_ex = setfunc;
3084  }
3085  if (rangefunc) {
3086  iprop->range_ex = rangefunc;
3087  }
3088 
3089  if (getfunc || setfunc) {
3090  /* don't save in id properties */
3091  prop->flag &= ~PROP_IDPROPERTY;
3092 
3093  if (!setfunc) {
3094  prop->flag &= ~PROP_EDITABLE;
3095  }
3096  }
3097 }
3098 
3100  IntArrayPropertyGetFunc getfunc,
3101  IntArrayPropertySetFunc setfunc,
3102  IntPropertyRangeFunc rangefunc)
3103 {
3104  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
3105 
3106  if (getfunc) {
3107  iprop->getarray_ex = getfunc;
3108  }
3109  if (setfunc) {
3110  iprop->setarray_ex = setfunc;
3111  }
3112  if (rangefunc) {
3113  iprop->range_ex = rangefunc;
3114  }
3115 
3116  if (getfunc || setfunc) {
3117  /* don't save in id properties */
3118  prop->flag &= ~PROP_IDPROPERTY;
3119 
3120  if (!setfunc) {
3121  prop->flag &= ~PROP_EDITABLE;
3122  }
3123  }
3124 }
3125 
3127  const char *get,
3128  const char *set,
3129  const char *range)
3130 {
3131  StructRNA *srna = DefRNA.laststruct;
3132 
3133  if (!DefRNA.preprocess) {
3134  CLOG_ERROR(&LOG, "only during preprocessing.");
3135  return;
3136  }
3137 
3138  switch (prop->type) {
3139  case PROP_FLOAT: {
3140  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
3141 
3142  if (prop->arraydimension) {
3143  if (get) {
3144  fprop->getarray = (PropFloatArrayGetFunc)get;
3145  }
3146  if (set) {
3147  fprop->setarray = (PropFloatArraySetFunc)set;
3148  }
3149  }
3150  else {
3151  if (get) {
3152  fprop->get = (PropFloatGetFunc)get;
3153  }
3154  if (set) {
3155  fprop->set = (PropFloatSetFunc)set;
3156  }
3157  }
3158  if (range) {
3159  fprop->range = (PropFloatRangeFunc)range;
3160  }
3161  break;
3162  }
3163  default:
3164  CLOG_ERROR(&LOG, "\"%s.%s\", type is not float.", srna->identifier, prop->identifier);
3165  DefRNA.error = true;
3166  break;
3167  }
3168 }
3169 
3171  FloatPropertyGetFunc getfunc,
3172  FloatPropertySetFunc setfunc,
3173  FloatPropertyRangeFunc rangefunc)
3174 {
3175  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
3176 
3177  if (getfunc) {
3178  fprop->get_ex = getfunc;
3179  }
3180  if (setfunc) {
3181  fprop->set_ex = setfunc;
3182  }
3183  if (rangefunc) {
3184  fprop->range_ex = rangefunc;
3185  }
3186 
3187  if (getfunc || setfunc) {
3188  /* don't save in id properties */
3189  prop->flag &= ~PROP_IDPROPERTY;
3190 
3191  if (!setfunc) {
3192  prop->flag &= ~PROP_EDITABLE;
3193  }
3194  }
3195 }
3196 
3198  FloatArrayPropertyGetFunc getfunc,
3199  FloatArrayPropertySetFunc setfunc,
3200  FloatPropertyRangeFunc rangefunc)
3201 {
3202  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
3203 
3204  if (getfunc) {
3205  fprop->getarray_ex = getfunc;
3206  }
3207  if (setfunc) {
3208  fprop->setarray_ex = setfunc;
3209  }
3210  if (rangefunc) {
3211  fprop->range_ex = rangefunc;
3212  }
3213 
3214  if (getfunc || setfunc) {
3215  /* don't save in id properties */
3216  prop->flag &= ~PROP_IDPROPERTY;
3217 
3218  if (!setfunc) {
3219  prop->flag &= ~PROP_EDITABLE;
3220  }
3221  }
3222 }
3223 
3225  const char *get,
3226  const char *set,
3227  const char *item)
3228 {
3229  StructRNA *srna = DefRNA.laststruct;
3230 
3231  if (!DefRNA.preprocess) {
3232  CLOG_ERROR(&LOG, "only during preprocessing.");
3233  return;
3234  }
3235 
3236  switch (prop->type) {
3237  case PROP_ENUM: {
3238  EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
3239 
3240  if (get) {
3241  eprop->get = (PropEnumGetFunc)get;
3242  }
3243  if (set) {
3244  eprop->set = (PropEnumSetFunc)set;
3245  }
3246  if (item) {
3247  eprop->item_fn = (PropEnumItemFunc)item;
3248  }
3249  break;
3250  }
3251  default:
3252  CLOG_ERROR(&LOG, "\"%s.%s\", type is not enum.", srna->identifier, prop->identifier);
3253  DefRNA.error = true;
3254  break;
3255  }
3256 }
3257 
3259  EnumPropertyGetFunc getfunc,
3260  EnumPropertySetFunc setfunc,
3261  EnumPropertyItemFunc itemfunc)
3262 {
3263  EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
3264 
3265  if (getfunc) {
3266  eprop->get_ex = getfunc;
3267  }
3268  if (setfunc) {
3269  eprop->set_ex = setfunc;
3270  }
3271  if (itemfunc) {
3272  eprop->item_fn = itemfunc;
3273  }
3274 
3275  if (getfunc || setfunc) {
3276  /* don't save in id properties */
3277  prop->flag &= ~PROP_IDPROPERTY;
3278 
3279  if (!setfunc) {
3280  prop->flag &= ~PROP_EDITABLE;
3281  }
3282  }
3283 }
3284 
3286  const char *get,
3287  const char *length,
3288  const char *set)
3289 {
3290  StructRNA *srna = DefRNA.laststruct;
3291 
3292  if (!DefRNA.preprocess) {
3293  CLOG_ERROR(&LOG, "only during preprocessing.");
3294  return;
3295  }
3296 
3297  switch (prop->type) {
3298  case PROP_STRING: {
3299  StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
3300 
3301  if (get) {
3302  sprop->get = (PropStringGetFunc)get;
3303  }
3304  if (length) {
3306  }
3307  if (set) {
3308  sprop->set = (PropStringSetFunc)set;
3309  }
3310  break;
3311  }
3312  default:
3313  CLOG_ERROR(&LOG, "\"%s.%s\", type is not string.", srna->identifier, prop->identifier);
3314  DefRNA.error = true;
3315  break;
3316  }
3317 }
3318 
3320  const char *search,
3321  const eStringPropertySearchFlag search_flag)
3322 {
3323  StructRNA *srna = DefRNA.laststruct;
3324 
3325  if (!DefRNA.preprocess) {
3326  CLOG_ERROR(&LOG, "only during preprocessing.");
3327  return;
3328  }
3329 
3330  switch (prop->type) {
3331  case PROP_STRING: {
3332  StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
3333  sprop->search = (StringPropertySearchFunc)search;
3334  if (search != NULL) {
3335  sprop->search_flag = search_flag | PROP_STRING_SEARCH_SUPPORTED;
3336  }
3337  break;
3338  }
3339  default:
3340  CLOG_ERROR(&LOG, "\"%s.%s\", type is not string.", srna->identifier, prop->identifier);
3341  DefRNA.error = true;
3342  break;
3343  }
3344 }
3345 
3347  StringPropertyGetFunc getfunc,
3348  StringPropertyLengthFunc lengthfunc,
3349  StringPropertySetFunc setfunc)
3350 {
3351  StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
3352 
3353  if (getfunc) {
3354  sprop->get_ex = getfunc;
3355  }
3356  if (lengthfunc) {
3357  sprop->length_ex = lengthfunc;
3358  }
3359  if (setfunc) {
3360  sprop->set_ex = setfunc;
3361  }
3362 
3363  if (getfunc || setfunc) {
3364  /* don't save in id properties */
3365  prop->flag &= ~PROP_IDPROPERTY;
3366 
3367  if (!setfunc) {
3368  prop->flag &= ~PROP_EDITABLE;
3369  }
3370  }
3371 }
3372 
3374  StringPropertySearchFunc search_fn,
3375  const eStringPropertySearchFlag search_flag)
3376 {
3377  StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
3378 
3379  sprop->search = search_fn;
3380  if (search_fn != NULL) {
3381  sprop->search_flag = search_flag | PROP_STRING_SEARCH_SUPPORTED;
3382  }
3383 }
3384 
3386  PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
3387 {
3388  StructRNA *srna = DefRNA.laststruct;
3389 
3390  if (!DefRNA.preprocess) {
3391  CLOG_ERROR(&LOG, "only during preprocessing.");
3392  return;
3393  }
3394 
3395  switch (prop->type) {
3396  case PROP_POINTER: {
3397  PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
3398 
3399  if (get) {
3400  pprop->get = (PropPointerGetFunc)get;
3401  }
3402  if (set) {
3403  pprop->set = (PropPointerSetFunc)set;
3404  }
3405  if (type_fn) {
3406  pprop->type_fn = (PropPointerTypeFunc)type_fn;
3407  }
3408  if (poll) {
3409  pprop->poll = (PropPointerPollFunc)poll;
3410  }
3411  break;
3412  }
3413  default:
3414  CLOG_ERROR(&LOG, "\"%s.%s\", type is not pointer.", srna->identifier, prop->identifier);
3415  DefRNA.error = true;
3416  break;
3417  }
3418 }
3419 
3421  const char *begin,
3422  const char *next,
3423  const char *end,
3424  const char *get,
3425  const char *length,
3426  const char *lookupint,
3427  const char *lookupstring,
3428  const char *assignint)
3429 {
3430  StructRNA *srna = DefRNA.laststruct;
3431 
3432  if (!DefRNA.preprocess) {
3433  CLOG_ERROR(&LOG, "only during preprocessing.");
3434  return;
3435  }
3436 
3437  switch (prop->type) {
3438  case PROP_COLLECTION: {
3440 
3441  if (begin) {
3442  cprop->begin = (PropCollectionBeginFunc)begin;
3443  }
3444  if (next) {
3445  cprop->next = (PropCollectionNextFunc)next;
3446  }
3447  if (end) {
3448  cprop->end = (PropCollectionEndFunc)end;
3449  }
3450  if (get) {
3451  cprop->get = (PropCollectionGetFunc)get;
3452  }
3453  if (length) {
3455  }
3456  if (lookupint) {
3457  cprop->lookupint = (PropCollectionLookupIntFunc)lookupint;
3458  }
3459  if (lookupstring) {
3460  cprop->lookupstring = (PropCollectionLookupStringFunc)lookupstring;
3461  }
3462  if (assignint) {
3463  cprop->assignint = (PropCollectionAssignIntFunc)assignint;
3464  }
3465  break;
3466  }
3467  default:
3468  CLOG_ERROR(&LOG, "\"%s.%s\", type is not collection.", srna->identifier, prop->identifier);
3469  DefRNA.error = true;
3470  break;
3471  }
3472 }
3473 
3474 void RNA_def_property_srna(PropertyRNA *prop, const char *type)
3475 {
3476  char error[512];
3477  if (rna_validate_identifier(type, error, false) == 0) {
3478  CLOG_ERROR(&LOG, "struct identifier \"%s\" error - %s", type, error);
3479  DefRNA.error = true;
3480  return;
3481  }
3482 
3483  prop->srna = (StructRNA *)type;
3484 }
3485 
3486 void RNA_def_py_data(PropertyRNA *prop, void *py_data)
3487 {
3488  prop->py_data = py_data;
3489 }
3490 
3491 /* Compact definitions */
3492 
3494  const char *identifier,
3495  bool default_value,
3496  const char *ui_name,
3497  const char *ui_description)
3498 {
3499  ContainerRNA *cont = cont_;
3500  PropertyRNA *prop;
3501 
3502  prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_NONE);
3503  RNA_def_property_boolean_default(prop, default_value);
3504  RNA_def_property_ui_text(prop, ui_name, ui_description);
3505 
3506  return prop;
3507 }
3508 
3510  const char *identifier,
3511  int len,
3512  bool *default_value,
3513  const char *ui_name,
3514  const char *ui_description)
3515 {
3516  ContainerRNA *cont = cont_;
3517  PropertyRNA *prop;
3518 
3519  prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_NONE);
3520  if (len != 0) {
3521  RNA_def_property_array(prop, len);
3522  }
3523  if (default_value) {
3524  RNA_def_property_boolean_array_default(prop, default_value);
3525  }
3526  RNA_def_property_ui_text(prop, ui_name, ui_description);
3527 
3528  return prop;
3529 }
3530 
3532  const char *identifier,
3533  int len,
3534  bool *default_value,
3535  const char *ui_name,
3536  const char *ui_description)
3537 {
3538  ContainerRNA *cont = cont_;
3539  PropertyRNA *prop;
3540 
3541  prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_LAYER);
3542  if (len != 0) {
3543  RNA_def_property_array(prop, len);
3544  }
3545  if (default_value) {
3546  RNA_def_property_boolean_array_default(prop, default_value);
3547  }
3548  RNA_def_property_ui_text(prop, ui_name, ui_description);
3549 
3550  return prop;
3551 }
3552 
3554  const char *identifier,
3555  int len,
3556  bool *default_value,
3557  const char *ui_name,
3558  const char *ui_description)
3559 {
3560  ContainerRNA *cont = cont_;
3561  PropertyRNA *prop;
3562 
3563  prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_LAYER_MEMBER);
3564  if (len != 0) {
3565  RNA_def_property_array(prop, len);
3566  }
3567  if (default_value) {
3568  RNA_def_property_boolean_array_default(prop, default_value);
3569  }
3570  RNA_def_property_ui_text(prop, ui_name, ui_description);
3571 
3572  return prop;
3573 }
3574 
3576  const char *identifier,
3577  int len,
3578  bool *default_value,
3579  const char *ui_name,
3580  const char *ui_description)
3581 {
3582  ContainerRNA *cont = cont_;
3583  PropertyRNA *prop;
3584 
3585  prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_XYZ); /* XXX */
3586  if (len != 0) {
3587  RNA_def_property_array(prop, len);
3588  }
3589  if (default_value) {
3590  RNA_def_property_boolean_array_default(prop, default_value);
3591  }
3592  RNA_def_property_ui_text(prop, ui_name, ui_description);
3593 
3594  return prop;
3595 }
3596 
3598  const char *identifier,
3599  int default_value,
3600  int hardmin,
3601  int hardmax,
3602  const char *ui_name,
3603  const char *ui_description,
3604  int softmin,
3605  int softmax)
3606 {
3607  ContainerRNA *cont = cont_;
3608  PropertyRNA *prop;
3609 
3611 
3612  prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
3613  RNA_def_property_int_default(prop, default_value);
3614  if (hardmin != hardmax) {
3615  RNA_def_property_range(prop, hardmin, hardmax);
3616  }
3617  RNA_def_property_ui_text(prop, ui_name, ui_description);
3618  RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
3619 
3620  return prop;
3621 }
3622 
3624  const char *identifier,
3625  int len,
3626  const int *default_value,
3627  int hardmin,
3628  int hardmax,
3629  const char *ui_name,
3630  const char *ui_description,
3631  int softmin,
3632  int softmax)
3633 {
3634  ContainerRNA *cont = cont_;
3635  PropertyRNA *prop;
3636 
3638 
3639  prop = RNA_def_property(cont, identifier, PROP_INT, PROP_XYZ); /* XXX */
3640  if (len != 0) {
3641  RNA_def_property_array(prop, len);
3642  }
3643  if (default_value) {
3644  RNA_def_property_int_array_default(prop, default_value);
3645  }
3646  if (hardmin != hardmax) {
3647  RNA_def_property_range(prop, hardmin, hardmax);
3648  }
3649  RNA_def_property_ui_text(prop, ui_name, ui_description);
3650  RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
3651 
3652  return prop;
3653 }
3654 
3656  const char *identifier,
3657  int len,
3658  const int *default_value,
3659  int hardmin,
3660  int hardmax,
3661  const char *ui_name,
3662  const char *ui_description,
3663  int softmin,
3664  int softmax)
3665 {
3666  ContainerRNA *cont = cont_;
3667  PropertyRNA *prop;
3668 
3670 
3671  prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
3672  if (len != 0) {
3673  RNA_def_property_array(prop, len);
3674  }
3675  if (default_value) {
3676  RNA_def_property_int_array_default(prop, default_value);
3677  }
3678  if (hardmin != hardmax) {
3679  RNA_def_property_range(prop, hardmin, hardmax);
3680  }
3681  RNA_def_property_ui_text(prop, ui_name, ui_description);
3682  RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
3683 
3684  return prop;
3685 }
3686 
3688  const char *identifier,
3689  const char *default_value,
3690  int maxlen,
3691  const char *ui_name,
3692  const char *ui_description)
3693 {
3694  ContainerRNA *cont = cont_;
3695  PropertyRNA *prop;
3696 
3697  BLI_assert(default_value == NULL || default_value[0]);
3698 
3699  prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_NONE);
3700  if (maxlen != 0) {
3701  RNA_def_property_string_maxlength(prop, maxlen);
3702  }
3703  if (default_value) {
3704  RNA_def_property_string_default(prop, default_value);
3705  }
3706  RNA_def_property_ui_text(prop, ui_name, ui_description);
3707 
3708  return prop;
3709 }
3710 
3712  const char *identifier,
3713  const char *default_value,
3714  int maxlen,
3715  const char *ui_name,
3716  const char *ui_description)
3717 {
3718  ContainerRNA *cont = cont_;
3719  PropertyRNA *prop;
3720 
3721  BLI_assert(default_value == NULL || default_value[0]);
3722 
3723  prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_FILEPATH);
3724  if (maxlen != 0) {
3725  RNA_def_property_string_maxlength(prop, maxlen);
3726  }
3727  if (default_value) {
3728  RNA_def_property_string_default(prop, default_value);
3729  }
3730  RNA_def_property_ui_text(prop, ui_name, ui_description);
3731 
3732  return prop;
3733 }
3734 
3736  const char *identifier,
3737  const char *default_value,
3738  int maxlen,
3739  const char *ui_name,
3740  const char *ui_description)
3741 {
3742  ContainerRNA *cont = cont_;
3743  PropertyRNA *prop;
3744 
3745  BLI_assert(default_value == NULL || default_value[0]);
3746 
3747  prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_DIRPATH);
3748  if (maxlen != 0) {
3749  RNA_def_property_string_maxlength(prop, maxlen);
3750  }
3751  if (default_value) {
3752  RNA_def_property_string_default(prop, default_value);
3753  }
3754  RNA_def_property_ui_text(prop, ui_name, ui_description);
3755 
3756  return prop;
3757 }
3758 
3760  const char *identifier,
3761  const char *default_value,
3762  int maxlen,
3763  const char *ui_name,
3764  const char *ui_description)
3765 {
3766  ContainerRNA *cont = cont_;
3767  PropertyRNA *prop;
3768 
3769  BLI_assert(default_value == NULL || default_value[0]);
3770 
3771  prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_FILENAME);
3772  if (maxlen != 0) {
3773  RNA_def_property_string_maxlength(prop, maxlen);
3774  }
3775  if (default_value) {
3776  RNA_def_property_string_default(prop, default_value);
3777  }
3778  RNA_def_property_ui_text(prop, ui_name, ui_description);
3779 
3780  return prop;
3781 }
3782 
3784  const char *identifier,
3785  const EnumPropertyItem *items,
3786  int default_value,
3787  const char *ui_name,
3788  const char *ui_description)
3789 {
3790  ContainerRNA *cont = cont_;
3791  PropertyRNA *prop;
3792 
3793  if (items == NULL) {
3794  CLOG_ERROR(&LOG, "items not allowed to be NULL.");
3795  return NULL;
3796  }
3797 
3798  prop = RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE);
3799  RNA_def_property_enum_items(prop, items);
3800  RNA_def_property_enum_default(prop, default_value);
3801  RNA_def_property_ui_text(prop, ui_name, ui_description);
3802 
3803  return prop;
3804 }
3805 
3807  const char *identifier,
3808  const EnumPropertyItem *items,
3809  int default_value,
3810  const char *ui_name,
3811  const char *ui_description)
3812 {
3813  ContainerRNA *cont = cont_;
3814  PropertyRNA *prop;
3815 
3816  if (items == NULL) {
3817  CLOG_ERROR(&LOG, "items not allowed to be NULL.");
3818  return NULL;
3819  }
3820 
3821  prop = RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE);
3822  RNA_def_property_flag(prop, PROP_ENUM_FLAG); /* important to run before default set */
3823  RNA_def_property_enum_items(prop, items);
3824  RNA_def_property_enum_default(prop, default_value);
3825  RNA_def_property_ui_text(prop, ui_name, ui_description);
3826 
3827  return prop;
3828 }
3829 
3831 {
3832  EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
3833  eprop->item_fn = itemfunc;
3834 }
3835 
3837  const char *identifier,
3838  float default_value,
3839  float hardmin,
3840  float hardmax,
3841  const char *ui_name,
3842  const char *ui_description,
3843  float softmin,
3844  float softmax)
3845 {
3846  ContainerRNA *cont = cont_;
3847  PropertyRNA *prop;
3848 
3850 
3851  prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
3852  RNA_def_property_float_default(prop, default_value);
3853  if (hardmin != hardmax) {
3854  RNA_def_property_range(prop, hardmin, hardmax);
3855  }
3856  RNA_def_property_ui_text(prop, ui_name, ui_description);
3857  RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
3858 
3859  return prop;
3860 }
3861 
3863  const char *identifier,
3864  int len,
3865  const float *default_value,
3866  float hardmin,
3867  float hardmax,
3868  const char *ui_name,
3869  const char *ui_description,
3870  float softmin,
3871  float softmax)
3872 {
3873  ContainerRNA *cont = cont_;
3874  PropertyRNA *prop;
3875 
3877 
3878  prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_XYZ);
3879  if (len != 0) {
3880  RNA_def_property_array(prop, len);
3881  }
3882  if (default_value) {
3883  RNA_def_property_float_array_default(prop, default_value);
3884  }
3885  if (hardmin != hardmax) {
3886  RNA_def_property_range(prop, hardmin, hardmax);
3887  }
3888  RNA_def_property_ui_text(prop, ui_name, ui_description);
3889  RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
3890 
3891  return prop;
3892 }
3893 
3895  const char *identifier,
3896  int len,
3897  const float *default_value,
3898  float hardmin,
3899  float hardmax,
3900  const char *ui_name,
3901  const char *ui_description,
3902  float softmin,
3903  float softmax)
3904 {
3905  PropertyRNA *prop;
3906 
3907  prop = RNA_def_float_vector(cont_,
3908  identifier,
3909  len,
3910  default_value,
3911  hardmin,
3912  hardmax,
3913  ui_name,
3914  ui_description,
3915  softmin,
3916  softmax);
3917  prop->subtype = PROP_XYZ_LENGTH;
3918 
3919  return prop;
3920 }
3921 
3923  const char *identifier,
3924  int len,
3925  const float *default_value,
3926  float hardmin,
3927  float hardmax,
3928  const char *ui_name,
3929  const char *ui_description,
3930  float softmin,
3931  float softmax)
3932 {
3933  ContainerRNA *cont = cont_;
3934  PropertyRNA *prop;
3935 
3937 
3938  prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_COLOR);
3939  if (len != 0) {
3940  RNA_def_property_array(prop, len);
3941  }
3942  if (default_value) {
3943  RNA_def_property_float_array_default(prop, default_value);
3944  }
3945  if (hardmin != hardmax) {
3946  RNA_def_property_range(prop, hardmin, hardmax);
3947  }
3948  RNA_def_property_ui_text(prop, ui_name, ui_description);
3949  RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
3950 
3951  return prop;
3952 }
3953 
3955  const char *identifier,
3956  int rows,
3957  int columns,
3958  const float *default_value,
3959  float hardmin,
3960  float hardmax,
3961  const char *ui_name,
3962  const char *ui_description,
3963  float softmin,
3964  float softmax)
3965 {
3966  ContainerRNA *cont = cont_;
3967  PropertyRNA *prop;
3968  const int length[2] = {rows, columns};
3969 
3971 
3972  prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_MATRIX);
3974  if (default_value) {
3975  RNA_def_property_float_array_default(prop, default_value);
3976  }
3977  if (hardmin != hardmax) {
3978  RNA_def_property_range(prop, hardmin, hardmax);
3979  }
3980  RNA_def_property_ui_text(prop, ui_name, ui_description);
3981  RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
3982 
3983  return prop;
3984 }
3985 
3987  const char *identifier,
3988  int len,
3989  const float *default_value,
3990  float hardmin,
3991  float hardmax,
3992  const char *ui_name,
3993  const char *ui_description,
3994  float softmin,
3995  float softmax)
3996 {
3997  PropertyRNA *prop;
3998 
3999  prop = RNA_def_float_vector(cont_,
4000  identifier,
4001  len,
4002  default_value,
4003  hardmin,
4004  hardmax,
4005  ui_name,
4006  ui_description,
4007  softmin,
4008  softmax);
4009  prop->subtype = PROP_TRANSLATION;
4010 
4011  RNA_def_property_ui_range(prop, softmin, softmax, 1, RNA_TRANSLATION_PREC_DEFAULT);
4012 
4013  return prop;
4014 }
4015 
4017  const char *identifier,
4018  int len,
4019  const float *default_value,
4020  float hardmin,
4021  float hardmax,
4022  const char *ui_name,
4023  const char *ui_description,
4024  float softmin,
4025  float softmax)
4026 {
4027  ContainerRNA *cont = cont_;
4028  PropertyRNA *prop;
4029 
4031 
4032  prop = RNA_def_property(cont, identifier, PROP_FLOAT, (len >= 3) ? PROP_EULER : PROP_ANGLE);
4033  if (len != 0) {
4034  RNA_def_property_array(prop, len);
4035  if (default_value) {
4036  RNA_def_property_float_array_default(prop, default_value);
4037  }
4038  }
4039  else {
4040  /* RNA_def_property_float_default must be called outside */
4041  BLI_assert(default_value == NULL);
4042  }
4043  if (hardmin != hardmax) {
4044  RNA_def_property_range(prop, hardmin, hardmax);
4045  }
4046  RNA_def_property_ui_text(prop, ui_name, ui_description);
4047  RNA_def_property_ui_range(prop, softmin, softmax, 10, 3);
4048 
4049  return prop;
4050 }
4051 
4053  const char *identifier,
4054  float default_value,
4055  float hardmin,
4056  float hardmax,
4057  const char *ui_name,
4058  const char *ui_description,
4059  float softmin,
4060  float softmax)
4061 {
4062  PropertyRNA *prop = RNA_def_float(cont_,
4063  identifier,
4064  default_value,
4065  hardmin,
4066  hardmax,
4067  ui_name,
4068  ui_description,
4069  softmin,
4070  softmax);
4072 
4073  return prop;
4074 }
4075 
4077  const char *identifier,
4078  int len,
4079  const float *default_value,
4080  float hardmin,
4081  float hardmax,
4082  const char *ui_name,
4083  const char *ui_description,
4084  float softmin,
4085  float softmax)
4086 {
4087  ContainerRNA *cont = cont_;
4088  PropertyRNA *prop;
4089 
4091 
4092  prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
4093  if (len != 0) {
4094  RNA_def_property_array(prop, len);
4095  }
4096  if (default_value) {
4097  RNA_def_property_float_array_default(prop, default_value);
4098  }
4099  if (hardmin != hardmax) {
4100  RNA_def_property_range(prop, hardmin, hardmax);
4101  }
4102  RNA_def_property_ui_text(prop, ui_name, ui_description);
4103  RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
4104 
4105  return prop;
4106 }
4107 
4109  const char *identifier,
4110  float default_value,
4111  float hardmin,
4112  float hardmax,
4113  const char *ui_name,
4114  const char *ui_description,
4115  float softmin,
4116  float softmax)
4117 {
4118  ContainerRNA *cont = cont_;
4119  PropertyRNA *prop;
4120 
4122 
4123 #ifdef DEBUG
4124  /* Properties with PROP_PERCENTAGE should use a range like 0 to 100, unlike PROP_FACTOR. */
4125  if (hardmax < 2.0f) {
4126  CLOG_WARN(&LOG,
4127  "Percentage property with incorrect range: %s.%s",
4128  CONTAINER_RNA_ID(cont),
4129  identifier);
4130  }
4131 #endif
4132 
4133  prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_PERCENTAGE);
4134  RNA_def_property_float_default(prop, default_value);
4135  if (hardmin != hardmax) {
4136  RNA_def_property_range(prop, hardmin, hardmax);
4137  }
4138  RNA_def_property_ui_text(prop, ui_name, ui_description);
4139  RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
4140 
4141  return prop;
4142 }
4143 
4145  const char *identifier,
4146  float default_value,
4147  float hardmin,
4148  float hardmax,
4149  const char *ui_name,
4150  const char *ui_description,
4151  float softmin,
4152  float softmax)
4153 {
4154  ContainerRNA *cont = cont_;
4155  PropertyRNA *prop;
4156 
4158 
4159  prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_FACTOR);
4160  RNA_def_property_float_default(prop, default_value);
4161  if (hardmin != hardmax) {
4162  RNA_def_property_range(prop, hardmin, hardmax);
4163  }
4164  RNA_def_property_ui_text(prop, ui_name, ui_description);
4165  RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
4166 
4167  return prop;
4168 }
4169 
4171  const char *identifier,
4172  const char *type,
4173  const char *ui_name,
4174  const char *ui_description)
4175 {
4176  ContainerRNA *cont = cont_;
4177  PropertyRNA *prop;
4178 
4179  prop = RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE);
4181  RNA_def_property_ui_text(prop, ui_name, ui_description);
4182 
4183  return prop;
4184 }
4185 
4187  const char *identifier,
4188  StructRNA *type,
4189  const char *ui_name,
4190  const char *ui_description)
4191 {
4192  ContainerRNA *cont = cont_;
4193  PropertyRNA *prop;
4194 
4195  prop = RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE);
4197  if ((type->flag & STRUCT_ID) != 0) {
4198  prop->flag |= PROP_EDITABLE;
4199  }
4200  RNA_def_property_ui_text(prop, ui_name, ui_description);
4201 
4202  return prop;
4203 }
4204 
4206  const char *identifier,
4207  const char *type,
4208  const char *ui_name,
4209  const char *ui_description)
4210 {
4211  ContainerRNA *cont = cont_;
4212  PropertyRNA *prop;
4213 
4214  prop = RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE);
4216  RNA_def_property_ui_text(prop, ui_name, ui_description);
4217 
4218  return prop;
4219 }
4220 
4222  const char *identifier,
4223  StructRNA *type,
4224  const char *ui_name,
4225  const char *ui_description)
4226 {
4227  ContainerRNA *cont = cont_;
4228  PropertyRNA *prop;
4229 
4230  prop = RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE);
4232  RNA_def_property_ui_text(prop, ui_name, ui_description);
4233 
4234  return prop;
4235 }
4236 
4237 /* Function */
4238 
4239 static FunctionRNA *rna_def_function(StructRNA *srna, const char *identifier)
4240 {
4241  FunctionRNA *func;
4242  StructDefRNA *dsrna;
4243  FunctionDefRNA *dfunc;
4244 
4245  if (DefRNA.preprocess) {
4246  char error[512];
4247 
4248  if (rna_validate_identifier(identifier, error, false) == 0) {
4249  CLOG_ERROR(&LOG, "function identifier \"%s\" - %s", identifier, error);
4250  DefRNA.error = true;
4251  }
4252  }
4253 
4254  func = MEM_callocN(sizeof(FunctionRNA), "FunctionRNA");
4255  func->identifier = identifier;
4256  func->description = identifier;
4257 
4258  rna_addtail(&srna->functions, func);
4259 
4260  if (DefRNA.preprocess) {
4261  dsrna = rna_find_struct_def(srna);
4262  dfunc = MEM_callocN(sizeof(FunctionDefRNA), "FunctionDefRNA");
4263  rna_addtail(&dsrna->functions, dfunc);
4264  dfunc->func = func;
4265  }
4266  else {
4267  func->flag |= FUNC_RUNTIME;
4268  }
4269 
4270  return func;
4271 }
4272 
4273 FunctionRNA *RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
4274 {
4275  FunctionRNA *func;
4276  FunctionDefRNA *dfunc;
4277 
4278  if (BLI_findstring_ptr(&srna->functions, identifier, offsetof(FunctionRNA, identifier))) {
4279  CLOG_ERROR(&LOG, "%s.%s already defined.", srna->identifier, identifier);
4280  return NULL;
4281  }
4282 
4283  func = rna_def_function(srna, identifier);
4284 
4285  if (!DefRNA.preprocess) {
4286  CLOG_ERROR(&LOG, "only at preprocess time.");
4287  return func;
4288  }
4289 
4290  dfunc = rna_find_function_def(func);
4291  dfunc->call = call;
4292 
4293  return func;
4294 }
4295 
4296 FunctionRNA *RNA_def_function_runtime(StructRNA *srna, const char *identifier, CallFunc call)
4297 {
4298  FunctionRNA *func;
4299 
4300  func = rna_def_function(srna, identifier);
4301 
4302  if (DefRNA.preprocess) {
4303  CLOG_ERROR(&LOG, "only at runtime.");
4304  return func;
4305  }
4306 
4307  func->call = call;
4308 
4309  return func;
4310 }
4311 
4313 {
4314  if (ret->flag & PROP_DYNAMIC) {
4315  CLOG_ERROR(&LOG,
4316  "\"%s.%s\", dynamic values are not allowed as strict returns, "
4317  "use RNA_def_function_output instead.",
4318  func->identifier,
4319  ret->identifier);
4320  return;
4321  }
4322  if (ret->arraydimension) {
4323  CLOG_ERROR(&LOG,
4324  "\"%s.%s\", arrays are not allowed as strict returns, "
4325  "use RNA_def_function_output instead.",
4326  func->identifier,
4327  ret->identifier);
4328  return;
4329  }
4330 
4331  BLI_assert(func->c_ret == NULL);
4332  func->c_ret = ret;
4333 
4335 }
4336 
4338 {
4339  ret->flag_parameter |= PARM_OUTPUT;
4340 }
4341 
4342 void RNA_def_function_flag(FunctionRNA *func, int flag)
4343 {
4344  func->flag |= flag;
4345 }
4346 
4347 void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
4348 {
4349  func->description = description;
4350 }
4351 
4353 {
4354  PropertyType ptype = parm->type;
4355  int len = parm->totarraylength;
4356 
4357  /* XXX in other parts is mentioned that strings can be dynamic as well */
4358  if (parm->flag & PROP_DYNAMIC) {
4359  return sizeof(ParameterDynAlloc);
4360  }
4361 
4362  if (len > 0) {
4363  switch (ptype) {
4364  case PROP_BOOLEAN:
4365  return sizeof(bool) * len;
4366  case PROP_INT:
4367  return sizeof(int) * len;
4368  case PROP_FLOAT:
4369  return sizeof(float) * len;
4370  default:
4371  break;
4372  }
4373  }
4374  else {
4375  switch (ptype) {
4376  case PROP_BOOLEAN:
4377  return sizeof(bool);
4378  case PROP_INT:
4379  case PROP_ENUM:
4380  return sizeof(int);
4381  case PROP_FLOAT:
4382  return sizeof(float);
4383  case PROP_STRING:
4384  /* return values don't store a pointer to the original */
4385  if (parm->flag & PROP_THICK_WRAP) {
4386  StringPropertyRNA *sparm = (StringPropertyRNA *)parm;
4387  return sizeof(char) * sparm->maxlength;
4388  }
4389  else {
4390  return sizeof(char *);
4391  }
4392  case PROP_POINTER: {
4393 #ifdef RNA_RUNTIME
4394  if (parm->flag_parameter & PARM_RNAPTR) {
4395  if (parm->flag & PROP_THICK_WRAP) {
4396  return sizeof(PointerRNA);
4397  }
4398  else {
4399  return sizeof(PointerRNA *);
4400  }
4401  }
4402  else {
4403  return sizeof(void *);
4404  }
4405 #else
4406  if (parm->flag_parameter & PARM_RNAPTR) {
4407  if (parm->flag & PROP_THICK_WRAP) {
4408  return sizeof(PointerRNA);
4409  }
4410  return sizeof(PointerRNA *);
4411  }
4412  return sizeof(void *);
4413 
4414 #endif
4415  }
4416  case PROP_COLLECTION:
4417  return sizeof(ListBase);
4418  }
4419  }
4420 
4421  return sizeof(void *);
4422 }
4423 
4425 {
4426  /* Pad parameters in memory so the next parameter is properly aligned.
4427  * This silences warnings in UBSAN. More complicated logic to pack parameters
4428  * more tightly in memory is unlikely to improve performance, and aligning
4429  * to the requirements for pointers is enough for all data types we use. */
4430  const int alignment = sizeof(void *);
4431  return (size + alignment - 1) & ~(alignment - 1);
4432 }
4433 
4434 /* Dynamic Enums */
4435 
4436 void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
4437 {
4438  int tot = *totitem;
4439 
4440  if (tot == 0) {
4441  *items = MEM_callocN(sizeof(EnumPropertyItem[8]), __func__);
4442  /* Ensure we get crashes on missing calls to 'RNA_enum_item_end', see T74227. */
4443 #ifdef DEBUG
4444  memset(*items, 0xff, sizeof(EnumPropertyItem[8]));
4445 #endif
4446  }
4447  else if (tot >= 8 && (tot & (tot - 1)) == 0) {
4448  /* Power of two > 8. */
4449  *items = MEM_recallocN_id(*items, sizeof(EnumPropertyItem) * tot * 2, __func__);
4450 #ifdef DEBUG
4451  memset((*items) + tot, 0xff, sizeof(EnumPropertyItem) * tot);
4452 #endif
4453  }
4454 
4455  (*items)[tot] = *item;
4456  *totitem = tot + 1;
4457 }
4458 
4460 {
4461  static const EnumPropertyItem sepr = RNA_ENUM_ITEM_SEPR;
4462  RNA_enum_item_add(items, totitem, &sepr);
4463 }
4464 
4465 void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
4466 {
4467  for (; item->identifier; item++) {
4468  RNA_enum_item_add(items, totitem, item);
4469  }
4470 }
4471 
4473  int *totitem,
4474  const EnumPropertyItem *item,
4475  int value)
4476 {
4477  for (; item->identifier; item++) {
4478  if (item->value == value) {
4479  RNA_enum_item_add(items, totitem, item);
4480  /* Break on first match - does this break anything?
4481  * (is quick hack to get `object->parent_type` working ok for armature/lattice). */
4482  break;
4483  }
4484  }
4485 }
4486 
4487 void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
4488 {
4489  static const EnumPropertyItem empty = {0, NULL, 0, NULL, NULL};
4490  RNA_enum_item_add(items, totitem, &empty);
4491 }
4492 
4493 /* Memory management */
4494 
4495 #ifdef RNA_RUNTIME
4497 {
4498  if (srna->identifier) {
4499  srna->identifier = BLI_strdup(srna->identifier);
4500  if (srna->flag & STRUCT_PUBLIC_NAMESPACE) {
4501  BLI_ghash_replace_key(brna->structs_map, (void *)srna->identifier);
4502  }
4503  }
4504  if (srna->name) {
4505  srna->name = BLI_strdup(srna->name);
4506  }
4507  if (srna->description) {
4508  srna->description = BLI_strdup(srna->description);
4509  }
4510 
4511  srna->flag |= STRUCT_FREE_POINTERS;
4512 }
4513 
4515 {
4516  if (srna->flag & STRUCT_FREE_POINTERS) {
4517  if (srna->identifier) {
4518  if (srna->flag & STRUCT_PUBLIC_NAMESPACE) {
4519  if (brna != NULL) {
4520  BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
4521  }
4522  }
4523  MEM_freeN((void *)srna->identifier);
4524  }
4525  if (srna->name) {
4526  MEM_freeN((void *)srna->name);
4527  }
4528  if (srna->description) {
4529  MEM_freeN((void *)srna->description);
4530  }
4531  }
4532 }
4533 
4535 {
4536  if (func->identifier) {
4537  func->identifier = BLI_strdup(func->identifier);
4538  }
4539  if (func->description) {
4540  func->description = BLI_strdup(func->description);
4541  }
4542 
4543  func->flag |= FUNC_FREE_POINTERS;
4544 }
4545 
4547 {
4548  if (func->flag & FUNC_FREE_POINTERS) {
4549  if (func->identifier) {
4550  MEM_freeN((void *)func->identifier);
4551  }
4552  if (func->description) {
4553  MEM_freeN((void *)func->description);
4554  }
4555  }
4556 }
4557 
4559 {
4560  ContainerRNA *cont = cont_;
4561  int a;
4562 
4563  /* annoying since we just added this to a hash, could make this add the correct key to the hash
4564  * in the first place */
4565  if (prop->identifier) {
4566  if (cont->prophash) {
4567  prop->identifier = BLI_strdup(prop->identifier);
4568  BLI_ghash_reinsert(cont->prophash, (void *)prop->identifier, prop, NULL, NULL);
4569  }
4570  else {
4571  prop->identifier = BLI_strdup(prop->identifier);
4572  }
4573  }
4574 
4575  if (prop->name) {
4576  prop->name = BLI_strdup(prop->name);
4577  }
4578  if (prop->description) {
4579  prop->description = BLI_strdup(prop->description);
4580  }
4581 
4582  switch (prop->type) {
4583  case PROP_BOOLEAN: {
4584  BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
4585 
4586  if (bprop->defaultarray) {
4587  bool *array = MEM_mallocN(sizeof(bool) * prop->totarraylength, "RNA_def_property_store");
4588  memcpy(array, bprop->defaultarray, sizeof(bool) * prop->totarraylength);
4589  bprop->defaultarray = array;
4590  }
4591  break;
4592  }
4593  case PROP_INT: {
4594  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
4595 
4596  if (iprop->defaultarray) {
4597  int *array = MEM_mallocN(sizeof(int) * prop->totarraylength, "RNA_def_property_store");
4598  memcpy(array, iprop->defaultarray, sizeof(int) * prop->totarraylength);
4599  iprop->defaultarray = array;
4600  }
4601  break;
4602  }
4603  case PROP_ENUM: {
4604  EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
4605 
4606  if (eprop->item) {
4607  EnumPropertyItem *array = MEM_mallocN(sizeof(EnumPropertyItem) * (eprop->totitem + 1),
4608  "RNA_def_property_store");
4609  memcpy(array, eprop->item, sizeof(EnumPropertyItem) * (eprop->totitem + 1));
4610  eprop->item = array;
4611 
4612  for (a = 0; a < eprop->totitem; a++) {
4613  if (array[a].identifier) {
4614  array[a].identifier = BLI_strdup(array[a].identifier);
4615  }
4616  if (array[a].name) {
4617  array[a].name = BLI_strdup(array[a].name);
4618  }
4619  if (array[a].description) {
4620  array[a].description = BLI_strdup(array[a].description);
4621  }
4622  }
4623  }
4624  break;
4625  }
4626  case PROP_FLOAT: {
4627  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
4628 
4629  if (fprop->defaultarray) {
4630  float *array = MEM_mallocN(sizeof(float) * prop->totarraylength, "RNA_def_property_store");
4631  memcpy(array, fprop->defaultarray, sizeof(float) * prop->totarraylength);
4632  fprop->defaultarray = array;
4633  }
4634  break;
4635  }
4636  case PROP_STRING: {
4637  StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
4638  if (sprop->defaultvalue) {
4639  sprop->defaultvalue = BLI_strdup(sprop->defaultvalue);
4640  }
4641  break;
4642  }
4643  default:
4644  break;
4645  }
4646 
4648 }
4649 
4650 static void (*g_py_data_clear_fn)(PropertyRNA *prop) = NULL;
4651 
4658  void (*py_data_clear_fn)(PropertyRNA *prop))
4659 {
4660  g_py_data_clear_fn = py_data_clear_fn;
4661 }
4662 
4664 {
4666  int a;
4667 
4668  if (g_py_data_clear_fn) {
4669  g_py_data_clear_fn(prop);
4670  }
4671 
4672  if (prop->identifier) {
4673  MEM_freeN((void *)prop->identifier);
4674  }
4675  if (prop->name) {
4676  MEM_freeN((void *)prop->name);
4677  }
4678  if (prop->description) {
4679  MEM_freeN((void *)prop->description);
4680  }
4681  if (prop->py_data) {
4682  MEM_freeN(prop->py_data);
4683  }
4684 
4685  switch (prop->type) {
4686  case PROP_BOOLEAN: {
4687  BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
4688  if (bprop->defaultarray) {
4689  MEM_freeN((void *)bprop->defaultarray);
4690  }
4691  break;
4692  }
4693  case PROP_INT: {
4694  IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
4695  if (iprop->defaultarray) {
4696  MEM_freeN((void *)iprop->defaultarray);
4697  }
4698  break;
4699  }
4700  case PROP_FLOAT: {
4701  FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
4702  if (fprop->defaultarray) {
4703  MEM_freeN((void *)fprop->defaultarray);
4704  }
4705  break;
4706  }
4707  case PROP_ENUM: {
4708  EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
4709 
4710  for (a = 0; a < eprop->totitem; a++) {
4711  if (eprop->item[a].identifier) {
4712  MEM_freeN((void *)eprop->item[a].identifier);
4713  }
4714  if (eprop->item[a].name) {
4715  MEM_freeN((void *)eprop->item[a].name);
4716  }
4717  if (eprop->item[a].description) {
4718  MEM_freeN((void *)eprop->item[a].description);
4719  }
4720  }
4721 
4722  if (eprop->item) {
4723  MEM_freeN((void *)eprop->item);
4724  }
4725  break;
4726  }
4727  case PROP_STRING: {
4728  StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
4729  if (sprop->defaultvalue) {
4730  MEM_freeN((void *)sprop->defaultvalue);
4731  }
4732  break;
4733  }
4734  default:
4735  break;
4736  }
4737  }
4738 }
4739 
4740 static void rna_def_property_free(StructOrFunctionRNA *cont_, PropertyRNA *prop)
4741 {
4742  ContainerRNA *cont = cont_;
4743 
4744  if (prop->flag_internal & PROP_INTERN_RUNTIME) {
4745  if (cont->prophash) {
4746  BLI_ghash_remove(cont->prophash, prop->identifier, NULL, NULL);
4747  }
4748 
4750  rna_freelinkN(&cont->properties, prop);
4751  }
4752  else {
4754  }
4755 }
4756 
4757 static PropertyRNA *rna_def_property_find_py_id(ContainerRNA *cont, const char *identifier)
4758 {
4759  for (PropertyRNA *prop = cont->properties.first; prop; prop = prop->next) {
4760  if (STREQ(prop->identifier, identifier)) {
4761  return prop;
4762  }
4763  }
4764  return NULL;
4765 }
4766 
4767 /* NOTE: only intended for removing dynamic props. */
4768 int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier)
4769 {
4770  ContainerRNA *cont = cont_;
4771  PropertyRNA *prop = rna_def_property_find_py_id(cont, identifier);
4772  if (prop != NULL) {
4773  if (prop->flag_internal & PROP_INTERN_RUNTIME) {
4774  rna_def_property_free(cont, prop);
4775  return 1;
4776  }
4777  else {
4778  return -1;
4779  }
4780  }
4781  return 0;
4782 }
4783 
4785  const char *identifier,
4786  void **r_handle)
4787 {
4788  ContainerRNA *cont = cont_;
4789  PropertyRNA *prop = rna_def_property_find_py_id(cont, identifier);
4790  if (prop != NULL) {
4791  if (prop->flag_internal & PROP_INTERN_RUNTIME) {
4792  *r_handle = prop;
4793  return 1;
4794  }
4795  else {
4796  return -1;
4797  }
4798  }
4799  return 0;
4800 }
4801 
4803 {
4804  ContainerRNA *cont = cont_;
4805  PropertyRNA *prop = handle;
4806  BLI_assert(BLI_findindex(&cont->properties, prop) != -1);
4808  rna_def_property_free(cont, prop);
4809 }
4810 
4811 #endif /* RNA_RUNTIME */
4812 
4814 {
4815  switch (type) {
4816  case PROP_BOOLEAN:
4817  return "PROP_BOOLEAN";
4818  case PROP_INT:
4819  return "PROP_INT";
4820  case PROP_FLOAT:
4821  return "PROP_FLOAT";
4822  case PROP_STRING:
4823  return "PROP_STRING";
4824  case PROP_ENUM:
4825  return "PROP_ENUM";
4826  case PROP_POINTER:
4827  return "PROP_POINTER";
4828  case PROP_COLLECTION:
4829  return "PROP_COLLECTION";
4830  }
4831 
4832  return "PROP_UNKNOWN";
4833 }
typedef float(TangentPoint)[2]
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
#define BLI_assert(a)
Definition: BLI_assert.h:46
GHash * BLI_ghash_str_new_ex(const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_reinsert(GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:715
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:734
void * BLI_ghash_lookup_default(const GHash *gh, const void *key, void *val_default) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:741
void * BLI_ghash_replace_key(GHash *gh, void *key)
Definition: BLI_ghash.c:721
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:790
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:710
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
void * BLI_findstring_ptr(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:273
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:42
unsigned int uint
Definition: BLI_sys_types.h:67
unsigned short ushort
Definition: BLI_sys_types.h:68
#define UNUSED_VARS(...)
#define UNUSED(x)
#define MAX2(a, b)
#define ELEM(...)
#define MIN2(a, b)
#define POINTER_OFFSET(v, ofs)
#define STREQ(a, b)
#define BLT_I18NCONTEXT_DEFAULT_BPYRNA
#define CLOG_ERROR(clg_ref,...)
Definition: CLG_log.h:190
#define CLOG_WARN(clg_ref,...)
Definition: CLG_log.h:189
const void * DNA_default_table[SDNA_TYPE_MAX]
Definition: dna_defaults.c:346
blenloader genfile private function prototypes
void DNA_sdna_free(struct SDNA *sdna)
Definition: dna_genfile.c:123
const unsigned char DNAstr[]
struct SDNA * DNA_sdna_from_data(const void *data, int data_len, bool do_endian_swap, bool data_alloc, const char **r_error_message)
Definition: dna_genfile.c:519
int DNA_elem_size_nr(const struct SDNA *sdna, short type, short name)
void DNA_sdna_alias_data_ensure(struct SDNA *sdna)
Definition: dna_genfile.c:1810
int DNA_struct_find_nr(const struct SDNA *sdna, const char *str)
const int DNAlen
struct ListBase ListBase
_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.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object instance
int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier)
void RNA_def_struct_free_pointers(BlenderRNA *brna, StructRNA *srna)
#define IS_DNATYPE_BOOLEAN_COMPAT(_str)
Definition: RNA_define.h:558
void RNA_def_property_duplicate_pointers(StructOrFunctionRNA *cont_, PropertyRNA *prop)
void RNA_def_property_free_pointers_set_py_data_callback(void(*py_data_clear_fn)(PropertyRNA *prop))
#define IS_DNATYPE_FLOAT_COMPAT(_str)
Definition: RNA_define.h:554
void RNA_def_property_free_identifier_deferred_finish(StructOrFunctionRNA *cont_, void *handle)
#define IS_DNATYPE_INT_COMPAT(_str)
Definition: RNA_define.h:555
void RNA_def_func_duplicate_pointers(FunctionRNA *func)
#define RNA_MAX_ARRAY_LENGTH
Definition: RNA_define.h:25
void RNA_def_struct_duplicate_pointers(BlenderRNA *brna, StructRNA *srna)
void RNA_def_property_free_pointers(PropertyRNA *prop)
void RNA_def_func_free_pointers(FunctionRNA *func)
int RNA_def_property_free_identifier_deferred_prepare(StructOrFunctionRNA *cont_, const char *identifier, void **handle)
void StructOrFunctionRNA
Definition: RNA_define.h:82
#define RNA_MAX_ARRAY_DIMENSION
Definition: RNA_define.h:28
ParameterFlag
Definition: RNA_types.h:351
@ PARM_RNAPTR
Definition: RNA_types.h:354
@ PARM_OUTPUT
Definition: RNA_types.h:353
struct StructRNA *(* StructRegisterFunc)(struct Main *bmain, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
Definition: RNA_types.h:738
int(* EnumPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop)
Definition: RNA_types.h:588
PropertyScaleType
Definition: RNA_types.h:96
@ FUNC_FREE_POINTERS
Definition: RNA_types.h:691
@ FUNC_RUNTIME
Definition: RNA_types.h:686
float(* FloatPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop)
Definition: RNA_types.h:516
@ STRUCT_ID_REFCOUNT
Definition: RNA_types.h:706
@ STRUCT_RUNTIME
Definition: RNA_types.h:711
@ STRUCT_FREE_POINTERS
Definition: RNA_types.h:713
@ STRUCT_PUBLIC_NAMESPACE
Definition: RNA_types.h:721
@ STRUCT_ID
Definition: RNA_types.h:705
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
Definition: RNA_types.h:717
@ STRUCT_PUBLIC_NAMESPACE_INHERIT
Definition: RNA_types.h:723
@ STRUCT_UNDO
Definition: RNA_types.h:708
void **(* StructInstanceFunc)(PointerRNA *ptr)
Definition: RNA_types.h:747
void(* IntPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value)
Definition: RNA_types.h:503
void(* EnumPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value)
Definition: RNA_types.h:589
void(* IntPropertyRangeFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int *min, int *max, int *softmin, int *softmax)
Definition: RNA_types.h:510
void(* StringPropertySearchFunc)(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, const char *edit_text, StringPropertySearchVisitFunc visit_fn, void *visit_user_data)
Definition: RNA_types.h:581
void(* IntArrayPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int *values)
Definition: RNA_types.h:504
eStringPropertySearchFlag
Definition: RNA_types.h:547
@ PROP_STRING_SEARCH_SUPPORTED
Definition: RNA_types.h:552
void(* FloatPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, float value)
Definition: RNA_types.h:517
PropertyType
Definition: RNA_types.h:58
@ PROP_FLOAT
Definition: RNA_types.h:61
@ PROP_BOOLEAN
Definition: RNA_types.h:59
@ PROP_ENUM
Definition: RNA_types.h:63
@ PROP_INT
Definition: RNA_types.h:60
@ PROP_STRING
Definition: RNA_types.h:62
@ PROP_POINTER
Definition: RNA_types.h:64
@ PROP_COLLECTION
Definition: RNA_types.h:65
#define RNA_ENUM_ITEM_SEPR
Definition: RNA_types.h:483
struct ParameterDynAlloc ParameterDynAlloc
struct PointerRNA PointerRNA
void(* CallFunc)(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, ParameterList *parms)
Definition: RNA_types.h:694
void(* FloatPropertyRangeFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, float *min, float *max, float *softmin, float *softmax)
Definition: RNA_types.h:526
#define RNA_TRANSLATION_PREC_DEFAULT
Definition: RNA_types.h:117
void(* BooleanArrayPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const bool *values)
Definition: RNA_types.h:499
void(* FloatArrayPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const float *values)
Definition: RNA_types.h:523
bool(* BooleanPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop)
Definition: RNA_types.h:492
void(* BooleanArrayPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, bool *values)
Definition: RNA_types.h:496
void(* StringPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, char *value)
Definition: RNA_types.h:532
void(* StringPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const char *value)
Definition: RNA_types.h:536
PropertyOverrideFlag
Definition: RNA_types.h:310
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition: RNA_types.h:312
void(* IntArrayPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const int *values)
Definition: RNA_types.h:507
void(* StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type)
Definition: RNA_types.h:746
int(* StringPropertyLengthFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop)
Definition: RNA_types.h:535
int(* IntPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop)
Definition: RNA_types.h:502
const EnumPropertyItem *(* EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free)
Definition: RNA_types.h:591
PropertyFlag
Definition: RNA_types.h:183
@ PROP_THICK_WRAP
Definition: RNA_types.h:285
@ PROP_DYNAMIC
Definition: RNA_types.h:290
@ PROP_ANIMATABLE
Definition: RNA_types.h:202
@ PROP_EDITABLE
Definition: RNA_types.h:189
@ PROP_ENUM_FLAG
Definition: RNA_types.h:266
@ PROP_NEVER_NULL
Definition: RNA_types.h:239
@ PROP_ICONS_CONSECUTIVE
Definition: RNA_types.h:212
@ PROP_PTR_NO_OWNERSHIP
Definition: RNA_types.h:257
@ PROP_ICONS_REVERSE
Definition: RNA_types.h:213
@ PROP_HIDDEN
Definition: RNA_types.h:216
@ PROP_ID_REFCOUNT
Definition: RNA_types.h:226
@ PROP_IDPROPERTY
Definition: RNA_types.h:288
void(* FloatArrayPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, float *values)
Definition: RNA_types.h:520
void(* BooleanPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, bool value)
Definition: RNA_types.h:493
PropertySubType
Definition: RNA_types.h:125
@ PROP_MATRIX
Definition: RNA_types.h:158
@ PROP_XYZ
Definition: RNA_types.h:162
@ PROP_DISTANCE
Definition: RNA_types.h:149
@ PROP_LAYER_MEMBER
Definition: RNA_types.h:171
@ PROP_FILENAME
Definition: RNA_types.h:131
@ PROP_COLOR
Definition: RNA_types.h:153
@ PROP_ANGLE
Definition: RNA_types.h:145
@ PROP_EULER
Definition: RNA_types.h:159
@ PROP_NONE
Definition: RNA_types.h:126
@ PROP_DIRPATH
Definition: RNA_types.h:130
@ PROP_PERCENTAGE
Definition: RNA_types.h:143
@ PROP_FACTOR
Definition: RNA_types.h:144
@ PROP_COLOR_GAMMA
Definition: RNA_types.h:165
@ PROP_TRANSLATION
Definition: RNA_types.h:154
@ PROP_XYZ_LENGTH
Definition: RNA_types.h:163
@ PROP_UNSIGNED
Definition: RNA_types.h:142
@ PROP_LAYER
Definition: RNA_types.h:170
@ PROP_FILEPATH
Definition: RNA_types.h:129
#define UI_PRECISION_FLOAT_MAX
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
StackEntry * from
SyclQueue void void size_t num_bytes void
const char * DNA_struct_rename_legacy_hack_static_from_alias(const char *name)
Definition: dna_utils.c:271
void DNA_alias_maps(enum eDNA_RenameDir version_dir, GHash **r_struct_map, GHash **r_elem_map)
Definition: dna_utils.c:181
int DNA_elem_array_size(const char *str)
Definition: dna_utils.c:27
@ DNA_RENAME_STATIC_FROM_ALIAS
Definition: dna_utils.h:53
int len
Definition: draw_manager.c:108
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void * rna_calloc(int buffer_len)
Definition: makesrna.c:412
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_recallocN_id)(void *vmemh, size_t len, const char *str)
Definition: mallocn.c:30
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
static ulong * next
static void error(const char *str)
Definition: meshlaplacian.c:51
static unsigned a[3]
Definition: RandGen.cpp:78
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt=1)
T length(const vec_base< T, Size > &a)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
return ret
void RNA_struct_py_type_set(StructRNA *srna, void *py_type)
Definition: rna_access.c:892
void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
Definition: rna_access.c:902
void * RNA_struct_py_type_get(StructRNA *srna)
Definition: rna_access.c:887
StructDefRNA * rna_find_struct_def(StructRNA *srna)
Definition: rna_define.c:219
PropertyRNA * RNA_def_string_file_name(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3759
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3836
void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
Definition: rna_define.c:4465
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
Definition: rna_define.c:1148
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2740
PropertyRNA * RNA_def_boolean_layer_member(StructOrFunctionRNA *cont_, const char *identifier, int len, bool *default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3553
void RNA_define_lib_overridable(const bool make_overridable)
Definition: rna_define.c:742
void RNA_def_property_struct_runtime(StructOrFunctionRNA *cont, PropertyRNA *prop, StructRNA *type)
Definition: rna_define.c:1800
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
Definition: rna_define.c:1193
void RNA_define_animate_sdna(bool animate)
Definition: rna_define.c:748
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
void rna_freelinkN(ListBase *listbase, void *vlink)
Definition: rna_define.c:158
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3806
static PropertyDefRNA * rna_def_property_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2164
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4170
struct DNAStructMember DNAStructMember
void RNA_def_property_string_search_func_runtime(PropertyRNA *prop, StringPropertySearchFunc search_fn, const eStringPropertySearchFlag search_flag)
Definition: rna_define.c:3373
void RNA_def_struct_flag(StructRNA *srna, int flag)
Definition: rna_define.c:1133
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2236
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1526
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3655
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
Definition: rna_define.c:3285
const float rna_default_quaternion[4]
Definition: rna_define.c:1590
void RNA_def_property_float_default(PropertyRNA *prop, float value)
Definition: rna_define.c:2022
static void rna_remlink(ListBase *listbase, void *vlink)
Definition: rna_define.c:125
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4312
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:4076
PropertyRNA * RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, int rows, int columns, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3954
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
Definition: rna_define.c:2106
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3126
void RNA_define_verify_sdna(bool verify)
Definition: rna_define.c:737
PropertyRNA * RNA_def_float_distance(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:4052
void rna_freelistN(ListBase *listbase)
Definition: rna_define.c:164
void RNA_def_property_string_search_func(PropertyRNA *prop, const char *search, const eStringPropertySearchFlag search_flag)
Definition: rna_define.c:3319
void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type)
Definition: rna_define.c:1855
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1645
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2695
const int rna_matrix_dimsize_4x2[]
Definition: rna_define.c:1596
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
Definition: rna_define.c:1653
void RNA_def_struct_property_tags(StructRNA *srna, const EnumPropertyItem *prop_tag_defines)
Definition: rna_define.c:1143
PropertyRNA * RNA_def_string_file_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3711
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4273
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
Definition: rna_define.c:3474
void RNA_def_property_int_funcs_runtime(PropertyRNA *prop, IntPropertyGetFunc getfunc, IntPropertySetFunc setfunc, IntPropertyRangeFunc rangefunc)
Definition: rna_define.c:3072
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
Definition: rna_define.c:3420
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1237
const float rna_default_scale_3d[3]
Definition: rna_define.c:1592
void RNA_def_function_output(FunctionRNA *UNUSED(func), PropertyRNA *ret)
Definition: rna_define.c:4337
#define ASSERT_SOFT_HARD_LIMITS
Definition: rna_define.c:45
PropertyDefRNA * rna_find_struct_property_def(StructRNA *srna, PropertyRNA *prop)
Definition: rna_define.c:239
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
Definition: rna_define.c:1937
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
Definition: rna_define.c:2944
PropertyRNA * RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4221
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
Definition: rna_define.c:1172
void RNA_identifier_sanitize(char *identifier, int property)
Definition: rna_define.c:603
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
Definition: rna_define.c:2926
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
Definition: rna_define.c:1598
void RNA_def_property_enum_funcs_runtime(PropertyRNA *prop, EnumPropertyGetFunc getfunc, EnumPropertySetFunc setfunc, EnumPropertyItemFunc itemfunc)
Definition: rna_define.c:3258
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3862
void RNA_def_property_boolean_array_funcs_runtime(PropertyRNA *prop, BooleanArrayPropertyGetFunc getfunc, BooleanArrayPropertySetFunc setfunc)
Definition: rna_define.c:3005
#define DESCR_CHECK(description, id1, id2)
Definition: rna_define.c:92
void RNA_def_struct_identifier(BlenderRNA *brna, StructRNA *srna, const char *identifier)
Definition: rna_define.c:1205
static int rna_member_cmp(const char *name, const char *oname)
Definition: rna_define.c:402
void RNA_def_property_int_default(PropertyRNA *prop, int value)
Definition: rna_define.c:1978
const float rna_default_axis_angle[4]
Definition: rna_define.c:1591
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
Definition: rna_define.c:900
void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editable)
Definition: rna_define.c:2867
PropertyRNA * RNA_def_boolean_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, bool *default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3575
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1872
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1048
void RNA_def_py_data(PropertyRNA *prop, void *py_data)
Definition: rna_define.c:3486
void RNA_def_struct_clear_flag(StructRNA *srna, int flag)
Definition: rna_define.c:1138
void RNA_def_property_array(PropertyRNA *prop, int length)
Definition: rna_define.c:1539
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
Definition: rna_define.c:1737
static bool debugSRNA_defaults
Definition: rna_define.c:74
void RNA_def_struct_identifier_no_struct_map(StructRNA *srna, const char *identifier)
Definition: rna_define.c:1227
void RNA_def_property_poll_runtime(PropertyRNA *prop, const void *func)
Definition: rna_define.c:2916
PropertyRNA * RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:4144
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
Definition: rna_define.c:1920
void RNA_def_struct_sdna_from(StructRNA *srna, const char *structname, const char *propname)
Definition: rna_define.c:1075
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1772
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
Definition: rna_define.c:2769
GHash * struct_map_static_from_alias
Definition: rna_define.c:65
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4347
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2900
const int rna_matrix_dimsize_4x4[]
Definition: rna_define.c:1595
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
Definition: rna_define.c:3224
static size_t rna_property_type_sizeof(PropertyType type)
Definition: rna_define.c:865
PropertyRNA * RNA_def_float_percentage(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:4108
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
Definition: rna_define.c:2855
void RNA_def_property_float_funcs_runtime(PropertyRNA *prop, FloatPropertyGetFunc getfunc, FloatPropertySetFunc setfunc, FloatPropertyRangeFunc rangefunc)
Definition: rna_define.c:3170
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1257
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3623
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2669
static FunctionRNA * rna_def_function(StructRNA *srna, const char *identifier)
Definition: rna_define.c:4239
void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
Definition: rna_define.c:2000
void RNA_free(BlenderRNA *brna)
Definition: rna_define.c:828
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
Definition: rna_define.c:4487
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
Definition: rna_define.c:1103
static int DNA_struct_find_nr_wrapper(const struct SDNA *sdna, const char *struct_name)
Definition: rna_define.c:206
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4342
static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *membername, DNAStructMember *smember, int *offset)
Definition: rna_define.c:439
static ContainerDefRNA * rna_find_container_def(ContainerRNA *cont)
Definition: rna_define.c:367
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1495
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext)
Definition: rna_define.c:762
static struct @1144 g_version_data
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
Definition: rna_define.c:3385
static int rna_validate_identifier(const char *identifier, char *error, bool property)
Definition: rna_define.c:527
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1028
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2601
PropertyRNA * RNA_def_float_translation(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3986
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
Definition: rna_define.c:4436
PropertyRNA * RNA_def_string_dir_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3735
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3028
PropertyRNA * RNA_def_pointer_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4186
const int rna_matrix_dimsize_3x3[]
Definition: rna_define.c:1594
int rna_parameter_size(PropertyRNA *parm)
Definition: rna_define.c:4352
void RNA_define_free(BlenderRNA *UNUSED(brna))
Definition: rna_define.c:707
void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
Definition: rna_define.c:2065
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1245
FunctionDefRNA * rna_find_function_def(FunctionRNA *func)
Definition: rna_define.c:296
FunctionRNA * RNA_def_function_runtime(StructRNA *srna, const char *identifier, CallFunc call)
Definition: rna_define.c:4296
void RNA_def_property_int_array_funcs_runtime(PropertyRNA *prop, IntArrayPropertyGetFunc getfunc, IntArrayPropertySetFunc setfunc, IntPropertyRangeFunc rangefunc)
Definition: rna_define.c:3099
void RNA_def_property_float_array_funcs_runtime(PropertyRNA *prop, FloatArrayPropertyGetFunc getfunc, FloatArrayPropertySetFunc setfunc, FloatPropertyRangeFunc rangefunc)
Definition: rna_define.c:3197
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
Definition: rna_define.c:777
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3922
static void print_default_info(const PropertyDefRNA *dp)
Definition: rna_define.c:76
BlenderDefRNA DefRNA
Definition: rna_define.c:50
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
Definition: rna_define.c:1160
void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, const char *apply)
Definition: rna_define.c:2879
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
Definition: rna_define.c:2848
static CLG_LogRef LOG
Definition: rna_define.c:35
PropertyRNA * RNA_def_float_vector_xyz(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3894
PropertyDefRNA * rna_find_parameter_def(PropertyRNA *parm)
Definition: rna_define.c:328
static StructDefRNA * rna_find_def_struct(StructRNA *srna)
Definition: rna_define.c:887
void RNA_def_property_ui_scale_type(PropertyRNA *prop, PropertyScaleType ui_scale_type)
Definition: rna_define.c:1715
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
void RNA_def_property_override_clear_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
Definition: rna_define.c:1508
void RNA_def_property_update_runtime(PropertyRNA *prop, const void *func)
Definition: rna_define.c:2911
void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem)
Definition: rna_define.c:4459
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
Definition: rna_define.c:3830
BlenderRNA * RNA_create(void)
Definition: rna_define.c:678
static void rna_brna_structs_add(BlenderRNA *brna, StructRNA *srna)
Definition: rna_define.c:176
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
Definition: rna_define.c:1534
PropertyRNA * RNA_def_collection(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4205
PropertyDefRNA * rna_findlink(ListBase *listbase, const char *identifier)
Definition: rna_define.c:144
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2493
PropertyRNA * RNA_def_boolean_layer(StructOrFunctionRNA *cont_, const char *identifier, int len, bool *default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3531
void RNA_def_property_boolean_array_default(PropertyRNA *prop, const bool *array)
Definition: rna_define.c:1961
void RNA_def_property_boolean_funcs_runtime(PropertyRNA *prop, BooleanPropertyGetFunc getfunc, BooleanPropertySetFunc setfunc)
Definition: rna_define.c:2982
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
Definition: rna_define.c:4472
PropertyRNA * RNA_def_boolean_array(StructOrFunctionRNA *cont_, const char *identifier, int len, bool *default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3509
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
Definition: rna_define.c:1664
PropertyRNA * RNA_def_float_rotation(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:4016
void RNA_def_property_tags(PropertyRNA *prop, int tags)
Definition: rna_define.c:1513
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2343
const char * RNA_property_typename(PropertyType type)
Definition: rna_define.c:4813
void RNA_def_struct_translation_context(StructRNA *srna, const char *context)
Definition: rna_define.c:1250
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
Definition: rna_define.c:2043
int rna_parameter_size_pad(const int size)
Definition: rna_define.c:4424
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
Definition: rna_define.c:2327
void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
Definition: rna_define.c:1119
void RNA_define_fallback_property_update(int noteflag, const char *updatefunc)
Definition: rna_define.c:755
void RNA_def_property_string_funcs_runtime(PropertyRNA *prop, StringPropertyGetFunc getfunc, StringPropertyLengthFunc lengthfunc, StringPropertySetFunc setfunc)
Definition: rna_define.c:3346
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
Definition: rna_define.c:1503
void rna_addtail(ListBase *listbase, void *vlink)
Definition: rna_define.c:109
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1518
PointerRNA rna_builtin_properties_get(struct CollectionPropertyIterator *iter)
void rna_builtin_properties_next(struct CollectionPropertyIterator *iter)
void rna_builtin_properties_begin(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr)
#define RNA_MAGIC
Definition: rna_internal.h:21
PointerRNA rna_builtin_type_get(struct PointerRNA *ptr)
StructRNA *(* PropPointerTypeFunc)(struct PointerRNA *ptr)
void(* PropIntSetFunc)(struct PointerRNA *ptr, int value)
void(* PropBooleanArrayGetFunc)(struct PointerRNA *ptr, bool *values)
struct IntPropertyRNA IntPropertyRNA
void(* PropEnumSetFunc)(struct PointerRNA *ptr, int value)
int(* PropArrayLengthGetFunc)(const struct PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
bool(* RNAPropOverrideApply)(struct Main *bmain, struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage, int len_dst, int len_src, int len_storage, struct PointerRNA *ptr_item_dst, struct PointerRNA *ptr_item_src, struct PointerRNA *ptr_item_storage, struct IDOverrideLibraryPropertyOperation *opop)
int(* PropCollectionAssignIntFunc)(struct PointerRNA *ptr, int key, const struct PointerRNA *assign_ptr)
void(* PropIntArrayGetFunc)(struct PointerRNA *ptr, int *values)
PointerRNA(* PropCollectionGetFunc)(struct CollectionPropertyIterator *iter)
void(* PropStringSetFunc)(struct PointerRNA *ptr, const char *value)
bool(* PropPointerPollFunc)(struct PointerRNA *ptr, const PointerRNA value)
@ PROP_INTERN_BUILTIN
@ PROP_INTERN_PTR_OWNERSHIP_FORCED
@ PROP_INTERN_FREE_POINTERS
@ PROP_INTERN_RUNTIME
void(* PropFloatRangeFunc)(struct PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
int(* PropStringLengthFunc)(struct PointerRNA *ptr)
void(* PropCollectionNextFunc)(struct CollectionPropertyIterator *iter)
struct StructRNA *(* StructRefineFunc)(struct PointerRNA *ptr)
int(* PropCollectionLengthFunc)(struct PointerRNA *ptr)
void(* PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value, struct ReportList *reports)
int(* RNAPropOverrideDiff)(struct Main *bmain, struct PropertyRNAOrID *prop_a, struct PropertyRNAOrID *prop_b, int mode, struct IDOverrideLibrary *override, const char *rna_path, size_t rna_path_len, int flags, bool *r_override_changed)
char *(* StructPathFunc)(const struct PointerRNA *ptr)
struct IDProperty **(* IDPropertiesFunc)(struct PointerRNA *ptr)
struct PointerPropertyRNA PointerPropertyRNA
bool(* RNAPropOverrideStore)(struct Main *bmain, struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_local, struct PropertyRNA *prop_reference, struct PropertyRNA *prop_storage, int len_local, int len_reference, int len_storage, struct IDOverrideLibraryPropertyOperation *opop)
void(* PropFloatSetFunc)(struct PointerRNA *ptr, float value)
void(* PropBooleanArraySetFunc)(struct PointerRNA *ptr, const bool *values)
struct FloatPropertyRNA FloatPropertyRNA
void(* PropStringGetFunc)(struct PointerRNA *ptr, char *value)
const EnumPropertyItem *(* PropEnumItemFunc)(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free)
void(* PropIntArraySetFunc)(struct PointerRNA *ptr, const int *values)
bool(* PropBooleanGetFunc)(struct PointerRNA *ptr)
int(* ItemEditableFunc)(struct PointerRNA *ptr, int index)
void(* PropBooleanSetFunc)(struct PointerRNA *ptr, bool value)
void(* PropFloatArraySetFunc)(struct PointerRNA *ptr, const float *values)
struct EnumPropertyRNA EnumPropertyRNA
struct CollectionPropertyRNA CollectionPropertyRNA
int(* PropEnumGetFunc)(struct PointerRNA *ptr)
PointerRNA(* PropPointerGetFunc)(struct PointerRNA *ptr)
void(* PropCollectionBeginFunc)(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr)
void(* PropIntRangeFunc)(struct PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
void(* PropCollectionEndFunc)(struct CollectionPropertyIterator *iter)
int(* PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr)
struct BoolPropertyRNA BoolPropertyRNA
#define CONTAINER_RNA_ID(cont)
struct StringPropertyRNA StringPropertyRNA
int(* PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key, struct PointerRNA *r_ptr)
void(* PropFloatArrayGetFunc)(struct PointerRNA *ptr, float *values)
void(* UpdateFunc)(struct Main *bmain, struct Scene *active_scene, struct PointerRNA *ptr)
int(* EditableFunc)(struct PointerRNA *ptr, const char **r_info)
float(* PropFloatGetFunc)(struct PointerRNA *ptr)
int(* PropIntGetFunc)(struct PointerRNA *ptr)
#define min(a, b)
Definition: sort.c:35
__int64 int64_t
Definition: stdint.h:89
#define INT8_MIN
Definition: stdint.h:132
#define INT8_MAX
Definition: stdint.h:133
struct AllocDefRNA * next
Definition: rna_internal.h:104
ListBase allocs
Definition: rna_internal.h:111
struct StructRNA * laststruct
Definition: rna_internal.h:112
ListBase structs
Definition: rna_internal.h:110
struct SDNA * sdna
Definition: rna_internal.h:109
struct BlenderDefRNA::@1145 fallback
bool make_overridable
Definition: rna_internal.h:119
struct BlenderDefRNA::@1145::@1146 property_update
struct GHash * structs_map
unsigned int structs_len
PropBooleanArraySetFuncEx setarray_ex
PropBooleanArrayGetFuncEx getarray_ex
PropBooleanArraySetFunc setarray
const bool * defaultarray
PropBooleanSetFunc set
PropBooleanGetFunc get
PropBooleanSetFuncEx set_ex
PropBooleanGetFuncEx get_ex
PropBooleanArrayGetFunc getarray
PropCollectionNextFunc next
PropCollectionLookupStringFunc lookupstring
PropCollectionLengthFunc length
struct StructRNA * item_type
PropCollectionLookupIntFunc lookupint
PropCollectionBeginFunc begin
PropCollectionAssignIntFunc assignint
PropCollectionEndFunc end
PropCollectionGetFunc get
ListBase properties
Definition: rna_internal.h:41
struct GHash * prophash
const char * type
Definition: rna_define.c:394
const char * name
Definition: rna_define.c:395
const char * identifier
Definition: RNA_types.h:461
const char * name
Definition: RNA_types.h:465
const char * description
Definition: RNA_types.h:467
const EnumPropertyItem * item
PropEnumSetFuncEx set_ex
PropEnumGetFunc get
const char * native_enum_type
PropEnumItemFunc item_fn
PropEnumGetFuncEx get_ex
PropEnumSetFunc set
void * data
Definition: RNA_types.h:765
StructFreeFunc free
Definition: RNA_types.h:768
PropFloatSetFuncEx set_ex
PropertyScaleType ui_scale_type
PropFloatGetFunc get
PropFloatRangeFuncEx range_ex
PropFloatArrayGetFuncEx getarray_ex
PropFloatArraySetFuncEx setarray_ex
PropFloatArrayGetFunc getarray
PropFloatSetFunc set
const float * defaultarray
PropFloatRangeFunc range
PropFloatArraySetFunc setarray
PropFloatGetFuncEx get_ex
FunctionRNA * func
Definition: rna_internal.h:47
ContainerDefRNA cont
Definition: rna_internal.h:45
const char * call
Definition: rna_internal.h:49
const char * identifier
PropertyRNA * c_ret
ContainerRNA cont
const char * description
PropIntRangeFuncEx range_ex
PropIntGetFunc get
PropIntArrayGetFunc getarray
const int * defaultarray
PropIntArrayGetFuncEx getarray_ex
PropIntRangeFunc range
PropIntArraySetFunc setarray
PropIntGetFuncEx get_ex
PropIntSetFunc set
PropIntArraySetFuncEx setarray_ex
PropertyScaleType ui_scale_type
PropIntSetFuncEx set_ex
void * last
Definition: DNA_listBase.h:31
void * first
Definition: DNA_listBase.h:31
PropPointerTypeFunc type_fn
struct StructRNA * type
PropPointerGetFunc get
PropPointerPollFunc poll
PropPointerSetFunc set
const char * dnatype
Definition: rna_internal.h:66
const char * dnaname
Definition: rna_internal.h:65
const char * dnastructfromprop
Definition: rna_internal.h:62
const char * dnastructname
Definition: rna_internal.h:60
struct ContainerRNA * cont
Definition: rna_internal.h:56
const char * dnalengthstructname
Definition: rna_internal.h:76
const char * dnalengthname
Definition: rna_internal.h:77
struct PropertyRNA * prop
Definition: rna_internal.h:57
const char * dnastructfromname
Definition: rna_internal.h:61
bool booleannegative
Definition: rna_internal.h:81
struct PropertyDefRNA * prev
Definition: rna_internal.h:54
int64_t booleanbit
Definition: rna_internal.h:80
ItemEditableFunc itemeditable
PropArrayLengthGetFunc getlength
const char * translation_context
RNAPropOverrideApply override_apply
unsigned int arraydimension
struct PropertyRNA * next
EditableFunc editable
RNAPropOverrideStore override_store
RNAPropOverrideDiff override_diff
struct StructRNA * srna
PropertySubType subtype
unsigned int arraylength[RNA_MAX_ARRAY_DIMENSION]
const char * description
const char * name
unsigned int totarraylength
const char * identifier
RawPropertyType rawtype
PropertyType type
UpdateFunc update
short members_len
SDNA_StructMember members[]
SDNA_Struct ** structs
struct SDNA::@1048 alias
const char ** types
const char ** names
PropStringSetFunc set
const char * defaultvalue
PropStringLengthFuncEx length_ex
PropStringLengthFunc length
PropStringGetFuncEx get_ex
PropStringSetFuncEx set_ex
PropStringGetFunc get
StringPropertySearchFunc search
eStringPropertySearchFlag search_flag
const char * dnaname
Definition: rna_internal.h:94
ContainerDefRNA cont
Definition: rna_internal.h:89
ListBase functions
Definition: rna_internal.h:100
struct StructRNA * srna
Definition: rna_internal.h:91
const char * dnafromprop
Definition: rna_internal.h:98
const char * dnafromname
Definition: rna_internal.h:97
StructRegisterFunc reg
StructUnregisterFunc unreg
const char * name
const char * identifier
StructInstanceFunc instance
ContainerRNA cont
struct StructRNA * nested
const char * translation_context
const EnumPropertyItem * prop_tag_defines
PropertyRNA * nameproperty
const char * description
IDPropertiesFunc idproperties
struct StructRNA * base
PropertyRNA * iteratorproperty
ListBase functions
StructRefineFunc refine
StructPathFunc path
float max