Blender V4.3
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
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 = static_cast<char *>(MEM_mallocN(sizeof(char) * len_new, "rna_cmp_file_new"));
243 arr_org = static_cast<char *>(MEM_mallocN(sizeof(char) * 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 = static_cast<void **>(MEM_mallocN(sizeof(void *) * 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 = static_cast<AllocDefRNA *>(MEM_callocN(sizeof(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 = static_cast<AllocDefRNA *>(MEM_callocN(sizeof(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_inherit_refine(ptr, &RNA_%s, &data->%s);\n",
839 (const char *)pprop->type,
840 dp->dnaname);
841 }
842 else {
843 fprintf(f,
844 " return rna_pointer_inherit_refine(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_inherit_refine(&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 int length = strlen(value);\n");
1225 fprintf(f, " if (length > 0) {\n");
1226 fprintf(
1227 f, " data->%s = (char *)MEM_mallocN(length + 1, __func__);\n", dp->dnaname);
1228 fprintf(f, " memcpy(data->%s, value, length + 1);\n", dp->dnaname);
1229 fprintf(f, " } else { data->%s = nullptr; }\n", dp->dnaname);
1230 }
1231 else {
1232 const char *string_copy_func =
1234 "BLI_strncpy" :
1235 "BLI_strncpy_utf8";
1236 /* Handle char array properties. */
1237 if (sprop->maxlength) {
1238 fprintf(f,
1239 " %s(data->%s, value, %d);\n",
1240 string_copy_func,
1241 dp->dnaname,
1242 sprop->maxlength);
1243 }
1244 else {
1245 fprintf(f,
1246 " %s(data->%s, value, sizeof(data->%s));\n",
1247 string_copy_func,
1248 dp->dnaname,
1249 dp->dnaname);
1250 }
1251 }
1252 }
1253 fprintf(f, "}\n\n");
1254 break;
1255 }
1256 case PROP_POINTER: {
1257 fprintf(f,
1258 "extern void %s(PointerRNA *ptr, PointerRNA value, struct ReportList *reports)\n",
1259 func);
1260 fprintf(f, "{\n");
1261 if (manualfunc) {
1262 fprintf(f, " PropPointerSetFunc fn = %s;\n", manualfunc);
1263 fprintf(f, " fn(ptr, value, reports);\n");
1264 }
1265 else {
1266 rna_print_data_get(f, dp);
1267
1269 StructRNA *type = (pprop->type) ? rna_find_struct((const char *)pprop->type) : nullptr;
1270
1271 if (prop->flag & PROP_ID_SELF_CHECK) {
1272 /* No pointers to self allowed. */
1273 rna_print_id_get(f, dp);
1274 fprintf(f, " if (id == value.data) {\n");
1275 fprintf(f, " return;\n");
1276 fprintf(f, " }\n");
1277 }
1278
1279 if (type && (type->flag & STRUCT_ID)) {
1280 /* Check if pointers between datablocks are allowed. */
1281 fprintf(f,
1282 " if (value.data && ptr->owner_id && value.owner_id && "
1283 "!BKE_id_can_use_id(*ptr->owner_id, *value.owner_id)) {\n");
1284 fprintf(f, " return;\n");
1285 fprintf(f, " }\n");
1286 }
1287
1288 if (prop->flag & PROP_ID_REFCOUNT) {
1289 /* Perform reference counting. */
1290 fprintf(f, "\n if (data->%s) {\n", dp->dnaname);
1291 fprintf(f, " id_us_min((ID *)data->%s);\n", dp->dnaname);
1292 fprintf(f, " }\n");
1293 fprintf(f, " if (value.data) {\n");
1294 fprintf(f, " id_us_plus((ID *)value.data);\n");
1295 fprintf(f, " }\n");
1296 }
1297 else if (type && (type->flag & STRUCT_ID)) {
1298 /* Still mark linked data as used if not reference counting. */
1299 fprintf(f, " if (value.data) {\n");
1300 fprintf(f, " id_lib_extern((ID *)value.data);\n");
1301 fprintf(f, " }\n");
1302 }
1303
1304 fprintf(f, " *(void **)&data->%s = value.data;\n", dp->dnaname);
1305 }
1306 fprintf(f, "}\n\n");
1307 break;
1308 }
1309 default:
1310 if (prop->arraydimension) {
1311 if (prop->flag & PROP_DYNAMIC) {
1312 fprintf(f,
1313 "extern void %s(PointerRNA *ptr, const %s values[])\n",
1314 func,
1315 rna_type_type(prop));
1316 }
1317 else {
1318 fprintf(f,
1319 "extern void %s(PointerRNA *ptr, const %s values[%u])\n",
1320 func,
1321 rna_type_type(prop),
1322 prop->totarraylength);
1323 }
1324 fprintf(f, "{\n");
1325
1326 if (manualfunc) {
1327 /* Assign `fn` to ensure function signatures match. */
1328 if (prop->type == PROP_BOOLEAN) {
1329 fprintf(f, " PropBooleanArraySetFunc fn = %s;\n", manualfunc);
1330 fprintf(f, " fn(ptr, values);\n");
1331 }
1332 else if (prop->type == PROP_INT) {
1333 fprintf(f, " PropIntArraySetFunc fn = %s;\n", manualfunc);
1334 fprintf(f, " fn(ptr, values);\n");
1335 }
1336 else if (prop->type == PROP_FLOAT) {
1337 fprintf(f, " PropFloatArraySetFunc fn = %s;\n", manualfunc);
1338 fprintf(f, " fn(ptr, values);\n");
1339 }
1340 else {
1341 BLI_assert_unreachable(); /* Valid but should be handled by type checks. */
1342 fprintf(f, " %s(ptr, values);\n", manualfunc);
1343 }
1344 }
1345 else {
1346 rna_print_data_get(f, dp);
1347
1348 if (prop->flag & PROP_DYNAMIC) {
1349 char *lenfunc = rna_alloc_function_name(
1350 srna->identifier, rna_safe_id(prop->identifier), "set_length");
1351 fprintf(f, " unsigned int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
1352 fprintf(f, " unsigned int len = %s(ptr, arraylen);\n\n", lenfunc);
1353 rna_clamp_value_range(f, prop);
1354 fprintf(f, " for (i = 0; i < len; i++) {\n");
1355 MEM_freeN(lenfunc);
1356 }
1357 else {
1358 fprintf(f, " unsigned int i;\n\n");
1359 rna_clamp_value_range(f, prop);
1360 fprintf(f, " for (i = 0; i < %u; i++) {\n", prop->totarraylength);
1361 }
1362
1363 if (dp->dnaarraylength == 1) {
1364 if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
1365 fprintf(f,
1366 " if (%svalues[i]) { data->%s |= (",
1367 (dp->booleannegative) ? "!" : "",
1368 dp->dnaname);
1369 rna_int_print(f, dp->booleanbit);
1370 fprintf(f, " << i); }\n");
1371 fprintf(f, " else { data->%s &= ~(", dp->dnaname);
1372 rna_int_print(f, dp->booleanbit);
1373 fprintf(f, " << i); }\n");
1374 }
1375 else {
1376 fprintf(
1377 f, " (&data->%s)[i] = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
1378 rna_clamp_value(f, prop, 1);
1379 }
1380 }
1381 else {
1382 if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
1383 fprintf(f,
1384 " if (%svalues[i]) { data->%s[i] |= ",
1385 (dp->booleannegative) ? "!" : "",
1386 dp->dnaname);
1387 rna_int_print(f, dp->booleanbit);
1388 fprintf(f, "; }\n");
1389 fprintf(f, " else { data->%s[i] &= ~", dp->dnaname);
1390 rna_int_print(f, dp->booleanbit);
1391 fprintf(f, "; }\n");
1392 }
1393 else if (rna_color_quantize(prop, dp)) {
1394 fprintf(
1395 f, " data->%s[i] = unit_float_to_uchar_clamp(values[i]);\n", dp->dnaname);
1396 }
1397 else {
1398 if (dp->dnatype) {
1399 fprintf(f,
1400 " ((%s *)data->%s)[i] = %s",
1401 dp->dnatype,
1402 dp->dnaname,
1403 (dp->booleannegative) ? "!" : "");
1404 }
1405 else {
1406 fprintf(f,
1407 " (data->%s)[i] = %s",
1408 dp->dnaname,
1409 (dp->booleannegative) ? "!" : "");
1410 }
1411 rna_clamp_value(f, prop, 1);
1412 }
1413 }
1414 fprintf(f, " }\n");
1415 }
1416
1417#ifdef USE_RNA_RANGE_CHECK
1418 if (dp->dnaname && manualfunc == nullptr) {
1419 if (dp->dnaarraylength == 1) {
1420 rna_clamp_value_range_check(f, prop, "data->", dp->dnaname);
1421 }
1422 else {
1423 rna_clamp_value_range_check(f, prop, "*data->", dp->dnaname);
1424 }
1425 }
1426#endif
1427
1428 fprintf(f, "}\n\n");
1429 }
1430 else {
1431 fprintf(f, "extern void %s(PointerRNA *ptr, %s value)\n", func, rna_type_type(prop));
1432 fprintf(f, "{\n");
1433
1434 if (manualfunc) {
1435 /* Assign `fn` to ensure function signatures match. */
1436 if (prop->type == PROP_BOOLEAN) {
1437 fprintf(f, " PropBooleanSetFunc fn = %s;\n", manualfunc);
1438 fprintf(f, " fn(ptr, value);\n");
1439 }
1440 else if (prop->type == PROP_INT) {
1441 fprintf(f, " PropIntSetFunc fn = %s;\n", manualfunc);
1442 fprintf(f, " fn(ptr, value);\n");
1443 }
1444 else if (prop->type == PROP_FLOAT) {
1445 fprintf(f, " PropFloatSetFunc fn = %s;\n", manualfunc);
1446 fprintf(f, " fn(ptr, value);\n");
1447 }
1448 else if (prop->type == PROP_ENUM) {
1449 fprintf(f, " PropEnumSetFunc fn = %s;\n", manualfunc);
1450 fprintf(f, " fn(ptr, value);\n");
1451 }
1452 else {
1453 BLI_assert_unreachable(); /* Valid but should be handled by type checks. */
1454 fprintf(f, " %s(ptr, value);\n", manualfunc);
1455 }
1456 }
1457 else {
1458 rna_print_data_get(f, dp);
1459 if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
1460 fprintf(f,
1461 " if (%svalue) { data->%s |= ",
1462 (dp->booleannegative) ? "!" : "",
1463 dp->dnaname);
1464 rna_int_print(f, dp->booleanbit);
1465 fprintf(f, "; }\n");
1466 fprintf(f, " else { data->%s &= ~", dp->dnaname);
1467 rna_int_print(f, dp->booleanbit);
1468 fprintf(f, "; }\n");
1469 }
1470 else if (prop->type == PROP_ENUM && dp->enumbitflags) {
1471 fprintf(f, " data->%s &= ~", dp->dnaname);
1473 fprintf(f, ";\n");
1474 fprintf(f, " data->%s |= value;\n", dp->dnaname);
1475 }
1476 else {
1477 rna_clamp_value_range(f, prop);
1478 /* C++ may require casting to an enum type. */
1479 fprintf(f, "#ifdef __cplusplus\n");
1480 fprintf(f,
1481 /* If #rna_clamp_value() adds an expression like `std::clamp(...)`
1482 * (instead of an `lvalue`), #decltype() yields a reference,
1483 * so that has to be removed. */
1484 " data->%s = %s(std::remove_reference_t<decltype(data->%s)>)",
1485 dp->dnaname,
1486 (dp->booleannegative) ? "!" : "",
1487 dp->dnaname);
1488 rna_clamp_value(f, prop, 0);
1489 fprintf(f, "#else\n");
1490 fprintf(f, " data->%s = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
1491 rna_clamp_value(f, prop, 0);
1492 fprintf(f, "#endif\n");
1493 }
1494 }
1495
1496#ifdef USE_RNA_RANGE_CHECK
1497 if (dp->dnaname && manualfunc == nullptr) {
1498 rna_clamp_value_range_check(f, prop, "data->", dp->dnaname);
1499 }
1500#endif
1501
1502 fprintf(f, "}\n\n");
1503 }
1504 break;
1505 }
1506
1507 return func;
1508}
1509
1511 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
1512{
1513 char *func = nullptr;
1514
1515 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1516 return nullptr;
1517 }
1518
1519 if (prop->type == PROP_STRING) {
1520 if (!manualfunc) {
1521 if (!dp->dnastructname || !dp->dnaname) {
1522 CLOG_ERROR(&LOG, "%s.%s has no valid dna info.", srna->identifier, prop->identifier);
1523 DefRNA.error = true;
1524 return nullptr;
1525 }
1526 }
1527
1528 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "length");
1529
1530 fprintf(f, "extern int %s(PointerRNA *ptr)\n", func);
1531 fprintf(f, "{\n");
1532 if (manualfunc) {
1533 fprintf(f, " PropStringLengthFunc fn = %s;\n", manualfunc);
1534 fprintf(f, " return fn(ptr);\n");
1535 }
1536 else {
1537 rna_print_data_get(f, dp);
1538 if (dp->dnapointerlevel == 1) {
1539 /* Handle allocated char pointer properties. */
1540 fprintf(f,
1541 " return (data->%s == nullptr) ? 0 : strlen(data->%s);\n",
1542 dp->dnaname,
1543 dp->dnaname);
1544 }
1545 else {
1546 /* Handle char array properties. */
1547 fprintf(f, " return strlen(data->%s);\n", dp->dnaname);
1548 }
1549 }
1550 fprintf(f, "}\n\n");
1551 }
1552 else if (prop->type == PROP_COLLECTION) {
1553 if (!manualfunc) {
1554 if (prop->type == PROP_COLLECTION &&
1555 (!(dp->dnalengthname || dp->dnalengthfixed) || !dp->dnaname))
1556 {
1557 CLOG_ERROR(&LOG, "%s.%s has no valid dna info.", srna->identifier, prop->identifier);
1558 DefRNA.error = true;
1559 return nullptr;
1560 }
1561 }
1562
1563 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "length");
1564
1565 fprintf(f, "extern int %s(PointerRNA *ptr)\n", func);
1566 fprintf(f, "{\n");
1567 if (manualfunc) {
1568 fprintf(f, " PropCollectionLengthFunc fn = %s;\n", manualfunc);
1569 fprintf(f, " return fn(ptr);\n");
1570 }
1571 else {
1572 if (dp->dnaarraylength <= 1 || dp->dnalengthname) {
1573 rna_print_data_get(f, dp);
1574 }
1575
1576 if (dp->dnaarraylength > 1) {
1577 fprintf(f, " return ");
1578 }
1579 else {
1580 fprintf(f, " return (data->%s == nullptr) ? 0 : ", dp->dnaname);
1581 }
1582
1583 if (dp->dnalengthname) {
1584 fprintf(f, "data->%s;\n", dp->dnalengthname);
1585 }
1586 else {
1587 fprintf(f, "%d;\n", dp->dnalengthfixed);
1588 }
1589 }
1590 fprintf(f, "}\n\n");
1591 }
1592
1593 return func;
1594}
1595
1597 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
1598{
1599 char *func, *getfunc;
1600
1601 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1602 return nullptr;
1603 }
1604
1605 if (!manualfunc) {
1606 if (!dp->dnastructname || !dp->dnaname) {
1607 CLOG_ERROR(&LOG, "%s.%s has no valid dna info.", srna->identifier, prop->identifier);
1608 DefRNA.error = true;
1609 return nullptr;
1610 }
1611 }
1612
1613 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "begin");
1614
1615 fprintf(f, "extern void %s(CollectionPropertyIterator *iter, PointerRNA *ptr)\n", func);
1616 fprintf(f, "{\n");
1617
1618 if (!manualfunc) {
1619 rna_print_data_get(f, dp);
1620 }
1621
1622 fprintf(f, "\n memset(iter, 0, sizeof(*iter));\n");
1623 fprintf(f, " iter->parent = *ptr;\n");
1624 fprintf(f, " iter->prop = &rna_%s_%s;\n", srna->identifier, prop->identifier);
1625
1626 if (dp->dnalengthname || dp->dnalengthfixed) {
1627 if (manualfunc) {
1628 fprintf(f, "\n PropCollectionBeginFunc fn = %s;\n", manualfunc);
1629 fprintf(f, " fn(iter, ptr);\n");
1630 }
1631 else {
1632 if (dp->dnalengthname) {
1633 fprintf(f,
1634 "\n rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), data->%s, 0, "
1635 "nullptr);\n",
1636 dp->dnaname,
1637 dp->dnaname,
1638 dp->dnalengthname);
1639 }
1640 else {
1641 fprintf(f,
1642 "\n rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), %d, 0, "
1643 "nullptr);\n",
1644 dp->dnaname,
1645 dp->dnaname,
1646 dp->dnalengthfixed);
1647 }
1648 }
1649 }
1650 else {
1651 if (manualfunc) {
1652 fprintf(f, "\n PropCollectionBeginFunc fn = %s;\n", manualfunc);
1653 fprintf(f, " fn(iter, ptr);\n");
1654 }
1655 else if (dp->dnapointerlevel == 0) {
1656 fprintf(f, "\n rna_iterator_listbase_begin(iter, &data->%s, nullptr);\n", dp->dnaname);
1657 }
1658 else {
1659 fprintf(f, "\n rna_iterator_listbase_begin(iter, data->%s, nullptr);\n", dp->dnaname);
1660 }
1661 }
1662
1663 getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
1664
1665 fprintf(f, "\n if (iter->valid) {\n");
1666 fprintf(f, " iter->ptr = %s(iter);", getfunc);
1667 fprintf(f, "\n }\n");
1668
1669 fprintf(f, "}\n\n");
1670
1671 return func;
1672}
1673
1675 StructRNA *srna,
1676 PropertyRNA *prop,
1677 PropertyDefRNA *dp,
1678 const char *manualfunc,
1679 const char *nextfunc)
1680{
1681 /* note on indices, this is for external functions and ignores skipped values.
1682 * so the index can only be checked against the length when there is no 'skip' function. */
1683 char *func;
1684
1685 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1686 return nullptr;
1687 }
1688
1689 if (!manualfunc) {
1690 if (!dp->dnastructname || !dp->dnaname) {
1691 return nullptr;
1692 }
1693
1694 /* only supported in case of standard next functions */
1695 if (STREQ(nextfunc, "rna_iterator_array_next")) {
1696 }
1697 else if (STREQ(nextfunc, "rna_iterator_listbase_next")) {
1698 }
1699 else {
1700 return nullptr;
1701 }
1702 }
1703
1704 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "lookup_int");
1705
1706 fprintf(f, "extern bool %s(PointerRNA *ptr, int index, PointerRNA *r_ptr)\n", func);
1707 fprintf(f, "{\n");
1708
1709 if (manualfunc) {
1710 fprintf(f, "\n PropCollectionLookupIntFunc fn = %s;\n", manualfunc);
1711 fprintf(f, " return fn(ptr, index, r_ptr);\n");
1712 fprintf(f, "}\n\n");
1713 return func;
1714 }
1715
1716 fprintf(f, " bool found = false;\n");
1717 fprintf(f, " CollectionPropertyIterator iter;\n\n");
1718
1719 fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier));
1720 fprintf(f, " if (iter.valid) {\n");
1721
1722 if (STREQ(nextfunc, "rna_iterator_array_next")) {
1723 fprintf(f, " ArrayIterator *internal = &iter.internal.array;\n");
1724 fprintf(f, " if (index < 0 || index >= internal->length) {\n");
1725 fprintf(f, "#ifdef __GNUC__\n");
1726 fprintf(f,
1727 " printf(\"Array iterator out of range: %%s (index %%d)\\n\", __func__, "
1728 "index);\n");
1729 fprintf(f, "#else\n");
1730 fprintf(f, " printf(\"Array iterator out of range: (index %%d)\\n\", index);\n");
1731 fprintf(f, "#endif\n");
1732 fprintf(f, " }\n");
1733 fprintf(f, " else if (internal->skip) {\n");
1734 fprintf(f, " while (index-- > 0 && iter.valid) {\n");
1735 fprintf(f, " rna_iterator_array_next(&iter);\n");
1736 fprintf(f, " }\n");
1737 fprintf(f, " found = (index == -1 && iter.valid);\n");
1738 fprintf(f, " }\n");
1739 fprintf(f, " else {\n");
1740 fprintf(f, " internal->ptr += internal->itemsize * index;\n");
1741 fprintf(f, " found = 1;\n");
1742 fprintf(f, " }\n");
1743 }
1744 else if (STREQ(nextfunc, "rna_iterator_listbase_next")) {
1745 fprintf(f, " ListBaseIterator *internal = &iter.internal.listbase;\n");
1746 fprintf(f, " if (internal->skip) {\n");
1747 fprintf(f, " while (index-- > 0 && iter.valid) {\n");
1748 fprintf(f, " rna_iterator_listbase_next(&iter);\n");
1749 fprintf(f, " }\n");
1750 fprintf(f, " found = (index == -1 && iter.valid);\n");
1751 fprintf(f, " }\n");
1752 fprintf(f, " else {\n");
1753 fprintf(f, " while (index-- > 0 && internal->link) {\n");
1754 fprintf(f, " internal->link = internal->link->next;\n");
1755 fprintf(f, " }\n");
1756 fprintf(f, " found = (index == -1 && internal->link);\n");
1757 fprintf(f, " }\n");
1758 }
1759
1760 fprintf(f,
1761 " if (found) { *r_ptr = %s_%s_get(&iter); }\n",
1762 srna->identifier,
1763 rna_safe_id(prop->identifier));
1764 fprintf(f, " }\n\n");
1765 fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, rna_safe_id(prop->identifier));
1766
1767 fprintf(f, " return found;\n");
1768
1769#if 0
1770 rna_print_data_get(f, dp);
1771 item_type = (cprop->item_type) ? (const char *)cprop->item_type : "UnknownType";
1772
1773 if (dp->dnalengthname || dp->dnalengthfixed) {
1774 if (dp->dnalengthname) {
1775 fprintf(f,
1776 "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), data->%s, "
1777 "index);\n",
1778 item_type,
1779 dp->dnaname,
1780 dp->dnaname,
1781 dp->dnalengthname);
1782 }
1783 else {
1784 fprintf(
1785 f,
1786 "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), %d, index);\n",
1787 item_type,
1788 dp->dnaname,
1789 dp->dnaname,
1790 dp->dnalengthfixed);
1791 }
1792 }
1793 else {
1794 if (dp->dnapointerlevel == 0) {
1795 fprintf(f,
1796 "\n return rna_listbase_lookup_int(ptr, &RNA_%s, &data->%s, index);\n",
1797 item_type,
1798 dp->dnaname);
1799 }
1800 else {
1801 fprintf(f,
1802 "\n return rna_listbase_lookup_int(ptr, &RNA_%s, data->%s, index);\n",
1803 item_type,
1804 dp->dnaname);
1805 }
1806 }
1807#endif
1808
1809 fprintf(f, "}\n\n");
1810
1811 return func;
1812}
1813
1815 StructRNA *srna,
1816 PropertyRNA *prop,
1817 PropertyDefRNA *dp,
1818 const char *manualfunc,
1819 const char *item_type)
1820{
1821 char *func;
1822 StructRNA *item_srna, *item_name_base;
1823 PropertyRNA *item_name_prop;
1824 const int namebuflen = 1024;
1825
1826 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1827 return nullptr;
1828 }
1829
1830 if (!manualfunc) {
1831 if (!dp->dnastructname || !dp->dnaname) {
1832 return nullptr;
1833 }
1834
1835 /* only supported for collection items with name properties */
1836 item_srna = rna_find_struct(item_type);
1837 if (item_srna && item_srna->nameproperty) {
1838 item_name_prop = item_srna->nameproperty;
1839 item_name_base = item_srna;
1840 while (item_name_base->base && item_name_base->base->nameproperty == item_name_prop) {
1841 item_name_base = item_name_base->base;
1842 }
1843 }
1844 else {
1845 return nullptr;
1846 }
1847 }
1848
1849 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "lookup_string");
1850
1851 if (!manualfunc) {
1852 /* XXX extern declaration could be avoid by including RNA_blender.hh, but this has lots of
1853 * unknown DNA types in functions, leading to conflicting function signatures.
1854 */
1855 fprintf(f,
1856 "extern int %s_%s_length(PointerRNA *);\n",
1857 item_name_base->identifier,
1858 rna_safe_id(item_name_prop->identifier));
1859 fprintf(f,
1860 "extern void %s_%s_get(PointerRNA *, char *);\n\n",
1861 item_name_base->identifier,
1862 rna_safe_id(item_name_prop->identifier));
1863 }
1864
1865 fprintf(f, "extern bool %s(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)\n", func);
1866 fprintf(f, "{\n");
1867
1868 if (manualfunc) {
1869 fprintf(f, " PropCollectionLookupStringFunc fn = %s;\n", manualfunc);
1870 fprintf(f, " return fn(ptr, key, r_ptr);\n");
1871 fprintf(f, "}\n\n");
1872 return func;
1873 }
1874
1875 fprintf(f, " bool found = false;\n");
1876 fprintf(f, " CollectionPropertyIterator iter;\n");
1877 fprintf(f, " char namebuf[%d];\n", namebuflen);
1878 fprintf(f, " char *name;\n\n");
1879
1880 fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier));
1881
1882 fprintf(f, " while (iter.valid) {\n");
1883 fprintf(f, " if (iter.ptr.data) {\n");
1884 fprintf(f,
1885 " int namelen = %s_%s_length(&iter.ptr);\n",
1886 item_name_base->identifier,
1887 rna_safe_id(item_name_prop->identifier));
1888 fprintf(f, " if (namelen < %d) {\n", namebuflen);
1889 fprintf(f,
1890 " %s_%s_get(&iter.ptr, namebuf);\n",
1891 item_name_base->identifier,
1892 rna_safe_id(item_name_prop->identifier));
1893 fprintf(f, " if (strcmp(namebuf, key) == 0) {\n");
1894 fprintf(f, " found = true;\n");
1895 fprintf(f, " *r_ptr = iter.ptr;\n");
1896 fprintf(f, " break;\n");
1897 fprintf(f, " }\n");
1898 fprintf(f, " }\n");
1899 fprintf(f, " else {\n");
1900 fprintf(f, " name = (char *)MEM_mallocN(namelen+1, \"name string\");\n");
1901 fprintf(f,
1902 " %s_%s_get(&iter.ptr, name);\n",
1903 item_name_base->identifier,
1904 rna_safe_id(item_name_prop->identifier));
1905 fprintf(f, " if (strcmp(name, key) == 0) {\n");
1906 fprintf(f, " MEM_freeN(name);\n\n");
1907 fprintf(f, " found = true;\n");
1908 fprintf(f, " *r_ptr = iter.ptr;\n");
1909 fprintf(f, " break;\n");
1910 fprintf(f, " }\n");
1911 fprintf(f, " else {\n");
1912 fprintf(f, " MEM_freeN(name);\n");
1913 fprintf(f, " }\n");
1914 fprintf(f, " }\n");
1915 fprintf(f, " }\n");
1916 fprintf(f, " %s_%s_next(&iter);\n", srna->identifier, rna_safe_id(prop->identifier));
1917 fprintf(f, " }\n");
1918 fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, rna_safe_id(prop->identifier));
1919
1920 fprintf(f, " return found;\n");
1921 fprintf(f, "}\n\n");
1922
1923 return func;
1924}
1925
1927 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA * /*dp*/, const char *manualfunc)
1928{
1929 char *func, *getfunc;
1930
1931 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1932 return nullptr;
1933 }
1934
1935 if (!manualfunc) {
1936 return nullptr;
1937 }
1938
1939 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "next");
1940
1941 fprintf(f, "extern void %s(CollectionPropertyIterator *iter)\n", func);
1942 fprintf(f, "{\n");
1943 fprintf(f, " PropCollectionNextFunc fn = %s;\n", manualfunc);
1944 fprintf(f, " fn(iter);\n");
1945
1946 getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
1947
1948 fprintf(f, "\n if (iter->valid) {\n");
1949 fprintf(f, " iter->ptr = %s(iter);", getfunc);
1950 fprintf(f, "\n }\n");
1951
1952 fprintf(f, "}\n\n");
1953
1954 return func;
1955}
1956
1958 FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA * /*dp*/, const char *manualfunc)
1959{
1960 char *func;
1961
1962 if (prop->flag & PROP_IDPROPERTY && manualfunc == nullptr) {
1963 return nullptr;
1964 }
1965
1966 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "end");
1967
1968 fprintf(f, "extern void %s(CollectionPropertyIterator *iter)\n", func);
1969 fprintf(f, "{\n");
1970 if (manualfunc) {
1971 fprintf(f, " PropCollectionEndFunc fn = %s;\n", manualfunc);
1972 fprintf(f, " fn(iter);\n");
1973 }
1974 fprintf(f, "}\n\n");
1975
1976 return func;
1977}
1978
1980{
1981 if (dp->dnapointerlevel != 0) {
1982 return;
1983 }
1984 if (!dp->dnatype || !dp->dnaname || !dp->dnastructname) {
1985 return;
1986 }
1987
1988 if (STREQ(dp->dnatype, "char")) {
1991 }
1992 else if (STREQ(dp->dnatype, "int8_t")) {
1995 }
1996 else if (STREQ(dp->dnatype, "uchar")) {
1999 }
2000 else if (STREQ(dp->dnatype, "short")) {
2001 prop->rawtype = PROP_RAW_SHORT;
2003 }
2004 else if (STREQ(dp->dnatype, "ushort")) {
2005 prop->rawtype = PROP_RAW_UINT16;
2007 }
2008 else if (STREQ(dp->dnatype, "int")) {
2009 prop->rawtype = PROP_RAW_INT;
2011 }
2012 else if (STREQ(dp->dnatype, "float")) {
2013 prop->rawtype = PROP_RAW_FLOAT;
2015 }
2016 else if (STREQ(dp->dnatype, "double")) {
2017 prop->rawtype = PROP_RAW_DOUBLE;
2019 }
2020 else if (STREQ(dp->dnatype, "int64_t")) {
2021 prop->rawtype = PROP_RAW_INT64;
2023 }
2024 else if (STREQ(dp->dnatype, "uint64_t")) {
2025 prop->rawtype = PROP_RAW_UINT64;
2027 }
2028}
2029
2030static void rna_set_raw_offset(FILE *f, StructRNA *srna, PropertyRNA *prop)
2031{
2033
2034 fprintf(
2035 f, "\toffsetof(%s, %s), (RawPropertyType)%d", dp->dnastructname, dp->dnaname, prop->rawtype);
2036}
2037
2038static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
2039{
2040 PropertyRNA *prop;
2041
2042 prop = dp->prop;
2043
2044 switch (prop->type) {
2045 case PROP_BOOLEAN: {
2046 BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
2047
2048 if (!(prop->flag & PROP_EDITABLE) &&
2049 (bprop->set || bprop->set_ex || bprop->setarray || bprop->setarray_ex))
2050 {
2051 CLOG_ERROR(&LOG,
2052 "%s.%s, is read-only but has defines a \"set\" callback.",
2053 srna->identifier,
2054 prop->identifier);
2055 DefRNA.error = true;
2056 }
2057
2058 if (!prop->arraydimension &&
2059 (bprop->getarray || bprop->getarray_ex || bprop->setarray || bprop->setarray_ex))
2060 {
2061 CLOG_ERROR(&LOG,
2062 "%s.%s, is not an array but defines an array callback.",
2063 srna->identifier,
2064 prop->identifier);
2065 DefRNA.error = true;
2066 }
2067
2068 if (!prop->arraydimension) {
2069 if (!bprop->get && !bprop->set && !dp->booleanbit) {
2070 rna_set_raw_property(dp, prop);
2071 }
2072
2073 bprop->get = reinterpret_cast<PropBooleanGetFunc>(
2074 rna_def_property_get_func(f, srna, prop, dp, (const char *)bprop->get));
2075 bprop->set = reinterpret_cast<PropBooleanSetFunc>(
2076 rna_def_property_set_func(f, srna, prop, dp, (const char *)bprop->set));
2077 }
2078 else {
2079 bprop->getarray = reinterpret_cast<PropBooleanArrayGetFunc>(
2080 rna_def_property_get_func(f, srna, prop, dp, (const char *)bprop->getarray));
2081 bprop->setarray = reinterpret_cast<PropBooleanArraySetFunc>(
2082 rna_def_property_set_func(f, srna, prop, dp, (const char *)bprop->setarray));
2083 }
2084 break;
2085 }
2086 case PROP_INT: {
2087 IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
2088
2089 if (!(prop->flag & PROP_EDITABLE) &&
2090 (iprop->set || iprop->set_ex || iprop->setarray || iprop->setarray_ex))
2091 {
2092 CLOG_ERROR(&LOG,
2093 "%s.%s, is read-only but has defines a \"set\" callback.",
2094 srna->identifier,
2095 prop->identifier);
2096 DefRNA.error = true;
2097 }
2098
2099 if (!prop->arraydimension &&
2100 (iprop->getarray || iprop->getarray_ex || iprop->setarray || iprop->setarray_ex))
2101 {
2102 CLOG_ERROR(&LOG,
2103 "%s.%s, is not an array but defines an array callback.",
2104 srna->identifier,
2105 prop->identifier);
2106 DefRNA.error = true;
2107 }
2108
2109 if (!prop->arraydimension) {
2110 if (!iprop->get && !iprop->set) {
2111 rna_set_raw_property(dp, prop);
2112 }
2113
2114 iprop->get = reinterpret_cast<PropIntGetFunc>(
2115 rna_def_property_get_func(f, srna, prop, dp, (const char *)iprop->get));
2116 iprop->set = reinterpret_cast<PropIntSetFunc>(
2117 rna_def_property_set_func(f, srna, prop, dp, (const char *)iprop->set));
2118 }
2119 else {
2120 if (!iprop->getarray && !iprop->setarray) {
2121 rna_set_raw_property(dp, prop);
2122 }
2123
2124 iprop->getarray = reinterpret_cast<PropIntArrayGetFunc>(
2125 rna_def_property_get_func(f, srna, prop, dp, (const char *)iprop->getarray));
2126 iprop->setarray = reinterpret_cast<PropIntArraySetFunc>(
2127 rna_def_property_set_func(f, srna, prop, dp, (const char *)iprop->setarray));
2128 }
2129 break;
2130 }
2131 case PROP_FLOAT: {
2132 FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
2133
2134 if (!(prop->flag & PROP_EDITABLE) &&
2135 (fprop->set || fprop->set_ex || fprop->setarray || fprop->setarray_ex))
2136 {
2137 CLOG_ERROR(&LOG,
2138 "%s.%s, is read-only but has defines a \"set\" callback.",
2139 srna->identifier,
2140 prop->identifier);
2141 DefRNA.error = true;
2142 }
2143
2144 if (!prop->arraydimension &&
2145 (fprop->getarray || fprop->getarray_ex || fprop->setarray || fprop->setarray_ex))
2146 {
2147 CLOG_ERROR(&LOG,
2148 "%s.%s, is not an array but defines an array callback.",
2149 srna->identifier,
2150 prop->identifier);
2151 DefRNA.error = true;
2152 }
2153
2154 if (!prop->arraydimension) {
2155 if (!fprop->get && !fprop->set) {
2156 rna_set_raw_property(dp, prop);
2157 }
2158
2159 fprop->get = reinterpret_cast<PropFloatGetFunc>(
2160 rna_def_property_get_func(f, srna, prop, dp, (const char *)fprop->get));
2161 fprop->set = reinterpret_cast<PropFloatSetFunc>(
2162 rna_def_property_set_func(f, srna, prop, dp, (const char *)fprop->set));
2163 }
2164 else {
2165 if (!fprop->getarray && !fprop->setarray) {
2166 rna_set_raw_property(dp, prop);
2167 }
2168
2169 fprop->getarray = reinterpret_cast<PropFloatArrayGetFunc>(
2170 rna_def_property_get_func(f, srna, prop, dp, (const char *)fprop->getarray));
2171 fprop->setarray = reinterpret_cast<PropFloatArraySetFunc>(
2172 rna_def_property_set_func(f, srna, prop, dp, (const char *)fprop->setarray));
2173 }
2174 break;
2175 }
2176 case PROP_ENUM: {
2177 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
2178
2179 if (!(prop->flag & PROP_EDITABLE) && (eprop->set || eprop->set_ex)) {
2180 CLOG_ERROR(&LOG,
2181 "%s.%s, is read-only but has defines a \"set\" callback.",
2182 srna->identifier,
2183 prop->identifier);
2184 DefRNA.error = true;
2185 }
2186
2187 if (!eprop->get && !eprop->set) {
2188 rna_set_raw_property(dp, prop);
2189 }
2190
2191 eprop->get = reinterpret_cast<PropEnumGetFunc>(
2192 rna_def_property_get_func(f, srna, prop, dp, (const char *)eprop->get));
2193 eprop->set = reinterpret_cast<PropEnumSetFunc>(
2194 rna_def_property_set_func(f, srna, prop, dp, (const char *)eprop->set));
2195 break;
2196 }
2197 case PROP_STRING: {
2198 StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
2199
2200 if (!(prop->flag & PROP_EDITABLE) && (sprop->set || sprop->set_ex)) {
2201 CLOG_ERROR(&LOG,
2202 "%s.%s, is read-only but has defines a \"set\" callback.",
2203 srna->identifier,
2204 prop->identifier);
2205 DefRNA.error = true;
2206 }
2207
2208 sprop->get = reinterpret_cast<PropStringGetFunc>(
2209 rna_def_property_get_func(f, srna, prop, dp, (const char *)sprop->get));
2210 sprop->length = reinterpret_cast<PropStringLengthFunc>(
2211 rna_def_property_length_func(f, srna, prop, dp, (const char *)sprop->length));
2212 sprop->set = reinterpret_cast<PropStringSetFunc>(
2213 rna_def_property_set_func(f, srna, prop, dp, (const char *)sprop->set));
2214 sprop->search = reinterpret_cast<StringPropertySearchFunc>(
2215 rna_def_property_search_func(f, srna, prop, dp, (const char *)sprop->search));
2216 break;
2217 }
2218 case PROP_POINTER: {
2219 PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
2220
2221 if (!(prop->flag & PROP_EDITABLE) && pprop->set) {
2222 CLOG_ERROR(&LOG,
2223 "%s.%s, is read-only but has defines a \"set\" callback.",
2224 srna->identifier,
2225 prop->identifier);
2226 DefRNA.error = true;
2227 }
2228
2229 pprop->get = reinterpret_cast<PropPointerGetFunc>(
2230 rna_def_property_get_func(f, srna, prop, dp, (const char *)pprop->get));
2231 pprop->set = reinterpret_cast<PropPointerSetFunc>(
2232 rna_def_property_set_func(f, srna, prop, dp, (const char *)pprop->set));
2233 if (!pprop->type) {
2234 CLOG_ERROR(
2235 &LOG, "%s.%s, pointer must have a struct type.", srna->identifier, prop->identifier);
2236 DefRNA.error = true;
2237 }
2238 break;
2239 }
2240 case PROP_COLLECTION: {
2242 const char *nextfunc = (const char *)cprop->next;
2243 const char *item_type = (const char *)cprop->item_type;
2244
2245 if (cprop->length) {
2246 /* always generate if we have a manual implementation */
2247 cprop->length = reinterpret_cast<PropCollectionLengthFunc>(
2248 rna_def_property_length_func(f, srna, prop, dp, (const char *)cprop->length));
2249 }
2250 else if (dp->dnatype && STREQ(dp->dnatype, "ListBase")) {
2251 /* pass */
2252 }
2253 else if (dp->dnalengthname || dp->dnalengthfixed) {
2254 cprop->length = reinterpret_cast<PropCollectionLengthFunc>(
2255 rna_def_property_length_func(f, srna, prop, dp, (const char *)cprop->length));
2256 }
2257
2258 /* test if we can allow raw array access, if it is using our standard
2259 * array get/next function, we can be sure it is an actual array */
2260 if (cprop->next && cprop->get) {
2261 if (STREQ((const char *)cprop->next, "rna_iterator_array_next") &&
2262 STREQ((const char *)cprop->get, "rna_iterator_array_get"))
2263 {
2265 }
2266 }
2267
2268 cprop->get = reinterpret_cast<PropCollectionGetFunc>(
2269 rna_def_property_get_func(f, srna, prop, dp, (const char *)cprop->get));
2270 cprop->begin = reinterpret_cast<PropCollectionBeginFunc>(
2271 rna_def_property_begin_func(f, srna, prop, dp, (const char *)cprop->begin));
2272 cprop->next = reinterpret_cast<PropCollectionNextFunc>(
2273 rna_def_property_next_func(f, srna, prop, dp, (const char *)cprop->next));
2274 cprop->end = reinterpret_cast<PropCollectionEndFunc>(
2275 rna_def_property_end_func(f, srna, prop, dp, (const char *)cprop->end));
2276 cprop->lookupint = reinterpret_cast<PropCollectionLookupIntFunc>(
2278 f, srna, prop, dp, (const char *)cprop->lookupint, nextfunc));
2279 cprop->lookupstring = reinterpret_cast<PropCollectionLookupStringFunc>(
2281 f, srna, prop, dp, (const char *)cprop->lookupstring, item_type));
2282
2283 if (!(prop->flag & PROP_IDPROPERTY)) {
2284 if (!cprop->begin) {
2285 CLOG_ERROR(&LOG,
2286 "%s.%s, collection must have a begin function.",
2287 srna->identifier,
2288 prop->identifier);
2289 DefRNA.error = true;
2290 }
2291 if (!cprop->next) {
2292 CLOG_ERROR(&LOG,
2293 "%s.%s, collection must have a next function.",
2294 srna->identifier,
2295 prop->identifier);
2296 DefRNA.error = true;
2297 }
2298 if (!cprop->get) {
2299 CLOG_ERROR(&LOG,
2300 "%s.%s, collection must have a get function.",
2301 srna->identifier,
2302 prop->identifier);
2303 DefRNA.error = true;
2304 }
2305 }
2306 if (!cprop->item_type) {
2307 CLOG_ERROR(&LOG,
2308 "%s.%s, collection must have a struct type.",
2309 srna->identifier,
2310 prop->identifier);
2311 DefRNA.error = true;
2312 }
2313 break;
2314 }
2315 }
2316}
2317
2319{
2320 PropertyRNA *prop;
2321 const char *func;
2322
2323 prop = dp->prop;
2324
2325 if (prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN) {
2326 return;
2327 }
2328
2329 func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "");
2330
2331 switch (prop->type) {
2332 case PROP_BOOLEAN: {
2333 if (!prop->arraydimension) {
2334 fprintf(f, "bool %sget(PointerRNA *ptr);\n", func);
2335 fprintf(f, "void %sset(PointerRNA *ptr, bool value);\n", func);
2336 }
2337 else if ((prop->flag & PROP_DYNAMIC) == 0 && prop->arraydimension && prop->totarraylength) {
2338 fprintf(f, "void %sget(PointerRNA *ptr, bool values[%u]);\n", func, prop->totarraylength);
2339 fprintf(f,
2340 "void %sset(PointerRNA *ptr, const bool values[%u]);\n",
2341 func,
2342 prop->totarraylength);
2343 }
2344 else {
2345 fprintf(f, "void %sget(PointerRNA *ptr, bool values[]);\n", func);
2346 fprintf(f, "void %sset(PointerRNA *ptr, const bool values[]);\n", func);
2347 }
2348 break;
2349 }
2350 case PROP_INT: {
2351 if (!prop->arraydimension) {
2352 fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
2353 fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
2354 }
2355 else if ((prop->flag & PROP_DYNAMIC) == 0 && prop->arraydimension && prop->totarraylength) {
2356 fprintf(f, "void %sget(PointerRNA *ptr, int values[%u]);\n", func, prop->totarraylength);
2357 fprintf(
2358 f, "void %sset(PointerRNA *ptr, const int values[%u]);\n", func, prop->totarraylength);
2359 }
2360 else {
2361 fprintf(f, "void %sget(PointerRNA *ptr, int values[]);\n", func);
2362 fprintf(f, "void %sset(PointerRNA *ptr, const int values[]);\n", func);
2363 }
2364 break;
2365 }
2366 case PROP_FLOAT: {
2367 if (!prop->arraydimension) {
2368 fprintf(f, "float %sget(PointerRNA *ptr);\n", func);
2369 fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func);
2370 }
2371 else if ((prop->flag & PROP_DYNAMIC) == 0 && prop->arraydimension && prop->totarraylength) {
2372 fprintf(f, "void %sget(PointerRNA *ptr, float values[%u]);\n", func, prop->totarraylength);
2373 fprintf(f,
2374 "void %sset(PointerRNA *ptr, const float values[%u]);\n",
2375 func,
2376 prop->totarraylength);
2377 }
2378 else {
2379 fprintf(f, "void %sget(PointerRNA *ptr, float values[]);\n", func);
2380 fprintf(f, "void %sset(PointerRNA *ptr, const float values[]);", func);
2381 }
2382 break;
2383 }
2384 case PROP_ENUM: {
2385 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
2386 int i;
2387
2388 if (eprop->item && eprop->totitem) {
2389 fprintf(f, "enum {\n");
2390
2391 for (i = 0; i < eprop->totitem; i++) {
2392 if (eprop->item[i].identifier[0]) {
2393 fprintf(f,
2394 "\t%s_%s_%s = %d,\n",
2395 srna->identifier,
2396 prop->identifier,
2397 eprop->item[i].identifier,
2398 eprop->item[i].value);
2399 }
2400 }
2401
2402 fprintf(f, "};\n\n");
2403 }
2404
2405 fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
2406 fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
2407
2408 break;
2409 }
2410 case PROP_STRING: {
2411 StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
2412
2413 if (sprop->maxlength) {
2414 fprintf(
2415 f, "#define %s_%s_MAX %d\n\n", srna->identifier, prop->identifier, sprop->maxlength);
2416 }
2417
2418 fprintf(f, "void %sget(PointerRNA *ptr, char *value);\n", func);
2419 fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
2420 fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func);
2421
2422 break;
2423 }
2424 case PROP_POINTER: {
2425 fprintf(f, "PointerRNA %sget(PointerRNA *ptr);\n", func);
2426 // fprintf(f, "void %sset(PointerRNA *ptr, PointerRNA value);\n", func);
2427 break;
2428 }
2429 case PROP_COLLECTION: {
2431 fprintf(f, "void %sbegin(CollectionPropertyIterator *iter, PointerRNA *ptr);\n", func);
2432 fprintf(f, "void %snext(CollectionPropertyIterator *iter);\n", func);
2433 fprintf(f, "void %send(CollectionPropertyIterator *iter);\n", func);
2434 if (cprop->length) {
2435 fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
2436 }
2437 if (cprop->lookupint) {
2438 fprintf(f, "bool %slookup_int(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n", func);
2439 }
2440 if (cprop->lookupstring) {
2441 fprintf(f,
2442 "bool %slookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n",
2443 func);
2444 }
2445 break;
2446 }
2447 }
2448
2449 if (prop->getlength) {
2450 char funcname[2048];
2452 funcname, sizeof(funcname), srna->identifier, prop->identifier, "get_length");
2453 fprintf(f, "int %s(PointerRNA *ptr, int *arraylen);\n", funcname);
2454 }
2455
2456 fprintf(f, "\n");
2457}
2458
2459static void rna_def_function_funcs_header(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
2460{
2461 FunctionRNA *func = dfunc->func;
2462 char funcname[2048];
2463
2465 funcname, sizeof(funcname), srna->identifier, func->identifier, "func");
2466 rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 1);
2467}
2468
2470{
2471 PropertyRNA *prop;
2472
2473 prop = dp->prop;
2474
2475 if (prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN) {
2476 return;
2477 }
2478
2479/* Disabled for now to avoid MSVC compiler error due to large file size. */
2480#if 0
2481 if (prop->name && prop->description && prop->description[0] != '\0') {
2482 fprintf(f, "\t/* %s: %s */\n", prop->name, prop->description);
2483 }
2484 else if (prop->name) {
2485 fprintf(f, "\t/* %s */\n", prop->name);
2486 }
2487 else {
2488 fprintf(f, "\t/* */\n");
2489 }
2490#endif
2491
2492 switch (prop->type) {
2493 case PROP_BOOLEAN: {
2494 if (!prop->arraydimension) {
2495 fprintf(f, "\tinline bool %s(void);\n", rna_safe_id(prop->identifier));
2496 fprintf(f, "\tinline void %s(bool value);", rna_safe_id(prop->identifier));
2497 }
2498 else if (prop->totarraylength) {
2499 fprintf(f,
2500 "\tinline Array<bool, %u> %s(void);\n",
2501 prop->totarraylength,
2502 rna_safe_id(prop->identifier));
2503 fprintf(f,
2504 "\tinline void %s(bool values[%u]);",
2505 rna_safe_id(prop->identifier),
2506 prop->totarraylength);
2507 }
2508 else if (prop->getlength) {
2509 fprintf(f, "\tinline DynamicArray<bool> %s(void);\n", rna_safe_id(prop->identifier));
2510 fprintf(f, "\tinline void %s(bool values[]);", rna_safe_id(prop->identifier));
2511 }
2512 break;
2513 }
2514 case PROP_INT: {
2515 if (!prop->arraydimension) {
2516 fprintf(f, "\tinline int %s(void);\n", rna_safe_id(prop->identifier));
2517 fprintf(f, "\tinline void %s(int value);", rna_safe_id(prop->identifier));
2518 }
2519 else if (prop->totarraylength) {
2520 fprintf(f,
2521 "\tinline Array<int, %u> %s(void);\n",
2522 prop->totarraylength,
2523 rna_safe_id(prop->identifier));
2524 fprintf(f,
2525 "\tinline void %s(int values[%u]);",
2526 rna_safe_id(prop->identifier),
2527 prop->totarraylength);
2528 }
2529 else if (prop->getlength) {
2530 fprintf(f, "\tinline DynamicArray<int> %s(void);\n", rna_safe_id(prop->identifier));
2531 fprintf(f, "\tinline void %s(int values[]);", rna_safe_id(prop->identifier));
2532 }
2533 break;
2534 }
2535 case PROP_FLOAT: {
2536 if (!prop->arraydimension) {
2537 fprintf(f, "\tinline float %s(void);\n", rna_safe_id(prop->identifier));
2538 fprintf(f, "\tinline void %s(float value);", rna_safe_id(prop->identifier));
2539 }
2540 else if (prop->totarraylength) {
2541 fprintf(f,
2542 "\tinline Array<float, %u> %s(void);\n",
2543 prop->totarraylength,
2544 rna_safe_id(prop->identifier));
2545 fprintf(f,
2546 "\tinline void %s(float values[%u]);",
2547 rna_safe_id(prop->identifier),
2548 prop->totarraylength);
2549 }
2550 else if (prop->getlength) {
2551 fprintf(f, "\tinline DynamicArray<float> %s(void);\n", rna_safe_id(prop->identifier));
2552 fprintf(f, "\tinline void %s(float values[]);", rna_safe_id(prop->identifier));
2553 }
2554 break;
2555 }
2556 case PROP_ENUM: {
2557 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
2558 int i;
2559
2560 if (eprop->item) {
2561 fprintf(f, "\tenum %s_enum {\n", rna_safe_id(prop->identifier));
2562
2563 for (i = 0; i < eprop->totitem; i++) {
2564 if (eprop->item[i].identifier[0]) {
2565 fprintf(f,
2566 "\t\t%s_%s = %d,\n",
2567 rna_safe_id(prop->identifier),
2568 eprop->item[i].identifier,
2569 eprop->item[i].value);
2570 }
2571 }
2572
2573 fprintf(f, "\t};\n");
2574 }
2575
2576 fprintf(f,
2577 "\tinline %s_enum %s(void);\n",
2578 rna_safe_id(prop->identifier),
2579 rna_safe_id(prop->identifier));
2580 fprintf(f,
2581 "\tinline void %s(%s_enum value);",
2582 rna_safe_id(prop->identifier),
2583 rna_safe_id(prop->identifier));
2584 break;
2585 }
2586 case PROP_STRING: {
2587 fprintf(f, "\tinline std::string %s(void);\n", rna_safe_id(prop->identifier));
2588 fprintf(f, "\tinline void %s(const std::string& value);", rna_safe_id(prop->identifier));
2589 break;
2590 }
2591 case PROP_POINTER: {
2593
2594 if (pprop->type) {
2595 fprintf(
2596 f, "\tinline %s %s(void);", (const char *)pprop->type, rna_safe_id(prop->identifier));
2597 }
2598 else {
2599 fprintf(f, "\tinline %s %s(void);", "UnknownType", rna_safe_id(prop->identifier));
2600 }
2601 break;
2602 }
2603 case PROP_COLLECTION: {
2605 const char *collection_funcs = "DefaultCollectionFunctions";
2606
2608 cprop->property.srna)
2609 {
2610 collection_funcs = (char *)cprop->property.srna;
2611 }
2612
2613 if (cprop->item_type) {
2614 fprintf(f,
2615 "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)",
2616 collection_funcs,
2617 (const char *)cprop->item_type,
2618 srna->identifier,
2619 rna_safe_id(prop->identifier),
2620 (cprop->length ? "true" : "false"),
2621 (cprop->lookupint ? "true" : "false"),
2622 (cprop->lookupstring ? "true" : "false"));
2623 }
2624 else {
2625 fprintf(f,
2626 "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)",
2627 collection_funcs,
2628 "UnknownType",
2629 srna->identifier,
2630 rna_safe_id(prop->identifier),
2631 (cprop->length ? "true" : "false"),
2632 (cprop->lookupint ? "true" : "false"),
2633 (cprop->lookupstring ? "true" : "false"));
2634 }
2635 break;
2636 }
2637 }
2638
2639 fprintf(f, "\n");
2640}
2641
2643{
2644 if (prop->type == PROP_POINTER) {
2645 /* for cpp api we need to use RNA structures names for pointers */
2646 PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
2647
2648 return (const char *)pprop->type;
2649 }
2650 return rna_parameter_type_name(prop);
2651}
2652
2654 StructRNA * /*srna*/,
2655 FunctionDefRNA *dfunc,
2656 const char *cpp_namespace,
2657 int close_prototype)
2658{
2659 FunctionRNA *func = dfunc->func;
2660
2661 int first = 1;
2662 const char *retval_type = "void";
2663
2664 if (func->c_ret) {
2666 retval_type = rna_parameter_type_cpp_name(dp->prop);
2667 }
2668
2669 if (cpp_namespace && cpp_namespace[0]) {
2670 fprintf(f, "\tinline %s %s::%s(", retval_type, cpp_namespace, rna_safe_id(func->identifier));
2671 }
2672 else {
2673 fprintf(f, "\tinline %s %s(", retval_type, rna_safe_id(func->identifier));
2674 }
2675
2676 if (func->flag & FUNC_USE_MAIN) {
2677 WRITE_PARAM("void *main");
2678 }
2679
2680 if (func->flag & FUNC_USE_CONTEXT) {
2681 WRITE_PARAM("Context C");
2682 }
2683
2685 int type, flag, flag_parameter, pout;
2686 const char *ptrstr;
2687
2688 if (dp->prop == func->c_ret) {
2689 continue;
2690 }
2691
2692 type = dp->prop->type;
2693 flag = dp->prop->flag;
2694 flag_parameter = dp->prop->flag_parameter;
2695 pout = (flag_parameter & PARM_OUTPUT);
2696
2697 if (flag & PROP_DYNAMIC) {
2698 if (type == PROP_STRING) {
2699 ptrstr = pout ? "*" : "";
2700 }
2701 else {
2702 ptrstr = pout ? "**" : "*";
2703 }
2704 }
2705 else if (type == PROP_POINTER) {
2706 ptrstr = pout ? "*" : "";
2707 }
2708 else if (dp->prop->arraydimension) {
2709 ptrstr = "*";
2710 }
2711 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
2712 ptrstr = "";
2713 }
2714 else {
2715 ptrstr = pout ? "*" : "";
2716 }
2717
2719
2720 if (flag & PROP_DYNAMIC) {
2721 fprintf(
2722 f, "int %s%s_len, ", (flag_parameter & PARM_OUTPUT) ? "*" : "", dp->prop->identifier);
2723 }
2724
2725 if (!(flag & PROP_DYNAMIC) && dp->prop->arraydimension) {
2726 fprintf(f,
2727 "%s %s[%u]",
2729 rna_safe_id(dp->prop->identifier),
2730 dp->prop->totarraylength);
2731 }
2732 else {
2733 fprintf(f,
2734 "%s%s%s%s",
2736 (dp->prop->type == PROP_POINTER && ptrstr[0] == '\0') ? "& " : " ",
2737 ptrstr,
2738 rna_safe_id(dp->prop->identifier));
2739 }
2740 }
2741
2742 fprintf(f, ")");
2743 if (close_prototype) {
2744 fprintf(f, ";\n");
2745 }
2746}
2747
2749{
2750 if (dfunc->call) {
2751/* Disabled for now to avoid MSVC compiler error due to large file size. */
2752#if 0
2753 FunctionRNA *func = dfunc->func;
2754 fprintf(f, "\n\t/* %s */\n", func->description);
2755#endif
2756
2757 rna_def_struct_function_prototype_cpp(f, srna, dfunc, nullptr, 1);
2758 }
2759}
2760
2762{
2763 PropertyRNA *prop;
2764
2765 prop = dp->prop;
2766
2767 if (prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN) {
2768 return;
2769 }
2770
2771 switch (prop->type) {
2772 case PROP_BOOLEAN: {
2773 if (!prop->arraydimension) {
2774 fprintf(f, "\tBOOLEAN_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
2775 }
2776 else if (prop->totarraylength) {
2777 fprintf(f,
2778 "\tBOOLEAN_ARRAY_PROPERTY(%s, %u, %s)",
2779 srna->identifier,
2780 prop->totarraylength,
2781 rna_safe_id(prop->identifier));
2782 }
2783 else if (prop->getlength) {
2784 fprintf(f,
2785 "\tBOOLEAN_DYNAMIC_ARRAY_PROPERTY(%s, %s)",
2786 srna->identifier,
2787 rna_safe_id(prop->identifier));
2788 }
2789 break;
2790 }
2791 case PROP_INT: {
2792 if (!prop->arraydimension) {
2793 fprintf(f, "\tINT_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
2794 }
2795 else if (prop->totarraylength) {
2796 fprintf(f,
2797 "\tINT_ARRAY_PROPERTY(%s, %u, %s)",
2798 srna->identifier,
2799 prop->totarraylength,
2800 rna_safe_id(prop->identifier));
2801 }
2802 else if (prop->getlength) {
2803 fprintf(f,
2804 "\tINT_DYNAMIC_ARRAY_PROPERTY(%s, %s)",
2805 srna->identifier,
2806 rna_safe_id(prop->identifier));
2807 }
2808 break;
2809 }
2810 case PROP_FLOAT: {
2811 if (!prop->arraydimension) {
2812 fprintf(f, "\tFLOAT_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
2813 }
2814 else if (prop->totarraylength) {
2815 fprintf(f,
2816 "\tFLOAT_ARRAY_PROPERTY(%s, %u, %s)",
2817 srna->identifier,
2818 prop->totarraylength,
2819 rna_safe_id(prop->identifier));
2820 }
2821 else if (prop->getlength) {
2822 fprintf(f,
2823 "\tFLOAT_DYNAMIC_ARRAY_PROPERTY(%s, %s)",
2824 srna->identifier,
2825 rna_safe_id(prop->identifier));
2826 }
2827 break;
2828 }
2829 case PROP_ENUM: {
2830 fprintf(f,
2831 "\tENUM_PROPERTY(%s_enum, %s, %s)",
2832 rna_safe_id(prop->identifier),
2833 srna->identifier,
2834 rna_safe_id(prop->identifier));
2835
2836 break;
2837 }
2838 case PROP_STRING: {
2839 fprintf(f, "\tSTRING_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
2840 break;
2841 }
2842 case PROP_POINTER: {
2844
2845 if (pprop->type) {
2846 fprintf(f,
2847 "\tPOINTER_PROPERTY(%s, %s, %s)",
2848 (const char *)pprop->type,
2849 srna->identifier,
2850 rna_safe_id(prop->identifier));
2851 }
2852 else {
2853 fprintf(f,
2854 "\tPOINTER_PROPERTY(%s, %s, %s)",
2855 "UnknownType",
2856 srna->identifier,
2857 rna_safe_id(prop->identifier));
2858 }
2859 break;
2860 }
2861 case PROP_COLLECTION: {
2862#if 0
2864
2865 if (cprop->type) {
2866 fprintf(f,
2867 "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)",
2868 (const char *)cprop->type,
2869 srna->identifier,
2870 prop->identifier,
2871 (cprop->length ? "true" : "false"),
2872 (cprop->lookupint ? "true" : "false"),
2873 (cprop->lookupstring ? "true" : "false"));
2874 }
2875 else {
2876 fprintf(f,
2877 "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)",
2878 "UnknownType",
2879 srna->identifier,
2880 prop->identifier,
2881 (cprop->length ? "true" : "false"),
2882 (cprop->lookupint ? "true" : "false"),
2883 (cprop->lookupstring ? "true" : "false"));
2884 }
2885#endif
2886 break;
2887 }
2888 }
2889
2890 fprintf(f, "\n");
2891}
2892
2894{
2895 PropertyDefRNA *dp;
2896 StructDefRNA *dsrna;
2897 FunctionRNA *func = dfunc->func;
2898 char funcname[2048];
2899
2900 int first = 1;
2901
2903 funcname, sizeof(funcname), srna->identifier, func->identifier, "func");
2904
2905 fprintf(f, "%s(", funcname);
2906
2907 dsrna = rna_find_struct_def(srna);
2908
2909 if (func->flag & FUNC_USE_SELF_ID) {
2910 WRITE_PARAM("(::ID *) ptr.owner_id");
2911 }
2912
2913 if ((func->flag & FUNC_NO_SELF) == 0) {
2915 if (dsrna->dnafromprop) {
2916 fprintf(f, "(::%s *) this->ptr.data", dsrna->dnafromname);
2917 }
2918 else if (dsrna->dnaname) {
2919 fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname);
2920 }
2921 else {
2922 fprintf(f, "(::%s *) this->ptr.data", srna->identifier);
2923 }
2924 }
2925 else if (func->flag & FUNC_USE_SELF_TYPE) {
2927 fprintf(f, "this->ptr.type");
2928 }
2929
2930 if (func->flag & FUNC_USE_MAIN) {
2931 WRITE_PARAM("(::Main *) main");
2932 }
2933
2934 if (func->flag & FUNC_USE_CONTEXT) {
2935 WRITE_PARAM("(::bContext *) C.ptr.data");
2936 }
2937
2938 if (func->flag & FUNC_USE_REPORTS) {
2939 WRITE_PARAM("nullptr");
2940 }
2941
2942 dp = static_cast<PropertyDefRNA *>(dfunc->cont.properties.first);
2943 for (; dp; dp = dp->next) {
2944 if (dp->prop == func->c_ret) {
2945 continue;
2946 }
2947
2949
2950 if (dp->prop->flag & PROP_DYNAMIC) {
2951 fprintf(f, "%s_len, ", dp->prop->identifier);
2952 }
2953
2954 if (dp->prop->type == PROP_POINTER) {
2955 if ((dp->prop->flag_parameter & PARM_RNAPTR) && !(dp->prop->flag & PROP_THICK_WRAP)) {
2956 fprintf(f,
2957 "(::%s *) &%s.ptr",
2960 }
2961 else if (dp->prop->flag_parameter & PARM_OUTPUT) {
2962 if (dp->prop->flag_parameter & PARM_RNAPTR) {
2963 fprintf(f, "&%s->ptr", rna_safe_id(dp->prop->identifier));
2964 }
2965 else {
2966 fprintf(f,
2967 "(::%s **) &%s->ptr.data",
2970 }
2971 }
2972 else if (dp->prop->flag_parameter & PARM_RNAPTR) {
2973 fprintf(f,
2974 "(::%s *) &%s",
2977 }
2978 else {
2979 fprintf(f,
2980 "(::%s *) %s.ptr.data",
2983 }
2984 }
2985 else {
2986 fprintf(f, "%s", rna_safe_id(dp->prop->identifier));
2987 }
2988 }
2989
2990 fprintf(f, ");\n");
2991}
2992
2994{
2995 PropertyDefRNA *dp;
2996 PointerPropertyRNA *pprop;
2997
2998 FunctionRNA *func = dfunc->func;
2999
3000 if (!dfunc->call) {
3001 return;
3002 }
3003
3004 rna_def_struct_function_prototype_cpp(f, srna, dfunc, srna->identifier, 0);
3005
3006 fprintf(f, " {\n");
3007
3008 if (func->c_ret) {
3009 dp = rna_find_parameter_def(func->c_ret);
3010
3011 if (dp->prop->type == PROP_POINTER) {
3012 pprop = (PointerPropertyRNA *)dp->prop;
3013
3014 fprintf(f, "\t\tPointerRNA result;\n");
3015
3016 if ((dp->prop->flag_parameter & PARM_RNAPTR) == 0) {
3017 StructRNA *ret_srna = rna_find_struct((const char *)pprop->type);
3018 fprintf(f, "\t\t::%s *retdata = ", rna_parameter_type_name(dp->prop));
3020 if (ret_srna->flag & STRUCT_ID) {
3021 fprintf(f, "\t\tresult = RNA_id_pointer_create((::ID *) retdata);\n");
3022 }
3023 else {
3024 fprintf(f,
3025 "\t\tresult = RNA_pointer_create((::ID *) ptr.owner_id, &RNA_%s, retdata);\n",
3026 (const char *)pprop->type);
3027 }
3028 }
3029 else {
3030 fprintf(f, "\t\tresult = ");
3032 }
3033
3034 fprintf(f, "\t\treturn %s(result);\n", (const char *)pprop->type);
3035 }
3036 else {
3037 fprintf(f, "\t\treturn ");
3039 }
3040 }
3041 else {
3042 fprintf(f, "\t\t");
3044 }
3045
3046 fprintf(f, "\t}\n\n");
3047}
3048
3050{
3051 if (dp->prop->getlength) {
3052 char funcname[2048];
3054 funcname, sizeof(funcname), dsrna->srna->identifier, dp->prop->identifier, "get_length");
3055 fprintf(f, "extern int %s(PointerRNA *ptr, int *arraylen)\n", funcname);
3056 fprintf(f, "{\n");
3057 fprintf(f, "\treturn %s(ptr, arraylen);\n", rna_function_string(dp->prop->getlength));
3058 fprintf(f, "}\n\n");
3059 }
3060}
3061
3063{
3064 StructRNA *srna = dsrna->srna;
3065 FunctionRNA *func = dfunc->func;
3066 PropertyDefRNA *dparm;
3067
3068 int first;
3069 char funcname[2048];
3070
3071 if (!dfunc->call) {
3072 return;
3073 }
3074
3076 funcname, sizeof(funcname), srna->identifier, func->identifier, "func");
3077
3078 fprintf(f, "extern ");
3079 rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 0);
3080
3081 fprintf(f, "\n{\n");
3082
3083 if (func->c_ret) {
3084 fprintf(f, "\treturn %s(", dfunc->call);
3085 }
3086 else {
3087 fprintf(f, "\t%s(", dfunc->call);
3088 }
3089
3090 first = 1;
3091
3092 if (func->flag & FUNC_USE_SELF_ID) {
3093 WRITE_PARAM("_selfid");
3094 }
3095
3096 if ((func->flag & FUNC_NO_SELF) == 0) {
3097 WRITE_PARAM("_self");
3098 }
3099 else if (func->flag & FUNC_USE_SELF_TYPE) {
3100 WRITE_PARAM("_type");
3101 }
3102
3103 if (func->flag & FUNC_USE_MAIN) {
3104 WRITE_PARAM("bmain");
3105 }
3106
3107 if (func->flag & FUNC_USE_CONTEXT) {
3108 WRITE_PARAM("C");
3109 }
3110
3111 if (func->flag & FUNC_USE_REPORTS) {
3112 WRITE_PARAM("reports");
3113 }
3114
3115 dparm = static_cast<PropertyDefRNA *>(dfunc->cont.properties.first);
3116 for (; dparm; dparm = dparm->next) {
3117 if (dparm->prop == func->c_ret) {
3118 continue;
3119 }
3120
3122
3123 if (dparm->prop->flag & PROP_DYNAMIC) {
3124 fprintf(f, "%s, %s_num", dparm->prop->identifier, dparm->prop->identifier);
3125 }
3126 else {
3127 fprintf(f, "%s", rna_safe_id(dparm->prop->identifier));
3128 }
3129 }
3130
3131 fprintf(f, ");\n");
3132 fprintf(f, "}\n\n");
3133}
3134
3135static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc)
3136{
3137 StructRNA *srna;
3138 FunctionRNA *func;
3139 PropertyDefRNA *dparm;
3140 PropertyType type;
3141 const char *funcname, *valstr;
3142 const char *ptrstr;
3143 const bool has_data = (dfunc->cont.properties.first != nullptr);
3144 int flag, flag_parameter, pout, cptr, first;
3145
3146 srna = dsrna->srna;
3147 func = dfunc->func;
3148
3149 if (!dfunc->call) {
3150 return;
3151 }
3152
3153 funcname = rna_alloc_function_name(srna->identifier, func->identifier, "call");
3154
3155 /* function definition */
3156 fprintf(
3157 f,
3158 "static void %s(bContext *C, ReportList *reports, PointerRNA *_ptr, ParameterList *_parms)",
3159 funcname);
3160 fprintf(f, "\n{\n");
3161
3162 /* variable definitions */
3163
3164 if (func->flag & FUNC_USE_SELF_ID) {
3165 fprintf(f, "\tstruct ID *_selfid;\n");
3166 }
3167
3168 if ((func->flag & FUNC_NO_SELF) == 0) {
3169 if (dsrna->dnafromprop) {
3170 fprintf(f, "\tstruct %s *_self;\n", dsrna->dnafromname);
3171 }
3172 else if (dsrna->dnaname) {
3173 fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
3174 }
3175 else {
3176 fprintf(f, "\tstruct %s *_self;\n", srna->identifier);
3177 }
3178 }
3179 else if (func->flag & FUNC_USE_SELF_TYPE) {
3180 fprintf(f, "\tstruct StructRNA *_type;\n");
3181 }
3182
3183 dparm = static_cast<PropertyDefRNA *>(dfunc->cont.properties.first);
3184 for (; dparm; dparm = dparm->next) {
3185 type = dparm->prop->type;
3186 flag = dparm->prop->flag;
3187 flag_parameter = dparm->prop->flag_parameter;
3188 pout = (flag_parameter & PARM_OUTPUT);
3189 cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
3190
3191 if (dparm->prop == func->c_ret) {
3192 ptrstr = cptr || dparm->prop->arraydimension ? "*" : "";
3193 /* XXX only arrays and strings are allowed to be dynamic, is this checked anywhere? */
3194 }
3195 else if (cptr || (flag & PROP_DYNAMIC)) {
3196 if (type == PROP_STRING) {
3197 ptrstr = pout ? "*" : "";
3198 }
3199 else {
3200 ptrstr = pout ? "**" : "*";
3201 }
3202 /* Fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack,
3203 * pass a pointer to it. */
3204 }
3205 else if (type == PROP_POINTER || dparm->prop->arraydimension) {
3206 ptrstr = "*";
3207 }
3208 else if ((type == PROP_POINTER) && (flag_parameter & PARM_RNAPTR) && !(flag & PROP_THICK_WRAP))
3209 {
3210 ptrstr = "*";
3211 /* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack,
3212 * but type name for string props is already (char *), so leave empty */
3213 }
3214 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
3215 ptrstr = "";
3216 }
3217 else {
3218 ptrstr = pout ? "*" : "";
3219 }
3220
3221 /* for dynamic parameters we pass an additional int for the length of the parameter */
3222 if (flag & PROP_DYNAMIC) {
3223 fprintf(f, "\tint %s%s_num;\n", pout ? "*" : "", dparm->prop->identifier);
3224 }
3225
3226 fprintf(f,
3227 "\t%s%s%s %s%s;\n",
3228 rna_parameter_is_const(dparm) ? "const " : "",
3229 rna_type_struct(dparm->prop),
3231 ptrstr,
3232 rna_safe_id(dparm->prop->identifier));
3233 }
3234
3235 if (has_data) {
3236 fprintf(f, "\tchar *_data");
3237 if (func->c_ret) {
3238 fprintf(f, ", *_retdata");
3239 }
3240 fprintf(f, ";\n");
3241 fprintf(f, "\t\n");
3242 }
3243
3244 /* assign self */
3245 if (func->flag & FUNC_USE_SELF_ID) {
3246 fprintf(f, "\t_selfid = (struct ID *)_ptr->owner_id;\n");
3247 }
3248
3249 if ((func->flag & FUNC_NO_SELF) == 0) {
3250 if (dsrna->dnafromprop) {
3251 fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnafromname);
3252 }
3253 else if (dsrna->dnaname) {
3254 fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnaname);
3255 }
3256 else {
3257 fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", srna->identifier);
3258 }
3259 }
3260 else if (func->flag & FUNC_USE_SELF_TYPE) {
3261 fprintf(f, "\t_type = _ptr->type;\n");
3262 }
3263
3264 if (has_data) {
3265 fprintf(f, "\t_data = (char *)_parms->data;\n");
3266 }
3267
3268 dparm = static_cast<PropertyDefRNA *>(dfunc->cont.properties.first);
3269 for (; dparm; dparm = dparm->next) {
3270 type = dparm->prop->type;
3271 flag = dparm->prop->flag;
3272 flag_parameter = dparm->prop->flag_parameter;
3273 pout = (flag_parameter & PARM_OUTPUT);
3274 cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
3275
3276 if (dparm->prop == func->c_ret) {
3277 fprintf(f, "\t_retdata = _data;\n");
3278 }
3279 else {
3280 const char *data_str;
3281 if (cptr || (flag & PROP_DYNAMIC)) {
3282 if (type == PROP_STRING) {
3283 ptrstr = "*";
3284 valstr = "";
3285 }
3286 else {
3287 ptrstr = "**";
3288 valstr = "*";
3289 }
3290 }
3291 else if ((type == PROP_POINTER) && !(flag & PROP_THICK_WRAP)) {
3292 ptrstr = "**";
3293 valstr = "*";
3294 }
3295 else if (type == PROP_POINTER || dparm->prop->arraydimension) {
3296 ptrstr = "*";
3297 valstr = "";
3298 }
3299 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
3300 ptrstr = "";
3301 valstr = "";
3302 }
3303 else {
3304 ptrstr = "*";
3305 valstr = "*";
3306 }
3307
3308 /* This must be kept in sync with RNA_parameter_dynamic_length_get_data and
3309 * RNA_parameter_get, we could just call the function directly, but this is faster. */
3310 if (flag & PROP_DYNAMIC) {
3311 fprintf(f,
3312 "\t%s_num = %s((ParameterDynAlloc *)_data)->array_tot;\n",
3313 rna_safe_id(dparm->prop->identifier),
3314 pout ? "(int *)&" : "(int)");
3315 data_str = "(&(((ParameterDynAlloc *)_data)->array))";
3316 }
3317 else {
3318 data_str = "_data";
3319 }
3320 fprintf(f, "\t%s = ", rna_safe_id(dparm->prop->identifier));
3321
3322 if (!pout) {
3323 fprintf(f, "%s", valstr);
3324 }
3325
3326 fprintf(f,
3327 "((%s%s%s %s)%s);\n",
3328 rna_parameter_is_const(dparm) ? "const " : "",
3329 rna_type_struct(dparm->prop),
3331 ptrstr,
3332 data_str);
3333 }
3334
3335 if (dparm->next) {
3336 fprintf(f, "\t_data += %d;\n", rna_parameter_size_pad(rna_parameter_size(dparm->prop)));
3337 }
3338 }
3339
3340 if (dfunc->call) {
3341 fprintf(f, "\t\n");
3342 fprintf(f, "\t");
3343 if (func->c_ret) {
3344 fprintf(f, "%s = ", func->c_ret->identifier);
3345 }
3346 fprintf(f, "%s(", dfunc->call);
3347
3348 first = 1;
3349
3350 if (func->flag & FUNC_USE_SELF_ID) {
3351 fprintf(f, "_selfid");
3352 first = 0;
3353 }
3354
3355 if ((func->flag & FUNC_NO_SELF) == 0) {
3356 if (!first) {
3357 fprintf(f, ", ");
3358 }
3359 fprintf(f, "_self");
3360 first = 0;
3361 }
3362 else if (func->flag & FUNC_USE_SELF_TYPE) {
3363 if (!first) {
3364 fprintf(f, ", ");
3365 }
3366 fprintf(f, "_type");
3367 first = 0;
3368 }
3369
3370 if (func->flag & FUNC_USE_MAIN) {
3371 if (!first) {
3372 fprintf(f, ", ");
3373 }
3374 first = 0;
3375 fprintf(f, "CTX_data_main(C)"); /* may have direct access later */
3376 }
3377
3378 if (func->flag & FUNC_USE_CONTEXT) {
3379 if (!first) {
3380 fprintf(f, ", ");
3381 }
3382 first = 0;
3383 fprintf(f, "C");
3384 }
3385
3386 if (func->flag & FUNC_USE_REPORTS) {
3387 if (!first) {
3388 fprintf(f, ", ");
3389 }
3390 first = 0;
3391 fprintf(f, "reports");
3392 }
3393
3394 dparm = static_cast<PropertyDefRNA *>(dfunc->cont.properties.first);
3395 for (; dparm; dparm = dparm->next) {
3396 if (dparm->prop == func->c_ret) {
3397 continue;
3398 }
3399
3400 if (!first) {
3401 fprintf(f, ", ");
3402 }
3403 first = 0;
3404
3405 if (dparm->prop->flag & PROP_DYNAMIC) {
3406 fprintf(f,
3407 "%s, %s_num",
3408 rna_safe_id(dparm->prop->identifier),
3409 rna_safe_id(dparm->prop->identifier));
3410 }
3411 else {
3412 fprintf(f, "%s", rna_safe_id(dparm->prop->identifier));
3413 }
3414 }
3415
3416 fprintf(f, ");\n");
3417
3418 if (func->c_ret) {
3419 dparm = rna_find_parameter_def(func->c_ret);
3420 ptrstr = (((dparm->prop->type == PROP_POINTER) &&
3421 !(dparm->prop->flag_parameter & PARM_RNAPTR)) ||
3422 (dparm->prop->arraydimension)) ?
3423 "*" :
3424 "";
3425 fprintf(f,
3426 "\t*((%s%s %s*)_retdata) = %s;\n",
3427 rna_type_struct(dparm->prop),
3429 ptrstr,
3430 func->c_ret->identifier);
3431 }
3432 }
3433
3434 fprintf(f, "}\n\n");
3435
3436 dfunc->gencall = funcname;
3437}
3438
3440{
3441 /* Ensure RNA enum definitions follow naming convention. */
3442 {
3443#define DEF_ENUM(id) #id,
3444 const char *rna_enum_id_array[] = {
3445#include "RNA_enum_items.hh"
3446 };
3447 for (int i = 0; i < ARRAY_SIZE(rna_enum_id_array); i++) {
3448 if (!(BLI_str_startswith(rna_enum_id_array[i], "rna_enum_") &&
3449 BLI_str_endswith(rna_enum_id_array[i], "_items")))
3450 {
3451 fprintf(stderr,
3452 "Error: enum defined in \"RNA_enum_items.hh\" "
3453 "doesn't confirm to \"rna_enum_*_items\" convention!\n");
3454 DefRNA.error = true;
3455 }
3456 }
3457 }
3458}
3459
3460static void rna_auto_types()
3461{
3462 StructDefRNA *ds;
3463
3464 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
3465 ds = static_cast<StructDefRNA *>(ds->cont.next))
3466 {
3467 /* DNA name for Screen is patched in 2.5, we do the reverse here. */
3468 if (ds->dnaname) {
3469 if (STREQ(ds->dnaname, "Screen")) {
3470 ds->dnaname = "bScreen";
3471 }
3472 if (STREQ(ds->dnaname, "Group")) {
3473 ds->dnaname = "Collection";
3474 }
3475 if (STREQ(ds->dnaname, "GroupObject")) {
3476 ds->dnaname = "CollectionObject";
3477 }
3478 }
3479
3481 if (dp->dnastructname) {
3482 if (STREQ(dp->dnastructname, "Screen")) {
3483 dp->dnastructname = "bScreen";
3484 }
3485 if (STREQ(dp->dnastructname, "Group")) {
3486 dp->dnastructname = "Collection";
3487 }
3488 if (STREQ(dp->dnastructname, "GroupObject")) {
3489 dp->dnastructname = "CollectionObject";
3490 }
3491 }
3492
3493 if (dp->dnatype) {
3494 if (dp->prop->type == PROP_POINTER) {
3495 PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop;
3496 StructRNA *type;
3497
3498 if (!pprop->type && !pprop->get) {
3499 pprop->type = (StructRNA *)rna_find_type(dp->dnatype);
3500 }
3501
3502 if (pprop->type) {
3503 type = rna_find_struct((const char *)pprop->type);
3504 if (type && (type->flag & STRUCT_ID_REFCOUNT)) {
3505 pprop->property.flag |= PROP_ID_REFCOUNT;
3506 }
3507 }
3508 }
3509 else if (dp->prop->type == PROP_COLLECTION) {
3510 CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop;
3511
3512 if (!cprop->item_type && !cprop->get && STREQ(dp->dnatype, "ListBase")) {
3513 cprop->item_type = (StructRNA *)rna_find_type(dp->dnatype);
3514 }
3515 }
3516 }
3517 }
3518 }
3519}
3520
3521static void rna_sort(BlenderRNA *brna)
3522{
3523 StructDefRNA *ds;
3524 StructRNA *srna;
3525
3528
3529 for (srna = static_cast<StructRNA *>(brna->structs.first); srna;
3530 srna = static_cast<StructRNA *>(srna->cont.next))
3531 {
3533 }
3534
3535 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
3536 ds = static_cast<StructDefRNA *>(ds->cont.next))
3537 {
3539 }
3540}
3541
3543{
3544 switch (type) {
3545 case PROP_BOOLEAN:
3546 return "BoolPropertyRNA";
3547 case PROP_INT:
3548 return "IntPropertyRNA";
3549 case PROP_FLOAT:
3550 return "FloatPropertyRNA";
3551 case PROP_STRING:
3552 return "StringPropertyRNA";
3553 case PROP_ENUM:
3554 return "EnumPropertyRNA";
3555 case PROP_POINTER:
3556 return "PointerPropertyRNA";
3557 case PROP_COLLECTION:
3558 return "CollectionPropertyRNA";
3559 default:
3560 return "UnknownPropertyRNA";
3561 }
3562}
3563
3565{
3566 switch (type) {
3567 case PROP_NONE:
3568 return "PROP_NONE";
3569 case PROP_FILEPATH:
3570 return "PROP_FILEPATH";
3571 case PROP_FILENAME:
3572 return "PROP_FILENAME";
3573 case PROP_DIRPATH:
3574 return "PROP_DIRPATH";
3575 case PROP_PIXEL:
3576 return "PROP_PIXEL";
3577 case PROP_BYTESTRING:
3578 return "PROP_BYTESTRING";
3579 case PROP_UNSIGNED:
3580 return "PROP_UNSIGNED";
3581 case PROP_PERCENTAGE:
3582 return "PROP_PERCENTAGE";
3583 case PROP_FACTOR:
3584 return "PROP_FACTOR";
3585 case PROP_ANGLE:
3586 return "PROP_ANGLE";
3587 case PROP_TIME:
3588 return "PROP_TIME";
3589 case PROP_TIME_ABSOLUTE:
3590 return "PROP_TIME_ABSOLUTE";
3591 case PROP_DISTANCE:
3592 return "PROP_DISTANCE";
3594 return "PROP_DISTANCE_CAMERA";
3595 case PROP_COLOR:
3596 return "PROP_COLOR";
3597 case PROP_TRANSLATION:
3598 return "PROP_TRANSLATION";
3599 case PROP_DIRECTION:
3600 return "PROP_DIRECTION";
3601 case PROP_MATRIX:
3602 return "PROP_MATRIX";
3603 case PROP_EULER:
3604 return "PROP_EULER";
3605 case PROP_QUATERNION:
3606 return "PROP_QUATERNION";
3607 case PROP_AXISANGLE:
3608 return "PROP_AXISANGLE";
3609 case PROP_VELOCITY:
3610 return "PROP_VELOCITY";
3611 case PROP_ACCELERATION:
3612 return "PROP_ACCELERATION";
3613 case PROP_XYZ:
3614 return "PROP_XYZ";
3615 case PROP_COLOR_GAMMA:
3616 return "PROP_COLOR_GAMMA";
3617 case PROP_COORDS:
3618 return "PROP_COORDS";
3619 case PROP_LAYER:
3620 return "PROP_LAYER";
3621 case PROP_LAYER_MEMBER:
3622 return "PROP_LAYER_MEMBER";
3623 case PROP_PASSWORD:
3624 return "PROP_PASSWORD";
3625 case PROP_POWER:
3626 return "PROP_POWER";
3627 case PROP_TEMPERATURE:
3628 return "PROP_TEMPERATURE";
3629 case PROP_WAVELENGTH:
3630 return "PROP_WAVELENGTH";
3632 return "PROP_COLOR_TEMPERATURE";
3633 case PROP_FREQUENCY:
3634 return "PROP_FREQUENCY";
3635 default: {
3636 /* in case we don't have a type preset that includes the subtype */
3637 if (RNA_SUBTYPE_UNIT(type)) {
3639 }
3640 return "PROP_SUBTYPE_UNKNOWN";
3641 }
3642 }
3643}
3644
3646{
3647 switch (RNA_SUBTYPE_UNIT(type)) {
3648 case PROP_UNIT_NONE:
3649 return "PROP_UNIT_NONE";
3650 case PROP_UNIT_LENGTH:
3651 return "PROP_UNIT_LENGTH";
3652 case PROP_UNIT_AREA:
3653 return "PROP_UNIT_AREA";
3654 case PROP_UNIT_VOLUME:
3655 return "PROP_UNIT_VOLUME";
3656 case PROP_UNIT_MASS:
3657 return "PROP_UNIT_MASS";
3658 case PROP_UNIT_ROTATION:
3659 return "PROP_UNIT_ROTATION";
3660 case PROP_UNIT_TIME:
3661 return "PROP_UNIT_TIME";
3663 return "PROP_UNIT_TIME_ABSOLUTE";
3664 case PROP_UNIT_VELOCITY:
3665 return "PROP_UNIT_VELOCITY";
3667 return "PROP_UNIT_ACCELERATION";
3668 case PROP_UNIT_CAMERA:
3669 return "PROP_UNIT_CAMERA";
3670 case PROP_UNIT_POWER:
3671 return "PROP_UNIT_POWER";
3673 return "PROP_UNIT_TEMPERATURE";
3675 return "PROP_UNIT_WAVELENGTH";
3677 return "PROP_UNIT_COLOR_TEMPERATURE";
3679 return "PROP_UNIT_FREQUENCY";
3680 default:
3681 return "PROP_UNIT_UNKNOWN";
3682 }
3683}
3684
3686{
3687 StructRNA *srna;
3688
3689 for (srna = static_cast<StructRNA *>(brna->structs.first); srna;
3690 srna = static_cast<StructRNA *>(srna->cont.next))
3691 {
3692 fprintf(f, "extern struct StructRNA RNA_%s;\n", srna->identifier);
3693 }
3694 fprintf(f, "\n");
3695}
3696
3697static void rna_generate_blender(BlenderRNA *brna, FILE *f)
3698{
3699 StructRNA *srna;
3700
3701 fprintf(f,
3702 "BlenderRNA BLENDER_RNA = {\n"
3703 "\t/*structs*/ {");
3704 srna = static_cast<StructRNA *>(brna->structs.first);
3705 if (srna) {
3706 fprintf(f, "&RNA_%s, ", srna->identifier);
3707 }
3708 else {
3709 fprintf(f, "nullptr, ");
3710 }
3711
3712 srna = static_cast<StructRNA *>(brna->structs.last);
3713 if (srna) {
3714 fprintf(f, "&RNA_%s},\n", srna->identifier);
3715 }
3716 else {
3717 fprintf(f, "nullptr},\n");
3718 }
3719
3720 fprintf(f,
3721 "\t/*structs_map*/ nullptr,\n"
3722 "\t/*structs_len*/ 0,\n"
3723 "};\n\n");
3724}
3725
3727{
3728 fprintf(f, "struct PropertyRNA;\n\n");
3729
3731
3732 /* NOTE: Generate generic `PropertyRNA &` references. The actual, type-refined properties data
3733 * are static variables in their translation units (the `_gen.cc` files), which are assigned to
3734 * these public generic `PointerRNA &` references. */
3735 for (StructRNA *srna = static_cast<StructRNA *>(brna->structs.first); srna;
3736 srna = static_cast<StructRNA *>(srna->cont.next))
3737 {
3738 LISTBASE_FOREACH (PropertyRNA *, prop, &srna->cont.properties) {
3739 fprintf(f, "extern PropertyRNA &rna_%s_%s;\n", srna->identifier, prop->identifier);
3740 }
3741 fprintf(f, "\n");
3742 }
3743}
3744
3746 StructRNA *srna,
3747 FILE *f)
3748{
3749 StructRNA *base;
3750
3751 /* NOTE: Generic `PropertyRNA &` references, see #rna_generate_external_property_prototypes
3752 * comments for details. */
3753 base = srna->base;
3754 while (base) {
3755 fprintf(f, "\n");
3756 LISTBASE_FOREACH (PropertyRNA *, prop, &base->cont.properties) {
3757 fprintf(f, "extern PropertyRNA &rna_%s_%s;\n", base->identifier, prop->identifier);
3758 }
3759 base = base->base;
3760 }
3761
3762 if (srna->cont.properties.first) {
3763 fprintf(f, "\n");
3764 }
3765
3766 LISTBASE_FOREACH (PropertyRNA *, prop, &srna->cont.properties) {
3767 fprintf(f, "extern PropertyRNA &rna_%s_%s;\n", srna->identifier, prop->identifier);
3768 }
3769 fprintf(f, "\n");
3770}
3771
3773 StructRNA *srna,
3774 FunctionRNA *func,
3775 FILE *f)
3776{
3777 /* NOTE: Generic `PropertyRNA &` references, see #rna_generate_external_property_prototypes
3778 * comments for details. */
3779 LISTBASE_FOREACH (PropertyRNA *, parm, &func->cont.properties) {
3780 fprintf(f,
3781 "extern PropertyRNA &rna_%s_%s_%s;\n",
3782 srna->identifier,
3783 func->identifier,
3784 parm->identifier);
3785 }
3786
3787 if (func->cont.properties.first) {
3788 fprintf(f, "\n");
3789 }
3790}
3791
3793{
3794 FunctionRNA *func;
3795 StructRNA *base;
3796
3797 base = srna->base;
3798 while (base) {
3799 for (func = static_cast<FunctionRNA *>(base->functions.first); func;
3800 func = static_cast<FunctionRNA *>(func->cont.next))
3801 {
3802 fprintf(f, "extern FunctionRNA rna_%s_%s_func;\n", base->identifier, func->identifier);
3803 rna_generate_parameter_prototypes(brna, base, func, f);
3804 }
3805
3806 if (base->functions.first) {
3807 fprintf(f, "\n");
3808 }
3809
3810 base = base->base;
3811 }
3812
3813 for (func = static_cast<FunctionRNA *>(srna->functions.first); func;
3814 func = static_cast<FunctionRNA *>(func->cont.next))
3815 {
3816 fprintf(f, "extern FunctionRNA rna_%s_%s_func;\n", srna->identifier, func->identifier);
3817 rna_generate_parameter_prototypes(brna, srna, func, f);
3818 }
3819
3820 if (srna->functions.first) {
3821 fprintf(f, "\n");
3822 }
3823}
3824
3826 StructRNA *srna,
3827 FunctionDefRNA *dfunc,
3828 const char *name_override,
3829 int close_prototype)
3830{
3831 FunctionRNA *func;
3832 PropertyDefRNA *dparm_return = nullptr;
3833 StructDefRNA *dsrna;
3834 PropertyType type;
3835 int flag, flag_parameter, pout, cptr, first;
3836 const char *ptrstr;
3837
3838 dsrna = rna_find_struct_def(srna);
3839 func = dfunc->func;
3840
3841 /* return type */
3842 LISTBASE_FOREACH (PropertyDefRNA *, dparm, &dfunc->cont.properties) {
3843 if (dparm->prop == func->c_ret) {
3844 if (dparm->prop->arraydimension) {
3845 fprintf(f, "XXX no array return types yet"); /* XXX not supported */
3846 }
3847 else if (dparm->prop->type == PROP_POINTER && !(dparm->prop->flag_parameter & PARM_RNAPTR)) {
3848 fprintf(f, "%s%s *", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
3849 }
3850 else {
3851 fprintf(f, "%s%s ", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
3852 }
3853
3854 dparm_return = dparm;
3855 break;
3856 }
3857 }
3858
3859 /* void if nothing to return */
3860 if (!dparm_return) {
3861 fprintf(f, "void ");
3862 }
3863
3864 /* function name */
3865 if (name_override == nullptr || name_override[0] == '\0') {
3866 fprintf(f, "%s(", dfunc->call);
3867 }
3868 else {
3869 fprintf(f, "%s(", name_override);
3870 }
3871
3872 first = 1;
3873
3874 /* self, context and reports parameters */
3875 if (func->flag & FUNC_USE_SELF_ID) {
3876 fprintf(f, "struct ID *_selfid");
3877 first = 0;
3878 }
3879
3880 if ((func->flag & FUNC_NO_SELF) == 0) {
3881 if (!first) {
3882 fprintf(f, ", ");
3883 }
3884 if (dsrna->dnafromprop) {
3885 fprintf(f, "struct %s *_self", dsrna->dnafromname);
3886 }
3887 else if (dsrna->dnaname) {
3888 fprintf(f, "struct %s *_self", dsrna->dnaname);
3889 }
3890 else {
3891 fprintf(f, "struct %s *_self", srna->identifier);
3892 }
3893 first = 0;
3894 }
3895 else if (func->flag & FUNC_USE_SELF_TYPE) {
3896 if (!first) {
3897 fprintf(f, ", ");
3898 }
3899 fprintf(f, "struct StructRNA *_type");
3900 first = 0;
3901 }
3902
3903 if (func->flag & FUNC_USE_MAIN) {
3904 if (!first) {
3905 fprintf(f, ", ");
3906 }
3907 first = 0;
3908 fprintf(f, "Main *bmain");
3909 }
3910
3911 if (func->flag & FUNC_USE_CONTEXT) {
3912 if (!first) {
3913 fprintf(f, ", ");
3914 }
3915 first = 0;
3916 fprintf(f, "bContext *C");
3917 }
3918
3919 if (func->flag & FUNC_USE_REPORTS) {
3920 if (!first) {
3921 fprintf(f, ", ");
3922 }
3923 first = 0;
3924 fprintf(f, "ReportList *reports");
3925 }
3926
3927 /* defined parameters */
3928 LISTBASE_FOREACH (PropertyDefRNA *, dparm, &dfunc->cont.properties) {
3929 type = dparm->prop->type;
3930 flag = dparm->prop->flag;
3931 flag_parameter = dparm->prop->flag_parameter;
3932 pout = (flag_parameter & PARM_OUTPUT);
3933 cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
3934
3935 if (dparm->prop == func->c_ret) {
3936 continue;
3937 }
3938
3939 if (cptr || (flag & PROP_DYNAMIC)) {
3940 if (type == PROP_STRING) {
3941 ptrstr = pout ? "*" : "";
3942 }
3943 else {
3944 ptrstr = pout ? "**" : "*";
3945 }
3946 }
3947 else if (type == PROP_POINTER || dparm->prop->arraydimension) {
3948 ptrstr = "*";
3949 }
3950 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
3951 ptrstr = "";
3952 }
3953 else {
3954 ptrstr = pout ? "*" : "";
3955 }
3956
3957 if (!first) {
3958 fprintf(f, ", ");
3959 }
3960 first = 0;
3961
3962 if (flag & PROP_DYNAMIC) {
3963 fprintf(f, "int %s%s_num, ", pout ? "*" : "", dparm->prop->identifier);
3964 }
3965
3966 if (!(flag & PROP_DYNAMIC) && dparm->prop->arraydimension) {
3967 fprintf(f,
3968 "%s%s %s[%u]",
3969 rna_type_struct(dparm->prop),
3970 rna_parameter_type_name(dparm->prop),
3971 rna_safe_id(dparm->prop->identifier),
3972 dparm->prop->totarraylength);
3973 }
3974 else {
3975 fprintf(f,
3976 "%s%s %s%s",
3977 rna_type_struct(dparm->prop),
3978 rna_parameter_type_name(dparm->prop),
3979 ptrstr,
3980 rna_safe_id(dparm->prop->identifier));
3981 }
3982 }
3983
3984 /* ensure func(void) if there are no args */
3985 if (first) {
3986 fprintf(f, "void");
3987 }
3988
3989 fprintf(f, ")");
3990
3991 if (close_prototype) {
3992 fprintf(f, ";\n");
3993 }
3994}
3995
3997 StructRNA *srna,
3998 FILE *f)
3999{
4000 FunctionRNA *func;
4001 FunctionDefRNA *dfunc;
4002 int first = 1;
4003
4004 for (func = static_cast<FunctionRNA *>(srna->functions.first); func;
4005 func = static_cast<FunctionRNA *>(func->cont.next))
4006 {
4007 dfunc = rna_find_function_def(func);
4008
4009 if (dfunc->call) {
4010 if (strstr(dfunc->call, "<")) {
4011 /* Can't generate the declaration for templates. We'll still get compile errors when trying
4012 * to call it with a wrong signature. */
4013 continue;
4014 }
4015
4016 if (first) {
4017 fprintf(f, "/* Repeated prototypes to detect errors */\n\n");
4018 first = 0;
4019 }
4020
4021 rna_generate_static_parameter_prototypes(f, srna, dfunc, nullptr, 1);
4022 }
4023 }
4024
4025 fprintf(f, "\n");
4026}
4027
4029{
4030 StructDefRNA *ds;
4031 FunctionDefRNA *dfunc;
4032 const char *structures[2048];
4033 int all_structures = 0;
4034
4035 /* structures definitions */
4036 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
4037 ds = static_cast<StructDefRNA *>(ds->cont.next))
4038 {
4039 for (dfunc = static_cast<FunctionDefRNA *>(ds->functions.first); dfunc;
4040 dfunc = static_cast<FunctionDefRNA *>(dfunc->cont.next))
4041 {
4042 if (dfunc->call) {
4044 if (dp->prop->type == PROP_POINTER) {
4045 int a, found = 0;
4046 const char *struct_name = rna_parameter_type_name(dp->prop);
4047 if (struct_name == nullptr) {
4048 printf("No struct found for property '%s'\n", dp->prop->identifier);
4049 exit(1);
4050 }
4051
4052 for (a = 0; a < all_structures; a++) {
4053 if (STREQ(struct_name, structures[a])) {
4054 found = 1;
4055 break;
4056 }
4057 }
4058
4059 if (found == 0) {
4060 fprintf(f, "struct %s;\n", struct_name);
4061
4062 if (all_structures >= ARRAY_SIZE(structures)) {
4063 printf("Array size to store all structures names is too small\n");
4064 exit(1);
4065 }
4066
4067 structures[all_structures++] = struct_name;
4068 }
4069 }
4070 }
4071 }
4072 }
4073 }
4074
4075 fprintf(f, "\n");
4076}
4077
4078static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, PropertyRNA *prop)
4079{
4080 char *strnest = (char *)"", *errnest = (char *)"";
4081 bool freenest = false;
4082
4083 if (nest != nullptr) {
4084 int len = strlen(nest);
4085
4086 strnest = static_cast<char *>(
4087 MEM_mallocN(sizeof(char) * len + 2, "rna_generate_property -> strnest"));
4088 errnest = static_cast<char *>(
4089 MEM_mallocN(sizeof(char) * len + 2, "rna_generate_property -> errnest"));
4090
4091 strnest[0] = '_';
4092 memcpy(strnest + 1, nest, len + 1);
4093
4094 errnest[0] = '.';
4095 memcpy(errnest + 1, nest, len + 1);
4096
4097 freenest = true;
4098 }
4099
4100 switch (prop->type) {
4101 case PROP_ENUM: {
4102 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
4103 int i, defaultfound = 0, totflag = 0;
4104
4105 if (eprop->item) {
4106 /* Inline the enum if this is not a defined in "RNA_enum_items.hh". */
4107 const char *item_global_id = rna_enum_id_from_pointer(eprop->item);
4108 if (item_global_id == nullptr) {
4109 fprintf(f,
4110 "static const EnumPropertyItem rna_%s%s_%s_items[%d] = {\n\t",
4111 srna->identifier,
4112 strnest,
4113 prop->identifier,
4114 eprop->totitem + 1);
4115
4116 for (i = 0; i < eprop->totitem; i++) {
4117 fprintf(f, "{%d, ", eprop->item[i].value);
4118 rna_print_c_string(f, eprop->item[i].identifier);
4119 fprintf(f, ", ");
4120 fprintf(f, "%d, ", eprop->item[i].icon);
4121 rna_print_c_string(f, eprop->item[i].name);
4122 fprintf(f, ", ");
4123 rna_print_c_string(f, eprop->item[i].description);
4124 fprintf(f, "},\n\t");
4125
4126 if (eprop->item[i].identifier[0]) {
4127 if (prop->flag & PROP_ENUM_FLAG) {
4128 totflag |= eprop->item[i].value;
4129 }
4130 else {
4131 if (eprop->defaultvalue == eprop->item[i].value) {
4132 defaultfound = 1;
4133 }
4134 }
4135 }
4136 }
4137
4138 fprintf(f, "{0, nullptr, 0, nullptr, nullptr}\n};\n\n");
4139 }
4140 else {
4141 for (i = 0; i < eprop->totitem; i++) {
4142 if (eprop->item[i].identifier[0]) {
4143 if (prop->flag & PROP_ENUM_FLAG) {
4144 totflag |= eprop->item[i].value;
4145 }
4146 else {
4147 if (eprop->defaultvalue == eprop->item[i].value) {
4148 defaultfound = 1;
4149 }
4150 }
4151 }
4152 }
4153 }
4154
4155 if (prop->flag & PROP_ENUM_FLAG) {
4156 if (eprop->defaultvalue & ~totflag) {
4157 CLOG_ERROR(&LOG,
4158 "%s%s.%s, enum default includes unused bits (%d).",
4159 srna->identifier,
4160 errnest,
4161 prop->identifier,
4162 eprop->defaultvalue & ~totflag);
4163 DefRNA.error = true;
4164 }
4165 }
4166 else {
4167 if (!defaultfound && !(eprop->item_fn && eprop->item == rna_enum_dummy_NULL_items)) {
4168 CLOG_ERROR(&LOG,
4169 "%s%s.%s, enum default is not in items.",
4170 srna->identifier,
4171 errnest,
4172 prop->identifier);
4173 DefRNA.error = true;
4174 }
4175 }
4176 }
4177 else {
4178 CLOG_ERROR(&LOG,
4179 "%s%s.%s, enum must have items defined.",
4180 srna->identifier,
4181 errnest,
4182 prop->identifier);
4183 DefRNA.error = true;
4184 }
4185 break;
4186 }
4187 case PROP_BOOLEAN: {
4188 BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
4189 uint i;
4190
4191 if (prop->arraydimension && prop->totarraylength) {
4192 fprintf(f,
4193 "static bool rna_%s%s_%s_default[%u] = {\n\t",
4194 srna->identifier,
4195 strnest,
4196 prop->identifier,
4197 prop->totarraylength);
4198
4199 for (i = 0; i < prop->totarraylength; i++) {
4200 if (bprop->defaultarray) {
4201 fprintf(f, "%d", bprop->defaultarray[i]);
4202 }
4203 else {
4204 fprintf(f, "%d", bprop->defaultvalue);
4205 }
4206 if (i != prop->totarraylength - 1) {
4207 fprintf(f, ",\n\t");
4208 }
4209 }
4210
4211 fprintf(f, "\n};\n\n");
4212 }
4213 break;
4214 }
4215 case PROP_INT: {
4216 IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
4217 uint i;
4218
4219 if (prop->arraydimension && prop->totarraylength) {
4220 fprintf(f,
4221 "static int rna_%s%s_%s_default[%u] = {\n\t",
4222 srna->identifier,
4223 strnest,
4224 prop->identifier,
4225 prop->totarraylength);
4226
4227 for (i = 0; i < prop->totarraylength; i++) {
4228 if (iprop->defaultarray) {
4229 fprintf(f, "%d", iprop->defaultarray[i]);
4230 }
4231 else {
4232 fprintf(f, "%d", iprop->defaultvalue);
4233 }
4234 if (i != prop->totarraylength - 1) {
4235 fprintf(f, ",\n\t");
4236 }
4237 }
4238
4239 fprintf(f, "\n};\n\n");
4240 }
4241 break;
4242 }
4243 case PROP_FLOAT: {
4244 FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
4245 uint i;
4246
4247 if (prop->arraydimension && prop->totarraylength) {
4248 fprintf(f,
4249 "static float rna_%s%s_%s_default[%u] = {\n\t",
4250 srna->identifier,
4251 strnest,
4252 prop->identifier,
4253 prop->totarraylength);
4254
4255 for (i = 0; i < prop->totarraylength; i++) {
4256 if (fprop->defaultarray) {
4257 rna_float_print(f, fprop->defaultarray[i]);
4258 }
4259 else {
4260 rna_float_print(f, fprop->defaultvalue);
4261 }
4262 if (i != prop->totarraylength - 1) {
4263 fprintf(f, ",\n\t");
4264 }
4265 }
4266
4267 fprintf(f, "\n};\n\n");
4268 }
4269 break;
4270 }
4271 case PROP_POINTER: {
4272 PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
4273
4274 /* XXX This systematically enforces that flag on ID pointers...
4275 * we'll probably have to revisit. :/ */
4276 StructRNA *type = rna_find_struct((const char *)pprop->type);
4277 if (type && (type->flag & STRUCT_ID) &&
4279 {
4281 }
4282 break;
4283 }
4284 case PROP_COLLECTION: {
4286
4287 /* XXX This systematically enforces that flag on ID pointers...
4288 * we'll probably have to revisit. :/ */
4289 StructRNA *type = rna_find_struct((const char *)cprop->item_type);
4290 if (type && (type->flag & STRUCT_ID) &&
4292 {
4294 }
4295 break;
4296 }
4297 default:
4298 break;
4299 }
4300
4301 /* Generate the RNA-private, type-refined property data.
4302 *
4303 * See #rna_generate_external_property_prototypes comments for details. */
4304 fprintf(f,
4305 "static %s rna_%s%s_%s_ = {\n",
4307 srna->identifier,
4308 strnest,
4309 prop->identifier);
4310
4311 if (prop->next) {
4312 fprintf(f, "\t{&rna_%s%s_%s, ", srna->identifier, strnest, prop->next->identifier);
4313 }
4314 else {
4315 fprintf(f, "\t{nullptr, ");
4316 }
4317 if (prop->prev) {
4318 fprintf(f, "&rna_%s%s_%s,\n", srna->identifier, strnest, prop->prev->identifier);
4319 }
4320 else {
4321 fprintf(f, "nullptr,\n");
4322 }
4323 fprintf(f, "\t%d, ", prop->magic);
4325 fprintf(f,
4326 ", %d, %d, %d, %d, %d, ",
4327 prop->flag,
4328 prop->flag_override,
4329 prop->flag_parameter,
4330 prop->flag_internal,
4331 prop->tags);
4332 rna_print_c_string(f, prop->name);
4333 fprintf(f, ",\n\t");
4335 fprintf(f, ",\n\t");
4336 fprintf(f, "%d, ", prop->icon);
4338 fprintf(f, ",\n");
4339 fprintf(f,
4340 "\t%s, (PropertySubType)((int)%s | (int)%s), %s, %u, {%u, %u, %u}, %u,\n",
4345 prop->arraydimension,
4346 prop->arraylength[0],
4347 prop->arraylength[1],
4348 prop->arraylength[2],
4349 prop->totarraylength);
4350 fprintf(f,
4351 "\t%s%s, %d, %s, %s, %s, %s, %s,\n",
4352 /* NOTE: void cast is needed to quiet function cast warning in C++. */
4353 (prop->flag & PROP_CONTEXT_UPDATE) ? "(UpdateFunc)(void *)" : "",
4355 prop->noteflag,
4361
4363 rna_set_raw_offset(f, srna, prop);
4364 }
4365 else {
4366 fprintf(f, "\t0, PROP_RAW_UNSET");
4367 }
4368
4369 /* our own type - collections/arrays only */
4370 if (prop->srna) {
4371 fprintf(f, ", &RNA_%s", (const char *)prop->srna);
4372 }
4373 else {
4374 fprintf(f, ", nullptr");
4375 }
4376
4377 fprintf(f, "},\n");
4378
4379 switch (prop->type) {
4380 case PROP_BOOLEAN: {
4381 BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
4382 fprintf(f,
4383 "\t%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, ",
4384 rna_function_string(bprop->get),
4385 rna_function_string(bprop->set),
4394 bprop->defaultvalue);
4395 if (prop->arraydimension && prop->totarraylength) {
4396 fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
4397 }
4398 else {
4399 fprintf(f, "nullptr\n");
4400 }
4401 break;
4402 }
4403 case PROP_INT: {
4404 IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
4405 fprintf(f,
4406 "\t%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,\n\t",
4407 rna_function_string(iprop->get),
4408 rna_function_string(iprop->set),
4411 rna_function_string(iprop->range),
4417 fprintf(f, "%s", rna_ui_scale_type_string(iprop->ui_scale_type));
4418 fprintf(f, ", ");
4419 rna_int_print(f, iprop->softmin);
4420 fprintf(f, ", ");
4421 rna_int_print(f, iprop->softmax);
4422 fprintf(f, ", ");
4423 rna_int_print(f, iprop->hardmin);
4424 fprintf(f, ", ");
4425 rna_int_print(f, iprop->hardmax);
4426 fprintf(f, ", ");
4427 rna_int_print(f, iprop->step);
4428 fprintf(f, ", ");
4429 fprintf(f,
4430 "%s, %s",
4433 fprintf(f, ", ");
4434 rna_int_print(f, iprop->defaultvalue);
4435 fprintf(f, ", ");
4436 if (prop->arraydimension && prop->totarraylength) {
4437 fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
4438 }
4439 else {
4440 fprintf(f, "nullptr\n");
4441 }
4442 break;
4443 }
4444 case PROP_FLOAT: {
4445 FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
4446 fprintf(f,
4447 "\t%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, ",
4448 rna_function_string(fprop->get),
4449 rna_function_string(fprop->set),
4452 rna_function_string(fprop->range),
4458 fprintf(f, "%s, ", rna_ui_scale_type_string(fprop->ui_scale_type));
4459 rna_float_print(f, fprop->softmin);
4460 fprintf(f, ", ");
4461 rna_float_print(f, fprop->softmax);
4462 fprintf(f, ", ");
4463 rna_float_print(f, fprop->hardmin);
4464 fprintf(f, ", ");
4465 rna_float_print(f, fprop->hardmax);
4466 fprintf(f, ", ");
4467 rna_float_print(f, fprop->step);
4468 fprintf(f, ", ");
4469 rna_int_print(f, int(fprop->precision));
4470 fprintf(f, ", ");
4471 fprintf(f,
4472 "%s, %s",
4475 fprintf(f, ", ");
4476 rna_float_print(f, fprop->defaultvalue);
4477 fprintf(f, ", ");
4478 if (prop->arraydimension && prop->totarraylength) {
4479 fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
4480 }
4481 else {
4482 fprintf(f, "nullptr\n");
4483 }
4484 break;
4485 }
4486 case PROP_STRING: {
4487 StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
4488 fprintf(f,
4489 "\t%s, %s, %s, %s, %s, %s, %s, (eStringPropertySearchFlag)%d, %d, ",
4490 rna_function_string(sprop->get),
4492 rna_function_string(sprop->set),
4497 int(sprop->search_flag),
4498 sprop->maxlength);
4500 fprintf(f, "\n");
4501 break;
4502 }
4503 case PROP_ENUM: {
4504 EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
4505 fprintf(f,
4506 "\t%s, %s, %s, %s, %s, ",
4507 rna_function_string(eprop->get),
4508 rna_function_string(eprop->set),
4511 rna_function_string(eprop->set_ex));
4512 if (eprop->item) {
4513 const char *item_global_id = rna_enum_id_from_pointer(eprop->item);
4514 if (item_global_id != nullptr) {
4515 fprintf(f, "%s, ", item_global_id);
4516 }
4517 else {
4518 fprintf(f, "rna_%s%s_%s_items, ", srna->identifier, strnest, prop->identifier);
4519 }
4520 }
4521 else {
4522 fprintf(f, "nullptr, ");
4523 }
4524 fprintf(f, "%d, %d\n", eprop->totitem, eprop->defaultvalue);
4525 break;
4526 }
4527 case PROP_POINTER: {
4528 PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
4529 fprintf(f,
4530 "\t%s, %s, %s, %s,",
4531 rna_function_string(pprop->get),
4532 rna_function_string(pprop->set),
4534 rna_function_string(pprop->poll));
4535 if (pprop->type) {
4536 fprintf(f, "&RNA_%s\n", (const char *)pprop->type);
4537 }
4538 else {
4539 fprintf(f, "nullptr\n");
4540 }
4541 break;
4542 }
4543 case PROP_COLLECTION: {
4545 fprintf(f,
4546 "\t%s, %s, %s, %s, %s, %s, %s, %s, ",
4547 rna_function_string(cprop->begin),
4548 rna_function_string(cprop->next),
4549 rna_function_string(cprop->end),
4550 rna_function_string(cprop->get),
4555 if (cprop->item_type) {
4556 fprintf(f, "&RNA_%s\n", (const char *)cprop->item_type);
4557 }
4558 else {
4559 fprintf(f, "nullptr\n");
4560 }
4561 break;
4562 }
4563 }
4564
4565 fprintf(f, "};\n");
4566
4567 /* Assign the RNA-private, type-refined static (local) property data to the public matching
4568 * generic `PropertyRNA &` reference.
4569 *
4570 * See #rna_generate_external_property_prototypes comments for details. */
4571 fprintf(
4572 f,
4573 /* Use a reference here instead of a pointer, because pointer usage somehow makes clang
4574 * optimizer take a very long time to compile the `rna_xxx_gen.cc` files (see faf56cc3bf).
4575 *
4576 * Note that in theory, any access to the 'public' `PointerRNA &` reference data is
4577 * undefined behavior (strict aliasing rules). This is currently not a real issue (these
4578 * PropertyRNA definitions are almost always only used as pointers, and are currently POD
4579 * types).
4580 *
4581 * `reinterpret_cast<PropertyRNA &>(rna_prop_data)` here is same as
4582 * `*reinterpret_cast<PropertyRNA *>(&rna_prop_data)` (see point (6) of
4583 * https://en.cppreference.com/w/cpp/language/reinterpret_cast). */
4584 "PropertyRNA &rna_%s%s_%s = reinterpret_cast<PropertyRNA &>(rna_%s%s_%s_);\n\n",
4585 srna->identifier,
4586 strnest,
4587 prop->identifier,
4588 srna->identifier,
4589 strnest,
4590 prop->identifier);
4591
4592 if (freenest) {
4593 MEM_freeN(strnest);
4594 MEM_freeN(errnest);
4595 }
4596}
4597
4598static void rna_generate_struct(BlenderRNA * /*brna*/, StructRNA *srna, FILE *f)
4599{
4600 FunctionRNA *func;
4601 FunctionDefRNA *dfunc;
4602 PropertyRNA *prop, *parm;
4603 StructRNA *base;
4604
4605 fprintf(f, "/* %s */\n", srna->name);
4606
4607 LISTBASE_FOREACH (PropertyRNA *, prop, &srna->cont.properties) {
4608 rna_generate_property(f, srna, nullptr, prop);
4609 }
4610
4611 for (func = static_cast<FunctionRNA *>(srna->functions.first); func;
4612 func = static_cast<FunctionRNA *>(func->cont.next))
4613 {
4614 LISTBASE_FOREACH (PropertyRNA *, parm, &func->cont.properties) {
4615 rna_generate_property(f, srna, func->identifier, parm);
4616 }
4617
4618 fprintf(f, "%s%s rna_%s_%s_func = {\n", "", "FunctionRNA", srna->identifier, func->identifier);
4619
4620 if (func->cont.next) {
4621 fprintf(f,
4622 "\t{(FunctionRNA *)&rna_%s_%s_func, ",
4623 srna->identifier,
4624 ((FunctionRNA *)func->cont.next)->identifier);
4625 }
4626 else {
4627 fprintf(f, "\t{nullptr, ");
4628 }
4629 if (func->cont.prev) {
4630 fprintf(f,
4631 "(FunctionRNA *)&rna_%s_%s_func,\n",
4632 srna->identifier,
4633 ((FunctionRNA *)func->cont.prev)->identifier);
4634 }
4635 else {
4636 fprintf(f, "nullptr,\n");
4637 }
4638
4639 fprintf(f, "\tnullptr,\n");
4640
4641 parm = static_cast<PropertyRNA *>(func->cont.properties.first);
4642 if (parm) {
4643 fprintf(f, "\t{&rna_%s_%s_%s, ", srna->identifier, func->identifier, parm->identifier);
4644 }
4645 else {
4646 fprintf(f, "\t{nullptr, ");
4647 }
4648
4649 parm = static_cast<PropertyRNA *>(func->cont.properties.last);
4650 if (parm) {
4651 fprintf(f, "&rna_%s_%s_%s}},\n", srna->identifier, func->identifier, parm->identifier);
4652 }
4653 else {
4654 fprintf(f, "nullptr}},\n");
4655 }
4656
4657 fprintf(f, "\t");
4659 fprintf(f, ", %d, ", func->flag);
4661 fprintf(f, ",\n");
4662
4663 dfunc = rna_find_function_def(func);
4664 if (dfunc->gencall) {
4665 fprintf(f, "\t%s,\n", dfunc->gencall);
4666 }
4667 else {
4668 fprintf(f, "\tnullptr,\n");
4669 }
4670
4671 if (func->c_ret) {
4672 fprintf(f, "\t&rna_%s_%s_%s\n", srna->identifier, func->identifier, func->c_ret->identifier);
4673 }
4674 else {
4675 fprintf(f, "\tnullptr\n");
4676 }
4677
4678 fprintf(f, "};\n");
4679 fprintf(f, "\n");
4680 }
4681
4682 fprintf(f, "StructRNA RNA_%s = {\n", srna->identifier);
4683
4684 if (srna->cont.next) {
4685 fprintf(f, "\t{(ContainerRNA *)&RNA_%s, ", ((StructRNA *)srna->cont.next)->identifier);
4686 }
4687 else {
4688 fprintf(f, "\t{nullptr, ");
4689 }
4690 if (srna->cont.prev) {
4691 fprintf(f, "(ContainerRNA *)&RNA_%s,\n", ((StructRNA *)srna->cont.prev)->identifier);
4692 }
4693 else {
4694 fprintf(f, "nullptr,\n");
4695 }
4696
4697 fprintf(f, "\tnullptr,\n");
4698
4699 prop = static_cast<PropertyRNA *>(srna->cont.properties.first);
4700 if (prop) {
4701 fprintf(f, "\t{&rna_%s_%s, ", srna->identifier, prop->identifier);
4702 }
4703 else {
4704 fprintf(f, "\t{nullptr, ");
4705 }
4706
4707 prop = static_cast<PropertyRNA *>(srna->cont.properties.last);
4708 if (prop) {
4709 fprintf(f, "&rna_%s_%s}},\n", srna->identifier, prop->identifier);
4710 }
4711 else {
4712 fprintf(f, "nullptr}},\n");
4713 }
4714 fprintf(f, "\t");
4716 fprintf(f, ", nullptr, nullptr"); /* PyType - Can't initialize here */
4717 fprintf(f, ", %d, nullptr, ", srna->flag);
4718 rna_print_c_string(f, srna->name);
4719 fprintf(f, ",\n\t");
4721 fprintf(f, ",\n\t");
4723 fprintf(f, ", %d,\n", srna->icon);
4724
4725 prop = srna->nameproperty;
4726 if (prop) {
4727 base = srna;
4728 while (base->base && base->base->nameproperty == prop) {
4729 base = base->base;
4730 }
4731
4732 fprintf(f, "\t&rna_%s_%s, ", base->identifier, prop->identifier);
4733 }
4734 else {
4735 fprintf(f, "\tnullptr, ");
4736 }
4737
4738 prop = srna->iteratorproperty;
4739 base = srna;
4740 while (base->base && base->base->iteratorproperty == prop) {
4741 base = base->base;
4742 }
4743 fprintf(f, "&rna_%s_rna_properties,\n", base->identifier);
4744
4745 if (srna->base) {
4746 fprintf(f, "\t&RNA_%s,\n", srna->base->identifier);
4747 }
4748 else {
4749 fprintf(f, "\tnullptr,\n");
4750 }
4751
4752 if (srna->nested) {
4753 fprintf(f, "\t&RNA_%s,\n", srna->nested->identifier);
4754 }
4755 else {
4756 fprintf(f, "\tnullptr,\n");
4757 }
4758
4759 fprintf(f, "\t%s,\n", rna_function_string(srna->refine));
4760 fprintf(f, "\t%s,\n", rna_function_string(srna->path));
4761 fprintf(f, "\t%s,\n", rna_function_string(srna->reg));
4762 fprintf(f, "\t%s,\n", rna_function_string(srna->unreg));
4763 fprintf(f, "\t%s,\n", rna_function_string(srna->instance));
4764 fprintf(f, "\t%s,\n", rna_function_string(srna->idproperties));
4765
4766 if (srna->reg && !srna->refine) {
4767 CLOG_ERROR(
4768 &LOG, "%s has a register function, must also have refine function.", srna->identifier);
4769 DefRNA.error = true;
4770 }
4771
4772 func = static_cast<FunctionRNA *>(srna->functions.first);
4773 if (func) {
4774 fprintf(f, "\t{(FunctionRNA *)&rna_%s_%s_func, ", srna->identifier, func->identifier);
4775 }
4776 else {
4777 fprintf(f, "\t{nullptr, ");
4778 }
4779
4780 func = static_cast<FunctionRNA *>(srna->functions.last);
4781 if (func) {
4782 fprintf(f, "(FunctionRNA *)&rna_%s_%s_func}\n", srna->identifier, func->identifier);
4783 }
4784 else {
4785 fprintf(f, "nullptr}\n");
4786 }
4787
4788 fprintf(f, "};\n");
4789
4790 fprintf(f, "\n");
4791}
4792
4794 const char *filename;
4795 const char *api_filename;
4796 void (*define)(BlenderRNA *brna);
4797};
4798
4800 {"rna_rna.cc", nullptr, RNA_def_rna},
4801 {"rna_ID.cc", nullptr, RNA_def_ID},
4802 {"rna_texture.cc", "rna_texture_api.cc", RNA_def_texture},
4803 {"rna_action.cc", "rna_action_api.cc", RNA_def_action},
4804 {"rna_animation.cc", "rna_animation_api.cc", RNA_def_animation},
4805 {"rna_animviz.cc", nullptr, RNA_def_animviz},
4806 {"rna_armature.cc", "rna_armature_api.cc", RNA_def_armature},
4807 {"rna_attribute.cc", nullptr, RNA_def_attribute},
4808 {"rna_asset.cc", nullptr, RNA_def_asset},
4809 {"rna_boid.cc", nullptr, RNA_def_boid},
4810 {"rna_brush.cc", nullptr, RNA_def_brush},
4811 {"rna_cachefile.cc", nullptr, RNA_def_cachefile},
4812 {"rna_camera.cc", "rna_camera_api.cc", RNA_def_camera},
4813 {"rna_cloth.cc", nullptr, RNA_def_cloth},
4814 {"rna_collection.cc", nullptr, RNA_def_collections},
4815 {"rna_color.cc", nullptr, RNA_def_color},
4816 {"rna_constraint.cc", nullptr, RNA_def_constraint},
4817 {"rna_context.cc", nullptr, RNA_def_context},
4818 {"rna_curve.cc", "rna_curve_api.cc", RNA_def_curve},
4819 {"rna_dynamicpaint.cc", nullptr, RNA_def_dynamic_paint},
4820 {"rna_fcurve.cc", "rna_fcurve_api.cc", RNA_def_fcurve},
4821 {"rna_annotations.cc", nullptr, RNA_def_annotations},
4822 {"rna_grease_pencil.cc", "rna_grease_pencil_api.cc", RNA_def_grease_pencil},
4823 {"rna_curves.cc", "rna_curves_api.cc", RNA_def_curves},
4824 {"rna_image.cc", "rna_image_api.cc", RNA_def_image},
4825 {"rna_key.cc", nullptr, RNA_def_key},
4826 {"rna_light.cc", nullptr, RNA_def_light},
4827 {"rna_lattice.cc", "rna_lattice_api.cc", RNA_def_lattice},
4828 {"rna_layer.cc", nullptr, RNA_def_view_layer},
4829 {"rna_linestyle.cc", nullptr, RNA_def_linestyle},
4830 {"rna_blendfile_import.cc", nullptr, RNA_def_blendfile_import},
4831 {"rna_main.cc", "rna_main_api.cc", RNA_def_main},
4832 {"rna_fluid.cc", nullptr, RNA_def_fluid},
4833 {"rna_material.cc", "rna_material_api.cc", RNA_def_material},
4834 {"rna_mesh.cc", "rna_mesh_api.cc", RNA_def_mesh},
4835 {"rna_meta.cc", "rna_meta_api.cc", RNA_def_meta},
4836 {"rna_modifier.cc", nullptr, RNA_def_modifier},
4837 {"rna_shader_fx.cc", nullptr, RNA_def_shader_fx},
4838 {"rna_nla.cc", nullptr, RNA_def_nla},
4839 {"rna_nodetree.cc", nullptr, RNA_def_nodetree},
4840 {"rna_node_socket.cc", nullptr, RNA_def_node_socket_subtypes},
4841 {"rna_node_tree_interface.cc", nullptr, RNA_def_node_tree_interface},
4842 {"rna_object.cc", "rna_object_api.cc", RNA_def_object},
4843 {"rna_object_force.cc", nullptr, RNA_def_object_force},
4844 {"rna_depsgraph.cc", nullptr, RNA_def_depsgraph},
4845 {"rna_packedfile.cc", nullptr, RNA_def_packedfile},
4846 {"rna_palette.cc", nullptr, RNA_def_palette},
4847 {"rna_particle.cc", nullptr, RNA_def_particle},
4848 {"rna_pointcloud.cc", nullptr, RNA_def_pointcloud},
4849 {"rna_pose.cc", "rna_pose_api.cc", RNA_def_pose},
4850 {"rna_curveprofile.cc", nullptr, RNA_def_profile},
4851 {"rna_lightprobe.cc", nullptr, RNA_def_lightprobe},
4852 {"rna_render.cc", nullptr, RNA_def_render},
4853 {"rna_rigidbody.cc", nullptr, RNA_def_rigidbody},
4854 {"rna_scene.cc", "rna_scene_api.cc", RNA_def_scene},
4855 {"rna_screen.cc", nullptr, RNA_def_screen},
4856 {"rna_sculpt_paint.cc", nullptr, RNA_def_sculpt_paint},
4857 {"rna_sequencer.cc", "rna_sequencer_api.cc", RNA_def_sequencer},
4858 {"rna_space.cc", "rna_space_api.cc", RNA_def_space},
4859 {"rna_speaker.cc", nullptr, RNA_def_speaker},
4860 {"rna_test.cc", nullptr, RNA_def_test},
4861 {"rna_text.cc", "rna_text_api.cc", RNA_def_text},
4862 {"rna_timeline.cc", nullptr, RNA_def_timeline_marker},
4863 {"rna_sound.cc", "rna_sound_api.cc", RNA_def_sound},
4864 {"rna_ui.cc", "rna_ui_api.cc", RNA_def_ui},
4865#ifdef WITH_USD
4866 {"rna_usd.cc", nullptr, RNA_def_usd},
4867#endif
4868 {"rna_userdef.cc", nullptr, RNA_def_userdef},
4869 {"rna_vfont.cc", "rna_vfont_api.cc", RNA_def_vfont},
4870 {"rna_volume.cc", nullptr, RNA_def_volume},
4871 {"rna_wm.cc", "rna_wm_api.cc", RNA_def_wm},
4872 {"rna_wm_gizmo.cc", "rna_wm_gizmo_api.cc", RNA_def_wm_gizmo},
4873 {"rna_workspace.cc", "rna_workspace_api.cc", RNA_def_workspace},
4874 {"rna_world.cc", nullptr, RNA_def_world},
4875 {"rna_movieclip.cc", nullptr, RNA_def_movieclip},
4876 {"rna_tracking.cc", nullptr, RNA_def_tracking},
4877 {"rna_mask.cc", nullptr, RNA_def_mask},
4878 {"rna_xr.cc", nullptr, RNA_def_xr},
4879 {nullptr, nullptr},
4880};
4881
4882static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const char *api_filename)
4883{
4884 StructDefRNA *ds;
4885 FunctionDefRNA *dfunc;
4886
4887 fprintf(f,
4888 "\n"
4889 "/* Automatically generated struct definitions for the Data API.\n"
4890 " * Do not edit manually, changes will be overwritten. */\n\n"
4891 "#define RNA_RUNTIME\n\n");
4892
4893 fprintf(f, "#include <float.h>\n");
4894 fprintf(f, "#include <stdio.h>\n");
4895 fprintf(f, "#include <limits.h>\n");
4896 fprintf(f, "#include <limits>\n");
4897 fprintf(f, "#include <string.h>\n\n");
4898 fprintf(f, "#include <stddef.h>\n\n");
4899 fprintf(f, "#include <algorithm>\n\n");
4900
4901 fprintf(f, "#include \"MEM_guardedalloc.h\"\n\n");
4902
4903 fprintf(f, "#include \"DNA_ID.h\"\n");
4904 fprintf(f, "#include \"DNA_scene_types.h\"\n");
4905 fprintf(f, "#include \"DNA_node_types.h\"\n");
4906
4907 fprintf(f, "#include \"BLI_blenlib.h\"\n\n");
4908 fprintf(f, "#include \"BLI_utildefines.h\"\n\n");
4909
4910 fprintf(f, "#include \"BKE_context.hh\"\n");
4911 fprintf(f, "#include \"BKE_lib_id.hh\"\n");
4912 fprintf(f, "#include \"BKE_main.hh\"\n");
4913 fprintf(f, "#include \"BKE_report.hh\"\n");
4914
4915 fprintf(f, "#include \"RNA_define.hh\"\n");
4916 fprintf(f, "#include \"RNA_types.hh\"\n");
4917 fprintf(f, "#include \"rna_internal.hh\"\n\n");
4918
4919 /* include the generated prototypes header */
4920 fprintf(f, "#include \"rna_prototypes_gen.hh\"\n\n");
4921
4922 if (filename) {
4923 fprintf(f, "#include \"%s\"\n", filename);
4924 }
4925 if (api_filename) {
4926 fprintf(f, "#include \"%s\"\n", api_filename);
4927 }
4928 fprintf(f, "\n");
4929
4930/* we want the included C files to have warnings enabled but for the generated code
4931 * ignore unused-parameter warnings which are hard to prevent */
4932#if defined(__GNUC__) || defined(__clang__)
4933 fprintf(f, "#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n\n");
4934#endif
4935
4936#if defined(__clang__)
4937 /* TODO(@ideasman42): ideally this workaround would not be needed,
4938 * could use some further investigation as these are intended to be declared. */
4939 fprintf(f, "#pragma GCC diagnostic ignored \"-Wmissing-variable-declarations\"\n\n");
4940#endif
4941
4942 fprintf(f, "/* Auto-generated Functions. */\n\n");
4943
4944 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
4945 ds = static_cast<StructDefRNA *>(ds->cont.next))
4946 {
4947 if (!filename || ds->filename == filename) {
4950 }
4951 }
4952
4953 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
4954 ds = static_cast<StructDefRNA *>(ds->cont.next))
4955 {
4956 if (!filename || ds->filename == filename) {
4958 rna_def_property_funcs(f, ds->srna, dp);
4959 }
4960 }
4961 }
4962
4963 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
4964 ds = static_cast<StructDefRNA *>(ds->cont.next))
4965 {
4966 if (!filename || ds->filename == filename) {
4969 }
4970
4971 for (dfunc = static_cast<FunctionDefRNA *>(ds->functions.first); dfunc;
4972 dfunc = static_cast<FunctionDefRNA *>(dfunc->cont.next))
4973 {
4974 rna_def_function_wrapper_funcs(f, ds, dfunc);
4975 rna_def_function_funcs(f, ds, dfunc);
4976 }
4977
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) {
4986 rna_generate_struct(brna, ds->srna, f);
4987 }
4988 }
4989
4990 if (filename && STREQ(filename, "rna_ID.cc")) {
4991 /* this is ugly, but we cannot have c files compiled for both
4992 * makesrna and blender with some build systems at the moment */
4993 fprintf(f, "#include \"rna_define.cc\"\n\n");
4994
4995 rna_generate_blender(brna, f);
4996 }
4997}
4998
4999static void rna_generate_header(BlenderRNA * /*brna*/, FILE *f)
5000{
5001 StructDefRNA *ds;
5002 StructRNA *srna;
5003 FunctionDefRNA *dfunc;
5004
5005 fprintf(f, "\n#ifndef __RNA_BLENDER_H__\n");
5006 fprintf(f, "#define __RNA_BLENDER_H__\n\n");
5007
5008 fprintf(f,
5009 "/* Automatically generated function declarations for the Data API.\n"
5010 " * Do not edit manually, changes will be overwritten. */\n\n");
5011
5012 fprintf(f, "#include \"RNA_types.hh\"\n\n");
5013 fprintf(f, "#include \"DNA_node_types.h\"\n\n");
5014
5015 fprintf(f, "#define FOREACH_BEGIN(property, sptr, itemptr) \\\n");
5016 fprintf(f, " { \\\n");
5017 fprintf(f, " CollectionPropertyIterator rna_macro_iter; \\\n");
5018 fprintf(f,
5019 " for (property##_begin(&rna_macro_iter, sptr); rna_macro_iter.valid; "
5020 "property##_next(&rna_macro_iter)) { \\\n");
5021 fprintf(f, " itemptr = rna_macro_iter.ptr;\n\n");
5022
5023 fprintf(f, "#define FOREACH_END(property) \\\n");
5024 fprintf(f, " } \\\n");
5025 fprintf(f, " property##_end(&rna_macro_iter); \\\n");
5026 fprintf(f, " }\n\n");
5027
5028 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5029 ds = static_cast<StructDefRNA *>(ds->cont.next))
5030 {
5031 srna = ds->srna;
5032
5033 fprintf(f, "/**************** %s ****************/\n\n", srna->name);
5034
5035 while (srna) {
5036 fprintf(f, "extern StructRNA RNA_%s;\n", srna->identifier);
5037 srna = srna->base;
5038 }
5039 fprintf(f, "\n");
5040
5043 }
5044
5045 for (dfunc = static_cast<FunctionDefRNA *>(ds->functions.first); dfunc;
5046 dfunc = static_cast<FunctionDefRNA *>(dfunc->cont.next))
5047 {
5048 rna_def_function_funcs_header(f, ds->srna, dfunc);
5049 }
5050 }
5051
5052 fprintf(f, "#endif /* __RNA_BLENDER_H__ */\n\n");
5053}
5054
5055static const char *cpp_classes =
5056 ""
5057 "\n"
5058 "#include <stdlib.h> /* for malloc */\n"
5059 "#include <string>\n"
5060 "#include <string.h> /* for memcpy */\n"
5061 "\n"
5062 "namespace BL {\n"
5063 "\n"
5064 "#define BOOLEAN_PROPERTY(sname, identifier) \\\n"
5065 " inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr) ? true: "
5066 "false; } \\\n"
5067 " inline void sname::identifier(bool value) { sname##_##identifier##_set(&ptr, value); }\n"
5068 "\n"
5069 "#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n"
5070 " inline Array<bool, size> sname::identifier(void) \\\n"
5071 " { Array<bool, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
5072 " inline void sname::identifier(bool values[size]) \\\n"
5073 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5074 "\n"
5075 "#define BOOLEAN_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
5076 " inline DynamicArray<bool> sname::identifier(void) { \\\n"
5077 " int arraylen[3]; \\\n"
5078 " int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
5079 " DynamicArray<bool> ar(len); \\\n"
5080 " sname##_##identifier##_get(&ptr, ar.data); \\\n"
5081 " return ar; } \\\n"
5082 " inline void sname::identifier(bool values[]) \\\n"
5083 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5084 "\n"
5085 "#define INT_PROPERTY(sname, identifier) \\\n"
5086 " inline int sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n"
5087 " inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n"
5088 "\n"
5089 "#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
5090 " inline Array<int, size> sname::identifier(void) \\\n"
5091 " { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
5092 " inline void sname::identifier(int values[size]) \\\n"
5093 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5094 "\n"
5095 "#define INT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
5096 " inline DynamicArray<int> sname::identifier(void) { \\\n"
5097 " int arraylen[3]; \\\n"
5098 " int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
5099 " DynamicArray<int> ar(len); \\\n"
5100 " sname##_##identifier##_get(&ptr, ar.data); \\\n"
5101 " return ar; } \\\n"
5102 " inline void sname::identifier(int values[]) \\\n"
5103 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5104 "\n"
5105 "#define FLOAT_PROPERTY(sname, identifier) \\\n"
5106 " inline float sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n"
5107 " inline void sname::identifier(float value) { sname##_##identifier##_set(&ptr, value); }\n"
5108 "\n"
5109 "#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
5110 " inline Array<float, size> sname::identifier(void) \\\n"
5111 " { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
5112 " inline void sname::identifier(float values[size]) \\\n"
5113 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5114 "\n"
5115 "#define FLOAT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
5116 " inline DynamicArray<float> sname::identifier(void) { \\\n"
5117 " int arraylen[3]; \\\n"
5118 " int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
5119 " DynamicArray<float> ar(len); \\\n"
5120 " sname##_##identifier##_get(&ptr, ar.data); \\\n"
5121 " return ar; } \\\n"
5122 " inline void sname::identifier(float values[]) \\\n"
5123 " { sname##_##identifier##_set(&ptr, values); } \\\n"
5124 "\n"
5125 "#define ENUM_PROPERTY(type, sname, identifier) \\\n"
5126 " inline sname::type sname::identifier(void) { return "
5127 "(type)sname##_##identifier##_get(&ptr); } \\\n"
5128 " inline void sname::identifier(sname::type value) { sname##_##identifier##_set(&ptr, "
5129 "value); }\n"
5130 "\n"
5131 "#define STRING_PROPERTY(sname, identifier) \\\n"
5132 " inline std::string sname::identifier(void) { \\\n"
5133 " int len = sname##_##identifier##_length(&ptr); \\\n"
5134 " std::string str; str.resize(len); \\\n"
5135 " sname##_##identifier##_get(&ptr, &str[0]); return str; } \\\n"
5136 " inline void sname::identifier(const std::string& value) { \\\n"
5137 " sname##_##identifier##_set(&ptr, value.c_str()); } \\\n"
5138 "\n"
5139 "#define POINTER_PROPERTY(type, sname, identifier) \\\n"
5140 " inline type sname::identifier(void) { return type(sname##_##identifier##_get(&ptr)); }\n"
5141 "\n"
5142 "#define COLLECTION_PROPERTY_LENGTH_false(sname, identifier) \\\n"
5143 " inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n"
5144 " { \\\n"
5145 " CollectionPropertyIterator iter; \\\n"
5146 " int length = 0; \\\n"
5147 " sname##_##identifier##_begin(&iter, ptr); \\\n"
5148 " while (iter.valid) { \\\n"
5149 " sname##_##identifier##_next(&iter); \\\n"
5150 " ++length; \\\n"
5151 " } \\\n"
5152 " sname##_##identifier##_end(&iter); \\\n"
5153 " return length; \\\n"
5154 " } \n"
5155 "#define COLLECTION_PROPERTY_LENGTH_true(sname, identifier) \\\n"
5156 " inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n"
5157 " { return sname##_##identifier##_length(ptr); } \n"
5158 "\n"
5159 "#define COLLECTION_PROPERTY_EMPTY_false(sname, identifier) \\\n"
5160 " inline static bool sname##_##identifier##_empty_wrap(PointerRNA *ptr) \\\n"
5161 " { \\\n"
5162 " CollectionPropertyIterator iter; \\\n"
5163 " sname##_##identifier##_begin(&iter, ptr); \\\n"
5164 " bool empty = !iter.valid; \\\n"
5165 " sname##_##identifier##_end(&iter); \\\n"
5166 " return empty; \\\n"
5167 " } \n"
5168 "#define COLLECTION_PROPERTY_EMPTY_true(sname, identifier) \\\n"
5169 " inline static bool sname##_##identifier##_empty_wrap(PointerRNA *ptr) \\\n"
5170 " { return sname##_##identifier##_length(ptr) == 0; } \n"
5171 "\n"
5172 "#define COLLECTION_PROPERTY_LOOKUP_INT_false(sname, identifier) \\\n"
5173 " inline static bool sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, "
5174 "PointerRNA *r_ptr) \\\n"
5175 " { \\\n"
5176 " CollectionPropertyIterator iter; \\\n"
5177 " int i = 0; \\\n"
5178 " bool found = false; \\\n"
5179 " sname##_##identifier##_begin(&iter, ptr); \\\n"
5180 " while (iter.valid) { \\\n"
5181 " if (i == key) { \\\n"
5182 " *r_ptr = iter.ptr; \\\n"
5183 " found = true; \\\n"
5184 " break; \\\n"
5185 " } \\\n"
5186 " sname##_##identifier##_next(&iter); \\\n"
5187 " ++i; \\\n"
5188 " } \\\n"
5189 " sname##_##identifier##_end(&iter); \\\n"
5190 " if (!found) { \\\n"
5191 " memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
5192 " } \\\n"
5193 " return found; \\\n"
5194 " } \n"
5195 "#define COLLECTION_PROPERTY_LOOKUP_INT_true(sname, identifier) \\\n"
5196 " inline static bool sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, "
5197 "PointerRNA *r_ptr) \\\n"
5198 " { \\\n"
5199 " bool found = sname##_##identifier##_lookup_int(ptr, key, r_ptr); \\\n"
5200 " if (!found) { \\\n"
5201 " memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
5202 " } \\\n"
5203 " return found; \\\n"
5204 " } \n"
5205 "#define COLLECTION_PROPERTY_LOOKUP_STRING_false(sname, identifier) \\\n"
5206 " inline static bool sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char "
5207 "*key, PointerRNA *r_ptr) \\\n"
5208 " { \\\n"
5209 " CollectionPropertyIterator iter; \\\n"
5210 " bool found = false; \\\n"
5211 " PropertyRNA *item_name_prop = RNA_struct_name_property(ptr->type); \\\n"
5212 " sname##_##identifier##_begin(&iter, ptr); \\\n"
5213 " while (iter.valid && !found) { \\\n"
5214 " char name_fixed[32]; \\\n"
5215 " const char *name; \\\n"
5216 " int name_length; \\\n"
5217 " name = RNA_property_string_get_alloc(&iter.ptr, item_name_prop, name_fixed, "
5218 "sizeof(name_fixed), &name_length); \\\n"
5219 " if (!strncmp(name, key, name_length)) { \\\n"
5220 " *r_ptr = iter.ptr; \\\n"
5221 " found = true; \\\n"
5222 " } \\\n"
5223 " if (name_fixed != name) { \\\n"
5224 " MEM_freeN((void *) name); \\\n"
5225 " } \\\n"
5226 " sname##_##identifier##_next(&iter); \\\n"
5227 " } \\\n"
5228 " sname##_##identifier##_end(&iter); \\\n"
5229 " if (!found) { \\\n"
5230 " memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
5231 " } \\\n"
5232 " return found; \\\n"
5233 " } \n"
5234 "#define COLLECTION_PROPERTY_LOOKUP_STRING_true(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 " bool found = sname##_##identifier##_lookup_string(ptr, key, r_ptr); \\\n"
5239 " if (!found) { \\\n"
5240 " memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
5241 " } \\\n"
5242 " return found; \\\n"
5243 " } \n"
5244 "#define COLLECTION_PROPERTY(collection_funcs, type, sname, identifier, has_length, "
5245 "has_lookup_int, has_lookup_string) \\\n"
5246 " typedef CollectionIterator<type, sname##_##identifier##_begin, \\\n"
5247 " sname##_##identifier##_next, sname##_##identifier##_end> identifier##_iterator; \\\n"
5248 " COLLECTION_PROPERTY_LENGTH_##has_length(sname, identifier) \\\n"
5249 " COLLECTION_PROPERTY_EMPTY_##has_length(sname, identifier) \\\n"
5250 " COLLECTION_PROPERTY_LOOKUP_INT_##has_lookup_int(sname, identifier) \\\n"
5251 " COLLECTION_PROPERTY_LOOKUP_STRING_##has_lookup_string(sname, identifier) \\\n"
5252 " CollectionRef<sname, type, sname##_##identifier##_begin, \\\n"
5253 " sname##_##identifier##_next, sname##_##identifier##_end, \\\n"
5254 " sname##_##identifier##_length_wrap, \\\n"
5255 " sname##_##identifier##_empty_wrap, \\\n"
5256 " sname##_##identifier##_lookup_int_wrap, sname##_##identifier##_lookup_string_wrap, "
5257 "collection_funcs> identifier;\n"
5258 "\n"
5259 "class Pointer {\n"
5260 "public:\n"
5261 " Pointer(const PointerRNA &p) : ptr(p) { }\n"
5262 " operator const PointerRNA&() { return ptr; }\n"
5263 " bool is_a(StructRNA *type) { return RNA_struct_is_a(ptr.type, type) ? true: false; }\n"
5264 " operator void*() { return ptr.data; }\n"
5265 " operator bool() const { return ptr.data != nullptr; }\n"
5266 "\n"
5267 " bool operator==(const Pointer &other) const { return ptr.data == other.ptr.data; }\n"
5268 " bool operator!=(const Pointer &other) const { return ptr.data != other.ptr.data; }\n"
5269 " bool operator<(const Pointer &other) const { return ptr.data < other.ptr.data; }\n"
5270 "\n"
5271 " PointerRNA ptr;\n"
5272 "};\n"
5273 "\n"
5274 "\n"
5275 "template<typename T, int Tsize>\n"
5276 "class Array {\n"
5277 "public:\n"
5278 " T data[Tsize];\n"
5279 "\n"
5280 " Array() {}\n"
5281 " Array(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); }\n"
5282 " const Array<T, Tsize>& operator = (const Array<T, Tsize>& other) { memcpy(data, "
5283 "other.data, sizeof(T) * Tsize); "
5284 "return *this; }\n"
5285 "\n"
5286 " operator T*() { return data; }\n"
5287 " operator const T*() const { return data; }\n"
5288 "};\n"
5289 "\n"
5290 "template<typename T>\n"
5291 "class DynamicArray {\n"
5292 "public:\n"
5293 " T *data;\n"
5294 " int length;\n"
5295 "\n"
5296 " DynamicArray() : data(nullptr), length(0) {}\n"
5297 " DynamicArray(int new_length) : data(nullptr), length(new_length) { data = (T "
5298 "*)malloc(sizeof(T) * new_length); }\n"
5299 " DynamicArray(const DynamicArray<T>& other) : data(nullptr), length(0) { "
5300 "copy_from(other); "
5301 "}\n"
5302 " const DynamicArray<T>& operator = (const DynamicArray<T>& other) { copy_from(other); "
5303 "return *this; }\n"
5304 "\n"
5305 " ~DynamicArray() { if (data) free(data); }\n"
5306 "\n"
5307 " operator T*() { return data; }\n"
5308 "\n"
5309 "protected:\n"
5310 " void copy_from(const DynamicArray<T>& other) {\n"
5311 " if (data) free(data);\n"
5312 " data = (T *)malloc(sizeof(T) * other.length);\n"
5313 " memcpy(data, other.data, sizeof(T) * other.length);\n"
5314 " length = other.length;\n"
5315 " }\n"
5316 "};\n"
5317 "\n"
5318 "typedef void (*TBeginFunc)(CollectionPropertyIterator *iter, PointerRNA *ptr);\n"
5319 "typedef void (*TNextFunc)(CollectionPropertyIterator *iter);\n"
5320 "typedef void (*TEndFunc)(CollectionPropertyIterator *iter);\n"
5321 "typedef int (*TLengthFunc)(PointerRNA *ptr);\n"
5322 "typedef bool (*TEmptyFunc)(PointerRNA *ptr);\n"
5323 "typedef bool (*TLookupIntFunc)(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n"
5324 "typedef bool (*TLookupStringFunc)(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n"
5325 "\n"
5326 "template<typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n"
5327 "class CollectionIterator {\n"
5328 "public:\n"
5329 " CollectionIterator() : iter(), t(iter.ptr), init(false) { iter.valid = false; }\n"
5330 " CollectionIterator(const PointerRNA &ptr) : CollectionIterator() { this->begin(ptr); }\n"
5331 " ~CollectionIterator(void) { if (init) Tend(&iter); };\n"
5332 "\n"
5333 " CollectionIterator(const CollectionIterator &other) = delete;\n"
5334 " CollectionIterator(CollectionIterator &&other) = delete;\n"
5335 " CollectionIterator &operator=(const CollectionIterator &other) = delete;\n"
5336 " CollectionIterator &operator=(CollectionIterator &&other) = delete;\n"
5337 "\n"
5338 " operator bool(void) const\n"
5339 " { return iter.valid != 0; }\n"
5340 " const CollectionIterator<T, Tbegin, Tnext, Tend>& operator++() { Tnext(&iter); t = "
5341 "T(iter.ptr); return *this; }\n"
5342 "\n"
5343 " T& operator*(void) { return t; }\n"
5344 " T* operator->(void) { return &t; }\n"
5345 " bool operator == (const CollectionIterator<T, Tbegin, Tnext, Tend>& other) "
5346 "{ return iter.valid == other.iter.valid; }\n"
5347 " bool operator!=(const CollectionIterator<T, Tbegin, Tnext, Tend>& other) "
5348 "{ return iter.valid != other.iter.valid; }\n"
5349 "\n"
5350 " void begin(const Pointer &ptr)\n"
5351 " { if (init) Tend(&iter); Tbegin(&iter, (PointerRNA *)&ptr.ptr); t = T(iter.ptr); init = "
5352 "true; }\n"
5353 "\n"
5354 "private:\n"
5355 " CollectionPropertyIterator iter;\n"
5356 " T t;\n"
5357 " bool init;\n"
5358 "};\n"
5359 "\n"
5360 "template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend,\n"
5361 " TLengthFunc Tlength, TEmptyFunc Tempty, TLookupIntFunc Tlookup_int,\n"
5362 " TLookupStringFunc Tlookup_string, typename Tcollection_funcs>\n"
5363 "class CollectionRef : public Tcollection_funcs {\n"
5364 "public:\n"
5365 " CollectionRef(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n"
5366 "\n"
5367 " void begin(CollectionIterator<T, Tbegin, Tnext, Tend>& iter)\n"
5368 " { iter.begin(ptr); }\n"
5369 " CollectionIterator<T, Tbegin, Tnext, Tend> begin()\n"
5370 " { return CollectionIterator<T, Tbegin, Tnext, Tend>(ptr); }\n"
5371 " CollectionIterator<T, Tbegin, Tnext, Tend> end()\n"
5372 " { return CollectionIterator<T, Tbegin, Tnext, Tend>(); } /* test */ \n"
5373 ""
5374 " int length()\n"
5375 " { return Tlength(&ptr); }\n"
5376 " bool empty()\n"
5377 " { return Tempty(&ptr); }\n"
5378 " T operator[](int key)\n"
5379 " { PointerRNA r_ptr; Tlookup_int(&ptr, key, &r_ptr); return T(r_ptr); }\n"
5380 " T operator[](const std::string &key)\n"
5381 " { PointerRNA r_ptr; Tlookup_string(&ptr, key.c_str(), &r_ptr); return T(r_ptr); }\n"
5382 "\n"
5383 "private:\n"
5384 " PointerRNA ptr;\n"
5385 "};\n"
5386 "\n"
5387 "class DefaultCollectionFunctions {\n"
5388 "public:\n"
5389 " DefaultCollectionFunctions(const PointerRNA & /*p*/) {}\n"
5390 "};\n"
5391 "\n"
5392 "\n";
5393
5395{
5396 if (!(prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN)) {
5397 if (prop->type == PROP_COLLECTION) {
5398 return true;
5399 }
5400 }
5401
5402 return false;
5403}
5404
5405static bool rna_is_collection_functions_struct(const char **collection_structs,
5406 const char *struct_name)
5407{
5408 int a = 0;
5409 bool found = false;
5410
5411 while (collection_structs[a]) {
5412 if (STREQ(collection_structs[a], struct_name)) {
5413 found = true;
5414 break;
5415 }
5416 a++;
5417 }
5418
5419 return found;
5420}
5421
5423{
5424 StructRNA *srna = ds->srna;
5425 FunctionDefRNA *dfunc;
5426
5427 fprintf(f, "/**************** %s ****************/\n\n", srna->name);
5428
5429 fprintf(f,
5430 "class %s : public %s {\n",
5431 srna->identifier,
5432 (srna->base) ? srna->base->identifier : "Pointer");
5433 fprintf(f, "public:\n");
5434 fprintf(f,
5435 "\t%s(const PointerRNA &ptr_arg) :\n\t\t%s(ptr_arg)",
5436 srna->identifier,
5437 (srna->base) ? srna->base->identifier : "Pointer");
5439 if (rna_is_collection_prop(dp->prop)) {
5440 fprintf(f, ",\n\t\t%s(ptr_arg)", dp->prop->identifier);
5441 }
5442 }
5443 fprintf(f, "\n\t\t{}\n\n");
5444
5447 }
5448
5449 fprintf(f, "\n");
5450 for (dfunc = static_cast<FunctionDefRNA *>(ds->functions.first); dfunc;
5451 dfunc = static_cast<FunctionDefRNA *>(dfunc->cont.next))
5452 {
5453 rna_def_struct_function_header_cpp(f, srna, dfunc);
5454 }
5455
5456 fprintf(f, "};\n\n");
5457}
5458
5459static void rna_generate_header_cpp(BlenderRNA * /*brna*/, FILE *f)
5460{
5461 StructDefRNA *ds;
5462 StructRNA *srna;
5463 FunctionDefRNA *dfunc;
5464 const char *first_collection_func_struct = nullptr;
5465 const char *collection_func_structs[256] = {nullptr};
5466 int all_collection_func_structs = 0;
5467 int max_collection_func_structs = sizeof(collection_func_structs) /
5468 sizeof(collection_func_structs[0]) -
5469 1;
5470
5471 fprintf(f, "\n#ifndef __RNA_BLENDER_CPP_H__\n");
5472 fprintf(f, "#define __RNA_BLENDER_CPP_H__\n\n");
5473
5474 fprintf(f,
5475 "/* Automatically generated classes for the Data API.\n"
5476 " * Do not edit manually, changes will be overwritten. */\n\n");
5477
5478 fprintf(f, "#include \"RNA_blender.hh\"\n");
5479 fprintf(f, "#include \"RNA_types.hh\"\n");
5480 fprintf(f, "#include \"RNA_access.hh\"\n");
5481 fprintf(f, "#include \"DNA_node_types.h\"\n");
5482
5483 fprintf(f, "%s", cpp_classes);
5484
5485 fprintf(f, "/**************** Declarations ****************/\n\n");
5486
5487 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5488 ds = static_cast<StructDefRNA *>(ds->cont.next))
5489 {
5490 fprintf(f, "class %s;\n", ds->srna->identifier);
5491 }
5492 fprintf(f, "\n");
5493
5494 /* first get list of all structures used as collection functions, so they'll be declared first */
5495 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5496 ds = static_cast<StructDefRNA *>(ds->cont.next))
5497 {
5499 if (rna_is_collection_prop(dp->prop)) {
5500 PropertyRNA *prop = dp->prop;
5501
5502 if (prop->srna) {
5503 /* store name of structure which first uses custom functions for collections */
5504 if (first_collection_func_struct == nullptr) {
5505 first_collection_func_struct = ds->srna->identifier;
5506 }
5507
5508 if (!rna_is_collection_functions_struct(collection_func_structs, (char *)prop->srna)) {
5509 if (all_collection_func_structs >= max_collection_func_structs) {
5510 printf("Array size to store all collection structures names is too small\n");
5511 exit(1);
5512 }
5513
5514 collection_func_structs[all_collection_func_structs++] = (char *)prop->srna;
5515 }
5516 }
5517 }
5518 }
5519 }
5520
5521 /* declare all structures in such order:
5522 * - first N structures which doesn't use custom functions for collections
5523 * - all structures used for custom functions in collections
5524 * - all the rest structures
5525 * such an order prevents usage of non-declared classes
5526 */
5527 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5528 ds = static_cast<StructDefRNA *>(ds->cont.next))
5529 {
5530 srna = ds->srna;
5531
5532 if (STREQ(srna->identifier, first_collection_func_struct)) {
5533 StructDefRNA *ds2;
5534 StructRNA *srna2;
5535
5536 for (ds2 = static_cast<StructDefRNA *>(DefRNA.structs.first); ds2;
5537 ds2 = static_cast<StructDefRNA *>(ds2->cont.next))
5538 {
5539 srna2 = ds2->srna;
5540
5541 if (rna_is_collection_functions_struct(collection_func_structs, srna2->identifier)) {
5543 }
5544 }
5545 }
5546
5547 if (!rna_is_collection_functions_struct(collection_func_structs, srna->identifier)) {
5549 }
5550 }
5551
5552 fprintf(f, "} /* namespace BL */\n");
5553
5554 fprintf(f, "\n");
5555 fprintf(f, "/**************** Implementation ****************/\n");
5556 fprintf(f, "\n");
5557
5558 fprintf(f, "/* Structure prototypes */\n\n");
5560
5561 fprintf(f, "namespace BL {\n");
5562
5563 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5564 ds = static_cast<StructDefRNA *>(ds->cont.next))
5565 {
5566 srna = ds->srna;
5567
5570 }
5571
5572 fprintf(f, "\n");
5573
5574 for (dfunc = static_cast<FunctionDefRNA *>(ds->functions.first); dfunc;
5575 dfunc = static_cast<FunctionDefRNA *>(dfunc->cont.next))
5576 {
5577 rna_def_struct_function_impl_cpp(f, srna, dfunc);
5578 }
5579
5580 fprintf(f, "\n");
5581 }
5582
5583 fprintf(f, "}\n\n#endif /* __RNA_BLENDER_CPP_H__ */\n\n");
5584}
5585
5586static void make_bad_file(const char *file, int line)
5587{
5588 FILE *fp = fopen(file, "w");
5589 fprintf(fp,
5590 "#error \"Error! can't make correct RNA file from %s:%d, "
5591 "check DNA properties.\"\n",
5592 __FILE__,
5593 line);
5594 fclose(fp);
5595}
5596
5601static int rna_preprocess(const char *outfile, const char *public_header_outfile)
5602{
5603 BlenderRNA *brna;
5604 StructDefRNA *ds;
5605 FILE *file;
5606 char deffile[4096];
5607 int i;
5608 /* The exit code (returned from this function). */
5609 int status = EXIT_SUCCESS;
5610 const char *deps[3]; /* expand as needed */
5611
5612 if (!public_header_outfile) {
5613 public_header_outfile = outfile;
5614 }
5615
5616 /* define rna */
5617 brna = RNA_create();
5618
5619 for (i = 0; PROCESS_ITEMS[i].filename; i++) {
5620 if (PROCESS_ITEMS[i].define) {
5621 PROCESS_ITEMS[i].define(brna);
5622
5623 /* sanity check */
5624 if (!DefRNA.animate) {
5625 fprintf(stderr, "Error: DefRNA.animate left disabled in %s\n", PROCESS_ITEMS[i].filename);
5626 }
5627
5628 for (ds = static_cast<StructDefRNA *>(DefRNA.structs.first); ds;
5629 ds = static_cast<StructDefRNA *>(ds->cont.next))
5630 {
5631 if (!ds->filename) {
5633 }
5634 }
5635 }
5636 }
5637
5639 if (DefRNA.error) {
5640 status = EXIT_FAILURE;
5641 }
5642
5644 if (DefRNA.error) {
5645 status = EXIT_FAILURE;
5646 }
5647
5648 /* Create external rna struct prototype header file RNA_prototypes.hh. */
5649 SNPRINTF(deffile, "%s%s", public_header_outfile, "RNA_prototypes.hh" TMP_EXT);
5650 if (status != EXIT_SUCCESS) {
5651 make_bad_file(deffile, __LINE__);
5652 }
5653 file = fopen(deffile, "w");
5654 if (!file) {
5655 fprintf(stderr, "Unable to open file: %s\n", deffile);
5656 status = EXIT_FAILURE;
5657 }
5658 else {
5659 fprintf(file,
5660 "/* Automatically generated RNA property declarations, to statically reference \n"
5661 " * properties as `rna_[struct-name]_[property-name]`.\n"
5662 " *\n"
5663 " * DO NOT EDIT MANUALLY, changes will be overwritten.\n"
5664 " */\n\n");
5665
5666 fprintf(file, "#pragma once\n\n");
5668 fclose(file);
5669 if (DefRNA.error) {
5670 status = EXIT_FAILURE;
5671 }
5672 replace_if_different(deffile, nullptr);
5673 }
5674
5675 /* create internal rna struct prototype header file */
5676 SNPRINTF(deffile, "%s%s", outfile, "rna_prototypes_gen.hh" TMP_EXT);
5677 if (status != EXIT_SUCCESS) {
5678 make_bad_file(deffile, __LINE__);
5679 }
5680 file = fopen(deffile, "w");
5681 if (!file) {
5682 fprintf(stderr, "Unable to open file: %s\n", deffile);
5683 status = EXIT_FAILURE;
5684 }
5685 else {
5686 fprintf(file,
5687 "/* Automatically generated function declarations for the Data API.\n"
5688 " * Do not edit manually, changes will be overwritten. */\n\n");
5690 fclose(file);
5691 replace_if_different(deffile, nullptr);
5692 if (DefRNA.error) {
5693 status = EXIT_FAILURE;
5694 }
5695 }
5696
5697 /* Create `rna_gen_*.c` & `rna_gen_*.cc` files. */
5698 for (i = 0; PROCESS_ITEMS[i].filename; i++) {
5699 const bool is_cc = BLI_str_endswith(PROCESS_ITEMS[i].filename, ".cc");
5700 const int ext_len = is_cc ? 3 : 2;
5701 const int filename_len = strlen(PROCESS_ITEMS[i].filename);
5702 SNPRINTF(deffile,
5703 "%s%.*s%s" TMP_EXT,
5704 outfile,
5705 (filename_len - ext_len),
5706 PROCESS_ITEMS[i].filename,
5707 is_cc ? "_gen.cc" : "_gen.c");
5708 if (status != EXIT_SUCCESS) {
5709 make_bad_file(deffile, __LINE__);
5710 }
5711 else {
5712 file = fopen(deffile, "w");
5713
5714 if (!file) {
5715 fprintf(stderr, "Unable to open file: %s\n", deffile);
5716 status = EXIT_FAILURE;
5717 }
5718 else {
5719 rna_generate(brna, file, PROCESS_ITEMS[i].filename, PROCESS_ITEMS[i].api_filename);
5720 fclose(file);
5721 if (DefRNA.error) {
5722 status = EXIT_FAILURE;
5723 }
5724 }
5725 }
5726
5727 /* avoid unneeded rebuilds */
5728 deps[0] = PROCESS_ITEMS[i].filename;
5729 deps[1] = PROCESS_ITEMS[i].api_filename;
5730 deps[2] = nullptr;
5731
5732 replace_if_different(deffile, deps);
5733 }
5734
5735 /* Create `RNA_blender_cpp.hh`. */
5736 SNPRINTF(deffile, "%s%s", outfile, "RNA_blender_cpp.hh" TMP_EXT);
5737
5738 if (status != EXIT_SUCCESS) {
5739 make_bad_file(deffile, __LINE__);
5740 }
5741 else {
5742 file = fopen(deffile, "w");
5743
5744 if (!file) {
5745 fprintf(stderr, "Unable to open file: %s\n", deffile);
5746 status = EXIT_FAILURE;
5747 }
5748 else {
5749 rna_generate_header_cpp(brna, file);
5750 fclose(file);
5751 if (DefRNA.error) {
5752 status = EXIT_FAILURE;
5753 }
5754 }
5755 }
5756
5757 replace_if_different(deffile, nullptr);
5758
5759 rna_sort(brna);
5760
5761 /* Create `RNA_blender.hh`. */
5762 SNPRINTF(deffile, "%s%s", outfile, "RNA_blender.hh" TMP_EXT);
5763
5764 if (status != EXIT_SUCCESS) {
5765 make_bad_file(deffile, __LINE__);
5766 }
5767 else {
5768 file = fopen(deffile, "w");
5769
5770 if (!file) {
5771 fprintf(stderr, "Unable to open file: %s\n", deffile);
5772 status = EXIT_FAILURE;
5773 }
5774 else {
5775 rna_generate_header(brna, file);
5776 fclose(file);
5777 if (DefRNA.error) {
5778 status = EXIT_FAILURE;
5779 }
5780 }
5781 }
5782
5783 replace_if_different(deffile, nullptr);
5784
5785 /* free RNA */
5786 RNA_define_free(brna);
5787 RNA_free(brna);
5788
5789 return status;
5790}
5791
5792static void mem_error_cb(const char *errorStr)
5793{
5794 fprintf(stderr, "%s", errorStr);
5795 fflush(stderr);
5796}
5797
5798int main(int argc, char **argv)
5799{
5800 int return_status = EXIT_SUCCESS;
5801
5804
5805 CLG_init();
5806
5807 /* Some useful defaults since this runs standalone. */
5810
5811 if (argc < 2) {
5812 fprintf(stderr, "Usage: %s outdirectory [public header outdirectory]/\n", argv[0]);
5813 return_status = EXIT_FAILURE;
5814 }
5815 else {
5816 if (debugSRNA > 0) {
5817 fprintf(stderr, "Running makesrna\n");
5818 }
5819 makesrna_path = argv[0];
5820 return_status = rna_preprocess(argv[1], (argc > 2) ? argv[2] : nullptr);
5821 }
5822
5823 CLG_exit();
5824
5825 return return_status;
5826}
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
#define LISTBASE_FOREACH(type, var, list)
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:653
#define STRNCPY(dst, src)
Definition BLI_string.h:593
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:597
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:716
void CLG_exit(void)
Definition clog.c:706
void CLG_level_set(int level)
Definition clog.c:751
void CLG_init(void)
Definition clog.c:699
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:399
@ PARM_OUTPUT
Definition RNA_types.hh:398
PropertyScaleType
Definition RNA_types.hh:106
@ PROP_SCALE_LOG
Definition RNA_types.hh:113
@ PROP_SCALE_LINEAR
Definition RNA_types.hh:108
@ PROP_SCALE_CUBIC
Definition RNA_types.hh:118
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_SELF_TYPE
Definition RNA_types.hh:675
@ FUNC_NO_SELF
Definition RNA_types.hh:673
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:679
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
@ STRUCT_ID_REFCOUNT
Definition RNA_types.hh:720
@ STRUCT_ID
Definition RNA_types.hh:719
PropertyType
Definition RNA_types.hh:64
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
void(*)(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *edit_text, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn) StringPropertySearchFunc
Definition RNA_types.hh:598
@ PROP_UNIT_VOLUME
Definition RNA_types.hh:79
@ PROP_UNIT_POWER
Definition RNA_types.hh:87
@ PROP_UNIT_ROTATION
Definition RNA_types.hh:81
@ PROP_UNIT_FREQUENCY
Definition RNA_types.hh:91
@ PROP_UNIT_WAVELENGTH
Definition RNA_types.hh:89
@ PROP_UNIT_VELOCITY
Definition RNA_types.hh:84
@ PROP_UNIT_LENGTH
Definition RNA_types.hh:77
@ PROP_UNIT_NONE
Definition RNA_types.hh:76
@ PROP_UNIT_ACCELERATION
Definition RNA_types.hh:85
@ PROP_UNIT_AREA
Definition RNA_types.hh:78
@ PROP_UNIT_TIME
Definition RNA_types.hh:82
@ PROP_UNIT_CAMERA
Definition RNA_types.hh:86
@ PROP_UNIT_TEMPERATURE
Definition RNA_types.hh:88
@ PROP_UNIT_MASS
Definition RNA_types.hh:80
@ PROP_UNIT_TIME_ABSOLUTE
Definition RNA_types.hh:83
@ PROP_UNIT_COLOR_TEMPERATURE
Definition RNA_types.hh:90
#define RNA_SUBTYPE_UNIT(subtype)
Definition RNA_types.hh:121
@ PROP_RAW_INT8
Definition RNA_types.hh:483
@ PROP_RAW_UINT64
Definition RNA_types.hh:482
@ PROP_RAW_INT
Definition RNA_types.hh:473
@ PROP_RAW_INT64
Definition RNA_types.hh:481
@ PROP_RAW_BOOLEAN
Definition RNA_types.hh:476
@ PROP_RAW_CHAR
Definition RNA_types.hh:475
@ PROP_RAW_FLOAT
Definition RNA_types.hh:478
@ PROP_RAW_DOUBLE
Definition RNA_types.hh:477
@ PROP_RAW_UINT8
Definition RNA_types.hh:479
@ PROP_RAW_UINT16
Definition RNA_types.hh:480
@ PROP_RAW_SHORT
Definition RNA_types.hh:474
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_DYNAMIC
Definition RNA_types.hh:317
@ PROP_CONTEXT_UPDATE
Definition RNA_types.hh:296
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_ENUM_FLAG
Definition RNA_types.hh:293
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:284
@ PROP_ID_SELF_CHECK
Definition RNA_types.hh:259
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:253
@ PROP_IDPROPERTY
Definition RNA_types.hh:315
PropertySubType
Definition RNA_types.hh:135
@ PROP_TIME
Definition RNA_types.hh:156
@ PROP_MATRIX
Definition RNA_types.hh:168
@ PROP_DIRECTION
Definition RNA_types.hh:165
@ PROP_XYZ
Definition RNA_types.hh:172
@ PROP_DISTANCE
Definition RNA_types.hh:159
@ PROP_ACCELERATION
Definition RNA_types.hh:167
@ PROP_TEMPERATURE
Definition RNA_types.hh:187
@ PROP_BYTESTRING
Definition RNA_types.hh:143
@ PROP_POWER
Definition RNA_types.hh:184
@ PROP_LAYER_MEMBER
Definition RNA_types.hh:181
@ PROP_FILENAME
Definition RNA_types.hh:141
@ PROP_PASSWORD
Definition RNA_types.hh:146
@ PROP_COLOR
Definition RNA_types.hh:163
@ PROP_PIXEL
Definition RNA_types.hh:151
@ PROP_ANGLE
Definition RNA_types.hh:155
@ PROP_TIME_ABSOLUTE
Definition RNA_types.hh:157
@ PROP_DISTANCE_CAMERA
Definition RNA_types.hh:160
@ PROP_AXISANGLE
Definition RNA_types.hh:171
@ PROP_EULER
Definition RNA_types.hh:169
@ PROP_COORDS
Definition RNA_types.hh:177
@ PROP_COLOR_TEMPERATURE
Definition RNA_types.hh:193
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_DIRPATH
Definition RNA_types.hh:140
@ PROP_PERCENTAGE
Definition RNA_types.hh:153
@ PROP_FREQUENCY
Definition RNA_types.hh:195
@ PROP_FACTOR
Definition RNA_types.hh:154
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:175
@ PROP_TRANSLATION
Definition RNA_types.hh:164
@ PROP_UNSIGNED
Definition RNA_types.hh:152
@ PROP_LAYER
Definition RNA_types.hh:180
@ PROP_QUATERNION
Definition RNA_types.hh:170
@ PROP_FILEPATH
Definition RNA_types.hh:139
@ PROP_VELOCITY
Definition RNA_types.hh:166
@ PROP_WAVELENGTH
Definition RNA_types.hh:190
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
output_img define("CONVERT_EXPRESSION(value)", "value") .do_static_compilation(true)
local_group_size(16, 16) .push_constant(Type b
#define printf
FILE * file
#define fabsf(x)
int len
#define str(s)
#define PRId64
Definition inttypes.h:78
void MEM_init_memleak_detection()
static void rna_def_struct_function_header_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
Definition makesrna.cc:2748
static char * rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *, const char *manualfunc)
Definition makesrna.cc:1957
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:1674
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:3135
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_sanity_checks()
Definition makesrna.cc:3439
static void rna_auto_types()
Definition makesrna.cc:3460
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:2038
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:5459
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:2030
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:4799
static void rna_generate_header(BlenderRNA *, FILE *f)
Definition makesrna.cc:4999
static const char * rna_find_dna_type(const char *type)
Definition makesrna.cc:495
static const char * cpp_classes
Definition makesrna.cc:5055
static bool rna_is_collection_functions_struct(const char **collection_structs, const char *struct_name)
Definition makesrna.cc:5405
static void mem_error_cb(const char *errorStr)
Definition makesrna.cc:5792
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:5422
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:3697
static void rna_def_struct_function_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
Definition makesrna.cc:2993
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:2893
static void rna_generate_static_function_prototypes(BlenderRNA *, StructRNA *srna, FILE *f)
Definition makesrna.cc:3996
static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc)
Definition makesrna.cc:3062
static const char * rna_property_subtypename(PropertySubType type)
Definition makesrna.cc:3564
static char * rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
Definition makesrna.cc:1596
static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, PropertyRNA *prop)
Definition makesrna.cc:4078
static void rna_sort(BlenderRNA *brna)
Definition makesrna.cc:3521
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:2459
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:3772
static void rna_generate_struct_rna_prototypes(BlenderRNA *brna, FILE *f)
Definition makesrna.cc:3685
static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc, const char *name_override, int close_prototype)
Definition makesrna.cc:3825
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:2469
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:3726
static char * rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
Definition makesrna.cc:1510
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:1814
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:3792
static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
Definition makesrna.cc:2318
static const char * rna_enum_id_from_pointer(const EnumPropertyItem *item)
Definition makesrna.cc:623
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:3645
static void rna_generate_struct_prototypes(FILE *f)
Definition makesrna.cc:4028
static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const char *api_filename)
Definition makesrna.cc:4882
#define REN_IF_DIFF
static CLG_LogRef LOG
Definition makesrna.cc:35
static void rna_def_struct_function_prototype_cpp(FILE *f, StructRNA *, FunctionDefRNA *dfunc, const char *cpp_namespace, int close_prototype)
Definition makesrna.cc:2653
static void rna_def_property_wrapper_funcs(FILE *f, StructDefRNA *dsrna, PropertyDefRNA *dp)
Definition makesrna.cc:3049
static void rna_generate_struct(BlenderRNA *, StructRNA *srna, FILE *f)
Definition makesrna.cc:4598
#define TMP_EXT
Definition makesrna.cc:54
static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
Definition makesrna.cc:2761
static const char * rna_parameter_type_cpp_name(PropertyRNA *prop)
Definition makesrna.cc:2642
static char * rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *, const char *manualfunc)
Definition makesrna.cc:1926
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:5394
static const char * rna_property_structname(PropertyType type)
Definition makesrna.cc:3542
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:1979
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:5586
static int rna_preprocess(const char *outfile, const char *public_header_outfile)
Definition makesrna.cc:5601
static void rna_generate_internal_property_prototypes(BlenderRNA *, StructRNA *srna, FILE *f)
Definition makesrna.cc:3745
void *(* MEM_mallocN)(size_t len, const char *str)
Definition mallocn.cc:44
void(* MEM_set_error_callback)(void(*func)(const char *))
Definition mallocn.cc:59
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
ccl_device_inline float4 mask(const int4 mask, const float4 a)
#define L
int main()
void RNA_def_ID(BlenderRNA *brna)
Definition rna_ID.cc:2696
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:750
void RNA_def_attribute(BlenderRNA *brna)
void RNA_def_blendfile_import(BlenderRNA *brna)
void RNA_def_boid(BlenderRNA *brna)
Definition rna_boid.cc:710
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:52
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)
Definition rna_define.cc:90
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:3691
void RNA_def_wm(BlenderRNA *brna)
Definition rna_wm.cc:3072
void RNA_def_nla(BlenderRNA *brna)
Definition rna_nla.cc:1206
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:425
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:103
void RNA_def_movieclip(BlenderRNA *brna)
void RNA_def_light(BlenderRNA *brna)
Definition rna_light.cc:479
void RNA_def_shader_fx(BlenderRNA *brna)
void RNA_def_usd(BlenderRNA *brna)
Definition rna_usd.cc:161
void RNA_def_packedfile(BlenderRNA *brna)
void RNA_def_main(BlenderRNA *brna)
Definition rna_main.cc:168
void RNA_def_linestyle(BlenderRNA *brna)
void RNA_def_mesh(BlenderRNA *brna)
Definition rna_mesh.cc:3352
void RNA_def_sound(BlenderRNA *brna)
Definition rna_sound.cc:108
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:211
void RNA_def_mask(BlenderRNA *brna)
Definition rna_mask.cc:1155
void RNA_def_workspace(BlenderRNA *brna)
void RNA_def_pose(BlenderRNA *brna)
Definition rna_pose.cc:1472
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:50
void RNA_def_view_layer(BlenderRNA *brna)
Definition rna_layer.cc:603
void RNA_def_object(BlenderRNA *brna)
void RNA_def_key(BlenderRNA *brna)
Definition rna_key.cc:1146
void RNA_def_object_force(BlenderRNA *brna)
void RNA_def_timeline_marker(BlenderRNA *brna)
void RNA_def_xr(BlenderRNA *brna)
Definition rna_xr.cc:2552
void RNA_def_text(BlenderRNA *brna)
Definition rna_text.cc:293
void RNA_def_screen(BlenderRNA *brna)
void RNA_def_ui(BlenderRNA *brna)
Definition rna_ui.cc:2515
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:29
#define FLT_MAX
Definition stdcycles.h:14
__int64 int64_t
Definition stdint.h:89
#define INT64_MIN
Definition stdint.h:138
#define INT64_MAX
Definition stdint.h:139
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:506
const char * name
Definition RNA_types.hh:510
const char * description
Definition RNA_types.hh:512
const EnumPropertyItem * item
PropEnumSetFuncEx set_ex
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
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:4796
const char * filename
Definition makesrna.cc:4794
const char * api_filename
Definition makesrna.cc:4795
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
uint8_t flag
Definition wm_window.cc:138