RNA: Use PROP_RAW_BOOLEAN with single-byte PROP_BOOLEAN raw types

The PROP_RAW_BOOLEAN raw type exists, but was only used as a fallback in
bpy_rna.cc#foreach_getset to help construct an input RawArray for
PROP_BOOLEAN properties without raw access.

Using the PROP_RAW_BOOLEAN raw type for PROP_BOOLEAN properties where
possible will make it so that almost all PROP_BOOLEAN properties are
considered compatible with bool buffers in bpy_rna.cc#foreach_getset,
which should simplify efficient access to bool properties of collection
items with bpy_rna.cc#foreach_getset.

Only about 50 PROP_BOOLEAN properties have raw access because most
either don't use #RNA_def_property_boolean_sdna or use a bitmask, which
disables raw access. Even fewer of these properties belong to a
StructRNA used by a collection property with raw access.

PROP_BOOLEAN properties with raw access, but which use a type larger
than a single byte are rarer still, and will remain using their existing
raw type because they cannot have raw access as bool.

Pull Request: https://projects.blender.org/blender/blender/pulls/116673
This commit is contained in:
Thomas Barlow
2024-01-12 16:04:47 +01:00
committed by Brecht Van Lommel
parent da685008be
commit 2a97516610
+3 -3
View File
@@ -1965,15 +1965,15 @@ static void rna_set_raw_property(PropertyDefRNA *dp, PropertyRNA *prop)
}
if (STREQ(dp->dnatype, "char")) {
prop->rawtype = PROP_RAW_CHAR;
prop->rawtype = prop->type == PROP_BOOLEAN ? PROP_RAW_BOOLEAN : PROP_RAW_CHAR;
prop->flag_internal |= PROP_INTERN_RAW_ACCESS;
}
else if (STREQ(dp->dnatype, "int8_t")) {
prop->rawtype = PROP_RAW_INT8;
prop->rawtype = prop->type == PROP_BOOLEAN ? PROP_RAW_BOOLEAN : PROP_RAW_INT8;
prop->flag_internal |= PROP_INTERN_RAW_ACCESS;
}
else if (STREQ(dp->dnatype, "uchar")) {
prop->rawtype = PROP_RAW_UINT8;
prop->rawtype = prop->type == PROP_BOOLEAN ? PROP_RAW_BOOLEAN : PROP_RAW_UINT8;
prop->flag_internal |= PROP_INTERN_RAW_ACCESS;
}
else if (STREQ(dp->dnatype, "short")) {