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