codec: append data values to score array
[sheet.git] / codec.plp
index 35b97ed30d5bb29b0b0cf3aa0b68197682238f37..1ae734aee72c00659ec338ffa69ccd57e242a86c 100644 (file)
--- a/codec.plp
+++ b/codec.plp
@@ -16,7 +16,7 @@ Html({
 my $info = do 'codec.inc.pl';
 $info and %{$info} > 1 or Abort("cannot open operator include", 500, $@ // $!);
 
-my %BOOLSCORE = (y => 5, n => 1);
+my %BOOLSCORE = (y => [5, '✔'], n => [1, '✘'], 0 => [0, 'n/a']);
 :>
 <h1>Image codecs</h1>
 
@@ -37,15 +37,21 @@ say '</thead>';
 while (defined (my $feat = shift @feat)) {
        my $featinfo = $info->{feature}->{$feat} or next;
        unshift @feat, @{$_} for $featinfo->{children} // ();
-       $featinfo->{score} or $featinfo->{data} or next;
+       $featinfo->{score} or next;
        print '<tbody>' if $featinfo->{children};
        printf '<tr><th>%s', $featinfo->{name} // $feat;
-       printf('<td class="l%d">%s',
-               (map { $_ && $BOOLSCORE{$_} || $_ || 0 } $featinfo->{score}->{$_}),
-               $featinfo->{data}->{$_} // (map {
-                       $BOOLSCORE{$_} ? ($_ eq 'y' ? '✔' : '✘') : '•' x ($_ - 1)
-               } $featinfo->{score}->{$_}),
-       ) for @codecs;
+       for (@codecs) {
+               my ($score, $data) = map { ref ? @$_ : $_ } $featinfo->{score}->{$_};
+               if (not defined $data) {
+                       if (my $override = $BOOLSCORE{$score}) {
+                               ($score, $data) = @{$override};
+                       }
+                       else {
+                               $data = '•' x ($score - 1);
+                       }
+               }
+               printf '<td class="l%d">%s', $score, $data;
+       }
        say '</td>';
 }