Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_stack.h
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Stack Support
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 #ifndef __AFW_STACK_H__
10 #define __AFW_STACK_H__
11 
12 #include "afw_interface.h"
13 
29 
40 #define afw_stack_create(typedef_name, \
41  initial_count, maximum_count, create_subpool_pool, p, xctx) \
42 (typedef_name *)afw_stack_create_impl( \
43  sizeof(*(((typedef_name *)0))->first), \
44  initial_count, maximum_count, create_subpool_pool, p, xctx);
45 
46 
47 
62  afw_size_t entry_size,
63  afw_size_t initial_count,
64  afw_size_t maximum_count,
65  afw_boolean_t create_subpool_pool,
66  const afw_pool_t *p,
67  afw_xctx_t *xctx);
68 
69 
75 #define afw_stack_release(instance, xctx) \
76 afw_stack_release_impl( &((instance)->pub), xctx)
77 
78 
86 AFW_DECLARE(void)
88  afw_stack_t *instance,
89  afw_xctx_t *xctx);
90 
91 
100 #define afw_stack_copy(instance, count, ptr, p, xctx) \
101 afw_stack_copy_impl( &((instance)->pub), count, ptr, p, xctx)
102 
103 
114 AFW_DECLARE(void)
116  afw_stack_t *instance,
117  afw_size_t *count,
118  const void ***ptr,
119  const afw_pool_t *p,
120  afw_xctx_t *xctx);
121 
122 
131 #define afw_stack_copy_and_release(instance, count, ptr, p, xctx) \
132 afw_stack_copy(instance, (count), (const void ***)(ptr), (p), (xctx)); \
133 afw_stack_release(instance, (xctx))
134 
135 
143 AFW_DECLARE(void)
145  afw_stack_t * instance,
146  afw_xctx_t *xctx);
147 
148 
157 #define afw_stack_is_empty(instance) \
158  ((instance)->top < (instance)->first)
159 
160 
168 #define afw_stack_pop(instance, xctx) \
169  if ((instance)->top < ((instance)->first)) { \
170  AFW_THROW_ERROR_Z(general, "stack underflow", xctx); \
171  } \
172  ((instance)->top)--;
173 
174 
181 #define afw_stack_count(instance, xctx) \
182  ((instance)->top + 1 - (instance)->first))
183 
184 
195 #define afw_stack_push(instance, xctx) \
196  ((instance)->top)++; \
197  if ((instance)->top >= ((instance)->end)) { \
198  afw_stack_extend_impl(&((instance)->pub), xctx); \
199  } \
200  *((instance)->top)
201 
202 
213 #define afw_stack_push_direct(instance, xctx) \
214  ((instance)->top)++; \
215  if ((instance)->top >= ((instance)->end)) { \
216  afw_stack_extend_impl(&((instance)->pub), xctx); \
217  }
218 
219 
230 #define afw_stack_push_and_get_entry(instance, entry, xctx) \
231  afw_stack_push_direct(instance, xctx); \
232  entry = (instance)->top
233 
234 
243 #define afw_stack_set_empty(instance) \
244  (instance)->top = ((instance)->first) - 1
245 
246 
254  afw_xctx_t *xctx);
255 
256 
263 afw_stack_internal_set_evaluation_stack(
264  afw_xctx_t *xctx);
265 
266 
267 AFW_END_DECLARES
268 
271 #endif /* __AFW_STACK_H__ */
#define AFW_DEFINE_INTERNAL(type)
Define an internal function for /src/afw/ source*.c files.
#define AFW_BEGIN_DECLARES
#define AFW_DECLARE(type)
Declare a public afw function.
Interfaceafw_interface header.
_Bool afw_boolean_t
Definition: afw_common.h:373
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
afw_stack_internal_set_qualifier_stack(afw_xctx_t *xctx)
Definition: afw_stack.c:31
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.
Definition: afw_stack.c:148
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
void afw_stack_release_impl(afw_stack_t *instance, afw_xctx_t *xctx)
Release stack implementation.
Definition: afw_stack.c:131
void afw_stack_extend_impl(afw_stack_t *instance, afw_xctx_t *xctx)
Extend stack implementation.
Definition: afw_stack.c:176
Interface afw_pool public struct.
Struct for afw_stack_t typedef.
Definition: afw_common.h:669
Interface afw_xctx public struct.