blob: 3683cb4f4f069a6d3f1f4541357fbcfc6350d0d5 (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#!/bin/bash
# vim: set sw=4 sts=4 et tw=0 :
echo -n "/* vim"
echo ": set ro : */"
echo
echo "/* ******************************************************** */"
echo "/* THIS IS A GENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY */"
echo "/* ******************************************************** */"
echo
what_to_make=${1}
shift
for src in ${@} ; do
if ! source ${src} ; then
echo "source ${src} failed" 1>&2
exit 7
fi
done
set | grep '^make_enum_.*() $' | sort -r | \
while read a ; do
a=${a##make_enum_}
a=${a%% *}
want_keys=( )
want_key_descriptions=( )
want_prefix_key=
want_namespace=paludis
key()
{
want_keys=( "${want_keys[@]}" "$1" )
want_key_descriptions=( "${want_key_descriptions[@]}" "$2" )
}
prefix()
{
want_prefix_key=$1
}
namespace()
{
want_namespace=$1
}
doxygen_comment()
{
:
}
make_enum_${a}
if [[ -z "${want_prefix_key}" ]] ; then
echo "no prefix key set for ${a}" 1>&2
exit 1
fi
key()
{
:
}
prefix()
{
:
}
namespace()
{
:
}
if [[ "${what_to_make}" == "--header" ]] ; then
echo "#ifdef DOXYGEN"
echo "// doxygen needs this to get namespaces right"
echo "namespace ${want_namespace}"
echo "{"
echo "#endif"
doxygen_comment()
{
cat
}
make_enum_${a}
echo "enum ${a}"
echo "{"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
echo " ${want_keys[${k}]}, ///< ${want_key_descriptions[${k}]}"
done
echo " last_${want_prefix_key} ///< Number of keys in ${want_namespace}::${a}"
echo "};"
echo
echo "std::ostream &"
echo "operator<< (std::ostream &, const $a &);"
echo
echo "#ifdef DOXYGEN"
echo "// end namespace for doxygen"
echo "}"
echo "#endif"
elif [[ "${what_to_make}" == "--source" ]] ; then
echo "std::ostream &"
echo "${want_namespace}::operator<< (std::ostream & o, const ${a} & s)"
echo "{"
echo " do"
echo " {"
echo " switch (s)"
echo " {"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
echo " case ${want_keys[${k}]}:"
echo " o << \"${want_keys[${k}]#${want_prefix_key}_}\";";
echo " continue;"
echo
done
echo " case last_${want_prefix_key}:"
echo " ;"
echo " }"
echo " throw InternalError(PALUDIS_HERE, \"Bad ${a} value '\" + paludis::stringify("
echo " static_cast<int>(s)));"
echo " } while (false);"
echo
echo " return o;"
echo "}"
echo
else
echo "bad argument (expected --header or --source)" 1>&2
exit 1
fi
done
|