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