stack_func_proto.h 4.26 KB
/**
 * \file scot/stack_func_proto.h
 * \author  Georg Steffers <georg@steffers.org>
 * \brief   Macro that produces function prototypes for handling stacks
 *          based on linked lists.
 *
 * The macros here create all function prototypes to 
 * the implementations created by the macros in 
 * \link scot/stack_impl.h scot/stack_impl.h\endlink.
 * These macros are normally not called directly within your code but
 * through \link scot/stack_proto.h::GEN_STACK_PROTO GEN_STACK_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  STACK_FUNC_PROTO_H
#define  STACK_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;
 *                   GEN_LIST_FUNC_PROTO should have bin called previously
 *                   in one or the other way.
 * \return           Nothing
 * \post             All function prototypes for a stack of the given 
 *                   datatype are created.
 *
 * \brief This creates the prototypes to all stack functions
 *
 * This creates all the prototypes to the functions that are created by
 * \link scot/stack_impl.h::GEN_STACK_IMPL GEN_STACK_IMPL\endlink in 
 * \link scot/stack_impl.h scot/stack_impl.h\endlink.
 * This provides one with the complete interface to the stack of the given
 * datatype.
 */
#define  GEN_STACK_FUNC_PROTO(type)                                  \
   STATIC                                                            \
   stack_ ## type ## _node_t *                                       \
   stack_ ## type ## _new (                                          \
         stack_ ## type ## _node_t *);                               \
                                                                     \
   STATIC                                                            \
   void                                                              \
   stack_ ## type ## _free (                                         \
         stack_ ## type ## _node_t *);                               \
                                                                     \
   STATIC                                                            \
   stack_ ## type ## _node_t *                                       \
   stack_ ## type ## _push (                                         \
         stack_ ## type ## _node_t *,                                \
         const type                *);                               \
                                                                     \
   STATIC                                                            \
   type *                                                            \
   stack_ ## type ## _pop (                                          \
         stack_ ## type ## _node_t *);                               \
                                                                     \
   STATIC                                                            \
   type *                                                            \
   stack_ ## type ## _top (                                          \
         stack_ ## type ## _node_t *);

#endif   /* STACK_FUNC_PROTO_H */