diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-06-25 08:33:21 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-06-25 08:33:21 +0400 |
commit | a1c5c501a6b4b8bfdee6f60869c122fb6f321726 (patch) | |
tree | b2bd0a250560638b3f08627494eeb002e067a8c9 /source/blender/makesrna/intern/rna_access.c | |
parent | e5f6a41b1b7125a4c3bc7ef2554c04b768ac765c (diff) | |
parent | 7a357cba3994bee7d05c7a8bf5736eb94067d564 (diff) |
At last... this merge should finally do the trick!
21073 to 21145
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 81 |
1 files changed, 37 insertions, 44 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 13686809cd2..66127ebc6df 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -426,23 +426,16 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier) /* Find the property which uses the given nested struct */ PropertyRNA *RNA_struct_find_nested(PointerRNA *ptr, StructRNA *srna) { - CollectionPropertyIterator iter; - PropertyRNA *iterprop, *prop; - int i = 0; + PropertyRNA *prop= NULL; - iterprop= RNA_struct_iterator_property(ptr->type); - RNA_property_collection_begin(ptr, iterprop, &iter); - prop= NULL; - - for(; iter.valid; RNA_property_collection_next(&iter), i++) { + RNA_STRUCT_BEGIN(ptr, iprop) { /* This assumes that there can only be one user of this nested struct */ - if (RNA_property_pointer_type(ptr, iter.ptr.data) == srna) { - prop= iter.ptr.data; + if (RNA_property_pointer_type(ptr, iprop) == srna) { + prop= iprop; break; } } - - RNA_property_collection_end(&iter); + RNA_PROP_END; return prop; } @@ -455,25 +448,21 @@ const struct ListBase *RNA_struct_defined_properties(StructRNA *srna) FunctionRNA *RNA_struct_find_function(PointerRNA *ptr, const char *identifier) { PointerRNA tptr; - CollectionPropertyIterator iter; PropertyRNA *iterprop; FunctionRNA *func; - int i = 0; RNA_pointer_create(NULL, &RNA_Struct, ptr->type, &tptr); iterprop= RNA_struct_find_property(&tptr, "functions"); - RNA_property_collection_begin(&tptr, iterprop, &iter); func= NULL; - for(; iter.valid; RNA_property_collection_next(&iter), i++) { - if(strcmp(identifier, RNA_function_identifier(iter.ptr.data)) == 0) { - func= iter.ptr.data; + RNA_PROP_BEGIN(&tptr, funcptr, iterprop) { + if(strcmp(identifier, RNA_function_identifier(funcptr.data)) == 0) { + func= funcptr.data; break; } } - - RNA_property_collection_end(&iter); + RNA_PROP_END; return func; } @@ -518,6 +507,16 @@ void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type) srna->blender_type= blender_type; } +char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen) +{ + PropertyRNA *nameprop; + + if(ptr->data && (nameprop = RNA_struct_name_property(ptr->type))) + return RNA_property_string_get_alloc(ptr, nameprop, fixedbuf, fixedlen); + + return NULL; +} + /* Property Information */ const char *RNA_property_identifier(PropertyRNA *prop) @@ -643,25 +642,27 @@ 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; - 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 +694,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, i; - - 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 +2066,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; @@ -2247,17 +2245,12 @@ char *RNA_pointer_as_string(PointerRNA *ptr) DynStr *dynstr= BLI_dynstr_new(); char *cstring; - PropertyRNA *prop, *iterprop; - CollectionPropertyIterator iter; const char *propname; int first_time = 1; BLI_dynstr_append(dynstr, "{"); - iterprop= RNA_struct_iterator_property(ptr->type); - - for(RNA_property_collection_begin(ptr, iterprop, &iter); iter.valid; RNA_property_collection_next(&iter)) { - prop= iter.ptr.data; + RNA_STRUCT_BEGIN(ptr, prop) { propname = RNA_property_identifier(prop); if(strcmp(propname, "rna_type")==0) @@ -2271,8 +2264,8 @@ char *RNA_pointer_as_string(PointerRNA *ptr) BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring); MEM_freeN(cstring); } + RNA_STRUCT_END; - RNA_property_collection_end(&iter); BLI_dynstr_append(dynstr, "}"); |