Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Files | Macros | Functions

Files

file  afw_stack.h
 Adaptive Framework stack support.
 

Macros

#define afw_stack_create(typedef_name, initial_count, maximum_count, create_subpool_pool, p, xctx)
 Create a stack for the specified typedef. More...
 
#define afw_stack_release(instance, xctx)   afw_stack_release_impl( &((instance)->pub), xctx)
 Release stack implementation. More...
 
#define afw_stack_copy(instance, count, ptr, p, xctx)   afw_stack_copy_impl( &((instance)->pub), count, ptr, p, xctx)
 Copy stack. More...
 
#define afw_stack_copy_and_release(instance, count, ptr, p, xctx)
 Copy and release stack. More...
 
#define afw_stack_is_empty(instance)    ((instance)->top < (instance)->first)
 Determine is a stack is empty. More...
 
#define afw_stack_pop(instance, xctx)
 Decrement stack->top to location of previous entry. More...
 
#define afw_stack_count(instance, xctx)    ((instance)->top + 1 - (instance)->first))
 Number of entries in stack. More...
 
#define afw_stack_push(instance, xctx)
 Increment stack->top to location of next entry and returns *top. More...
 
#define afw_stack_push_direct(instance, xctx)
 Increment stack->top to location of next entry and returns top. More...
 
#define afw_stack_push_and_get_entry(instance, entry, xctx)
 Increment stack->top to location of next entry and get entry. More...
 
#define afw_stack_set_empty(instance)    (instance)->top = ((instance)->first) - 1
 Increment stack->top to location of next entry. More...
 

Functions

afw_stack_tafw_stack_create_impl (afw_size_t entry_size, afw_size_t initial_count, afw_size_t maximum_count, afw_boolean_t create_subpool_pool, const afw_pool_t *p, afw_xctx_t *xctx)
 Create a stack implementation. More...
 
void afw_stack_release_impl (afw_stack_t *instance, afw_xctx_t *xctx)
 Release stack implementation. More...
 
void afw_stack_copy_impl (afw_stack_t *instance, afw_size_t *count, const void ***ptr, const afw_pool_t *p, afw_xctx_t *xctx)
 Copy stack implementation. More...
 
void afw_stack_extend_impl (afw_stack_t *instance, afw_xctx_t *xctx)
 Extend stack implementation. More...
 
 afw_stack_internal_set_qualifier_stack (afw_xctx_t *xctx)
 
 afw_stack_internal_set_evaluation_stack (afw_xctx_t *xctx)
 

Detailed Description

Adaptive Framework Stack.

Macro Definition Documentation

◆ afw_stack_copy

#define afw_stack_copy (   instance,
  count,
  ptr,
  p,
  xctx 
)    afw_stack_copy_impl( &((instance)->pub), count, ptr, p, xctx)

Copy stack.

Parameters
instanceof AFW_STACK_STRUCT().
countis place to return count.
ptris place to return pointer to copy.
pto use for result.
xctxof caller.

Definition at line 100 of file afw_stack.h.

◆ afw_stack_copy_and_release

#define afw_stack_copy_and_release (   instance,
  count,
  ptr,
  p,
  xctx 
)
Value:
afw_stack_copy(instance, (count), (const void ***)(ptr), (p), (xctx)); \
afw_stack_release(instance, (xctx))
#define afw_stack_copy(instance, count, ptr, p, xctx)
Copy stack.
Definition: afw_stack.h:100

Copy and release stack.

Parameters
instanceof AFW_STACK_STRUCT().
countis place to return count or NULL.
ptris place to return pointer to copy.
pto use for result.
xctxof caller.

Definition at line 131 of file afw_stack.h.

◆ afw_stack_count

#define afw_stack_count (   instance,
  xctx 
)     ((instance)->top + 1 - (instance)->first))

Number of entries in stack.

Parameters
instance.
xctxof caller.
Returns
number of entries.

Definition at line 181 of file afw_stack.h.

◆ afw_stack_create

#define afw_stack_create (   typedef_name,
  initial_count,
  maximum_count,
  create_subpool_pool,
  p,
  xctx 
)
Value:
(typedef_name *)afw_stack_create_impl( \
sizeof(*(((typedef_name *)0))->first), \
initial_count, maximum_count, create_subpool_pool, p, xctx);
afw_stack_t * afw_stack_create_impl(afw_size_t entry_size, afw_size_t initial_count, afw_size_t maximum_count, afw_boolean_t create_subpool_pool, const afw_pool_t *p, afw_xctx_t *xctx)
Create a stack implementation.
Definition: afw_stack.c:99

Create a stack for the specified typedef.

Parameters
typedef_name(See AFW_STACK_STRUCT macro in afw_common.h)
initial_count
maximum_countor 0 if no limit
create_subpool_poolif true.
pfor stack
xctxof caller
Returns
pointer to created stack of type typedef_name *.

Definition at line 40 of file afw_stack.h.

◆ afw_stack_is_empty

#define afw_stack_is_empty (   instance)     ((instance)->top < (instance)->first)

Determine is a stack is empty.

