Code Cleanup: use bool for bmesh operator boolean mapping functions

This commit is contained in:
2014-01-03 21:35:29 +11:00
parent a288644b1e
commit c5cb42f402
3 changed files with 5 additions and 6 deletions

View File

@@ -78,11 +78,10 @@ BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot *slot,
} }
BLI_INLINE void BMO_slot_map_bool_insert(BMOperator *op, BMOpSlot *slot, BLI_INLINE void BMO_slot_map_bool_insert(BMOperator *op, BMOpSlot *slot,
void *element, const int val) void *element, const bool val)
{ {
union { void *ptr; int val; } t = {NULL}; union { void *ptr; bool val; } t = {NULL};
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_BOOL); BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_BOOL);
BLI_assert(val == false || val == true);
BMO_slot_map_insert(op, slot, element, ((t.val = val), t.ptr)); BMO_slot_map_insert(op, slot, element, ((t.val = val), t.ptr));
} }
@@ -170,7 +169,7 @@ BLI_INLINE bool BMO_slot_map_bool_get(BMOpSlot *slot, const void *element)
data = BMO_slot_map_data_get(slot, element); data = BMO_slot_map_data_get(slot, element);
if (data) { if (data) {
return **(int **)data; return **(bool **)data;
} }
else { else {
return false; return false;

View File

@@ -1466,7 +1466,7 @@ int BMO_iter_map_value_int(BMOIter *iter)
bool BMO_iter_map_value_bool(BMOIter *iter) bool BMO_iter_map_value_bool(BMOIter *iter)
{ {
BLI_assert(iter->slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_BOOL); BLI_assert(iter->slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_BOOL);
return **((int **)iter->val); return **((bool **)iter->val);
} }
/* error system */ /* error system */

View File

@@ -639,7 +639,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
void *ele_val = BLI_ghashIterator_getValue(&hash_iter); void *ele_val = BLI_ghashIterator_getValue(&hash_iter);
PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key); PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
PyObject *py_val = PyBool_FromLong(*(int *)&ele_val); PyObject *py_val = PyBool_FromLong(*(bool *)&ele_val);
PyDict_SetItem(item, py_key, py_val); PyDict_SetItem(item, py_key, py_val);
Py_DECREF(py_key); Py_DECREF(py_key);