diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-03-06 13:22:12 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-03-06 13:22:12 +0300 |
commit | e6d742a69f1be9599cd17c026667794a4117988b (patch) | |
tree | 4f12e4baf1c0e3f02eb6a6921c8f9e3a106e6534 /source/blender/makesrna/intern/makesrna.c | |
parent | d0267ccf6dffa0b7dafa85f6db8ff03251dbb8df (diff) |
RNA:
* Enum default value is now automatically the first item if it
is not specified or 0.
* Otherwise if it's not in the items an error will be printed.
Diffstat (limited to 'source/blender/makesrna/intern/makesrna.c')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 4b7b5babc2e..acc0ed5cec9 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1022,7 +1022,7 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) switch(prop->type) { case PROP_ENUM: { EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; - int i; + int i, defaultfound= 0; if(eprop->item) { fprintf(f, "static EnumPropertyItem rna_%s_%s_items[%d] = {", srna->identifier, prop->identifier, eprop->totitem); @@ -1034,9 +1034,17 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) rna_print_c_string(f, eprop->item[i].description); fprintf(f, "}"); if(i != eprop->totitem-1) fprintf(f, ", "); + + if(eprop->defaultvalue == eprop->item[i].value) + defaultfound= 1; } fprintf(f, "};\n\n"); + + if(!defaultfound) { + fprintf(stderr, "rna_generate_structs: %s.%s, enum default is not in items.\n", srna->identifier, prop->identifier); + DefRNA.error= 1; + } } else { fprintf(stderr, "rna_generate_structs: %s.%s, enum must have items defined.\n", srna->identifier, prop->identifier); |