Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/bmesh/bmesh_py_ops_call.c
| Show All 40 Lines | |||||
| #include "bmesh_py_ops_call.h" /* own include */ | #include "bmesh_py_ops_call.h" /* own include */ | ||||
| #include "bmesh_py_types.h" | #include "bmesh_py_types.h" | ||||
| #include "../generic/python_utildefines.h" | #include "../generic/python_utildefines.h" | ||||
| #include "../generic/py_capi_utils.h" | #include "../generic/py_capi_utils.h" | ||||
| BLI_STATIC_ASSERT(sizeof(PyC_FlagSet) == sizeof(BMO_FlagSet), "size mismatch"); | |||||
| static int bpy_bm_op_as_py_error(BMesh *bm) | static int bpy_bm_op_as_py_error(BMesh *bm) | ||||
| { | { | ||||
| if (BMO_error_occurred(bm)) { | if (BMO_error_occurred(bm)) { | ||||
| /* note: we could have multiple errors */ | /* note: we could have multiple errors */ | ||||
| const char *errmsg; | const char *errmsg; | ||||
| if (BMO_error_get(bm, &errmsg, NULL)) { | if (BMO_error_get(bm, &errmsg, NULL)) { | ||||
| PyErr_Format(PyExc_RuntimeError, | PyErr_Format(PyExc_RuntimeError, | ||||
| "bmesh operator: %.200s", | "bmesh operator: %.200s", | ||||
| ▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | case BMO_OP_SLOT_BOOL: | ||||
| else { | else { | ||||
| BMO_SLOT_AS_BOOL(slot) = param; | BMO_SLOT_AS_BOOL(slot) = param; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case BMO_OP_SLOT_INT: | case BMO_OP_SLOT_INT: | ||||
| { | { | ||||
| if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_ENUM) { | |||||
| int enum_val = -1; | |||||
| PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_flags; | |||||
| const char *enum_str = _PyUnicode_AsString(value); | |||||
| if (enum_str == NULL) { | |||||
| PyErr_Format(PyExc_TypeError, | |||||
| "%.200s: keyword \"%.200s\" expected a string, not %.200s", | |||||
| opname, slot_name, Py_TYPE(value)->tp_name); | |||||
| return -1; | |||||
| } | |||||
| if (PyC_FlagSet_ValueFromID(items, enum_str, &enum_val, slot_name) == -1) { | |||||
| return -1; | |||||
| } | |||||
| BMO_SLOT_AS_INT(slot) = enum_val; | |||||
| } | |||||
| else if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_FLAG) { | |||||
| int flag = 0; | |||||
| PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_flags; | |||||
| if (PyC_FlagSet_ToBitfield(items, value, &flag, slot_name) == -1) { | |||||
| return -1; | |||||
| } | |||||
| BMO_SLOT_AS_INT(slot) = flag; | |||||
| } | |||||
| else { | |||||
| const int param = PyC_Long_AsI32(value); | const int param = PyC_Long_AsI32(value); | ||||
| if (param == -1 && PyErr_Occurred()) { | if (param == -1 && PyErr_Occurred()) { | ||||
| PyErr_Format(PyExc_TypeError, | PyErr_Format(PyExc_TypeError, | ||||
| "%.200s: keyword \"%.200s\" expected an int, not %.200s", | "%.200s: keyword \"%.200s\" expected an int, not %.200s", | ||||
| opname, slot_name, Py_TYPE(value)->tp_name); | opname, slot_name, Py_TYPE(value)->tp_name); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| else { | else { | ||||
| BMO_SLOT_AS_INT(slot) = param; | BMO_SLOT_AS_INT(slot) = param; | ||||
| } | } | ||||
| } | |||||
| break; | break; | ||||
| } | } | ||||
| case BMO_OP_SLOT_FLT: | case BMO_OP_SLOT_FLT: | ||||
| { | { | ||||
| float param = PyFloat_AsDouble(value); | float param = PyFloat_AsDouble(value); | ||||
| if (param == -1 && PyErr_Occurred()) { | if (param == -1 && PyErr_Occurred()) { | ||||
| PyErr_Format(PyExc_TypeError, | PyErr_Format(PyExc_TypeError, | ||||
| "%.200s: keyword \"%.200s\" expected a float, not %.200s", | "%.200s: keyword \"%.200s\" expected a float, not %.200s", | ||||
| ▲ Show 20 Lines • Show All 591 Lines • Show Last 20 Lines | |||||