|
8 | 8 | use Data::Dumper;
|
9 | 9 | use File::Basename qw(dirname);
|
10 | 10 | use Storable qw(lock_retrieve lock_store);
|
| 11 | +use LWP::UserAgent; |
| 12 | +use URI::Escape qw(uri_escape); |
| 13 | +use Time::HiRes (); |
| 14 | + |
11 | 15 | use constant WIDTH => 68;
|
12 | 16 |
|
13 |
| -# see http://dev.w3.org/2006/webapi/WebIDL/ |
| 17 | +# see http://www.w3.org/TR/WebIDL/ |
14 | 18 |
|
15 | 19 | my $continuous = ($ARGV[0] ~~ "--continuous" && shift @ARGV);
|
16 | 20 |
|
17 |
| -my $db = dirname(__FILE__) . '/.idl2jsx.bin'; |
18 |
| - |
19 | 21 | my @files = @ARGV;
|
20 | 22 |
|
| 23 | +my $root = dirname(__FILE__); |
| 24 | +my $db = "$root/.idl2jsx.bin"; |
| 25 | +mkdir "$root/.save"; |
| 26 | + |
| 27 | +{ |
| 28 | + my $t0 = [Time::HiRes::gettimeofday()]; |
| 29 | + END { |
| 30 | + info(sprintf "elapsed %.02f sec.", Time::HiRes::tv_interval($t0)) if $t0 } |
| 31 | +} |
| 32 | + |
21 | 33 | my %primitive = (
|
22 | 34 | string => 1,
|
23 | 35 | number => 1,
|
@@ -192,11 +204,19 @@ sub info {
|
192 | 204 | {
|
193 | 205 | my $arg = $file;
|
194 | 206 | if($arg =~ /^https?:/) {
|
| 207 | + state $ua = LWP::UserAgent->new(); |
| 208 | + my $filename = "$root/.save/" . uri_escape($arg); |
| 209 | + my $res = $ua->mirror($arg, $filename); |
| 210 | + |
| 211 | + if($res->header("Last-Modified")) { |
| 212 | + info("Last-Modified: ", $res->header("Last-Modified")); |
| 213 | + } |
| 214 | + |
195 | 215 | if($arg =~ /\.idl$/) {
|
196 |
| - $arg = "curl -L $arg 2>/dev/null |"; |
| 216 | + $arg = $filename; |
197 | 217 | }
|
198 | 218 | else {
|
199 |
| - $arg = "w3m -dump $arg |"; |
| 219 | + $arg = "w3m -T text/html -dump $filename |"; |
200 | 220 | }
|
201 | 221 | }
|
202 | 222 | open my($fh), $arg; # magic open!
|
@@ -326,6 +346,7 @@ sub info {
|
326 | 346 | }
|
327 | 347 | }
|
328 | 348 |
|
| 349 | + # FIXME: Complex regular subexpression recursion limit (32766) exceeded |
329 | 350 |
|
330 | 351 | while($members =~ m{
|
331 | 352 | (?<comments> $rx_comments)
|
@@ -612,7 +633,7 @@ sub info {
|
612 | 633 | next if $seen{ join(";", $member->{id}, $member->{static}) }++;
|
613 | 634 | }
|
614 | 635 |
|
615 |
| - say "\t", sprintf '/** @see %s */', $member->{spec} if $member->{spec}; |
| 636 | + say "\t", sprintf '/** @see %s */', $member->{spec} if $member->{spec} && $def->{spec} ne $member->{spec}; |
616 | 637 | }
|
617 | 638 | else { # comments, etc.
|
618 | 639 | $s = $member;
|
|
0 commit comments