4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * Contributor(s): Blender Foundation (2008).
22 * ***** END GPL LICENSE BLOCK *****
31 #include "MEM_guardedalloc.h"
33 #include "RNA_access.h"
34 #include "RNA_define.h"
35 #include "RNA_types.h"
37 #include "rna_internal.h"
39 #define RNA_VERSION_DATE "$Id$"
43 #define snprintf _snprintf
47 /* Replace if different */
48 #define TMP_EXT ".tmp"
50 static int replace_if_different(char *tmpfile)
52 // return 0; // use for testing had edited rna
56 if(rename(tmpfile, orgfile) != 0) { \
57 fprintf(stderr, "%s:%d, rename error: \"%s\" -> \"%s\"\n", __FILE__, __LINE__, tmpfile, orgfile); \
65 FILE *fp_new, *fp_org;
67 char *arr_new, *arr_org;
72 strcpy(orgfile, tmpfile);
73 orgfile[strlen(orgfile) - strlen(TMP_EXT)] = '\0'; /* strip '.tmp' */
75 fp_org= fopen(orgfile, "rb");
81 fp_new= fopen(tmpfile, "rb");
84 /* shouldn't happen, just to be safe */
85 fprintf(stderr, "%s:%d, open error: \"%s\"\n", __FILE__, __LINE__, tmpfile);
90 fseek(fp_new, 0L, SEEK_END); len_new = ftell(fp_new); fseek(fp_new, 0L, SEEK_SET);
91 fseek(fp_org, 0L, SEEK_END); len_org = ftell(fp_org); fseek(fp_org, 0L, SEEK_SET);
94 if(len_new != len_org) {
100 /* now compare the files... */
101 arr_new= MEM_mallocN(sizeof(char)*len_new, "rna_cmp_file_new");
102 arr_org= MEM_mallocN(sizeof(char)*len_org, "rna_cmp_file_org");
104 if(fread(arr_new, sizeof(char), len_new, fp_new) != len_new)
105 fprintf(stderr, "%s:%d, error reading file %s for comparison.\n", __FILE__, __LINE__, tmpfile);
106 if(fread(arr_org, sizeof(char), len_org, fp_org) != len_org)
107 fprintf(stderr, "%s:%d, error reading file %s for comparison.\n", __FILE__, __LINE__, orgfile);
112 cmp= memcmp(arr_new, arr_org, len_new);
132 static int cmp_struct(const void *a, const void *b)
134 const StructRNA *structa= *(const StructRNA**)a;
135 const StructRNA *structb= *(const StructRNA**)b;
137 return strcmp(structa->identifier, structb->identifier);
140 static int cmp_property(const void *a, const void *b)
142 const PropertyRNA *propa= *(const PropertyRNA**)a;
143 const PropertyRNA *propb= *(const PropertyRNA**)b;
145 if(strcmp(propa->identifier, "rna_type") == 0) return -1;
146 else if(strcmp(propb->identifier, "rna_type") == 0) return 1;
148 if(strcmp(propa->identifier, "name") == 0) return -1;
149 else if(strcmp(propb->identifier, "name") == 0) return 1;
151 return strcmp(propa->name, propb->name);
154 static int cmp_def_struct(const void *a, const void *b)
156 const StructDefRNA *dsa= *(const StructDefRNA**)a;
157 const StructDefRNA *dsb= *(const StructDefRNA**)b;
159 return cmp_struct(&dsa->srna, &dsb->srna);
162 static int cmp_def_property(const void *a, const void *b)
164 const PropertyDefRNA *dpa= *(const PropertyDefRNA**)a;
165 const PropertyDefRNA *dpb= *(const PropertyDefRNA**)b;
167 return cmp_property(&dpa->prop, &dpb->prop);
170 static void rna_sortlist(ListBase *listbase, int(*cmp)(const void*, const void*))
176 if(listbase->first == listbase->last)
179 for(size=0, link=listbase->first; link; link=link->next)
182 array= MEM_mallocN(sizeof(void*)*size, "rna_sortlist");
183 for(a=0, link=listbase->first; link; link=link->next, a++)
186 qsort(array, size, sizeof(void*), cmp);
188 listbase->first= listbase->last= NULL;
189 for(a=0; a<size; a++) {
191 link->next= link->prev= NULL;
192 rna_addtail(listbase, link);
200 static void rna_print_c_string(FILE *f, const char *str)
202 static char *escape[] = {"\''", "\"\"", "\??", "\\\\","\aa", "\bb", "\ff", "\nn", "\rr", "\tt", "\vv", NULL};
211 for(i=0; str[i]; i++) {
212 for(j=0; escape[j]; j++)
213 if(str[i] == escape[j][0])
216 if(escape[j]) fprintf(f, "\\%c", escape[j][1]);
217 else fprintf(f, "%c", str[i]);
222 static void rna_print_data_get(FILE *f, PropertyDefRNA *dp)
224 if(dp->dnastructfromname && dp->dnastructfromprop)
225 fprintf(f, " %s *data= (%s*)(((%s*)ptr->data)->%s);\n", dp->dnastructname, dp->dnastructname, dp->dnastructfromname, dp->dnastructfromprop);
227 fprintf(f, " %s *data= (%s*)(ptr->data);\n", dp->dnastructname, dp->dnastructname);
230 static void rna_print_id_get(FILE *f, PropertyDefRNA *dp)
232 fprintf(f, " ID *id= ptr->id.data;\n");
235 static char *rna_alloc_function_name(const char *structname, const char *propname, const char *type)
241 snprintf(buffer, sizeof(buffer), "%s_%s_%s", structname, propname, type);
242 result= MEM_callocN(sizeof(char)*strlen(buffer)+1, "rna_alloc_function_name");
243 strcpy(result, buffer);
245 alloc= MEM_callocN(sizeof(AllocDefRNA), "AllocDefRNA");
247 rna_addtail(&DefRNA.allocs, alloc);
252 static StructRNA *rna_find_struct(const char *identifier)
256 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next)
257 if(strcmp(ds->srna->identifier, identifier)==0)
263 static const char *rna_find_type(const char *type)
267 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next)
268 if(ds->dnaname && strcmp(ds->dnaname, type)==0)
269 return ds->srna->identifier;
274 static const char *rna_find_dna_type(const char *type)
278 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next)
279 if(strcmp(ds->srna->identifier, type)==0)
285 static const char *rna_type_type_name(PropertyRNA *prop)
301 static const char *rna_type_type(PropertyRNA *prop)
305 type= rna_type_type_name(prop);
313 static const char *rna_type_struct(PropertyRNA *prop)
317 type= rna_type_type_name(prop);
325 static const char *rna_parameter_type_name(PropertyRNA *parm)
329 type= rna_type_type_name(parm);
336 PointerPropertyRNA *pparm= (PointerPropertyRNA*)parm;
338 if(parm->flag & PROP_RNAPTR)
341 return rna_find_dna_type((const char *)pparm->type);
343 case PROP_COLLECTION: {
347 return "<error, no type specified>";
351 static int rna_enum_bitmask(PropertyRNA *prop)
353 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
357 for(a=0; a<eprop->totitem; a++)
358 if(eprop->item[a].identifier[0])
359 mask |= eprop->item[a].value;
365 static int rna_color_quantize(PropertyRNA *prop, PropertyDefRNA *dp)
367 if(prop->type == PROP_FLOAT && prop->subtype == PROP_COLOR)
368 if(strcmp(dp->dnatype, "float") != 0 && strcmp(dp->dnatype, "double") != 0)
374 static const char *rna_function_string(void *func)
376 return (func)? (const char*)func: "NULL";
379 static void rna_float_print(FILE *f, float num)
381 if(num == -FLT_MAX) fprintf(f, "-FLT_MAX");
382 else if(num == FLT_MAX) fprintf(f, "FLT_MAX");
383 else if((int)num == num) fprintf(f, "%.1ff", num);
384 else fprintf(f, "%.10ff", num);
387 static void rna_int_print(FILE *f, int num)
389 if(num == INT_MIN) fprintf(f, "INT_MIN");
390 else if(num == INT_MAX) fprintf(f, "INT_MAX");
391 else fprintf(f, "%d", num);
394 static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
398 if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL)
402 if(!dp->dnastructname || !dp->dnaname) {
403 fprintf(stderr, "rna_def_property_get_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier);
409 func= rna_alloc_function_name(srna->identifier, prop->identifier, "get");
413 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
414 fprintf(f, "void %s(PointerRNA *ptr, char *value)\n", func);
417 fprintf(f, " %s(ptr, value);\n", manualfunc);
420 rna_print_data_get(f, dp);
422 fprintf(f, " BLI_strncpy(value, data->%s, %d);\n", dp->dnaname, sprop->maxlength);
424 fprintf(f, " BLI_strncpy(value, data->%s, sizeof(data->%s));\n", dp->dnaname, dp->dnaname);
430 fprintf(f, "PointerRNA %s(PointerRNA *ptr)\n", func);
433 fprintf(f, " return %s(ptr);\n", manualfunc);
436 PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
437 rna_print_data_get(f, dp);
438 if(dp->dnapointerlevel == 0)
439 fprintf(f, " return rna_pointer_inherit_refine(ptr, &RNA_%s, &data->%s);\n", (char*)pprop->type, dp->dnaname);
441 fprintf(f, " return rna_pointer_inherit_refine(ptr, &RNA_%s, data->%s);\n", (char*)pprop->type, dp->dnaname);
446 case PROP_COLLECTION: {
447 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
449 fprintf(f, "static PointerRNA %s(CollectionPropertyIterator *iter)\n", func);
452 if(strcmp(manualfunc, "rna_iterator_listbase_get") == 0 ||
453 strcmp(manualfunc, "rna_iterator_array_get") == 0 ||
454 strcmp(manualfunc, "rna_iterator_array_dereference_get") == 0)
455 fprintf(f, " return rna_pointer_inherit_refine(&iter->parent, &RNA_%s, %s(iter));\n", (cprop->item_type)? (char*)cprop->item_type: "UnknownType", manualfunc);
457 fprintf(f, " return %s(iter);\n", manualfunc);
463 if(prop->arraydimension) {
464 if(prop->flag & PROP_DYNAMIC)
465 fprintf(f, "void %s(PointerRNA *ptr, %s values[])\n", func, rna_type_type(prop));
467 fprintf(f, "void %s(PointerRNA *ptr, %s values[%d])\n", func, rna_type_type(prop), prop->totarraylength);
471 fprintf(f, " %s(ptr, values);\n", manualfunc);
474 rna_print_data_get(f, dp);
476 if(prop->flag & PROP_DYNAMIC) {
477 char *lenfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "get_length");
478 fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
479 fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc);
480 fprintf(f, " for(i=0; i<len; i++) {\n");
484 fprintf(f, " int i;\n\n");
485 fprintf(f, " for(i=0; i<%d; i++) {\n", prop->totarraylength);
488 if(dp->dnaarraylength == 1) {
489 if(prop->type == PROP_BOOLEAN && dp->booleanbit)
490 fprintf(f, " values[i]= %s((data->%s & (%d<<i)) != 0);\n", (dp->booleannegative)? "!": "", dp->dnaname, dp->booleanbit);
492 fprintf(f, " values[i]= (%s)%s((&data->%s)[i]);\n", rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnaname);
495 if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
496 fprintf(f, " values[i]= %s((data->%s[i] & ", (dp->booleannegative)? "!": "", dp->dnaname);
497 rna_int_print(f, dp->booleanbit);
498 fprintf(f, ") != 0);\n");
500 else if(rna_color_quantize(prop, dp))
501 fprintf(f, " values[i]= (%s)(data->%s[i]*(1.0f/255.0f));\n", rna_type_type(prop), dp->dnaname);
503 fprintf(f, " values[i]= (%s)%s(((%s*)data->%s)[i]);\n", rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnatype, dp->dnaname);
505 fprintf(f, " values[i]= (%s)%s((data->%s)[i]);\n", rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnaname);
512 fprintf(f, "%s %s(PointerRNA *ptr)\n", rna_type_type(prop), func);
516 fprintf(f, " return %s(ptr);\n", manualfunc);
519 rna_print_data_get(f, dp);
520 if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
521 fprintf(f, " return %s(((data->%s) & ", (dp->booleannegative)? "!": "", dp->dnaname);
522 rna_int_print(f, dp->booleanbit);
523 fprintf(f, ") != 0);\n");
525 else if(prop->type == PROP_ENUM && dp->enumbitflags) {
526 fprintf(f, " return ((data->%s) & ", dp->dnaname);
527 rna_int_print(f, rna_enum_bitmask(prop));
531 fprintf(f, " return (%s)%s(data->%s);\n", rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnaname);
542 static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array)
544 if(prop->type == PROP_INT) {
545 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
547 if(iprop->hardmin != INT_MIN || iprop->hardmax != INT_MAX) {
548 if(array) fprintf(f, "CLAMPIS(values[i], ");
549 else fprintf(f, "CLAMPIS(value, ");
550 rna_int_print(f, iprop->hardmin); fprintf(f, ", ");
551 rna_int_print(f, iprop->hardmax); fprintf(f, ");\n");
555 else if(prop->type == PROP_FLOAT) {
556 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
558 if(fprop->hardmin != -FLT_MAX || fprop->hardmax != FLT_MAX) {
559 if(array) fprintf(f, "CLAMPIS(values[i], ");
560 else fprintf(f, "CLAMPIS(value, ");
561 rna_float_print(f, fprop->hardmin); fprintf(f, ", ");
562 rna_float_print(f, fprop->hardmax); fprintf(f, ");\n");
568 fprintf(f, "values[i];\n");
570 fprintf(f, "value;\n");
573 static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc)
577 if(!(prop->flag & PROP_EDITABLE))
579 if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL)
583 if(!dp->dnastructname || !dp->dnaname) {
584 if(prop->flag & PROP_EDITABLE) {
585 fprintf(stderr, "rna_def_property_set_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier);
592 func= rna_alloc_function_name(srna->identifier, prop->identifier, "set");
596 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
597 fprintf(f, "void %s(PointerRNA *ptr, const char *value)\n", func);
600 fprintf(f, " %s(ptr, value);\n", manualfunc);
603 rna_print_data_get(f, dp);
605 fprintf(f, " BLI_strncpy(data->%s, value, %d);\n", dp->dnaname, sprop->maxlength);
607 fprintf(f, " BLI_strncpy(data->%s, value, sizeof(data->%s));\n", dp->dnaname, dp->dnaname);
613 fprintf(f, "void %s(PointerRNA *ptr, PointerRNA value)\n", func);
616 fprintf(f, " %s(ptr, value);\n", manualfunc);
619 rna_print_data_get(f, dp);
621 if(prop->flag & PROP_ID_SELF_CHECK) {
622 rna_print_id_get(f, dp);
623 fprintf(f, " if(id==value.data) return;\n\n");
626 if(prop->flag & PROP_ID_REFCOUNT) {
627 fprintf(f, "\n if(data->%s)\n", dp->dnaname);
628 fprintf(f, " id_us_min((ID*)data->%s);\n", dp->dnaname);
629 fprintf(f, " if(value.data)\n");
630 fprintf(f, " id_us_plus((ID*)value.data);\n\n");
633 PointerPropertyRNA *pprop= (PointerPropertyRNA*)dp->prop;
634 StructRNA *type= rna_find_struct((char*)pprop->type);
635 if(type && (type->flag & STRUCT_ID)) {
636 fprintf(f, " if(value.data)\n");
637 fprintf(f, " id_lib_extern((ID*)value.data);\n\n");
641 fprintf(f, " data->%s= value.data;\n", dp->dnaname);
648 if(prop->arraydimension) {
649 if(prop->flag & PROP_DYNAMIC)
650 fprintf(f, "void %s(PointerRNA *ptr, const %s values[])\n", func, rna_type_type(prop));
652 fprintf(f, "void %s(PointerRNA *ptr, const %s values[%d])\n", func, rna_type_type(prop), prop->totarraylength);
656 fprintf(f, " %s(ptr, values);\n", manualfunc);
659 rna_print_data_get(f, dp);
661 if(prop->flag & PROP_DYNAMIC) {
662 char *lenfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "set_length");
663 fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
664 fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc);
665 fprintf(f, " for(i=0; i<len; i++) {\n");
669 fprintf(f, " int i;\n\n");
670 fprintf(f, " for(i=0; i<%d; i++) {\n", prop->totarraylength);
673 if(dp->dnaarraylength == 1) {
674 if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
675 fprintf(f, " if(%svalues[i]) data->%s |= (%d<<i);\n", (dp->booleannegative)? "!": "", dp->dnaname, dp->booleanbit);
676 fprintf(f, " else data->%s &= ~(%d<<i);\n", dp->dnaname, dp->booleanbit);
679 fprintf(f, " (&data->%s)[i]= %s", dp->dnaname, (dp->booleannegative)? "!": "");
680 rna_clamp_value(f, prop, 1);
684 if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
685 fprintf(f, " if(%svalues[i]) data->%s[i] |= ", (dp->booleannegative)? "!": "", dp->dnaname);
686 rna_int_print(f, dp->booleanbit);
688 fprintf(f, " else data->%s[i] &= ~", dp->dnaname);
689 rna_int_print(f, dp->booleanbit);
692 else if(rna_color_quantize(prop, dp)) {
693 fprintf(f, " data->%s[i]= FTOCHAR(values[i]);\n", dp->dnaname);
697 fprintf(f, " ((%s*)data->%s)[i]= %s", dp->dnatype, dp->dnaname, (dp->booleannegative)? "!": "");
699 fprintf(f, " (data->%s)[i]= %s", dp->dnaname, (dp->booleannegative)? "!": "");
700 rna_clamp_value(f, prop, 1);
708 fprintf(f, "void %s(PointerRNA *ptr, %s value)\n", func, rna_type_type(prop));
712 fprintf(f, " %s(ptr, value);\n", manualfunc);
715 rna_print_data_get(f, dp);
716 if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
717 fprintf(f, " if(%svalue) data->%s |= ", (dp->booleannegative)? "!": "", dp->dnaname);
718 rna_int_print(f, dp->booleanbit);
720 fprintf(f, " else data->%s &= ~", dp->dnaname);
721 rna_int_print(f, dp->booleanbit);
724 else if(prop->type == PROP_ENUM && dp->enumbitflags) {
725 fprintf(f, " data->%s &= ~", dp->dnaname);
726 rna_int_print(f, rna_enum_bitmask(prop));
728 fprintf(f, " data->%s |= value;\n", dp->dnaname);
731 fprintf(f, " data->%s= %s", dp->dnaname, (dp->booleannegative)? "!": "");
732 rna_clamp_value(f, prop, 0);
743 static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc)
747 if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL)
750 if(prop->type == PROP_STRING) {
752 if(!dp->dnastructname || !dp->dnaname) {
753 fprintf(stderr, "rna_def_property_length_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier);
759 func= rna_alloc_function_name(srna->identifier, prop->identifier, "length");
761 fprintf(f, "int %s(PointerRNA *ptr)\n", func);
764 fprintf(f, " return %s(ptr);\n", manualfunc);
767 rna_print_data_get(f, dp);
768 fprintf(f, " return strlen(data->%s);\n", dp->dnaname);
772 else if(prop->type == PROP_COLLECTION) {
774 if(prop->type == PROP_COLLECTION && (!(dp->dnalengthname || dp->dnalengthfixed)|| !dp->dnaname)) {
775 fprintf(stderr, "rna_def_property_length_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier);
781 func= rna_alloc_function_name(srna->identifier, prop->identifier, "length");
783 fprintf(f, "int %s(PointerRNA *ptr)\n", func);
786 fprintf(f, " return %s(ptr);\n", manualfunc);
789 rna_print_data_get(f, dp);
790 if(dp->dnalengthname)
791 fprintf(f, " return (data->%s == NULL)? 0: data->%s;\n", dp->dnaname, dp->dnalengthname);
793 fprintf(f, " return (data->%s == NULL)? 0: %d;\n", dp->dnaname, dp->dnalengthfixed);
801 static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc)
803 char *func, *getfunc;
805 if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL)
809 if(!dp->dnastructname || !dp->dnaname) {
810 fprintf(stderr, "rna_def_property_begin_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier);
816 func= rna_alloc_function_name(srna->identifier, prop->identifier, "begin");
818 fprintf(f, "void %s(CollectionPropertyIterator *iter, PointerRNA *ptr)\n", func);
822 rna_print_data_get(f, dp);
824 fprintf(f, "\n memset(iter, 0, sizeof(*iter));\n");
825 fprintf(f, " iter->parent= *ptr;\n");
826 fprintf(f, " iter->prop= (PropertyRNA*)&rna_%s_%s;\n", srna->identifier, prop->identifier);
828 if(dp->dnalengthname || dp->dnalengthfixed) {
830 fprintf(f, "\n %s(iter, ptr);\n", manualfunc);
833 if(dp->dnalengthname)
834 fprintf(f, "\n rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), data->%s, 0, NULL);\n", dp->dnaname, dp->dnaname, dp->dnalengthname);
836 fprintf(f, "\n rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), %d, 0, NULL);\n", dp->dnaname, dp->dnaname, dp->dnalengthfixed);
841 fprintf(f, "\n %s(iter, ptr);\n", manualfunc);
842 else if(dp->dnapointerlevel == 0)
843 fprintf(f, "\n rna_iterator_listbase_begin(iter, &data->%s, NULL);\n", dp->dnaname);
845 fprintf(f, "\n rna_iterator_listbase_begin(iter, data->%s, NULL);\n", dp->dnaname);
848 getfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "get");
850 fprintf(f, "\n if(iter->valid)\n");
851 fprintf(f, " iter->ptr= %s(iter);\n", getfunc);
859 static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc, char *nextfunc)
863 if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL)
867 if(!dp->dnastructname || !dp->dnaname)
870 /* only supported in case of standard next functions */
871 if(strcmp(nextfunc, "rna_iterator_array_next") == 0);
872 else if(strcmp(nextfunc, "rna_iterator_listbase_next") == 0);
876 func= rna_alloc_function_name(srna->identifier, prop->identifier, "lookup_int");
878 fprintf(f, "PointerRNA %s(PointerRNA *ptr, int index)\n", func);
882 fprintf(f, "\n return %s(ptr, index);\n", manualfunc);
887 fprintf(f, " PointerRNA r_ptr;\n");
888 fprintf(f, " CollectionPropertyIterator iter;\n\n");
890 fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, prop->identifier);
893 if(strcmp(nextfunc, "rna_iterator_array_next") == 0) {
894 fprintf(f, " ArrayIterator *internal= iter.internal;\n");
895 fprintf(f, " if(internal->skip) {\n");
896 fprintf(f, " while(index-- > 0) {\n");
897 fprintf(f, " do {\n");
898 fprintf(f, " internal->ptr += internal->itemsize;\n");
899 fprintf(f, " } while(internal->skip(&iter, internal->ptr));\n");
902 fprintf(f, " else {\n");
903 fprintf(f, " internal->ptr += internal->itemsize*index;\n");
906 else if(strcmp(nextfunc, "rna_iterator_listbase_next") == 0) {
907 fprintf(f, " ListBaseIterator *internal= iter.internal;\n");
908 fprintf(f, " if(internal->skip) {\n");
909 fprintf(f, " while(index-- > 0) {\n");
910 fprintf(f, " do {\n");
911 fprintf(f, " internal->link= internal->link->next;\n");
912 fprintf(f, " } while(internal->skip(&iter, internal->link));\n");
915 fprintf(f, " else {\n");
916 fprintf(f, " while(index-- > 0)\n");
917 fprintf(f, " internal->link= internal->link->next;\n");
921 fprintf(f, " }\n\n");
923 fprintf(f, " r_ptr = %s_%s_get(&iter);\n", srna->identifier, prop->identifier);
924 fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, prop->identifier);
926 fprintf(f, " return r_ptr;\n");
929 rna_print_data_get(f, dp);
930 item_type= (cprop->item_type)? (char*)cprop->item_type: "UnknownType";
932 if(dp->dnalengthname || dp->dnalengthfixed) {
933 if(dp->dnalengthname)
934 fprintf(f, "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), data->%s, index);\n", item_type, dp->dnaname, dp->dnaname, dp->dnalengthname);
936 fprintf(f, "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), %d, index);\n", item_type, dp->dnaname, dp->dnaname, dp->dnalengthfixed);
939 if(dp->dnapointerlevel == 0)
940 fprintf(f, "\n return rna_listbase_lookup_int(ptr, &RNA_%s, &data->%s, index);\n", item_type, dp->dnaname);
942 fprintf(f, "\n return rna_listbase_lookup_int(ptr, &RNA_%s, data->%s, index);\n", item_type, dp->dnaname);
951 static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc)
953 char *func, *getfunc;
955 if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL)
961 func= rna_alloc_function_name(srna->identifier, prop->identifier, "next");
963 fprintf(f, "void %s(CollectionPropertyIterator *iter)\n", func);
965 fprintf(f, " %s(iter);\n", manualfunc);
967 getfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "get");
969 fprintf(f, "\n if(iter->valid)\n");
970 fprintf(f, " iter->ptr= %s(iter);\n", getfunc);
977 static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc)
981 if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL)
984 func= rna_alloc_function_name(srna->identifier, prop->identifier, "end");
986 fprintf(f, "void %s(CollectionPropertyIterator *iter)\n", func);
989 fprintf(f, " %s(iter);\n", manualfunc);
995 static void rna_set_raw_property(PropertyDefRNA *dp, PropertyRNA *prop)
997 if(dp->dnapointerlevel != 0)
999 if(!dp->dnatype || !dp->dnaname || !dp->dnastructname)
1002 if(strcmp(dp->dnatype, "char") == 0) {
1003 prop->rawtype= PROP_RAW_CHAR;
1004 prop->flag |= PROP_RAW_ACCESS;
1006 else if(strcmp(dp->dnatype, "short") == 0) {
1007 prop->rawtype= PROP_RAW_SHORT;
1008 prop->flag |= PROP_RAW_ACCESS;
1010 else if(strcmp(dp->dnatype, "int") == 0) {
1011 prop->rawtype= PROP_RAW_INT;
1012 prop->flag |= PROP_RAW_ACCESS;
1014 else if(strcmp(dp->dnatype, "float") == 0) {
1015 prop->rawtype= PROP_RAW_FLOAT;
1016 prop->flag |= PROP_RAW_ACCESS;
1018 else if(strcmp(dp->dnatype, "double") == 0) {
1019 prop->rawtype= PROP_RAW_DOUBLE;
1020 prop->flag |= PROP_RAW_ACCESS;
1024 static void rna_set_raw_offset(FILE *f, StructRNA *srna, PropertyRNA *prop)
1026 PropertyDefRNA *dp= rna_find_struct_property_def(srna, prop);
1028 fprintf(f, "\toffsetof(%s, %s), %d", dp->dnastructname, dp->dnaname, prop->rawtype);
1031 static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
1037 switch(prop->type) {
1038 case PROP_BOOLEAN: {
1039 BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
1041 if(!prop->arraydimension) {
1042 if(!bprop->get && !bprop->set && !dp->booleanbit)
1043 rna_set_raw_property(dp, prop);
1045 bprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)bprop->get);
1046 bprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)bprop->set);
1049 bprop->getarray= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)bprop->getarray);
1050 bprop->setarray= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)bprop->setarray);
1055 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
1057 if(!prop->arraydimension) {
1058 if(!iprop->get && !iprop->set)
1059 rna_set_raw_property(dp, prop);
1061 iprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)iprop->get);
1062 iprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)iprop->set);
1065 if(!iprop->getarray && !iprop->setarray)
1066 rna_set_raw_property(dp, prop);
1068 iprop->getarray= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)iprop->getarray);
1069 iprop->setarray= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)iprop->setarray);
1074 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
1076 if(!prop->arraydimension) {
1077 if(!fprop->get && !fprop->set)
1078 rna_set_raw_property(dp, prop);
1080 fprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)fprop->get);
1081 fprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)fprop->set);
1084 if(!fprop->getarray && !fprop->setarray)
1085 rna_set_raw_property(dp, prop);
1087 fprop->getarray= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)fprop->getarray);
1088 fprop->setarray= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)fprop->setarray);
1093 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
1095 eprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)eprop->get);
1096 eprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)eprop->set);
1100 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
1102 sprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)sprop->get);
1103 sprop->length= (void*)rna_def_property_length_func(f, srna, prop, dp, (char*)sprop->length);
1104 sprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)sprop->set);
1107 case PROP_POINTER: {
1108 PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
1110 pprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)pprop->get);
1111 pprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)pprop->set);
1113 fprintf(stderr, "rna_def_property_funcs: %s.%s, pointer must have a struct type.\n", srna->identifier, prop->identifier);
1118 case PROP_COLLECTION: {
1119 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
1120 char *nextfunc= (char*)cprop->next;
1122 if(dp->dnatype && strcmp(dp->dnatype, "ListBase")==0);
1123 else if(dp->dnalengthname || dp->dnalengthfixed)
1124 cprop->length= (void*)rna_def_property_length_func(f, srna, prop, dp, (char*)cprop->length);
1126 /* test if we can allow raw array access, if it is using our standard
1127 * array get/next function, we can be sure it is an actual array */
1128 if(cprop->next && cprop->get)
1129 if(strcmp((char*)cprop->next, "rna_iterator_array_next") == 0 &&
1130 strcmp((char*)cprop->get, "rna_iterator_array_get") == 0)
1131 prop->flag |= PROP_RAW_ARRAY;
1133 cprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)cprop->get);
1134 cprop->begin= (void*)rna_def_property_begin_func(f, srna, prop, dp, (char*)cprop->begin);
1135 cprop->next= (void*)rna_def_property_next_func(f, srna, prop, dp, (char*)cprop->next);
1136 cprop->end= (void*)rna_def_property_end_func(f, srna, prop, dp, (char*)cprop->end);
1137 cprop->lookupint= (void*)rna_def_property_lookup_int_func(f, srna, prop, dp, (char*)cprop->lookupint, nextfunc);
1139 if(!(prop->flag & PROP_IDPROPERTY)) {
1141 fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a begin function.\n", srna->identifier, prop->identifier);
1145 fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a next function.\n", srna->identifier, prop->identifier);
1149 fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a get function.\n", srna->identifier, prop->identifier);
1153 if(!cprop->item_type) {
1154 fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a struct type.\n", srna->identifier, prop->identifier);
1162 static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
1169 if(prop->flag & (PROP_IDPROPERTY|PROP_BUILTIN))
1172 func= rna_alloc_function_name(srna->identifier, prop->identifier, "");
1174 switch(prop->type) {
1177 if(!prop->arraydimension) {
1178 fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
1179 //fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
1182 fprintf(f, "void %sget(PointerRNA *ptr, int values[%d]);\n", func, prop->totarraylength);
1183 //fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->arraylength);
1188 if(!prop->arraydimension) {
1189 fprintf(f, "float %sget(PointerRNA *ptr);\n", func);
1190 //fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func);
1193 fprintf(f, "void %sget(PointerRNA *ptr, float values[%d]);\n", func, prop->totarraylength);
1194 //fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->arraylength);
1199 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
1203 fprintf(f, "enum {\n");
1205 for(i=0; i<eprop->totitem; i++)
1206 if(eprop->item[i].identifier[0])
1207 fprintf(f, "\t%s_%s_%s = %d,\n", srna->identifier, prop->identifier, eprop->item[i].identifier, eprop->item[i].value);
1209 fprintf(f, "};\n\n");
1212 fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
1213 //fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
1218 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
1220 if(sprop->maxlength) {
1221 fprintf(f, "#define %s_%s_MAX %d\n\n", srna->identifier, prop->identifier, sprop->maxlength);
1224 fprintf(f, "void %sget(PointerRNA *ptr, char *value);\n", func);
1225 fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
1226 //fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func);
1230 case PROP_POINTER: {
1231 fprintf(f, "PointerRNA %sget(PointerRNA *ptr);\n", func);
1232 //fprintf(f, "void %sset(PointerRNA *ptr, PointerRNA value);\n", func);
1235 case PROP_COLLECTION: {
1236 fprintf(f, "void %sbegin(CollectionPropertyIterator *iter, PointerRNA *ptr);\n", func);
1237 fprintf(f, "void %snext(CollectionPropertyIterator *iter);\n", func);
1238 fprintf(f, "void %send(CollectionPropertyIterator *iter);\n", func);
1239 //fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
1240 //fprintf(f, "void %slookup_int(PointerRNA *ptr, int key, StructRNA **type);\n", func);
1241 //fprintf(f, "void %slookup_string(PointerRNA *ptr, const char *key, StructRNA **type);\n", func);
1249 static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
1255 if(prop->flag & (PROP_IDPROPERTY|PROP_BUILTIN))
1258 if(prop->name && prop->description && strcmp(prop->description, "") != 0)
1259 fprintf(f, "\t/* %s: %s */\n", prop->name, prop->description);
1261 fprintf(f, "\t/* %s */\n", prop->name);
1263 fprintf(f, "\t/* */\n");
1265 switch(prop->type) {
1266 case PROP_BOOLEAN: {
1267 if(!prop->arraydimension)
1268 fprintf(f, "\tbool %s(void);", prop->identifier);
1270 fprintf(f, "\tArray<int, %d> %s(void);", prop->totarraylength, prop->identifier);
1274 if(!prop->arraydimension)
1275 fprintf(f, "\tint %s(void);", prop->identifier);
1277 fprintf(f, "\tArray<int, %d> %s(void);", prop->totarraylength, prop->identifier);
1281 if(!prop->arraydimension)
1282 fprintf(f, "\tfloat %s(void);", prop->identifier);
1284 fprintf(f, "\tArray<float, %d> %s(void);", prop->totarraylength, prop->identifier);
1288 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
1292 fprintf(f, "\tenum %s_enum {\n", prop->identifier);
1294 for(i=0; i<eprop->totitem; i++)
1295 if(eprop->item[i].identifier[0])
1296 fprintf(f, "\t\t%s_%s = %d,\n", prop->identifier, eprop->item[i].identifier, eprop->item[i].value);
1298 fprintf(f, "\t};\n");
1301 fprintf(f, "\t%s_enum %s(void);", prop->identifier, prop->identifier);
1305 fprintf(f, "\tstd::string %s(void);", prop->identifier);
1308 case PROP_POINTER: {
1309 PointerPropertyRNA *pprop= (PointerPropertyRNA*)dp->prop;
1312 fprintf(f, "\t%s %s(void);", (char*)pprop->type, prop->identifier);
1314 fprintf(f, "\t%s %s(void);", "UnknownType", prop->identifier);
1317 case PROP_COLLECTION: {
1318 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)dp->prop;
1320 if(cprop->item_type)
1321 fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (char*)cprop->item_type, srna->identifier, prop->identifier);
1323 fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, prop->identifier);
1331 static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
1337 if(prop->flag & (PROP_IDPROPERTY|PROP_BUILTIN))
1340 switch(prop->type) {
1341 case PROP_BOOLEAN: {
1342 if(!prop->arraydimension)
1343 fprintf(f, "\tBOOLEAN_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
1345 fprintf(f, "\tBOOLEAN_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, prop->identifier);
1349 if(!prop->arraydimension)
1350 fprintf(f, "\tINT_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
1352 fprintf(f, "\tINT_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, prop->identifier);
1356 if(!prop->arraydimension)
1357 fprintf(f, "\tFLOAT_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
1359 fprintf(f, "\tFLOAT_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, prop->identifier);
1363 fprintf(f, "\tENUM_PROPERTY(%s_enum, %s, %s)", prop->identifier, srna->identifier, prop->identifier);
1368 fprintf(f, "\tSTRING_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
1371 case PROP_POINTER: {
1372 PointerPropertyRNA *pprop= (PointerPropertyRNA*)dp->prop;
1375 fprintf(f, "\tPOINTER_PROPERTY(%s, %s, %s)", (char*)pprop->type, srna->identifier, prop->identifier);
1377 fprintf(f, "\tPOINTER_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, prop->identifier);
1380 case PROP_COLLECTION: {
1381 /*CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)dp->prop;
1384 fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (char*)cprop->type, srna->identifier, prop->identifier);
1386 fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, prop->identifier);*/
1394 static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc)
1398 PropertyDefRNA *dparm;
1400 char *funcname, *ptrstr, *valstr;
1401 int flag, pout, cptr, first;
1409 funcname= rna_alloc_function_name(srna->identifier, func->identifier, "call");
1411 /* function definition */
1412 fprintf(f, "void %s(bContext *C, ReportList *reports, PointerRNA *_ptr, ParameterList *_parms)", funcname);
1413 fprintf(f, "\n{\n");
1415 /* variable definitions */
1417 if(func->flag & FUNC_USE_SELF_ID) {
1418 fprintf(f, "\tstruct ID *_selfid;\n");
1421 if((func->flag & FUNC_NO_SELF)==0) {
1422 if(dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
1423 else fprintf(f, "\tstruct %s *_self;\n", srna->identifier);
1426 dparm= dfunc->cont.properties.first;
1427 for(; dparm; dparm= dparm->next) {
1428 type = dparm->prop->type;
1429 flag = dparm->prop->flag;
1430 pout = (flag & PROP_OUTPUT);
1431 cptr = ((type == PROP_POINTER) && !(flag & PROP_RNAPTR));
1433 if(dparm->prop==func->c_ret)
1434 ptrstr= cptr || dparm->prop->arraydimension ? "*" : "";
1435 /* XXX only arrays and strings are allowed to be dynamic, is this checked anywhere? */
1436 else if (cptr || (flag & PROP_DYNAMIC))
1437 ptrstr= pout ? "**" : "*";
1438 /* fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack, pass a pointer to it */
1439 else if (type == PROP_POINTER || dparm->prop->arraydimension)
1441 /* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack, but type name for string props is already char*, so leave empty */
1442 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
1445 ptrstr= pout ? "*" : "";
1447 /* for dynamic parameters we pass an additional int for the length of the parameter */
1448 if (flag & PROP_DYNAMIC)
1449 fprintf(f, "\tint %s%s_len;\n", pout ? "*" : "", dparm->prop->identifier);
1451 fprintf(f, "\t%s%s %s%s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, dparm->prop->identifier);
1454 fprintf(f, "\tchar *_data");
1455 if(func->c_ret) fprintf(f, ", *_retdata");
1460 if(func->flag & FUNC_USE_SELF_ID) {
1461 fprintf(f, "\t_selfid= (struct ID*)_ptr->id.data;\n");
1464 if((func->flag & FUNC_NO_SELF)==0) {
1465 if(dsrna->dnaname) fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", dsrna->dnaname);
1466 else fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", srna->identifier);
1469 fprintf(f, "\t_data= (char *)_parms->data;\n");
1471 dparm= dfunc->cont.properties.first;
1472 for(; dparm; dparm= dparm->next) {
1473 type = dparm->prop->type;
1474 flag = dparm->prop->flag;
1475 pout = (flag & PROP_OUTPUT);
1476 cptr = ((type == PROP_POINTER) && !(flag & PROP_RNAPTR));
1478 if(dparm->prop==func->c_ret)
1479 fprintf(f, "\t_retdata= _data;\n");
1482 if (cptr || (flag & PROP_DYNAMIC)) {
1486 else if (type == PROP_POINTER || dparm->prop->arraydimension) {
1490 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
1499 /* this must be kept in sync with RNA_parameter_length_get_data, we could just call the function directly, but this is faster */
1500 if (flag & PROP_DYNAMIC) {
1501 fprintf(f, "\t%s_len= %s((int *)_data);\n", dparm->prop->identifier, pout ? "" : "*");
1502 data_str= "(&(((char *)_data)[sizeof(void *)]))";
1507 fprintf(f, "\t%s= ", dparm->prop->identifier);
1510 fprintf(f, "%s", valstr);
1512 fprintf(f, "((%s%s%s)%s);\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, data_str);
1516 fprintf(f, "\t_data+= %d;\n", rna_parameter_size_alloc(dparm->prop));
1522 if(func->c_ret) fprintf(f, "%s= ", func->c_ret->identifier);
1523 fprintf(f, "%s(", dfunc->call);
1527 if(func->flag & FUNC_USE_SELF_ID) {
1528 fprintf(f, "_selfid");
1532 if((func->flag & FUNC_NO_SELF)==0) {
1533 if(!first) fprintf(f, ", ");
1534 fprintf(f, "_self");
1538 if(func->flag & FUNC_USE_CONTEXT) {
1539 if(!first) fprintf(f, ", ");
1544 if(func->flag & FUNC_USE_REPORTS) {
1545 if(!first) fprintf(f, ", ");
1547 fprintf(f, "reports");
1550 dparm= dfunc->cont.properties.first;
1551 for(; dparm; dparm= dparm->next) {
1552 if(dparm->prop==func->c_ret)
1555 if(!first) fprintf(f, ", ");
1558 if (dparm->prop->flag & PROP_DYNAMIC)
1559 fprintf(f, "%s_len, %s", dparm->prop->identifier, dparm->prop->identifier);
1561 fprintf(f, "%s", dparm->prop->identifier);
1567 dparm= rna_find_parameter_def(func->c_ret);
1568 ptrstr= (((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR)) || (dparm->prop->arraydimension))? "*": "";
1569 fprintf(f, "\t*((%s%s%s*)_retdata)= %s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, func->c_ret->identifier);
1573 fprintf(f, "}\n\n");
1575 dfunc->gencall= funcname;
1578 static void rna_auto_types()
1583 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next) {
1584 /* DNA name for Screen is patched in 2.5, we do the reverse here .. */
1585 if(ds->dnaname && strcmp(ds->dnaname, "Screen") == 0)
1586 ds->dnaname= "bScreen";
1588 for(dp=ds->cont.properties.first; dp; dp=dp->next) {
1589 if(dp->dnastructname && strcmp(dp->dnastructname, "Screen") == 0)
1590 dp->dnastructname= "bScreen";
1593 if(dp->prop->type == PROP_POINTER) {
1594 PointerPropertyRNA *pprop= (PointerPropertyRNA*)dp->prop;
1597 if(!pprop->type && !pprop->get)
1598 pprop->type= (StructRNA*)rna_find_type(dp->dnatype);
1601 type= rna_find_struct((char*)pprop->type);
1602 if(type && (type->flag & STRUCT_ID_REFCOUNT))
1603 pprop->property.flag |= PROP_ID_REFCOUNT;
1606 else if(dp->prop->type== PROP_COLLECTION) {
1607 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)dp->prop;
1609 if(!cprop->item_type && !cprop->get && strcmp(dp->dnatype, "ListBase")==0)
1610 cprop->item_type= (StructRNA*)rna_find_type(dp->dnatype);
1617 static void rna_sort(BlenderRNA *brna)
1622 rna_sortlist(&brna->structs, cmp_struct);
1623 rna_sortlist(&DefRNA.structs, cmp_def_struct);
1625 for(srna=brna->structs.first; srna; srna=srna->cont.next)
1626 rna_sortlist(&srna->cont.properties, cmp_property);
1628 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next)
1629 rna_sortlist(&ds->cont.properties, cmp_def_property);
1632 static const char *rna_property_structname(PropertyType type)
1635 case PROP_BOOLEAN: return "BooleanPropertyRNA";
1636 case PROP_INT: return "IntPropertyRNA";
1637 case PROP_FLOAT: return "FloatPropertyRNA";
1638 case PROP_STRING: return "StringPropertyRNA";
1639 case PROP_ENUM: return "EnumPropertyRNA";
1640 case PROP_POINTER: return "PointerPropertyRNA";
1641 case PROP_COLLECTION: return "CollectionPropertyRNA";
1642 default: return "UnknownPropertyRNA";
1646 static const char *rna_property_typename(PropertyType type)
1649 case PROP_BOOLEAN: return "PROP_BOOLEAN";
1650 case PROP_INT: return "PROP_INT";
1651 case PROP_FLOAT: return "PROP_FLOAT";
1652 case PROP_STRING: return "PROP_STRING";
1653 case PROP_ENUM: return "PROP_ENUM";
1654 case PROP_POINTER: return "PROP_POINTER";
1655 case PROP_COLLECTION: return "PROP_COLLECTION";
1656 default: return "PROP_UNKNOWN";
1660 static const char *rna_property_subtypename(PropertySubType type)
1663 case PROP_NONE: return "PROP_NONE";
1664 case PROP_FILEPATH: return "PROP_FILEPATH";
1665 case PROP_FILENAME: return "PROP_FILENAME";
1666 case PROP_DIRPATH: return "PROP_DIRPATH";
1667 case PROP_UNSIGNED: return "PROP_UNSIGNED";
1668 case PROP_PERCENTAGE: return "PROP_PERCENTAGE";
1669 case PROP_FACTOR: return "PROP_FACTOR";
1670 case PROP_ANGLE: return "PROP_ANGLE";
1671 case PROP_TIME: return "PROP_TIME";
1672 case PROP_DISTANCE: return "PROP_DISTANCE";
1673 case PROP_COLOR: return "PROP_COLOR";
1674 case PROP_TRANSLATION: return "PROP_TRANSLATION";
1675 case PROP_DIRECTION: return "PROP_DIRECTION";
1676 case PROP_MATRIX: return "PROP_MATRIX";
1677 case PROP_EULER: return "PROP_EULER";
1678 case PROP_QUATERNION: return "PROP_QUATERNION";
1679 case PROP_AXISANGLE: return "PROP_AXISANGLE";
1680 case PROP_VELOCITY: return "PROP_VELOCITY";
1681 case PROP_ACCELERATION: return "PROP_ACCELERATION";
1682 case PROP_XYZ: return "PROP_XYZ";
1683 case PROP_COLOR_GAMMA: return "PROP_COLOR_GAMMA";
1684 case PROP_LAYER: return "PROP_LAYER";
1685 case PROP_LAYER_MEMBER: return "PROP_LAYER_MEMBER";
1687 /* incase we dont have a type preset that includes the subtype */
1688 if(RNA_SUBTYPE_UNIT(type)) {
1689 return rna_property_subtypename(type & ~RNA_SUBTYPE_UNIT(type));
1692 return "PROP_SUBTYPE_UNKNOWN";
1698 static const char *rna_property_subtype_unit(PropertyType type)
1700 switch(RNA_SUBTYPE_UNIT(type)) {
1701 case PROP_UNIT_NONE: return "PROP_UNIT_NONE";
1702 case PROP_UNIT_LENGTH: return "PROP_UNIT_LENGTH";
1703 case PROP_UNIT_AREA: return "PROP_UNIT_AREA";
1704 case PROP_UNIT_VOLUME: return "PROP_UNIT_VOLUME";
1705 case PROP_UNIT_MASS: return "PROP_UNIT_MASS";
1706 case PROP_UNIT_ROTATION: return "PROP_UNIT_ROTATION";
1707 case PROP_UNIT_TIME: return "PROP_UNIT_TIME";
1708 case PROP_UNIT_VELOCITY: return "PROP_UNIT_VELOCITY";
1709 case PROP_UNIT_ACCELERATION:return "PROP_UNIT_ACCELERATION";
1710 default: return "PROP_UNIT_UNKNOWN";
1714 static void rna_generate_prototypes(BlenderRNA *brna, FILE *f)
1718 for(srna=brna->structs.first; srna; srna=srna->cont.next)
1719 fprintf(f, "extern StructRNA RNA_%s;\n", srna->identifier);
1723 static void rna_generate_blender(BlenderRNA *brna, FILE *f)
1727 fprintf(f, "BlenderRNA BLENDER_RNA = {");
1729 srna= brna->structs.first;
1730 if(srna) fprintf(f, "{&RNA_%s, ", srna->identifier);
1731 else fprintf(f, "{NULL, ");
1733 srna= brna->structs.last;
1734 if(srna) fprintf(f, "&RNA_%s}", srna->identifier);
1735 else fprintf(f, "NULL}");
1737 fprintf(f, "};\n\n");
1740 static void rna_generate_property_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f)
1748 for(prop=base->cont.properties.first; prop; prop=prop->next)
1749 fprintf(f, "%s%s rna_%s_%s;\n", "extern ", rna_property_structname(prop->type), base->identifier, prop->identifier);
1753 if(srna->cont.properties.first)
1756 for(prop=srna->cont.properties.first; prop; prop=prop->next)
1757 fprintf(f, "%s%s rna_%s_%s;\n", (prop->flag & PROP_EXPORT)? "": "", rna_property_structname(prop->type), srna->identifier, prop->identifier);
1761 static void rna_generate_parameter_prototypes(BlenderRNA *brna, StructRNA *srna, FunctionRNA *func, FILE *f)
1765 for(parm= func->cont.properties.first; parm; parm= parm->next)
1766 fprintf(f, "%s%s rna_%s_%s_%s;\n", "extern ", rna_property_structname(parm->type), srna->identifier, func->identifier, parm->identifier);
1768 if(func->cont.properties.first)
1772 static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f)
1779 for(func= base->functions.first; func; func= func->cont.next) {
1780 fprintf(f, "%s%s rna_%s_%s_func;\n", "extern ", "FunctionRNA", base->identifier, func->identifier);
1781 rna_generate_parameter_prototypes(brna, base, func, f);
1784 if(base->functions.first)
1790 for(func= srna->functions.first; func; func= func->cont.next) {
1791 fprintf(f, "%s%s rna_%s_%s_func;\n", "extern ", "FunctionRNA", srna->identifier, func->identifier);
1792 rna_generate_parameter_prototypes(brna, srna, func, f);
1795 if(srna->functions.first)
1799 static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA *srna, FunctionDefRNA *dfunc, FILE *f)
1802 PropertyDefRNA *dparm;
1803 StructDefRNA *dsrna;
1805 int flag, pout, cptr, first;
1808 dsrna= rna_find_struct_def(srna);
1812 for(dparm= dfunc->cont.properties.first; dparm; dparm= dparm->next) {
1813 if(dparm->prop==func->c_ret) {
1814 if(dparm->prop->arraydimension)
1815 fprintf(f, "XXX no array return types yet"); /* XXX not supported */
1816 else if(dparm->prop->type == PROP_POINTER && !(dparm->prop->flag & PROP_RNAPTR))
1817 fprintf(f, "%s%s *", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
1819 fprintf(f, "%s%s ", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
1825 /* void if nothing to return */
1827 fprintf(f, "void ");
1830 fprintf(f, "%s(", dfunc->call);
1834 /* self, context and reports parameters */
1835 if(func->flag & FUNC_USE_SELF_ID) {
1836 fprintf(f, "struct ID *_selfid");
1840 if((func->flag & FUNC_NO_SELF)==0) {
1841 if(!first) fprintf(f, ", ");
1842 if(dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname);
1843 else fprintf(f, "struct %s *_self", srna->identifier);
1847 if(func->flag & FUNC_USE_CONTEXT) {
1848 if(!first) fprintf(f, ", ");
1850 fprintf(f, "bContext *C");
1853 if(func->flag & FUNC_USE_REPORTS) {
1854 if(!first) fprintf(f, ", ");
1856 fprintf(f, "ReportList *reports");
1859 /* defined parameters */
1860 for(dparm= dfunc->cont.properties.first; dparm; dparm= dparm->next) {
1861 type = dparm->prop->type;
1862 flag = dparm->prop->flag;
1863 pout = (flag & PROP_OUTPUT);
1864 cptr = ((type == PROP_POINTER) && !(flag & PROP_RNAPTR));
1866 if(dparm->prop==func->c_ret)
1869 if (cptr || (flag & PROP_DYNAMIC))
1870 ptrstr= pout ? "**" : "*";
1871 else if (type == PROP_POINTER || dparm->prop->arraydimension)
1873 else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
1876 ptrstr= pout ? "*" : "";
1878 if(!first) fprintf(f, ", ");
1881 if (flag & PROP_DYNAMIC)
1882 fprintf(f, "int %s%s_len, ", pout ? "*" : "", dparm->prop->identifier);
1884 if(!(flag & PROP_DYNAMIC) && dparm->prop->arraydimension)
1885 fprintf(f, "%s%s %s[%d]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier, dparm->prop->totarraylength);
1887 fprintf(f, "%s%s %s%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, dparm->prop->identifier);
1894 static void rna_generate_static_function_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f)
1897 FunctionDefRNA *dfunc;
1900 for(func= srna->functions.first; func; func= func->cont.next) {
1901 dfunc= rna_find_function_def(func);
1905 fprintf(f, "/* Repeated prototypes to detect errors */\n\n");
1909 rna_generate_static_parameter_prototypes(brna, srna, dfunc, f);
1916 static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, PropertyRNA *prop)
1918 char *strnest= "", *errnest= "";
1919 int len, freenest= 0;
1924 strnest= MEM_mallocN(sizeof(char)*(len+2), "rna_generate_property -> strnest");
1925 errnest= MEM_mallocN(sizeof(char)*(len+2), "rna_generate_property -> errnest");
1927 strcpy(strnest, "_"); strcat(strnest, nest);
1928 strcpy(errnest, "."); strcat(errnest, nest);
1933 switch(prop->type) {
1935 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
1936 int i, defaultfound= 0;
1939 fprintf(f, "static EnumPropertyItem rna_%s%s_%s_items[%d] = {\n\t", srna->identifier, strnest, prop->identifier, eprop->totitem+1);
1941 for(i=0; i<eprop->totitem; i++) {
1942 fprintf(f, "{%d, ", eprop->item[i].value);
1943 rna_print_c_string(f, eprop->item[i].identifier); fprintf(f, ", ");
1944 fprintf(f, "%d, ", eprop->item[i].icon);
1945 rna_print_c_string(f, eprop->item[i].name); fprintf(f, ", ");
1946 rna_print_c_string(f, eprop->item[i].description); fprintf(f, "},\n\t");
1948 if(eprop->item[i].identifier[0])
1949 if(eprop->defaultvalue == eprop->item[i].value)
1953 fprintf(f, "{0, NULL, 0, NULL, NULL}\n};\n\n");
1956 fprintf(stderr, "rna_generate_structs: %s%s.%s, enum default is not in items.\n", srna->identifier, errnest, prop->identifier);
1961 fprintf(stderr, "rna_generate_structs: %s%s.%s, enum must have items defined.\n", srna->identifier, errnest, prop->identifier);
1966 case PROP_BOOLEAN: {
1967 BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
1970 if(prop->arraydimension && prop->totarraylength) {
1971 fprintf(f, "static int rna_%s%s_%s_default[%d] = {\n\t", srna->identifier, strnest, prop->identifier, prop->totarraylength);
1973 for(i=0; i<prop->totarraylength; i++) {
1974 if(bprop->defaultarray)
1975 fprintf(f, "%d", bprop->defaultarray[i]);
1977 fprintf(f, "%d", bprop->defaultvalue);
1978 if(i != prop->totarraylength-1)
1979 fprintf(f, ",\n\t");
1982 fprintf(f, "\n};\n\n");
1987 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
1990 if(prop->arraydimension && prop->totarraylength) {
1991 fprintf(f, "static int rna_%s%s_%s_default[%d] = {\n\t", srna->identifier, strnest, prop->identifier, prop->totarraylength);
1993 for(i=0; i<prop->totarraylength; i++) {
1994 if(iprop->defaultarray)
1995 fprintf(f, "%d", iprop->defaultarray[i]);
1997 fprintf(f, "%d", iprop->defaultvalue);
1998 if(i != prop->totarraylength-1)
1999 fprintf(f, ",\n\t");
2002 fprintf(f, "\n};\n\n");
2007 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
2010 if(prop->arraydimension && prop->totarraylength) {
2011 fprintf(f, "static float rna_%s%s_%s_default[%d] = {\n\t", srna->identifier, strnest, prop->identifier, prop->totarraylength);
2013 for(i=0; i<prop->totarraylength; i++) {
2014 if(fprop->defaultarray)
2015 rna_float_print(f, fprop->defaultarray[i]);
2017 rna_float_print(f, fprop->defaultvalue);
2018 if(i != prop->totarraylength-1)
2019 fprintf(f, ",\n\t");
2022 fprintf(f, "\n};\n\n");
2030 fprintf(f, "%s%s rna_%s%s_%s = {\n", (prop->flag & PROP_EXPORT)? "": "", rna_property_structname(prop->type), srna->identifier, strnest, prop->identifier);
2032 if(prop->next) fprintf(f, "\t{(PropertyRNA*)&rna_%s%s_%s, ", srna->identifier, strnest, prop->next->identifier);
2033 else fprintf(f, "\t{NULL, ");
2034 if(prop->prev) fprintf(f, "(PropertyRNA*)&rna_%s%s_%s,\n", srna->identifier, strnest, prop->prev->identifier);
2035 else fprintf(f, "NULL,\n");
2036 fprintf(f, "\t%d, ", prop->magic);
2037 rna_print_c_string(f, prop->identifier);
2038 fprintf(f, ", %d, ", prop->flag);
2039 rna_print_c_string(f, prop->name); fprintf(f, ",\n\t");
2040 rna_print_c_string(f, prop->description); fprintf(f, ",\n\t");
2041 fprintf(f, "%d,\n", prop->icon);
2042 fprintf(f, "\t%s, %s|%s, %s, %d, {%d, %d, %d}, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), rna_property_subtype_unit(prop->subtype), rna_function_string(prop->getlength), prop->arraydimension, prop->arraylength[0], prop->arraylength[1], prop->arraylength[2], prop->totarraylength);
2043 fprintf(f, "\t%s%s, %d, %s, %s,\n", (prop->flag & PROP_CONTEXT_UPDATE)? "(UpdateFunc)": "", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable), rna_function_string(prop->itemeditable));
2045 if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop);
2046 else fprintf(f, "\t0, -1");
2048 /* our own type - collections/arrays only */
2049 if(prop->srna) fprintf(f, ", &RNA_%s", (char*)prop->srna);
2050 else fprintf(f, ", NULL");
2054 switch(prop->type) {
2055 case PROP_BOOLEAN: {
2056 BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
2057 fprintf(f, "\t%s, %s, %s, %s, %d, ", rna_function_string(bprop->get), rna_function_string(bprop->set), rna_function_string(bprop->getarray), rna_function_string(bprop->setarray), bprop->defaultvalue);
2058 if(prop->arraydimension && prop->totarraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
2059 else fprintf(f, "NULL\n");
2063 IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
2064 fprintf(f, "\t%s, %s, %s, %s, %s,\n\t", rna_function_string(iprop->get), rna_function_string(iprop->set), rna_function_string(iprop->getarray), rna_function_string(iprop->setarray), rna_function_string(iprop->range));
2065 rna_int_print(f, iprop->softmin); fprintf(f, ", ");
2066 rna_int_print(f, iprop->softmax); fprintf(f, ", ");
2067 rna_int_print(f, iprop->hardmin); fprintf(f, ", ");
2068 rna_int_print(f, iprop->hardmax); fprintf(f, ", ");
2069 rna_int_print(f, iprop->step); fprintf(f, ", ");
2070 rna_int_print(f, iprop->defaultvalue); fprintf(f, ", ");
2071 if(prop->arraydimension && prop->totarraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
2072 else fprintf(f, "NULL\n");
2076 FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
2077 fprintf(f, "\t%s, %s, %s, %s, %s, ", rna_function_string(fprop->get), rna_function_string(fprop->set), rna_function_string(fprop->getarray), rna_function_string(fprop->setarray), rna_function_string(fprop->range));
2078 rna_float_print(f, fprop->softmin); fprintf(f, ", ");
2079 rna_float_print(f, fprop->softmax); fprintf(f, ", ");
2080 rna_float_print(f, fprop->hardmin); fprintf(f, ", ");
2081 rna_float_print(f, fprop->hardmax); fprintf(f, ", ");
2082 rna_float_print(f, fprop->step); fprintf(f, ", ");
2083 rna_int_print(f, (int)fprop->precision); fprintf(f, ", ");
2084 rna_float_print(f, fprop->defaultvalue); fprintf(f, ", ");
2085 if(prop->arraydimension && prop->totarraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
2086 else fprintf(f, "NULL\n");
2090 StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
2091 fprintf(f, "\t%s, %s, %s, %d, ", rna_function_string(sprop->get), rna_function_string(sprop->length), rna_function_string(sprop->set), sprop->maxlength);
2092 rna_print_c_string(f, sprop->defaultvalue); fprintf(f, "\n");
2096 EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
2097 fprintf(f, "\t%s, %s, %s, ", rna_function_string(eprop->get), rna_function_string(eprop->set), rna_function_string(eprop->itemf));
2099 fprintf(f, "rna_%s%s_%s_items, ", srna->identifier, strnest, prop->identifier);
2101 fprintf(f, "NULL, ");
2102 fprintf(f, "%d, %d\n", eprop->totitem, eprop->defaultvalue);
2105 case PROP_POINTER: {
2106 PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
2107 fprintf(f, "\t%s, %s, %s, %s,", rna_function_string(pprop->get), rna_function_string(pprop->set), rna_function_string(pprop->typef), rna_function_string(pprop->poll));
2108 if(pprop->type) fprintf(f, "&RNA_%s\n", (char*)pprop->type);
2109 else fprintf(f, "NULL\n");
2112 case PROP_COLLECTION: {
2113 CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
2114 fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, ", rna_function_string(cprop->begin), rna_function_string(cprop->next), rna_function_string(cprop->end), rna_function_string(cprop->get), rna_function_string(cprop->length), rna_function_string(cprop->lookupint), rna_function_string(cprop->lookupstring));
2115 if(cprop->item_type) fprintf(f, "&RNA_%s\n", (char*)cprop->item_type);
2116 else fprintf(f, "NULL\n");
2121 fprintf(f, "};\n\n");
2129 static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
2132 FunctionDefRNA *dfunc;
2133 PropertyRNA *prop, *parm;
2136 fprintf(f, "/* %s */\n", srna->name);
2138 for(prop= srna->cont.properties.first; prop; prop= prop->next)
2139 rna_generate_property(f, srna, NULL, prop);
2141 for(func= srna->functions.first; func; func= func->cont.next) {
2142 for(parm= func->cont.properties.first; parm; parm= parm->next)
2143 rna_generate_property(f, srna, func->identifier, parm);
2145 fprintf(f, "%s%s rna_%s_%s_func = {\n", "", "FunctionRNA", srna->identifier, func->identifier);
2147 if(func->cont.next) fprintf(f, "\t{(FunctionRNA*)&rna_%s_%s_func, ", srna->identifier, ((FunctionRNA*)func->cont.next)->identifier);
2148 else fprintf(f, "\t{NULL, ");
2149 if(func->cont.prev) fprintf(f, "(FunctionRNA*)&rna_%s_%s_func,\n", srna->identifier, ((FunctionRNA*)func->cont.prev)->identifier);
2150 else fprintf(f, "NULL,\n");
2152 fprintf(f, "\tNULL,\n");
2154 parm= func->cont.properties.first;
2155 if(parm) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s_%s, ", srna->identifier, func->identifier, parm->identifier);
2156 else fprintf(f, "\t{NULL, ");
2158 parm= func->cont.properties.last;
2159 if(parm) fprintf(f, "(PropertyRNA*)&rna_%s_%s_%s}},\n", srna->identifier, func->identifier, parm->identifier);
2160 else fprintf(f, "NULL}},\n");
2163 rna_print_c_string(f, func->identifier);
2164 fprintf(f, ", %d, ", func->flag);
2165 rna_print_c_string(f, func->description); fprintf(f, ",\n");
2167 dfunc= rna_find_function_def(func);
2168 if(dfunc->gencall) fprintf(f, "\t%s,\n", dfunc->gencall);
2169 else fprintf(f, "\tNULL,\n");
2171 if(func->c_ret) fprintf(f, "\t(PropertyRNA*)&rna_%s_%s_%s\n", srna->identifier, func->identifier, func->c_ret->identifier);
2172 else fprintf(f, "\tNULL\n");
2178 fprintf(f, "StructRNA RNA_%s = {\n", srna->identifier);
2180 if(srna->cont.next) fprintf(f, "\t{(ContainerRNA *)&RNA_%s, ", ((StructRNA*)srna->cont.next)->identifier);
2181 else fprintf(f, "\t{NULL, ");
2182 if(srna->cont.prev) fprintf(f, "(ContainerRNA *)&RNA_%s,\n", ((StructRNA*)srna->cont.prev)->identifier);
2183 else fprintf(f, "NULL,\n");
2185 fprintf(f, "\tNULL,\n");
2187 prop= srna->cont.properties.first;
2188 if(prop) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", srna->identifier, prop->identifier);
2189 else fprintf(f, "\t{NULL, ");
2191 prop= srna->cont.properties.last;
2192 if(prop) fprintf(f, "(PropertyRNA*)&rna_%s_%s}},\n", srna->identifier, prop->identifier);
2193 else fprintf(f, "NULL}},\n");
2195 fprintf(f, "\tNULL,NULL,\n"); /* PyType - Cant initialize here */
2198 rna_print_c_string(f, srna->identifier);
2199 fprintf(f, ", %d, ", srna->flag);
2200 rna_print_c_string(f, srna->name);
2202 rna_print_c_string(f, srna->description);
2203 fprintf(f, ",\n\t%d,\n", srna->icon);
2205 prop= srna->nameproperty;
2208 while (base->base && base->base->nameproperty==prop)
2211 fprintf(f, "\t(PropertyRNA*)&rna_%s_%s, ", base->identifier, prop->identifier);
2213 else fprintf(f, "\tNULL, ");
2215 prop= srna->iteratorproperty;
2217 while (base->base && base->base->iteratorproperty==prop)
2219 fprintf(f, "(PropertyRNA*)&rna_%s_rna_properties,\n", base->identifier);
2221 if(srna->base) fprintf(f, "\t&RNA_%s,\n", srna->base->identifier);
2222 else fprintf(f, "\tNULL,\n");
2224 if(srna->nested) fprintf(f, "\t&RNA_%s,\n", srna->nested->identifier);
2225 else fprintf(f, "\tNULL,\n");
2227 fprintf(f, "\t%s,\n", rna_function_string(srna->refine));
2228 fprintf(f, "\t%s,\n", rna_function_string(srna->path));
2229 fprintf(f, "\t%s,\n", rna_function_string(srna->reg));
2230 fprintf(f, "\t%s,\n", rna_function_string(srna->unreg));
2231 fprintf(f, "\t%s,\n", rna_function_string(srna->idproperties));
2233 if(srna->reg && !srna->refine) {
2234 fprintf(stderr, "rna_generate_struct: %s has a register function, must also have refine function.\n", srna->identifier);
2238 func= srna->functions.first;
2239 if(func) fprintf(f, "\t{(FunctionRNA*)&rna_%s_%s_func, ", srna->identifier, func->identifier);
2240 else fprintf(f, "\t{NULL, ");
2242 func= srna->functions.last;
2243 if(func) fprintf(f, "(FunctionRNA*)&rna_%s_%s_func}\n", srna->identifier, func->identifier);
2244 else fprintf(f, "NULL}\n");
2251 typedef struct RNAProcessItem {
2254 void (*define)(BlenderRNA *brna);
2257 RNAProcessItem PROCESS_ITEMS[]= {
2258 {"rna_rna.c", NULL, RNA_def_rna},
2259 {"rna_ID.c", NULL, RNA_def_ID},
2260 {"rna_texture.c", NULL, RNA_def_texture},
2261 {"rna_action.c", "rna_action_api.c", RNA_def_action},
2262 {"rna_animation.c", "rna_animation_api.c", RNA_def_animation},
2263 {"rna_animviz.c", NULL, RNA_def_animviz},
2264 {"rna_actuator.c", "rna_actuator_api.c", RNA_def_actuator},
2265 {"rna_armature.c", "rna_armature_api.c", RNA_def_armature},
2266 {"rna_boid.c", NULL, RNA_def_boid},
2267 {"rna_brush.c", NULL, RNA_def_brush},
2268 {"rna_camera.c", NULL, RNA_def_camera},
2269 {"rna_cloth.c", NULL, RNA_def_cloth},
2270 {"rna_color.c", NULL, RNA_def_color},
2271 {"rna_constraint.c", NULL, RNA_def_constraint},
2272 {"rna_context.c", NULL, RNA_def_context},
2273 {"rna_controller.c", "rna_controller_api.c", RNA_def_controller},
2274 {"rna_curve.c", NULL, RNA_def_curve},
2275 {"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve},
2276 {"rna_fluidsim.c", NULL, RNA_def_fluidsim},
2277 {"rna_gpencil.c", NULL, RNA_def_gpencil},
2278 {"rna_group.c", NULL, RNA_def_group},
2279 {"rna_image.c", "rna_image_api.c", RNA_def_image},
2280 {"rna_key.c", NULL, RNA_def_key},
2281 {"rna_lamp.c", NULL, RNA_def_lamp},
2282 {"rna_lattice.c", NULL, RNA_def_lattice},
2283 {"rna_main.c", "rna_main_api.c", RNA_def_main},
2284 {"rna_material.c", "rna_material_api.c", RNA_def_material},
2285 {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh},
2286 {"rna_meta.c", NULL, RNA_def_meta},
2287 {"rna_modifier.c", NULL, RNA_def_modifier},
2288 {"rna_nla.c", NULL, RNA_def_nla},
2289 {"rna_nodetree.c", NULL, RNA_def_nodetree},
2290 {"rna_object.c", "rna_object_api.c", RNA_def_object},
2291 {"rna_object_force.c", NULL, RNA_def_object_force},
2292 {"rna_packedfile.c", NULL, RNA_def_packedfile},
2293 {"rna_particle.c", NULL, RNA_def_particle},
2294 {"rna_pose.c", "rna_pose_api.c", RNA_def_pose},
2295 {"rna_property.c", NULL, RNA_def_gameproperty},
2296 {"rna_render.c", NULL, RNA_def_render},
2297 {"rna_scene.c", "rna_scene_api.c", RNA_def_scene},
2298 {"rna_screen.c", NULL, RNA_def_screen},
2299 {"rna_sculpt_paint.c", NULL, RNA_def_sculpt_paint},
2300 {"rna_sensor.c", "rna_sensor_api.c", RNA_def_sensor},
2301 {"rna_sequencer.c", "rna_sequencer_api.c", RNA_def_sequencer},
2302 {"rna_smoke.c", NULL, RNA_def_smoke},
2303 {"rna_space.c", NULL, RNA_def_space},
2304 {"rna_test.c", NULL, RNA_def_test},
2305 {"rna_text.c", NULL, RNA_def_text},
2306 {"rna_timeline.c", NULL, RNA_def_timeline_marker},
2307 {"rna_sound.c", NULL, RNA_def_sound},
2308 {"rna_ui.c", "rna_ui_api.c", RNA_def_ui},
2309 {"rna_userdef.c", NULL, RNA_def_userdef},
2310 {"rna_vfont.c", NULL, RNA_def_vfont},
2311 {"rna_wm.c", "rna_wm_api.c", RNA_def_wm},
2312 {"rna_world.c", NULL, RNA_def_world},
2315 static void rna_generate(BlenderRNA *brna, FILE *f, char *filename, char *api_filename)
2319 FunctionDefRNA *dfunc;
2321 fprintf(f, "\n/* Automatically generated struct definitions for the Data API.\n"
2322 " Do not edit manually, changes will be overwritten. */\n\n"
2323 "#define RNA_RUNTIME\n\n");
2325 fprintf(f, "#include <float.h>\n");
2326 fprintf(f, "#include <limits.h>\n");
2327 fprintf(f, "#include <string.h>\n\n");
2328 fprintf(f, "#include <stddef.h>\n\n");
2330 fprintf(f, "#include \"DNA_ID.h\"\n");
2331 fprintf(f, "#include \"DNA_scene_types.h\"\n");
2333 fprintf(f, "#include \"BLI_blenlib.h\"\n\n");
2335 fprintf(f, "#include \"BKE_context.h\"\n");
2336 fprintf(f, "#include \"BKE_library.h\"\n");
2337 fprintf(f, "#include \"BKE_main.h\"\n");
2338 fprintf(f, "#include \"BKE_report.h\"\n");
2339 fprintf(f, "#include \"BKE_utildefines.h\"\n\n");
2341 fprintf(f, "#include \"RNA_define.h\"\n");
2342 fprintf(f, "#include \"RNA_types.h\"\n");
2343 fprintf(f, "#include \"rna_internal.h\"\n\n");
2345 rna_generate_prototypes(brna, f);
2347 fprintf(f, "#include \"%s\"\n", filename);
2349 fprintf(f, "#include \"%s\"\n", api_filename);
2352 fprintf(f, "/* Autogenerated Functions */\n\n");
2354 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next) {
2355 if(!filename || ds->filename == filename) {
2356 rna_generate_property_prototypes(brna, ds->srna, f);
2357 rna_generate_function_prototypes(brna, ds->srna, f);
2361 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next)
2362 if(!filename || ds->filename == filename)
2363 for(dp=ds->cont.properties.first; dp; dp=dp->next)
2364 rna_def_property_funcs(f, ds->srna, dp);
2366 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next) {
2367 if(!filename || ds->filename == filename) {
2368 for(dfunc=ds->functions.first; dfunc; dfunc= dfunc->cont.next)
2369 rna_def_function_funcs(f, ds, dfunc);
2371 rna_generate_static_function_prototypes(brna, ds->srna, f);
2375 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next)
2376 if(!filename || ds->filename == filename)
2377 rna_generate_struct(brna, ds->srna, f);
2379 if(strcmp(filename, "rna_ID.c") == 0) {
2380 /* this is ugly, but we cannot have c files compiled for both
2381 * makesrna and blender with some build systems at the moment */
2382 fprintf(f, "#include \"rna_define.c\"\n\n");
2384 rna_generate_blender(brna, f);
2388 static void rna_generate_header(BlenderRNA *brna, FILE *f)
2394 fprintf(f, "\n#ifndef __RNA_BLENDER_H__\n");
2395 fprintf(f, "#define __RNA_BLENDER_H__\n\n");
2397 fprintf(f, "/* Automatically generated function declarations for the Data API.\n"
2398 " Do not edit manually, changes will be overwritten. */\n\n");
2400 fprintf(f, "#include \"RNA_types.h\"\n\n");
2402 fprintf(f, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n");
2404 fprintf(f, "#define FOREACH_BEGIN(property, sptr, itemptr) \\\n");
2405 fprintf(f, " { \\\n");
2406 fprintf(f, " CollectionPropertyIterator rna_macro_iter; \\\n");
2407 fprintf(f, " for(property##_begin(&rna_macro_iter, sptr); rna_macro_iter.valid; property##_next(&rna_macro_iter)) { \\\n");
2408 fprintf(f, " itemptr= rna_macro_iter.ptr;\n\n");
2410 fprintf(f, "#define FOREACH_END(property) \\\n");
2411 fprintf(f, " } \\\n");
2412 fprintf(f, " property##_end(&rna_macro_iter); \\\n");
2413 fprintf(f, " }\n\n");
2415 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next) {
2418 fprintf(f, "/**************** %s ****************/\n\n", srna->name);
2421 fprintf(f, "extern StructRNA RNA_%s;\n", srna->identifier);
2426 for(dp=ds->cont.properties.first; dp; dp=dp->next)
2427 rna_def_property_funcs_header(f, ds->srna, dp);
2430 fprintf(f, "#ifdef __cplusplus\n}\n#endif\n\n");
2432 fprintf(f, "#endif /* __RNA_BLENDER_H__ */\n\n");
2435 static const char *cpp_classes = ""
2437 "#include <string>\n"
2441 "#define BOOLEAN_PROPERTY(sname, identifier) \\\n"
2442 " bool sname::identifier(void) { return (bool)sname##_##identifier##_get(&ptr); }\n"
2444 "#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n"
2445 " Array<int,size> sname::identifier(void) \\\n"
2446 " { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n"
2448 "#define INT_PROPERTY(sname, identifier) \\\n"
2449 " int sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n"
2451 "#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
2452 " Array<int,size> sname::identifier(void) \\\n"
2453 " { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n"
2455 "#define FLOAT_PROPERTY(sname, identifier) \\\n"
2456 " float sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n"
2458 "#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
2459 " Array<float,size> sname::identifier(void) \\\n"
2460 " { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n"
2462 "#define ENUM_PROPERTY(type, sname, identifier) \\\n"
2463 " sname::type sname::identifier(void) { return (type)sname##_##identifier##_get(&ptr); }\n"
2465 "#define STRING_PROPERTY(sname, identifier) \\\n"
2466 " std::string sname::identifier(void) { \\\n"
2467 " int len= sname##_##identifier##_length(&ptr); \\\n"
2468 " std::string str; str.resize(len); \\\n"
2469 " sname##_##identifier##_get(&ptr, &str[0]); return str; } \\\n"
2471 "#define POINTER_PROPERTY(type, sname, identifier) \\\n"
2472 " type sname::identifier(void) { return type(sname##_##identifier##_get(&ptr)); }\n"
2474 "#define COLLECTION_PROPERTY(type, sname, identifier) \\\n"
2475 " typedef CollectionIterator<type, sname##_##identifier##_begin, \\\n"
2476 " sname##_##identifier##_next, sname##_##identifier##_end> identifier##_iterator; \\\n"
2477 " Collection<sname, type, sname##_##identifier##_begin, \\\n"
2478 " sname##_##identifier##_next, sname##_##identifier##_end> identifier;\n"
2482 " Pointer(const PointerRNA& p) : ptr(p) { }\n"
2483 " operator const PointerRNA&() { return ptr; }\n"
2484 " bool is_a(StructRNA *type) { return RNA_struct_is_a(&ptr, type); }\n"
2485 " operator void*() { return ptr.data; }\n"
2486 " operator bool() { return ptr.data != NULL; }\n"
2488 " PointerRNA ptr;\n"
2492 "template<typename T, int Tsize>\n"
2496 " operator T*() { return data; }\n"
2499 "typedef void (*TBeginFunc)(CollectionPropertyIterator *iter, PointerRNA *ptr);\n"
2500 "typedef void (*TNextFunc)(CollectionPropertyIterator *iter);\n"
2501 "typedef void (*TEndFunc)(CollectionPropertyIterator *iter);\n"
2503 "template<typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n"
2504 "class CollectionIterator {\n"
2506 " CollectionIterator() : t(iter.ptr), init(false) { iter.valid= false; }\n"
2507 " ~CollectionIterator(void) { if(init) Tend(&iter); };\n"
2508 " const CollectionIterator<T, Tbegin, Tnext, Tend>& operator=(const CollectionIterator<T, Tbegin, Tnext, Tend>& copy)\n"
2509 " { if(init) Tend(&iter); iter= copy.iter; if(iter.internal) iter.internal= MEM_dupallocN(iter.internal); t= copy.t; init= copy.init; return *this; }\n"
2511 " operator bool(void)\n"
2512 " { return iter.valid != 0; }\n"
2513 " const CollectionIterator<T, Tbegin, Tnext, Tend>& operator++() { Tnext(&iter); t = T(iter.ptr); return *this; }\n"
2514 " T& operator*(void) { return t; }\n"
2515 " T* operator->(void) { return &t; }\n"
2516 " bool operator==(const CollectionIterator<T, Tbegin, Tnext, Tend>& other) { return iter.valid == other.iter.valid; }\n"
2517 " bool operator!=(const CollectionIterator<T, Tbegin, Tnext, Tend>& other) { return iter.valid != other.iter.valid; }\n"
2519 " void begin(const Pointer& ptr)\n"
2520 " { if(init) Tend(&iter); Tbegin(&iter, (PointerRNA*)&ptr.ptr); t = T(iter.ptr); init = true; }\n"
2523 " CollectionPropertyIterator iter;\n"
2528 "template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n"
2529 "class Collection {\n"
2531 " Collection(const PointerRNA& p) : ptr(p) {}\n"
2533 " CollectionIterator<T, Tbegin, Tnext, Tend> begin()\n"
2534 " { CollectionIterator<T, Tbegin, Tnext, Tend> iter; iter.begin(ptr); return iter; }\n"
2535 " CollectionIterator<T, Tbegin, Tnext, Tend> end()\n"
2536 " { return CollectionIterator<T, Tbegin, Tnext, Tend>(); } /* test */ \n"
2539 " PointerRNA ptr;\n"
2543 static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f)
2549 fprintf(f, "\n#ifndef __RNA_BLENDER_CPP_H__\n");
2550 fprintf(f, "#define __RNA_BLENDER_CPP_H__\n\n");
2552 fprintf(f, "/* Automatically generated classes for the Data API.\n"
2553 " Do not edit manually, changes will be overwritten. */\n\n");
2555 fprintf(f, "#include \"RNA_blender.h\"\n");
2556 fprintf(f, "#include \"RNA_types.h\"\n");
2558 fprintf(f, "%s", cpp_classes);
2560 fprintf(f, "/**************** Declarations ****************/\n\n");
2562 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next)
2563 fprintf(f, "class %s;\n", ds->srna->identifier);
2566 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next) {
2569 fprintf(f, "/**************** %s ****************/\n\n", srna->name);
2571 fprintf(f, "class %s : public %s {\n", srna->identifier, (srna->base)? srna->base->identifier: "Pointer");
2572 fprintf(f, "public:\n");
2573 fprintf(f, "\t%s(const PointerRNA& ptr) :\n\t\t%s(ptr)", srna->identifier, (srna->base)? srna->base->identifier: "Pointer");
2574 for(dp=ds->cont.properties.first; dp; dp=dp->next)
2575 if(!(dp->prop->flag & (PROP_IDPROPERTY|PROP_BUILTIN)))
2576 if(dp->prop->type == PROP_COLLECTION)
2577 fprintf(f, ",\n\t\t%s(ptr)", dp->prop->identifier);
2578 fprintf(f, "\n\t\t{}\n\n");
2580 for(dp=ds->cont.properties.first; dp; dp=dp->next)
2581 rna_def_property_funcs_header_cpp(f, ds->srna, dp);
2582 fprintf(f, "};\n\n");
2586 fprintf(f, "/**************** Implementation ****************/\n");
2588 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next) {
2589 for(dp=ds->cont.properties.first; dp; dp=dp->next)
2590 rna_def_property_funcs_impl_cpp(f, ds->srna, dp);
2595 fprintf(f, "}\n\n#endif /* __RNA_BLENDER_CPP_H__ */\n\n");
2598 static void make_bad_file(char *file, int line)
2600 FILE *fp= fopen(file, "w");
2601 fprintf(fp, "#error \"Error! can't make correct RNA file from %s:%d, STUPID!\"\n", __FILE__, line);
2605 static int rna_preprocess(char *outfile)
2616 for(i=0; PROCESS_ITEMS[i].filename; i++) {
2617 if(PROCESS_ITEMS[i].define) {
2618 PROCESS_ITEMS[i].define(brna);
2620 for(ds=DefRNA.structs.first; ds; ds=ds->cont.next)
2622 ds->filename= PROCESS_ITEMS[i].filename;
2629 /* create RNA_blender_cpp.h */
2630 strcpy(deffile, outfile);
2631 strcat(deffile, "RNA_blender_cpp.h" TMP_EXT);
2633 status= (DefRNA.error != 0);
2636 make_bad_file(deffile, __LINE__);
2639 file = fopen(deffile, "w");
2642 printf ("Unable to open file: %s\n", deffile);
2646 rna_generate_header_cpp(brna, file);
2648 status= (DefRNA.error != 0);
2652 replace_if_different(deffile);
2656 /* create rna_gen_*.c files */
2657 for(i=0; PROCESS_ITEMS[i].filename; i++) {
2658 strcpy(deffile, outfile);
2659 strcat(deffile, PROCESS_ITEMS[i].filename);
2660 deffile[strlen(deffile)-2] = '\0';
2661 strcat(deffile, "_gen.c" TMP_EXT);
2664 make_bad_file(deffile, __LINE__);
2667 file = fopen(deffile, "w");
2670 printf ("Unable to open file: %s\n", deffile);
2674 rna_generate(brna, file, PROCESS_ITEMS[i].filename, PROCESS_ITEMS[i].api_filename);
2676 status= (DefRNA.error != 0);
2680 replace_if_different(deffile);
2683 /* create RNA_blender.h */
2684 strcpy(deffile, outfile);
2685 strcat(deffile, "RNA_blender.h" TMP_EXT);
2688 make_bad_file(deffile, __LINE__);
2691 file = fopen(deffile, "w");
2694 printf ("Unable to open file: %s\n", deffile);
2698 rna_generate_header(brna, file);
2700 status= (DefRNA.error != 0);
2704 replace_if_different(deffile);
2707 RNA_define_free(brna);
2713 static void mem_error_cb(const char *errorStr)
2715 fprintf(stderr, "%s", errorStr);
2719 int main(int argc, char **argv)
2721 int totblock, return_status = 0;
2724 printf("Usage: %s outdirectory/\n", argv[0]);
2728 printf("Running makesrna, program versions %s\n", RNA_VERSION_DATE);
2729 return_status= rna_preprocess(argv[1]);
2732 totblock= MEM_get_memory_blocks_in_use();
2734 printf("Error Totblock: %d\n",totblock);
2735 MEM_set_error_callback(mem_error_cb);
2739 return return_status;