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 365 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; | ||||
| } | } | ||||
| /** | |||||
| * Check if \a prop has valid property-tags passed as \a tags set. | |||||
| * | |||||
| * \note Multiple tags can be passed within \a tags (using bitflags). This checks if all are set then. | |||||
| * \return true if \a prop has all tags set in \a tags and if they are valid (that is, | |||||
| * having a matching item defined in #StructRNA.prop_tag_defines). | |||||
| */ | |||||
| bool RNA_property_has_tags(PointerRNA *ptr, PropertyRNA *prop, int tags) | |||||
| { | |||||
| StructRNA *srna = ptr->type; | |||||
| prop = rna_ensure_property(prop); | |||||
| if ((srna->prop_tag_defines == NULL) || (srna == &RNA_UnknownType)) { | |||||
| printf("%s: Can't set tags for struct \"%s\".\n", __func__, RNA_struct_identifier(srna)); | |||||
| return false; | |||||
| } | |||||
| /* Might want to skip this sanity check for NDEBUG. Right now it's | |||||
| * cheap, but that may change if struct has many tag defines. */ | |||||
| for (const EnumPropertyItem *tag_item = srna->prop_tag_defines; tag_item->identifier; tag_item++) { | |||||
| if ((tag_item->value & tags) != tag_item->value) { | |||||
| printf("%s: Can't set tag(s) of value %d for \"%s.%s\". No matching tag(s) found in struct \"%s\".\n", | |||||
| __func__, tags, srna->identifier, prop->identifier, srna->identifier); | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return (prop->tags & tags) == 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) | ||||
| { | { | ||||
| return prop->py_data; | return prop->py_data; | ||||
| ▲ Show 20 Lines • Show All 641 Lines • ▼ Show 20 Lines | int RNA_enum_from_value(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) | ||||
| { | { | ||||
| EnumPropertyItem *item = NULL; | 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,622 Lines • Show Last 20 Lines | |||||