Parameters
instance.stack->top will point to uninitialize storage. If needed the stack's extend will be called, so stack first and end may change after afw_stack_push*().

Definition at line 157 of file afw_stack.h.

◆ afw_stack_pop

#define afw_stack_pop (   instance,
  xctx 
)
Value:
if ((instance)->top < ((instance)->first)) { \
AFW_THROW_ERROR_Z(general, "stack underflow", xctx); \
} \
((instance)->top)--;

Decrement stack->top to location of previous entry.

Parameters
instance.
xctxof caller.

An error will be thrown on underflow.

Definition at line 168 of file afw_stack.h.

◆ afw_stack_push

#define afw_stack_push (   instance,
  xctx 
)
Value:
((instance)->top)++; \
if ((instance)->top >= ((instance)->end)) { \
afw_stack_extend_impl(&((instance)->pub), xctx); \
} \
*((instance)->top)

Increment stack->top to location of next entry and returns *top.

Parameters
instanceof AFW_STACK_STRUCT().
xctxof caller.
Returns
stack->top.

stack->top will point to uninitialize storage. If needed the stack's extend will be called, so stack first and end may change after afw_stack_push*().

Definition at line 195 of file afw_stack.h.

◆ afw_stack_push_and_get_entry

#define afw_stack_push_and_get_entry (   instance,
  entry,
  xctx 
)
Value:
afw_stack_push_direct(instance, xctx); \
entry = (instance)->top
#define afw_stack_push_direct(instance, xctx)
Increment stack->top to location of next entry and returns top.
Definition: afw_stack.h:213

Increment stack->top to location of next entry and get entry.

Parameters
instanceof AFW_STACK_STRUCT().
xctxof caller.
Returns
stack->top.

stack->top will point to uninitialize storage. If needed the stack's extend will be called, so stack first and end may change after afw_stack_push*().

Definition at line 230 of file afw_stack.h.

◆ afw_stack_push_direct

#define afw_stack_push_direct (   instance,
  xctx 
)
Value:
((instance)->top)++; \
if ((instance)->top >= ((instance)->end)) { \
afw_stack_extend_impl(&((instance)->pub), xctx); \
}

Increment stack->top to location of next entry and returns top.

Parameters
instanceof AFW_STACK_STRUCT().
xctxof caller.
Returns
Don't count return. Use (instance)->top.

stack->top will point to uninitialize storage. If needed the stack's extend will be called, so stack first and end may change after afw_stack_push*().

Definition at line 213 of file afw_stack.h.

◆ afw_stack_release

#define afw_stack_release (   instance,
  xctx 
)    afw_stack_release_impl( &((instance)->pub), xctx)

Release stack implementation.

Parameters
instanceof AFW_STACK_STRUCT().
xctxof caller.

Definition at line 75 of file afw_stack.h.

◆ afw_stack_set_empty

#define afw_stack_set_empty (   instance)     (instance)->top = ((instance)->first) - 1

Increment stack->top to location of next entry.

Parameters
instance.stack->top will point to uninitialize storage. If needed the stack's extend will be called, so stack first and end may change after afw_stack_push*().

Definition at line 243 of file afw_stack.h.

Function Documentation

◆ afw_stack_copy_impl()

void afw_stack_copy_impl ( afw_stack_t instance,
afw_size_t count,
const void ***  ptr,
const afw_pool_t p,
afw_xctx_t xctx 
)

Copy stack implementation.

Parameters
instance
countis place to return count or NULL.
ptris place to return pointer to copy.
pto use for result.
xctxof caller.

This is normally called by macro afw_stack_copy().

Definition at line 148 of file afw_stack.c.

◆ afw_stack_create_impl()

afw_stack_t* afw_stack_create_impl ( afw_size_t  entry_size,
afw_size_t  initial_count,
afw_size_t  maximum_count,
afw_boolean_t  create_subpool_pool,
const afw_pool_t p,
afw_xctx_t xctx 
)

Create a stack implementation.

Parameters
entry_size
initial_count
maximum_countor 0 for no limit.
create_subpool_poolif true.
pfor stack.
xctxof caller.
Returns
stack

This is normally called by macro afw_stack_create().

Definition at line 99 of file afw_stack.c.

◆ afw_stack_extend_impl()

void afw_stack_extend_impl ( afw_stack_t instance,
afw_xctx_t xctx 
)

Extend stack implementation.

Parameters
instance
xctxof caller.

This is normally called by a afw_stack_push*() macro.

Definition at line 176 of file afw_stack.c.

◆ afw_stack_internal_set_qualifier_stack()

afw_stack_internal_set_qualifier_stack ( afw_xctx_t xctx)
Todo:
FIXME:

self->maximum_count should be able to be 0, but the entries are the full struct. When an expand happens, all of these structs are copied to another area so they have different addresses.

To allow this, all code must access these entries indirectly by using an index.

Definition at line 31 of file afw_stack.c.

◆ afw_stack_release_impl()

void afw_stack_release_impl ( afw_stack_t instance,
afw_xctx_t xctx 
)

Release stack implementation.

Parameters
instance
xctxof caller.

This is normally called by macro afw_stack_release().

Definition at line 131 of file afw_stack.c.