P99
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
p99_args.h
Go to the documentation of this file.
00001 /* This may look like nonsense, but it really is -*- mode: C -*-             */
00002 /*                                                                           */
00003 /* Except of parts copied from previous work and as explicitly stated below, */
00004 /* the author and copyright holder for this work is                          */
00005 /* (C) copyright  2010-2011 Jens Gustedt, INRIA, France                      */
00006 /*                                                                           */
00007 /* This file is free software; it is part of the P99 project.                */
00008 /* You can redistribute it and/or modify it under the terms of the QPL as    */
00009 /* given in the file LICENSE. It is distributed without any warranty;        */
00010 /* without even the implied warranty of merchantability or fitness for a     */
00011 /* particular purpose.                                                       */
00012 /*                                                                           */
00013 #ifndef     P99_ARGS_H_
00014 # define    P99_ARGS_H_
00015 
00021 #include "p99_paste.h"
00022 
00041 #define P00_NARG(...) P00_NARG_1(__VA_ARGS__)
00042 
00043 #define P00_IS__EQ__(...) ,
00044 
00065 #define P99_IS_EMPTY(...)                                               \
00066 P00_ISEMPTY(                                                            \
00067              /* test if there is just one argument, eventually an empty \
00068                 one */                                                  \
00069              P99_HAS_COMMA(__VA_ARGS__),                                \
00070              /* test if P99_IS__EQ__ together with the argument         \
00071                 adds a comma */                                         \
00072              P99_HAS_COMMA(P00_IS__EQ__ __VA_ARGS__),                   \
00073              /* test if the argument together with a parenthesis        \
00074                 adds a comma */                                         \
00075              P99_HAS_COMMA(__VA_ARGS__ (/*empty*/)),                    \
00076              /* test if placing it between P99_IS__EQ__ and the         \
00077                 parenthesis adds a comma */                             \
00078              P99_HAS_COMMA(P00_IS__EQ__ __VA_ARGS__ (/*empty*/))        \
00079              )
00080 
00081 #define P00_ISEMPTY(_0, _1, _2, _3) P99_HAS_COMMA(P99_PASTE5(P00_IS_EMPTY_CASE_, _0, _1, _2, _3))
00082 #define P00_IS_EMPTY_CASE_0000 P00_IS_EMPTY_CASE_0000
00083 #define P00_IS_EMPTY_CASE_0001 ,
00084 #define P00_IS_EMPTY_CASE_0010 P00_IS_EMPTY_CASE_0010
00085 #define P00_IS_EMPTY_CASE_0011 P00_IS_EMPTY_CASE_0011
00086 #define P00_IS_EMPTY_CASE_0100 P00_IS_EMPTY_CASE_0100
00087 #define P00_IS_EMPTY_CASE_0101 P00_IS_EMPTY_CASE_0101
00088 #define P00_IS_EMPTY_CASE_0110 P00_IS_EMPTY_CASE_0110
00089 #define P00_IS_EMPTY_CASE_0111 P00_IS_EMPTY_CASE_0111
00090 #define P00_IS_EMPTY_CASE_1000 P00_IS_EMPTY_CASE_1000
00091 #define P00_IS_EMPTY_CASE_1001 P00_IS_EMPTY_CASE_1001
00092 #define P00_IS_EMPTY_CASE_1010 P00_IS_EMPTY_CASE_1010
00093 #define P00_IS_EMPTY_CASE_1011 P00_IS_EMPTY_CASE_1011
00094 #define P00_IS_EMPTY_CASE_1100 P00_IS_EMPTY_CASE_1100
00095 #define P00_IS_EMPTY_CASE_1101 P00_IS_EMPTY_CASE_1101
00096 #define P00_IS_EMPTY_CASE_1110 P00_IS_EMPTY_CASE_1110
00097 #define P00_IS_EMPTY_CASE_1111 P00_IS_EMPTY_CASE_1111
00098 
00099 
00100 #define P00_NARG_EMPTY_1(VAL) 0
00101 #define P00_NARG_EMPTY_0(VAL) VAL
00102 
00111 #define P99_NARG(...) P00_NARG__1(P99_IS_EMPTY(__VA_ARGS__), P00_NARG(__VA_ARGS__))
00112 #define P00_NARG__1(B, VAL) P00_NARG__2(P99_PASTE2(P00_NARG_EMPTY_, B), VAL)
00113 #define P00_NARG__2(B, VAL) B(VAL)
00114 
00115 
00136 #define P99_TOK_EQ(TOK, ...)  P00_TOK_EQ_(P99_PASTE3(P00_IS_, TOK, _EQ_), __VA_ARGS__)
00137 #define P00_TOK_EQ_(MAC, ...)  P00_TOK_EQ__(MAC, __VA_ARGS__)
00138 #define P00_TOK_EQ__(MAC, ...) P99_HAS_COMMA(P99_PASTE2(P00_TOK_EQ_, P00_NARG(MAC ## __VA_ARGS__ (~) MAC ## __VA_ARGS__))(~))
00139 
00140 #define P00_TOK_EQ_0(...) ~
00141 #define P00_TOK_EQ_1(...) ~
00142 #define P00_TOK_EQ_2(...) ,
00143 #define P00_TOK_EQ_3(...) ~
00144 #define P00_TOK_EQ_4(...) ~
00145 
00146 
00207 #define P99_VA_ARGS(X) size_t X , ...
00208 
00209 #define P00_FSYMB(NAME) P99_PASTE5(NAME, _f, sy, mb, _)
00210 
00217 #define P99_FSYMB(NAME) P00_FSYMB(NAME)
00218 
00228 #define P99_LENGTH_VA_ARG(...) ((size_t)P99_NARG(__VA_ARGS__)), __VA_ARGS__
00229 
00230 
00276 #define P99_LENGTH_ARR_ARG(T, ...) ((size_t)P99_NARG(__VA_ARGS__)), (T[]){ __VA_ARGS__ }
00277 
00278 
00285 #endif      /* !P99_ARGS_H_ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines