Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_define.c
| Show First 20 Lines • Show All 960 Lines • ▼ Show 20 Lines | void RNA_def_struct_flag(StructRNA *srna, int flag) | ||||
| srna->flag |= flag; | srna->flag |= flag; | ||||
| } | } | ||||
| void RNA_def_struct_clear_flag(StructRNA *srna, int flag) | void RNA_def_struct_clear_flag(StructRNA *srna, int flag) | ||||
| { | { | ||||
| srna->flag &= ~flag; | srna->flag &= ~flag; | ||||
| } | } | ||||
| void RNA_def_struct_property_tags(StructRNA *srna, const EnumPropertyItem *prop_tag_defines) | |||||
| { | |||||
| srna->prop_tag_defines = prop_tag_defines; | |||||
| } | |||||
| void RNA_def_struct_refine_func(StructRNA *srna, const char *refine) | void RNA_def_struct_refine_func(StructRNA *srna, const char *refine) | ||||
| { | { | ||||
| if (!DefRNA.preprocess) { | if (!DefRNA.preprocess) { | ||||
| fprintf(stderr, "%s: only during preprocessing.\n", __func__); | fprintf(stderr, "%s: only during preprocessing.\n", __func__); | ||||
| return; | return; | ||||
| } | } | ||||
| if (refine) srna->refine = (StructRefineFunc)refine; | if (refine) srna->refine = (StructRefineFunc)refine; | ||||
| ▲ Show 20 Lines • Show All 298 Lines • ▼ Show 20 Lines | void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag) | ||||
| prop->flag |= flag; | prop->flag |= flag; | ||||
| } | } | ||||
| void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag) | void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag) | ||||
| { | { | ||||
| prop->flag &= ~flag; | prop->flag &= ~flag; | ||||
| } | } | ||||
| #ifndef NDEBUG /* debug-only sanity check */ | |||||
| static bool rna_property_tags_are_valid(const StructRNA *srna, int tags) | |||||
| { | |||||
| int tags_remaining = tags; | |||||
| if (tags == 0) { | |||||
| return true; | |||||
| } | |||||
| for (const EnumPropertyItem *tags_define = srna->prop_tag_defines; | |||||
| tags_define->identifier && (tags_remaining > 0); | |||||
| tags_define++) | |||||
| { | |||||
| if ((tags & tags_define->value) == tags_define->value) { // found a valid tag value | |||||
| tags_remaining &= ~tags_define->value; | |||||
| } | |||||
| } | |||||
| /* Remaining tags are not valid! */ | |||||
campbellbarton: Again, storing all used bits could make this a one liner. | |||||
| if (tags_remaining > 0) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| #endif | |||||
| /** | |||||
| * Add the property-tags passed as \a tags to \a prop (if valid). | |||||
| * | |||||
| * \note Multiple tags can be set by passing them within \a tags (using bitflags). | |||||
| */ | |||||
| void RNA_def_property_tags(PropertyRNA *prop, int tags) | |||||
| { | |||||
| BLI_assert(rna_property_tags_are_valid(DefRNA.laststruct, tags)); | |||||
| prop->tags |= tags; | |||||
| } | |||||
| void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter) | void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter) | ||||
| { | { | ||||
| prop->flag |= flag_property; | prop->flag |= flag_property; | ||||
| prop->flag_parameter |= flag_parameter; | prop->flag_parameter |= flag_parameter; | ||||
| } | } | ||||
| void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter) | void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 2,288 Lines • Show Last 20 Lines | |||||
Again, storing all used bits could make this a one liner.