aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-10-07 19:40:44 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-10-07 19:59:26 -0400
commitc72fda7d695142cc29ac986125234140f6414d97 (patch)
tree179c34e7b570a7f0ce5480457135e054c828b379 /IkiWiki.pm
parentd1061d0094febfc21957554655a8eff4663b00ca (diff)
downloadikiwiki-c72fda7d695142cc29ac986125234140f6414d97.tar
ikiwiki-c72fda7d695142cc29ac986125234140f6414d97.tar.gz
make success and failreason objects carry an influences hash
The hash will be used used to record a set of pages that influenced the result of a pagespec match. The influences are merged together when boolean and/or are encountered in a pagespec. That means using a non-short-circuiting OR operator. And so I use & and | when translating pagespecs, since those bitwise operators can be overloaded. ("and" and "or" cannot, apparently).
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm34
1 files changed, 19 insertions, 15 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 7b1d24c6a..73d2a9763 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -1926,10 +1926,10 @@ sub pagespec_translate ($) {
}gx) {
my $word=$1;
if (lc $word eq 'and') {
- $code.=' &&';
+ $code.=' &';
}
elsif (lc $word eq 'or') {
- $code.=' ||';
+ $code.=' |';
}
elsif ($word eq "(" || $word eq ")" || $word eq "!") {
$code.=' '.$word;
@@ -2015,36 +2015,40 @@ sub glob2re ($) {
package IkiWiki::FailReason;
use overload (
- '""' => sub { ${$_[0]} },
+ '""' => sub { $_[0][0] },
'0+' => sub { 0 },
'!' => sub { bless $_[0], 'IkiWiki::SuccessReason'},
+ '&' => sub { $_[0][1]={%{$_[0][1]}, %{$_[1][1]}}; $_[0] },
+ '|' => sub { $_[1][1]={%{$_[0][1]}, %{$_[1][1]}}; $_[1] },
fallback => 1,
);
-sub new {
- my $class = shift;
- my $value = shift;
- return bless \$value, $class;
-}
-
-package IkiWiki::ErrorReason;
-
-our @ISA = 'IkiWiki::FailReason';
+our @ISA = 'IkiWiki::SuccessReason';
package IkiWiki::SuccessReason;
use overload (
- '""' => sub { ${$_[0]} },
+ '""' => sub { $_[0][0] },
'0+' => sub { 1 },
'!' => sub { bless $_[0], 'IkiWiki::FailReason'},
+ '&' => sub { $_[1][1]={%{$_[0][1]}, %{$_[1][1]}}; $_[1] },
+ '|' => sub { $_[0][1]={%{$_[0][1]}, %{$_[1][1]}}; $_[0] },
fallback => 1,
);
sub new {
my $class = shift;
my $value = shift;
- return bless \$value, $class;
-};
+ return bless [$value, {@_}], $class;
+}
+
+sub influences {
+ return keys %{$_[0][1]};
+}
+
+package IkiWiki::ErrorReason;
+
+our @ISA = 'IkiWiki::FailReason';
package IkiWiki::PageSpec;