1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
File=$1
EnumType=$2
echo "// **** DO NOT modify this file! ****"
echo "// This file is generated by cmd:"
echo "// gen_statistics.bash $@"
echo "iterable_named_enum! {"
echo " #[derive(Debug, Copy, Clone, PartialEq, Eq)]"
echo " #[repr(u32)]"
echo " pub enum $EnumType {"
perl -n0e '/const std::vector<std::pair<'$EnumType's, std::string>> '$EnumType'sNameMap.*?\};/sm && print $&' $File |
perl -n0e '
while (/\{\s*([\w_]+)\s*,.*?"(.*?)"/smg) {
$val = $2;
$name = lc($1);
$name =~ s/(\b|_)(\w)/\U$2/g;
print " $name(\"$val\"),\n"
}'
echo " }"
echo "}"
|