diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-10 15:36:02 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-10 15:36:02 +0400 |
commit | 3496437585c79d590b18d423d1b34d93f226f296 (patch) | |
tree | 3487baf8ec4cac148802ed6ac46ce8186d6c9dc0 /source/blender/makesrna | |
parent | 146a887b81b45ca92972e037976ccf9205da97ee (diff) |
2.5:
* RNA: enum items with "" indentifier are now interpreted as separators.
* Add Object menu: added consistent names, separators.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 19 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 9 |
4 files changed, 27 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 059afad4c70..ec509dbf863 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -119,6 +119,11 @@ static void rna_print_c_string(FILE *f, const char *str) static char *escape[] = {"\''", "\"\"", "\??", "\\\\","\aa", "\bb", "\ff", "\nn", "\rr", "\tt", "\vv", NULL}; int i, j; + if(!str) { + fprintf(f, "NULL"); + return; + } + fprintf(f, "\""); for(i=0; str[i]; i++) { for(j=0; escape[j]; j++) @@ -262,7 +267,8 @@ static int rna_enum_bitmask(PropertyRNA *prop) if(eprop->item) { for(a=0; a<eprop->totitem; a++) - mask |= eprop->item[a].value; + if(eprop->item[a].identifier[0]) + mask |= eprop->item[a].value; } return mask; @@ -971,7 +977,8 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR fprintf(f, "enum {\n"); for(i=0; i<eprop->totitem; i++) - fprintf(f, "\t%s_%s_%s = %d,\n", srna->identifier, prop->identifier, eprop->item[i].identifier, eprop->item[i].value); + if(eprop->item[i].identifier[0]) + fprintf(f, "\t%s_%s_%s = %d,\n", srna->identifier, prop->identifier, eprop->item[i].identifier, eprop->item[i].value); fprintf(f, "};\n\n"); } @@ -1059,7 +1066,8 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property fprintf(f, "\tenum %s_enum {\n", prop->identifier); for(i=0; i<eprop->totitem; i++) - fprintf(f, "\t\t%s_%s = %d,\n", prop->identifier, eprop->item[i].identifier, eprop->item[i].value); + if(eprop->item[i].identifier[0]) + fprintf(f, "\t\t%s_%s = %d,\n", prop->identifier, eprop->item[i].identifier, eprop->item[i].value); fprintf(f, "\t};\n"); } @@ -1577,8 +1585,9 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr rna_print_c_string(f, eprop->item[i].name); fprintf(f, ", "); rna_print_c_string(f, eprop->item[i].description); fprintf(f, "}, "); - if(eprop->defaultvalue == eprop->item[i].value) - defaultfound= 1; + if(eprop->item[i].identifier[0]) + if(eprop->defaultvalue == eprop->item[i].value) + defaultfound= 1; } fprintf(f, "{0, NULL, 0, NULL, NULL}};\n\n"); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index eb53d0fbf51..42f6250728f 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -666,7 +666,7 @@ int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *iden RNA_property_enum_items(ptr, prop, &item, NULL); for(; item->identifier; item++) { - if(strcmp(item->identifier, identifier)==0) { + if(item->identifier[0] && strcmp(item->identifier, identifier)==0) { *value = item->value; return 1; } @@ -678,7 +678,7 @@ int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *iden int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier) { for (; item->identifier; item++) { - if(item->value==value) { + if(item->identifier[0] && item->value==value) { *identifier = item->identifier; return 1; } @@ -689,7 +689,7 @@ int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const cha int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name) { for (; item->identifier; item++) { - if(item->value==value) { + if(item->identifier[0] && item->value==value) { *name = item->name; return 1; } diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 2916c1bcb6e..2b414adf05b 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1117,7 +1117,7 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item for(i=0; item[i].identifier; i++) { eprop->totitem++; - if(item[i].value == eprop->defaultvalue) + if(item[i].identifier[0] && item[i].value == eprop->defaultvalue) defaultfound= 1; } @@ -1280,7 +1280,7 @@ void RNA_def_property_enum_default(PropertyRNA *prop, int value) eprop->defaultvalue= value; for(i=0; i<eprop->totitem; i++) { - if(eprop->item[i].value == eprop->defaultvalue) + if(eprop->item[i].identifier[0] && eprop->item[i].value == eprop->defaultvalue) defaultfound= 1; } diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 557d472afef..0b605db20cf 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -516,6 +516,13 @@ static int rna_StringProperty_max_length_get(PointerRNA *ptr) return ((StringPropertyRNA*)prop)->maxlength; } +static int rna_enum_check_separator(CollectionPropertyIterator *iter, void *data) +{ + EnumPropertyItem *item= (EnumPropertyItem*)data; + + return (item->identifier[0] != 0); +} + static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; @@ -524,7 +531,7 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point rna_idproperty_check(&prop, ptr); eprop= (EnumPropertyRNA*)prop; - rna_iterator_array_begin(iter, (void*)eprop->item, sizeof(eprop->item[0]), eprop->totitem, NULL); + rna_iterator_array_begin(iter, (void*)eprop->item, sizeof(eprop->item[0]), eprop->totitem, rna_enum_check_separator); } static void rna_EnumPropertyItem_identifier_get(PointerRNA *ptr, char *value) |