P99
Main Page
Related Pages
Modules
Data Structures
Data Structures
Data Structure Index
Data Fields
All
a
c
d
e
f
i
l
m
n
r
s
t
w
Functions
c
e
f
i
n
r
Variables
Typedefs
Related Functions
Files
File List
Globals
All
0
1
2
3
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
i
j
l
m
n
p
r
s
t
u
v
w
Variables
Typedefs
_
b
c
d
e
f
i
l
m
o
p
r
s
t
u
v
Enumerations
Enumerator
Macros
0
1
2
3
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Examples
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
p99
p99_args.h
Go to the documentation of this file.
1
/* This may look like nonsense, but it really is -*- mode: C; coding: utf-8 -*- */
2
/* */
3
/* Except for parts copied from previous work and as explicitly stated below, */
4
/* the authors and copyright holders for this work are as follows: */
5
/* (C) copyright 2010-2012 Jens Gustedt, INRIA, France */
6
/* (C) copyright 2012 William Morris */
7
/* */
8
/* This file is free software; it is part of the P99 project. */
9
/* */
10
/* Licensed under the Apache License, Version 2.0 (the "License"); */
11
/* you may not use this file except in compliance with the License. */
12
/* You may obtain a copy of the License at */
13
/* */
14
/* http://www.apache.org/licenses/LICENSE-2.0 */
15
/* */
16
/* Unless required by applicable law or agreed to in writing, software */
17
/* distributed under the License is distributed on an "AS IS" BASIS, */
18
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
19
/* See the License for the specific language governing permissions and */
20
/* limitations under the License. */
21
/* */
22
#ifndef P99_ARGS_H_
23
# define P99_ARGS_H_
24
30
#include "
p99_paste.h
"
31
50
#define P00_NARG(...) P00_NARG_1(__VA_ARGS__)
51
52
#define P00_IS__EQ__(...) ,
53
75
#define P99_IS_EMPTY(...) \
76
P00_ISEMPTY( \
77
/* test if there is just one argument, that might be empty */
\
78
P99_HAS_COMMA(__VA_ARGS__), \
79
/* test if P99_IS__EQ__ together with the argument \
80
adds a comma */
\
81
P99_HAS_COMMA(P00_IS__EQ__ __VA_ARGS__), \
82
/* test if the argument together with a parenthesis \
83
adds a comma */
\
84
P99_HAS_COMMA(__VA_ARGS__ (
/*empty*/
)), \
85
/* test if placing it between P99_IS__EQ__ and the \
86
parenthesis adds a comma */
\
87
P99_HAS_COMMA(P00_IS__EQ__ __VA_ARGS__ (
/*empty*/
)) \
88
)
89
90
#define P00_ISEMPTY(_0, _1, _2, _3) P99_HAS_COMMA(P99_PASTE5(P00_IS_EMPTY_CASE_, _0, _1, _2, _3))
91
#define P00_IS_EMPTY_CASE_0000 P00_IS_EMPTY_CASE_0000
92
#define P00_IS_EMPTY_CASE_0001 ,
93
#define P00_IS_EMPTY_CASE_0010 P00_IS_EMPTY_CASE_0010
94
#define P00_IS_EMPTY_CASE_0011 P00_IS_EMPTY_CASE_0011
95
#define P00_IS_EMPTY_CASE_0100 P00_IS_EMPTY_CASE_0100
96
#define P00_IS_EMPTY_CASE_0101 P00_IS_EMPTY_CASE_0101
97
#define P00_IS_EMPTY_CASE_0110 P00_IS_EMPTY_CASE_0110
98
#define P00_IS_EMPTY_CASE_0111 P00_IS_EMPTY_CASE_0111
99
#define P00_IS_EMPTY_CASE_1000 P00_IS_EMPTY_CASE_1000
100
#define P00_IS_EMPTY_CASE_1001 P00_IS_EMPTY_CASE_1001
101
#define P00_IS_EMPTY_CASE_1010 P00_IS_EMPTY_CASE_1010
102
#define P00_IS_EMPTY_CASE_1011 P00_IS_EMPTY_CASE_1011
103
#define P00_IS_EMPTY_CASE_1100 P00_IS_EMPTY_CASE_1100
104
#define P00_IS_EMPTY_CASE_1101 P00_IS_EMPTY_CASE_1101
105
#define P00_IS_EMPTY_CASE_1110 P00_IS_EMPTY_CASE_1110
106
#define P00_IS_EMPTY_CASE_1111 P00_IS_EMPTY_CASE_1111
107
108
109
#define P00_NARG_EMPTY_1(VAL) 0
110
#define P00_NARG_EMPTY_0(VAL) VAL
111
120
#define P99_NARG(...) P00_NARG__1(P99_IS_EMPTY(__VA_ARGS__), P00_NARG(__VA_ARGS__))
121
#define P00_NARG__1(B, VAL) P00_NARG__2(P99_PASTE2(P00_NARG_EMPTY_, B), VAL)
122
#define P00_NARG__2(B, VAL) B(VAL)
123
124
145
#define P99_TOK_EQ(TOK, ...) P00_TOK_EQ_(P99_PASTE3(P00_IS_, TOK, _EQ_), __VA_ARGS__)
146
#define P00_TOK_EQ_(MAC, ...) P00_TOK_EQ__(MAC, __VA_ARGS__)
147
#define P00_TOK_EQ__(MAC, ...) P99_HAS_COMMA(P99_PASTE2(P00_TOK_EQ_, P00_NARG(MAC ## __VA_ARGS__ (~) MAC ## __VA_ARGS__))(~))
148
149
#define P00_TOK_EQ_0(...) ~
150
#define P00_TOK_EQ_1(...) ~
151
#define P00_TOK_EQ_2(...) ,
152
#define P00_TOK_EQ_3(...) ~
153
#define P00_TOK_EQ_4(...) ~
154
155
216
#define P99_VA_ARGS(X) size_t X , ...
217
218
#define P00_FSYMB(NAME) P99_PASTE5(NAME, _f, sy, mb, _)
219
226
#define P99_FSYMB(NAME) P00_FSYMB(NAME)
227
237
#define P99_LENGTH_VA_ARG(...) ((size_t)P99_NARG(__VA_ARGS__)), __VA_ARGS__
238
239
285
#define P99_LENGTH_ARR_ARG(T, ...) ((size_t)P99_NARG(__VA_ARGS__)), (T[]){ __VA_ARGS__ }
286
287
294
#endif
/* !P99_ARGS_H_ */
p99_paste.h
macros that paste tokens in a predictable way
Generated by
1.8.17