2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2012 Blender Foundation.
19 * All rights reserved.
21 * Contributor(s): Campbell Barton
23 * ***** END GPL LICENSE BLOCK *****
26 /** \file blender/python/bmesh/bmesh_py_ops_call.c
29 * This file provides __call__ aka BPy_BMO_call for
30 * the bmesh operatorand has been given its own file
31 * because argument conversion is involved.
36 #include "BLI_utildefines.h"
38 #include "../mathutils/mathutils.h"
42 #include "bmesh_py_ops.h"
43 #include "bmesh_py_ops_call.h" /* own include */
45 #include "bmesh_py_types.h"
46 #include "bmesh_py_utils.h"
48 static int bpy_bm_op_as_py_error(BMesh *bm)
50 if (BMO_error_occurred(bm)) {
51 /* note: we could have multiple errors */
53 if (BMO_error_get(bm, &errmsg, NULL)) {
54 PyErr_Format(PyExc_RuntimeError,
55 "bmesh operator: %.200s",
65 * \brief Utility function to check BMVert/BMEdge/BMFace's
68 * \param bm Check the \a value against this.
69 * \param htype Test \a value matches this type.
70 * \param descr Description text.
72 static int bpy_slot_from_py_elem_check(BPy_BMElem *value, BMesh *bm, const char htype,
73 /* for error messages */
74 const char *opname, const char *slot_name, const char *descr)
76 if (!BPy_BMElem_Check(value) ||
77 !(value->ele->head.htype & htype))
79 PyErr_Format(PyExc_TypeError,
80 "%.200s: keyword \"%.200s\" %.200s, expected a %.200s not *.200s",
81 opname, slot_name, descr,
82 BPy_BMElem_StringFromHType(htype),
83 Py_TYPE(value)->tp_name);
86 else if (value->bm == NULL) {
87 PyErr_Format(PyExc_TypeError,
88 "%.200s: keyword \"%.200s\" %.200s invalidated element",
89 opname, slot_name, descr);
92 else if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
93 PyErr_Format(PyExc_TypeError,
94 "%.200s: keyword \"%.200s\" %.200s invalidated element",
95 opname, slot_name, descr);
102 * \brief Utility function to check BMVertSeq/BMEdgeSeq/BMFaceSeq's
104 * \param value Caller must check its a BMeshSeq
105 * \param bm Check the \a value against this.
106 * \param htype_py The type(s) of \a value.
107 * \param htype_bmo The type(s) supported by the target slot.
108 * \param descr Description text.
110 static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value, BMesh *bm,
111 const char htype_py, const char htype_bmo,
112 /* for error messages */
113 const char *opname, const char *slot_name, const char *descr)
115 if (value->bm == NULL) {
116 PyErr_Format(PyExc_TypeError,
117 "%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
118 opname, slot_name, descr);
121 else if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
122 PyErr_Format(PyExc_TypeError,
123 "%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
124 opname, slot_name, descr);
127 else if ((htype_py & htype_bmo) == 0) {
130 PyErr_Format(PyExc_TypeError,
131 "%.200s: keyword \"%.200s\" %.200s, expected "
132 "a sequence of %.200s not %.200s",
133 opname, slot_name, descr,
134 BPy_BMElem_StringFromHType_ex(htype_bmo, str_bmo),
135 BPy_BMElem_StringFromHType_ex(htype_py, str_py));
143 * Use for giving py args to an operator.
145 static int bpy_slot_from_py(BMesh *bm, BMOperator *bmop, BMOpSlot *slot, PyObject *value,
146 /* the are just for exception messages */
147 const char *opname, const char *slot_name)
149 switch (slot->slot_type) {
150 case BMO_OP_SLOT_BOOL:
154 param = PyLong_AsLong(value);
157 PyErr_Format(PyExc_TypeError,
158 "%.200s: keyword \"%.200s\" expected True/False or 0/1, not %.200s",
159 opname, slot_name, Py_TYPE(value)->tp_name);
163 BMO_SLOT_AS_BOOL(slot) = param;
168 case BMO_OP_SLOT_INT:
171 long param = PyLong_AsLongAndOverflow(value, &overflow);
172 if (overflow || (param > INT_MAX) || (param < INT_MIN)) {
173 PyErr_Format(PyExc_ValueError,
174 "%.200s: keyword \"%.200s\" value not in 'int' range "
175 "(" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")",
176 opname, slot_name, Py_TYPE(value)->tp_name);
179 else if (param == -1 && PyErr_Occurred()) {
180 PyErr_Format(PyExc_TypeError,
181 "%.200s: keyword \"%.200s\" expected an int, not %.200s",
182 opname, slot_name, Py_TYPE(value)->tp_name);
186 BMO_SLOT_AS_INT(slot) = (int)param;
190 case BMO_OP_SLOT_FLT:
192 float param = PyFloat_AsDouble(value);
193 if (param == -1 && PyErr_Occurred()) {
194 PyErr_Format(PyExc_TypeError,
195 "%.200s: keyword \"%.200s\" expected a float, not %.200s",
196 opname, slot_name, Py_TYPE(value)->tp_name);
200 BMO_SLOT_AS_FLOAT(slot) = param;
204 case BMO_OP_SLOT_MAT:
206 /* XXX - BMesh operator design is crappy here, operator slot should define matrix size,
209 if (!MatrixObject_Check(value)) {
210 PyErr_Format(PyExc_TypeError,
211 "%.200s: keyword \"%.200s\" expected a Matrix, not %.200s",
212 opname, slot_name, Py_TYPE(value)->tp_name);
215 else if (BaseMath_ReadCallback((MatrixObject *)value) == -1) {
218 else if (((size = ((MatrixObject *)value)->num_col) != ((MatrixObject *)value)->num_row) ||
219 (ELEM(size, 3, 4) == false))
221 PyErr_Format(PyExc_TypeError,
222 "%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix Matrix",
227 BMO_slot_mat_set(bmop, bmop->slots_in, slot_name, ((MatrixObject *)value)->matrix, size);
230 case BMO_OP_SLOT_VEC:
232 /* passing slot name here is a bit non-descriptive */
233 if (mathutils_array_parse(BMO_SLOT_AS_VECTOR(slot), 3, 3, value, slot_name) == -1) {
238 case BMO_OP_SLOT_ELEMENT_BUF:
240 if (slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) {
241 if (bpy_slot_from_py_elem_check((BPy_BMElem *)value, bm, (slot->slot_subtype.elem & BM_ALL_NOLOOP),
242 opname, slot_name, "single element") == -1)
244 return -1; /* error is set in bpy_slot_from_py_elem_check() */
247 BMO_slot_buffer_from_single(bmop, slot, &((BPy_BMElem *)value)->ele->head);
250 /* there are many ways we could interpret arguments, for now...
251 * - verts/edges/faces from the mesh direct,
252 * this way the operator takes every item.
253 * - `TODO` a plain python sequence (list) of elements.
254 * - `TODO` an iterator. eg.
256 * - `TODO` (type, flag) pair, eg.
260 if (BPy_BMVertSeq_Check(value)) {
261 if (bpy_slot_from_py_elemseq_check((BPy_BMGeneric *)value, bm,
262 BM_VERT, (slot->slot_subtype.elem & BM_ALL_NOLOOP),
263 opname, slot_name, "element buffer") == -1)
265 return -1; /* error is set in bpy_slot_from_py_elem_check() */
268 BMO_slot_buffer_from_all(bm, bmop, bmop->slots_in, slot_name, BM_VERT);
270 else if (BPy_BMEdgeSeq_Check(value)) {
271 if (bpy_slot_from_py_elemseq_check((BPy_BMGeneric *)value, bm,
272 BM_EDGE, (slot->slot_subtype.elem & BM_ALL_NOLOOP),
273 opname, slot_name, "element buffer") == -1)
275 return -1; /* error is set in bpy_slot_from_py_elem_check() */
278 BMO_slot_buffer_from_all(bm, bmop, bmop->slots_in, slot_name, BM_EDGE);
280 else if (BPy_BMFaceSeq_Check(value)) {
281 if (bpy_slot_from_py_elemseq_check((BPy_BMGeneric *)value, bm,
282 BM_FACE, (slot->slot_subtype.elem & BM_ALL_NOLOOP),
283 opname, slot_name, "element buffer") == -1)
285 return -1; /* error is set in bpy_slot_from_py_elem_check() */
287 BMO_slot_buffer_from_all(bm, bmop, bmop->slots_in, slot_name, BM_FACE);
290 else if (BPy_BMElemSeq_Check(value)) {
296 if (bpy_slot_from_py_elemseq_check((BPy_BMGeneric *)value, bm,
297 bm_iter_itype_htype_map[((BPy_BMElemSeq *)value)->itype],
298 (slot->slot_subtype.elem & BM_ALL_NOLOOP),
299 opname, slot_name, "element buffer") == -1)
301 return -1; /* error is set in bpy_slot_from_py_elem_check() */
304 /* this will loop over all elements which is a shame but
305 * we need to know this before alloc */
306 /* calls bpy_bmelemseq_length() */
307 tot = Py_TYPE(value)->tp_as_sequence->sq_length(value);
309 BMO_slot_buffer_alloc(bmop, bmop->slots_in, slot_name, tot);
312 BM_ITER_BPY_BM_SEQ (ele, &iter, ((BPy_BMElemSeq *)value)) {
313 slot->data.buf[i] = ele;
318 else if (PySequence_Check(value)) {
319 BMElem **elem_array = NULL;
320 Py_ssize_t elem_array_len;
322 elem_array = BPy_BMElem_PySeq_As_Array(&bm, value, 0, PY_SSIZE_T_MAX,
323 &elem_array_len, (slot->slot_subtype.elem & BM_ALL_NOLOOP),
324 true, true, slot_name);
326 /* error is set above */
327 if (elem_array == NULL) {
331 BMO_slot_buffer_alloc(bmop, bmop->slots_in, slot_name, elem_array_len);
332 memcpy(slot->data.buf, elem_array, sizeof(void *) * elem_array_len);
333 PyMem_FREE(elem_array);
336 PyErr_Format(PyExc_TypeError,
337 "%.200s: keyword \"%.200s\" expected "
338 "a bmesh sequence, list, (htype, flag) pair, not %.200s",
339 opname, slot_name, Py_TYPE(value)->tp_name);
345 case BMO_OP_SLOT_MAPPING:
347 /* first check types */
348 if (slot->slot_subtype.map != BMO_OP_SLOT_SUBTYPE_MAP_EMPTY) {
349 if (!PyDict_Check(value)) {
350 PyErr_Format(PyExc_TypeError,
351 "%.200s: keyword \"%.200s\" expected "
352 "a dict, not %.200s",
353 opname, slot_name, Py_TYPE(value)->tp_name);
358 if (!PySet_Check(value)) {
359 PyErr_Format(PyExc_TypeError,
360 "%.200s: keyword \"%.200s\" expected "
362 opname, slot_name, Py_TYPE(value)->tp_name);
367 switch (slot->slot_subtype.map) {
368 case BMO_OP_SLOT_SUBTYPE_MAP_ELEM:
370 if (PyDict_Size(value) > 0) {
371 PyObject *arg_key, *arg_value;
372 Py_ssize_t arg_pos = 0;
373 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
374 if (bpy_slot_from_py_elem_check((BPy_BMElem *)arg_key, bm, BM_ALL_NOLOOP,
375 opname, slot_name, "invalid key in dict") == -1)
377 return -1; /* error is set in bpy_slot_from_py_elem_check() */
380 if (bpy_slot_from_py_elem_check((BPy_BMElem *)arg_value, bm, BM_ALL_NOLOOP,
381 opname, slot_name, "invalid value in dict") == -1)
383 return -1; /* error is set in bpy_slot_from_py_elem_check() */
386 BMO_slot_map_elem_insert(bmop, slot,
387 ((BPy_BMElem *)arg_key)->ele, ((BPy_BMElem *)arg_value)->ele);
392 case BMO_OP_SLOT_SUBTYPE_MAP_FLT:
394 if (PyDict_Size(value) > 0) {
395 PyObject *arg_key, *arg_value;
396 Py_ssize_t arg_pos = 0;
397 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
400 if (bpy_slot_from_py_elem_check((BPy_BMElem *)arg_key, bm, BM_ALL_NOLOOP,
401 opname, slot_name, "invalid key in dict") == -1)
403 return -1; /* error is set in bpy_slot_from_py_elem_check() */
406 value_f = PyFloat_AsDouble(arg_value);
408 if (value_f == -1.0f && PyErr_Occurred()) {
409 PyErr_Format(PyExc_TypeError,
410 "%.200s: keyword \"%.200s\" expected "
411 "a dict with float values, not %.200s",
412 opname, slot_name, Py_TYPE(arg_value)->tp_name);
416 BMO_slot_map_float_insert(bmop, slot,
417 ((BPy_BMElem *)arg_key)->ele, value_f);
422 case BMO_OP_SLOT_SUBTYPE_MAP_INT:
424 if (PyDict_Size(value) > 0) {
425 PyObject *arg_key, *arg_value;
426 Py_ssize_t arg_pos = 0;
427 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
430 if (bpy_slot_from_py_elem_check((BPy_BMElem *)arg_key, bm, BM_ALL_NOLOOP,
431 opname, slot_name, "invalid key in dict") == -1)
433 return -1; /* error is set in bpy_slot_from_py_elem_check() */
436 value_i = PyLong_AsLong(arg_value);
438 if (value_i == -1 && PyErr_Occurred()) {
439 PyErr_Format(PyExc_TypeError,
440 "%.200s: keyword \"%.200s\" expected "
441 "a dict with int values, not %.200s",
442 opname, slot_name, Py_TYPE(arg_value)->tp_name);
446 BMO_slot_map_int_insert(bmop, slot,
447 ((BPy_BMElem *)arg_key)->ele, value_i);
452 case BMO_OP_SLOT_SUBTYPE_MAP_BOOL:
454 if (PyDict_Size(value) > 0) {
455 PyObject *arg_key, *arg_value;
456 Py_ssize_t arg_pos = 0;
457 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
460 if (bpy_slot_from_py_elem_check((BPy_BMElem *)arg_key, bm, BM_ALL_NOLOOP,
461 opname, slot_name, "invalid key in dict") == -1)
463 return -1; /* error is set in bpy_slot_from_py_elem_check() */
466 value_i = PyLong_AsLong(arg_value);
468 if (value_i == -1 && PyErr_Occurred()) {
469 PyErr_Format(PyExc_TypeError,
470 "%.200s: keyword \"%.200s\" expected "
471 "a dict with bool values, not %.200s",
472 opname, slot_name, Py_TYPE(arg_value)->tp_name);
476 BMO_slot_map_bool_insert(bmop, slot,
477 ((BPy_BMElem *)arg_key)->ele, value_i != 0);
482 case BMO_OP_SLOT_SUBTYPE_MAP_EMPTY:
484 if (PySet_Size(value) > 0) {
486 Py_ssize_t arg_pos = 0;
487 Py_ssize_t arg_hash = 0;
488 while (_PySet_NextEntry(value, &arg_pos, &arg_key, &arg_hash)) {
490 if (bpy_slot_from_py_elem_check((BPy_BMElem *)arg_key, bm, BM_ALL_NOLOOP,
491 opname, slot_name, "invalid key in set") == -1)
493 return -1; /* error is set in bpy_slot_from_py_elem_check() */
496 BMO_slot_map_empty_insert(bmop, slot,
497 ((BPy_BMElem *)arg_key)->ele);
502 case BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL:
504 /* can't convert from these */
505 PyErr_Format(PyExc_NotImplementedError,
506 "This arguments mapping subtype %d is not supported", slot->slot_subtype.map);
513 /* TODO --- many others */
514 PyErr_Format(PyExc_NotImplementedError,
515 "%.200s: keyword \"%.200s\" type %d not working yet!",
516 opname, slot_name, slot->slot_type);
525 * Use for getting return values from an operator thats already executed.
527 * \note Don't throw any exceptions and should always return a valid (PyObject *).
529 static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
531 PyObject *item = NULL;
533 /* keep switch in same order as above */
534 switch (slot->slot_type) {
535 case BMO_OP_SLOT_BOOL:
536 item = PyBool_FromLong((BMO_SLOT_AS_BOOL(slot)));
538 case BMO_OP_SLOT_INT:
539 item = PyLong_FromLong(BMO_SLOT_AS_INT(slot));
541 case BMO_OP_SLOT_FLT:
542 item = PyFloat_FromDouble((double)BMO_SLOT_AS_FLOAT(slot));
544 case BMO_OP_SLOT_MAT:
545 item = Matrix_CreatePyObject((float *)BMO_SLOT_AS_MATRIX(slot), 4, 4, Py_NEW, NULL);
547 case BMO_OP_SLOT_VEC:
548 item = Vector_CreatePyObject(BMO_SLOT_AS_VECTOR(slot), slot->len, Py_NEW, NULL);
550 case BMO_OP_SLOT_PTR:
551 BLI_assert(0); /* currently we don't have any pointer return values in use */
552 item = (Py_INCREF(Py_None), Py_None);
554 case BMO_OP_SLOT_ELEMENT_BUF:
556 if (slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) {
557 BMHeader *ele = BMO_slot_buffer_get_single(slot);
558 item = ele ? BPy_BMElem_CreatePyObject(bm, ele) : (Py_INCREF(Py_None), Py_None);
561 const int size = slot->len;
562 void **buffer = BMO_SLOT_AS_BUFFER(slot);
565 item = PyList_New(size);
566 for (j = 0; j < size; j++) {
567 BMHeader *ele = buffer[j];
568 PyList_SET_ITEM(item, j, BPy_BMElem_CreatePyObject(bm, ele));
573 case BMO_OP_SLOT_MAPPING:
575 GHash *slot_hash = BMO_SLOT_AS_GHASH(slot);
576 GHashIterator hash_iter;
578 switch (slot->slot_subtype.map) {
579 case BMO_OP_SLOT_SUBTYPE_MAP_ELEM:
583 GHASH_ITER (hash_iter, slot_hash) {
584 BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
585 void *ele_val = BLI_ghashIterator_getValue(&hash_iter);
587 PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
588 PyObject *py_val = BPy_BMElem_CreatePyObject(bm, ele_val);
590 PyDict_SetItem(item, py_key, py_val);
597 case BMO_OP_SLOT_SUBTYPE_MAP_FLT:
601 GHASH_ITER (hash_iter, slot_hash) {
602 BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
603 void *ele_val = BLI_ghashIterator_getValue(&hash_iter);
605 PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
606 PyObject *py_val = PyFloat_FromDouble(*(float *)&ele_val);
608 PyDict_SetItem(item, py_key, py_val);
615 case BMO_OP_SLOT_SUBTYPE_MAP_INT:
619 GHASH_ITER (hash_iter, slot_hash) {
620 BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
621 void *ele_val = BLI_ghashIterator_getValue(&hash_iter);
623 PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
624 PyObject *py_val = PyLong_FromLong(*(int *)&ele_val);
626 PyDict_SetItem(item, py_key, py_val);
633 case BMO_OP_SLOT_SUBTYPE_MAP_BOOL:
637 GHASH_ITER (hash_iter, slot_hash) {
638 BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
639 void *ele_val = BLI_ghashIterator_getValue(&hash_iter);
641 PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
642 PyObject *py_val = PyBool_FromLong(*(bool *)&ele_val);
644 PyDict_SetItem(item, py_key, py_val);
651 case BMO_OP_SLOT_SUBTYPE_MAP_EMPTY:
653 item = PySet_New(NULL);
655 GHASH_ITER (hash_iter, slot_hash) {
656 BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
658 PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
660 PySet_Add(item, py_key);
667 case BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL:
668 /* can't convert from these */
669 item = (Py_INCREF(Py_None), Py_None);
675 BLI_assert(item != NULL);
681 * This is the __call__ for bmesh.ops.xxx()
683 PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
691 if ((PyTuple_GET_SIZE(args) == 1) &&
692 (py_bm = (BPy_BMesh *)PyTuple_GET_ITEM(args, 0)) &&
693 (BPy_BMesh_Check(py_bm)))
695 BPY_BM_CHECK_OBJ(py_bm);
698 /* could complain about entering with exceptions... */
702 PyErr_SetString(PyExc_TypeError,
703 "bmesh operators expect a single BMesh positional argument, all other args must be keywords");
707 /* TODO - error check this!, though we do the error check on attribute access */
708 /* TODO - make flags optional */
709 BMO_op_init(bm, &bmop, BMO_FLAG_DEFAULTS, self->opname);
711 if (kw && PyDict_Size(kw) > 0) {
712 /* setup properties, see bpy_rna.c: pyrna_py_to_prop()
713 * which shares this logic for parsing properties */
715 PyObject *key, *value;
717 while (PyDict_Next(kw, &pos, &key, &value)) {
718 const char *slot_name = _PyUnicode_AsString(key);
721 if (!BMO_slot_exists(bmop.slots_in, slot_name)) {
722 PyErr_Format(PyExc_TypeError,
723 "%.200s: keyword \"%.200s\" is invalid for this operator",
724 self->opname, slot_name);
725 BMO_op_finish(bm, &bmop);
729 slot = BMO_slot_get(bmop.slots_in, slot_name);
731 /* now assign the value */
732 if (bpy_slot_from_py(bm, &bmop, slot, value,
733 self->opname, slot_name) == -1)
735 BMO_op_finish(bm, &bmop);
741 BMO_op_exec(bm, &bmop);
743 /* from here until the end of the function, no returns, just set 'ret' */
744 if (UNLIKELY(bpy_bm_op_as_py_error(bm) == -1)) {
745 ret = NULL; /* exception raised above */
747 else if (bmop.slots_out[0].slot_name == NULL) {
748 ret = (Py_INCREF(Py_None), Py_None);
751 /* build return value */
755 for (i = 0; bmop.slots_out[i].slot_name; i++) {
756 // BMOpDefine *op_def = opdefines[bmop.type];
757 // BMOSlotType *slot_type = op_def->slot_types_out[i];
758 BMOpSlot *slot = &bmop.slots_out[i];
761 /* this function doesn't throw exceptions */
762 item = bpy_slot_to_py(bm, slot);
764 item = (Py_INCREF(Py_None), Py_None);
768 /* temp code, strip off '.out' while we keep this convention */
770 char slot_name_strip[MAX_SLOTNAME];
771 const char *ch = strchr(slot->slot_name, '.'); /* can't fail! */
772 int tot = ch - slot->slot_name;
773 BLI_assert(ch != NULL);
774 memcpy(slot_name_strip, slot->slot_name, tot);
775 slot_name_strip[tot] = '\0';
776 PyDict_SetItemString(ret, slot_name_strip, item);
779 PyDict_SetItemString(ret, slot->slot_name, item);
785 BMO_op_finish(bm, &bmop);