list_type_proto.h
2.93 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
/**
* \file scot/list_type_proto.h
* \author Georg Steffers <georg@steffers.org>
* \brief Macro that creates the datatype for handling linked lists.
*
* The macros here create all datatype prototypes typedefs declarations 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 normally one did not only
* want the datatypes but also the interface declaration to them.
*
* 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_TYPE_PROTO_H
#define LIST_TYPE_PROTO_H
/**
* \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 datatype prototypes for lists of the given
* datatype are created.
*
* \brief Datatype prototypes to lists.
*
* This creates the prototypes of the datatypes needed to use the
* list interface.
*
* Normally this is not called directly, but by
* \link scot/list_proto.h::GEN_LIST_PROTO GEN_LIST_PROTO()\endlink
* because it is also neccesary to create the interface to this
* datatypes for working lists.
*/
#define GEN_LIST_TYPE_PROTO(type) \
struct list_ ## type ## _node_t; \
typedef struct list_ ## type ## _node_t \
list_ ## type ## _node_t; \
\
typedef int (*list_ ## type ## _cmp_fptr) ( \
const type *, \
const type *); \
\
typedef void (*list_ ## type ## _elem_free_fptr) (type *);
#endif /* LIST_TYPE_PROTO_H */