aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/preprocessor-gen.h.pump
blob: 0f178ae37ea1d173a96614ccae53011c8704c62e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once

$$ Please, use Pump to convert this source file to valid C++ header.
$$ Note that lines in this file could be longer than 80 symbols.
$var n = 199
$range i 0..n

/*!
  \internal
*/

#ifndef PREPROCESSOR_GEN_H_
#error "Direct inclusion of this file is not allowed, include preprocessor.h"
// For the sake of sane code completion.
#include "preprocessor.h"
#endif
#undef PREPROCESSOR_GEN_H_

////////////////////////////////////////////////////////////////////////////////
#define PP_COUNT_IMPL(...) PP_CONCAT(PP_COUNT_CONST_, PP_COUNT_IMPL_0 __VA_ARGS__)

$for i [[
#define PP_COUNT_CONST_PP_COUNT_IMPL_$i $i

]]

$for i [[
#define PP_COUNT_IMPL_$i(_) PP_COUNT_IMPL_$(i+1)

]]

////////////////////////////////////////////////////////////////////////////////
#define PP_KILL_IMPL(seq, index) PP_CONCAT(PP_KILL_IMPL_, index) seq
#define PP_KILL_IMPL_0

$for i [[
#define PP_KILL_IMPL_$(i+1)(_) PP_KILL_IMPL_$i

]]

////////////////////////////////////////////////////////////////////////////////
#define PP_ELEMENT_IMPL(seq, index) PP_ELEMENT_IMPL_A((PP_CONCAT(PP_ELEMENT_IMPL_, index) seq))
#define PP_ELEMENT_IMPL_A(x) PP_ELEMENT_IMPL_C(PP_ELEMENT_IMPL_B x)
#define PP_ELEMENT_IMPL_B(x, _) x
#define PP_ELEMENT_IMPL_C(x) x
#define PP_ELEMENT_IMPL_0(x) x, PP_NIL

$for i [[
#define PP_ELEMENT_IMPL_$(i+1)(_) PP_ELEMENT_IMPL_$i

]]

////////////////////////////////////////////////////////////////////////////////
#define PP_HEAD_IMPL(seq) PP_ELEMENT_IMPL(seq, 0)

////////////////////////////////////////////////////////////////////////////////
#define PP_TAIL_IMPL(seq) PP_KILL_IMPL(seq, 1)

////////////////////////////////////////////////////////////////////////////////
#define PP_FOR_EACH_IMPL(what, seq) PP_CONCAT(PP_FOR_EACH_IMPL_, PP_COUNT(seq))(what, seq)
#define PP_FOR_EACH_IMPL_0(what, seq)

$for i [[
#define PP_FOR_EACH_IMPL_$(i+1)(what, seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_$i(what, PP_TAIL(seq))

]]
////////////////////////////////////////////////////////////////////////////////
/*!
  \endinternal
*/