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