14#define PY_SSIZE_T_CLEAN
39 for (
bool is_first =
true; item->
identifier; item++) {
58 const char *identifier,
60 const char *error_prefix)
65 PyExc_ValueError,
"%s: '%.200s' not found in (%s)", error_prefix, identifier, enum_str);
76 bool type_convert_sign,
78 const char *error_prefix)
83 if (PySet_GET_SIZE(value) > 0) {
85 PyObject *it = PyObject_GetIter(value);
87 while ((key = PyIter_Next(it))) {
91 const char *param = PyUnicode_AsUTF8(key);
92 if (param ==
nullptr) {
93 PyErr_Format(PyExc_TypeError,
94 "%.200s expected a string, not %.200s",
96 Py_TYPE(key)->tp_name);
107 if (type_convert_sign) {
108 if (type_size == 2) {
110 signed short as_signed;
113 ret_convert.as_signed = short(
ret);
114 index = int(ret_convert.as_unsigned);
116 else if (type_size == 1) {
118 signed char as_signed;
121 ret_convert.as_signed =
static_cast<signed char>(
ret);
122 index = int(ret_convert.as_unsigned);
145 const char *error_prefix)
153 PyObject *key =
nullptr;
154 if (PySet_GET_SIZE(value) > 0) {
156 PyObject *it = PyObject_GetIter(value);
157 while ((key = PyIter_Next(it))) {
161 const char *param = PyUnicode_AsUTF8(key);
162 if (param ==
nullptr) {
163 PyErr_Format(PyExc_TypeError,
164 "%.200s expected a string, not %.200s",
166 Py_TYPE(key)->tp_name);
189 PyObject *
ret = PySet_New(
nullptr);
196 item = PyUnicode_FromString(identifier[
index]);
197 PySet_Add(
ret, item);
213 const char *identifier = PyUnicode_AsUTF8(o);
214 if (identifier ==
nullptr) {
215 PyErr_Format(PyExc_TypeError,
"expected a string enum, not %.200s", Py_TYPE(o)->tp_name);
220 parse_data->
items, identifier, &parse_data->
value,
"enum identifier") == -1)
226 parse_data->
is_set =
true;
232 if (!PySet_Check(o)) {
233 PyErr_Format(PyExc_TypeError,
"expected a set, not %.200s", Py_TYPE(o)->tp_name);
239 parse_data->
items, o, &parse_data->
value,
"enum identifier set") == -1)
244 parse_data->
is_set =
true;
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
A dynamically sized string ADT.
Read Blender memory allocation and freeing.
#define RNA_ENUM_BITFLAG_SIZE
#define BLI_assert_unreachable()
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
int pyrna_enum_bitfield_from_set(const EnumPropertyItem *items, PyObject *value, int *r_value, const char *error_prefix)
int RNA_enum_bitflag_identifiers(const EnumPropertyItem *item, const int value, const char **r_identifier)
BLI_bitmap * pyrna_enum_bitmap_from_set(const EnumPropertyItem *items, PyObject *value, int type_size, bool type_convert_sign, int bitmap_size, const char *error_prefix)
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
bool RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *r_value)
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int pyrna_enum_bitfield_parse_set(PyObject *o, void *p)
PyObject * pyrna_enum_bitfield_as_set(const EnumPropertyItem *items, int value)
int pyrna_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *r_value, const char *error_prefix)
char * pyrna_enum_repr(const EnumPropertyItem *item)
DynStr * BLI_dynstr_new() ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
int pyrna_enum_value_parse_string(PyObject *o, void *p)
const EnumPropertyItem * items