P99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
p99_list.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 author and copyright holder for this work is */
5 /* (C) copyright 2010-2012 Jens Gustedt, INRIA, France */
6 /* */
7 /* This file is free software; it is part of the P99 project. */
8 /* */
9 /* Licensed under the Apache License, Version 2.0 (the "License"); */
10 /* you may not use this file except in compliance with the License. */
11 /* You may obtain a copy of the License at */
12 /* */
13 /* http://www.apache.org/licenses/LICENSE-2.0 */
14 /* */
15 /* Unless required by applicable law or agreed to in writing, software */
16 /* distributed under the License is distributed on an "AS IS" BASIS, */
17 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
18 /* See the License for the specific language governing permissions and */
19 /* limitations under the License. */
20 /* */
21 #ifndef P99_LIST_H_
22 # define P99_LIST_H_
23 
31 #include "p99_generated.h"
32 
33 #define P00_PRE0(...)
34 #define P00_PRE1(_0, ...) _0
35 
50 #define P99_SELS(N, ...) P99_PASTE2(P00_PRE, N)(__VA_ARGS__)
51 
52 #define P00_SKP0(...) __VA_ARGS__
53 #define P00_SKP1(_0, ...) __VA_ARGS__
54 
55 
59 #define P99_SKP(N, ...) P99_PASTE2(P00_SKP, N)(__VA_ARGS__)
60 
67 #define P99_SUB(N, L, ...) P00_SUB(L, P99_SKP(N, __VA_ARGS__))
68 #define P00_SUB(L, ...) P99_SELS(L, __VA_ARGS__)
69 
76 #define P99_CHS(N, ...) P00_CHS(P99_SKP(N, __VA_ARGS__))
77 #define P00_CHS(...) P00_CHS_(__VA_ARGS__,)
78 #define P00_CHS_(X, ...) X
79 
80 
90 #define P99_DUPL(...) P99_PASTE2(P00_DUPL_0_, P99_IS_LT(P99_NARG(__VA_ARGS__), 2))(__VA_ARGS__)
91 
92 #define P00_DUPL_0_0(...) P00_DUPL(__VA_ARGS__)
93 #define P00_DUPL_0_1(...)
94 
95 #define P00_DUPL_1(...) __VA_ARGS__
96 
97 #define P00_DUPL(N, ...) P00_DUPL_ ## N(__VA_ARGS__)
98 
108 P00_DOCUMENT_NUMBER_ARGUMENT(P99_REP, 0)
109 P00_DOCUMENT_MULTIPLE_ARGUMENT(P99_REP, 1)
110 P00_DOCUMENT_MULTIPLE_ARGUMENT(P99_REP, 2)
111 #define P99_REP(...) P99_PASTE2(P00_REP_0_, P99_IS_LT(P99_NARG(__VA_ARGS__), 2))(__VA_ARGS__)
112 
113 #define P00_REP_0_0(...) P00_REP(__VA_ARGS__)
114 #define P00_REP_0_1(...)
115 
116 #define P00_REP_1(...) __VA_ARGS__
117 
118 #define P00_REP(N, ...) P00_REP_ ## N(__VA_ARGS__)
119 
120 #define P99_BRACKETS(...) P99_PASTE2(P00_BRACKETS_, P99_IS_LT(P99_NARG(__VA_ARGS__), 1))(P99_NARG(__VA_ARGS__), __VA_ARGS__)
121 
122 #define P00_BRACKETS_0(...) P00_BRACKET(__VA_ARGS__)
123 #define P00_BRACKETS_1(...)
124 
125 #define P00_BRACKET_1(...) [__VA_ARGS__]
126 
127 #define P00_BRACKET(N, ...) P00_BRACKET_ ## N(__VA_ARGS__)
128 
129 #define P99_PARENS(...) P99_PASTE2(P00_PARENS_, P99_IS_LT(P99_NARG(__VA_ARGS__), 1))(P99_NARG(__VA_ARGS__), __VA_ARGS__)
130 
131 #define P00_PARENS_0(...) P00_PAREN(__VA_ARGS__)
132 #define P00_PARENS_1(...)
133 
134 #define P00_PAREN_1(...) [__VA_ARGS__]
135 
136 #define P00_PAREN(N, ...) P00_PAREN_ ## N(__VA_ARGS__)
137 
138 #define P99_BRACES(...) P99_PASTE2(P00_BRACES_, P99_IS_LT(P99_NARG(__VA_ARGS__), 1))(P99_NARG(__VA_ARGS__), __VA_ARGS__)
139 
140 #define P00_BRACES_0(...) P00_BRACE(__VA_ARGS__)
141 #define P00_BRACES_1(...)
142 
143 #define P00_BRACE_1(...) [__VA_ARGS__]
144 
145 #define P00_BRACE(N, ...) P00_BRACE_ ## N(__VA_ARGS__)
146 
147 #define P00_MAP_1(MAC, SEP, ...) MAC(__VA_ARGS__)
148 #define P00_MAP_0(...)
149 
150 #define P00_MAP_0_(N, MAC, SEP, ...) P00_MAP_ ## N(MAC, SEP, __VA_ARGS__)
151 
152 #define P00_MAP_(...) P00_MAP_0_(__VA_ARGS__)
153 
154 
159 #endif /* !P99_LIST_H_ */
p99_generated.h
automatically generated macros to handle variadic macros.
P99_REP
#define P99_REP(...)