Blender V4.5
makesrna.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 <algorithm>
10#include <cerrno>
11#include <cfloat>
12#include <cinttypes>
13#include <climits>
14#include <cmath>
15#include <cstdio>
16#include <cstdlib>
17#include <cstring>
18#include <limits>
19
20#include "MEM_guardedalloc.h"
21
22#include "BLI_listbase.h"
23#include "BLI_string.h"
24#include "BLI_system.h" /* For #BLI_system_backtrace stub. */
25#include "BLI_utildefines.h"
26
27#include "RNA_define.hh"
28#include "RNA_enum_types.hh"
29#include "RNA_types.hh"
30
31#include "rna_internal.hh"
32
33#include "CLG_log.h"
34
35static CLG_LogRef LOG = {"makesrna"};
36
43static int debugSRNA = 0;
44
45/* stub for BLI_abort() */
46#ifndef NDEBUG
48{
49 (void)fp;
50}
51#endif /* !NDEBUG */
52
53/* Replace if different */
54#define TMP_EXT ".tmp"
55
56/* copied from BLI_file_older */
57#include <sys/stat.h>
58static bool file_older(const char *file1, const char *file2)
59{
60 struct stat st1, st2;
61 if (debugSRNA > 0) {
62 printf("compare: %s %s\n", file1, file2);
63 }
64
65 if (stat(file1, &st1)) {
66 return false;
67 }
68 if (stat(file2, &st2)) {
69 return false;
70 }
71
72 return (st1.st_mtime < st2.st_mtime);
73}
74static const char *makesrna_path = nullptr;
75
76static const char *path_basename(const char *path)
77{
78 const char *lfslash, *lbslash;
79
80 lfslash = strrchr(path, '/');
81 lbslash = strrchr(path, '\\');
82 if (lbslash) {
83 lbslash++;
84 }
85 if (lfslash) {
86 lfslash++;
87 }
88
89 return std::max({path, lfslash, lbslash});
90}
91
92/* forward declarations */
94 StructRNA *srna,
95 FunctionDefRNA *dfunc,
96 const char *name_override,
97 int close_prototype);
98
99/* helpers */
100#define WRITE_COMMA \
101 { \
102 if (!first) { \
103 fprintf(f, ", "); \
104 } \
105 first = 0; \
106 } \
107 (void)0
108
109#define WRITE_PARAM(param) \
110 { \
111 WRITE_COMMA; \
112 fprintf(f, param); \
113 } \
114 (void)0
115
119static int replace_if_different(const char *tmpfile, const char *dep_files[])
120{
121
122#ifdef USE_MAKEFILE_WORKAROUND
123 const bool use_makefile_workaround = true;
124#else
125 const bool use_makefile_workaround = false;
126#endif
127
128 /* Use for testing hand edited `rna_*_gen.c` files. */
129 // return 0;
130
131#define REN_IF_DIFF \
132 { \
133 FILE *file_test = fopen(orgfile, "rb"); \
134 if (file_test) { \
135 fclose(file_test); \
136 if (fp_org) { \
137 fclose(fp_org); \
138 } \
139 if (fp_new) { \
140 fclose(fp_new); \
141 } \
142 if (remove(orgfile) != 0) { \
143 CLOG_ERROR(&LOG, "remove error (%s): \"%s\"", strerror(errno), orgfile); \
144 return -1; \
145 } \
146 } \
147 } \
148 if (rename(tmpfile, orgfile) != 0) { \
149 CLOG_ERROR(&LOG, "rename error (%s): \"%s\" -> \"%s\"", strerror(errno), tmpfile, orgfile); \
150 return -1; \
151 } \
152 remove(tmpfile); \
153 return 1; \
154 ((void)0)
155 /* End `REN_IF_DIFF`. */
156
157 FILE *fp_new = nullptr, *fp_org = nullptr;
158 int len_new, len_org;
159 char *arr_new, *arr_org;
160 int cmp;
161
162 const char *makesrna_source_filepath = __FILE__;
163 const char *makesrna_source_filename = path_basename(makesrna_source_filepath);
164
165 char orgfile[4096];
166
167 STRNCPY(orgfile, tmpfile);
168 orgfile[strlen(orgfile) - strlen(TMP_EXT)] = '\0'; /* Strip `.tmp`. */
169
170 fp_org = fopen(orgfile, "rb");
171
172 if (fp_org == nullptr) {
174 }
175
176 /* NOTE(@ideasman42): trick to work around dependency problem.
177 * The issue is as follows: When `makesrna.cc` or any of the `rna_*.c` files being newer than
178 * their generated output, the build-system detects that the `rna_*_gen.c` file is out-dated and
179 * requests the `rna_*_gen.c` files are re-generated (even if this function always returns 0).
180 * It happens *every* rebuild, slowing incremental builds which isn't practical for development.
181 *
182 * This is only an issue for `Unix Makefiles`, `Ninja` generator doesn't have this problem.
183 *
184 * CMake will set `use_makefile_workaround` to 0 or 1 depending on the generator used. */
185
186 if (use_makefile_workaround) {
187 /* First check if `makesrna.cc` is newer than generated files.
188 * For development on `makesrna.cc` you may want to disable this. */
189 if (file_older(orgfile, makesrna_source_filepath)) {
191 }
192
193 if (file_older(orgfile, makesrna_path)) {
195 }
196
197 /* Now check if any files we depend on are newer than any generated files. */
198 if (dep_files) {
199 int pass;
200 for (pass = 0; dep_files[pass]; pass++) {
201 char from_path[4096];
202 /* Only the directory (base-name). */
203 SNPRINTF(from_path,
204 "%.*s%s",
205 int(makesrna_source_filename - makesrna_source_filepath),
206 makesrna_source_filepath,
207 dep_files[pass]);
208 /* Account for build dependencies, if `makesrna.cc` (this file) is newer. */
209 if (file_older(orgfile, from_path)) {
211 }
212 }
213 }
214 }
215 /* XXX end dep trick */
216
217 fp_new = fopen(tmpfile, "rb");
218
219 if (fp_new == nullptr) {
220 /* Shouldn't happen, just to be safe. */
221 CLOG_ERROR(&LOG, "open error: \"%s\"", tmpfile);
222 fclose(fp_org);
223 return -1;
224 }
225
226 fseek(fp_new, 0L, SEEK_END);
227 len_new = ftell(fp_new);
228 fseek(fp_new, 0L, SEEK_SET);
229 fseek(fp_org, 0L, SEEK_END);
230 len_org = ftell(fp_org);
231 fseek(fp_org, 0L, SEEK_SET);
232
233 if (len_new != len_org) {
234 fclose(fp_new);
235 fp_new = nullptr;
236 fclose(fp_org);
237 fp_org = nullptr;
239 }
240
241 /* Now compare the files: */
242 arr_new = MEM_malloc_arrayN<char>(size_t(len_new), "rna_cmp_file_new");
243 arr_org = MEM_malloc_arrayN<char>(size_t(len_org), "rna_cmp_file_org");
244
245 if (fread(arr_new, sizeof(char), len_new, fp_new) != len_new) {
246 CLOG_ERROR(&LOG, "unable to read file %s for comparison.", tmpfile);
247 }
248 if (fread(arr_org, sizeof(char), len_org, fp_org) != len_org) {
249 CLOG_ERROR(&LOG, "unable to read file %s for comparison.", orgfile);
250 }
251
252 fclose(fp_new);
253 fp_new = nullptr;
254 fclose(fp_org);
255 fp_org = nullptr;
256
257 cmp = memcmp(arr_new, arr_org, len_new);
258
259 MEM_freeN(arr_new);
260 MEM_freeN(arr_org);
261
262 if (cmp) {
264 }
265 remove(tmpfile);
266 return 0;
267
268#undef REN_IF_DIFF
269}
270
271/* Helper to solve keyword problems with C/C++. */
272
273static const char *rna_safe_id(const char *id)
274{
275 if (STREQ(id, "default")) {
276 return "default_value";
277 }
278 if (STREQ(id, "operator")) {
279 return "operator_value";
280 }
281 if (STREQ(id, "new")) {
282 return "create";
283 }
284 if (STREQ(id, "co_return")) {
285 /* MSVC2015, C++ uses for coroutines */
286 return "coord_return";
287 }
288
289 return id;
290}
291
292/* Sorting */
293
294static int cmp_struct(const void *a, const void *b)
295{
296 const StructRNA *structa = *(const StructRNA **)a;
297 const StructRNA *structb = *(const StructRNA **)b;
298
299 return strcmp(structa->identifier, structb->identifier);
300}
301
302static int cmp_property(const void *a, const void *b)
303{
304 const PropertyRNA *propa = *(const PropertyRNA **)a;
305 const PropertyRNA *propb = *(const PropertyRNA **)b;
306
307 if (STREQ(propa->identifier, "rna_type")) {
308 return -1;
309 }
310 if (STREQ(propb->identifier, "rna_type")) {
311 return 1;
312 }
313
314 if (STREQ(propa->identifier, "name")) {
315 return -1;
316 }
317 if (STREQ(propb->identifier, "name")) {
318 return 1;
319 }
320
321 return strcmp(propa->name, propb->name);
322}
323
324static int cmp_def_struct(const void *a, const void *b)
325{
326 const StructDefRNA *dsa = *(const StructDefRNA **)a;
327 const StructDefRNA *dsb = *(const StructDefRNA **)b;
328
329 return cmp_struct(&dsa->srna, &dsb->srna);
330}
331
332static int cmp_def_property(const void *a, const void *b)
333{
334 const PropertyDefRNA *dpa = *(const PropertyDefRNA **)a;
335 const PropertyDefRNA *dpb = *(const PropertyDefRNA **)b;
336
337 return cmp_property(&dpa->prop, &dpb->prop);
338}
339
340static void rna_sortlist(ListBase *listbase, int (*cmp)(const void *, const void *))
341{
342 Link *link;
343 void **array;
344 int a, size;
345
346 if (listbase->first == listbase->last) {
347 return;
348 }
349
350 for (size = 0, link = static_cast<Link *>(listbase->first); link; link = link->next) {
351 size++;
352 }
353
354 array = MEM_malloc_arrayN<void *>(size_t(size), "rna_sortlist");
355 for (a = 0, link = static_cast<Link *>(listbase->first); link; link = link->next, a++) {
356 array[a] = link;
357 }
358
359 qsort(array, size, sizeof(void *), cmp);
360
361 listbase->first = listbase->last = nullptr;
362 for (a = 0; a < size; a++) {
363 link = static_cast<Link *>(array[a]);
364 link->next = link->prev = nullptr;
365 rna_addtail(listbase, link);
366 }
367
369}
370
371/* Preprocessing */
372
373static void rna_print_c_string(FILE *f, const char *str)
374{
375 static const char *escape[] = {
376 "\''", "\"\"", "\??", "\\\\", "\aa", "\bb", "\ff", "\nn", "\rr", "\tt", "\vv", nullptr};
377 int i, j;
378
379 if (!str) {
380 fprintf(f, "nullptr");
381 return;
382 }
383
384 fprintf(f, "\"");
385 for (i = 0; str[i]; i++) {
386 for (j = 0; escape[j]; j++) {
387 if (str[i] == escape[j][0]) {
388 break;
389 }
390 }
391
392 if (escape[j]) {
393 fprintf(f, "\\%c", escape[j][1]);
394 }
395 else {
396 fprintf(f, "%c", str[i]);
397 }
398 }
399 fprintf(f, "\"");
400}
401
402static void rna_print_data_get(FILE *f, PropertyDefRNA *dp)
403{
404 if (dp->dnastructfromname && dp->dnastructfromprop) {
405 fprintf(f,
406 " %s *data = (%s *)(((%s *)ptr->data)->%s);\n",
407 dp->dnastructname,
408 dp->dnastructname,
411 }
412 else {
413 fprintf(f, " %s *data = (%s *)(ptr->data);\n", dp->dnastructname, dp->dnastructname);
414 }
415}
416
417static void rna_print_id_get(FILE *f, PropertyDefRNA * /*dp*/)
418{
419 fprintf(f, " ID *id = ptr->owner_id;\n");
420}
421
423 char *buffer, int size, const char *structname, const char *propname, const char *type)
424{
425 BLI_snprintf(buffer, size, "%s_%s_%s", structname, propname, type);
426}
427
429 char *buffer, int size, const char *structname, const char *propname, const char *type)
430{
431 if (type == nullptr || type[0] == '\0') {
432 BLI_snprintf(buffer, size, "%s_%s", structname, propname);
433 }
434 else {
435 BLI_snprintf(buffer, size, "%s_%s_%s", structname, propname, type);
436 }
437}
438
439void *rna_alloc_from_buffer(const char *buffer, int buffer_size)
440{
441 AllocDefRNA *alloc = MEM_callocN<AllocDefRNA>("AllocDefRNA");
442 alloc->mem = MEM_mallocN(buffer_size, __func__);
443 memcpy(alloc->mem, buffer, buffer_size);
444 rna_addtail(&DefRNA.allocs, alloc);
445 return alloc->mem;
446}
447
448void *rna_calloc(int buffer_size)
449{
450 AllocDefRNA *alloc = MEM_callocN<AllocDefRNA>("AllocDefRNA");
451 alloc->mem = MEM_callocN(buffer_size, __func__);
452 rna_addtail(&DefRNA.allocs, alloc);
453 return alloc->mem;
454}
455
456static char *rna_alloc_function_name(const char *structname,
457 const char *propname,
458 const char *type)
459{
460 char buffer[2048];
461 rna_construct_function_name(buffer, sizeof(buffer), structname, propname, type);
462 return static_cast<char *>(rna_alloc_from_buffer(buffer, strlen(buffer) + 1));
463}
464
465static StructRNA *rna_find_struct(const char *identifier)
466{
467 StructDefRNA *ds;
468
469 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
470 ds = static_cast<StructDefRNA *>(ds->cont.next))
471 {
472 if (STREQ(ds->srna->identifier, identifier)) {
473 return ds->srna;
474 }
475 }
476
477 return nullptr;
478}
479
480static const char *rna_find_type(const char *type)
481{
482 StructDefRNA *ds;
483
484 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
485 ds = static_cast<StructDefRNA *>(ds->cont.next))
486 {
487 if (ds->dnaname && STREQ(ds->dnaname, type)) {
488 return ds->srna->identifier;
489 }
490 }
491
492 return nullptr;
493}
494
495static const char *rna_find_dna_type(const char *type)
496{
497 StructDefRNA *ds;
498
499 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
500 ds = static_cast<StructDefRNA *>(ds->cont.next))
501 {
502 if (STREQ(ds->srna->identifier, type)) {
503 return ds->dnaname;
504 }
505 }
506
507 return nullptr;
508}
509
510static const char *rna_type_type_name(PropertyRNA *prop)
511{
512 switch (prop->type) {
513 case PROP_BOOLEAN:
514 return "bool";
515 case PROP_INT:
516 return "int";
517 case PROP_ENUM: {
518 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
519 if (eprop->native_enum_type) {
520 return eprop->native_enum_type;
521 }
522 return "int";
523 }
524 case PROP_FLOAT:
525 return "float";
526 case PROP_STRING:
527 if (prop->flag & PROP_THICK_WRAP) {
528 return "char *";
529 }
530 else {
531 return "const char *";
532 }
533 default:
534 return nullptr;
535 }
536}
537
538static const char *rna_type_type(PropertyRNA *prop)
539{
540 const char *type;
541
542 type = rna_type_type_name(prop);
543
544 if (type) {
545 return type;
546 }
547
548 return "PointerRNA";
549}
550
551static const char *rna_type_struct(PropertyRNA *prop)
552{
553 const char *type;
554
555 type = rna_type_type_name(prop);
556
557 if (type) {
558 return "";
559 }
560
561 return "struct ";
562}
563
564static const char *rna_parameter_type_name(PropertyRNA *parm)
565{
566 const char *type;
567
568 type = rna_type_type_name(parm);
569
570 if (type) {
571 return type;
572 }
573
574 switch (parm->type) {
575 case PROP_POINTER: {
576 PointerPropertyRNA *pparm = (PointerPropertyRNA *)parm;
577
578 if (parm->flag_parameter & PARM_RNAPTR) {
579 return "PointerRNA";
580 }
581 return rna_find_dna_type((const char *)pparm->type);
582 }
583 case PROP_COLLECTION: {
584 return "CollectionVector";
585 }
586 default:
587 return "<error, no type specified>";
588 }
589}
590
592{
593 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
594 int a, mask = 0;
595
596 if (eprop->item) {
597 for (a = 0; a < eprop->totitem; a++) {
598 if (eprop->item[a].identifier[0]) {
599 mask |= eprop->item[a].value;
600 }
601 }
602 }
603
604 return mask;
605}
606
607static bool rna_parameter_is_const(const PropertyDefRNA *dparm)
608{
609 return (dparm->prop->arraydimension) && ((dparm->prop->flag_parameter & PARM_OUTPUT) == 0);
610}
611
613{
614 return ((prop->type == PROP_FLOAT) && ELEM(prop->subtype, PROP_COLOR, PROP_COLOR_GAMMA) &&
615 (IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0));
616}
617
623static const char *rna_enum_id_from_pointer(const EnumPropertyItem *item)
624{
625#define RNA_MAKESRNA
626#define DEF_ENUM(id) \
627 if (item == id) { \
628 return STRINGIFY(id); \
629 }
630#include "RNA_enum_items.hh"
631#undef RNA_MAKESRNA
632 return nullptr;
633}
634
635template<typename T> static const char *rna_function_string(T *func)
636{
637 return (func) ? (const char *)func : "nullptr";
638}
639
640static void rna_float_print(FILE *f, float num)
641{
642 if (num == -FLT_MAX) {
643 fprintf(f, "-FLT_MAX");
644 }
645 else if (num == FLT_MAX) {
646 fprintf(f, "FLT_MAX");
647 }
648 else if ((fabsf(num) < float(INT64_MAX)) && (int64_t(num) == num)) {
649 fprintf(f, "%.1ff", num);
650 }
651 else if (num == std::numeric_limits<float>::infinity()) {
652 fprintf(f, "std::numeric_limits<float>::infinity()");
653 }
654 else if (num == -std::numeric_limits<float>::infinity()) {
655 fprintf(f, "-std::numeric_limits<float>::infinity()");
656 }
657 else {
658 fprintf(f, "%.10ff", num);
659 }
660}
661
662static const char *rna_ui_scale_type_string(const PropertyScaleType type)
663{
664 switch (type) {
666 return "PROP_SCALE_LINEAR";
667 case PROP_SCALE_LOG:
668 return "PROP_SCALE_LOG";
669 case PROP_SCALE_CUBIC:
670 return "PROP_SCALE_CUBIC";
671 }
673 return "";
674}
675
676static void rna_int_print(FILE *f, int64_t num)
677{
678 if (num == INT_MIN) {
679 fprintf(f, "INT_MIN");
680 }
681 else if (num == INT_MAX) {
682 fprintf(f, "INT_MAX");
683 }
684 else if (num == INT64_MIN) {
685 fprintf(f, "INT64_MIN");
686 }
687 else if (num == INT64_MAX) {
688 fprintf(f, "INT64_MAX");
689 }
690 else if (num < INT_MIN || num > INT_MAX) {
691 fprintf(f, "%" PRId64 "LL", num);
692 }
693 else {
694 fprintf(f, "%d", int(num));
695 }
696}
697
699 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
700{
701 char *func;
702
703 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
704 return nullptr;
705 }
706
707 if (!manualfunc) {
708 if (!dp->dnastructname || !dp->dnaname) {
709 CLOG_ERROR(&LOG, "%s.%s has no valid dna info.", srna->identifier, prop->identifier);
710 DefRNA.error = true;
711 return nullptr;
712 }
713
714 /* Type check. */
715 if (dp->dnatype && *dp->dnatype) {
716
717 if (prop->type == PROP_FLOAT) {
718 if (IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0) {
719 /* Colors are an exception. these get translated. */
720 if (prop->subtype != PROP_COLOR_GAMMA) {
722 "%s.%s is a '%s' but wrapped as type '%s'.",
723 srna->identifier,
724 prop->identifier,
725 dp->dnatype,
727 DefRNA.error = true;
728 return nullptr;
729 }
730 }
731 }
732 else if (prop->type == PROP_BOOLEAN) {
733 if (IS_DNATYPE_BOOLEAN_COMPAT(dp->dnatype) == 0) {
735 "%s.%s is a '%s' but wrapped as type '%s'.",
736 srna->identifier,
737 prop->identifier,
738 dp->dnatype,
740 DefRNA.error = true;
741 return nullptr;
742 }
743 }
744 else if (ELEM(prop->type, PROP_INT, PROP_ENUM)) {
745 if (IS_DNATYPE_INT_COMPAT(dp->dnatype) == 0) {
747 "%s.%s is a '%s' but wrapped as type '%s'.",
748 srna->identifier,
749 prop->identifier,
750 dp->dnatype,
752 DefRNA.error = true;
753 return nullptr;
754 }
755 }
756 }
757
758 /* Check log scale sliders for negative range. */
759 if (prop->type == PROP_FLOAT) {
760 FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
761 /* NOTE: UI_BTYPE_NUM_SLIDER can't have a softmin of zero. */
762 if ((fprop->ui_scale_type == PROP_SCALE_LOG) && (fprop->hardmin < 0 || fprop->softmin < 0)) {
764 &LOG, "\"%s.%s\", range for log scale < 0.", srna->identifier, prop->identifier);
765 DefRNA.error = true;
766 return nullptr;
767 }
768 }
769 if (prop->type == PROP_INT) {
770 IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
771 /* Only UI_BTYPE_NUM_SLIDER is implemented and that one can't have a softmin of zero. */
772 if ((iprop->ui_scale_type == PROP_SCALE_LOG) && (iprop->hardmin <= 0 || iprop->softmin <= 0))
773 {
775 &LOG, "\"%s.%s\", range for log scale <= 0.", srna->identifier, prop->identifier);
776 DefRNA.error = true;
777 return nullptr;
778 }
779 }
780 }
781
782 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
783
784 switch (prop->type) {
785 case PROP_STRING: {
786 StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
787 UNUSED_VARS_NDEBUG(sprop);
788 fprintf(f, "extern void %s(PointerRNA *ptr, char *value)\n", func);
789 fprintf(f, "{\n");
790 if (manualfunc) {
791 fprintf(f, " PropStringGetFunc fn = %s;\n", manualfunc);
792 fprintf(f, " fn(ptr, value);\n");
793 }
794 else {
795 rna_print_data_get(f, dp);
796
797 if (dp->dnapointerlevel == 1) {
798 /* Handle allocated char pointer properties. */
799 fprintf(f, " if (data->%s == nullptr) {\n", dp->dnaname);
800 fprintf(f, " *value = '\\0';\n");
801 fprintf(f, " return;\n");
802 fprintf(f, " }\n");
803 fprintf(f, " strcpy(value, data->%s);\n", dp->dnaname);
804 }
805 else {
806 /* Handle char array properties. */
807
808#ifndef NDEBUG /* Assert lengths never exceed their maximum expected value. */
809 if (sprop->maxlength) {
810 fprintf(f, " BLI_assert(strlen(data->%s) < %d);\n", dp->dnaname, sprop->maxlength);
811 }
812 else {
813 fprintf(f,
814 " BLI_assert(strlen(data->%s) < sizeof(data->%s));\n",
815 dp->dnaname,
816 dp->dnaname);
817 }
818#endif
819
820 fprintf(f, " strcpy(value, data->%s);\n", dp->dnaname);
821 }
822 }
823 fprintf(f, "}\n\n");
824 break;
825 }
826 case PROP_POINTER: {
827 fprintf(f, "extern PointerRNA %s(PointerRNA *ptr)\n", func);
828 fprintf(f, "{\n");
829 if (manualfunc) {
830 fprintf(f, " PropPointerGetFunc fn = %s;\n", manualfunc);
831 fprintf(f, " return fn(ptr);\n");
832 }
833 else {
834 PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
835 rna_print_data_get(f, dp);
836 if (dp->dnapointerlevel == 0) {
837 fprintf(f,
838 " return RNA_pointer_create_with_parent(*ptr, &RNA_%s, &data->%s);\n",
839 (const char *)pprop->type,
840 dp->dnaname);
841 }
842 else {
843 fprintf(f,
844 " return RNA_pointer_create_with_parent(*ptr, &RNA_%s, data->%s);\n",
845 (const char *)pprop->type,
846 dp->dnaname);
847 }
848 }
849 fprintf(f, "}\n\n");
850 break;
851 }
852 case PROP_COLLECTION: {
854
855 fprintf(f, "static PointerRNA %s(CollectionPropertyIterator *iter)\n", func);
856 fprintf(f, "{\n");
857 if (manualfunc) {
858 if (STR_ELEM(manualfunc,
859 "rna_iterator_listbase_get",
860 "rna_iterator_array_get",
861 "rna_iterator_array_dereference_get"))
862 {
863 fprintf(f,
864 " return RNA_pointer_create_with_parent(iter->parent, &RNA_%s, %s(iter));\n",
865 (cprop->item_type) ? (const char *)cprop->item_type : "UnknownType",
866 manualfunc);
867 }
868 else {
869 fprintf(f, " PropCollectionGetFunc fn = %s;\n", manualfunc);
870 fprintf(f, " return fn(iter);\n");
871 }
872 }
873 fprintf(f, "}\n\n");
874 break;
875 }
876 default:
877 if (prop->arraydimension) {
878 if (prop->flag & PROP_DYNAMIC) {
879 fprintf(f, "extern void %s(PointerRNA *ptr, %s values[])\n", func, rna_type_type(prop));
880 }
881 else {
882 fprintf(f,
883 "extern void %s(PointerRNA *ptr, %s values[%u])\n",
884 func,
885 rna_type_type(prop),
886 prop->totarraylength);
887 }
888 fprintf(f, "{\n");
889
890 if (manualfunc) {
891 /* Assign `fn` to ensure function signatures match. */
892 if (prop->type == PROP_BOOLEAN) {
893 fprintf(f, " PropBooleanArrayGetFunc fn = %s;\n", manualfunc);
894 fprintf(f, " fn(ptr, values);\n");
895 }
896 else if (prop->type == PROP_INT) {
897 fprintf(f, " PropIntArrayGetFunc fn = %s;\n", manualfunc);
898 fprintf(f, " fn(ptr, values);\n");
899 }
900 else if (prop->type == PROP_FLOAT) {
901 fprintf(f, " PropFloatArrayGetFunc fn = %s;\n", manualfunc);
902 fprintf(f, " fn(ptr, values);\n");
903 }
904 else {
905 BLI_assert_unreachable(); /* Valid but should be handled by type checks. */
906 fprintf(f, " %s(ptr, values);\n", manualfunc);
907 }
908 }
909 else {
910 rna_print_data_get(f, dp);
911
912 if (prop->flag & PROP_DYNAMIC) {
913 char *lenfunc = rna_alloc_function_name(
914 srna->identifier, rna_safe_id(prop->identifier), "get_length");
915 fprintf(f, " unsigned int arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
916 fprintf(f, " unsigned int i;\n");
917 fprintf(f, " unsigned int len = %s(ptr, arraylen);\n\n", lenfunc);
918 fprintf(f, " for (i = 0; i < len; i++) {\n");
919 MEM_freeN(lenfunc);
920 }
921 else {
922 fprintf(f, " unsigned int i;\n\n");
923 fprintf(f, " for (i = 0; i < %u; i++) {\n", prop->totarraylength);
924 }
925
926 if (dp->dnaarraylength == 1) {
927 if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
928 fprintf(f,
929 " values[i] = %s((data->%s & (",
930 (dp->booleannegative) ? "!" : "",
931 dp->dnaname);
933 fprintf(f, " << i)) != 0);\n");
934 }
935 else {
936 fprintf(f,
937 " values[i] = (%s)%s((&data->%s)[i]);\n",
938 rna_type_type(prop),
939 (dp->booleannegative) ? "!" : "",
940 dp->dnaname);
941 }
942 }
943 else {
944 if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
945 fprintf(f,
946 " values[i] = %s((data->%s[i] & ",
947 (dp->booleannegative) ? "!" : "",
948 dp->dnaname);
950 fprintf(f, ") != 0);\n");
951 }
952 else if (rna_color_quantize(prop, dp)) {
953 fprintf(f,
954 " values[i] = (%s)(data->%s[i] * (1.0f / 255.0f));\n",
955 rna_type_type(prop),
956 dp->dnaname);
957 }
958 else if (dp->dnatype) {
959 fprintf(f,
960 " values[i] = (%s)%s(((%s *)data->%s)[i]);\n",
961 rna_type_type(prop),
962 (dp->booleannegative) ? "!" : "",
963 dp->dnatype,
964 dp->dnaname);
965 }
966 else {
967 fprintf(f,
968 " values[i] = (%s)%s((data->%s)[i]);\n",
969 rna_type_type(prop),
970 (dp->booleannegative) ? "!" : "",
971 dp->dnaname);
972 }
973 }
974 fprintf(f, " }\n");
975 }
976 fprintf(f, "}\n\n");
977 }
978 else {
979 fprintf(f, "extern %s %s(PointerRNA *ptr)\n", rna_type_type(prop), func);
980 fprintf(f, "{\n");
981
982 if (manualfunc) {
983 /* Assign `fn` to ensure function signatures match. */
984 if (prop->type == PROP_BOOLEAN) {
985 fprintf(f, " PropBooleanGetFunc fn = %s;\n", manualfunc);
986 fprintf(f, " return fn(ptr);\n");
987 }
988 else if (prop->type == PROP_INT) {
989 fprintf(f, " PropIntGetFunc fn = %s;\n", manualfunc);
990 fprintf(f, " return fn(ptr);\n");
991 }
992 else if (prop->type == PROP_FLOAT) {
993 fprintf(f, " PropFloatGetFunc fn = %s;\n", manualfunc);
994 fprintf(f, " return fn(ptr);\n");
995 }
996 else if (prop->type == PROP_ENUM) {
997 fprintf(f, " PropEnumGetFunc fn = %s;\n", manualfunc);
998 fprintf(f, " return fn(ptr);\n");
999 }
1000 else {
1001 BLI_assert_unreachable(); /* Valid but should be handled by type checks. */
1002 fprintf(f, " return %s(ptr);\n", manualfunc);
1003 }
1004 }
1005 else {
1006 rna_print_data_get(f, dp);
1007 if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
1008 fprintf(
1009 f, " return %s(((data->%s) & ", (dp->booleannegative) ? "!" : "", dp->dnaname);
1010 rna_int_print(f, dp->booleanbit);
1011 fprintf(f, ") != 0);\n");
1012 }
1013 else if (prop->type == PROP_ENUM && dp->enumbitflags) {
1014 fprintf(f, " return ((data->%s) & ", dp->dnaname);
1016 fprintf(f, ");\n");
1017 }
1018 else {
1019 fprintf(f,
1020 " return (%s)%s(data->%s);\n",
1021 rna_type_type(prop),
1022 (dp->booleannegative) ? "!" : "",
1023 dp->dnaname);
1024 }
1025 }
1026
1027 fprintf(f, "}\n\n");
1028 }
1029 break;
1030 }
1031
1032 return func;
1033}
1034
1035/* defined min/max variables to be used by rna_clamp_value() */
1036static void rna_clamp_value_range(FILE *f, PropertyRNA *prop)
1037{
1038 if (prop->type == PROP_FLOAT) {
1039 FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
1040 if (fprop->range) {
1041 fprintf(f,
1042 " float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, "
1043 "prop_soft_max;\n");
1044 fprintf(f,
1045 " %s(ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);\n",
1046 rna_function_string(fprop->range));
1047 }
1048 }
1049 else if (prop->type == PROP_INT) {
1050 IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
1051 if (iprop->range) {
1052 fprintf(f,
1053 " int prop_clamp_min = INT_MIN, prop_clamp_max = INT_MAX, prop_soft_min, "
1054 "prop_soft_max;\n");
1055 fprintf(f,
1056 " %s(ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);\n",
1057 rna_function_string(iprop->range));
1058 }
1059 }
1060}
1061
1062#ifdef USE_RNA_RANGE_CHECK
1063static void rna_clamp_value_range_check(FILE *f,
1064 PropertyRNA *prop,
1065 const char *dnaname_prefix,
1066 const char *dnaname)
1067{
1068 if (prop->type == PROP_INT) {
1069 IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
1070 fprintf(f, " {\n");
1071 fprintf(f, "#ifdef __cplusplus\n");
1072 fprintf(f, " using T = decltype(%s%s);\n", dnaname_prefix, dnaname);
1073 fprintf(f,
1074 " static_assert(std::numeric_limits<std::decay_t<T>>::max() >= %d);\n",
1075 iprop->hardmax);
1076 fprintf(f,
1077 " static_assert(std::numeric_limits<std::decay_t<T>>::min() <= %d);\n",
1078 iprop->hardmin);
1079 fprintf(f, "#else\n");
1080 fprintf(f,
1081 " BLI_STATIC_ASSERT("
1082 "(TYPEOF_MAX(%s%s) >= %d) && "
1083 "(TYPEOF_MIN(%s%s) <= %d), "
1084 "\"invalid limits\");\n",
1085 dnaname_prefix,
1086 dnaname,
1087 iprop->hardmax,
1088 dnaname_prefix,
1089 dnaname,
1090 iprop->hardmin);
1091 fprintf(f, "#endif\n");
1092 fprintf(f, " }\n");
1093 }
1094}
1095#endif /* USE_RNA_RANGE_CHECK */
1096
1097static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array)
1098{
1099 if (prop->type == PROP_INT) {
1100 IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
1101
1102 if (iprop->hardmin != INT_MIN || iprop->hardmax != INT_MAX || iprop->range) {
1103 if (array) {
1104 fprintf(f, "std::clamp(values[i], ");
1105 }
1106 else {
1107 fprintf(f, "std::clamp(value, ");
1108 }
1109 if (iprop->range) {
1110 fprintf(f, "prop_clamp_min, prop_clamp_max);\n");
1111 }
1112 else {
1113 rna_int_print(f, iprop->hardmin);
1114 fprintf(f, ", ");
1115 rna_int_print(f, iprop->hardmax);
1116 fprintf(f, ");\n");
1117 }
1118 return;
1119 }
1120 }
1121 else if (prop->type == PROP_FLOAT) {
1122 FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
1123
1124 if (fprop->hardmin != -FLT_MAX || fprop->hardmax != FLT_MAX || fprop->range) {
1125 if (array) {
1126 fprintf(f, "std::clamp(values[i], ");
1127 }
1128 else {
1129 fprintf(f, "std::clamp(value, ");
1130 }
1131 if (fprop->range) {
1132 fprintf(f, "prop_clamp_min, prop_clamp_max);\n");
1133 }
1134 else {
1135 rna_float_print(f, fprop->hardmin);
1136 fprintf(f, ", ");
1137 rna_float_print(f, fprop->hardmax);
1138 fprintf(f, ");\n");
1139 }
1140 return;
1141 }
1142 }
1143
1144 if (array) {
1145 fprintf(f, "values[i];\n");
1146 }
1147 else {
1148 fprintf(f, "value;\n");
1149 }
1150}
1151
1153 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA * /*dp*/, const char *manualfunc)
1154{
1155 char *func;
1156
1157 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1158 return nullptr;
1159 }
1160 if (!manualfunc) {
1161 return nullptr;
1162 }
1163
1164 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "search");
1165
1166 fprintf(f,
1167 "extern void %s("
1168 "const bContext *C, "
1169 "PointerRNA *ptr, "
1170 "PropertyRNA *prop, "
1171 "const char *edit_text, "
1172 "blender::FunctionRef<void(StringPropertySearchVisitParams)> visit_fn)\n",
1173 func);
1174 fprintf(f, "{\n");
1175 fprintf(f, "\n StringPropertySearchFunc fn = %s;\n", manualfunc);
1176 fprintf(f, "\n fn(C, ptr, prop, edit_text, visit_fn);\n");
1177 fprintf(f, "}\n\n");
1178 return func;
1179}
1180
1182 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
1183{
1184 char *func;
1185
1186 if (!(prop->flag & PROP_EDITABLE)) {
1187 return nullptr;
1188 }
1189 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1190 return nullptr;
1191 }
1192
1193 if (!manualfunc) {
1194 if (!dp->dnastructname || !dp->dnaname) {
1195 if (prop->flag & PROP_EDITABLE) {
1196 CLOG_ERROR(&LOG, "%s.%s has no valid dna info.", srna->identifier, prop->identifier);
1197 DefRNA.error = true;
1198 }
1199 return nullptr;
1200 }
1201 }
1202
1203 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "set");
1204
1205 switch (prop->type) {
1206 case PROP_STRING: {
1207 StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
1208 fprintf(f, "extern void %s(PointerRNA *ptr, const char *value)\n", func);
1209 fprintf(f, "{\n");
1210 if (manualfunc) {
1211 fprintf(f, " PropStringSetFunc fn = %s;\n", manualfunc);
1212 fprintf(f, " fn(ptr, value);\n");
1213 }
1214 else {
1215 const PropertySubType subtype = prop->subtype;
1216 rna_print_data_get(f, dp);
1217
1218 if (dp->dnapointerlevel == 1) {
1219 /* Handle allocated char pointer properties. */
1220 fprintf(f,
1221 " if (data->%s != nullptr) { MEM_freeN(data->%s); }\n",
1222 dp->dnaname,
1223 dp->dnaname);
1224 fprintf(f, " const size_t length = strlen(value);\n");
1225 fprintf(f, " if (length > 0) {\n");
1226 fprintf(f,
1227 " data->%s = MEM_malloc_arrayN<char>(length + 1, __func__);\n",
1228 dp->dnaname);
1229 fprintf(f, " memcpy(data->%s, value, length + 1);\n", dp->dnaname);
1230 fprintf(f, " } else { data->%s = nullptr; }\n", dp->dnaname);
1231 }
1232 else {
1233 const char *string_copy_func =
1235 "BLI_strncpy" :
1236 "BLI_strncpy_utf8";
1237 /* Handle char array properties. */
1238 if (sprop->maxlength) {
1239 fprintf(f,
1240 " %s(data->%s, value, %d);\n",
1241 string_copy_func,
1242 dp->dnaname,
1243 sprop->maxlength);
1244 }
1245 else {
1246 fprintf(f,
1247 " %s(data->%s, value, sizeof(data->%s));\n",
1248 string_copy_func,
1249 dp->dnaname,
1250 dp->dnaname);
1251 }
1252 }
1253 }
1254 fprintf(f, "}\n\n");
1255 break;
1256 }
1257 case PROP_POINTER: {
1258 fprintf(f,
1259 "extern void %s(PointerRNA *ptr, PointerRNA value, struct ReportList *reports)\n",
1260 func);
1261 fprintf(f, "{\n");
1262 if (manualfunc) {
1263 fprintf(f, " PropPointerSetFunc fn = %s;\n", manualfunc);
1264 fprintf(f, " fn(ptr, value, reports);\n");
1265 }
1266 else {
1267 rna_print_data_get(f, dp);
1268
1270 StructRNA *type = (pprop->type) ? rna_find_struct((const char *)pprop->type) : nullptr;
1271
1272 if (prop->flag & PROP_ID_SELF_CHECK) {
1273 /* No pointers to self allowed. */
1274 rna_print_id_get(f, dp);
1275 fprintf(f, " if (id == value.data) {\n");
1276 fprintf(f, " return;\n");
1277 fprintf(f, " }\n");
1278 }
1279
1280 if (type && (type->flag & STRUCT_ID)) {
1281 /* Check if pointers between datablocks are allowed. */
1282 fprintf(f,
1283 " if (value.data && ptr->owner_id && value.owner_id && "
1284 "!BKE_id_can_use_id(*ptr->owner_id, *value.owner_id)) {\n");
1285 fprintf(f, " return;\n");
1286 fprintf(f, " }\n");
1287 }
1288
1289 if (prop->flag & PROP_ID_REFCOUNT) {
1290 /* Perform reference counting. */
1291 fprintf(f, "\n if (data->%s) {\n", dp->dnaname);
1292 fprintf(f, " id_us_min((ID *)data->%s);\n", dp->dnaname);
1293 fprintf(f, " }\n");
1294 fprintf(f, " if (value.data) {\n");
1295 fprintf(f, " id_us_plus((ID *)value.data);\n");
1296 fprintf(f, " }\n");
1297 }
1298 else if (type && (type->flag & STRUCT_ID)) {
1299 /* Still mark linked data as used if not reference counting. */
1300 fprintf(f, " if (value.data) {\n");
1301 fprintf(f, " id_lib_extern((ID *)value.data);\n");
1302 fprintf(f, " }\n");
1303 }
1304
1305 fprintf(f, " *(void **)&data->%s = value.data;\n", dp->dnaname);
1306 }
1307 fprintf(f, "}\n\n");
1308 break;
1309 }
1310 default:
1311 if (prop->arraydimension) {
1312 if (prop->flag & PROP_DYNAMIC) {
1313 fprintf(f,
1314 "extern void %s(PointerRNA *ptr, const %s values[])\n",
1315 func,
1316 rna_type_type(prop));
1317 }
1318 else {
1319 fprintf(f,
1320 "extern void %s(PointerRNA *ptr, const %s values[%u])\n",
1321 func,
1322 rna_type_type(prop),
1323 prop->totarraylength);
1324 }
1325 fprintf(f, "{\n");
1326
1327 if (manualfunc) {
1328 /* Assign `fn` to ensure function signatures match. */
1329 if (prop->type == PROP_BOOLEAN) {
1330 fprintf(f, " PropBooleanArraySetFunc fn = %s;\n", manualfunc);
1331 fprintf(f, " fn(ptr, values);\n");
1332 }
1333 else if (prop->type == PROP_INT) {
1334 fprintf(f, " PropIntArraySetFunc fn = %s;\n", manualfunc);
1335 fprintf(f, " fn(ptr, values);\n");
1336 }
1337 else if (prop->type == PROP_FLOAT) {
1338 fprintf(f, " PropFloatArraySetFunc fn = %s;\n", manualfunc);
1339 fprintf(f, " fn(ptr, values);\n");
1340 }
1341 else {
1342 BLI_assert_unreachable(); /* Valid but should be handled by type checks. */
1343 fprintf(f, " %s(ptr, values);\n", manualfunc);
1344 }
1345 }
1346 else {
1347 rna_print_data_get(f, dp);
1348
1349 if (prop->flag & PROP_DYNAMIC) {
1350 char *lenfunc = rna_alloc_function_name(
1351 srna->identifier, rna_safe_id(prop->identifier), "set_length");
1352 fprintf(f, " unsigned int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
1353 fprintf(f, " unsigned int len = %s(ptr, arraylen);\n\n", lenfunc);
1354 rna_clamp_value_range(f, prop);
1355 fprintf(f, " for (i = 0; i < len; i++) {\n");
1356 MEM_freeN(lenfunc);
1357 }
1358 else {
1359 fprintf(f, " unsigned int i;\n\n");
1360 rna_clamp_value_range(f, prop);
1361 fprintf(f, " for (i = 0; i < %u; i++) {\n", prop->totarraylength);
1362 }
1363
1364 if (dp->dnaarraylength == 1) {
1365 if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
1366 fprintf(f,
1367 " if (%svalues[i]) { data->%s |= (",
1368 (dp->booleannegative) ? "!" : "",
1369 dp->dnaname);
1370 rna_int_print(f, dp->booleanbit);
1371 fprintf(f, " << i); }\n");
1372 fprintf(f, " else { data->%s &= ~(", dp->dnaname);
1373 rna_int_print(f, dp->booleanbit);
1374 fprintf(f, " << i); }\n");
1375 }
1376 else {
1377 fprintf(
1378 f, " (&data->%s)[i] = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
1379 rna_clamp_value(f, prop, 1);
1380 }
1381 }
1382 else {
1383 if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
1384 fprintf(f,
1385 " if (%svalues[i]) { data->%s[i] |= ",
1386 (dp->booleannegative) ? "!" : "",
1387 dp->dnaname);
1388 rna_int_print(f, dp->booleanbit);
1389 fprintf(f, "; }\n");
1390 fprintf(f, " else { data->%s[i] &= ~", dp->dnaname);
1391 rna_int_print(f, dp->booleanbit);
1392 fprintf(f, "; }\n");
1393 }
1394 else if (rna_color_quantize(prop, dp)) {
1395 fprintf(
1396 f, " data->%s[i] = unit_float_to_uchar_clamp(values[i]);\n", dp->dnaname);
1397 }
1398 else {
1399 if (dp->dnatype) {
1400 fprintf(f,
1401 " ((%s *)data->%s)[i] = %s",
1402 dp->dnatype,
1403 dp->dnaname,
1404 (dp->booleannegative) ? "!" : "");
1405 }
1406 else {
1407 fprintf(f,
1408 " (data->%s)[i] = %s",
1409 dp->dnaname,
1410 (dp->booleannegative) ? "!" : "");
1411 }
1412 rna_clamp_value(f, prop, 1);
1413 }
1414 }
1415 fprintf(f, " }\n");
1416 }
1417
1418#ifdef USE_RNA_RANGE_CHECK
1419 if (dp->dnaname && manualfunc == nullptr) {
1420 if (dp->dnaarraylength == 1) {
1421 rna_clamp_value_range_check(f, prop, "data->", dp->dnaname);
1422 }
1423 else {
1424 rna_clamp_value_range_check(f, prop, "*data->", dp->dnaname);
1425 }
1426 }
1427#endif
1428
1429 fprintf(f, "}\n\n");
1430 }
1431 else {
1432 fprintf(f, "extern void %s(PointerRNA *ptr, %s value)\n", func, rna_type_type(prop));
1433 fprintf(f, "{\n");
1434
1435 if (manualfunc) {
1436 /* Assign `fn` to ensure function signatures match. */
1437 if (prop->type == PROP_BOOLEAN) {
1438 fprintf(f, " PropBooleanSetFunc fn = %s;\n", manualfunc);
1439 fprintf(f, " fn(ptr, value);\n");
1440 }
1441 else if (prop->type == PROP_INT) {
1442 fprintf(f, " PropIntSetFunc fn = %s;\n", manualfunc);
1443 fprintf(f, " fn(ptr, value);\n");
1444 }
1445 else if (prop->type == PROP_FLOAT) {
1446 fprintf(f, " PropFloatSetFunc fn = %s;\n", manualfunc);
1447 fprintf(f, " fn(ptr, value);\n");
1448 }
1449 else if (prop->type == PROP_ENUM) {
1450 fprintf(f, " PropEnumSetFunc fn = %s;\n", manualfunc);
1451 fprintf(f, " fn(ptr, value);\n");
1452 }
1453 else {
1454 BLI_assert_unreachable(); /* Valid but should be handled by type checks. */
1455 fprintf(f, " %s(ptr, value);\n", manualfunc);
1456 }
1457 }
1458 else {
1459 rna_print_data_get(f, dp);
1460 if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
1461 fprintf(f,
1462 " if (%svalue) { data->%s |= ",
1463 (dp->booleannegative) ? "!" : "",
1464 dp->dnaname);
1465 rna_int_print(f, dp->booleanbit);
1466 fprintf(f, "; }\n");
1467 fprintf(f, " else { data->%s &= ~", dp->dnaname);
1468 rna_int_print(f, dp->booleanbit);
1469 fprintf(f, "; }\n");
1470 }
1471 else if (prop->type == PROP_ENUM && dp->enumbitflags) {
1472 fprintf(f, " data->%s &= ~", dp->dnaname);
1474 fprintf(f, ";\n");
1475 fprintf(f, " data->%s |= value;\n", dp->dnaname);
1476 }
1477 else {
1478 rna_clamp_value_range(f, prop);
1479 /* C++ may require casting to an enum type. */
1480 fprintf(f, "#ifdef __cplusplus\n");
1481 fprintf(f,
1482 /* If #rna_clamp_value() adds an expression like `std::clamp(...)`
1483 * (instead of an `lvalue`), #decltype() yields a reference,
1484 * so that has to be removed. */
1485 " data->%s = %s(std::remove_reference_t<decltype(data->%s)>)",
1486 dp->dnaname,
1487 (dp->booleannegative) ? "!" : "",
1488 dp->dnaname);
1489 rna_clamp_value(f, prop, 0);
1490 fprintf(f, "#else\n");
1491 fprintf(f, " data->%s = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
1492 rna_clamp_value(f, prop, 0);
1493 fprintf(f, "#endif\n");
1494 }
1495 }
1496
1497#ifdef USE_RNA_RANGE_CHECK
1498 if (dp->dnaname && manualfunc == nullptr) {
1499 rna_clamp_value_range_check(f, prop, "data->", dp->dnaname);
1500 }
1501#endif
1502
1503 fprintf(f, "}\n\n");
1504 }
1505 break;
1506 }
1507
1508 return func;
1509}
1510
1512 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
1513{
1514 char *func = nullptr;
1515
1516 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1517 return nullptr;
1518 }
1519
1520 if (prop->type == PROP_STRING) {
1521 if (!manualfunc) {
1522 if (!dp->dnastructname || !dp->dnaname) {
1523 CLOG_ERROR(&LOG, "%s.%s has no valid dna info.", srna->identifier, prop->identifier);
1524 DefRNA.error = true;
1525 return nullptr;
1526 }
1527 }
1528
1529 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "length");
1530
1531 fprintf(f, "extern int %s(PointerRNA *ptr)\n", func);
1532 fprintf(f, "{\n");
1533 if (manualfunc) {
1534 fprintf(f, " PropStringLengthFunc fn = %s;\n", manualfunc);
1535 fprintf(f, " return fn(ptr);\n");
1536 }
1537 else {
1538 rna_print_data_get(f, dp);
1539 if (dp->dnapointerlevel == 1) {
1540 /* Handle allocated char pointer properties. */
1541 fprintf(f,
1542 " return (data->%s == nullptr) ? 0 : strlen(data->%s);\n",
1543 dp->dnaname,
1544 dp->dnaname);
1545 }
1546 else {
1547 /* Handle char array properties. */
1548 fprintf(f, " return strlen(data->%s);\n", dp->dnaname);
1549 }
1550 }
1551 fprintf(f, "}\n\n");
1552 }
1553 else if (prop->type == PROP_COLLECTION) {
1554 if (!manualfunc) {
1555 if (prop->type == PROP_COLLECTION &&
1556 (!(dp->dnalengthname || dp->dnalengthfixed) || !dp->dnaname))
1557 {
1558 CLOG_ERROR(&LOG, "%s.%s has no valid dna info.", srna->identifier, prop->identifier);
1559 DefRNA.error = true;
1560 return nullptr;
1561 }
1562 }
1563
1564 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "length");
1565
1566 fprintf(f, "extern int %s(PointerRNA *ptr)\n", func);
1567 fprintf(f, "{\n");
1568 if (manualfunc) {
1569 fprintf(f, " PropCollectionLengthFunc fn = %s;\n", manualfunc);
1570 fprintf(f, " return fn(ptr);\n");
1571 }
1572 else {
1573 if (dp->dnaarraylength <= 1 || dp->dnalengthname) {
1574 rna_print_data_get(f, dp);
1575 }
1576
1577 if (dp->dnaarraylength > 1) {
1578 fprintf(f, " return ");
1579 }
1580 else {
1581 fprintf(f, " return (data->%s == nullptr) ? 0 : ", dp->dnaname);
1582 }
1583
1584 if (dp->dnalengthname) {
1585 fprintf(f, "data->%s;\n", dp->dnalengthname);
1586 }
1587 else {
1588 fprintf(f, "%d;\n", dp->dnalengthfixed);
1589 }
1590 }
1591 fprintf(f, "}\n\n");
1592 }
1593
1594 return func;
1595}
1596
1598 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
1599{
1600 char *func, *getfunc;
1601
1602 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1603 return nullptr;
1604 }
1605
1606 if (!manualfunc) {
1607 if (!dp->dnastructname || !dp->dnaname) {
1608 CLOG_ERROR(&LOG, "%s.%s has no valid dna info.", srna->identifier, prop->identifier);
1609 DefRNA.error = true;
1610 return nullptr;
1611 }
1612 }
1613
1614 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "begin");
1615
1616 fprintf(f, "extern void %s(CollectionPropertyIterator *iter, PointerRNA *ptr)\n", func);
1617 fprintf(f, "{\n");
1618
1619 if (!manualfunc) {
1620 rna_print_data_get(f, dp);
1621 }
1622
1623 fprintf(f, "\n *iter = {};\n");
1624 fprintf(f, " iter->parent = *ptr;\n");
1625 fprintf(f, " iter->prop = &rna_%s_%s;\n", srna->identifier, prop->identifier);
1626
1627 if (dp->dnalengthname || dp->dnalengthfixed) {
1628 if (manualfunc) {
1629 fprintf(f, "\n PropCollectionBeginFunc fn = %s;\n", manualfunc);
1630 fprintf(f, " fn(iter, ptr);\n");
1631 }
1632 else {
1633 if (dp->dnalengthname) {
1634 fprintf(f,
1635 "\n rna_iterator_array_begin(iter, ptr, data->%s, sizeof(data->%s[0]), "
1636 "data->%s, 0, nullptr);\n",
1637 dp->dnaname,
1638 dp->dnaname,
1639 dp->dnalengthname);
1640 }
1641 else {
1642 fprintf(f,
1643 "\n rna_iterator_array_begin(iter, ptr, data->%s, sizeof(data->%s[0]), %d, 0, "
1644 "nullptr);\n",
1645 dp->dnaname,
1646 dp->dnaname,
1647 dp->dnalengthfixed);
1648 }
1649 }
1650 }
1651 else {
1652 if (manualfunc) {
1653 fprintf(f, "\n PropCollectionBeginFunc fn = %s;\n", manualfunc);
1654 fprintf(f, " fn(iter, ptr);\n");
1655 }
1656 else if (dp->dnapointerlevel == 0) {
1657 fprintf(
1658 f, "\n rna_iterator_listbase_begin(iter, ptr, &data->%s, nullptr);\n", dp->dnaname);
1659 }
1660 else {
1661 fprintf(
1662 f, "\n rna_iterator_listbase_begin(iter, ptr, data->%s, nullptr);\n", dp->dnaname);
1663 }
1664 }
1665
1666 getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
1667
1668 fprintf(f, "\n if (iter->valid) {\n");
1669 fprintf(f, " iter->ptr = %s(iter);", getfunc);
1670 fprintf(f, "\n }\n");
1671
1672 fprintf(f, "}\n\n");
1673
1674 return func;
1675}
1676
1678 StructRNA *srna,
1679 PropertyRNA *prop,
1680 PropertyDefRNA *dp,
1681 const char *manualfunc,
1682 const char *nextfunc)
1683{
1684 /* note on indices, this is for external functions and ignores skipped values.
1685 * so the index can only be checked against the length when there is no 'skip' function. */
1686 char *func;
1687
1688 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1689 return nullptr;
1690 }
1691
1692 if (!manualfunc) {
1693 if (!dp->dnastructname || !dp->dnaname) {
1694 return nullptr;
1695 }
1696
1697 /* only supported in case of standard next functions */
1698 if (STREQ(nextfunc, "rna_iterator_array_next")) {
1699 }
1700 else if (STREQ(nextfunc, "rna_iterator_listbase_next")) {
1701 }
1702 else {
1703 return nullptr;
1704 }
1705 }
1706
1707 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "lookup_int");
1708
1709 fprintf(f, "extern bool %s(PointerRNA *ptr, int index, PointerRNA *r_ptr)\n", func);
1710 fprintf(f, "{\n");
1711
1712 if (manualfunc) {
1713 fprintf(f, "\n PropCollectionLookupIntFunc fn = %s;\n", manualfunc);
1714 fprintf(f, " return fn(ptr, index, r_ptr);\n");
1715 fprintf(f, "}\n\n");
1716 return func;
1717 }
1718
1719 fprintf(f, " bool found = false;\n");
1720 fprintf(f, " CollectionPropertyIterator iter;\n\n");
1721
1722 fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier));
1723 fprintf(f, " if (iter.valid) {\n");
1724
1725 if (STREQ(nextfunc, "rna_iterator_array_next")) {
1726 fprintf(f, " ArrayIterator *internal = &iter.internal.array;\n");
1727 fprintf(f, " if (index < 0 || index >= internal->length) {\n");
1728 fprintf(f, "#ifdef __GNUC__\n");
1729 fprintf(f,
1730 " printf(\"Array iterator out of range: %%s (index %%d)\\n\", __func__, "
1731 "index);\n");
1732 fprintf(f, "#else\n");
1733 fprintf(f, " printf(\"Array iterator out of range: (index %%d)\\n\", index);\n");
1734 fprintf(f, "#endif\n");
1735 fprintf(f, " }\n");
1736 fprintf(f, " else if (internal->skip) {\n");
1737 fprintf(f, " while (index-- > 0 && iter.valid) {\n");
1738 fprintf(f, " rna_iterator_array_next(&iter);\n");
1739 fprintf(f, " }\n");
1740 fprintf(f, " found = (index == -1 && iter.valid);\n");
1741 fprintf(f, " }\n");
1742 fprintf(f, " else {\n");
1743 fprintf(f, " internal->ptr += internal->itemsize * index;\n");
1744 fprintf(f, " found = 1;\n");
1745 fprintf(f, " }\n");
1746 }
1747 else if (STREQ(nextfunc, "rna_iterator_listbase_next")) {
1748 fprintf(f, " ListBaseIterator *internal = &iter.internal.listbase;\n");
1749 fprintf(f, " if (internal->skip) {\n");
1750 fprintf(f, " while (index-- > 0 && iter.valid) {\n");
1751 fprintf(f, " rna_iterator_listbase_next(&iter);\n");
1752 fprintf(f, " }\n");
1753 fprintf(f, " found = (index == -1 && iter.valid);\n");
1754 fprintf(f, " }\n");
1755 fprintf(f, " else {\n");
1756 fprintf(f, " while (index-- > 0 && internal->link) {\n");
1757 fprintf(f, " internal->link = internal->link->next;\n");
1758 fprintf(f, " }\n");
1759 fprintf(f, " found = (index == -1 && internal->link);\n");
1760 fprintf(f, " }\n");
1761 }
1762
1763 fprintf(f,
1764 " if (found) { *r_ptr = %s_%s_get(&iter); }\n",
1765 srna->identifier,
1766 rna_safe_id(prop->identifier));
1767 fprintf(f, " }\n\n");
1768 fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, rna_safe_id(prop->identifier));
1769
1770 fprintf(f, " return found;\n");
1771
1772#if 0
1773 rna_print_data_get(f, dp);
1774 item_type = (cprop->item_type) ? (const char *)cprop->item_type : "UnknownType";
1775
1776 if (dp->dnalengthname || dp->dnalengthfixed) {
1777 if (dp->dnalengthname) {
1778 fprintf(f,
1779 "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), data->%s, "
1780 "index);\n",
1781 item_type,
1782 dp->dnaname,
1783 dp->dnaname,
1784 dp->dnalengthname);
1785 }
1786 else {
1787 fprintf(
1788 f,
1789 "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), %d, index);\n",
1790 item_type,
1791 dp->dnaname,
1792 dp->dnaname,
1793 dp->dnalengthfixed);
1794 }
1795 }
1796 else {
1797 if (dp->dnapointerlevel == 0) {
1798 fprintf(f,
1799 "\n return rna_listbase_lookup_int(ptr, &RNA_%s, &data->%s, index);\n",
1800 item_type,
1801 dp->dnaname);
1802 }
1803 else {
1804 fprintf(f,
1805 "\n return rna_listbase_lookup_int(ptr, &RNA_%s, data->%s, index);\n",
1806 item_type,
1807 dp->dnaname);
1808 }
1809 }
1810#endif
1811
1812 fprintf(f, "}\n\n");
1813
1814 return func;
1815}
1816
1818 StructRNA *srna,
1819 PropertyRNA *prop,
1820 PropertyDefRNA *dp,
1821 const char *manualfunc,
1822 const char *item_type)
1823{
1824 char *func;
1825 StructRNA *item_srna, *item_name_base;
1826 PropertyRNA *item_name_prop;
1827 const int namebuflen = 1024;
1828
1829 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1830 return nullptr;
1831 }
1832
1833 if (!manualfunc) {
1834 if (!dp->dnastructname || !dp->dnaname) {
1835 return nullptr;
1836 }
1837
1838 /* only supported for collection items with name properties */
1839 item_srna = rna_find_struct(item_type);
1840 if (item_srna && item_srna->nameproperty) {
1841 item_name_prop = item_srna->nameproperty;
1842 item_name_base = item_srna;
1843 while (item_name_base->base && item_name_base->base->nameproperty == item_name_prop) {
1844 item_name_base = item_name_base->base;
1845 }
1846 }
1847 else {
1848 return nullptr;
1849 }
1850 }
1851
1852 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "lookup_string");
1853
1854 if (!manualfunc) {
1855 /* XXX extern declaration could be avoid by including RNA_blender.hh, but this has lots of
1856 * unknown DNA types in functions, leading to conflicting function signatures.
1857 */
1858 fprintf(f,
1859 "extern int %s_%s_length(PointerRNA *);\n",
1860 item_name_base->identifier,
1861 rna_safe_id(item_name_prop->identifier));
1862 fprintf(f,
1863 "extern void %s_%s_get(PointerRNA *, char *);\n\n",
1864 item_name_base->identifier,
1865 rna_safe_id(item_name_prop->identifier));
1866 }
1867
1868 fprintf(f, "extern bool %s(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)\n", func);
1869 fprintf(f, "{\n");
1870
1871 if (manualfunc) {
1872 fprintf(f, " PropCollectionLookupStringFunc fn = %s;\n", manualfunc);
1873 fprintf(f, " return fn(ptr, key, r_ptr);\n");
1874 fprintf(f, "}\n\n");
1875 return func;
1876 }
1877
1878 fprintf(f, " bool found = false;\n");
1879 fprintf(f, " CollectionPropertyIterator iter;\n");
1880 fprintf(f, " char namebuf[%d];\n", namebuflen);
1881 fprintf(f, " char *name;\n\n");
1882
1883 fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier));
1884
1885 fprintf(f, " while (iter.valid) {\n");
1886 fprintf(f, " if (iter.ptr.data) {\n");
1887 fprintf(f,
1888 " int namelen = %s_%s_length(&iter.ptr);\n",
1889 item_name_base->identifier,
1890 rna_safe_id(item_name_prop->identifier));
1891 fprintf(f, " if (namelen < %d) {\n", namebuflen);
1892 fprintf(f,
1893 " %s_%s_get(&iter.ptr, namebuf);\n",
1894 item_name_base->identifier,
1895 rna_safe_id(item_name_prop->identifier));
1896 fprintf(f, " if (strcmp(namebuf, key) == 0) {\n");
1897 fprintf(f, " found = true;\n");
1898 fprintf(f, " *r_ptr = iter.ptr;\n");
1899 fprintf(f, " break;\n");
1900 fprintf(f, " }\n");
1901 fprintf(f, " }\n");
1902 fprintf(f, " else {\n");
1903 fprintf(f, " name = MEM_malloc_arrayN<char>(size_t(namelen) + 1,\n");
1904 fprintf(f, " \"name string\");\n");
1905 fprintf(f,
1906 " %s_%s_get(&iter.ptr, name);\n",
1907 item_name_base->identifier,
1908 rna_safe_id(item_name_prop->identifier));
1909 fprintf(f, " if (strcmp(name, key) == 0) {\n");
1910 fprintf(f, " MEM_freeN(name);\n\n");
1911 fprintf(f, " found = true;\n");
1912 fprintf(f, " *r_ptr = iter.ptr;\n");
1913 fprintf(f, " break;\n");
1914 fprintf(f, " }\n");
1915 fprintf(f, " else {\n");
1916 fprintf(f, " MEM_freeN(name);\n");
1917 fprintf(f, " }\n");
1918 fprintf(f, " }\n");
1919 fprintf(f, " }\n");
1920 fprintf(f, " %s_%s_next(&iter);\n", srna->identifier, rna_safe_id(prop->identifier));
1921 fprintf(f, " }\n");
1922 fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, rna_safe_id(prop->identifier));
1923
1924 fprintf(f, " return found;\n");
1925 fprintf(f, "}\n\n");
1926
1927 return func;
1928}
1929
1931 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA * /*dp*/, const char *manualfunc)
1932{
1933 char *func, *getfunc;
1934
1935 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1936 return nullptr;
1937 }
1938
1939 if (!manualfunc) {
1940 return nullptr;
1941 }
1942
1943 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "next");
1944
1945 fprintf(f, "extern void %s(CollectionPropertyIterator *iter)\n", func);
1946 fprintf(f, "{\n");
1947 fprintf(f, " PropCollectionNextFunc fn = %s;\n", manualfunc);
1948 fprintf(f, " fn(iter);\n");
1949
1950 getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
1951
1952 fprintf(f, "\n if (iter->valid) {\n");
1953 fprintf(f, " iter->ptr = %s(iter);", getfunc);
1954 fprintf(f, "\n }\n");
1955
1956 fprintf(f, "}\n\n");
1957
1958 return func;
1959}
1960
1962 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA * /*dp*/, const char *manualfunc)
1963{
1964 char *func;
1965
1966 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1967 return nullptr;
1968 }
1969
1970 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "end");
1971
1972 fprintf(f, "extern void %s(CollectionPropertyIterator *iter)\n", func);
1973 fprintf(f, "{\n");
1974 if (manualfunc) {
1975 fprintf(f, " PropCollectionEndFunc fn = %s;\n", manualfunc);
1976 fprintf(f, " fn(iter);\n");
1977 }
1978 fprintf(f, "}\n\n");
1979
1980 return func;
1981}
1982
1984{
1985 if (dp->dnapointerlevel != 0) {
1986 return;
1987 }
1988 if (!dp->dnatype || !dp->dnaname || !dp->dnastructname) {
1989 return;
1990 }
1991
1992 if (STREQ(dp->dnatype, "char")) {
1995 }
1996 else if (STREQ(dp->dnatype, "int8_t")) {
1999 }
2000 else if (STREQ(dp->dnatype, "uchar")) {
2003 }
2004 else if (STREQ(dp->dnatype, "short")) {
2005 prop->rawtype = PROP_RAW_SHORT;
2007 }
2008 else if (STREQ(dp->dnatype, "ushort")) {
2009 prop->rawtype = PROP_RAW_UINT16;
2011 }
2012 else if (STREQ(dp->dnatype, "int")) {
2013 prop->rawtype = PROP_RAW_INT;
2015 }
2016 else if (STREQ(dp->dnatype, "float")) {
2017 prop->rawtype = PROP_RAW_FLOAT;
2019 }
2020 else if (STREQ(dp->dnatype, "double")) {
2021 prop->rawtype = PROP_RAW_DOUBLE;
2023 }
2024 else if (STREQ(dp->dnatype, "int64_t")) {
2025 prop->rawtype = PROP_RAW_INT64;
2027 }
2028 else if (STREQ(dp->dnatype, "uint64_t")) {
2029 prop->rawtype = PROP_RAW_UINT64;
2031 }
2032}
2033
2034static void rna_set_raw_offset(FILE *f, StructRNA *srna, PropertyRNA *prop)
2035{
2037
2038 fprintf(
2039 f, "\toffsetof(%s, %s), RawPropertyType(%d)", dp->dnastructname, dp->dnaname, prop->rawtype);
2040}
2041
2042static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
2043{
2044 PropertyRNA *prop;
2045
2046 prop = dp->prop;
2047
2048 switch (prop->type) {
2049 case PROP_BOOLEAN: {
2050 BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
2051
2052 if (!(prop->flag & PROP_EDITABLE) &&
2053 (bprop->set || bprop->set_ex || bprop->setarray || bprop->setarray_ex))
2054 {
2055 CLOG_ERROR(&LOG,
2056 "%s.%s, is read-only but has defines a \"set\" callback.",
2057 srna->identifier,
2058 prop->identifier);
2059 DefRNA.error = true;
2060 }
2061
2062 if (!prop->arraydimension &&
2063 (bprop->getarray || bprop->getarray_ex || bprop->setarray || bprop->setarray_ex))
2064 {
2065 CLOG_ERROR(&LOG,
2066 "%s.%s, is not an array but defines an array callback.",
2067 srna->identifier,
2068 prop->identifier);
2069 DefRNA.error = true;
2070 }
2071
2072 if (!prop->arraydimension) {
2073 if (!bprop->get && !bprop->set && !dp->booleanbit) {
2074 rna_set_raw_property(dp, prop);
2075 }
2076
2077 bprop->get = reinterpret_cast<PropBooleanGetFunc>(
2078 rna_def_property_get_func(f, srna, prop, dp, (const char *)bprop->get));
2079 bprop->set = reinterpret_cast<PropBooleanSetFunc>(
2080 rna_def_property_set_func(f, srna, prop, dp, (const char *)bprop->set));
2081 }
2082 else {
2083 bprop->getarray = reinterpret_cast<PropBooleanArrayGetFunc>(
2084 rna_def_property_get_func(f, srna, prop, dp, (const char *)bprop->getarray));
2085 bprop->setarray = reinterpret_cast<PropBooleanArraySetFunc>(
2086 rna_def_property_set_func(f, srna, prop, dp, (const char *)bprop->setarray));
2087 }
2088 break;
2089 }
2090 case PROP_INT: {
2091 IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
2092
2093 if (!(prop->flag & PROP_EDITABLE) &&
2094 (iprop->set || iprop->set_ex || iprop->setarray || iprop->setarray_ex))
2095 {
2096 CLOG_ERROR(&LOG,
2097 "%s.%s, is read-only but has defines a \"set\" callback.",
2098 srna->identifier,
2099 prop->identifier);
2100 DefRNA.error = true;
2101 }
2102
2103 if (!prop->arraydimension &&
2104 (iprop->getarray || iprop->getarray_ex || iprop->setarray || iprop->setarray_ex))
2105 {
2106 CLOG_ERROR(&LOG,
2107 "%s.%s, is not an array but defines an array callback.",
2108 srna->identifier,
2109 prop->identifier);
2110 DefRNA.error = true;
2111 }
2112
2113 if (!prop->arraydimension) {
2114 if (!iprop->get && !iprop->set) {
2115 rna_set_raw_property(dp, prop);
2116 }
2117
2118 iprop->get = reinterpret_cast<PropIntGetFunc>(
2119 rna_def_property_get_func(f, srna, prop, dp, (const char *)iprop->get));
2120 iprop->set = reinterpret_cast<PropIntSetFunc>(
2121 rna_def_property_set_func(f, srna, prop, dp, (const char *)iprop->set));
2122 }
2123 else {
2124 if (!iprop->getarray && !iprop->setarray) {
2125 rna_set_raw_property(dp, prop);
2126 }
2127
2128 iprop->getarray = reinterpret_cast<PropIntArrayGetFunc>(
2129 rna_def_property_get_func(f, srna, prop, dp, (const char *)iprop->getarray));
2130 iprop->setarray = reinterpret_cast<PropIntArraySetFunc>(
2131 rna_def_property_set_func(f, srna, prop, dp, (const char *)iprop->setarray));
2132 }
2133 break;
2134 }
2135 case PROP_FLOAT: {
2136 FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
2137
2138 if (!(prop->flag & PROP_EDITABLE) &&
2139 (fprop->set || fprop->set_ex || fprop->setarray || fprop->setarray_ex))
2140 {
2141 CLOG_ERROR(&LOG,
2142 "%s.%s, is read-only but has defines a \"set\" callback.",
2143 srna->identifier,
2144 prop->identifier);
2145 DefRNA.error = true;
2146 }
2147
2148 if (!prop->arraydimension &&
2149 (fprop->getarray || fprop->getarray_ex || fprop->setarray || fprop->setarray_ex))
2150 {
2151 CLOG_ERROR(&LOG,
2152 "%s.%s, is not an array but defines an array callback.",
2153 srna->identifier,
2154 prop->identifier);
2155 DefRNA.error = true;
2156 }
2157
2158 if (!prop->arraydimension) {
2159 if (!fprop->get && !fprop->set) {
2160 rna_set_raw_property(dp, prop);
2161 }
2162
2163 fprop->get = reinterpret_cast<PropFloatGetFunc>(
2164 rna_def_property_get_func(f, srna, prop, dp, (const char *)fprop->get));
2165 fprop->set = reinterpret_cast<PropFloatSetFunc>(
2166 rna_def_property_set_func(f, srna, prop, dp, (const char *)fprop->set));
2167 }
2168 else {
2169 if (!fprop->getarray && !fprop->setarray) {
2170 rna_set_raw_property(dp, prop);
2171 }
2172
2173 fprop->getarray = reinterpret_cast<PropFloatArrayGetFunc>(
2174 rna_def_property_get_func(f, srna, prop, dp, (const char *)fprop->getarray));
2175 fprop->setarray = reinterpret_cast<PropFloatArraySetFunc>(
2176 rna_def_property_set_func(f, srna, prop, dp, (const char *)fprop->setarray));
2177 }
2178 break;
2179 }
2180 case PROP_ENUM: {
2181 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
2182
2183 if (!(prop->flag & PROP_EDITABLE) && (eprop->set || eprop->set_ex)) {
2184 CLOG_ERROR(&LOG,
2185 "%s.%s, is read-only but has defines a \"set\" callback.",
2186 srna->identifier,
2187 prop->identifier);
2188 DefRNA.error = true;
2189 }
2190
2191 if (!eprop->get && !eprop->set) {
2192 rna_set_raw_property(dp, prop);
2193 }
2194
2195 eprop->get = reinterpret_cast<PropEnumGetFunc>(
2196 rna_def_property_get_func(f, srna, prop, dp, (const char *)eprop->get));
2197 eprop->set = reinterpret_cast<PropEnumSetFunc>(
2198 rna_def_property_set_func(f, srna, prop, dp, (const char *)eprop->set));
2199 break;
2200 }
2201 case PROP_STRING: {
2202 StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
2203
2204 if (!(prop->flag & PROP_EDITABLE) && (sprop->set || sprop->set_ex)) {
2205 CLOG_ERROR(&LOG,
2206 "%s.%s, is read-only but has defines a \"set\" callback.",
2207 srna->identifier,
2208 prop->identifier);
2209 DefRNA.error = true;
2210 }
2211
2212 sprop->get = reinterpret_cast<PropStringGetFunc>(
2213 rna_def_property_get_func(f, srna, prop, dp, (const char *)sprop->get));
2214 sprop->length = reinterpret_cast<PropStringLengthFunc>(
2215 rna_def_property_length_func(f, srna, prop, dp, (const char *)sprop->length));
2216 sprop->set = reinterpret_cast<PropStringSetFunc>(
2217 rna_def_property_set_func(f, srna, prop, dp, (const char *)sprop->set));
2218 sprop->search = reinterpret_cast<StringPropertySearchFunc>(
2219 rna_def_property_search_func(f, srna, prop, dp, (const char *)sprop->search));
2220 break;
2221 }
2222 case PROP_POINTER: {
2223 PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
2224
2225 if (!(prop->flag & PROP_EDITABLE) && pprop->set) {
2226 CLOG_ERROR(&LOG,
2227 "%s.%s, is read-only but has defines a \"set\" callback.",
2228 srna->identifier,
2229 prop->identifier);
2230 DefRNA.error = true;
2231 }
2232
2233 pprop->get = reinterpret_cast<PropPointerGetFunc>(
2234 rna_def_property_get_func(f, srna, prop, dp, (const char *)pprop->get));
2235 pprop->set = reinterpret_cast<PropPointerSetFunc>(
2236 rna_def_property_set_func(f, srna, prop, dp, (const char *)pprop->set));
2237 if (!pprop->type) {
2238 CLOG_ERROR(
2239 &LOG, "%s.%s, pointer must have a struct type.", srna->identifier, prop->identifier);
2240 DefRNA.error = true;
2241 }
2242 break;
2243 }
2244 case PROP_COLLECTION: {
2246 const char *nextfunc = (const char *)cprop->next;
2247 const char *item_type = (const char *)cprop->item_type;
2248
2249 if (cprop->length) {
2250 /* always generate if we have a manual implementation */
2251 cprop->length = reinterpret_cast<PropCollectionLengthFunc>(
2252 rna_def_property_length_func(f, srna, prop, dp, (const char *)cprop->length));
2253 }
2254 else if (dp->dnatype && STREQ(dp->dnatype, "ListBase")) {
2255 /* pass */
2256 }
2257 else if (dp->dnalengthname || dp->dnalengthfixed) {
2258 cprop->length = reinterpret_cast<PropCollectionLengthFunc>(
2259 rna_def_property_length_func(f, srna, prop, dp, (const char *)cprop->length));
2260 }
2261
2262 /* test if we can allow raw array access, if it is using our standard
2263 * array get/next function, we can be sure it is an actual array */
2264 if (cprop->next && cprop->get) {
2265 if (STREQ((const char *)cprop->next, "rna_iterator_array_next") &&
2266 STREQ((const char *)cprop->get, "rna_iterator_array_get"))
2267 {
2269 }
2270 }
2271
2272 cprop->get = reinterpret_cast<PropCollectionGetFunc>(
2273 rna_def_property_get_func(f, srna, prop, dp, (const char *)cprop->get));
2274 cprop->begin = reinterpret_cast<PropCollectionBeginFunc>(
2275 rna_def_property_begin_func(f, srna, prop, dp, (const char *)cprop->begin));
2276 cprop->next = reinterpret_cast<PropCollectionNextFunc>(
2277 rna_def_property_next_func(f, srna, prop, dp, (const char *)cprop->next));
2278 cprop->end = reinterpret_cast<PropCollectionEndFunc>(
2279 rna_def_property_end_func(f, srna, prop, dp, (const char *)cprop->end));
2280 cprop->lookupint = reinterpret_cast<PropCollectionLookupIntFunc>(
2282 f, srna, prop, dp, (const char *)cprop->lookupint, nextfunc));
2283 cprop->lookupstring = reinterpret_cast<PropCollectionLookupStringFunc>(
2285 f, srna, prop, dp, (const char *)cprop->lookupstring, item_type));
2286
2287 if (!(prop->flag & PROP_IDPROPERTY)) {
2288 if (!cprop->begin) {
2289 CLOG_ERROR(&LOG,
2290 "%s.%s, collection must have a begin function.",
2291 srna->identifier,
2292 prop->identifier);
2293 DefRNA.error = true;
2294 }
2295 if (!cprop->next) {
2296 CLOG_ERROR(&LOG,
2297 "%s.%s, collection must have a next function.",
2298 srna->identifier,
2299 prop->identifier);
2300 DefRNA.error = true;
2301 }
2302 if (!cprop->get) {
2303 CLOG_ERROR(&LOG,
2304 "%s.%s, collection must have a get function.",
2305 srna->identifier,
2306 prop->identifier);
2307 DefRNA.error = true;
2308 }
2309 }
2310 if (!cprop->item_type) {
2311 CLOG_ERROR(&LOG,
2312 "%s.%s, collection must have a struct type.",
2313 srna->identifier,
2314 prop->identifier);
2315 DefRNA.error = true;
2316 }
2317 break;
2318 }
2319 }
2320}
2321
2323{
2324 PropertyRNA *prop;
2325 const char *func;
2326
2327 prop = dp->prop;
2328
2329 if (prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN) {
2330 return;
2331 }
2332
2333 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "");
2334
2335 switch (prop->type) {
2336 case PROP_BOOLEAN: {
2337 if (!prop->arraydimension) {
2338 fprintf(f, "bool %sget(PointerRNA *ptr);\n", func);
2339 fprintf(f, "void %sset(PointerRNA *ptr, bool value);\n", func);
2340 }
2341 else if ((prop->flag & PROP_DYNAMIC) == 0 && prop->arraydimension && prop->totarraylength) {
2342 fprintf(f, "void %sget(PointerRNA *ptr, bool values[%u]);\n", func, prop->totarraylength);
2343 fprintf(f,
2344 "void %sset(PointerRNA *ptr, const bool values[%u]);\n",
2345 func,
2346 prop->totarraylength);
2347 }
2348 else {
2349 fprintf(f, "void %sget(PointerRNA *ptr, bool values[]);\n", func);
2350 fprintf(f, "void %sset(PointerRNA *ptr, const bool values[]);\n", func);
2351 }
2352 break;
2353 }
2354 case PROP_INT: {
2355 if (!prop->arraydimension) {
2356 fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
2357 fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
2358 }
2359 else if ((prop->flag & PROP_DYNAMIC) == 0 && prop->arraydimension && prop->totarraylength) {
2360 fprintf(f, "void %sget(PointerRNA *ptr, int values[%u]);\n", func, prop->totarraylength);
2361 fprintf(
2362 f, "void %sset(PointerRNA *ptr, const int values[%u]);\n", func, prop->totarraylength);
2363 }
2364 else {
2365 fprintf(f, "void %sget(PointerRNA *ptr, int values[]);\n", func);
2366 fprintf(f, "void %sset(PointerRNA *ptr, const int values[]);\n", func);
2367 }
2368 break;
2369 }
2370 case PROP_FLOAT: {
2371 if (!prop->arraydimension) {
2372 fprintf(f, "float %sget(PointerRNA *ptr);\n", func);
2373 fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func);
2374 }
2375 else if ((prop->flag & PROP_DYNAMIC) == 0 && prop->arraydimension && prop->totarraylength) {
2376 fprintf(f, "void %sget(PointerRNA *ptr, float values[%u]);\n", func, prop->totarraylength);
2377 fprintf(f,
2378 "void %sset(PointerRNA *ptr, const float values[%u]);\n",
2379 func,
2380 prop->totarraylength);
2381 }
2382 else {
2383 fprintf(f, "void %sget(PointerRNA *ptr, float values[]);\n", func);
2384 fprintf(f, "void %sset(PointerRNA *ptr, const float values[]);", func);
2385 }
2386 break;
2387 }
2388 case PROP_ENUM: {
2389 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
2390 int i;
2391
2392 if (eprop->item && eprop->totitem) {
2393 fprintf(f, "enum {\n");
2394
2395 for (i = 0; i < eprop->totitem; i++) {
2396 if (eprop->item[i].identifier[0]) {
2397 fprintf(f,
2398 "\t%s_%s_%s = %d,\n",
2399 srna->identifier,
2400 prop->identifier,
2401 eprop->item[i].identifier,
2402 eprop->item[i].value);
2403 }
2404 }
2405
2406 fprintf(f, "};\n\n");
2407 }
2408
2409 fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
2410 fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
2411
2412 break;
2413 }
2414 case PROP_STRING: {
2415 StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
2416
2417 if (sprop->maxlength) {
2418 fprintf(
2419 f, "#define %s_%s_MAX %d\n\n", srna->identifier, prop->identifier, sprop->maxlength);
2420 }
2421
2422 fprintf(f, "void %sget(PointerRNA *ptr, char *value);\n", func);
2423 fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
2424 fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func);
2425
2426 break;
2427 }
2428 case PROP_POINTER: {
2429 fprintf(f, "PointerRNA %sget(PointerRNA *ptr);\n", func);
2430 // fprintf(f, "void %sset(PointerRNA *ptr, PointerRNA value);\n", func);
2431 break;
2432 }
2433 case PROP_COLLECTION: {
2435 fprintf(f, "void %sbegin(CollectionPropertyIterator *iter, PointerRNA *ptr);\n", func);
2436 fprintf(f, "void %snext(CollectionPropertyIterator *iter);\n", func);
2437 fprintf(f, "void %send(CollectionPropertyIterator *iter);\n", func);
2438 if (cprop->length) {
2439 fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
2440 }
2441 if (cprop->lookupint) {
2442 fprintf(f, "bool %slookup_int(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n", func);
2443 }
2444 if (cprop->lookupstring) {
2445 fprintf(f,
2446 "bool %slookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n",
2447 func);
2448 }
2449 break;
2450 }
2451 }
2452
2453 if (prop->getlength) {
2454 char funcname[2048];
2456 funcname, sizeof(funcname), srna->identifier, prop->identifier, "get_length");
2457 fprintf(f, "int %s(PointerRNA *ptr, int *arraylen);\n", funcname);
2458 }
2459
2460 fprintf(f, "\n");
2461}
2462
2463static void rna_def_function_funcs_header(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
2464{
2465 FunctionRNA *func = dfunc->func;
2466 char funcname[2048];
2467
2469 funcname, sizeof(funcname), srna->identifier, func->identifier, "func");
2470 rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 1);
2471}
2472
2474{
2475 PropertyRNA *prop;
2476
2477 prop = dp->prop;
2478
2479 if (prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN) {
2480 return;
2481 }
2482
2483/* Disabled for now to avoid MSVC compiler error due to large file size. */
2484#if 0
2485 if (prop->name && prop->description && prop->description[0] != '\0') {
2486 fprintf(f, "\t/* %s: %s */\n", prop->name, prop->description);
2487 }
2488 else if (prop->name) {
2489 fprintf(f, "\t/* %s */\n", prop->name);
2490 }
2491 else {
2492 fprintf(f, "\t/* */\n");
2493 }
2494#endif
2495
2496 switch (prop->type) {
2497 case PROP_BOOLEAN: {
2498 if (!prop->arraydimension) {
2499 fprintf(f, "\tinline bool %s(void);\n", rna_safe_id(prop->identifier));
2500 fprintf(f, "\tinline void %s(bool value);", rna_safe_id(prop->identifier));
2501 }
2502 else if (prop->totarraylength) {
2503 fprintf(f,
2504 "\tinline Array<bool, %u> %s(void);\n",
2505 prop->totarraylength,
2506 rna_safe_id(prop->identifier));
2507 fprintf(f,
2508 "\tinline void %s(bool values[%u]);",
2509 rna_safe_id(prop->identifier),
2510 prop->totarraylength);
2511 }
2512 else if (prop->getlength) {
2513 fprintf(f, "\tinline DynamicArray<bool> %s(void);\n", rna_safe_id(prop->identifier));
2514 fprintf(f, "\tinline void %s(bool values[]);", rna_safe_id(prop->identifier));
2515 }
2516 break;
2517 }
2518 case PROP_INT: {
2519 if (!prop->arraydimension) {
2520 fprintf(f, "\tinline int %s(void);\n", rna_safe_id(prop->identifier));
2521 fprintf(f, "\tinline void %s(int value);", rna_safe_id(prop->identifier));
2522 }
2523 else if (prop->totarraylength) {
2524 fprintf(f,
2525 "\tinline Array<int, %u> %s(void);\n",
2526 prop->totarraylength,
2527 rna_safe_id(prop->identifier));
2528 fprintf(f,
2529 "\tinline void %s(int values[%u]);",
2530 rna_safe_id(prop->identifier),
2531 prop->totarraylength);
2532 }
2533 else if (prop->getlength) {
2534 fprintf(f, "\tinline DynamicArray<int> %s(void);\n", rna_safe_id(prop->identifier));
2535 fprintf(f, "\tinline void %s(int values[]);", rna_safe_id(prop->identifier));
2536 }
2537 break;
2538 }
2539 case PROP_FLOAT: {
2540 if (!prop->arraydimension) {
2541 fprintf(f, "\tinline float %s(void);\n", rna_safe_id(prop->identifier));
2542 fprintf(f, "\tinline void %s(float value);", rna_safe_id(prop->identifier));
2543 }
2544 else if (prop->totarraylength) {
2545 fprintf(f,
2546 "\tinline Array<float, %u> %s(void);\n",
2547 prop->totarraylength,
2548 rna_safe_id(prop->identifier));
2549 fprintf(f,
2550 "\tinline void %s(float values[%u]);",
2551 rna_safe_id(prop->identifier),
2552 prop->totarraylength);
2553 }
2554 else if (prop->getlength) {
2555 fprintf(f, "\tinline DynamicArray<float> %s(void);\n", rna_safe_id(prop->identifier));
2556 fprintf(f, "\tinline void %s(float values[]);", rna_safe_id(prop->identifier));
2557 }
2558 break;
2559 }
2560 case PROP_ENUM: {
2561 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
2562 int i;
2563
2564 if (eprop->item) {
2565 fprintf(f, "\tenum %s_enum {\n", rna_safe_id(prop->identifier));
2566
2567 for (i = 0; i < eprop->totitem; i++) {
2568 if (eprop->item[i].identifier[0]) {
2569 fprintf(f,
2570 "\t\t%s_%s = %d,\n",
2571 rna_safe_id(prop->identifier),
2572 eprop->item[i].identifier,
2573 eprop->item[i].value);
2574 }
2575 }
2576
2577 fprintf(f, "\t};\n");
2578 }
2579
2580 fprintf(f,
2581 "\tinline %s_enum %s(void);\n",
2582 rna_safe_id(prop->identifier),
2583 rna_safe_id(prop->identifier));
2584 fprintf(f,
2585 "\tinline void %s(%s_enum value);",
2586 rna_safe_id(prop->identifier),
2587 rna_safe_id(prop->identifier));
2588 break;
2589 }
2590 case PROP_STRING: {
2591 fprintf(f, "\tinline std::string %s(void);\n", rna_safe_id(prop->identifier));
2592 fprintf(f, "\tinline void %s(const std::string& value);", rna_safe_id(prop->identifier));
2593 break;
2594 }
2595 case PROP_POINTER: {
2597
2598 if (pprop->type) {
2599 fprintf(
2600 f, "\tinline %s %s(void);", (const char *)pprop->type, rna_safe_id(prop->identifier));
2601 }
2602 else {
2603 fprintf(f, "\tinline %s %s(void);", "UnknownType", rna_safe_id(prop->identifier));
2604 }
2605 break;
2606 }
2607 case PROP_COLLECTION: {
2609 const char *collection_funcs = "DefaultCollectionFunctions";
2610
2612 cprop->property.srna)
2613 {
2614 collection_funcs = (char *)cprop->property.srna;
2615 }
2616
2617 if (cprop->item_type) {
2618 fprintf(f,
2619 "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)",
2620 collection_funcs,
2621 (const char *)cprop->item_type,
2622 srna->identifier,
2623 rna_safe_id(prop->identifier),
2624 (cprop->length ? "true" : "false"),
2625 (cprop->lookupint ? "true" : "false"),
2626 (cprop->lookupstring ? "true" : "false"));
2627 }
2628 else {
2629 fprintf(f,
2630 "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)",
2631 collection_funcs,
2632 "UnknownType",
2633 srna->identifier,
2634 rna_safe_id(prop->identifier),
2635 (cprop->length ? "true" : "false"),
2636 (cprop->lookupint ? "true" : "false"),
2637 (cprop->lookupstring ? "true" : "false"));
2638 }
2639 break;
2640 }
2641 }
2642
2643 fprintf(f, "\n");
2644}
2645
2647{
2648 if (prop->type == PROP_POINTER) {
2649 /* For the C++ API we need to use RNA structures names for pointers. */
2650 PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
2651
2652 return (const char *)pprop->type;
2653 }
2654 return rna_parameter_type_name(prop);
2655}
2656
2658 StructRNA * /*srna*/,
2659 FunctionDefRNA *dfunc,
2660 const char *cpp_namespace,
2661 int close_prototype)
2662{
2663 FunctionRNA *func = dfunc->func;
2664
2665 int first = 1;
2666 const char *retval_type = "void";
2667
2668 if (func->c_ret) {
2670 retval_type = rna_parameter_type_cpp_name(dp->prop);
2671 }
2672
2673 if (cpp_namespace && cpp_namespace[0]) {
2674 fprintf(f, "\tinline %s %s::%s(", retval_type, cpp_namespace, rna_safe_id(func->identifier));
2675 }
2676 else {
2677 fprintf(f, "\tinline %s %s(", retval_type, rna_safe_id(func->identifier));
2678 }
2679
2680 if (func->flag & FUNC_USE_MAIN) {
2681 WRITE_PARAM("void *main");
2682 }
2683
2684 if (func->flag & FUNC_USE_CONTEXT) {
2685 WRITE_PARAM("Context C");
2686 }
2687
2689 int type, flag, flag_parameter, pout;
2690 const char *ptrstr;
2691
2692 if (dp->prop == func->c_ret) {
2693 continue;
2694 }
2695
2696 type = dp->prop->type;
2697 flag = dp->prop->flag;
2698 flag_parameter = dp->prop->flag_parameter;
2699 pout = (flag_parameter & PARM_OUTPUT);
2700
2701 if (flag & PROP_DYNAMIC) {
2702 if (type == PROP_STRING) {
2703 ptrstr = pout ? "*" : "";
2704 }
2705 else {
2706 ptrstr = pout ? "**" : "*";
2707 }
2708 }
2709 else if (type == PROP_POINTER) {
2710 ptrstr = pout ? "*" : "";
2711 }
2712 else if (dp->prop->arraydimension) {
2713 ptrstr = "*";
2714 }
2715 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
2716 ptrstr = "";
2717 }
2718 else {
2719 ptrstr = pout ? "*" : "";
2720 }
2721
2723
2724 if (flag & PROP_DYNAMIC) {
2725 fprintf(
2726 f, "int %s%s_len, ", (flag_parameter & PARM_OUTPUT) ? "*" : "", dp->prop->identifier);
2727 }
2728
2729 if (!(flag & PROP_DYNAMIC) && dp->prop->arraydimension) {
2730 fprintf(f,
2731 "%s %s[%u]",
2733 rna_safe_id(dp->prop->identifier),
2734 dp->prop->totarraylength);
2735 }
2736 else {
2737 fprintf(f,
2738 "%s%s%s%s",
2740 (dp->prop->type == PROP_POINTER && ptrstr[0] == '\0') ? "& " : " ",
2741 ptrstr,
2742 rna_safe_id(dp->prop->identifier));
2743 }
2744 }
2745
2746 fprintf(f, ")");
2747 if (close_prototype) {
2748 fprintf(f, ";\n");
2749 }
2750}
2751
2753{
2754 if (dfunc->call) {
2755/* Disabled for now to avoid MSVC compiler error due to large file size. */
2756#if 0
2757 FunctionRNA *func = dfunc->func;
2758 fprintf(f, "\n\t/* %s */\n", func->description);
2759#endif
2760
2761 rna_def_struct_function_prototype_cpp(f, srna, dfunc, nullptr, 1);
2762 }
2763}
2764
2766{
2767 PropertyRNA *prop;
2768
2769 prop = dp->prop;
2770
2771 if (prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN) {
2772 return;
2773 }
2774
2775 switch (prop->type) {
2776 case PROP_BOOLEAN: {
2777 if (!prop->arraydimension) {
2778 fprintf(f, "\tBOOLEAN_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
2779 }
2780 else if (prop->totarraylength) {
2781 fprintf(f,
2782 "\tBOOLEAN_ARRAY_PROPERTY(%s, %u, %s)",
2783 srna->identifier,
2784 prop->totarraylength,
2785 rna_safe_id(prop->identifier));
2786 }
2787 else if (prop->getlength) {
2788 fprintf(f,
2789 "\tBOOLEAN_DYNAMIC_ARRAY_PROPERTY(%s, %s)",
2790 srna->identifier,
2791 rna_safe_id(prop->identifier));
2792 }
2793 break;
2794 }
2795 case PROP_INT: {
2796 if (!prop->arraydimension) {
2797 fprintf(f, "\tINT_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
2798 }
2799 else if (prop->totarraylength) {
2800 fprintf(f,
2801 "\tINT_ARRAY_PROPERTY(%s, %u, %s)",
2802 srna->identifier,
2803 prop->totarraylength,
2804 rna_safe_id(prop->identifier));
2805 }
2806 else if (prop->getlength) {
2807 fprintf(f,
2808 "\tINT_DYNAMIC_ARRAY_PROPERTY(%s, %s)",
2809 srna->identifier,
2810 rna_safe_id(prop->identifier));
2811 }
2812 break;
2813 }
2814 case PROP_FLOAT: {
2815 if (!prop->arraydimension) {
2816 fprintf(f, "\tFLOAT_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
2817 }
2818 else if (prop->totarraylength) {
2819 fprintf(f,
2820 "\tFLOAT_ARRAY_PROPERTY(%s, %u, %s)",
2821 srna->identifier,
2822 prop->totarraylength,
2823 rna_safe_id(prop->identifier));
2824 }
2825 else if (prop->getlength) {
2826 fprintf(f,
2827 "\tFLOAT_DYNAMIC_ARRAY_PROPERTY(%s, %s)",
2828 srna->identifier,
2829 rna_safe_id(prop->identifier));
2830 }
2831 break;
2832 }
2833 case PROP_ENUM: {
2834 fprintf(f,
2835 "\tENUM_PROPERTY(%s_enum, %s, %s)",
2836 rna_safe_id(prop->identifier),
2837 srna->identifier,
2838 rna_safe_id(prop->identifier));
2839
2840 break;
2841 }
2842 case PROP_STRING: {
2843 fprintf(f, "\tSTRING_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
2844 break;
2845 }
2846 case PROP_POINTER: {
2848
2849 if (pprop->type) {
2850 fprintf(f,
2851 "\tPOINTER_PROPERTY(%s, %s, %s)",
2852 (const char *)pprop->type,
2853 srna->identifier,
2854 rna_safe_id(prop->identifier));
2855 }
2856 else {
2857 fprintf(f,
2858 "\tPOINTER_PROPERTY(%s, %s, %s)",
2859 "UnknownType",
2860 srna->identifier,
2861 rna_safe_id(prop->identifier));
2862 }
2863 break;
2864 }
2865 case PROP_COLLECTION: {
2866#if 0
2868
2869 if (cprop->type) {
2870 fprintf(f,
2871 "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)",
2872 (const char *)cprop->type,
2873 srna->identifier,
2874 prop->identifier,
2875 (cprop->length ? "true" : "false"),
2876 (cprop->lookupint ? "true" : "false"),
2877 (cprop->lookupstring ? "true" : "false"));
2878 }
2879 else {
2880 fprintf(f,
2881 "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)",
2882 "UnknownType",
2883 srna->identifier,
2884 prop->identifier,
2885 (cprop->length ? "true" : "false"),
2886 (cprop->lookupint ? "true" : "false"),
2887 (cprop->lookupstring ? "true" : "false"));
2888 }
2889#endif
2890 break;
2891 }
2892 }
2893
2894 fprintf(f, "\n");
2895}
2896
2898{
2899 PropertyDefRNA *dp;
2900 StructDefRNA *dsrna;
2901 FunctionRNA *func = dfunc->func;
2902 char funcname[2048];
2903
2904 int first = 1;
2905
2907 funcname, sizeof(funcname), srna->identifier, func->identifier, "func");
2908
2909 fprintf(f, "%s(", funcname);
2910
2911 dsrna = rna_find_struct_def(srna);
2912
2913 if (func->flag & FUNC_USE_SELF_ID) {
2914 WRITE_PARAM("(::ID *) ptr.owner_id");
2915 }
2916
2917 if ((func->flag & FUNC_NO_SELF) == 0) {
2919 if (dsrna->dnafromprop) {
2920 fprintf(f, "(::%s *) this->ptr.data", dsrna->dnafromname);
2921 }
2922 else if (dsrna->dnaname) {
2923 fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname);
2924 }
2925 else {
2926 fprintf(f, "(::%s *) this->ptr.data", srna->identifier);
2927 }
2928 }
2929 else if (func->flag & FUNC_USE_SELF_TYPE) {
2931 fprintf(f, "this->ptr.type");
2932 }
2933
2934 if (func->flag & FUNC_USE_MAIN) {
2935 WRITE_PARAM("(::Main *) main");
2936 }
2937
2938 if (func->flag & FUNC_USE_CONTEXT) {
2939 WRITE_PARAM("(::bContext *) C.ptr.data");
2940 }
2941
2942 if (func->flag & FUNC_USE_REPORTS) {
2943 WRITE_PARAM("nullptr");
2944 }
2945
2946 dp = static_cast<PropertyDefRNA *>(dfunc->cont.properties.first);
2947 for (; dp; dp = dp->next) {
2948 if (dp->prop == func->c_ret) {
2949 continue;
2950 }
2951
2953
2954 if (dp->prop->flag & PROP_DYNAMIC) {
2955 fprintf(f, "%s_len, ", dp->prop->identifier);
2956 }
2957
2958 if (dp->prop->type == PROP_POINTER) {
2959 if ((dp->prop->flag_parameter & PARM_RNAPTR) && !(dp->prop->flag & PROP_THICK_WRAP)) {
2960 fprintf(f,
2961 "(::%s *) &%s.ptr",
2964 }
2965 else if (dp->prop->flag_parameter & PARM_OUTPUT) {
2966 if (dp->prop->flag_parameter & PARM_RNAPTR) {
2967 fprintf(f, "&%s->ptr", rna_safe_id(dp->prop->identifier));
2968 }
2969 else {
2970 fprintf(f,
2971 "(::%s **) &%s->ptr.data",
2974 }
2975 }
2976 else if (dp->prop->flag_parameter & PARM_RNAPTR) {
2977 fprintf(f,
2978 "(::%s *) &%s",
2981 }
2982 else {
2983 fprintf(f,
2984 "(::%s *) %s.ptr.data",
2987 }
2988 }
2989 else {
2990 fprintf(f, "%s", rna_safe_id(dp->prop->identifier));
2991 }
2992 }
2993
2994 fprintf(f, ");\n");
2995}
2996
2998{
2999 PropertyDefRNA *dp;
3000 PointerPropertyRNA *pprop;
3001
3002 FunctionRNA *func = dfunc->func;
3003
3004 if (!dfunc->call) {
3005 return;
3006 }
3007
3008 rna_def_struct_function_prototype_cpp(f, srna, dfunc, srna->identifier, 0);
3009
3010 fprintf(f, " {\n");
3011
3012 if (func->c_ret) {
3013 dp = rna_find_parameter_def(func->c_ret);
3014
3015 if (dp->prop->type == PROP_POINTER) {
3016 pprop = (PointerPropertyRNA *)dp->prop;
3017
3018 fprintf(f, "\t\tPointerRNA result;\n");
3019
3020 if ((dp->prop->flag_parameter & PARM_RNAPTR) == 0) {
3021 StructRNA *ret_srna = rna_find_struct((const char *)pprop->type);
3022 fprintf(f, "\t\t::%s *retdata = ", rna_parameter_type_name(dp->prop));
3024 if (ret_srna->flag & STRUCT_ID) {
3025 fprintf(f, "\t\tresult = RNA_id_pointer_create((::ID *) retdata);\n");
3026 }
3027 else {
3028 fprintf(f,
3029 "\t\tresult = RNA_pointer_create_with_parent(ptr, &RNA_%s, retdata);\n",
3030 (const char *)pprop->type);
3031 }
3032 }
3033 else {
3034 fprintf(f, "\t\tresult = ");
3036 }
3037
3038 fprintf(f, "\t\treturn %s(result);\n", (const char *)pprop->type);
3039 }
3040 else {
3041 fprintf(f, "\t\treturn ");
3043 }
3044 }
3045 else {
3046 fprintf(f, "\t\t");
3048 }
3049
3050 fprintf(f, "\t}\n\n");
3051}
3052
3054{
3055 if (dp->prop->getlength) {
3056 char funcname[2048];
3058 funcname, sizeof(funcname), dsrna->srna->identifier, dp->prop->identifier, "get_length");
3059 fprintf(f, "extern int %s(PointerRNA *ptr, int *arraylen)\n", funcname);
3060 fprintf(f, "{\n");
3061 fprintf(f, "\treturn %s(ptr, arraylen);\n", rna_function_string(dp->prop->getlength));
3062 fprintf(f, "}\n\n");
3063 }
3064}
3065
3067{
3068 StructRNA *srna = dsrna->srna;
3069 FunctionRNA *func = dfunc->func;
3070 PropertyDefRNA *dparm;
3071
3072 int first;
3073 char funcname[2048];
3074
3075 if (!dfunc->call) {
3076 return;
3077 }
3078
3080 funcname, sizeof(funcname), srna->identifier, func->identifier, "func");
3081
3082 fprintf(f, "extern ");
3083 rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 0);
3084
3085 fprintf(f, "\n{\n");
3086
3087 if (func->c_ret) {
3088 fprintf(f, "\treturn %s(", dfunc->call);
3089 }
3090 else {
3091 fprintf(f, "\t%s(", dfunc->call);
3092 }
3093
3094 first = 1;
3095
3096 if (func->flag & FUNC_USE_SELF_ID) {
3097 WRITE_PARAM("_selfid");
3098 }
3099
3100 if ((func->flag & FUNC_NO_SELF) == 0) {
3101 WRITE_PARAM("_self");
3102 }
3103 else if (func->flag & FUNC_USE_SELF_TYPE) {
3104 WRITE_PARAM("_type");
3105 }
3106
3107 if (func->flag & FUNC_USE_MAIN) {
3108 WRITE_PARAM("bmain");
3109 }
3110
3111 if (func->flag & FUNC_USE_CONTEXT) {
3112 WRITE_PARAM("C");
3113 }
3114
3115 if (func->flag & FUNC_USE_REPORTS) {
3116 WRITE_PARAM("reports");
3117 }
3118
3119 dparm = static_cast<PropertyDefRNA *>(dfunc->cont.properties.first);
3120 for (; dparm; dparm = dparm->next) {
3121 if (dparm->prop == func->c_ret) {
3122 continue;
3123 }
3124
3126
3127 if (dparm->prop->flag & PROP_DYNAMIC) {
3128 fprintf(f, "%s, %s_num", dparm->prop->identifier, dparm->prop->identifier);
3129 }
3130 else {
3131 fprintf(f, "%s", rna_safe_id(dparm->prop->identifier));
3132 }
3133 }
3134
3135 fprintf(f, ");\n");
3136 fprintf(f, "}\n\n");
3137}
3138
3139static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc)
3140{
3141 StructRNA *srna;
3142 FunctionRNA *func;
3143 PropertyDefRNA *dparm;
3144 PropertyType type;
3145 const char *funcname, *valstr;
3146 const char *ptrstr;
3147 const bool has_data = (dfunc->cont.properties.first != nullptr);
3148 int flag, flag_parameter, pout, cptr, first;
3149
3150 srna = dsrna->srna;
3151 func = dfunc->func;
3152
3153 if (!dfunc->call) {
3154 return;
3155 }
3156
3157 funcname = rna_alloc_function_name(srna->identifier, func->identifier, "call");
3158
3159 /* function definition */
3160 fprintf(
3161 f,
3162 "static void %s(bContext *C, ReportList *reports, PointerRNA *_ptr, ParameterList *_parms)",
3163 funcname);
3164 fprintf(f, "\n{\n");
3165
3166 /* variable definitions */
3167
3168 if (func->flag & FUNC_USE_SELF_ID) {
3169 fprintf(f, "\tstruct ID *_selfid;\n");
3170 }
3171
3172 if ((func->flag & FUNC_NO_SELF) == 0) {
3173 if (dsrna->dnafromprop) {
3174 fprintf(f, "\tstruct %s *_self;\n", dsrna->dnafromname);
3175 }
3176 else if (dsrna->dnaname) {
3177 fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
3178 }
3179 else {
3180 fprintf(f, "\tstruct %s *_self;\n", srna->identifier);
3181 }
3182 }
3183 else if (func->flag & FUNC_USE_SELF_TYPE) {
3184 fprintf(f, "\tstruct StructRNA *_type;\n");
3185 }
3186
3187 dparm = static_cast<PropertyDefRNA *>(dfunc->cont.properties.first);
3188 for (; dparm; dparm = dparm->next) {
3189 type = dparm->prop->type;
3190 flag = dparm->prop->flag;
3191 flag_parameter = dparm->prop->flag_parameter;
3192 pout = (flag_parameter & PARM_OUTPUT);
3193 cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
3194
3195 if (dparm->prop == func->c_ret) {
3196 ptrstr = cptr || dparm->prop->arraydimension ? "*" : "";
3197 /* XXX only arrays and strings are allowed to be dynamic, is this checked anywhere? */
3198 }
3199 else if (cptr || (flag & PROP_DYNAMIC)) {
3200 if (type == PROP_STRING) {
3201 ptrstr = pout ? "*" : "";
3202 }
3203 else {
3204 ptrstr = pout ? "**" : "*";
3205 }
3206 /* Fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack,
3207 * pass a pointer to it. */
3208 }
3209 else if (type == PROP_POINTER || dparm->prop->arraydimension) {
3210 ptrstr = "*";
3211 }
3212 else if ((type == PROP_POINTER) && (flag_parameter & PARM_RNAPTR) && !(flag & PROP_THICK_WRAP))
3213 {
3214 ptrstr = "*";
3215 /* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack,
3216 * but type name for string props is already (char *), so leave empty */
3217 }
3218 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
3219 ptrstr = "";
3220 }
3221 else {
3222 ptrstr = pout ? "*" : "";
3223 }
3224
3225 /* for dynamic parameters we pass an additional int for the length of the parameter */
3226 if (flag & PROP_DYNAMIC) {
3227 fprintf(f, "\tint %s%s_num;\n", pout ? "*" : "", dparm->prop->identifier);
3228 }
3229
3230 fprintf(f,
3231 "\t%s%s%s %s%s;\n",
3232 rna_parameter_is_const(dparm) ? "const " : "",
3233 rna_type_struct(dparm->prop),
3235 ptrstr,
3236 rna_safe_id(dparm->prop->identifier));
3237 }
3238
3239 if (has_data) {
3240 fprintf(f, "\tchar *_data");
3241 if (func->c_ret) {
3242 fprintf(f, ", *_retdata");
3243 }
3244 fprintf(f, ";\n");
3245 fprintf(f, "\t\n");
3246 }
3247
3248 /* assign self */
3249 if (func->flag & FUNC_USE_SELF_ID) {
3250 fprintf(f, "\t_selfid = (struct ID *)_ptr->owner_id;\n");
3251 }
3252
3253 if ((func->flag & FUNC_NO_SELF) == 0) {
3254 if (dsrna->dnafromprop) {
3255 fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnafromname);
3256 }
3257 else if (dsrna->dnaname) {
3258 fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnaname);
3259 }
3260 else {
3261 fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", srna->identifier);
3262 }
3263 }
3264 else if (func->flag & FUNC_USE_SELF_TYPE) {
3265 fprintf(f, "\t_type = _ptr->type;\n");
3266 }
3267
3268 if (has_data) {
3269 fprintf(f, "\t_data = (char *)_parms->data;\n");
3270 }
3271
3272 dparm = static_cast<PropertyDefRNA *>(dfunc->cont.properties.first);
3273 for (; dparm; dparm = dparm->next) {
3274 type = dparm->prop->type;
3275 flag = dparm->prop->flag;
3276 flag_parameter = dparm->prop->flag_parameter;
3277 pout = (flag_parameter & PARM_OUTPUT);
3278 cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
3279
3280 if (dparm->prop == func->c_ret) {
3281 fprintf(f, "\t_retdata = _data;\n");
3282 }
3283 else {
3284 const char *data_str;
3285 if (cptr || (flag & PROP_DYNAMIC)) {
3286 if (type == PROP_STRING) {
3287 ptrstr = "*";
3288 valstr = "";
3289 }
3290 else {
3291 ptrstr = "**";
3292 valstr = "*";
3293 }
3294 }
3295 else if ((type == PROP_POINTER) && !(flag & PROP_THICK_WRAP)) {
3296 ptrstr = "**";
3297 valstr = "*";
3298 }
3299 else if (type == PROP_POINTER || dparm->prop->arraydimension) {
3300 ptrstr = "*";
3301 valstr = "";
3302 }
3303 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
3304 ptrstr = "";
3305 valstr = "";
3306 }
3307 else {
3308 ptrstr = "*";
3309 valstr = "*";
3310 }
3311
3312 /* This must be kept in sync with RNA_parameter_dynamic_length_get_data and
3313 * RNA_parameter_get, we could just call the function directly, but this is faster. */
3314 if (flag & PROP_DYNAMIC) {
3315 fprintf(f,
3316 "\t%s_num = %s((ParameterDynAlloc *)_data)->array_tot;\n",
3317 rna_safe_id(dparm->prop->identifier),
3318 pout ? "(int *)&" : "(int)");
3319 data_str = "(&(((ParameterDynAlloc *)_data)->array))";
3320 }
3321 else {
3322 data_str = "_data";
3323 }
3324 fprintf(f, "\t%s = ", rna_safe_id(dparm->prop->identifier));
3325
3326 if (!pout) {
3327 fprintf(f, "%s", valstr);
3328 }
3329
3330 fprintf(f,
3331 "((%s%s%s %s)%s);\n",
3332 rna_parameter_is_const(dparm) ? "const " : "",
3333 rna_type_struct(dparm->prop),
3335 ptrstr,
3336 data_str);
3337 }
3338
3339 if (dparm->next) {
3340 fprintf(f, "\t_data += %d;\n", rna_parameter_size_pad(rna_parameter_size(dparm->prop)));
3341 }
3342 }
3343
3344 if (dfunc->call) {
3345 fprintf(f, "\t\n");
3346 fprintf(f, "\t");
3347 if (func->c_ret) {
3348 fprintf(f, "%s = ", func->c_ret->identifier);
3349 }
3350 fprintf(f, "%s(", dfunc->call);
3351
3352 first = 1;
3353
3354 if (func->flag & FUNC_USE_SELF_ID) {
3355 fprintf(f, "_selfid");
3356 first = 0;
3357 }
3358
3359 if ((func->flag & FUNC_NO_SELF) == 0) {
3360 if (!first) {
3361 fprintf(f, ", ");
3362 }
3363 fprintf(f, "_self");
3364 first = 0;
3365 }
3366 else if (func->flag & FUNC_USE_SELF_TYPE) {
3367 if (!first) {
3368 fprintf(f, ", ");
3369 }
3370 fprintf(f, "_type");
3371 first = 0;
3372 }
3373
3374 if (func->flag & FUNC_USE_MAIN) {
3375 if (!first) {
3376 fprintf(f, ", ");
3377 }
3378 first = 0;
3379 fprintf(f, "CTX_data_main(C)"); /* may have direct access later */
3380 }
3381
3382 if (func->flag & FUNC_USE_CONTEXT) {
3383 if (!first) {
3384 fprintf(f, ", ");
3385 }
3386 first = 0;
3387 fprintf(f, "C");
3388 }
3389
3390 if (func->flag & FUNC_USE_REPORTS) {
3391 if (!first) {
3392 fprintf(f, ", ");
3393 }
3394 first = 0;
3395 fprintf(f, "reports");
3396 }
3397
3398 dparm = static_cast<PropertyDefRNA *>(dfunc->cont.properties.first);
3399 for (; dparm; dparm = dparm->next) {
3400 if (dparm->prop == func->c_ret) {
3401 continue;
3402 }
3403
3404 if (!first) {
3405 fprintf(f, ", ");
3406 }
3407 first = 0;
3408
3409 if (dparm->prop->flag & PROP_DYNAMIC) {
3410 fprintf(f,
3411 "%s, %s_num",
3412 rna_safe_id(dparm->prop->identifier),
3413 rna_safe_id(dparm->prop->identifier));
3414 }
3415 else {
3416 fprintf(f, "%s", rna_safe_id(dparm->prop->identifier));
3417 }
3418 }
3419
3420 fprintf(f, ");\n");
3421
3422 if (func->c_ret) {
3423 dparm = rna_find_parameter_def(func->c_ret);
3424 if ((dparm->prop->type == PROP_POINTER) && (dparm->prop->flag_parameter & PARM_RNAPTR) &&
3425 (dparm->prop->flag & PROP_THICK_WRAP))
3426 {
3427 const char *parameter_type_name = rna_parameter_type_name(dparm->prop);
3428 fprintf(f,
3429 "\t*reinterpret_cast<%s *>(_retdata) = %s;\n",
3430 parameter_type_name,
3431 func->c_ret->identifier);
3432 }
3433 else {
3434 ptrstr = (((dparm->prop->type == PROP_POINTER) &&
3435 !(dparm->prop->flag_parameter & PARM_RNAPTR)) ||
3436 (dparm->prop->arraydimension)) ?
3437 "*" :
3438 "";
3439 if (dparm->prop->type == PROP_COLLECTION) {
3440 /* Placement new is necessary because #ParameterList::data is not initialized. */
3441 fprintf(f,
3442 "\tnew ((CollectionVector *)_retdata) CollectionVector(std::move(%s));\n",
3443 func->c_ret->identifier);
3444 }
3445 else {
3446 fprintf(f,
3447 "\t*((%s%s %s*)_retdata) = %s;\n",
3448 rna_type_struct(dparm->prop),
3450 ptrstr,
3451 func->c_ret->identifier);
3452 }
3453 }
3454 }
3455 }
3456
3457 fprintf(f, "}\n\n");
3458
3459 dfunc->gencall = funcname;
3460}
3461
3462static void rna_sanity_checks()
3463{
3464 /* Ensure RNA enum definitions follow naming convention. */
3465 {
3466#define DEF_ENUM(id) #id,
3467 const char *rna_enum_id_array[] = {
3468#include "RNA_enum_items.hh"
3469 };
3470 for (int i = 0; i < ARRAY_SIZE(rna_enum_id_array); i++) {
3471 if (!(BLI_str_startswith(rna_enum_id_array[i], "rna_enum_") &&
3472 BLI_str_endswith(rna_enum_id_array[i], "_items")))
3473 {
3474 fprintf(stderr,
3475 "Error: enum defined in \"RNA_enum_items.hh\" "
3476 "doesn't confirm to \"rna_enum_*_items\" convention!\n");
3477 DefRNA.error = true;
3478 }
3479 }
3480 }
3481}
3482
3483static void rna_auto_types()
3484{
3485 StructDefRNA *ds;
3486
3487 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
3488 ds = static_cast<StructDefRNA *>(ds->cont.next))
3489 {
3490 /* DNA name for Screen is patched in 2.5, we do the reverse here. */
3491 if (ds->dnaname) {
3492 if (STREQ(ds->dnaname, "Screen")) {
3493 ds->dnaname = "bScreen";
3494 }
3495 if (STREQ(ds->dnaname, "Group")) {
3496 ds->dnaname = "Collection";
3497 }
3498 if (STREQ(ds->dnaname, "GroupObject")) {
3499 ds->dnaname = "CollectionObject";
3500 }
3501 }
3502
3504 if (dp->dnastructname) {
3505 if (STREQ(dp->dnastructname, "Screen")) {
3506 dp->dnastructname = "bScreen";
3507 }
3508 if (STREQ(dp->dnastructname, "Group")) {
3509 dp->dnastructname = "Collection";
3510 }
3511 if (STREQ(dp->dnastructname, "GroupObject")) {
3512 dp->dnastructname = "CollectionObject";
3513 }
3514 }
3515
3516 if (dp->dnatype) {
3517 if (dp->prop->type == PROP_POINTER) {
3518 PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop;
3519 StructRNA *type;
3520
3521 if (!pprop->type && !pprop->get) {
3522 pprop->type = (StructRNA *)rna_find_type(dp->dnatype);
3523 }
3524
3525 if (pprop->type) {
3526 type = rna_find_struct((const char *)pprop->type);
3527 if (type && (type->flag & STRUCT_ID_REFCOUNT)) {
3528 pprop->property.flag |= PROP_ID_REFCOUNT;
3529 }
3530 }
3531 }
3532 else if (dp->prop->type == PROP_COLLECTION) {
3533 CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop;
3534
3535 if (!cprop->item_type && !cprop->get && STREQ(dp->dnatype, "ListBase")) {
3536 cprop->item_type = (StructRNA *)rna_find_type(dp->dnatype);
3537 }
3538 }
3539 }
3540 }
3541 }
3542}
3543
3544static void rna_sort(BlenderRNA *brna)
3545{
3546 StructDefRNA *ds;
3547 StructRNA *srna;
3548
3551
3552 for (srna = static_cast<StructRNA *>(brna->structs.first); srna;
3553 srna = static_cast<StructRNA *>(srna->cont.next))
3554 {
3556 }
3557
3558 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
3559 ds = static_cast<StructDefRNA *>(ds->cont.next))
3560 {
3562 }
3563}
3564
3566{
3567 switch (type) {
3568 case PROP_BOOLEAN:
3569 return "BoolPropertyRNA";
3570 case PROP_INT:
3571 return "IntPropertyRNA";
3572 case PROP_FLOAT:
3573 return "FloatPropertyRNA";
3574 case PROP_STRING:
3575 return "StringPropertyRNA";
3576 case PROP_ENUM:
3577 return "EnumPropertyRNA";
3578 case PROP_POINTER:
3579 return "PointerPropertyRNA";
3580 case PROP_COLLECTION:
3581 return "CollectionPropertyRNA";
3582 default:
3583 return "UnknownPropertyRNA";
3584 }
3585}
3586
3588{
3589 switch (type) {
3590 case PROP_NONE:
3591 return "PROP_NONE";
3592 case PROP_FILEPATH:
3593 return "PROP_FILEPATH";
3594 case PROP_FILENAME:
3595 return "PROP_FILENAME";
3596 case PROP_DIRPATH:
3597 return "PROP_DIRPATH";
3598 case PROP_PIXEL:
3599 return "PROP_PIXEL";
3600 case PROP_BYTESTRING:
3601 return "PROP_BYTESTRING";
3602 case PROP_UNSIGNED:
3603 return "PROP_UNSIGNED";
3604 case PROP_PERCENTAGE:
3605 return "PROP_PERCENTAGE";
3606 case PROP_FACTOR:
3607 return "PROP_FACTOR";
3608 case PROP_ANGLE:
3609 return "PROP_ANGLE";
3610 case PROP_TIME:
3611 return "PROP_TIME";
3612 case PROP_TIME_ABSOLUTE:
3613 return "PROP_TIME_ABSOLUTE";
3614 case PROP_DISTANCE:
3615 return "PROP_DISTANCE";
3617 return "PROP_DISTANCE_CAMERA";
3618 case PROP_COLOR:
3619 return "PROP_COLOR";
3620 case PROP_TRANSLATION:
3621 return "PROP_TRANSLATION";
3622 case PROP_DIRECTION:
3623 return "PROP_DIRECTION";
3624 case PROP_MATRIX:
3625 return "PROP_MATRIX";
3626 case PROP_EULER:
3627 return "PROP_EULER";
3628 case PROP_QUATERNION:
3629 return "PROP_QUATERNION";
3630 case PROP_AXISANGLE:
3631 return "PROP_AXISANGLE";
3632 case PROP_VELOCITY:
3633 return "PROP_VELOCITY";
3634 case PROP_ACCELERATION:
3635 return "PROP_ACCELERATION";
3636 case PROP_XYZ:
3637 return "PROP_XYZ";
3638 case PROP_COLOR_GAMMA:
3639 return "PROP_COLOR_GAMMA";
3640 case PROP_COORDS:
3641 return "PROP_COORDS";
3642 case PROP_LAYER:
3643 return "PROP_LAYER";
3644 case PROP_LAYER_MEMBER:
3645 return "PROP_LAYER_MEMBER";
3646 case PROP_PASSWORD:
3647 return "PROP_PASSWORD";
3648 case PROP_POWER:
3649 return "PROP_POWER";
3650 case PROP_TEMPERATURE:
3651 return "PROP_TEMPERATURE";
3652 case PROP_WAVELENGTH:
3653 return "PROP_WAVELENGTH";
3655 return "PROP_COLOR_TEMPERATURE";
3656 case PROP_FREQUENCY:
3657 return "PROP_FREQUENCY";
3658 default: {
3659 /* in case we don't have a type preset that includes the subtype */
3660 if (RNA_SUBTYPE_UNIT(type)) {
3662 }
3663 return "PROP_SUBTYPE_UNKNOWN";
3664 }
3665 }
3666}
3667
3669{
3670 switch (RNA_SUBTYPE_UNIT(type)) {
3671 case PROP_UNIT_NONE:
3672 return "PROP_UNIT_NONE";
3673 case PROP_UNIT_LENGTH:
3674 return "PROP_UNIT_LENGTH";
3675 case PROP_UNIT_AREA:
3676 return "PROP_UNIT_AREA";
3677 case PROP_UNIT_VOLUME:
3678 return "PROP_UNIT_VOLUME";
3679 case PROP_UNIT_MASS:
3680 return "PROP_UNIT_MASS";
3681 case PROP_UNIT_ROTATION:
3682 return "PROP_UNIT_ROTATION";
3683 case PROP_UNIT_TIME:
3684 return "PROP_UNIT_TIME";
3686 return "PROP_UNIT_TIME_ABSOLUTE";
3687 case PROP_UNIT_VELOCITY:
3688 return "PROP_UNIT_VELOCITY";
3690 return "PROP_UNIT_ACCELERATION";
3691 case PROP_UNIT_CAMERA:
3692 return "PROP_UNIT_CAMERA";
3693 case PROP_UNIT_POWER:
3694 return "PROP_UNIT_POWER";
3696 return "PROP_UNIT_TEMPERATURE";
3698 return "PROP_UNIT_WAVELENGTH";
3700 return "PROP_UNIT_COLOR_TEMPERATURE";
3702 return "PROP_UNIT_FREQUENCY";
3703 default:
3704 return "PROP_UNIT_UNKNOWN";
3705 }
3706}
3707
3709{
3710 StructRNA *srna;
3711
3712 for (srna = static_cast<StructRNA *>(brna->structs.first); srna;
3713 srna = static_cast<StructRNA *>(srna->cont.next))
3714 {
3715 fprintf(f, "extern struct StructRNA RNA_%s;\n", srna->identifier);
3716 }
3717 fprintf(f, "\n");
3718}
3719
3720static void rna_generate_blender(BlenderRNA *brna, FILE *f)
3721{
3722 StructRNA *srna;
3723
3724 fprintf(f,
3725 "BlenderRNA BLENDER_RNA = {\n"
3726 "\t/*structs*/ {");
3727 srna = static_cast<StructRNA *>(brna->structs.first);
3728 if (srna) {
3729 fprintf(f, "&RNA_%s, ", srna->identifier);
3730 }
3731 else {
3732 fprintf(f, "nullptr, ");
3733 }
3734
3735 srna = static_cast<StructRNA *>(brna->structs.last);
3736 if (srna) {
3737 fprintf(f, "&RNA_%s},\n", srna->identifier);
3738 }
3739 else {
3740 fprintf(f, "nullptr},\n");
3741 }
3742
3743 fprintf(f,
3744 "\t/*structs_map*/ nullptr,\n"
3745 "\t/*structs_len*/ 0,\n"
3746 "};\n\n");
3747}
3748
3750{
3751 fprintf(f, "struct PropertyRNA;\n\n");
3752
3754
3755 /* NOTE: Generate generic `PropertyRNA &` references. The actual, type-refined properties data
3756 * are static variables in their translation units (the `_gen.cc` files), which are assigned to
3757 * these public generic `PointerRNA &` references. */
3758 for (StructRNA *srna = static_cast<StructRNA *>(brna->structs.first); srna;
3759 srna = static_cast<StructRNA *>(srna->cont.next))
3760 {
3761 LISTBASE_FOREACH (PropertyRNA *, prop, &srna->cont.properties) {
3762 fprintf(f, "extern PropertyRNA &rna_%s_%s;\n", srna->identifier, prop->identifier);
3763 }
3764 fprintf(f, "\n");
3765 }
3766}
3767
3769 StructRNA *srna,
3770 FILE *f)
3771{
3772 StructRNA *base;
3773
3774 /* NOTE: Generic `PropertyRNA &` references, see #rna_generate_external_property_prototypes
3775 * comments for details. */
3776 base = srna->base;
3777 while (base) {
3778 fprintf(f, "\n");
3779 LISTBASE_FOREACH (PropertyRNA *, prop, &base->cont.properties) {
3780 fprintf(f, "extern PropertyRNA &rna_%s_%s;\n", base->identifier, prop->identifier);
3781 }
3782 base = base->base;
3783 }
3784
3785 if (srna->cont.properties.first) {
3786 fprintf(f, "\n");
3787 }
3788
3789 LISTBASE_FOREACH (PropertyRNA *, prop, &srna->cont.properties) {
3790 fprintf(f, "extern PropertyRNA &rna_%s_%s;\n", srna->identifier, prop->identifier);
3791 }
3792 fprintf(f, "\n");
3793}
3794
3796 StructRNA *srna,
3797 FunctionRNA *func,
3798 FILE *f)
3799{
3800 /* NOTE: Generic `PropertyRNA &` references, see #rna_generate_external_property_prototypes
3801 * comments for details. */
3802 LISTBASE_FOREACH (PropertyRNA *, parm, &func->cont.properties) {
3803 fprintf(f,
3804 "extern PropertyRNA &rna_%s_%s_%s;\n",
3805 srna->identifier,
3806 func->identifier,
3807 parm->identifier);
3808 }
3809
3810 if (func->cont.properties.first) {
3811 fprintf(f, "\n");
3812 }
3813}
3814
3816{
3817 FunctionRNA *func;
3818 StructRNA *base;
3819
3820 base = srna->base;
3821 while (base) {
3822 for (func = static_cast<FunctionRNA *>(base->functions.first); func;
3823 func = static_cast<FunctionRNA *>(func->cont.next))
3824 {
3825 fprintf(f, "extern FunctionRNA rna_%s_%s_func;\n", base->identifier, func->identifier);
3826 rna_generate_parameter_prototypes(brna, base, func, f);
3827 }
3828
3829 if (base->functions.first) {
3830 fprintf(f, "\n");
3831 }
3832
3833 base = base->base;
3834 }
3835
3836 for (func = static_cast<FunctionRNA *>(srna->functions.first); func;
3837 func = static_cast<FunctionRNA *>(func->cont.next))
3838 {
3839 fprintf(f, "extern FunctionRNA rna_%s_%s_func;\n", srna->identifier, func->identifier);
3840 rna_generate_parameter_prototypes(brna, srna, func, f);
3841 }
3842
3843 if (srna->functions.first) {
3844 fprintf(f, "\n");
3845 }
3846}
3847
3849 StructRNA *srna,
3850 FunctionDefRNA *dfunc,
3851 const char *name_override,
3852 int close_prototype)
3853{
3854 FunctionRNA *func;
3855 PropertyDefRNA *dparm_return = nullptr;
3856 StructDefRNA *dsrna;
3857 PropertyType type;
3858 int flag, flag_parameter, pout, cptr, first;
3859 const char *ptrstr;
3860
3861 dsrna = rna_find_struct_def(srna);
3862 func = dfunc->func;
3863
3864 /* return type */
3865 LISTBASE_FOREACH (PropertyDefRNA *, dparm, &dfunc->cont.properties) {
3866 if (dparm->prop == func->c_ret) {
3867 if (dparm->prop->arraydimension) {
3868 fprintf(f, "XXX no array return types yet"); /* XXX not supported */
3869 }
3870 else if (dparm->prop->type == PROP_POINTER && !(dparm->prop->flag_parameter & PARM_RNAPTR)) {
3871 fprintf(f, "%s%s *", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
3872 }
3873 else {
3874 fprintf(f, "%s%s ", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
3875 }
3876
3877 dparm_return = dparm;
3878 break;
3879 }
3880 }
3881
3882 /* void if nothing to return */
3883 if (!dparm_return) {
3884 fprintf(f, "void ");
3885 }
3886
3887 /* function name */
3888 if (name_override == nullptr || name_override[0] == '\0') {
3889 fprintf(f, "%s(", dfunc->call);
3890 }
3891 else {
3892 fprintf(f, "%s(", name_override);
3893 }
3894
3895 first = 1;
3896
3897 /* self, context and reports parameters */
3898 if (func->flag & FUNC_USE_SELF_ID) {
3899 fprintf(f, "struct ID *_selfid");
3900 first = 0;
3901 }
3902
3903 if ((func->flag & FUNC_NO_SELF) == 0) {
3904 if (!first) {
3905 fprintf(f, ", ");
3906 }
3907 if (dsrna->dnafromprop) {
3908 fprintf(f, "struct %s *_self", dsrna->dnafromname);
3909 }
3910 else if (dsrna->dnaname) {
3911 fprintf(f, "struct %s *_self", dsrna->dnaname);
3912 }
3913 else {
3914 fprintf(f, "struct %s *_self", srna->identifier);
3915 }
3916 first = 0;
3917 }
3918 else if (func->flag & FUNC_USE_SELF_TYPE) {
3919 if (!first) {
3920 fprintf(f, ", ");
3921 }
3922 fprintf(f, "struct StructRNA *_type");
3923 first = 0;
3924 }
3925
3926 if (func->flag & FUNC_USE_MAIN) {
3927 if (!first) {
3928 fprintf(f, ", ");
3929 }
3930 first = 0;
3931 fprintf(f, "Main *bmain");
3932 }
3933
3934 if (func->flag & FUNC_USE_CONTEXT) {
3935 if (!first) {
3936 fprintf(f, ", ");
3937 }
3938 first = 0;
3939 fprintf(f, "bContext *C");
3940 }
3941
3942 if (func->flag & FUNC_USE_REPORTS) {
3943 if (!first) {
3944 fprintf(f, ", ");
3945 }
3946 first = 0;
3947 fprintf(f, "ReportList *reports");
3948 }
3949
3950 /* defined parameters */
3951 LISTBASE_FOREACH (PropertyDefRNA *, dparm, &dfunc->cont.properties) {
3952 type = dparm->prop->type;
3953 flag = dparm->prop->flag;
3954 flag_parameter = dparm->prop->flag_parameter;
3955 pout = (flag_parameter & PARM_OUTPUT);
3956 cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
3957
3958 if (dparm->prop == func->c_ret) {
3959 continue;
3960 }
3961
3962 if (cptr || (flag & PROP_DYNAMIC)) {
3963 if (type == PROP_STRING) {
3964 ptrstr = pout ? "*" : "";
3965 }
3966 else {
3967 ptrstr = pout ? "**" : "*";
3968 }
3969 }
3970 else if (type == PROP_POINTER || dparm->prop->arraydimension) {
3971 ptrstr = "*";
3972 }
3973 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
3974 ptrstr = "";
3975 }
3976 else {
3977 ptrstr = pout ? "*" : "";
3978 }
3979
3980 if (!first) {
3981 fprintf(f, ", ");
3982 }
3983 first = 0;
3984
3985 if (flag & PROP_DYNAMIC) {
3986 fprintf(f, "int %s%s_num, ", pout ? "*" : "", dparm->prop->identifier);
3987 }
3988
3989 if (!(flag & PROP_DYNAMIC) && dparm->prop->arraydimension) {
3990 fprintf(f,
3991 "%s%s %s[%u]",
3992 rna_type_struct(dparm->prop),
3993 rna_parameter_type_name(dparm->prop),
3994 rna_safe_id(dparm->prop->identifier),
3995 dparm->prop->totarraylength);
3996 }
3997 else {
3998 fprintf(f,
3999 "%s%s %s%s",
4000 rna_type_struct(dparm->prop),
4001 rna_parameter_type_name(dparm->prop),
4002 ptrstr,
4003 rna_safe_id(dparm->prop->identifier));
4004 }
4005 }
4006
4007 /* ensure func(void) if there are no args */
4008 if (first) {
4009 fprintf(f, "void");
4010 }
4011
4012 fprintf(f, ")");
4013
4014 if (close_prototype) {
4015 fprintf(f, ";\n");
4016 }
4017}
4018
4020 StructRNA *srna,
4021 FILE *f)
4022{
4023 FunctionRNA *func;
4024 FunctionDefRNA *dfunc;
4025 int first = 1;
4026
4027 for (func = static_cast<FunctionRNA *>(srna->functions.first); func;
4028 func = static_cast<FunctionRNA *>(func->cont.next))
4029 {
4030 dfunc = rna_find_function_def(func);
4031
4032 if (dfunc->call) {
4033 if (strstr(dfunc->call, "<")) {
4034 /* Can't generate the declaration for templates. We'll still get compile errors when trying
4035 * to call it with a wrong signature. */
4036 continue;
4037 }
4038
4039 if (first) {
4040 fprintf(f, "/* Repeated prototypes to detect errors */\n\n");
4041 first = 0;
4042 }
4043
4044 rna_generate_static_parameter_prototypes(f, srna, dfunc, nullptr, 1);
4045 }
4046 }
4047
4048 fprintf(f, "\n");
4049}
4050
4052{
4053 StructDefRNA *ds;
4054 FunctionDefRNA *dfunc;
4055 const char *structures[2048];
4056 int all_structures = 0;
4057
4058 /* structures definitions */
4059 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
4060 ds = static_cast<StructDefRNA *>(ds->cont.next))
4061 {
4062 for (dfunc = static_cast<FunctionDefRNA *>(ds->functions.first); dfunc;
4063 dfunc = static_cast<FunctionDefRNA *>(dfunc->cont.next))
4064 {
4065 if (dfunc->call) {
4067 if (dp->prop->type == PROP_POINTER) {
4068 int a, found = 0;
4069 const char *struct_name = rna_parameter_type_name(dp->prop);
4070 if (struct_name == nullptr) {
4071 printf("No struct found for property '%s'\n", dp->prop->identifier);
4072 exit(1);
4073 }
4074
4075 for (a = 0; a < all_structures; a++) {
4076 if (STREQ(struct_name, structures[a])) {
4077 found = 1;
4078 break;
4079 }
4080 }
4081
4082 if (found == 0) {
4083 fprintf(f, "struct %s;\n", struct_name);
4084
4085 if (all_structures >= ARRAY_SIZE(structures)) {
4086 printf("Array size to store all structures names is too small\n");
4087 exit(1);
4088 }
4089
4090 structures[all_structures++] = struct_name;
4091 }
4092 }
4093 }
4094 }
4095 }
4096 }
4097
4098 fprintf(f, "\n");
4099}
4100
4101static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, PropertyRNA *prop)
4102{
4103 char *strnest = (char *)"", *errnest = (char *)"";
4104 bool freenest = false;
4105
4106 if (nest != nullptr) {
4107 size_t len = strlen(nest);
4108
4109 strnest = MEM_malloc_arrayN<char>(len + 2, "rna_generate_property -> strnest");
4110 errnest = MEM_malloc_arrayN<char>(len + 2, "rna_generate_property -> errnest");
4111
4112 strnest[0] = '_';
4113 memcpy(strnest + 1, nest, len + 1);
4114
4115 errnest[0] = '.';
4116 memcpy(errnest + 1, nest, len + 1);
4117
4118 freenest = true;
4119 }
4120
4121 switch (prop->type) {
4122 case PROP_ENUM: {
4123 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
4124 int i, defaultfound = 0, totflag = 0;
4125
4126 if (eprop->item) {
4127 /* Inline the enum if this is not a defined in "RNA_enum_items.hh". */
4128 const char *item_global_id = rna_enum_id_from_pointer(eprop->item);
4129 if (item_global_id == nullptr) {
4130 fprintf(f,
4131 "static const EnumPropertyItem rna_%s%s_%s_items[%d] = {\n\t",
4132 srna->identifier,
4133 strnest,
4134 prop->identifier,
4135 eprop->totitem + 1);
4136
4137 for (i = 0; i < eprop->totitem; i++) {
4138 fprintf(f, "{%d, ", eprop->item[i].value);
4139 rna_print_c_string(f, eprop->item[i].identifier);
4140 fprintf(f, ", ");
4141 fprintf(f, "%d, ", eprop->item[i].icon);
4142 rna_print_c_string(f, eprop->item[i].name);
4143 fprintf(f, ", ");
4145 fprintf(f, "},\n\t");
4146
4147 if (eprop->item[i].identifier[0]) {
4148 if (prop->flag & PROP_ENUM_FLAG) {
4149 totflag |= eprop->item[i].value;
4150 }
4151 else {
4152 if (eprop->defaultvalue == eprop->item[i].value) {
4153 defaultfound = 1;
4154 }
4155 }
4156 }
4157 }
4158
4159 fprintf(f, "{0, nullptr, 0, nullptr, nullptr}\n};\n\n");
4160 }
4161 else {
4162 for (i = 0; i < eprop->totitem; i++) {
4163 if (eprop->item[i].identifier[0]) {
4164 if (prop->flag & PROP_ENUM_FLAG) {
4165 totflag |= eprop->item[i].value;
4166 }
4167 else {
4168 if (eprop->defaultvalue == eprop->item[i].value) {
4169 defaultfound = 1;
4170 }
4171 }
4172 }
4173 }
4174 }
4175
4176 if (prop->flag & PROP_ENUM_FLAG) {
4177 if (eprop->defaultvalue & ~totflag) {
4178 CLOG_ERROR(&LOG,
4179 "%s%s.%s, enum default includes unused bits (%d).",
4180 srna->identifier,
4181 errnest,
4182 prop->identifier,
4183 eprop->defaultvalue & ~totflag);
4184 DefRNA.error = true;
4185 }
4186 }
4187 else {
4188 if (!defaultfound && !(eprop->item_fn && eprop->item == rna_enum_dummy_NULL_items)) {
4189 CLOG_ERROR(&LOG,
4190 "%s%s.%s, enum default is not in items.",
4191 srna->identifier,
4192 errnest,
4193 prop->identifier);
4194 DefRNA.error = true;
4195 }
4196 }
4197 }
4198 else {
4199 CLOG_ERROR(&LOG,
4200 "%s%s.%s, enum must have items defined.",
4201 srna->identifier,
4202 errnest,
4203 prop->identifier);
4204 DefRNA.error = true;
4205 }
4206 break;
4207 }
4208 case PROP_BOOLEAN: {
4209 BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
4210 uint i;
4211
4212 if (prop->arraydimension && prop->totarraylength) {
4213 fprintf(f,
4214 "static bool rna_%s%s_%s_default[%u] = {\n\t",
4215 srna->identifier,
4216 strnest,
4217 prop->identifier,
4218 prop->totarraylength);
4219
4220 for (i = 0; i < prop->totarraylength; i++) {
4221 if (bprop->defaultarray) {
4222 fprintf(f, "%d", bprop->defaultarray[i]);
4223 }
4224 else {
4225 fprintf(f, "%d", bprop->defaultvalue);
4226 }
4227 if (i != prop->totarraylength - 1) {
4228 fprintf(f, ",\n\t");
4229 }
4230 }
4231
4232 fprintf(f, "\n};\n\n");
4233 }
4234 break;
4235 }
4236 case PROP_INT: {
4237 IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
4238 uint i;
4239
4240 if (prop->arraydimension && prop->totarraylength) {
4241 fprintf(f,
4242 "static int rna_%s%s_%s_default[%u] = {\n\t",
4243 srna->identifier,
4244 strnest,
4245 prop->identifier,
4246 prop->totarraylength);
4247
4248 for (i = 0; i < prop->totarraylength; i++) {
4249 if (iprop->defaultarray) {
4250 fprintf(f, "%d", iprop->defaultarray[i]);
4251 }
4252 else {
4253 fprintf(f, "%d", iprop->defaultvalue);
4254 }
4255 if (i != prop->totarraylength - 1) {
4256 fprintf(f, ",\n\t");
4257 }
4258 }
4259
4260 fprintf(f, "\n};\n\n");
4261 }
4262 break;
4263 }
4264 case PROP_FLOAT: {
4265 FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
4266 uint i;
4267
4268 if (prop->arraydimension && prop->totarraylength) {
4269 fprintf(f,
4270 "static float rna_%s%s_%s_default[%u] = {\n\t",
4271 srna->identifier,
4272 strnest,
4273 prop->identifier,
4274 prop->totarraylength);
4275
4276 for (i = 0; i < prop->totarraylength; i++) {
4277 if (fprop->defaultarray) {
4278 rna_float_print(f, fprop->defaultarray[i]);
4279 }
4280 else {
4281 rna_float_print(f, fprop->defaultvalue);
4282 }
4283 if (i != prop->totarraylength - 1) {
4284 fprintf(f, ",\n\t");
4285 }
4286 }
4287
4288 fprintf(f, "\n};\n\n");
4289 }
4290 break;
4291 }
4292 case PROP_POINTER: {
4293 PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
4294
4295 /* XXX This systematically enforces that flag on ID pointers...
4296 * we'll probably have to revisit. :/ */
4297 StructRNA *type = rna_find_struct((const char *)pprop->type);
4298 if (type && (type->flag & STRUCT_ID) &&
4300 {
4302 }
4303 break;
4304 }
4305 case PROP_COLLECTION: {
4307
4308 /* XXX This systematically enforces that flag on ID pointers...
4309 * we'll probably have to revisit. :/ */
4310 StructRNA *type = rna_find_struct((const char *)cprop->item_type);
4311 if (type && (type->flag & STRUCT_ID) &&
4313 {
4315 }
4316 break;
4317 }
4318 default:
4319 break;
4320 }
4321
4322 /* Generate the RNA-private, type-refined property data.
4323 *
4324 * See #rna_generate_external_property_prototypes comments for details. */
4325 fprintf(f,
4326 "static %s rna_%s%s_%s_ = {\n",
4328 srna->identifier,
4329 strnest,
4330 prop->identifier);
4331
4332 if (prop->next) {
4333 fprintf(f, "\t{&rna_%s%s_%s, ", srna->identifier, strnest, prop->next->identifier);
4334 }
4335 else {
4336 fprintf(f, "\t{nullptr, ");
4337 }
4338 if (prop->prev) {
4339 fprintf(f, "&rna_%s%s_%s,\n", srna->identifier, strnest, prop->prev->identifier);
4340 }
4341 else {
4342 fprintf(f, "nullptr,\n");
4343 }
4344 fprintf(f, "\t%d, ", prop->magic);
4346 fprintf(f,
4347 ", %d, %d, %d, %d, %d, ",
4348 prop->flag,
4349 prop->flag_override,
4350 prop->flag_parameter,
4351 prop->flag_internal,
4352 prop->tags);
4353 fprintf(f, "PropertyPathTemplateType(%d), ", prop->path_template_type);
4354 rna_print_c_string(f, prop->name);
4355 fprintf(f, ",\n\t");
4357 fprintf(f, ",\n\t");
4358 fprintf(f, "%d, ", prop->icon);
4360 fprintf(f, ",\n");
4361 fprintf(f,
4362 "\t%s, PropertySubType(int(%s) | int(%s)), %s, %u, {%u, %u, %u}, %u,\n",
4367 prop->arraydimension,
4368 prop->arraylength[0],
4369 prop->arraylength[1],
4370 prop->arraylength[2],
4371 prop->totarraylength);
4372 fprintf(f,
4373 "\t%s%s, %d, %s, %s, %s, %s, %s,\n",
4374 /* NOTE: void cast is needed to quiet function cast warning in C++. */
4375 (prop->flag & PROP_CONTEXT_UPDATE) ? "(UpdateFunc)(void *)" : "",
4377 prop->noteflag,
4383
4385 rna_set_raw_offset(f, srna, prop);
4386 }
4387 else {
4388 fprintf(f, "\t0, PROP_RAW_UNSET");
4389 }
4390
4391 /* our own type - collections/arrays only */
4392 if (prop->srna) {
4393 fprintf(f, ", &RNA_%s", (const char *)prop->srna);
4394 }
4395 else {
4396 fprintf(f, ", nullptr");
4397 }
4398
4399 fprintf(f, "},\n");
4400
4401 switch (prop->type) {
4402 case PROP_BOOLEAN: {
4403 BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
4404 fprintf(f,
4405 "\t%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, ",
4406 rna_function_string(bprop->get),
4407 rna_function_string(bprop->set),
4416 bprop->defaultvalue);
4417 if (prop->arraydimension && prop->totarraylength) {
4418 fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
4419 }
4420 else {
4421 fprintf(f, "nullptr\n");
4422 }
4423 break;
4424 }
4425 case PROP_INT: {
4426 IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
4427 fprintf(f,
4428 "\t%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,\n\t",
4429 rna_function_string(iprop->get),
4430 rna_function_string(iprop->set),
4433 rna_function_string(iprop->range),
4439 fprintf(f, "%s", rna_ui_scale_type_string(iprop->ui_scale_type));
4440 fprintf(f, ", ");
4441 rna_int_print(f, iprop->softmin);
4442 fprintf(f, ", ");
4443 rna_int_print(f, iprop->softmax);
4444 fprintf(f, ", ");
4445 rna_int_print(f, iprop->hardmin);
4446 fprintf(f, ", ");
4447 rna_int_print(f, iprop->hardmax);
4448 fprintf(f, ", ");
4449 rna_int_print(f, iprop->step);
4450 fprintf(f, ", ");
4451 fprintf(f,
4452 "%s, %s",
4455 fprintf(f, ", ");
4456 rna_int_print(f, iprop->defaultvalue);
4457 fprintf(f, ", ");
4458 if (prop->arraydimension && prop->totarraylength) {
4459 fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
4460 }
4461 else {
4462 fprintf(f, "nullptr\n");
4463 }
4464 break;
4465 }
4466 case PROP_FLOAT: {
4467 FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
4468 fprintf(f,
4469 "\t%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, ",
4470 rna_function_string(fprop->get),
4471 rna_function_string(fprop->set),
4474 rna_function_string(fprop->range),
4480 fprintf(f, "%s, ", rna_ui_scale_type_string(fprop->ui_scale_type));
4481 rna_float_print(f, fprop->softmin);
4482 fprintf(f, ", ");
4483 rna_float_print(f, fprop->softmax);
4484 fprintf(f, ", ");
4485 rna_float_print(f, fprop->hardmin);
4486 fprintf(f, ", ");
4487 rna_float_print(f, fprop->hardmax);
4488 fprintf(f, ", ");
4489 rna_float_print(f, fprop->step);
4490 fprintf(f, ", ");
4491 rna_int_print(f, fprop->precision);
4492 fprintf(f, ", ");
4493 fprintf(f,
4494 "%s, %s",
4497 fprintf(f, ", ");
4498 rna_float_print(f, fprop->defaultvalue);
4499 fprintf(f, ", ");
4500 if (prop->arraydimension && prop->totarraylength) {
4501 fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
4502 }
4503 else {
4504 fprintf(f, "nullptr\n");
4505 }
4506 break;
4507 }
4508 case PROP_STRING: {
4509 StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
4510 fprintf(f,
4511 "\t%s, %s, %s, %s, %s, %s, %s, eStringPropertySearchFlag(%d), %s, %d, ",
4512 rna_function_string(sprop->get),
4514 rna_function_string(sprop->set),
4519 int(sprop->search_flag),
4521 sprop->maxlength);
4523 fprintf(f, "\n");
4524 break;
4525 }
4526 case PROP_ENUM: {
4527 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
4528 fprintf(f,
4529 "\t%s, %s, %s, %s, %s, %s, ",
4530 rna_function_string(eprop->get),
4531 rna_function_string(eprop->set),
4536 if (eprop->item) {
4537 const char *item_global_id = rna_enum_id_from_pointer(eprop->item);
4538 if (item_global_id != nullptr) {
4539 fprintf(f, "%s, ", item_global_id);
4540 }
4541 else {
4542 fprintf(f, "rna_%s%s_%s_items, ", srna->identifier, strnest, prop->identifier);
4543 }
4544 }
4545 else {
4546 fprintf(f, "nullptr, ");
4547 }
4548 fprintf(f, "%d, %d\n", eprop->totitem, eprop->defaultvalue);
4549 break;
4550 }
4551 case PROP_POINTER: {
4552 PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
4553 fprintf(f,
4554 "\t%s, %s, %s, %s,",
4555 rna_function_string(pprop->get),
4556 rna_function_string(pprop->set),
4558 rna_function_string(pprop->poll));
4559 if (pprop->type) {
4560 fprintf(f, "&RNA_%s\n", (const char *)pprop->type);
4561 }
4562 else {
4563 fprintf(f, "nullptr\n");
4564 }
4565 break;
4566 }
4567 case PROP_COLLECTION: {
4569 fprintf(f,
4570 "\t%s, %s, %s, %s, %s, %s, %s, %s, ",
4571 rna_function_string(cprop->begin),
4572 rna_function_string(cprop->next),
4573 rna_function_string(cprop->end),
4574 rna_function_string(cprop->get),
4579 if (cprop->item_type) {
4580 fprintf(f, "&RNA_%s\n", (const char *)cprop->item_type);
4581 }
4582 else {
4583 fprintf(f, "nullptr\n");
4584 }
4585 break;
4586 }
4587 }
4588
4589 fprintf(f, "};\n");
4590
4591 /* Assign the RNA-private, type-refined static (local) property data to the public matching
4592 * generic `PropertyRNA &` reference.
4593 *
4594 * See #rna_generate_external_property_prototypes comments for details. */
4595 fprintf(
4596 f,
4597 /* Use a reference here instead of a pointer, because pointer usage somehow makes clang
4598 * optimizer take a very long time to compile the `rna_xxx_gen.cc` files (see faf56cc3bf).
4599 *
4600 * Note that in theory, any access to the 'public' `PointerRNA &` reference data is
4601 * undefined behavior (strict aliasing rules). This is currently not a real issue (these
4602 * PropertyRNA definitions are almost always only used as pointers, and are currently POD
4603 * types).
4604 *
4605 * `reinterpret_cast<PropertyRNA &>(rna_prop_data)` here is same as
4606 * `*reinterpret_cast<PropertyRNA *>(&rna_prop_data)` (see point (6) of
4607 * https://en.cppreference.com/w/cpp/language/reinterpret_cast). */
4608 "PropertyRNA &rna_%s%s_%s = reinterpret_cast<PropertyRNA &>(rna_%s%s_%s_);\n\n",
4609 srna->identifier,
4610 strnest,
4611 prop->identifier,
4612 srna->identifier,
4613 strnest,
4614 prop->identifier);
4615
4616 if (freenest) {
4617 MEM_freeN(strnest);
4618 MEM_freeN(errnest);
4619 }
4620}
4621
4622static void rna_generate_struct(BlenderRNA * /*brna*/, StructRNA *srna, FILE *f)
4623{
4624 FunctionRNA *func;
4625 FunctionDefRNA *dfunc;
4626 PropertyRNA *prop, *parm;
4627 StructRNA *base;
4628
4629 fprintf(f, "/* %s */\n", srna->name);
4630
4631 LISTBASE_FOREACH (PropertyRNA *, prop, &srna->cont.properties) {
4632 rna_generate_property(f, srna, nullptr, prop);
4633 }
4634
4635 for (func = static_cast<FunctionRNA *>(srna->functions.first); func;
4636 func = static_cast<FunctionRNA *>(func->cont.next))
4637 {
4638 LISTBASE_FOREACH (PropertyRNA *, parm, &func->cont.properties) {
4639 rna_generate_property(f, srna, func->identifier, parm);
4640 }
4641
4642 fprintf(f, "%s%s rna_%s_%s_func = {\n", "", "FunctionRNA", srna->identifier, func->identifier);
4643
4644 if (func->cont.next) {
4645 fprintf(f,
4646 "\t{(FunctionRNA *)&rna_%s_%s_func, ",
4647 srna->identifier,
4648 ((FunctionRNA *)func->cont.next)->identifier);
4649 }
4650 else {
4651 fprintf(f, "\t{nullptr, ");
4652 }
4653 if (func->cont.prev) {
4654 fprintf(f,
4655 "(FunctionRNA *)&rna_%s_%s_func,\n",
4656 srna->identifier,
4657 ((FunctionRNA *)func->cont.prev)->identifier);
4658 }
4659 else {
4660 fprintf(f, "nullptr,\n");
4661 }
4662
4663 fprintf(f, "\tnullptr,\n");
4664
4665 parm = static_cast<PropertyRNA *>(func->cont.properties.first);
4666 if (parm) {
4667 fprintf(f, "\t{&rna_%s_%s_%s, ", srna->identifier, func->identifier, parm->identifier);
4668 }
4669 else {
4670 fprintf(f, "\t{nullptr, ");
4671 }
4672
4673 parm = static_cast<PropertyRNA *>(func->cont.properties.last);
4674 if (parm) {
4675 fprintf(f, "&rna_%s_%s_%s}},\n", srna->identifier, func->identifier, parm->identifier);
4676 }
4677 else {
4678 fprintf(f, "nullptr}},\n");
4679 }
4680
4681 fprintf(f, "\t");
4683 fprintf(f, ", %d, ", func->flag);
4685 fprintf(f, ",\n");
4686
4687 dfunc = rna_find_function_def(func);
4688 if (dfunc->gencall) {
4689 fprintf(f, "\t%s,\n", dfunc->gencall);
4690 }
4691 else {
4692 fprintf(f, "\tnullptr,\n");
4693 }
4694
4695 if (func->c_ret) {
4696 fprintf(f, "\t&rna_%s_%s_%s\n", srna->identifier, func->identifier, func->c_ret->identifier);
4697 }
4698 else {
4699 fprintf(f, "\tnullptr\n");
4700 }
4701
4702 fprintf(f, "};\n");
4703 fprintf(f, "\n");
4704 }
4705
4706 fprintf(f, "StructRNA RNA_%s = {\n", srna->identifier);
4707
4708 if (srna->cont.next) {
4709 fprintf(f, "\t{(ContainerRNA *)&RNA_%s, ", ((StructRNA *)srna->cont.next)->identifier);
4710 }
4711 else {
4712 fprintf(f, "\t{nullptr, ");
4713 }
4714 if (srna->cont.prev) {
4715 fprintf(f, "(ContainerRNA *)&RNA_%s,\n", ((StructRNA *)srna->cont.prev)->identifier);
4716 }
4717 else {
4718 fprintf(f, "nullptr,\n");
4719 }
4720
4721 fprintf(f, "\tnullptr,\n");
4722
4723 prop = static_cast<PropertyRNA *>(srna->cont.properties.first);
4724 if (prop) {
4725 fprintf(f, "\t{&rna_%s_%s, ", srna->identifier, prop->identifier);
4726 }
4727 else {
4728 fprintf(f, "\t{nullptr, ");
4729 }
4730
4731 prop = static_cast<PropertyRNA *>(srna->cont.properties.last);
4732 if (prop) {
4733 fprintf(f, "&rna_%s_%s}},\n", srna->identifier, prop->identifier);
4734 }
4735 else {
4736 fprintf(f, "nullptr}},\n");
4737 }
4738 fprintf(f, "\t");
4740 fprintf(f, ", nullptr, nullptr"); /* PyType - Can't initialize here */
4741 fprintf(f, ", %d, nullptr, ", srna->flag);
4742 rna_print_c_string(f, srna->name);
4743 fprintf(f, ",\n\t");
4745 fprintf(f, ",\n\t");
4747 fprintf(f, ", %d,\n", srna->icon);
4748
4749 prop = srna->nameproperty;
4750 if (prop) {
4751 base = srna;
4752 while (base->base && base->base->nameproperty == prop) {
4753 base = base->base;
4754 }
4755
4756 fprintf(f, "\t&rna_%s_%s, ", base->identifier, prop->identifier);
4757 }
4758 else {
4759 fprintf(f, "\tnullptr, ");
4760 }
4761
4762 prop = srna->iteratorproperty;
4763 base = srna;
4764 while (base->base && base->base->iteratorproperty == prop) {
4765 base = base->base;
4766 }
4767 fprintf(f, "&rna_%s_rna_properties,\n", base->identifier);
4768
4769 if (srna->base) {
4770 fprintf(f, "\t&RNA_%s,\n", srna->base->identifier);
4771 }
4772 else {
4773 fprintf(f, "\tnullptr,\n");
4774 }
4775
4776 if (srna->nested) {
4777 fprintf(f, "\t&RNA_%s,\n", srna->nested->identifier);
4778 }
4779 else {
4780 fprintf(f, "\tnullptr,\n");
4781 }
4782
4783 fprintf(f, "\t%s,\n", rna_function_string(srna->refine));
4784 fprintf(f, "\t%s,\n", rna_function_string(srna->path));
4785 fprintf(f, "\t%s,\n", rna_function_string(srna->reg));
4786 fprintf(f, "\t%s,\n", rna_function_string(srna->unreg));
4787 fprintf(f, "\t%s,\n", rna_function_string(srna->instance));
4788 fprintf(f, "\t%s,\n", rna_function_string(srna->idproperties));
4789
4790 if (srna->reg && !srna->refine) {
4791 CLOG_ERROR(
4792 &LOG, "%s has a register function, must also have refine function.", srna->identifier);
4793 DefRNA.error = true;
4794 }
4795
4796 func = static_cast<FunctionRNA *>(srna->functions.first);
4797 if (func) {
4798 fprintf(f, "\t{(FunctionRNA *)&rna_%s_%s_func, ", srna->identifier, func->identifier);
4799 }
4800 else {
4801 fprintf(f, "\t{nullptr, ");
4802 }
4803
4804 func = static_cast<FunctionRNA *>(srna->functions.last);
4805 if (func) {
4806 fprintf(f, "(FunctionRNA *)&rna_%s_%s_func}\n", srna->identifier, func->identifier);
4807 }
4808 else {
4809 fprintf(f, "nullptr}\n");
4810 }
4811
4812 fprintf(f, "};\n");
4813
4814 fprintf(f, "\n");
4815}
4816
4818 const char *filename;
4819 const char *api_filename;
4820 void (*define)(BlenderRNA *brna);
4821};
4822
4824 {"rna_rna.cc", nullptr, RNA_def_rna},
4825 {"rna_ID.cc", nullptr, RNA_def_ID},
4826 {"rna_texture.cc", "rna_texture_api.cc", RNA_def_texture},
4827 {"rna_action.cc", "rna_action_api.cc", RNA_def_action},
4828 {"rna_animation.cc", "rna_animation_api.cc", RNA_def_animation},
4829 {"rna_animviz.cc", nullptr, RNA_def_animviz},
4830 {"rna_armature.cc", "rna_armature_api.cc", RNA_def_armature},
4831 {"rna_attribute.cc", nullptr, RNA_def_attribute},
4832 {"rna_asset.cc", nullptr, RNA_def_asset},
4833 {"rna_boid.cc", nullptr, RNA_def_boid},
4834 {"rna_brush.cc", nullptr, RNA_def_brush},
4835 {"rna_cachefile.cc", nullptr, RNA_def_cachefile},
4836 {"rna_camera.cc", "rna_camera_api.cc", RNA_def_camera},
4837 {"rna_cloth.cc", nullptr, RNA_def_cloth},
4838 {"rna_collection.cc", nullptr, RNA_def_collections},
4839 {"rna_color.cc", nullptr, RNA_def_color},
4840 {"rna_constraint.cc", nullptr, RNA_def_constraint},
4841 {"rna_context.cc", nullptr, RNA_def_context},
4842 {"rna_curve.cc", "rna_curve_api.cc", RNA_def_curve},
4843 {"rna_dynamicpaint.cc", nullptr, RNA_def_dynamic_paint},
4844 {"rna_fcurve.cc", "rna_fcurve_api.cc", RNA_def_fcurve},
4845 {"rna_annotations.cc", nullptr, RNA_def_annotations},
4846 {"rna_grease_pencil.cc", "rna_grease_pencil_api.cc", RNA_def_grease_pencil},
4847 {"rna_curves.cc", "rna_curves_api.cc", RNA_def_curves},
4848 {"rna_image.cc", "rna_image_api.cc", RNA_def_image},
4849 {"rna_key.cc", nullptr, RNA_def_key},
4850 {"rna_light.cc", nullptr, RNA_def_light},
4851 {"rna_lattice.cc", "rna_lattice_api.cc", RNA_def_lattice},
4852 {"rna_layer.cc", nullptr, RNA_def_view_layer},
4853 {"rna_linestyle.cc", nullptr, RNA_def_linestyle},
4854 {"rna_blendfile_import.cc", nullptr, RNA_def_blendfile_import},
4855 {"rna_main.cc", "rna_main_api.cc", RNA_def_main},
4856 {"rna_fluid.cc", nullptr, RNA_def_fluid},
4857 {"rna_material.cc", "rna_material_api.cc", RNA_def_material},
4858 {"rna_mesh.cc", "rna_mesh_api.cc", RNA_def_mesh},
4859 {"rna_meta.cc", "rna_meta_api.cc", RNA_def_meta},
4860 {"rna_modifier.cc", nullptr, RNA_def_modifier},
4861 {"rna_shader_fx.cc", nullptr, RNA_def_shader_fx},
4862 {"rna_nla.cc", nullptr, RNA_def_nla},
4863 {"rna_nodetree.cc", nullptr, RNA_def_nodetree},
4864 {"rna_node_socket.cc", nullptr, RNA_def_node_socket_subtypes},
4865 {"rna_node_tree_interface.cc", nullptr, RNA_def_node_tree_interface},
4866 {"rna_object.cc", "rna_object_api.cc", RNA_def_object},
4867 {"rna_object_force.cc", nullptr, RNA_def_object_force},
4868 {"rna_depsgraph.cc", nullptr, RNA_def_depsgraph},
4869 {"rna_packedfile.cc", nullptr, RNA_def_packedfile},
4870 {"rna_palette.cc", nullptr, RNA_def_palette},
4871 {"rna_particle.cc", nullptr, RNA_def_particle},
4872 {"rna_pointcloud.cc", nullptr, RNA_def_pointcloud},
4873 {"rna_pose.cc", "rna_pose_api.cc", RNA_def_pose},
4874 {"rna_curveprofile.cc", nullptr, RNA_def_profile},
4875 {"rna_lightprobe.cc", nullptr, RNA_def_lightprobe},
4876 {"rna_render.cc", nullptr, RNA_def_render},
4877 {"rna_rigidbody.cc", nullptr, RNA_def_rigidbody},
4878 {"rna_scene.cc", "rna_scene_api.cc", RNA_def_scene},
4879 {"rna_screen.cc", nullptr, RNA_def_screen},
4880 {"rna_sculpt_paint.cc", nullptr, RNA_def_sculpt_paint},
4881 {"rna_sequencer.cc", "rna_sequencer_api.cc", RNA_def_sequencer},
4882 {"rna_space.cc", "rna_space_api.cc", RNA_def_space},
4883 {"rna_speaker.cc", nullptr, RNA_def_speaker},
4884 {"rna_test.cc", nullptr, RNA_def_test},
4885 {"rna_text.cc", "rna_text_api.cc", RNA_def_text},
4886 {"rna_timeline.cc", nullptr, RNA_def_timeline_marker},
4887 {"rna_sound.cc", "rna_sound_api.cc", RNA_def_sound},
4888 {"rna_ui.cc", "rna_ui_api.cc", RNA_def_ui},
4889#ifdef WITH_USD
4890 {"rna_usd.cc", nullptr, RNA_def_usd},
4891#endif
4892 {"rna_userdef.cc", nullptr, RNA_def_userdef},
4893 {"rna_vfont.cc", "rna_vfont_api.cc", RNA_def_vfont},
4894 {"rna_volume.cc", nullptr, RNA_def_volume},
4895 {"rna_wm.cc", "rna_wm_api.cc", RNA_def_wm},
4896 {"rna_wm_gizmo.cc", "rna_wm_gizmo_api.cc", RNA_def_wm_gizmo},
4897 {"rna_workspace.cc", "rna_workspace_api.cc", RNA_def_workspace},
4898 {"rna_world.cc", nullptr, RNA_def_world},
4899 {"rna_movieclip.cc", nullptr, RNA_def_movieclip},
4900 {"rna_tracking.cc", nullptr, RNA_def_tracking},
4901 {"rna_mask.cc", nullptr, RNA_def_mask},
4902 {"rna_xr.cc", nullptr, RNA_def_xr},
4903 {nullptr, nullptr},
4904};
4905
4906static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const char *api_filename)
4907{
4908 StructDefRNA *ds;
4909 FunctionDefRNA *dfunc;
4910
4911 fprintf(f,
4912 "\n"
4913 "/* Automatically generated struct definitions for the Data API.\n"
4914 " * Do not edit manually, changes will be overwritten. */\n\n"
4915 "#define RNA_RUNTIME\n\n");
4916
4917 fprintf(f, "#include <float.h>\n");
4918 fprintf(f, "#include <stdio.h>\n");
4919 fprintf(f, "#include <limits.h>\n");
4920 fprintf(f, "#include <limits>\n");
4921 fprintf(f, "#include <string.h>\n\n");
4922 fprintf(f, "#include <stddef.h>\n\n");
4923 fprintf(f, "#include <algorithm>\n\n");
4924
4925 fprintf(f, "#include \"MEM_guardedalloc.h\"\n\n");
4926
4927 fprintf(f, "#include \"DNA_ID.h\"\n");
4928 fprintf(f, "#include \"DNA_scene_types.h\"\n");
4929 fprintf(f, "#include \"DNA_node_types.h\"\n");
4930
4931 fprintf(f, "#include \"BLI_fileops.h\"\n\n");
4932 fprintf(f, "#include \"BLI_listbase.h\"\n\n");
4933 fprintf(f, "#include \"BLI_path_utils.hh\"\n\n");
4934 fprintf(f, "#include \"BLI_rect.h\"\n\n");
4935 fprintf(f, "#include \"BLI_string.h\"\n\n");
4936 fprintf(f, "#include \"BLI_string_utf8.h\"\n\n");
4937 fprintf(f, "#include \"BLI_utildefines.h\"\n\n");
4938
4939 fprintf(f, "#include \"BKE_context.hh\"\n");
4940 fprintf(f, "#include \"BKE_lib_id.hh\"\n");
4941 fprintf(f, "#include \"BKE_main.hh\"\n");
4942 fprintf(f, "#include \"BKE_report.hh\"\n");
4943
4944 fprintf(f, "#include \"RNA_define.hh\"\n");
4945 fprintf(f, "#include \"RNA_types.hh\"\n");
4946 fprintf(f, "#include \"rna_internal.hh\"\n\n");
4947
4948 /* include the generated prototypes header */
4949 fprintf(f, "#include \"rna_prototypes_gen.hh\"\n\n");
4950
4951 if (filename) {
4952 fprintf(f, "#include \"%s\"\n", filename);
4953 }
4954 if (api_filename) {
4955 fprintf(f, "#include \"%s\"\n", api_filename);
4956 }
4957 fprintf(f, "\n");
4958
4959/* we want the included C files to have warnings enabled but for the generated code
4960 * ignore unused-parameter warnings which are hard to prevent */
4961#if defined(__GNUC__) || defined(__clang__)
4962 fprintf(f, "#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n\n");
4963#endif
4964
4965#if defined(__clang__)
4966 /* TODO(@ideasman42): ideally this workaround would not be needed,
4967 * could use some further investigation as these are intended to be declared. */
4968 fprintf(f, "#pragma GCC diagnostic ignored \"-Wmissing-variable-declarations\"\n\n");
4969#endif
4970
4971 fprintf(f, "/* Auto-generated Functions. */\n\n");
4972
4973 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
4974 ds = static_cast<StructDefRNA *>(ds->cont.next))
4975 {
4976 if (!filename || ds->filename == filename) {
4979 }
4980 }
4981
4982 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
4983 ds = static_cast<StructDefRNA *>(ds->cont.next))
4984 {
4985 if (!filename || ds->filename == filename) {
4987 rna_def_property_funcs(f, ds->srna, dp);
4988 }
4989 }
4990 }
4991
4992 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
4993 ds = static_cast<StructDefRNA *>(ds->cont.next))
4994 {
4995 if (!filename || ds->filename == filename) {
4998 }
4999
5000 for (dfunc = static_cast<FunctionDefRNA *>(ds->functions.first); dfunc;
5001 dfunc = static_cast<FunctionDefRNA *>(dfunc->cont.next))
5002 {
5003 rna_def_function_wrapper_funcs(f, ds, dfunc);
5004 rna_def_function_funcs(f, ds, dfunc);
5005 }
5006
5008 }
5009 }
5010
5011 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5012 ds = static_cast<StructDefRNA *>(ds->cont.next))
5013 {
5014 if (!filename || ds->filename == filename) {
5015 rna_generate_struct(brna, ds->srna, f);
5016 }
5017 }
5018
5019 if (filename && STREQ(filename, "rna_ID.cc")) {
5020 /* this is ugly, but we cannot have c files compiled for both
5021 * makesrna and blender with some build systems at the moment */
5022 fprintf(f, "#include \"rna_define.cc\"\n\n");
5023
5024 rna_generate_blender(brna, f);
5025 }
5026}
5027
5028static void rna_generate_header(BlenderRNA * /*brna*/, FILE *f)
5029{
5030 StructDefRNA *ds;
5031 StructRNA *srna;
5032 FunctionDefRNA *dfunc;
5033
5034 fprintf(f, "\n#ifndef __RNA_BLENDER_H__\n");
5035 fprintf(f, "#define __RNA_BLENDER_H__\n\n");
5036
5037 fprintf(f,
5038 "/* Automatically generated function declarations for the Data API.\n"
5039 " * Do not edit manually, changes will be overwritten. */\n\n");
5040
5041 fprintf(f, "#include \"RNA_types.hh\"\n\n");
5042 fprintf(f, "#include \"DNA_node_types.h\"\n\n");
5043
5044 fprintf(f, "#define FOREACH_BEGIN(property, sptr, itemptr) \\\n");
5045 fprintf(f, " { \\\n");
5046 fprintf(f, " CollectionPropertyIterator rna_macro_iter; \\\n");
5047 fprintf(f,
5048 " for (property##_begin(&rna_macro_iter, sptr); rna_macro_iter.valid; "
5049 "property##_next(&rna_macro_iter)) { \\\n");
5050 fprintf(f, " itemptr = rna_macro_iter.ptr;\n\n");
5051
5052 fprintf(f, "#define FOREACH_END(property) \\\n");
5053 fprintf(f, " } \\\n");
5054 fprintf(f, " property##_end(&rna_macro_iter); \\\n");
5055 fprintf(f, " }\n\n");
5056
5057 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5058 ds = static_cast<StructDefRNA *>(ds->cont.next))
5059 {
5060 srna = ds->srna;
5061
5062 fprintf(f, "/**************** %s ****************/\n\n", srna->name);
5063
5064 while (srna) {
5065 fprintf(f, "extern StructRNA RNA_%s;\n", srna->identifier);
5066 srna = srna->base;
5067 }
5068 fprintf(f, "\n");
5069
5072 }
5073
5074 for (dfunc = static_cast<FunctionDefRNA *>(ds->functions.first); dfunc;
5075 dfunc = static_cast<FunctionDefRNA *>(dfunc->cont.next))
5076 {
5077 rna_def_function_funcs_header(f, ds->srna, dfunc);
5078 }
5079 }
5080
5081 fprintf(f, "#endif /* __RNA_BLENDER_H__ */\n\n");
5082}
5083
5084static const char *cpp_classes =
5085 ""
5086 "\n"
5087 "#include <stdlib.h> /* for malloc */\n"
5088 "#include <string>\n"
5089 "#include <string.h> /* for memcpy */\n"
5090 "\n"
5091 "namespace BL {\n"
5092 "\n"
5093 "#define BOOLEAN_PROPERTY(sname, identifier) \\\n"
5094 " inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr) ? true: "
5095 "false; } \\\n"
5096 " inline void sname::identifier(bool value) { sname##_##identifier##_set(&ptr, value); }\n"
5097 "\n"
5098 "#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n"
5099 " inline Array<bool, size> sname::identifier(void) \\\n"
5100 " { Array<bool, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
5101 " inline void sname::identifier(bool values[size]) \\\n"
5102 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5103 "\n"
5104 "#define BOOLEAN_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
5105 " inline DynamicArray<bool> sname::identifier(void) { \\\n"
5106 " int arraylen[3]; \\\n"
5107 " int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
5108 " DynamicArray<bool> ar(len); \\\n"
5109 " sname##_##identifier##_get(&ptr, ar.data); \\\n"
5110 " return ar; } \\\n"
5111 " inline void sname::identifier(bool values[]) \\\n"
5112 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5113 "\n"
5114 "#define INT_PROPERTY(sname, identifier) \\\n"
5115 " inline int sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n"
5116 " inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n"
5117 "\n"
5118 "#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
5119 " inline Array<int, size> sname::identifier(void) \\\n"
5120 " { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
5121 " inline void sname::identifier(int values[size]) \\\n"
5122 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5123 "\n"
5124 "#define INT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
5125 " inline DynamicArray<int> sname::identifier(void) { \\\n"
5126 " int arraylen[3]; \\\n"
5127 " int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
5128 " DynamicArray<int> ar(len); \\\n"
5129 " sname##_##identifier##_get(&ptr, ar.data); \\\n"
5130 " return ar; } \\\n"
5131 " inline void sname::identifier(int values[]) \\\n"
5132 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5133 "\n"
5134 "#define FLOAT_PROPERTY(sname, identifier) \\\n"
5135 " inline float sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n"
5136 " inline void sname::identifier(float value) { sname##_##identifier##_set(&ptr, value); }\n"
5137 "\n"
5138 "#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
5139 " inline Array<float, size> sname::identifier(void) \\\n"
5140 " { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
5141 " inline void sname::identifier(float values[size]) \\\n"
5142 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5143 "\n"
5144 "#define FLOAT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
5145 " inline DynamicArray<float> sname::identifier(void) { \\\n"
5146 " int arraylen[3]; \\\n"
5147 " int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
5148 " DynamicArray<float> ar(len); \\\n"
5149 " sname##_##identifier##_get(&ptr, ar.data); \\\n"
5150 " return ar; } \\\n"
5151 " inline void sname::identifier(float values[]) \\\n"
5152 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5153 "\n"
5154 "#define ENUM_PROPERTY(type, sname, identifier) \\\n"
5155 " inline sname::type sname::identifier(void) { return "
5156 "(type)sname##_##identifier##_get(&ptr); } \\\n"
5157 " inline void sname::identifier(sname::type value) { sname##_##identifier##_set(&ptr, "
5158 "value); }\n"
5159 "\n"
5160 "#define STRING_PROPERTY(sname, identifier) \\\n"
5161 " inline std::string sname::identifier(void) { \\\n"
5162 " int len = sname##_##identifier##_length(&ptr); \\\n"
5163 " std::string str; str.resize(len); \\\n"
5164 " sname##_##identifier##_get(&ptr, &str[0]); return str; } \\\n"
5165 " inline void sname::identifier(const std::string& value) { \\\n"
5166 " sname##_##identifier##_set(&ptr, value.c_str()); } \\\n"
5167 "\n"
5168 "#define POINTER_PROPERTY(type, sname, identifier) \\\n"
5169 " inline type sname::identifier(void) { return type(sname##_##identifier##_get(&ptr)); }\n"
5170 "\n"
5171 "#define COLLECTION_PROPERTY_LENGTH_false(sname, identifier) \\\n"
5172 " inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n"
5173 " { \\\n"
5174 " CollectionPropertyIterator iter; \\\n"
5175 " int length = 0; \\\n"
5176 " sname##_##identifier##_begin(&iter, ptr); \\\n"
5177 " while (iter.valid) { \\\n"
5178 " sname##_##identifier##_next(&iter); \\\n"
5179 " ++length; \\\n"
5180 " } \\\n"
5181 " sname##_##identifier##_end(&iter); \\\n"
5182 " return length; \\\n"
5183 " } \n"
5184 "#define COLLECTION_PROPERTY_LENGTH_true(sname, identifier) \\\n"
5185 " inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n"
5186 " { return sname##_##identifier##_length(ptr); } \n"
5187 "\n"
5188 "#define COLLECTION_PROPERTY_EMPTY_false(sname, identifier) \\\n"
5189 " inline static bool sname##_##identifier##_empty_wrap(PointerRNA *ptr) \\\n"
5190 " { \\\n"
5191 " CollectionPropertyIterator iter; \\\n"
5192 " sname##_##identifier##_begin(&iter, ptr); \\\n"
5193 " bool empty = !iter.valid; \\\n"
5194 " sname##_##identifier##_end(&iter); \\\n"
5195 " return empty; \\\n"
5196 " } \n"
5197 "#define COLLECTION_PROPERTY_EMPTY_true(sname, identifier) \\\n"
5198 " inline static bool sname##_##identifier##_empty_wrap(PointerRNA *ptr) \\\n"
5199 " { return sname##_##identifier##_length(ptr) == 0; } \n"
5200 "\n"
5201 "#define COLLECTION_PROPERTY_LOOKUP_INT_false(sname, identifier) \\\n"
5202 " inline static bool sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, "
5203 "PointerRNA *r_ptr) \\\n"
5204 " { \\\n"
5205 " CollectionPropertyIterator iter; \\\n"
5206 " int i = 0; \\\n"
5207 " bool found = false; \\\n"
5208 " sname##_##identifier##_begin(&iter, ptr); \\\n"
5209 " while (iter.valid) { \\\n"
5210 " if (i == key) { \\\n"
5211 " *r_ptr = iter.ptr; \\\n"
5212 " found = true; \\\n"
5213 " break; \\\n"
5214 " } \\\n"
5215 " sname##_##identifier##_next(&iter); \\\n"
5216 " ++i; \\\n"
5217 " } \\\n"
5218 " sname##_##identifier##_end(&iter); \\\n"
5219 " if (!found) { \\\n"
5220 " *r_ptr = {}; \\\n"
5221 " } \\\n"
5222 " return found; \\\n"
5223 " } \n"
5224 "#define COLLECTION_PROPERTY_LOOKUP_INT_true(sname, identifier) \\\n"
5225 " inline static bool sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, "
5226 "PointerRNA *r_ptr) \\\n"
5227 " { \\\n"
5228 " bool found = sname##_##identifier##_lookup_int(ptr, key, r_ptr); \\\n"
5229 " if (!found) { \\\n"
5230 " *r_ptr = {}; \\\n"
5231 " } \\\n"
5232 " return found; \\\n"
5233 " } \n"
5234 "#define COLLECTION_PROPERTY_LOOKUP_STRING_false(sname, identifier) \\\n"
5235 " inline static bool sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char "
5236 "*key, PointerRNA *r_ptr) \\\n"
5237 " { \\\n"
5238 " CollectionPropertyIterator iter; \\\n"
5239 " bool found = false; \\\n"
5240 " PropertyRNA *item_name_prop = RNA_struct_name_property(ptr->type); \\\n"
5241 " sname##_##identifier##_begin(&iter, ptr); \\\n"
5242 " while (iter.valid && !found) { \\\n"
5243 " char name_fixed[32]; \\\n"
5244 " const char *name; \\\n"
5245 " int name_length; \\\n"
5246 " name = RNA_property_string_get_alloc(&iter.ptr, item_name_prop, name_fixed, "
5247 "sizeof(name_fixed), &name_length); \\\n"
5248 " if (!strncmp(name, key, name_length)) { \\\n"
5249 " *r_ptr = iter.ptr; \\\n"
5250 " found = true; \\\n"
5251 " } \\\n"
5252 " if (name_fixed != name) { \\\n"
5253 " MEM_freeN( name); \\\n"
5254 " } \\\n"
5255 " sname##_##identifier##_next(&iter); \\\n"
5256 " } \\\n"
5257 " sname##_##identifier##_end(&iter); \\\n"
5258 " if (!found) { \\\n"
5259 " *r_ptr = {}; \\\n"
5260 " } \\\n"
5261 " return found; \\\n"
5262 " } \n"
5263 "#define COLLECTION_PROPERTY_LOOKUP_STRING_true(sname, identifier) \\\n"
5264 " inline static bool sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char "
5265 "*key, PointerRNA *r_ptr) \\\n"
5266 " { \\\n"
5267 " bool found = sname##_##identifier##_lookup_string(ptr, key, r_ptr); \\\n"
5268 " if (!found) { \\\n"
5269 " *r_ptr = {}; \\\n"
5270 " } \\\n"
5271 " return found; \\\n"
5272 " } \n"
5273 "#define COLLECTION_PROPERTY(collection_funcs, type, sname, identifier, has_length, "
5274 "has_lookup_int, has_lookup_string) \\\n"
5275 " typedef CollectionIterator<type, sname##_##identifier##_begin, \\\n"
5276 " sname##_##identifier##_next, sname##_##identifier##_end> identifier##_iterator; \\\n"
5277 " COLLECTION_PROPERTY_LENGTH_##has_length(sname, identifier) \\\n"
5278 " COLLECTION_PROPERTY_EMPTY_##has_length(sname, identifier) \\\n"
5279 " COLLECTION_PROPERTY_LOOKUP_INT_##has_lookup_int(sname, identifier) \\\n"
5280 " COLLECTION_PROPERTY_LOOKUP_STRING_##has_lookup_string(sname, identifier) \\\n"
5281 " CollectionRef<sname, type, sname##_##identifier##_begin, \\\n"
5282 " sname##_##identifier##_next, sname##_##identifier##_end, \\\n"
5283 " sname##_##identifier##_length_wrap, \\\n"
5284 " sname##_##identifier##_empty_wrap, \\\n"
5285 " sname##_##identifier##_lookup_int_wrap, sname##_##identifier##_lookup_string_wrap, "
5286 "collection_funcs> identifier;\n"
5287 "\n"
5288 "class Pointer {\n"
5289 "public:\n"
5290 " Pointer(const PointerRNA &p) : ptr(p) { }\n"
5291 " operator const PointerRNA&() { return ptr; }\n"
5292 " bool is_a(StructRNA *type) { return RNA_struct_is_a(ptr.type, type) ? true: false; }\n"
5293 " operator void*() { return ptr.data; }\n"
5294 " operator bool() const { return ptr.data != nullptr; }\n"
5295 "\n"
5296 " bool operator==(const Pointer &other) const { return ptr.data == other.ptr.data; }\n"
5297 " bool operator!=(const Pointer &other) const { return ptr.data != other.ptr.data; }\n"
5298 " bool operator<(const Pointer &other) const { return ptr.data < other.ptr.data; }\n"
5299 "\n"
5300 " PointerRNA ptr;\n"
5301 "};\n"
5302 "\n"
5303 "\n"
5304 "template<typename T, int Tsize>\n"
5305 "class Array {\n"
5306 "public:\n"
5307 " T data[Tsize];\n"
5308 "\n"
5309 " Array() {}\n"
5310 " Array(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); }\n"
5311 " const Array<T, Tsize>& operator = (const Array<T, Tsize>& other) { memcpy(data, "
5312 "other.data, sizeof(T) * Tsize); "
5313 "return *this; }\n"
5314 "\n"
5315 " operator T*() { return data; }\n"
5316 " operator const T*() const { return data; }\n"
5317 "};\n"
5318 "\n"
5319 "template<typename T>\n"
5320 "class DynamicArray {\n"
5321 "public:\n"
5322 " T *data;\n"
5323 " int length;\n"
5324 "\n"
5325 " DynamicArray() : data(nullptr), length(0) {}\n"
5326 " DynamicArray(int new_length) : data(nullptr), length(new_length) { data = (T "
5327 "*)malloc(sizeof(T) * new_length); }\n"
5328 " DynamicArray(const DynamicArray<T>& other) : data(nullptr), length(0) { "
5329 "copy_from(other); "
5330 "}\n"
5331 " const DynamicArray<T>& operator = (const DynamicArray<T>& other) { copy_from(other); "
5332 "return *this; }\n"
5333 "\n"
5334 " ~DynamicArray() { if (data) free(data); }\n"
5335 "\n"
5336 " operator T*() { return data; }\n"
5337 "\n"
5338 "protected:\n"
5339 " void copy_from(const DynamicArray<T>& other) {\n"
5340 " if (data) free(data);\n"
5341 " data = (T *)malloc(sizeof(T) * other.length);\n"
5342 " memcpy(data, other.data, sizeof(T) * other.length);\n"
5343 " length = other.length;\n"
5344 " }\n"
5345 "};\n"
5346 "\n"
5347 "typedef void (*TBeginFunc)(CollectionPropertyIterator *iter, PointerRNA *ptr);\n"
5348 "typedef void (*TNextFunc)(CollectionPropertyIterator *iter);\n"
5349 "typedef void (*TEndFunc)(CollectionPropertyIterator *iter);\n"
5350 "typedef int (*TLengthFunc)(PointerRNA *ptr);\n"
5351 "typedef bool (*TEmptyFunc)(PointerRNA *ptr);\n"
5352 "typedef bool (*TLookupIntFunc)(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n"
5353 "typedef bool (*TLookupStringFunc)(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n"
5354 "\n"
5355 "template<typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n"
5356 "class CollectionIterator {\n"
5357 "public:\n"
5358 " CollectionIterator() : iter(), t(iter.ptr), init(false) { iter.valid = false; }\n"
5359 " CollectionIterator(const PointerRNA &ptr) : CollectionIterator() { this->begin(ptr); }\n"
5360 " ~CollectionIterator(void) { if (init) Tend(&iter); };\n"
5361 "\n"
5362 " CollectionIterator(const CollectionIterator &other) = delete;\n"
5363 " CollectionIterator(CollectionIterator &&other) = delete;\n"
5364 " CollectionIterator &operator=(const CollectionIterator &other) = delete;\n"
5365 " CollectionIterator &operator=(CollectionIterator &&other) = delete;\n"
5366 "\n"
5367 " operator bool(void) const\n"
5368 " { return iter.valid != 0; }\n"
5369 " const CollectionIterator<T, Tbegin, Tnext, Tend>& operator++() { Tnext(&iter); t = "
5370 "T(iter.ptr); return *this; }\n"
5371 "\n"
5372 " T& operator*(void) { return t; }\n"
5373 " T* operator->(void) { return &t; }\n"
5374 " bool operator == (const CollectionIterator<T, Tbegin, Tnext, Tend>& other) "
5375 "{ return iter.valid == other.iter.valid; }\n"
5376 " bool operator!=(const CollectionIterator<T, Tbegin, Tnext, Tend>& other) "
5377 "{ return iter.valid != other.iter.valid; }\n"
5378 "\n"
5379 " void begin(const Pointer &ptr)\n"
5380 " { if (init) Tend(&iter); Tbegin(&iter, (PointerRNA *)&ptr.ptr); t = T(iter.ptr); init = "
5381 "true; }\n"
5382 "\n"
5383 "private:\n"
5384 " CollectionPropertyIterator iter;\n"
5385 " T t;\n"
5386 " bool init;\n"
5387 "};\n"
5388 "\n"
5389 "template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend,\n"
5390 " TLengthFunc Tlength, TEmptyFunc Tempty, TLookupIntFunc Tlookup_int,\n"
5391 " TLookupStringFunc Tlookup_string, typename Tcollection_funcs>\n"
5392 "class CollectionRef : public Tcollection_funcs {\n"
5393 "public:\n"
5394 " CollectionRef(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n"
5395 "\n"
5396 " void begin(CollectionIterator<T, Tbegin, Tnext, Tend>& iter)\n"
5397 " { iter.begin(ptr); }\n"
5398 " CollectionIterator<T, Tbegin, Tnext, Tend> begin()\n"
5399 " { return CollectionIterator<T, Tbegin, Tnext, Tend>(ptr); }\n"
5400 " CollectionIterator<T, Tbegin, Tnext, Tend> end()\n"
5401 " { return CollectionIterator<T, Tbegin, Tnext, Tend>(); } /* test */ \n"
5402 ""
5403 " int length()\n"
5404 " { return Tlength(&ptr); }\n"
5405 " bool empty()\n"
5406 " { return Tempty(&ptr); }\n"
5407 " T operator[](int key)\n"
5408 " { PointerRNA r_ptr; Tlookup_int(&ptr, key, &r_ptr); return T(r_ptr); }\n"
5409 " T operator[](const std::string &key)\n"
5410 " { PointerRNA r_ptr; Tlookup_string(&ptr, key.c_str(), &r_ptr); return T(r_ptr); }\n"
5411 "\n"
5412 "private:\n"
5413 " PointerRNA ptr;\n"
5414 "};\n"
5415 "\n"
5416 "class DefaultCollectionFunctions {\n"
5417 "public:\n"
5418 " DefaultCollectionFunctions(const PointerRNA & /*p*/) {}\n"
5419 "};\n"
5420 "\n"
5421 "\n";
5422
5424{
5425 if (!(prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN)) {
5426 if (prop->type == PROP_COLLECTION) {
5427 return true;
5428 }
5429 }
5430
5431 return false;
5432}
5433
5434static bool rna_is_collection_functions_struct(const char **collection_structs,
5435 const char *struct_name)
5436{
5437 int a = 0;
5438 bool found = false;
5439
5440 while (collection_structs[a]) {
5441 if (STREQ(collection_structs[a], struct_name)) {
5442 found = true;
5443 break;
5444 }
5445 a++;
5446 }
5447
5448 return found;
5449}
5450
5452{
5453 StructRNA *srna = ds->srna;
5454 FunctionDefRNA *dfunc;
5455
5456 fprintf(f, "/**************** %s ****************/\n\n", srna->name);
5457
5458 fprintf(f,
5459 "class %s : public %s {\n",
5460 srna->identifier,
5461 (srna->base) ? srna->base->identifier : "Pointer");
5462 fprintf(f, "public:\n");
5463 fprintf(f,
5464 "\t%s(const PointerRNA &ptr_arg) :\n\t\t%s(ptr_arg)",
5465 srna->identifier,
5466 (srna->base) ? srna->base->identifier : "Pointer");
5468 if (rna_is_collection_prop(dp->prop)) {
5469 fprintf(f, ",\n\t\t%s(ptr_arg)", dp->prop->identifier);
5470 }
5471 }
5472 fprintf(f, "\n\t\t{}\n\n");
5473
5476 }
5477
5478 fprintf(f, "\n");
5479 for (dfunc = static_cast<FunctionDefRNA *>(ds->functions.first); dfunc;
5480 dfunc = static_cast<FunctionDefRNA *>(dfunc->cont.next))
5481 {
5482 rna_def_struct_function_header_cpp(f, srna, dfunc);
5483 }
5484
5485 fprintf(f, "};\n\n");
5486}
5487
5488static void rna_generate_header_cpp(BlenderRNA * /*brna*/, FILE *f)
5489{
5490 StructDefRNA *ds;
5491 StructRNA *srna;
5492 FunctionDefRNA *dfunc;
5493 const char *first_collection_func_struct = nullptr;
5494 const char *collection_func_structs[256] = {nullptr};
5495 int all_collection_func_structs = 0;
5496 int max_collection_func_structs = sizeof(collection_func_structs) /
5497 sizeof(collection_func_structs[0]) -
5498 1;
5499
5500 fprintf(f, "\n#ifndef __RNA_BLENDER_CPP_H__\n");
5501 fprintf(f, "#define __RNA_BLENDER_CPP_H__\n\n");
5502
5503 fprintf(f,
5504 "/* Automatically generated classes for the Data API.\n"
5505 " * Do not edit manually, changes will be overwritten. */\n\n");
5506
5507 fprintf(f, "#include \"RNA_blender.hh\"\n");
5508 fprintf(f, "#include \"RNA_types.hh\"\n");
5509 fprintf(f, "#include \"RNA_access.hh\"\n");
5510 fprintf(f, "#include \"DNA_node_types.h\"\n");
5511
5512 fprintf(f, "%s", cpp_classes);
5513
5514 fprintf(f, "/**************** Declarations ****************/\n\n");
5515
5516 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5517 ds = static_cast<StructDefRNA *>(ds->cont.next))
5518 {
5519 fprintf(f, "class %s;\n", ds->srna->identifier);
5520 }
5521 fprintf(f, "\n");
5522
5523 /* first get list of all structures used as collection functions, so they'll be declared first */
5524 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5525 ds = static_cast<StructDefRNA *>(ds->cont.next))
5526 {
5528 if (rna_is_collection_prop(dp->prop)) {
5529 PropertyRNA *prop = dp->prop;
5530
5531 if (prop->srna) {
5532 /* store name of structure which first uses custom functions for collections */
5533 if (first_collection_func_struct == nullptr) {
5534 first_collection_func_struct = ds->srna->identifier;
5535 }
5536
5537 if (!rna_is_collection_functions_struct(collection_func_structs, (char *)prop->srna)) {
5538 if (all_collection_func_structs >= max_collection_func_structs) {
5539 printf("Array size to store all collection structures names is too small\n");
5540 exit(1);
5541 }
5542
5543 collection_func_structs[all_collection_func_structs++] = (char *)prop->srna;
5544 }
5545 }
5546 }
5547 }
5548 }
5549
5550 /* declare all structures in such order:
5551 * - first N structures which doesn't use custom functions for collections
5552 * - all structures used for custom functions in collections
5553 * - all the rest structures
5554 * such an order prevents usage of non-declared classes
5555 */
5556 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5557 ds = static_cast<StructDefRNA *>(ds->cont.next))
5558 {
5559 srna = ds->srna;
5560
5561 if (STREQ(srna->identifier, first_collection_func_struct)) {
5562 StructDefRNA *ds2;
5563 StructRNA *srna2;
5564
5565 for (ds2 = static_cast<StructDefRNA *>(DefRNA.structs.first); ds2;
5566 ds2 = static_cast<StructDefRNA *>(ds2->cont.next))
5567 {
5568 srna2 = ds2->srna;
5569
5570 if (rna_is_collection_functions_struct(collection_func_structs, srna2->identifier)) {
5572 }
5573 }
5574 }
5575
5576 if (!rna_is_collection_functions_struct(collection_func_structs, srna->identifier)) {
5578 }
5579 }
5580
5581 fprintf(f, "} /* namespace BL */\n");
5582
5583 fprintf(f, "\n");
5584 fprintf(f, "/**************** Implementation ****************/\n");
5585 fprintf(f, "\n");
5586
5587 fprintf(f, "/* Structure prototypes */\n\n");
5589
5590 fprintf(f, "namespace BL {\n");
5591
5592 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5593 ds = static_cast<StructDefRNA *>(ds->cont.next))
5594 {
5595 srna = ds->srna;
5596
5599 }
5600
5601 fprintf(f, "\n");
5602
5603 for (dfunc = static_cast<FunctionDefRNA *>(ds->functions.first); dfunc;
5604 dfunc = static_cast<FunctionDefRNA *>(dfunc->cont.next))
5605 {
5606 rna_def_struct_function_impl_cpp(f, srna, dfunc);
5607 }
5608
5609 fprintf(f, "\n");
5610 }
5611
5612 fprintf(f, "}\n\n#endif /* __RNA_BLENDER_CPP_H__ */\n\n");
5613}
5614
5615static void make_bad_file(const char *file, int line)
5616{
5617 FILE *fp = fopen(file, "w");
5618 fprintf(fp,
5619 "#error \"Error! can't make correct RNA file from %s:%d, "
5620 "check DNA properties.\"\n",
5621 __FILE__,
5622 line);
5623 fclose(fp);
5624}
5625
5630static int rna_preprocess(const char *outfile, const char *public_header_outfile)
5631{
5632 BlenderRNA *brna;
5633 StructDefRNA *ds;
5634 FILE *file;
5635 char deffile[4096];
5636 int i;
5637 /* The exit code (returned from this function). */
5638 int status = EXIT_SUCCESS;
5639 const char *deps[3]; /* expand as needed */
5640
5641 if (!public_header_outfile) {
5642 public_header_outfile = outfile;
5643 }
5644
5645 /* define rna */
5646 brna = RNA_create();
5647
5648 for (i = 0; PROCESS_ITEMS[i].filename; i++) {
5649 if (PROCESS_ITEMS[i].define) {
5650 PROCESS_ITEMS[i].define(brna);
5651
5652 /* sanity check */
5653 if (!DefRNA.animate) {
5654 fprintf(stderr, "Error: DefRNA.animate left disabled in %s\n", PROCESS_ITEMS[i].filename);
5655 }
5656
5657 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5658 ds = static_cast<StructDefRNA *>(ds->cont.next))
5659 {
5660 if (!ds->filename) {
5661 ds->filename = PROCESS_ITEMS[i].filename;
5662 }
5663 }
5664 }
5665 }
5666
5667 rna_sanity_checks();
5668 if (DefRNA.error) {
5669 status = EXIT_FAILURE;
5670 }
5671
5673 if (DefRNA.error) {
5674 status = EXIT_FAILURE;
5675 }
5676
5677 /* Create external rna struct prototype header file RNA_prototypes.hh. */
5678 SNPRINTF(deffile, "%s%s", public_header_outfile, "RNA_prototypes.hh" TMP_EXT);
5679 if (status != EXIT_SUCCESS) {
5680 make_bad_file(deffile, __LINE__);
5681 }
5682 file = fopen(deffile, "w");
5683 if (!file) {
5684 fprintf(stderr, "Unable to open file: %s\n", deffile);
5685 status = EXIT_FAILURE;
5686 }
5687 else {
5688 fprintf(file,
5689 "/* Automatically generated RNA property declarations, to statically reference \n"
5690 " * properties as `rna_[struct-name]_[property-name]`.\n"
5691 " *\n"
5692 " * DO NOT EDIT MANUALLY, changes will be overwritten.\n"
5693 " */\n\n");
5694
5695 fprintf(file, "#pragma once\n\n");
5697 fclose(file);
5698 if (DefRNA.error) {
5699 status = EXIT_FAILURE;
5700 }
5701 replace_if_different(deffile, nullptr);
5702 }
5703
5704 /* create internal rna struct prototype header file */
5705 SNPRINTF(deffile, "%s%s", outfile, "rna_prototypes_gen.hh" TMP_EXT);
5706 if (status != EXIT_SUCCESS) {
5707 make_bad_file(deffile, __LINE__);
5708 }
5709 file = fopen(deffile, "w");
5710 if (!file) {
5711 fprintf(stderr, "Unable to open file: %s\n", deffile);
5712 status = EXIT_FAILURE;
5713 }
5714 else {
5715 fprintf(file,
5716 "/* Automatically generated function declarations for the Data API.\n"
5717 " * Do not edit manually, changes will be overwritten. */\n\n");
5719 fclose(file);
5720 replace_if_different(deffile, nullptr);
5721 if (DefRNA.error) {
5722 status = EXIT_FAILURE;
5723 }
5724 }
5725
5726 /* Create `rna_gen_*.c` & `rna_gen_*.cc` files. */
5727 for (i = 0; PROCESS_ITEMS[i].filename; i++) {
5728 const bool is_cc = BLI_str_endswith(PROCESS_ITEMS[i].filename, ".cc");
5729 const int ext_len = is_cc ? 3 : 2;
5730 const int filename_len = strlen(PROCESS_ITEMS[i].filename);
5731 SNPRINTF(deffile,
5732 "%s%.*s%s" TMP_EXT,
5733 outfile,
5734 (filename_len - ext_len),
5735 PROCESS_ITEMS[i].filename,
5736 is_cc ? "_gen.cc" : "_gen.c");
5737 if (status != EXIT_SUCCESS) {
5738 make_bad_file(deffile, __LINE__);
5739 }
5740 else {
5741 file = fopen(deffile, "w");
5742
5743 if (!file) {
5744 fprintf(stderr, "Unable to open file: %s\n", deffile);
5745 status = EXIT_FAILURE;
5746 }
5747 else {
5748 rna_generate(brna, file, PROCESS_ITEMS[i].filename, PROCESS_ITEMS[i].api_filename);
5749 fclose(file);
5750 if (DefRNA.error) {
5751 status = EXIT_FAILURE;
5752 }
5753 }
5754 }
5755
5756 /* avoid unneeded rebuilds */
5757 deps[0] = PROCESS_ITEMS[i].filename;
5758 deps[1] = PROCESS_ITEMS[i].api_filename;
5759 deps[2] = nullptr;
5760
5761 replace_if_different(deffile, deps);
5762 }
5763
5764 /* Create `RNA_blender_cpp.hh`. */
5765 SNPRINTF(deffile, "%s%s", outfile, "RNA_blender_cpp.hh" TMP_EXT);
5766
5767 if (status != EXIT_SUCCESS) {
5768 make_bad_file(deffile, __LINE__);
5769 }
5770 else {
5771 file = fopen(deffile, "w");
5772
5773 if (!file) {
5774 fprintf(stderr, "Unable to open file: %s\n", deffile);
5775 status = EXIT_FAILURE;
5776 }
5777 else {
5778 rna_generate_header_cpp(brna, file);
5779 fclose(file);
5780 if (DefRNA.error) {
5781 status = EXIT_FAILURE;
5782 }
5783 }
5784 }
5785
5786 replace_if_different(deffile, nullptr);
5787
5788 rna_sort(brna);
5789
5790 /* Create `RNA_blender.hh`. */
5791 SNPRINTF(deffile, "%s%s", outfile, "RNA_blender.hh" TMP_EXT);
5792
5793 if (status != EXIT_SUCCESS) {
5794 make_bad_file(deffile, __LINE__);
5795 }
5796 else {
5797 file = fopen(deffile, "w");
5798
5799 if (!file) {
5800 fprintf(stderr, "Unable to open file: %s\n", deffile);
5801 status = EXIT_FAILURE;
5802 }
5803 else {
5804 rna_generate_header(brna, file);
5805 fclose(file);
5806 if (DefRNA.error) {
5807 status = EXIT_FAILURE;
5808 }
5809 }
5810 }
5811
5812 replace_if_different(deffile, nullptr);
5813
5814 /* free RNA */
5815 RNA_define_free(brna);
5816 RNA_free(brna);
5817
5818 return status;
5819}
5820
5821static void mem_error_cb(const char *errorStr)
5822{
5823 fprintf(stderr, "%s", errorStr);
5824 fflush(stderr);
5825}
5826
5827int main(int argc, char **argv)
5828{
5829 int return_status = EXIT_SUCCESS;
5830
5833
5834 CLG_init();
5835
5836 /* Some useful defaults since this runs standalone. */
5839
5840 if (argc < 2) {
5841 fprintf(stderr, "Usage: %s outdirectory [public header outdirectory]/\n", argv[0]);
5842 return_status = EXIT_FAILURE;
5843 }
5844 else {
5845 if (debugSRNA > 0) {
5846 fprintf(stderr, "Running makesrna\n");
5847 }
5848 makesrna_path = argv[0];
5849 return_status = rna_preprocess(argv[1], (argc > 2) ? argv[2] : nullptr);
5850 }
5851
5852 CLG_exit();
5853
5854 return return_status;
5855}
#define BLI_assert_unreachable()
Definition BLI_assert.h:93
#define LISTBASE_FOREACH(type, var, list)
ATTR_WARN_UNUSED_RESULT const size_t num
int bool BLI_str_startswith(const char *__restrict str, const char *__restrict start) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
#define STR_ELEM(...)
Definition BLI_string.h:656
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:599
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:688
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
int bool bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL(1
unsigned int uint
#define ARRAY_SIZE(arr)
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
#define STREQ(a, b)
#define CLOG_ERROR(clg_ref,...)
Definition CLG_log.h:182
void CLG_output_use_basename_set(int value)
Definition clog.c:714
void CLG_exit(void)
Definition clog.c:704
void CLG_level_set(int level)
Definition clog.c:749
void CLG_init(void)
Definition clog.c:697
Read Guarded memory(de)allocation.
#define IS_DNATYPE_BOOLEAN_COMPAT(_str)
#define IS_DNATYPE_FLOAT_COMPAT(_str)
#define IS_DNATYPE_INT_COMPAT(_str)
@ PARM_RNAPTR
Definition RNA_types.hh:513
@ PARM_OUTPUT
Definition RNA_types.hh:512
PropertyScaleType
Definition RNA_types.hh:191
@ PROP_SCALE_LOG
Definition RNA_types.hh:198
@ PROP_SCALE_LINEAR
Definition RNA_types.hh:193
@ PROP_SCALE_CUBIC
Definition RNA_types.hh:203
@ FUNC_USE_REPORTS
Definition RNA_types.hh:805
@ FUNC_USE_SELF_TYPE
Definition RNA_types.hh:800
@ FUNC_NO_SELF
Definition RNA_types.hh:798
@ FUNC_USE_MAIN
Definition RNA_types.hh:803
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:804
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:792
@ STRUCT_ID_REFCOUNT
Definition RNA_types.hh:845
@ STRUCT_ID
Definition RNA_types.hh:844
PropertyType
Definition RNA_types.hh:149
@ PROP_FLOAT
Definition RNA_types.hh:152
@ PROP_BOOLEAN
Definition RNA_types.hh:150
@ PROP_ENUM
Definition RNA_types.hh:154
@ PROP_INT
Definition RNA_types.hh:151
@ PROP_STRING
Definition RNA_types.hh:153
@ PROP_POINTER
Definition RNA_types.hh:155
@ PROP_COLLECTION
Definition RNA_types.hh:156
void(*)(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *edit_text, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn) StringPropertySearchFunc
Definition RNA_types.hh:715
@ PROP_UNIT_VOLUME
Definition RNA_types.hh:164
@ PROP_UNIT_POWER
Definition RNA_types.hh:172
@ PROP_UNIT_ROTATION
Definition RNA_types.hh:166
@ PROP_UNIT_FREQUENCY
Definition RNA_types.hh:176
@ PROP_UNIT_WAVELENGTH
Definition RNA_types.hh:174
@ PROP_UNIT_VELOCITY
Definition RNA_types.hh:169
@ PROP_UNIT_LENGTH
Definition RNA_types.hh:162
@ PROP_UNIT_NONE
Definition RNA_types.hh:161
@ PROP_UNIT_ACCELERATION
Definition RNA_types.hh:170
@ PROP_UNIT_AREA
Definition RNA_types.hh:163
@ PROP_UNIT_TIME
Definition RNA_types.hh:167
@ PROP_UNIT_CAMERA
Definition RNA_types.hh:171
@ PROP_UNIT_TEMPERATURE
Definition RNA_types.hh:173
@ PROP_UNIT_MASS
Definition RNA_types.hh:165
@ PROP_UNIT_TIME_ABSOLUTE
Definition RNA_types.hh:168
@ PROP_UNIT_COLOR_TEMPERATURE
Definition RNA_types.hh:175
#define RNA_SUBTYPE_UNIT(subtype)
Definition RNA_types.hh:206
@ PROP_RAW_INT8
Definition RNA_types.hh:600
@ PROP_RAW_UINT64
Definition RNA_types.hh:599
@ PROP_RAW_INT
Definition RNA_types.hh:590
@ PROP_RAW_INT64
Definition RNA_types.hh:598
@ PROP_RAW_BOOLEAN
Definition RNA_types.hh:593
@ PROP_RAW_CHAR
Definition RNA_types.hh:592
@ PROP_RAW_FLOAT
Definition RNA_types.hh:595
@ PROP_RAW_DOUBLE
Definition RNA_types.hh:594
@ PROP_RAW_UINT8
Definition RNA_types.hh:596
@ PROP_RAW_UINT16
Definition RNA_types.hh:597
@ PROP_RAW_SHORT
Definition RNA_types.hh:591
@ PROP_THICK_WRAP
Definition RNA_types.hh:397
@ PROP_DYNAMIC
Definition RNA_types.hh:402
@ PROP_CONTEXT_UPDATE
Definition RNA_types.hh:381
@ PROP_EDITABLE
Definition RNA_types.hh:292
@ PROP_ENUM_FLAG
Definition RNA_types.hh:378
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:369
@ PROP_ID_SELF_CHECK
Definition RNA_types.hh:344
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:338
@ PROP_IDPROPERTY
Definition RNA_types.hh:400
PropertySubType
Definition RNA_types.hh:220
@ PROP_TIME
Definition RNA_types.hh:241
@ PROP_MATRIX
Definition RNA_types.hh:253
@ PROP_DIRECTION
Definition RNA_types.hh:250
@ PROP_XYZ
Definition RNA_types.hh:257
@ PROP_DISTANCE
Definition RNA_types.hh:244
@ PROP_ACCELERATION
Definition RNA_types.hh:252
@ PROP_TEMPERATURE
Definition RNA_types.hh:272
@ PROP_BYTESTRING
Definition RNA_types.hh:228
@ PROP_POWER
Definition RNA_types.hh:269
@ PROP_LAYER_MEMBER
Definition RNA_types.hh:266
@ PROP_FILENAME
Definition RNA_types.hh:226
@ PROP_PASSWORD
Definition RNA_types.hh:231
@ PROP_COLOR
Definition RNA_types.hh:248
@ PROP_PIXEL
Definition RNA_types.hh:236
@ PROP_ANGLE
Definition RNA_types.hh:240
@ PROP_TIME_ABSOLUTE
Definition RNA_types.hh:242
@ PROP_DISTANCE_CAMERA
Definition RNA_types.hh:245
@ PROP_AXISANGLE
Definition RNA_types.hh:256
@ PROP_EULER
Definition RNA_types.hh:254
@ PROP_COORDS
Definition RNA_types.hh:262
@ PROP_COLOR_TEMPERATURE
Definition RNA_types.hh:278
@ PROP_NONE
Definition RNA_types.hh:221
@ PROP_DIRPATH
Definition RNA_types.hh:225
@ PROP_PERCENTAGE
Definition RNA_types.hh:238
@ PROP_FREQUENCY
Definition RNA_types.hh:280
@ PROP_FACTOR
Definition RNA_types.hh:239
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:260
@ PROP_TRANSLATION
Definition RNA_types.hh:249
@ PROP_UNSIGNED
Definition RNA_types.hh:237
@ PROP_LAYER
Definition RNA_types.hh:265
@ PROP_QUATERNION
Definition RNA_types.hh:255
@ PROP_FILEPATH
Definition RNA_types.hh:224
@ PROP_VELOCITY
Definition RNA_types.hh:251
@ PROP_WAVELENGTH
Definition RNA_types.hh:275
long long int int64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
#define fabsf(x)
#define str(s)
#define INT64_MIN
#define INT64_MAX
#define main()
#define printf(...)
#define PRId64
Definition inttypes.h:78
void MEM_init_memleak_detection()
#define LOG(severity)
Definition log.h:32
static void rna_def_struct_function_header_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
Definition makesrna.cc:2752
static char * rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *, const char *manualfunc)
Definition makesrna.cc:1961
static char * rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc, const char *nextfunc)
Definition makesrna.cc:1677
static void rna_print_data_get(FILE *f, PropertyDefRNA *dp)
Definition makesrna.cc:402
static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc)
Definition makesrna.cc:3139
void * rna_calloc(int buffer_size)
Definition makesrna.cc:448
static StructRNA * rna_find_struct(const char *identifier)
Definition makesrna.cc:465
static void rna_auto_types()
Definition makesrna.cc:3483
static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array)
Definition makesrna.cc:1097
static const char * rna_type_type(PropertyRNA *prop)
Definition makesrna.cc:538
static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
Definition makesrna.cc:2042
static bool rna_color_quantize(PropertyRNA *prop, PropertyDefRNA *dp)
Definition makesrna.cc:612
static void rna_generate_header_cpp(BlenderRNA *, FILE *f)
Definition makesrna.cc:5488
static char * rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
Definition makesrna.cc:698
static char * rna_def_property_search_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *, const char *manualfunc)
Definition makesrna.cc:1152
static void rna_print_c_string(FILE *f, const char *str)
Definition makesrna.cc:373
static void rna_set_raw_offset(FILE *f, StructRNA *srna, PropertyRNA *prop)
Definition makesrna.cc:2034
static void rna_print_id_get(FILE *f, PropertyDefRNA *)
Definition makesrna.cc:417
static int replace_if_different(const char *tmpfile, const char *dep_files[])
Definition makesrna.cc:119
static bool file_older(const char *file1, const char *file2)
Definition makesrna.cc:58
static void rna_float_print(FILE *f, float num)
Definition makesrna.cc:640
static const char * rna_type_struct(PropertyRNA *prop)
Definition makesrna.cc:551
static RNAProcessItem PROCESS_ITEMS[]
Definition makesrna.cc:4823
static void rna_generate_header(BlenderRNA *, FILE *f)
Definition makesrna.cc:5028
static const char * rna_find_dna_type(const char *type)
Definition makesrna.cc:495
static const char * cpp_classes
Definition makesrna.cc:5084
static bool rna_is_collection_functions_struct(const char **collection_structs, const char *struct_name)
Definition makesrna.cc:5434
static void mem_error_cb(const char *errorStr)
Definition makesrna.cc:5821
static char * rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
Definition makesrna.cc:1181
static int rna_enum_bitmask(PropertyRNA *prop)
Definition makesrna.cc:591
static void rna_generate_header_class_cpp(StructDefRNA *ds, FILE *f)
Definition makesrna.cc:5451
static const char * rna_ui_scale_type_string(const PropertyScaleType type)
Definition makesrna.cc:662
static void rna_generate_blender(BlenderRNA *brna, FILE *f)
Definition makesrna.cc:3720
static void rna_def_struct_function_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
Definition makesrna.cc:2997
static const char * rna_safe_id(const char *id)
Definition makesrna.cc:273
static int cmp_def_struct(const void *a, const void *b)
Definition makesrna.cc:324
static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
Definition makesrna.cc:2897
static void rna_generate_static_function_prototypes(BlenderRNA *, StructRNA *srna, FILE *f)
Definition makesrna.cc:4019
static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc)
Definition makesrna.cc:3066
static const char * rna_property_subtypename(PropertySubType type)
Definition makesrna.cc:3587
static char * rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
Definition makesrna.cc:1597
static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, PropertyRNA *prop)
Definition makesrna.cc:4101
static void rna_sort(BlenderRNA *brna)
Definition makesrna.cc:3544
void BLI_system_backtrace(FILE *fp)
Definition makesrna.cc:47
static void rna_def_function_funcs_header(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
Definition makesrna.cc:2463
static void rna_clamp_value_range(FILE *f, PropertyRNA *prop)
Definition makesrna.cc:1036
#define WRITE_PARAM(param)
Definition makesrna.cc:109
static const char * path_basename(const char *path)
Definition makesrna.cc:76
static void rna_generate_parameter_prototypes(BlenderRNA *, StructRNA *srna, FunctionRNA *func, FILE *f)
Definition makesrna.cc:3795
static void rna_generate_struct_rna_prototypes(BlenderRNA *brna, FILE *f)
Definition makesrna.cc:3708
static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc, const char *name_override, int close_prototype)
Definition makesrna.cc:3848
static int cmp_def_property(const void *a, const void *b)
Definition makesrna.cc:332
static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
Definition makesrna.cc:2473
static const char * rna_find_type(const char *type)
Definition makesrna.cc:480
#define WRITE_COMMA
Definition makesrna.cc:100
static const char * rna_parameter_type_name(PropertyRNA *parm)
Definition makesrna.cc:564
static const char * rna_type_type_name(PropertyRNA *prop)
Definition makesrna.cc:510
static const char * makesrna_path
Definition makesrna.cc:74
static void rna_generate_external_property_prototypes(BlenderRNA *brna, FILE *f)
Definition makesrna.cc:3749
static char * rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
Definition makesrna.cc:1511
static char * rna_def_property_lookup_string_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc, const char *item_type)
Definition makesrna.cc:1817
static int cmp_property(const void *a, const void *b)
Definition makesrna.cc:302
static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f)
Definition makesrna.cc:3815
static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
Definition makesrna.cc:2322
static int debugSRNA
Definition makesrna.cc:43
static void rna_construct_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type)
Definition makesrna.cc:422
static void rna_int_print(FILE *f, int64_t num)
Definition makesrna.cc:676
static void rna_sortlist(ListBase *listbase, int(*cmp)(const void *, const void *))
Definition makesrna.cc:340
static const char * rna_property_subtype_unit(PropertySubType type)
Definition makesrna.cc:3668
static void rna_generate_struct_prototypes(FILE *f)
Definition makesrna.cc:4051
static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const char *api_filename)
Definition makesrna.cc:4906
#define REN_IF_DIFF
static void rna_def_struct_function_prototype_cpp(FILE *f, StructRNA *, FunctionDefRNA *dfunc, const char *cpp_namespace, int close_prototype)
Definition makesrna.cc:2657
static void rna_def_property_wrapper_funcs(FILE *f, StructDefRNA *dsrna, PropertyDefRNA *dp)
Definition makesrna.cc:3053
static void rna_generate_struct(BlenderRNA *, StructRNA *srna, FILE *f)
Definition makesrna.cc:4622
#define TMP_EXT
Definition makesrna.cc:54
static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
Definition makesrna.cc:2765
static const char * rna_parameter_type_cpp_name(PropertyRNA *prop)
Definition makesrna.cc:2646
static char * rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *, const char *manualfunc)
Definition makesrna.cc:1930
static int cmp_struct(const void *a, const void *b)
Definition makesrna.cc:294
void * rna_alloc_from_buffer(const char *buffer, int buffer_size)
Definition makesrna.cc:439
static bool rna_is_collection_prop(PropertyRNA *prop)
Definition makesrna.cc:5423
static const char * rna_property_structname(PropertyType type)
Definition makesrna.cc:3565
static char * rna_alloc_function_name(const char *structname, const char *propname, const char *type)
Definition makesrna.cc:456
static bool rna_parameter_is_const(const PropertyDefRNA *dparm)
Definition makesrna.cc:607
static void rna_set_raw_property(PropertyDefRNA *dp, PropertyRNA *prop)
Definition makesrna.cc:1983
static void rna_construct_wrapper_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type)
Definition makesrna.cc:428
static const char * rna_function_string(T *func)
Definition makesrna.cc:635
static void make_bad_file(const char *file, int line)
Definition makesrna.cc:5615
static int rna_preprocess(const char *outfile, const char *public_header_outfile)
Definition makesrna.cc:5630
static void rna_generate_internal_property_prototypes(BlenderRNA *, StructRNA *srna, FILE *f)
Definition makesrna.cc:3768
void * MEM_mallocN(size_t len, const char *str)
Definition mallocn.cc:128
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:133
void(* MEM_set_error_callback)(void(*func)(const char *))
Definition mallocn.cc:67
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
#define T
#define L
void RNA_def_ID(BlenderRNA *brna)
Definition rna_ID.cc:2707
void RNA_def_action(BlenderRNA *brna)
void RNA_def_animation(BlenderRNA *brna)
void RNA_def_animviz(BlenderRNA *brna)
void RNA_def_annotations(BlenderRNA *brna)
void RNA_def_armature(BlenderRNA *brna)
void RNA_def_asset(BlenderRNA *brna)
Definition rna_asset.cc:753
void RNA_def_attribute(BlenderRNA *brna)
void RNA_def_blendfile_import(BlenderRNA *brna)
void RNA_def_boid(BlenderRNA *brna)
Definition rna_boid.cc:705
void RNA_def_brush(BlenderRNA *brna)
void RNA_def_cachefile(BlenderRNA *brna)
void RNA_def_camera(BlenderRNA *brna)
void RNA_def_cloth(BlenderRNA *brna)
void RNA_def_collections(BlenderRNA *brna)
void RNA_def_color(BlenderRNA *brna)
void RNA_def_constraint(BlenderRNA *brna)
void RNA_def_context(BlenderRNA *brna)
void RNA_def_curve(BlenderRNA *brna)
void RNA_def_profile(BlenderRNA *brna)
void RNA_def_curves(BlenderRNA *brna)
const char * RNA_property_typename(PropertyType type)
FunctionDefRNA * rna_find_function_def(FunctionRNA *func)
void RNA_free(BlenderRNA *brna)
BlenderRNA * RNA_create()
PropertyDefRNA * rna_find_parameter_def(PropertyRNA *parm)
int rna_parameter_size(PropertyRNA *parm)
BlenderDefRNA DefRNA
Definition rna_define.cc:65
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyDefRNA * rna_find_struct_property_def(StructRNA *srna, PropertyRNA *prop)
StructDefRNA * rna_find_struct_def(StructRNA *srna)
void RNA_define_free(BlenderRNA *)
int rna_parameter_size_pad(const int size)
void rna_addtail(ListBase *listbase, void *vlink)
void RNA_def_depsgraph(BlenderRNA *brna)
void RNA_def_dynamic_paint(BlenderRNA *brna)
void RNA_def_fcurve(BlenderRNA *brna)
void RNA_def_fluid(BlenderRNA *brna)
void RNA_def_grease_pencil(BlenderRNA *brna)
void RNA_def_image(BlenderRNA *brna)
void RNA_def_rna(BlenderRNA *brna)
Definition rna_rna.cc:3735
void RNA_def_wm(BlenderRNA *brna)
Definition rna_wm.cc:3232
void RNA_def_nla(BlenderRNA *brna)
Definition rna_nla.cc:1235
void RNA_def_sculpt_paint(BlenderRNA *brna)
void RNA_def_rigidbody(BlenderRNA *brna)
void RNA_def_palette(BlenderRNA *brna)
void RNA_def_meta(BlenderRNA *brna)
Definition rna_meta.cc:422
void RNA_def_sequencer(BlenderRNA *brna)
void RNA_def_lightprobe(BlenderRNA *brna)
void RNA_def_material(BlenderRNA *brna)
void RNA_def_test(BlenderRNA *brna)
Definition rna_test.cc:101
void RNA_def_movieclip(BlenderRNA *brna)
void RNA_def_light(BlenderRNA *brna)
Definition rna_light.cc:560
void RNA_def_shader_fx(BlenderRNA *brna)
void RNA_def_usd(BlenderRNA *brna)
Definition rna_usd.cc:160
void RNA_def_packedfile(BlenderRNA *brna)
void RNA_def_main(BlenderRNA *brna)
Definition rna_main.cc:166
void RNA_def_linestyle(BlenderRNA *brna)
void RNA_def_mesh(BlenderRNA *brna)
Definition rna_mesh.cc:3406
void RNA_def_sound(BlenderRNA *brna)
Definition rna_sound.cc:110
void RNA_def_lattice(BlenderRNA *brna)
void RNA_def_scene(BlenderRNA *brna)
void RNA_def_space(BlenderRNA *brna)
void RNA_def_speaker(BlenderRNA *brna)
void RNA_def_tracking(BlenderRNA *brna)
void RNA_def_node_socket_subtypes(BlenderRNA *brna)
void RNA_def_nodetree(BlenderRNA *brna)
void RNA_def_particle(BlenderRNA *brna)
void RNA_def_render(BlenderRNA *brna)
void RNA_def_modifier(BlenderRNA *brna)
void RNA_def_world(BlenderRNA *brna)
Definition rna_world.cc:206
void RNA_def_mask(BlenderRNA *brna)
Definition rna_mask.cc:1195
void RNA_def_workspace(BlenderRNA *brna)
void RNA_def_pose(BlenderRNA *brna)
Definition rna_pose.cc:1487
void RNA_def_node_tree_interface(BlenderRNA *brna)
void RNA_def_userdef(BlenderRNA *brna)
void RNA_def_texture(BlenderRNA *brna)
void RNA_def_wm_gizmo(BlenderRNA *brna)
void RNA_def_pointcloud(BlenderRNA *brna)
void RNA_def_vfont(BlenderRNA *brna)
Definition rna_vfont.cc:51
void RNA_def_view_layer(BlenderRNA *brna)
Definition rna_layer.cc:601
void RNA_def_object(BlenderRNA *brna)
void RNA_def_key(BlenderRNA *brna)
Definition rna_key.cc:1137
void RNA_def_object_force(BlenderRNA *brna)
void RNA_def_timeline_marker(BlenderRNA *brna)
void RNA_def_xr(BlenderRNA *brna)
Definition rna_xr.cc:2547
void RNA_def_text(BlenderRNA *brna)
Definition rna_text.cc:288
void RNA_def_screen(BlenderRNA *brna)
void RNA_def_ui(BlenderRNA *brna)
Definition rna_ui.cc:2546
void RNA_def_volume(BlenderRNA *brna)
void(*)(PointerRNA *ptr, bool *values) PropBooleanArrayGetFunc
void(*)(CollectionPropertyIterator *iter) PropCollectionNextFunc
int(*)(PointerRNA *ptr) PropStringLengthFunc
void(*)(CollectionPropertyIterator *iter, PointerRNA *ptr) PropCollectionBeginFunc
bool(*)(PointerRNA *ptr, int key, PointerRNA *r_ptr) PropCollectionLookupIntFunc
PointerRNA(*)(CollectionPropertyIterator *iter) PropCollectionGetFunc
void(*)(PointerRNA *ptr, const PointerRNA value, ReportList *reports) PropPointerSetFunc
@ PROP_INTERN_BUILTIN
@ PROP_INTERN_RAW_ACCESS
@ PROP_INTERN_PTR_OWNERSHIP_FORCED
@ PROP_INTERN_RAW_ARRAY
void(*)(PointerRNA *ptr, int value) PropEnumSetFunc
int(*)(PointerRNA *ptr) PropEnumGetFunc
bool(*)(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) PropCollectionLookupStringFunc
void(*)(PointerRNA *ptr, int value) PropIntSetFunc
PointerRNA(*)(PointerRNA *ptr) PropPointerGetFunc
void(*)(PointerRNA *ptr, const float *values) PropFloatArraySetFunc
void(*)(PointerRNA *ptr, char *value) PropStringGetFunc
void(*)(PointerRNA *ptr, bool value) PropBooleanSetFunc
int(*)(PointerRNA *ptr) PropCollectionLengthFunc
void(*)(PointerRNA *ptr, const bool *values) PropBooleanArraySetFunc
bool(*)(PointerRNA *ptr) PropBooleanGetFunc
void(*)(PointerRNA *ptr, int *values) PropIntArrayGetFunc
void(*)(PointerRNA *ptr, float value) PropFloatSetFunc
void(*)(PointerRNA *ptr, const int *values) PropIntArraySetFunc
int(*)(PointerRNA *ptr) PropIntGetFunc
void(*)(PointerRNA *ptr, const char *value) PropStringSetFunc
float(*)(PointerRNA *ptr) PropFloatGetFunc
void(*)(PointerRNA *ptr, float *values) PropFloatArrayGetFunc
void(*)(CollectionPropertyIterator *iter) PropCollectionEndFunc
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:26
#define FLT_MAX
Definition stdcycles.h:14
PropBooleanGetFuncEx get_default
PropBooleanArraySetFuncEx setarray_ex
PropBooleanArrayGetFuncEx getarray_ex
PropBooleanArraySetFunc setarray
const bool * defaultarray
PropBooleanArrayGetFuncEx get_default_array
PropBooleanSetFunc set
PropBooleanGetFunc get
PropBooleanSetFuncEx set_ex
PropBooleanGetFuncEx get_ex
PropBooleanArrayGetFunc getarray
PropCollectionNextFunc next
PropCollectionLookupStringFunc lookupstring
PropCollectionLengthFunc length
PropCollectionLookupIntFunc lookupint
PropCollectionBeginFunc begin
PropCollectionAssignIntFunc assignint
PropCollectionEndFunc end
PropCollectionGetFunc get
ListBase properties
const char * identifier
Definition RNA_types.hh:623
const char * name
Definition RNA_types.hh:627
const char * description
Definition RNA_types.hh:629
const EnumPropertyItem * item
PropEnumSetFuncEx set_ex
PropEnumGetFuncEx get_default
PropEnumGetFunc get
const char * native_enum_type
PropEnumItemFunc item_fn
PropEnumGetFuncEx get_ex
PropEnumSetFunc set
PropFloatSetFuncEx set_ex
PropertyScaleType ui_scale_type
PropFloatGetFunc get
PropFloatRangeFuncEx range_ex
PropFloatArrayGetFuncEx getarray_ex
PropFloatArraySetFuncEx setarray_ex
PropFloatArrayGetFunc getarray
PropFloatGetFuncEx get_default
PropFloatSetFunc set
const float * defaultarray
PropFloatRangeFunc range
PropFloatArraySetFunc setarray
PropFloatGetFuncEx get_ex
PropFloatArrayGetFuncEx get_default_array
const char * gencall
FunctionRNA * func
ContainerDefRNA cont
const char * call
const char * identifier
PropertyRNA * c_ret
ContainerRNA cont
const char * description
PropIntRangeFuncEx range_ex
PropIntArrayGetFunc getarray
PropIntArrayGetFuncEx getarray_ex
PropIntRangeFunc range
PropIntArraySetFunc setarray
PropIntGetFuncEx get_ex
PropIntArrayGetFuncEx get_default_array
PropIntArraySetFuncEx setarray_ex
PropertyScaleType ui_scale_type
PropIntGetFuncEx get_default
PropIntSetFuncEx set_ex
void * last
void * first
PropPointerTypeFunc type_fn
PropPointerGetFunc get
PropPointerPollFunc poll
PropPointerSetFunc set
const char * dnatype
const char * dnaname
const char * dnastructfromprop
const char * dnastructname
const char * dnalengthname
const char * dnastructfromname
PropertyDefRNA * next
PropertyRNA * prop
ItemEditableFunc itemeditable
PropArrayLengthGetFunc getlength
const char * translation_context
RNAPropOverrideApply override_apply
unsigned int arraydimension
PropertyRNA * prev
EditableFunc editable
PropertyPathTemplateType path_template_type
RNAPropOverrideStore override_store
PropertyRNA * next
RNAPropOverrideDiff override_diff
PropertySubType subtype
unsigned int arraylength[RNA_MAX_ARRAY_DIMENSION]
const char * description
const char * name
unsigned int totarraylength
const char * identifier
RawPropertyType rawtype
PropertyType type
void(* define)(BlenderRNA *brna)
Definition makesrna.cc:4820
const char * filename
Definition makesrna.cc:4818
const char * api_filename
Definition makesrna.cc:4819
StringPropertyPathFilterFunc path_filter
PropStringSetFunc set
PropStringLengthFuncEx length_ex
PropStringLengthFunc length
PropStringGetFuncEx get_ex
PropStringSetFuncEx set_ex
PropStringGetFunc get
StringPropertySearchFunc search
eStringPropertySearchFlag search_flag
const char * dnaname
ContainerDefRNA cont
StructRNA * srna
ListBase functions
const char * filename
const char * dnafromprop
const char * dnafromname
StructRNA * nested
StructRegisterFunc reg
StructUnregisterFunc unreg
const char * name
const char * identifier
StructInstanceFunc instance
ContainerRNA cont
const char * translation_context
PropertyRNA * nameproperty
const char * description
IDPropertiesFunc idproperties
PropertyRNA * iteratorproperty
StructRNA * base
StructRefineFunc refine
StructPathFunc path
i
Definition text_draw.cc:230
uint len
uint8_t flag
Definition wm_window.cc:139