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