SourceIds.pm

filter: Statementstmt 81.8% 9 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 86.6% 13 / 15 CC 1 SCAR 0.7
CC
1
Cov
82%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« SignalBits.pm ↑ Summary SignalIds.pm »
1 # Copyright 2008, 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 modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # Glib-Ex-ObjectBits is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # 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::SourceIds;
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 0 ▶use Glib;
Subroutine BEGIN: called CC=1 SCAR=2.6
23  
24 our $VERSION = 17;
25  
26 sub new {
27 my ($class, @ids) = @_;
28 my $self = bless [], $class;
29 $self->add (@ids);
30 return $self;
31 }
32 sub add {
33 my ($self, @ids) = @_;
34 push @$self, @ids;
35 }
36  
37 sub DESTROY {
38 my ($self) = @_;
39 $self->remove;
40 }
41  
42 # g_source_remove() returns false if it didn't find the ID, so no need to
43 # check whether it's already removed (for instance by a false return from
44 # the handler function).
45 #
46 # Recent Glib has made incompatible changes to this so that
47 # g_source_remove() emits a g_log() error message on attempting to remove a
48 # non-existent ID.
49 #
50 sub remove {
51 my ($self) = @_;
52 while (my $id = pop @$self) {
53 Glib::Source->remove ($id);
54 }
55 }
56  
57 1;
58 __END__
« SignalBits.pm ↑ Summary SignalIds.pm »