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> '$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 "}"