File: gen_statistics.bash

package info (click to toggle)
rust-librocksdb-sys 0.17.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 256 kB
  • sloc: ansic: 44; sh: 19; makefile: 9
file content (19 lines) | stat: -rw-r--r-- 589 bytes parent folder | download
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 "}"