37 PyErr_Format(PyExc_RuntimeError,
"bmesh operator: %.200s", errmsg);
58 const char *slot_name,
62 PyErr_Format(PyExc_TypeError,
63 "%.200s: keyword \"%.200s\" %.200s, expected a %.200s not %.200s",
68 Py_TYPE(value)->tp_name);
71 if (value->
bm ==
nullptr) {
72 PyErr_Format(PyExc_TypeError,
73 "%.200s: keyword \"%.200s\" %.200s invalidated element",
79 if (value->
bm !=
bm) {
80 PyErr_Format(PyExc_TypeError,
81 "%.200s: keyword \"%.200s\" %.200s from another mesh",
102 const char htype_bmo,
105 const char *slot_name,
108 if (value->
bm ==
nullptr) {
109 PyErr_Format(PyExc_TypeError,
110 "%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
116 if (value->
bm !=
bm) {
117 PyErr_Format(PyExc_TypeError,
118 "%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
124 if ((htype_py & htype_bmo) == 0) {
127 PyErr_Format(PyExc_TypeError,
128 "%.200s: keyword \"%.200s\" %.200s, expected "
129 "a sequence of %.200s not %.200s",
150 const char *slot_name)
157 PyErr_Format(PyExc_TypeError,
158 "%.200s: keyword \"%.200s\" expected True/False or 0/1, not %.200s",
161 Py_TYPE(value)->tp_name);
173 const char *enum_str = PyUnicode_AsUTF8(value);
175 if (enum_str ==
nullptr) {
176 PyErr_Format(PyExc_TypeError,
177 "%.200s: keyword \"%.200s\" expected a string, not %.200s",
180 Py_TYPE(value)->tp_name);
201 const int param = PyC_Long_AsI32(value);
203 if (param == -1 && PyErr_Occurred()) {
204 PyErr_Format(PyExc_TypeError,
205 "%.200s: keyword \"%.200s\" expected an int, not %.200s",
208 Py_TYPE(value)->tp_name);
217 const float param = PyFloat_AsDouble(value);
218 if (param == -1 && PyErr_Occurred()) {
219 PyErr_Format(PyExc_TypeError,
220 "%.200s: keyword \"%.200s\" expected a float, not %.200s",
223 Py_TYPE(value)->tp_name);
239 if ((size != pymat->
row_num) || !
ELEM(size, 3, 4)) {
240 PyErr_Format(PyExc_TypeError,
241 "%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix",
264 "single element") == -1)
270 bmop, slot, &(
reinterpret_cast<BPy_BMElem *
>(value))->ele->head);
290 "element buffer") == -1)
304 "element buffer") == -1)
318 "element buffer") == -1)
338 "element buffer") == -1)
346 tot = Py_TYPE(value)->tp_as_sequence->sq_length(value);
352 slot->
data.buf[i] = ele;
357 else if (PySequence_Check(value)) {
358 BMElem **elem_array =
nullptr;
359 Py_ssize_t elem_array_len;
361 elem_array =
static_cast<BMElem **
>(
373 if (elem_array ==
nullptr) {
378 memcpy(slot->
data.buf, elem_array,
sizeof(
void *) * elem_array_len);
379 PyMem_FREE(elem_array);
382 PyErr_Format(PyExc_TypeError,
383 "%.200s: keyword \"%.200s\" expected "
384 "a bmesh sequence, list, (htype, flag) pair, not %.200s",
387 Py_TYPE(value)->tp_name);
396 if (!PyDict_Check(value)) {
397 PyErr_Format(PyExc_TypeError,
398 "%.200s: keyword \"%.200s\" expected "
399 "a dict, not %.200s",
402 Py_TYPE(value)->tp_name);
407 if (!PySet_Check(value)) {
408 PyErr_Format(PyExc_TypeError,
409 "%.200s: keyword \"%.200s\" expected "
413 Py_TYPE(value)->tp_name);
420 if (PyDict_Size(value) > 0) {
421 PyObject *arg_key, *arg_value;
422 Py_ssize_t arg_pos = 0;
423 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
429 "invalid key in dict") == -1)
439 "invalid value in dict") == -1)
446 (
reinterpret_cast<BPy_BMElem *
>(arg_key))->ele,
447 (
reinterpret_cast<BPy_BMElem *
>(arg_value))->ele);
453 if (PyDict_Size(value) > 0) {
454 PyObject *arg_key, *arg_value;
455 Py_ssize_t arg_pos = 0;
456 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
464 "invalid key in dict") == -1)
469 value_f = PyFloat_AsDouble(arg_value);
471 if (value_f == -1.0f && PyErr_Occurred()) {
472 PyErr_Format(PyExc_TypeError,
473 "%.200s: keyword \"%.200s\" expected "
474 "a dict with float values, not %.200s",
477 Py_TYPE(arg_value)->tp_name);
482 bmop, slot, (
reinterpret_cast<BPy_BMElem *
>(arg_key))->ele, value_f);
488 if (PyDict_Size(value) > 0) {
489 PyObject *arg_key, *arg_value;
490 Py_ssize_t arg_pos = 0;
491 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
499 "invalid key in dict") == -1)
504 value_i = PyC_Long_AsI32(arg_value);
506 if (value_i == -1 && PyErr_Occurred()) {
507 PyErr_Format(PyExc_TypeError,
508 "%.200s: keyword \"%.200s\" expected "
509 "a dict with int values, not %.200s",
512 Py_TYPE(arg_value)->tp_name);
517 bmop, slot, (
reinterpret_cast<BPy_BMElem *
>(arg_key))->ele, value_i);
523 if (PyDict_Size(value) > 0) {
524 PyObject *arg_key, *arg_value;
525 Py_ssize_t arg_pos = 0;
526 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
534 "invalid key in dict") == -1)
539 value_i = PyC_Long_AsI32(arg_value);
541 if (value_i == -1 && PyErr_Occurred()) {
542 PyErr_Format(PyExc_TypeError,
543 "%.200s: keyword \"%.200s\" expected "
544 "a dict with bool values, not %.200s",
547 Py_TYPE(arg_value)->tp_name);
552 bmop, slot, (
reinterpret_cast<BPy_BMElem *
>(arg_key))->ele, value_i != 0);
558 if (PySet_GET_SIZE(value) > 0) {
559 PyObject *it = PyObject_GetIter(value);
561 while ((arg_key = PyIter_Next(it))) {
570 "invalid key in set") == -1)
577 bmop, slot, (
reinterpret_cast<BPy_BMElem *
>(arg_key))->ele);
588 PyErr_Format(PyExc_NotImplementedError,
589 "This arguments mapping subtype %d is not supported",
598 PyErr_Format(PyExc_NotImplementedError,
599 "%.200s: keyword \"%.200s\" type %d not working yet!",
617 PyObject *item =
nullptr;
639 item = Py_NewRef(Py_None);
647 const int size = slot->
len;
651 item = PyList_New(size);
652 for (j = 0; j < size; j++) {
665 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
674 PyDict_SetItem(item, py_key, py_val);
682 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
689 PyObject *py_val = PyFloat_FromDouble(*
reinterpret_cast<float *
>(&ele_val));
691 PyDict_SetItem(item, py_key, py_val);
699 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
706 PyObject *py_val = PyLong_FromLong(*
reinterpret_cast<int *
>(&ele_val));
708 PyDict_SetItem(item, py_key, py_val);
716 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
723 PyObject *py_val = PyBool_FromLong(*
reinterpret_cast<bool *
>(&ele_val));
725 PyDict_SetItem(item, py_key, py_val);
733 item = PySet_New(
nullptr);
740 PySet_Add(item, py_key);
749 item = Py_NewRef(Py_None);
768 if ((PyTuple_GET_SIZE(args) == 1) &&
775 PyErr_SetString(PyExc_ValueError,
"bmesh created with 'use_operators=False'");
783 PyErr_SetString(PyExc_TypeError,
784 "bmesh operators expect a single BMesh positional argument, all other args "
793 if (kw && PyDict_Size(kw) > 0) {
797 PyObject *key, *value;
799 while (PyDict_Next(kw, &pos, &key, &value)) {
800 const char *slot_name = PyUnicode_AsUTF8(key);
804 PyErr_Format(PyExc_TypeError,
805 "%.200s: keyword \"%.200s\" is invalid for this operator",
829 ret = Py_NewRef(Py_None);
844 if (item ==
nullptr) {
845 item = Py_NewRef(Py_None);
852 const char *ch = strchr(slot->
slot_name,
'.');
855 memcpy(slot_name_strip, slot->
slot_name, tot);
856 slot_name_strip[tot] =
'\0';
857 PyDict_SetItemString(
ret, slot_name_strip, item);
#define GHASH_ITER(gh_iter_, ghash_)
#define BMO_SLOT_AS_VECTOR(slot)
#define BMO_SLOT_AS_FLOAT(slot)
#define BMO_SLOT_AS_BUFFER(slot)
#define BMO_SLOT_AS_GHASH(slot)
#define BMO_SLOT_AS_BOOL(slot)
#define BMO_SLOT_AS_MATRIX(slot)
#define BMO_FLAG_DEFAULTS
#define BMO_SLOT_AS_INT(slot)
#define BPY_BM_CHECK_OBJ(obj)
#define BPy_BMVertSeq_Check(v)
#define BPy_BMFaceSeq_Check(v)
#define BPy_BMElemSeq_Check(v)
#define BPy_BMElem_Check(v)
#define BPy_BMesh_Check(v)
#define BPy_BMEdgeSeq_Check(v)
#define BM_ITER_BPY_BM_SEQ(ele, iter, bpy_bmelemseq)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool BMO_error_occurred_at_level(BMesh *bm, eBMOpErrorLevel level)
int PyC_FlagSet_ToBitfield(const PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix)
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings)==CTX_MODE_NUM+1, "Must have a string for each context mode") const char *CTX_data_mode_string(const bContext *C)
@ BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL
@ BMO_OP_SLOT_SUBTYPE_MAP_FLT
@ BMO_OP_SLOT_SUBTYPE_MAP_BOOL
@ BMO_OP_SLOT_SUBTYPE_MAP_EMPTY
@ BMO_OP_SLOT_SUBTYPE_MAP_INT
@ BMO_OP_SLOT_SUBTYPE_MAP_ELEM
@ BMO_OP_SLOT_SUBTYPE_INT_ENUM
@ BMO_OP_SLOT_SUBTYPE_INT_FLAG
const char bm_iter_itype_htype_map[BM_ITYPE_MAX]
void BMO_error_clear(BMesh *bm)
static PyObject * bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
char * BPy_BMElem_StringFromHType(const char htype)
int PyC_FlagSet_ValueFromID(const PyC_FlagSet *item, const char *identifier, int *r_value, const char *error_prefix)
void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype)
BMO_ALL_TO_SLOT.
int Matrix_ParseAny(PyObject *o, void *p)
void BMO_op_exec(BMesh *bm, BMOperator *op)
BMESH OPSTACK EXEC OP.
void * BMO_slot_buffer_get_single(BMOpSlot *slot)
BLI_INLINE void BMO_slot_map_bool_insert(BMOperator *op, BMOpSlot *slot, void *element, const bool val)
BLI_INLINE void BMO_slot_map_empty_insert(BMOperator *op, BMOpSlot *slot, const void *element)
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
PyObject * Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObject *base_type)
void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float *mat, int size)
PyObject * Matrix_CreatePyObject(const float *mat, const ushort col_num, const ushort row_num, PyTypeObject *base_type)
BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot *slot, void *element, const float val)
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
static int bpy_slot_from_py(BMesh *bm, BMOperator *bmop, BMOpSlot *slot, PyObject *value, const char *opname, const char *slot_name)
PyObject * BPy_BMElem_CreatePyObject(BMesh *bm, BMHeader *ele)
@ BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE
@ BMO_OP_SLOT_ELEMENT_BUF
unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT
BMOpSlot * BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
BMESH OPSTACK GET SLOT.
int PyC_Long_AsBool(PyObject *value)
static int bpy_slot_from_py_elem_check(BPy_BMElem *value, BMesh *bm, const char htype, const char *opname, const char *slot_name, const char *descr)
Utility function to check BMVert/BMEdge/BMFace's.
void * BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int len)
BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot *slot, void *element, const int val)
static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value, BMesh *bm, const char htype_py, const char htype_bmo, const char *opname, const char *slot_name, const char *descr)
Utility function to check BMVertSeq/BMEdgeSeq/BMFaceSeq's.
void BMO_slot_buffer_from_single(BMOperator *op, BMOpSlot *slot, BMHeader *ele)
char * BPy_BMElem_StringFromHType_ex(const char htype, char ret[32])
void BMO_op_init(BMesh *bm, BMOperator *op, int flag, const char *opname)
BMESH OPSTACK INIT OP.
PyObject * BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
void * BPy_BMElem_PySeq_As_Array(BMesh **r_bm, PyObject *seq, Py_ssize_t min, Py_ssize_t max, Py_ssize_t *r_seq_num, const char htype, const bool do_unique_check, const bool do_bm_check, const char *error_prefix)
void BMO_op_finish(BMesh *bm, BMOperator *op)
BMESH OPSTACK FINISH OP.
BLI_INLINE void BMO_slot_map_elem_insert(BMOperator *op, BMOpSlot *slot, const void *element, void *val)
void bool BMO_error_get(BMesh *bm, const char **r_msg, BMOperator **r_op, eBMOpErrorLevel *r_level)
bool BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
BMESH OPSTACK HAS SLOT.
static int bpy_bm_op_as_py_error(BMesh *bm)
eBMOpSlotSubType_Union slot_subtype
union blender::BMOpSlot::@376352321363166111241172004263244043165250166277 data
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
PyObject_HEAD const char * opname
eBMOpSlotSubType_Int intg
eBMOpSlotSubType_Elem elem