list_func_proto.h
11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/**
* \file scot/list_func_proto.h
* \author Georg Steffers <georg@steffers.org>
* \brief Macro that produce function prototypes for handling
* linked lists.
*
* The macros here create all function prototypes to
* the implementations created by the macros in
* \link scot/list_impl.h scot/list_impl.h\endlink.
* These macros are normally not called directly within your code but
* through \link scot/list_proto.h::GEN_LIST_PROTO GEN_LIST_PROTO\endlink.
* This is because to use the interface declaration
* provided here one will also need the typedefs and datatype prototypes.
*
* Copyright (C)2006 Georg Steffers <georg@steffers.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef LIST_FUNC_PROTO_H
#define LIST_FUNC_PROTO_H
#ifdef GEN_LOCAL
# define STATIC static
#else
# define STATIC
#endif
/**
* \param type the datatype that this list code should handle.
* \pre Type must be a single word typename. If one wants
* to use e.g. lists of structs one has to use typedef
* to create a single word type name like this:
* typedef struct mystruct_t mystruct_t;
* \return Nothing
* \post The function prototypes for manage lists of the given
* datatype are created.
*
* \brief Function prototypes for management.
*
* This creates the prototypes to the functions that are created by
* \link scot/list_man.h::GEN_LIST_MANAGEMENT GEN_LIST_MANAGEMENT\endlink
* in \link scot/list_man.h scot/list_man.h\endlink.
*
* Normally this is not called directly, but by
* \link scot/list_proto.h::GEN_LIST_PROTO GEN_LIST_PROTO()\endlink
* because this defined just a subset of all function prototypes neccesarry
* to handle typesafe lists.
*/
#define GEN_LIST_MAN_PROTO(type) \
STATIC \
void \
list_ ## type ## _set_cmp ( \
list_ ## type ## _cmp_fptr); \
STATIC \
void \
list_ ## type ## _set_elem_free ( \
list_ ## type ## _elem_free_fptr); \
STATIC \
long \
list_ ## type ## _elem_free_is_set (void); \
STATIC \
list_ ## type ## _node_t * \
list_ ## type ## _new ( \
list_ ## type ## _node_t *); \
STATIC \
void \
list_ ## type ## _free ( \
list_ ## type ## _node_t *); \
STATIC \
int \
list_ ## type ## _count ( \
list_ ## type ## _node_t *); \
STATIC \
int \
list_ ## type ## _bol ( \
list_ ## type ## _node_t *, \
list_ ## type ## _node_t *); \
STATIC \
int \
list_ ## type ## _eol ( \
list_ ## type ## _node_t *anchor, \
list_ ## type ## _node_t *node);
/**
* \param type the datatype that this list code should handle.
* \pre Type must be a single word typename. If one wants
* to use e.g. lists of structs one has to use typedef
* to create a single word type name like this:
* typedef struct mystruct_t mystruct_t;
* \return Nothing
* \post The function prototypes to navigate lists of the given
* datatype are created.
*
* \brief Function prototypes for navigation.
*
* This creates the prototypes to the functions that are created by
* \link scot/list_nav.h::GEN_LIST_NAVIGATION GEN_LIST_NAVIGATION\endlink
* in \link scot/list_nav.h scot/list_nav.h\endlink.
*
* Normally this is not called directly, but by
* \link scot/list_proto.h::GEN_LIST_PROTO GEN_LIST_PROTO()\endlink
* because this defined just a subset of all function prototypes neccesarry
* to handle typesafe lists.
*/
#define GEN_LIST_NAV_PROTO(type) \
STATIC \
list_ ## type ## _node_t * \
list_ ## type ## _front ( \
list_ ## type ## _node_t *); \
STATIC \
list_ ## type ## _node_t * \
list_ ## type ## _last ( \
list_ ## type ## _node_t *); \
STATIC \
list_ ## type ## _node_t * \
list_ ## type ## _next ( \
list_ ## type ## _node_t *); \
STATIC \
list_ ## type ## _node_t * \
list_ ## type ## _prev ( \
list_ ## type ## _node_t *); \
STATIC \
list_ ## type ## _node_t * \
list_ ## type ## _find ( \
list_ ## type ## _node_t *, \
const type *); \
STATIC \
list_ ## type ## _node_t * \
list_ ## type ## _find_anchor ( \
list_ ## type ## _node_t *);
/**
* \param type the datatype that this list code should handle.
* \pre Type must be a single word typename. If one wants
* to use e.g. lists of structs one has to use typedef
* to create a single word type name like this:
* typedef struct mystruct_t mystruct_t;
* \return Nothing
* \post The function prototypes to modify lists of the given
* datatype are created.
*
* \brief Function prototypes for modification.
*
* This creates the prototypes to the functions that are created by
* \link scot/list_mod.h::GEN_LIST_MODIFY GEN_LIST_MODIFY\endlink
* in \link scot/list_mod.h scot/list_mod.h\endlink.
*
* Normally this is not called directly, but by
* \link scot/list_proto.h::GEN_LIST_PROTO GEN_LIST_PROTO()\endlink
* because this defined just a subset of all function prototypes neccesarry
* to handle typesafe lists.
*/
#define GEN_LIST_MOD_PROTO(type) \
STATIC \
type * \
list_ ## type ## _retrive ( \
list_ ## type ## _node_t *); \
STATIC \
void \
list_ ## type ## _set ( \
list_ ## type ## _node_t *, \
const type *); \
STATIC \
list_ ## type ## _node_t * \
list_ ## type ## _insert ( \
list_ ## type ## _node_t *, \
const type *); \
STATIC \
list_ ## type ## _node_t * \
list_ ## type ## _delete ( \
list_ ## type ## _node_t *); \
STATIC \
list_ ## type ## _node_t * \
list_ ## type ## _concat ( \
list_ ## type ## _node_t *, \
list_ ## type ## _node_t *);
/**
* \param type the datatype that this list code should handle.
* \pre Type must be a single word typename. If one wants
* to use e.g. lists of structs one has to use typedef
* to create a single word type name like this:
* typedef struct mystruct_t mystruct_t;
* \return Nothing
* \post All function prototypes for a lists of the given
* datatype are created.
*
* \brief Calls GEN_LIST_MAN_PROTO, GEN_LIST_NAV_PROTO and GEN_LIST_MOD_PROTO.
*
* This creates all the prototypes to the functions that are created by
* \link scot/list_impl.h::GEN_LIST_IMPL GEN_LIST_IMPL\endlink in
* \link scot/list_impl.h scot/list_impl.h\endlink.
* This provides one with the complete interface to the list of the given
* datatype.
*/
#define GEN_LIST_FUNC_PROTO(type) \
GEN_LIST_MAN_PROTO (type); \
GEN_LIST_NAV_PROTO (type); \
GEN_LIST_MOD_PROTO (type);
#endif /* LIST_FUNC_PROTO_H */