OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/perl |
| 2 use strict; |
| 3 use warnings; |
| 4 use Exporter; |
| 5 |
| 6 package idltopath; |
| 7 |
| 8 our @ISA = qw( Exporter ); |
| 9 # These are exported by default. |
| 10 our @EXPORT = qw( initIdlToPath idlToPath ); |
| 11 |
| 12 my %idlToPathHash; |
| 13 my $idlToPathFile; |
| 14 |
| 15 sub initIdlToPath |
| 16 { |
| 17 $idlToPathFile = shift; |
| 18 if (!%idlToPathHash) { |
| 19 open(FILE, $idlToPathFile) || die "Could not find generated data file "
. $idlToPathFile; |
| 20 while (<FILE>) |
| 21 { |
| 22 my ($key, $val) = split /,/; |
| 23 # Strip CRLF from val (chomp is picky and will often remove only hal
f). |
| 24 $val =~ s/\s*$//; |
| 25 $idlToPathHash{$key} .= $val; |
| 26 } |
| 27 |
| 28 die if !%idlToPathHash; |
| 29 } |
| 30 } |
| 31 |
| 32 |
| 33 sub idlToPath |
| 34 { |
| 35 my $interface = shift; |
| 36 |
| 37 if (!%idlToPathHash) { |
| 38 die "idltopath is not initialized. Call initIdlToPath(datafile)."; |
| 39 } |
| 40 |
| 41 if ($idlToPathHash{$interface}) { |
| 42 return $idlToPathHash{$interface} . '/'; |
| 43 } elsif ($interface =~ /^SVGPath/ && $idlToPathHash{$interface . "Abs"}) { |
| 44 return $idlToPathHash{$interface . "Abs"} . '/'; |
| 45 } elsif ($interface =~ /^WebKit/ && $idlToPathHash{substr($interface, 6)}) { |
| 46 # WebKitAnimationEvent is in AnimationEvent.idl. |
| 47 # WebKitNamedFlow is in NamedFlow.idl. |
| 48 return $idlToPathHash{substr($interface, 6)} . '/'; |
| 49 } else { |
| 50 my $caller_package; |
| 51 my $caller_filename; |
| 52 my $caller_line; |
| 53 ($caller_package, $caller_filename, $caller_line) = caller; |
| 54 die "Unknown interface '$interface'. Not found in $idlToPathFile. Called
from $caller_filename:$caller_line."; |
| 55 } |
| 56 } |
| 57 |
| 58 # A module must return a truth value. |
| 59 1; |
OLD | NEW |