Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-11-26 07:16:29 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-26 07:16:29 +0400
commit3d64381e4de22c8c65177b8f8d1b541284ae4483 (patch)
tree92ea493b0bfe5521e596f0c0d56545df5fb07c40 /source/blender/bmesh/intern/bmesh_operator_api_inline.h
parent3fe8134d6dbd954c6afaec8064abc30be61886c7 (diff)
use more rigid type checking for bmesh slot subtypes.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_operator_api_inline.h')
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api_inline.h61
1 files changed, 58 insertions, 3 deletions
diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
index b405ecc1841..1f6e44e9320 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
@@ -72,12 +72,22 @@ BLI_INLINE void _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const shor
BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot *slot,
void *element, int val)
{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_INT);
+ BMO_slot_map_insert(op, slot, element, &val, sizeof(int));
+}
+
+BLI_INLINE void BMO_slot_map_bool_insert(BMOperator *op, BMOpSlot *slot,
+ void *element, int val)
+{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_BOOL);
+ BLI_assert(val == FALSE || val == TRUE);
BMO_slot_map_insert(op, slot, element, &val, sizeof(int));
}
BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot *slot,
void *element, float val)
{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_FLOAT);
BMO_slot_map_insert(op, slot, element, &val, sizeof(float));
}
@@ -90,9 +100,26 @@ BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot *slot,
BLI_INLINE void BMO_slot_map_ptr_insert(BMOperator *op, BMOpSlot *slot,
const void *element, void *val)
{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL);
BMO_slot_map_insert(op, slot, element, &val, sizeof(void *));
}
+BLI_INLINE void BMO_slot_map_elem_insert(BMOperator *op, BMOpSlot *slot,
+ const void *element, void *val)
+{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_ELEM);
+ BMO_slot_map_insert(op, slot, element, &val, sizeof(void *));
+}
+
+
+/* no values */
+BLI_INLINE void BMO_slot_map_empty_insert(BMOperator *op, BMOpSlot *slot,
+ const void *element)
+{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_EMPTY);
+ BMO_slot_map_insert(op, slot, element, NULL, 0);
+}
+
BLI_INLINE int BMO_slot_map_contains(BMOpSlot *slot, const void *element)
{
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
@@ -126,7 +153,10 @@ BLI_INLINE void *BMO_slot_map_data_get(BMOpSlot *slot, const void *element)
BLI_INLINE float BMO_slot_map_float_get(BMOpSlot *slot, const void *element)
{
- float *val = (float *) BMO_slot_map_data_get(slot, element);
+ float *val;
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_FLOAT);
+
+ val = (float *) BMO_slot_map_data_get(slot, element);
if (val) return *val;
return 0.0f;
@@ -134,15 +164,40 @@ BLI_INLINE float BMO_slot_map_float_get(BMOpSlot *slot, const void *element)
BLI_INLINE int BMO_slot_map_int_get(BMOpSlot *slot, const void *element)
{
- int *val = (int *) BMO_slot_map_data_get(slot, element);
+ int *val;
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_INT);
+
+ val = (int *) BMO_slot_map_data_get(slot, element);
+ if (val) return *val;
+
+ return 0;
+}
+
+BLI_INLINE int BMO_slot_map_bool_get(BMOpSlot *slot, const void *element)
+{
+ int *val;
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_BOOL);
+
+ val = (int *) BMO_slot_map_data_get(slot, element);
+ BLI_assert(val == NULL || *val == FALSE || *val == TRUE);
if (val) return *val;
return 0;
}
-BLI_INLINE void *BMO_slot_map_ptr_get(BMOpSlot *slot, const void *element)
+BLI_INLINE void *BMO_slot_map_ptr_get_(BMOpSlot *slot, const void *element)
+{
+ void **val = (void **) BMO_slot_map_data_get(slot, element);
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL);
+ if (val) return *val;
+
+ return NULL;
+}
+
+BLI_INLINE void *BMO_slot_map_elem_get(BMOpSlot *slot, const void *element)
{
void **val = (void **) BMO_slot_map_data_get(slot, element);
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_ELEM);
if (val) return *val;
return NULL;