line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2009, 2010, 2011, 2012, 2014 Kevin Ryde |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of Glib-Ex-ObjectBits. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Glib-Ex-ObjectBits is free software; you can redistribute it and/or |
6
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License as published |
7
|
|
|
|
|
|
|
# by the Free Software Foundation; either version 3, or (at your option) any |
8
|
|
|
|
|
|
|
# later version. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Glib-Ex-ObjectBits is distributed in the hope that it will be useful, |
11
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
13
|
|
|
|
|
|
|
# Public License for more details. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
16
|
|
|
|
|
|
|
# with Glib-Ex-ObjectBits. If not, see . |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Glib::Ex::SignalBits; |
19
|
1
|
|
|
1
|
|
24059
|
use 5.008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
67
|
|
20
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
21
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
5
|
use base 'Exporter'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
226
|
|
24
|
|
|
|
|
|
|
our @EXPORT_OK = qw(accumulator_first |
25
|
|
|
|
|
|
|
accumulator_first_defined); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
28
|
|
|
|
|
|
|
#use Smart::Comments; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = 16; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub accumulator_first { |
33
|
0
|
|
|
0
|
1
|
|
my ($hint, $acc, $ret) = @_; |
34
|
|
|
|
|
|
|
### accumulator_first(): $acc,$ret |
35
|
0
|
|
|
|
|
|
return (0, # flag, false don't continue emission |
36
|
|
|
|
|
|
|
$ret); # retval |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub accumulator_first_defined { |
40
|
0
|
|
|
0
|
1
|
|
my ($hint, $acc, $ret) = @_; |
41
|
|
|
|
|
|
|
### accumulator_first_defined(): $acc,$ret |
42
|
0
|
|
|
|
|
|
return (! defined $ret, # flag, true to continue if $ret is undef |
43
|
|
|
|
|
|
|
$ret); # retval |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# # signal accumulator returning first true value from handler |
47
|
|
|
|
|
|
|
# sub accumulator_first_true { |
48
|
|
|
|
|
|
|
# my ($hint, $acc, $ret) = @_; |
49
|
|
|
|
|
|
|
# ### _accumulator_first_true: [$acc,$ret] |
50
|
|
|
|
|
|
|
# return (! $ret, # flag, true to continue if no $ret item |
51
|
|
|
|
|
|
|
# $ret); # retval |
52
|
|
|
|
|
|
|
# } |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
# =item C<< Glib::Ex::SignalBits::accumulator_first_true ($hint, $acc, $ret) >> |
55
|
|
|
|
|
|
|
# |
56
|
|
|
|
|
|
|
# Accumulator stopping at and returning the first true value (true in the Perl |
57
|
|
|
|
|
|
|
# boolean sense) from the handlers. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
__END__ |