Cleanup: Move IDProperty enums (types, flags, etc.) to DNA_ID_enums.h

Allows to use typed enum parameters in functions without having to
include the whole `DNA_ID.h` file into other headers.
This commit is contained in:
Bastien Montagne
2024-06-11 16:37:36 +02:00
parent f9c2758c85
commit 60190a7ea7
2 changed files with 58 additions and 58 deletions

View File

@@ -185,64 +185,6 @@ typedef struct IDProperty {
#define MAX_IDPROP_NAME 64
#define DEFAULT_ALLOC_FOR_NULL_STRINGS 64
/** #IDProperty.type */
typedef enum eIDPropertyType {
IDP_STRING = 0,
IDP_INT = 1,
IDP_FLOAT = 2,
/** Array containing int, floats, doubles or groups. */
IDP_ARRAY = 5,
IDP_GROUP = 6,
IDP_ID = 7,
IDP_DOUBLE = 8,
IDP_IDPARRAY = 9,
/**
* True or false value, backed by an `int8_t` underlying type for arrays. Values are expected to
* be 0 or 1.
*/
IDP_BOOLEAN = 10,
} eIDPropertyType;
#define IDP_NUMTYPES 11
/** Used by some IDP utils, keep values in sync with type enum above. */
enum {
IDP_TYPE_FILTER_STRING = 1 << 0,
IDP_TYPE_FILTER_INT = 1 << 1,
IDP_TYPE_FILTER_FLOAT = 1 << 2,
IDP_TYPE_FILTER_ARRAY = 1 << 5,
IDP_TYPE_FILTER_GROUP = 1 << 6,
IDP_TYPE_FILTER_ID = 1 << 7,
IDP_TYPE_FILTER_DOUBLE = 1 << 8,
IDP_TYPE_FILTER_IDPARRAY = 1 << 9,
IDP_TYPE_FILTER_BOOLEAN = 1 << 10,
};
/** #IDProperty.subtype for #IDP_STRING properties. */
typedef enum eIDPropertySubType {
IDP_STRING_SUB_UTF8 = 0, /* default */
IDP_STRING_SUB_BYTE = 1, /* arbitrary byte array, _not_ null terminated */
} eIDPropertySubType;
/** #IDProperty.flag. */
typedef enum eIDPropertyFlag {
/**
* This #IDProperty may be library-overridden.
* Should only be used/be relevant for custom properties.
*/
IDP_FLAG_OVERRIDABLE_LIBRARY = 1 << 0,
/**
* This collection item #IDProperty has been inserted in a local override.
* This is used by internal code to distinguish between library-originated items and
* local-inserted ones, as many operations are not allowed on the former.
*/
IDP_FLAG_OVERRIDELIBRARY_LOCAL = 1 << 1,
/**
* This means the property is set but RNA will return false when checking
* #RNA_property_is_set, currently this is a runtime flag.
*/
IDP_FLAG_GHOST = 1 << 7,
} eIDPropertyFlag;
/* add any future new id property types here. */
/* Static ID override structs. */

View File

@@ -20,6 +20,64 @@ enum eIconSizes {
NUM_ICON_SIZES,
};
/** #IDProperty.type */
typedef enum eIDPropertyType {
IDP_STRING = 0,
IDP_INT = 1,
IDP_FLOAT = 2,
/** Array containing int, floats, doubles or groups. */
IDP_ARRAY = 5,
IDP_GROUP = 6,
IDP_ID = 7,
IDP_DOUBLE = 8,
IDP_IDPARRAY = 9,
/**
* True or false value, backed by an `int8_t` underlying type for arrays. Values are expected to
* be 0 or 1.
*/
IDP_BOOLEAN = 10,
} eIDPropertyType;
#define IDP_NUMTYPES 11
/** Used by some IDP utils, keep values in sync with type enum above. */
enum {
IDP_TYPE_FILTER_STRING = 1 << IDP_STRING,
IDP_TYPE_FILTER_INT = 1 << IDP_INT,
IDP_TYPE_FILTER_FLOAT = 1 << IDP_FLOAT,
IDP_TYPE_FILTER_ARRAY = 1 << IDP_ARRAY,
IDP_TYPE_FILTER_GROUP = 1 << IDP_GROUP,
IDP_TYPE_FILTER_ID = 1 << IDP_ID,
IDP_TYPE_FILTER_DOUBLE = 1 << IDP_DOUBLE,
IDP_TYPE_FILTER_IDPARRAY = 1 << IDP_IDPARRAY,
IDP_TYPE_FILTER_BOOLEAN = 1 << IDP_BOOLEAN,
};
/** #IDProperty.subtype for #IDP_STRING properties. */
typedef enum eIDPropertySubType {
IDP_STRING_SUB_UTF8 = 0, /* default */
IDP_STRING_SUB_BYTE = 1, /* arbitrary byte array, _not_ null terminated */
} eIDPropertySubType;
/** #IDProperty.flag. */
typedef enum eIDPropertyFlag {
/**
* This #IDProperty may be library-overridden.
* Should only be used/be relevant for custom properties.
*/
IDP_FLAG_OVERRIDABLE_LIBRARY = 1 << 0,
/**
* This collection item #IDProperty has been inserted in a local override.
* This is used by internal code to distinguish between library-originated items and
* local-inserted ones, as many operations are not allowed on the former.
*/
IDP_FLAG_OVERRIDELIBRARY_LOCAL = 1 << 1,
/**
* This means the property is set but RNA will return false when checking
* #RNA_property_is_set, currently this is a runtime flag.
*/
IDP_FLAG_GHOST = 1 << 7,
} eIDPropertyFlag;
/**
* Defines for working with IDs.
*