3 my ($BINDIR, $BINNAME) = $0 =~ m!^(.*)/(.*)!;
5 print STDERR <<"fnord";
6 usage: $BINNAME <module> <class-base>
7 eg: $BINNAME base QuadSet
10 $BINNAME gedsubed QuadSet
11 Should be in module sub-directory (Reve/ or Alieve/).
12 Note that GL and Editor suffixes are not present!
17 my $MODULE = $ARGV[0];
19 # die "'$MODULE' not a directory" unless -d $MODULE;
21 %suff = ( 'gl' => 'GL', 'ged' => 'Editor', 'gedsubed' => 'Editor');
23 my $CLASS = $STEM . $suff{$MODULE};
25 if ($MODULE eq 'gedsubed') {
27 $XXCLASS = $STEM . 'SubEditor';
31 # my $H_NAME = "$MODULE/$CLASS.h";
32 # my $C_NAME = "$MODULE/$CLASS.cxx";
33 my $H_NAME = "$CLASS.h";
34 my $C_NAME = "$CLASS.cxx";
36 die "File '$H_NAME' already exists" if -e $H_NAME;
37 die "File '$C_NAME' already exists" if -e $C_NAME;
40 my ($stem, $suff) = @_;
41 my $file1 = "$stem-$MODULE.$suff";
42 return $file1 if -e $file1;
43 my $file2 = "$stem.$suff";
44 return $file2 if -e $file2;
45 die "Skeleton file not found neither as '$file 1' nor '$file2'";
48 my $SKEL_H_NAME = find_skel(".SKEL", "h");
49 my $SKEL_C_NAME = find_skel(".SKEL", "cxx");
51 print "Using skeleton files '$SKEL_H_NAME' and '$SKEL_C_NAME'\n";
53 my ($skel_h, $skel_c);
55 my $ex_sla = $/; undef $/;
56 open H, "$SKEL_H_NAME" or die "can't open $SKEL_H_NAME";
57 $skel_h = <H>; close H;
58 open C, "$SKEL_C_NAME" or die "can't open $SKEL_C_NAME";
59 $skel_c = <C>; close C;
63 print "Replacing CLASS -> $CLASS, STEM -> $STEM.\n";
65 for $f ($skel_h, $skel_c) {
66 $f =~ s/XXCLASS/$XXCLASS/g if ($replace_xxclass);
67 $f =~ s/CLASS/$CLASS/g;
71 print "Writing files '$H_NAME', '$C_NAME'.\n";
74 die "can't open $H_NAME";
75 print H $skel_h; close H;
77 die "can't open $C_NAME";
78 print H $skel_c; close H;
81 print "# Now you should also edit the link-def file.\n";
82 print "# Remember to run 'make depend'.\n";