Metalang99
1.13.3
Full-blown preprocessor metaprogramming
seq.h
Go to the documentation of this file.
1
34
#ifndef ML99_SEQ_H
35
#define ML99_SEQ_H
36
37
#include <metalang99/nat/inc.h>
38
#include <metalang99/priv/tuple.h>
39
#include <metalang99/priv/util.h>
40
41
#include <
metalang99/lang.h
>
42
58
#define ML99_seqIsEmpty(seq) ML99_call(ML99_seqIsEmpty, seq)
59
74
#define ML99_seqGet(i) ML99_PRIV_CAT(ML99_PRIV_seqGet_, i)
75
91
#define ML99_seqTail(seq) ML99_call(ML99_seqTail, seq)
92
110
#define ML99_seqForEach(f, seq) ML99_call(ML99_seqForEach, f, seq)
111
127
#define ML99_seqForEachI(f, seq) ML99_call(ML99_seqForEachI, f, seq)
128
129
#define ML99_SEQ_IS_EMPTY(seq) ML99_PRIV_NOT(ML99_PRIV_CONTAINS_COMMA(ML99_PRIV_COMMA seq))
130
#define ML99_SEQ_GET(i) ML99_PRIV_CAT(ML99_PRIV_SEQ_GET_, i)
131
#define ML99_SEQ_TAIL(seq) ML99_PRIV_TAIL(ML99_PRIV_COMMA seq)
132
133
#ifndef DOXYGEN_IGNORE
134
135
#define ML99_seqIsEmpty_IMPL(seq) v(ML99_SEQ_IS_EMPTY(seq))
136
137
#define ML99_PRIV_seqGet_0(seq) ML99_call(ML99_PRIV_seqGet_0, seq)
138
#define ML99_PRIV_seqGet_1(seq) ML99_call(ML99_PRIV_seqGet_1, seq)
139
#define ML99_PRIV_seqGet_2(seq) ML99_call(ML99_PRIV_seqGet_2, seq)
140
#define ML99_PRIV_seqGet_3(seq) ML99_call(ML99_PRIV_seqGet_3, seq)
141
#define ML99_PRIV_seqGet_4(seq) ML99_call(ML99_PRIV_seqGet_4, seq)
142
#define ML99_PRIV_seqGet_5(seq) ML99_call(ML99_PRIV_seqGet_5, seq)
143
#define ML99_PRIV_seqGet_6(seq) ML99_call(ML99_PRIV_seqGet_6, seq)
144
#define ML99_PRIV_seqGet_7(seq) ML99_call(ML99_PRIV_seqGet_7, seq)
145
146
#define ML99_PRIV_seqGet_0_IMPL(seq) v(ML99_SEQ_GET(0)(seq))
147
#define ML99_PRIV_seqGet_1_IMPL(seq) v(ML99_SEQ_GET(1)(seq))
148
#define ML99_PRIV_seqGet_2_IMPL(seq) v(ML99_SEQ_GET(2)(seq))
149
#define ML99_PRIV_seqGet_3_IMPL(seq) v(ML99_SEQ_GET(3)(seq))
150
#define ML99_PRIV_seqGet_4_IMPL(seq) v(ML99_SEQ_GET(4)(seq))
151
#define ML99_PRIV_seqGet_5_IMPL(seq) v(ML99_SEQ_GET(5)(seq))
152
#define ML99_PRIV_seqGet_6_IMPL(seq) v(ML99_SEQ_GET(6)(seq))
153
#define ML99_PRIV_seqGet_7_IMPL(seq) v(ML99_SEQ_GET(7)(seq))
154
155
#define ML99_PRIV_SEQ_GET_0(seq) ML99_PRIV_UNTUPLE(ML99_PRIV_HEAD(ML99_PRIV_SEQ_SEPARATE seq))
156
#define ML99_PRIV_SEQ_GET_1(seq) ML99_PRIV_SEQ_GET_0(ML99_SEQ_TAIL(seq))
157
#define ML99_PRIV_SEQ_GET_2(seq) ML99_PRIV_SEQ_GET_1(ML99_SEQ_TAIL(seq))
158
#define ML99_PRIV_SEQ_GET_3(seq) ML99_PRIV_SEQ_GET_2(ML99_SEQ_TAIL(seq))
159
#define ML99_PRIV_SEQ_GET_4(seq) ML99_PRIV_SEQ_GET_3(ML99_SEQ_TAIL(seq))
160
#define ML99_PRIV_SEQ_GET_5(seq) ML99_PRIV_SEQ_GET_4(ML99_SEQ_TAIL(seq))
161
#define ML99_PRIV_SEQ_GET_6(seq) ML99_PRIV_SEQ_GET_5(ML99_SEQ_TAIL(seq))
162
#define ML99_PRIV_SEQ_GET_7(seq) ML99_PRIV_SEQ_GET_6(ML99_SEQ_TAIL(seq))
163
164
#define ML99_PRIV_SEQ_SEPARATE(...) (__VA_ARGS__),
165
166
#define ML99_seqTail_IMPL(seq) v(ML99_SEQ_TAIL(seq))
167
168
#define ML99_seqForEach_IMPL(f, seq) \
169
ML99_PRIV_CAT(ML99_PRIV_seqForEach_, ML99_SEQ_IS_EMPTY(seq))(f, seq)
170
#define ML99_PRIV_seqForEach_1(...) v(ML99_PRIV_EMPTY())
171
#define ML99_PRIV_seqForEach_0(f, seq) \
172
ML99_TERMS( \
173
ML99_appl_IMPL(f, ML99_SEQ_GET(0)(seq)), \
174
ML99_callUneval(ML99_seqForEach, f, ML99_SEQ_TAIL(seq)))
175
176
#define ML99_seqForEachI_IMPL(f, seq) ML99_PRIV_seqForEachIAux_IMPL(f, 0, seq)
177
#define ML99_PRIV_seqForEachIAux_IMPL(f, i, seq) \
178
ML99_PRIV_CAT(ML99_PRIV_seqForEachI_, ML99_SEQ_IS_EMPTY(seq))(f, i, seq)
179
#define ML99_PRIV_seqForEachI_1(...) v(ML99_PRIV_EMPTY())
180
#define ML99_PRIV_seqForEachI_0(f, i, seq) \
181
ML99_TERMS( \
182
ML99_appl2_IMPL(f, i, ML99_SEQ_GET(0)(seq)), \
183
ML99_callUneval(ML99_PRIV_seqForEachIAux, f, ML99_PRIV_INC(i), ML99_SEQ_TAIL(seq)))
184
185
// Arity specifiers {
186
187
#define ML99_seqIsEmpty_ARITY 1
188
#define ML99_seqTail_ARITY 1
189
#define ML99_seqForEach_ARITY 2
190
#define ML99_seqForEachI_ARITY 2
191
192
#define ML99_PRIV_seqGet_0_ARITY 1
193
#define ML99_PRIV_seqGet_1_ARITY 1
194
#define ML99_PRIV_seqGet_2_ARITY 1
195
#define ML99_PRIV_seqGet_3_ARITY 1
196
#define ML99_PRIV_seqGet_4_ARITY 1
197
#define ML99_PRIV_seqGet_5_ARITY 1
198
#define ML99_PRIV_seqGet_6_ARITY 1
199
#define ML99_PRIV_seqGet_7_ARITY 1
200
// } (Arity specifiers)
201
202
#endif
// DOXYGEN_IGNORE
203
204
#endif
// ML99_SEQ_H
lang.h
The core metalanguage.
include
metalang99
seq.h
Generated by
1.9.4