| 1 | # Copyright 2009, 2010, 2011, 2012, 2014, 2024 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 <http://www.gnu.org/licenses/>. | ||
| 17 | |||
| 18 | package Glib::Ex::SignalBits; | ||
| 19 | 1 | ▶ | use 5.008; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | |||
| 23 | 1 | ▶ | use base 'Exporter'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | 1 | our @EXPORT_OK = qw(accumulator_first | |
| 25 | accumulator_first_defined); | ||
| 26 | |||
| 27 | # uncomment this to run the ### lines | ||
| 28 | #use Smart::Comments; | ||
| 29 | |||
| 30 | 1 | our $VERSION = 17; | |
| 31 | |||
| 32 | 0 | ▶ | sub accumulator_first { |
|
Subroutine
accumulator_first: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 33 | 0 | 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 | 0 | ▶ | sub accumulator_first_defined { |
|
Subroutine
accumulator_first_defined: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 40 | 0 | 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 | 1; | |
| 60 | __END__ | ||