Blender V5.0
BLI_utildefines_stack.h File Reference

Go to the source code of this file.

Macros

#define STACK_DECLARE(stack)
#define STACK_INIT(stack, stack_num)
#define _STACK_SIZETEST(stack, off)
#define _STACK_SWAP_TOTALLOC(stack_a, stack_b)
#define _STACK_BOUNDSTEST(stack, index)
#define STACK_SIZE(stack)
#define STACK_CLEAR(stack)
#define STACK_PUSH(stack, val)
#define STACK_PUSH_RET(stack)
#define STACK_PUSH_RET_PTR(stack)
#define STACK_POP(stack)
#define STACK_POP_PTR(stack)
#define STACK_POP_DEFAULT(stack, r)
#define STACK_PEEK(stack)
#define STACK_PEEK_PTR(stack)
#define STACK_REMOVE(stack, i)
#define STACK_DISCARD(stack, n)
#define STACK_SWAP(stack_a, stack_b)

Detailed Description

Macro's for a simple array based stack

Note
Caller handles alloc & free.

Definition in file BLI_utildefines_stack.h.

Macro Definition Documentation

◆ _STACK_BOUNDSTEST

#define _STACK_BOUNDSTEST ( stack,
index )
Value:
((void)stack, BLI_assert((unsigned int)(index) < _##stack##_index))
#define BLI_assert(a)
Definition BLI_assert.h:46

Definition at line 32 of file BLI_utildefines_stack.h.

◆ _STACK_SIZETEST

#define _STACK_SIZETEST ( stack,
off )
Value:
(BLI_assert((_##stack##_index) + (off) <= _##stack##_num_alloc))

Definition at line 21 of file BLI_utildefines_stack.h.

◆ _STACK_SWAP_TOTALLOC

#define _STACK_SWAP_TOTALLOC ( stack_a,
stack_b )
Value:
SWAP(unsigned int, _##stack_a##_num_alloc, _##stack_b##_num_alloc)
#define SWAP(type, a, b)

Definition at line 23 of file BLI_utildefines_stack.h.

◆ STACK_CLEAR

#define STACK_CLEAR ( stack)
Value:
{ \
(void)stack; \
_##stack##_index = 0; \
} \
((void)0)

Definition at line 36 of file BLI_utildefines_stack.h.

Referenced by bm_face_connect_verts(), EDBM_select_interior_faces(), mesh_calc_path_region_elem(), mesh_calc_path_region_elem(), and remdoubles_createface().

◆ STACK_DECLARE

◆ STACK_DISCARD

#define STACK_DISCARD ( stack,
n )
Value:
{ \
const unsigned int _n = n; \
BLI_assert(_##stack##_index >= _n); \
(void)stack; \
_##stack##_index -= _n; \
} \
((void)0)

Definition at line 66 of file BLI_utildefines_stack.h.

◆ STACK_INIT

◆ STACK_PEEK

#define STACK_PEEK ( stack)
Value:
(BLI_assert(_##stack##_index), ((stack)[_##stack##_index - 1]))

look at last item (assumes non-empty stack)

Definition at line 54 of file BLI_utildefines_stack.h.

◆ STACK_PEEK_PTR

#define STACK_PEEK_PTR ( stack)
Value:
(BLI_assert(_##stack##_index), &((stack)[_##stack##_index - 1]))

Definition at line 55 of file BLI_utildefines_stack.h.

◆ STACK_POP

#define STACK_POP ( stack)

◆ STACK_POP_DEFAULT

#define STACK_POP_DEFAULT ( stack,
r )
Value:
((_##stack##_index) ? ((stack)[--(_##stack##_index)]) : (r))

Definition at line 52 of file BLI_utildefines_stack.h.

◆ STACK_POP_PTR

#define STACK_POP_PTR ( stack)
Value:
((_##stack##_index) ? &((stack)[--(_##stack##_index)]) : NULL)

Definition at line 51 of file BLI_utildefines_stack.h.

Referenced by bm_face_split_edgenet_find_loop_walk().

◆ STACK_PUSH

◆ STACK_PUSH_RET

#define STACK_PUSH_RET ( stack)
Value:
((void)stack, _STACK_SIZETEST(stack, 1), ((stack)[(_##stack##_index)++]))

Definition at line 45 of file BLI_utildefines_stack.h.

Referenced by bm_face_connect_verts(), BM_mesh_calc_edge_groups_as_arrays(), and BM_mesh_intersect().

◆ STACK_PUSH_RET_PTR

#define STACK_PUSH_RET_PTR ( stack)
Value:
((void)stack, _STACK_SIZETEST(stack, 1), &((stack)[(_##stack##_index)++]))

Definition at line 47 of file BLI_utildefines_stack.h.

Referenced by bm_face_split_edgenet_find_loop_walk().

◆ STACK_REMOVE

#define STACK_REMOVE ( stack,
i )
Value:
{ \
const unsigned int _i = i; \
_STACK_BOUNDSTEST(stack, _i); \
if (--_##stack##_index != _i) { \
stack[_i] = stack[_##stack##_index]; \
} \
} \
((void)0)
i
Definition text_draw.cc:230

remove any item from the stack, take care, re-orders

Definition at line 57 of file BLI_utildefines_stack.h.

Referenced by bm_edge_info_average_length_fallback(), and bmo_offset_edgeloops_exec().

◆ STACK_SIZE

◆ STACK_SWAP

#define STACK_SWAP ( stack_a,
stack_b )
Value:
{ \
SWAP(void *, *(void **)&stack_a, *(void **)&stack_b); \
SWAP(unsigned int, _##stack_a##_index, _##stack_b##_index); \
_STACK_SWAP_TOTALLOC(stack_a, stack_b); \
} \
((void)0)

Definition at line 83 of file BLI_utildefines_stack.h.

Referenced by mesh_calc_path_region_elem(), and mesh_calc_path_region_elem().