36 PyErr_Format(PyExc_RuntimeError,
"bmesh operator: %.200s", errmsg);
57 const char *slot_name,
61 PyErr_Format(PyExc_TypeError,
62 "%.200s: keyword \"%.200s\" %.200s, expected a %.200s not *.200s",
67 Py_TYPE(value)->tp_name);
70 if (value->bm ==
nullptr) {
71 PyErr_Format(PyExc_TypeError,
72 "%.200s: keyword \"%.200s\" %.200s invalidated element",
78 if (value->bm !=
bm) {
79 PyErr_Format(PyExc_TypeError,
80 "%.200s: keyword \"%.200s\" %.200s invalidated element",
101 const char htype_bmo,
104 const char *slot_name,
107 if (value->bm ==
nullptr) {
108 PyErr_Format(PyExc_TypeError,
109 "%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
115 if (value->bm !=
bm) {
116 PyErr_Format(PyExc_TypeError,
117 "%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
123 if ((htype_py & htype_bmo) == 0) {
126 PyErr_Format(PyExc_TypeError,
127 "%.200s: keyword \"%.200s\" %.200s, expected "
128 "a sequence of %.200s not %.200s",
149 const char *slot_name)
156 PyErr_Format(PyExc_TypeError,
157 "%.200s: keyword \"%.200s\" expected True/False or 0/1, not %.200s",
160 Py_TYPE(value)->tp_name);
172 const char *enum_str = PyUnicode_AsUTF8(value);
174 if (enum_str ==
nullptr) {
175 PyErr_Format(PyExc_TypeError,
176 "%.200s: keyword \"%.200s\" expected a string, not %.200s",
179 Py_TYPE(value)->tp_name);
200 const int param = PyC_Long_AsI32(value);
202 if (param == -1 && PyErr_Occurred()) {
203 PyErr_Format(PyExc_TypeError,
204 "%.200s: keyword \"%.200s\" expected an int, not %.200s",
207 Py_TYPE(value)->tp_name);
216 const float param = PyFloat_AsDouble(value);
217 if (param == -1 && PyErr_Occurred()) {
218 PyErr_Format(PyExc_TypeError,
219 "%.200s: keyword \"%.200s\" expected a float, not %.200s",
222 Py_TYPE(value)->tp_name);
238 if ((size != pymat->
row_num) || !
ELEM(size, 3, 4)) {
239 PyErr_Format(PyExc_TypeError,
240 "%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix",
263 "single element") == -1)
288 "element buffer") == -1)
302 "element buffer") == -1)
316 "element buffer") == -1)
336 "element buffer") == -1)
344 tot = Py_TYPE(value)->tp_as_sequence->sq_length(value);
355 else if (PySequence_Check(value)) {
356 BMElem **elem_array =
nullptr;
357 Py_ssize_t elem_array_len;
359 elem_array =
static_cast<BMElem **
>(
371 if (elem_array ==
nullptr) {
376 memcpy(slot->
data.
buf, elem_array,
sizeof(
void *) * elem_array_len);
377 PyMem_FREE(elem_array);
380 PyErr_Format(PyExc_TypeError,
381 "%.200s: keyword \"%.200s\" expected "
382 "a bmesh sequence, list, (htype, flag) pair, not %.200s",
385 Py_TYPE(value)->tp_name);
394 if (!PyDict_Check(value)) {
395 PyErr_Format(PyExc_TypeError,
396 "%.200s: keyword \"%.200s\" expected "
397 "a dict, not %.200s",
400 Py_TYPE(value)->tp_name);
405 if (!PySet_Check(value)) {
406 PyErr_Format(PyExc_TypeError,
407 "%.200s: keyword \"%.200s\" expected "
411 Py_TYPE(value)->tp_name);
418 if (PyDict_Size(value) > 0) {
419 PyObject *arg_key, *arg_value;
420 Py_ssize_t arg_pos = 0;
421 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
427 "invalid key in dict") == -1)
437 "invalid value in dict") == -1)
449 if (PyDict_Size(value) > 0) {
450 PyObject *arg_key, *arg_value;
451 Py_ssize_t arg_pos = 0;
452 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
460 "invalid key in dict") == -1)
465 value_f = PyFloat_AsDouble(arg_value);
467 if (value_f == -1.0f && PyErr_Occurred()) {
468 PyErr_Format(PyExc_TypeError,
469 "%.200s: keyword \"%.200s\" expected "
470 "a dict with float values, not %.200s",
473 Py_TYPE(arg_value)->tp_name);
483 if (PyDict_Size(value) > 0) {
484 PyObject *arg_key, *arg_value;
485 Py_ssize_t arg_pos = 0;
486 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
494 "invalid key in dict") == -1)
499 value_i = PyC_Long_AsI32(arg_value);
501 if (value_i == -1 && PyErr_Occurred()) {
502 PyErr_Format(PyExc_TypeError,
503 "%.200s: keyword \"%.200s\" expected "
504 "a dict with int values, not %.200s",
507 Py_TYPE(arg_value)->tp_name);
517 if (PyDict_Size(value) > 0) {
518 PyObject *arg_key, *arg_value;
519 Py_ssize_t arg_pos = 0;
520 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
528 "invalid key in dict") == -1)
533 value_i = PyC_Long_AsI32(arg_value);
535 if (value_i == -1 && PyErr_Occurred()) {
536 PyErr_Format(PyExc_TypeError,
537 "%.200s: keyword \"%.200s\" expected "
538 "a dict with bool values, not %.200s",
541 Py_TYPE(arg_value)->tp_name);
551 if (PySet_Size(value) > 0) {
553 Py_ssize_t arg_pos = 0;
554 Py_ssize_t arg_hash = 0;
555 while (_PySet_NextEntry(value, &arg_pos, &arg_key, &arg_hash)) {
562 "invalid key in set") == -1)
574 PyErr_Format(PyExc_NotImplementedError,
575 "This arguments mapping subtype %d is not supported",
584 PyErr_Format(PyExc_NotImplementedError,
585 "%.200s: keyword \"%.200s\" type %d not working yet!",
603 PyObject *item =
nullptr;
624 item = Py_NewRef(Py_None);
632 const int size = slot->
len;
636 item = PyList_New(size);
637 for (j = 0; j <
size; j++) {
650 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
659 PyDict_SetItem(item, py_key, py_val);
667 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
674 PyObject *py_val = PyFloat_FromDouble(*(
float *)&ele_val);
676 PyDict_SetItem(item, py_key, py_val);
684 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
691 PyObject *py_val = PyLong_FromLong(*(
int *)&ele_val);
693 PyDict_SetItem(item, py_key, py_val);
701 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
708 PyObject *py_val = PyBool_FromLong(*(
bool *)&ele_val);
710 PyDict_SetItem(item, py_key, py_val);
718 item = PySet_New(
nullptr);
725 PySet_Add(item, py_key);
734 item = Py_NewRef(Py_None);
753 if ((PyTuple_GET_SIZE(args) == 1) && (py_bm = (
BPy_BMesh *)PyTuple_GET_ITEM(args, 0)) &&
760 PyErr_SetString(PyExc_ValueError,
"bmesh created with 'use_operators=False'");
768 PyErr_SetString(PyExc_TypeError,
769 "bmesh operators expect a single BMesh positional argument, all other args "
778 if (kw && PyDict_Size(kw) > 0) {
782 PyObject *key, *value;
784 while (PyDict_Next(kw, &
pos, &key, &value)) {
785 const char *slot_name = PyUnicode_AsUTF8(key);
789 PyErr_Format(PyExc_TypeError,
790 "%.200s: keyword \"%.200s\" is invalid for this operator",
814 ret = Py_NewRef(Py_None);
829 if (item ==
nullptr) {
830 item = Py_NewRef(Py_None);
837 const char *ch = strchr(slot->
slot_name,
'.');
840 memcpy(slot_name_strip, slot->
slot_name, tot);
841 slot_name_strip[tot] =
'\0';
842 PyDict_SetItemString(
ret, slot_name_strip, item);
#define BLI_STATIC_ASSERT(a, msg)
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
#define GHASH_ITER(gh_iter_, ghash_)
unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT
void BMO_error_clear(BMesh *bm)
bool BMO_error_occurred_at_level(BMesh *bm, eBMOpErrorLevel level)
void bool BMO_error_get(BMesh *bm, const char **r_msg, BMOperator **r_op, eBMOpErrorLevel *r_level)
const char bm_iter_itype_htype_map[BM_ITYPE_MAX]
ATTR_WARN_UNUSED_RESULT BMesh const char itype
ATTR_WARN_UNUSED_RESULT BMesh * bm
void * BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int len)
void * BMO_slot_buffer_get_single(BMOpSlot *slot)
#define BMO_SLOT_AS_VECTOR(slot)
void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float *mat, int size)
#define BMO_SLOT_AS_FLOAT(slot)
@ BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE
@ BMO_OP_SLOT_ELEMENT_BUF
void BMO_slot_buffer_from_single(BMOperator *op, BMOpSlot *slot, BMHeader *ele)
BMOpSlot * BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
BMESH OPSTACK GET SLOT.
void BMO_op_exec(BMesh *bm, BMOperator *op)
BMESH OPSTACK EXEC OP.
#define BMO_SLOT_AS_BUFFER(slot)
@ BMO_OP_SLOT_SUBTYPE_MAP_ELEM
@ BMO_OP_SLOT_SUBTYPE_MAP_BOOL
@ BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL
@ BMO_OP_SLOT_SUBTYPE_MAP_INT
@ BMO_OP_SLOT_SUBTYPE_MAP_EMPTY
@ BMO_OP_SLOT_SUBTYPE_MAP_FLT
@ BMO_OP_SLOT_SUBTYPE_INT_FLAG
@ BMO_OP_SLOT_SUBTYPE_INT_ENUM
#define BMO_SLOT_AS_GHASH(slot)
void BMO_op_init(BMesh *bm, BMOperator *op, int flag, const char *opname)
BMESH OPSTACK INIT OP.
#define BMO_SLOT_AS_BOOL(slot)
#define BMO_SLOT_AS_MATRIX(slot)
void BMO_op_finish(BMesh *bm, BMOperator *op)
BMESH OPSTACK FINISH OP.
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.
#define BMO_FLAG_DEFAULTS
bool BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
BMESH OPSTACK HAS SLOT.
#define BMO_SLOT_AS_INT(slot)
BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot *slot, void *element, const int val)
BLI_INLINE void BMO_slot_map_elem_insert(BMOperator *op, BMOpSlot *slot, const void *element, void *val)
BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot *slot, void *element, const float val)
BLI_INLINE void BMO_slot_map_empty_insert(BMOperator *op, BMOpSlot *slot, const void *element)
BLI_INLINE void BMO_slot_map_bool_insert(BMOperator *op, BMOpSlot *slot, void *element, const bool val)
PyObject * BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
static int bpy_bm_op_as_py_error(BMesh *bm)
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.
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.
static PyObject * bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
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)
char * BPy_BMElem_StringFromHType(const char htype)
char * BPy_BMElem_StringFromHType_ex(const char htype, char ret[32])
void * BPy_BMElem_PySeq_As_Array(BMesh **r_bm, PyObject *seq, Py_ssize_t min, Py_ssize_t max, Py_ssize_t *r_size, const char htype, const bool do_unique_check, const bool do_bm_check, const char *error_prefix)
#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)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
PyObject * Matrix_CreatePyObject(const float *mat, const ushort col_num, const ushort row_num, PyTypeObject *base_type)
int Matrix_ParseAny(PyObject *o, void *p)
PyObject * Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObject *base_type)
int PyC_FlagSet_ValueFromID(const PyC_FlagSet *item, const char *identifier, int *r_value, const char *error_prefix)
int PyC_Long_AsBool(PyObject *value)
int PyC_FlagSet_ToBitfield(const PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix)
eBMOpSlotSubType_Union slot_subtype
union BMOpSlot::@139 data
struct BMOpSlot::@139::@140 enum_data
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
PyObject_VAR_HEAD BMesh * bm
eBMOpSlotSubType_Int intg
eBMOpSlotSubType_Elem elem