Started experimenting with perl/python scripts to auto rename incl guards etc.
[aesalon.git] / pl.pl
blob04cedf6a7f60dde622fd5fb1abe96b5b04d78ed0
1 #!/usr/bin/perl
3 my $file = $ARGV[0];
5 my $class = $file;
6 $class =~ s/\.h//;
7 $class =~ s|/|::|;
8 $class =~ s|::(.)|'::'.uc($1)|e;
9 $class =~ s|[Vv]comm|VComm|;
10 $class =~ s|shm|SHM|i;
12 #print "$class\n";
14 open(FILE, "<$file") or die;
16 while(<FILE>) {
17 if(/\@file/) {
18 print `/tmp/newsource.py cppheader $class | grep '\@file'`;
20 elsif(/^#define Aesalon/) {
21 print `/tmp/newsource.py cppheader $class | grep define`;
23 elsif(/^#ifndef Aesalon/) {
24 print `/tmp/newsource.py cppheader $class | grep ifndef`;
26 elsif(/^namespace /) {
27 print `/tmp/newsource.py cppheader $class | grep ^namespace` if !$ns;
28 $ns = 1;
30 elsif(m|^} //|) {
31 print `/tmp/newsource.py cppheader $class | grep '^} //'` if !$close;
32 $close = 1;
34 else {
35 print;