Cleanup: replace macros with converter callbacks for bpy.props

Macros were used for expanding shared logic for some properties.

Replace this with Python converters & a funciton that handles
deferred registration.

Add generic converter functions for RNA enums:

- pyrna_enum_value_parse_string
- pyrna_enum_bitfield_parse_set
This commit is contained in:
2021-07-29 15:11:58 +10:00
parent 5280d4bf0b
commit ddcb6b1023
3 changed files with 638 additions and 439 deletions

View File

@@ -213,6 +213,18 @@ int pyrna_set_to_enum_bitfield(const struct EnumPropertyItem *items,
int *r_value,
const char *error_prefix);
/**
* Data for #pyrna_enum_value_parse_string & #pyrna_enum_bitfield_parse_set parsing utilities.
* Use with #PyArg_ParseTuple's `O&` formatting.
*/
struct BPy_EnumProperty_Parse {
const EnumPropertyItem *items;
int value;
bool is_set;
};
int pyrna_enum_value_parse_string(PyObject *o, void *p);
int pyrna_enum_bitfield_parse_set(PyObject *o, void *p);
int pyrna_enum_value_from_id(const EnumPropertyItem *item,
const char *identifier,
int *value,