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