cvx
Loading...
Searching...
No Matches
stack_cast.h
Go to the documentation of this file.
1#include "cvx/fallback.h"
2
3// clang-format off
4#ifndef INTERFACE
5#error "cvx/interface/stack_cast.h requires INTERFACE to be defined (the struct name, e.g. #define INTERFACE my_stack)"
6#endif
7#ifndef IMPL_DROP
8#error "cvx/interface/stack_cast.h requires IMPL_DROP to be defined"
9#endif
10#ifndef IMPL_CLONE
11#error "cvx/interface/stack_cast.h requires IMPL_CLONE to be defined"
12#endif
13#ifndef IMPL_PUSH
14#error "cvx/interface/stack_cast.h requires IMPL_PUSH to be defined"
15#endif
16#ifndef IMPL_POP
17#error "cvx/interface/stack_cast.h requires IMPL_POP to be defined"
18#endif
19#ifndef IMPL_COUNT
20#error "cvx/interface/stack_cast.h requires IMPL_COUNT to be defined"
21#endif
22#ifndef IMPL_PEEK
23#error "cvx/interface/stack_cast.h requires IMPL_PEEK to be defined"
24#endif
25#ifndef IMPL_REPLACE
26#error "cvx/interface/stack_cast.h requires IMPL_REPLACE to be defined"
27#endif
28// clang-format on
29
30#include "cvx/core.h"
31
32struct VTABLE(INTERFACE) GLOBAL_VTABLE(SNAME, _as_, INTERFACE) = {
33 .drop = IMPL_DROP,
34 .clone = IMPL_CLONE,
35 .push = IMPL_PUSH,
36 .pop = IMPL_POP,
37 .count = IMPL_COUNT,
38 .peek = IMPL_PEEK,
39 .replace = IMPL_REPLACE,
40};
41
42struct INTERFACE FUNC(CVX_(_as_, INTERFACE))(cvx_container *instance)
43{
44 return (struct INTERFACE){
45 .vtable = &GLOBAL_VTABLE(SNAME, _as_, INTERFACE),
46 .instance = instance,
47 };
48}
49
50#undef INTERFACE
#define CVX_(A, B)
Definition core.h:10
#define GLOBAL_VTABLE(SNAME, X, NAME)
Definition core.h:13
Definition deque.h:30
struct INTERFACE_vtable * vtable
Definition deque.h:32
Definition binary_heap.h:135