Skip to content

Commit c978813

Browse files
committed
idl2jsx: reuse HTML files as much as possible
1 parent 2a5c7cc commit c978813

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

idl2jsx/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.bin
1+
!.gitignore
2+
.*

idl2jsx/idl2jsx.pl

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,28 @@
88
use Data::Dumper;
99
use File::Basename qw(dirname);
1010
use Storable qw(lock_retrieve lock_store);
11+
use LWP::UserAgent;
12+
use URI::Escape qw(uri_escape);
13+
use Time::HiRes ();
14+
1115
use constant WIDTH => 68;
1216

13-
# see http://dev.w3.org/2006/webapi/WebIDL/
17+
# see http://www.w3.org/TR/WebIDL/
1418

1519
my $continuous = ($ARGV[0] ~~ "--continuous" && shift @ARGV);
1620

17-
my $db = dirname(__FILE__) . '/.idl2jsx.bin';
18-
1921
my @files = @ARGV;
2022

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+
2133
my %primitive = (
2234
string => 1,
2335
number => 1,
@@ -192,11 +204,19 @@ sub info {
192204
{
193205
my $arg = $file;
194206
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+
195215
if($arg =~ /\.idl$/) {
196-
$arg = "curl -L $arg 2>/dev/null |";
216+
$arg = $filename;
197217
}
198218
else {
199-
$arg = "w3m -dump $arg |";
219+
$arg = "w3m -T text/html -dump $filename |";
200220
}
201221
}
202222
open my($fh), $arg; # magic open!
@@ -326,6 +346,7 @@ sub info {
326346
}
327347
}
328348

349+
# FIXME: Complex regular subexpression recursion limit (32766) exceeded
329350

330351
while($members =~ m{
331352
(?<comments> $rx_comments)
@@ -612,7 +633,7 @@ sub info {
612633
next if $seen{ join(";", $member->{id}, $member->{static}) }++;
613634
}
614635

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};
616637
}
617638
else { # comments, etc.
618639
$s = $member;

0 commit comments

Comments
 (0)