diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-06-23 16:36:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-06-23 16:36:15 +0400 |
commit | bf74f105bc5ec98980fa087347203244750fb669 (patch) | |
tree | b23e701e4a851f29c271e8d02ad7ab21fc38f523 /source/blender/makesrna | |
parent | 502a3849bd0881f74f5a2adc543032a89eede252 (diff) |
small changes...
- allow RNA_property_enum_items to take the totitems int pointer as NULL (spares a loop on all the enum items). this change also makes enums types with no enum array crash in some places, could support these though Id rather disallow them, generating docs is a quick way to test for this.
- open recent file operator used and enum to open the recent file without an enum array, changed to an int type.
- added space_logic.py poll functions
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index c806f1885ba..60774c8432c 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -643,25 +643,28 @@ void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPrope if(eprop->itemf) { *item= eprop->itemf(ptr); - for(tot=0; (*item)[tot].identifier; tot++); - *totitem= tot; + if(totitem) { + for(tot=0; (*item)[tot].identifier; tot++); + *totitem= tot; + } } else { *item= eprop->item; - *totitem= eprop->totitem; + if(totitem) + *totitem= eprop->totitem; } } int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value) { const EnumPropertyItem *item; - int totitem, i; + int i; - RNA_property_enum_items(ptr, prop, &item, &totitem); + RNA_property_enum_items(ptr, prop, &item, NULL); - for(i=0; i<totitem; i++) { - if(strcmp(item[i].identifier, identifier)==0) { - *value = item[i].value; + for(; item->identifier; item++) { + if(strcmp(item->identifier, identifier)==0) { + *value = item->value; return 1; } } @@ -693,11 +696,9 @@ int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **na int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier) { - const EnumPropertyItem *item; - int totitem; - - RNA_property_enum_items(ptr, prop, &item, &totitem); + const EnumPropertyItem *item= NULL; + RNA_property_enum_items(ptr, prop, &item, NULL); return RNA_enum_identifier(item, value, identifier); } @@ -2067,14 +2068,13 @@ int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname) { PropertyRNA *prop= RNA_struct_find_property(ptr, name); const EnumPropertyItem *item; - int a, totitem; if(prop) { - RNA_property_enum_items(ptr, prop, &item, &totitem); + RNA_property_enum_items(ptr, prop, &item, NULL); - for(a=0; a<totitem; a++) - if(strcmp(item[a].identifier, enumname) == 0) - return (item[a].value == RNA_property_enum_get(ptr, prop)); + for(; item->identifier; item++) + if(strcmp(item->identifier, enumname) == 0) + return (item->value == RNA_property_enum_get(ptr, prop)); printf("RNA_enum_is_equal: %s.%s item %s not found.\n", ptr->type->identifier, name, enumname); return 0; |