blob: b04e7c72a049c86b7dccbf51926e9cf8673edeb0 (
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
|
#!/usr/bin/env 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 "/* ******************************************************** */"
what_to_make=${1}
shift
include_cc() {
if [[ "${what_to_make}" == "--source" ]] ; then
echo
cat
echo
fi
}
include_hh() {
if [[ "${what_to_make}" == "--header" ]] ; then
echo
cat
echo
fi
}
use_namespace() {
if [[ "${what_to_make}" == "--source" ]] ; then
echo "using namespace $1;"
fi
}
if ! source ${1} ; then
echo "source ${1} failed" 1>&2
exit 7
fi
set | grep '^make_nn_.*() $' | sort -r | \
while read name ; do
name=${name##make_nn_}
name=${name%% *}
if [[ "${what_to_make}" == "--header" ]] ; then
namespace() {
a=${1//::/ }
echo
for ns in ${a}; do
echo "${indent}namespace ${ns}"
echo "${indent}{"
indent+=" "
done
echo "${indent}template <typename>"
echo "${indent}struct ${name};"
}
name() {
class=$1
echo
echo "${indent}template<>"
echo "${indent}struct ${name}<${class}>"
echo "${indent}{"
echo "${indent} static const char * name;"
echo "${indent}};"
}
make_nn_${name}
while [[ -n ${indent} ]]; do
indent=${indent/ }
echo "${indent}}"
done
elif [[ "${what_to_make}" == "--source" ]] ; then
namespace() {
ns="${1}::"
}
name() {
class=$1
class_name=${2:-$1}
echo "const char * ${ns}${name}<${class}>::name = \"${class_name}\";"
}
echo
make_nn_${name}
else
echo "bad argument (expected --header or --source)" 1>&2
exit 1
fi
done
|