Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_access.c
| Show First 20 Lines • Show All 560 Lines • ▼ Show 20 Lines | const char *RNA_struct_translation_context(const StructRNA *type) | ||||
| return type->translation_context; | return type->translation_context; | ||||
| } | } | ||||
| PropertyRNA *RNA_struct_name_property(const StructRNA *type) | PropertyRNA *RNA_struct_name_property(const StructRNA *type) | ||||
| { | { | ||||
| return type->nameproperty; | return type->nameproperty; | ||||
| } | } | ||||
| const EnumPropertyItem *RNA_struct_property_tag_defines(const StructRNA *type) | |||||
| { | |||||
| return type->prop_tag_defines; | |||||
| } | |||||
| PropertyRNA *RNA_struct_iterator_property(StructRNA *type) | PropertyRNA *RNA_struct_iterator_property(StructRNA *type) | ||||
| { | { | ||||
| return type->iteratorproperty; | return type->iteratorproperty; | ||||
| } | } | ||||
| StructRNA *RNA_struct_base(StructRNA *type) | StructRNA *RNA_struct_base(StructRNA *type) | ||||
| { | { | ||||
| return type->base; | return type->base; | ||||
| ▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | if (prop_test == (PropertyRNA *)itemptr.data) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| RNA_PROP_END; | RNA_PROP_END; | ||||
| return found; | return found; | ||||
| } | } | ||||
| unsigned int RNA_struct_count_properties(StructRNA *srna) | |||||
| { | |||||
| PointerRNA struct_ptr; | |||||
| unsigned int counter = 0; | |||||
| RNA_pointer_create(NULL, srna, NULL, &struct_ptr); | |||||
| RNA_STRUCT_BEGIN (&struct_ptr, prop) | |||||
| { | |||||
| counter++; | |||||
| UNUSED_VARS(prop); | |||||
| } | |||||
| RNA_STRUCT_END; | |||||
| return counter; | |||||
| } | |||||
| /* low level direct access to type->properties, note this ignores parent classes so should be used with care */ | /* low level direct access to type->properties, note this ignores parent classes so should be used with care */ | ||||
| const struct ListBase *RNA_struct_type_properties(StructRNA *srna) | const struct ListBase *RNA_struct_type_properties(StructRNA *srna) | ||||
| { | { | ||||
| return &srna->cont.properties; | return &srna->cont.properties; | ||||
| } | } | ||||
| PropertyRNA *RNA_struct_type_find_property(StructRNA *srna, const char *identifier) | PropertyRNA *RNA_struct_type_find_property(StructRNA *srna, const char *identifier) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | PropertyUnit RNA_property_unit(PropertyRNA *prop) | ||||
| return RNA_SUBTYPE_UNIT(rna_ensure_property(prop)->subtype); | return RNA_SUBTYPE_UNIT(rna_ensure_property(prop)->subtype); | ||||
| } | } | ||||
| int RNA_property_flag(PropertyRNA *prop) | int RNA_property_flag(PropertyRNA *prop) | ||||
| { | { | ||||
| return rna_ensure_property(prop)->flag; | return rna_ensure_property(prop)->flag; | ||||
| } | } | ||||
| /** | |||||
| * Get the tags set for \a prop as int bitfield. | |||||
| * \note Doesn't perform any validity check on the set bits. #RNA_def_property_tags does this | |||||
| * in debug builds (to avoid performance issues in non-debug builds), which should be | |||||
| * the only way to set tags. Hence, at this point we assume the tag bitfield to be valid. | |||||
| */ | |||||
| int RNA_property_tags(PropertyRNA *prop) | |||||
| { | |||||
campbellbarton: While not so much against this function, I think it would be good to have… | |||||
| return rna_ensure_property(prop)->tags; | |||||
| } | |||||
| bool RNA_property_builtin(PropertyRNA *prop) | bool RNA_property_builtin(PropertyRNA *prop) | ||||
| { | { | ||||
| return (rna_ensure_property(prop)->flag_internal & PROP_INTERN_BUILTIN) != 0; | return (rna_ensure_property(prop)->flag_internal & PROP_INTERN_BUILTIN) != 0; | ||||
| } | } | ||||
| void *RNA_property_py_data_get(PropertyRNA *prop) | void *RNA_property_py_data_get(PropertyRNA *prop) | ||||
| { | { | ||||
Done Inline ActionsAgree, should be debug, maybe worth storing all used bits next to srna->prop_tag_defines for quick one liner checks. campbellbarton: Agree, should be debug, maybe worth storing all used bits next to `srna->prop_tag_defines` for… | |||||
| return prop->py_data; | return prop->py_data; | ||||
| } | } | ||||
| int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop) | int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop) | ||||
| { | { | ||||
| return rna_ensure_property_array_length(ptr, prop); | return rna_ensure_property_array_length(ptr, prop); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 643 Lines • ▼ Show 20 Lines | int RNA_enum_from_value(const EnumPropertyItem *item, const int value) | ||||
| for (; item->identifier; item++, i++) { | for (; item->identifier; item++, i++) { | ||||
| if (item->identifier[0] && item->value == value) { | if (item->identifier[0] && item->value == value) { | ||||
| return i; | return i; | ||||
| } | } | ||||
| } | } | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| unsigned int RNA_enum_items_count(const EnumPropertyItem *item) | |||||
| { | |||||
| unsigned int i = 0; | |||||
| while (item->identifier) { | |||||
| item++; | |||||
| i++; | |||||
| } | |||||
| return i; | |||||
| } | |||||
| bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, | bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, | ||||
| const char **identifier) | const char **identifier) | ||||
| { | { | ||||
| const EnumPropertyItem *item = NULL; | const EnumPropertyItem *item = NULL; | ||||
| bool free; | bool free; | ||||
| RNA_property_enum_items(C, ptr, prop, &item, NULL, &free); | RNA_property_enum_items(C, ptr, prop, &item, NULL, &free); | ||||
| if (item) { | if (item) { | ||||
| ▲ Show 20 Lines • Show All 5,624 Lines • Show Last 20 Lines | |||||
While not so much against this function, I think it would be good to have
RNA_property_tags_get() to avoid having to loop over each bit - eg: rna_Property_tags_get - while this isn't a performance critical code path,
Only being able to check for a single flag forces this elsewhere.