| 1 | package POE::Sugar::Attributes::SymInfo; | ||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use Class::Struct; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Attribute::Handlers; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||
| 7 | 5 | struct (__PACKAGE__, | |||||||||||||||||||||||||||||
| 8 | [ | ||||||||||||||||||||||||||||||
| 9 | 'flags' => '$', | ||||||||||||||||||||||||||||||
| 10 | 'coderef' => '$', | ||||||||||||||||||||||||||||||
| 11 | '_name' => '$', | ||||||||||||||||||||||||||||||
| 12 | 'package' => '$', | ||||||||||||||||||||||||||||||
| 13 | 'events' => '@', | ||||||||||||||||||||||||||||||
| 14 | 'data' => '*@' | ||||||||||||||||||||||||||||||
| 15 | ]); | ||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||
| 17 | 35 | ▶ | sub name { | ||||||||||||||||||||||||||||
|
Subroutine
name: called CC=4 SCAR=14.7
| |||||||||||||||||||||||||||||||
| 18 | 35 | my ($self,$pkg) = @_; | |||||||||||||||||||||||||||||
| 19 | 35 | ▶ | if($self->_name) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 20 | 10 | return $self->_name; | |||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||
| 23 | 25 | ▶ | $pkg ||= $self->package; | ||||||||||||||||||||||||||||
|
Condition33%1/3
$pkg ||= $self->package
MC/DC0%0/2
$pkg ||= $self->package
$pkg
$self->package
Truth table33%1/3
A ||= B
A= $pkgB= $self->package
| |||||||||||||||||||||||||||||||
| 24 | 25 | my $glob = Attribute::Handlers::findsym($pkg, $self->coderef); | |||||||||||||||||||||||||||||
| 25 | 25 | ▶ | if(!$glob) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 26 | 0 | warn("Can't find symbol for " . $self->coderef); | |||||||||||||||||||||||||||||
| 27 | 0 | return; | |||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||
| 29 | 25 | my $symname = *$glob{NAME}; | |||||||||||||||||||||||||||||
| 30 | 25 | $self->_name($symname); | |||||||||||||||||||||||||||||
| 31 | 25 | return $symname; | |||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||
| 34 | package POE::Sugar::Attributes::PkgInfo; | ||||||||||||||||||||||||||||||
| 35 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 36 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 37 | 5 | ▶ | use Class::Struct; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||
| 39 | 5 | struct (__PACKAGE__, | |||||||||||||||||||||||||||||
| 40 | [ | ||||||||||||||||||||||||||||||
| 41 | 'ctor' => '$', | ||||||||||||||||||||||||||||||
| 42 | 'dtor' => '$', | ||||||||||||||||||||||||||||||
| 43 | 'events' => '%', | ||||||||||||||||||||||||||||||
| 44 | 'catcher' => '$', | ||||||||||||||||||||||||||||||
| 45 | 'reaper' => '$', | ||||||||||||||||||||||||||||||
| 46 | 'sigs' => '%', | ||||||||||||||||||||||||||||||
| 47 | 'syms' => '%' | ||||||||||||||||||||||||||||||
| 48 | ]); | ||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||
| 51 | package POE::Sugar::Attributes; | ||||||||||||||||||||||||||||||
| 52 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 53 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||
| 55 | 5 | ▶ | use POE; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 56 | 5 | ▶ | use POE::Session; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||
| 58 | 5 | our $VERSION = 0.02; | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||
| 60 | 5 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 61 | 5 | ▶ | use Log::Fu { level => "info" }; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 62 | 5 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 63 | 5 | our @EXPORT_OK; | |||||||||||||||||||||||||||||
| 64 | 5 | ▶ | BEGIN { | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 65 | 5 | @EXPORT_OK = qw( | |||||||||||||||||||||||||||||
| 66 | wire_new_session | ||||||||||||||||||||||||||||||
| 67 | wire_current_session | ||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||
| 71 | 5 | ▶ | use Attribute::Handlers; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||
| 73 | 5 | ▶ | use Constant::Generate [qw( | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 74 | PA_EVENT | ||||||||||||||||||||||||||||||
| 75 | PA_CTOR | ||||||||||||||||||||||||||||||
| 76 | PA_DTOR | ||||||||||||||||||||||||||||||
| 77 | PA_TIMER | ||||||||||||||||||||||||||||||
| 78 | PA_CATCHER | ||||||||||||||||||||||||||||||
| 79 | PA_REAPER | ||||||||||||||||||||||||||||||
| 80 | PA_SIGHANDLER | ||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||
| 82 | PA_NAME_RESOLVE | ||||||||||||||||||||||||||||||
| 83 | )], -type => 'bitfield', | ||||||||||||||||||||||||||||||
| 84 | 5 | -start_at => 1; | |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||
| 86 | 5 | ▶ | use Constant::Generate [qw( | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 87 | FLD_FLAGS | ||||||||||||||||||||||||||||||
| 88 | FLD_DATA | ||||||||||||||||||||||||||||||
| 89 | FLD_CODE | ||||||||||||||||||||||||||||||
| 90 | 5 | )]; | |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||
| 92 | 5 | my %map_names; | |||||||||||||||||||||||||||||
| 93 | my %pkgcache; | ||||||||||||||||||||||||||||||
| 94 | 5 | my %const2hkey; | |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||
| 96 | 5 | my ($HKEY_CATCHER, | |||||||||||||||||||||||||||||
| 97 | $HKEY_REAPER, | ||||||||||||||||||||||||||||||
| 98 | $HKEY_SIGHANDLERS | ||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||
| 101 | 5 | %map_names = ( | |||||||||||||||||||||||||||||
| 102 | Start => PA_CTOR, | ||||||||||||||||||||||||||||||
| 103 | Stop => PA_DTOR, | ||||||||||||||||||||||||||||||
| 104 | Event => PA_EVENT, | ||||||||||||||||||||||||||||||
| 105 | State => PA_EVENT, | ||||||||||||||||||||||||||||||
| 106 | Recurring=> PA_TIMER, | ||||||||||||||||||||||||||||||
| 107 | Catcher => PA_CATCHER, | ||||||||||||||||||||||||||||||
| 108 | Reaper => PA_REAPER, | ||||||||||||||||||||||||||||||
| 109 | SigHandler=> PA_SIGHANDLER, | ||||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||
| 112 | #Ensure we don't actually collide with a real symbol | ||||||||||||||||||||||||||||||
| 113 | 5 | $HKEY_CATCHER = __PACKAGE__ . "__HKEY_CATCHER__"; | |||||||||||||||||||||||||||||
| 114 | 5 | $HKEY_REAPER = __PACKAGE__ . "__HKEY_REAPER__"; | |||||||||||||||||||||||||||||
| 115 | 5 | $HKEY_SIGHANDLERS = __PACKAGE__ . "__HKEY_SIGHANDLERS__"; | |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||
| 117 | 5 | %const2hkey = ( | |||||||||||||||||||||||||||||
| 118 | PA_CATCHER, $HKEY_CATCHER, | ||||||||||||||||||||||||||||||
| 119 | PA_REAPER, $HKEY_REAPER | ||||||||||||||||||||||||||||||
| 120 | ); | ||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||
| 124 | 25 | ▶ | sub _get_infos { | ||||||||||||||||||||||||||||
|
Subroutine
_get_infos: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||||
| 125 | 25 | my ($pkg,$cv) = @_; | |||||||||||||||||||||||||||||
| 126 | 25 | ▶ | my $pkginfo = ($pkgcache{$pkg} ||= | ||||||||||||||||||||||||||||
|
Condition66%2/3
$pkgcache{$pkg} ||= "POE::Sugar::Attributes::PkgInfo"->new
MC/DC0%0/2
$pkgcache{$pkg} ||= "POE::Sugar::Attributes::PkgInfo"->new
$pkgcache{$pkg}
"POE::Sugar::Attributes::PkgInfo"->new
Truth table66%2/3
A ||= B
A= $pkgcache{$pkg}B= "POE::Sugar::Attributes::PkgInfo"->new
| |||||||||||||||||||||||||||||||
| 127 | POE::Sugar::Attributes::PkgInfo->new()); | ||||||||||||||||||||||||||||||
| 128 | 25 | ▶ | my $syminfo = ($pkginfo->syms->{$cv+0} ||= | ||||||||||||||||||||||||||||
|
Condition33%1/3
$pkginfo->syms->{$cv + 0} ||= "POE::Sugar::Attributes::SymInfo"->new("package", $pkg, "coderef", $cv)
MC/DC0%0/2
$pkginfo->syms->{$cv + 0} ||= "POE::Sugar::Attributes::SymInfo"->new("package", $pkg, "coderef", $cv)
$pkginfo->syms->{$cv + 0}
"POE::Sugar::Attributes::SymInfo"->new("package", $pkg, "coderef", $cv)
Truth table33%1/3
A ||= B
A= $pkginfo->syms->{$cv + 0}B= "POE::Sugar::Attributes::SymInfo"->new("package", $pkg, "coderef", $cv)
| |||||||||||||||||||||||||||||||
| 129 | POE::Sugar::Attributes::SymInfo->new( | ||||||||||||||||||||||||||||||
| 130 | package => $pkg, | ||||||||||||||||||||||||||||||
| 131 | coderef => $cv) | ||||||||||||||||||||||||||||||
| 132 | ); | ||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||
| 134 | 25 | return ($pkginfo,$syminfo); | |||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||
| 137 | 25 | ▶ | sub _poe_attr_handler :ATTR(CODE) { | ||||||||||||||||||||||||||||
|
Subroutine
_poe_attr_handler: called CC=19 SCAR=29.9
| |||||||||||||||||||||||||||||||
| 138 | 25 | my ($pkg,undef,$cv,$attr,$data) = @_; | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||
| 140 | 25 | my @opt_array; | |||||||||||||||||||||||||||||
| 141 | my %opt_hash; | ||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||
| 143 | 25 | ▶ | if(ref $data) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 144 | 10 | ▶ | if(@$data % 2 == 0) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 145 | 6 | %opt_hash = @$data; | |||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||
| 147 | 10 | @opt_array = @$data; | |||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||
| 150 | 25 | my $flag = $map_names{$attr}; | |||||||||||||||||||||||||||||
| 151 | 25 | ▶ | die "No such attribute: $attr" unless defined $flag; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||
| 153 | 25 | my ($pkg_info,$sym_info) = _get_infos($pkg, $cv); | |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||
| 155 | 25 | ▶ | $sym_info->flags( ($sym_info->flags || 0) | $flag ); | ||||||||||||||||||||||||||||
|
Condition50%1/2
$sym_info->flags || 0
MC/DC0%0/1
$sym_info->flags || 0
$sym_info->flags
Truth table50%1/2
A
A= $sym_info->flags
| |||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||
| 157 | 25 | ▶ | if($flag == PA_EVENT) | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 158 | { | ||||||||||||||||||||||||||||||
| 159 | 6 | ▶ | if(@opt_array) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 160 | 3 | push @{$sym_info->events}, @opt_array; | |||||||||||||||||||||||||||||
| 161 | } else { | ||||||||||||||||||||||||||||||
| 162 | 3 | push @{$sym_info->events}, \undef; | |||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||
| 166 | elsif ($flag == PA_TIMER) | ||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||
| 168 | 5 | my $interval = delete $opt_hash{Interval}; | |||||||||||||||||||||||||||||
| 169 | 5 | ▶ | die("Timer must have interval ()") unless $interval; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 170 | 5 | my $evname = $opt_hash{Name}; | |||||||||||||||||||||||||||||
| 171 | 5 | ▶ | $evname ||= \undef; | ||||||||||||||||||||||||||||
|
Condition100%2/2
$evname ||= \(undef)
MC/DC100%1/1
$evname ||= \(undef)
$evname
Truth table100%2/2
A
A= $evname
| |||||||||||||||||||||||||||||||
| 172 | 5 | $sym_info->data->[PA_TIMER] = [ $evname, $interval ]; | |||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||
| 175 | ▶ | elsif ($flag == PA_CTOR || $flag == PA_DTOR) | |||||||||||||||||||||||||||||
|
Condition100%3/3
$flag == 4 or $flag == 8
MC/DC100%2/2
$flag == 4 or $flag == 8
$flag == 4
$flag == 8
Truth table100%3/3
A or B
A= $flag == 4B= $flag == 8
| |||||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||||
| 177 | 10 | ▶ | if($flag == PA_CTOR) { | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 178 | 5 | $pkg_info->ctor($sym_info); | |||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||
| 180 | elsif($flag == PA_DTOR) { | ||||||||||||||||||||||||||||||
| 181 | 5 | $pkg_info->dtor($sym_info); | |||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||
| 183 | #Do we have anything to do here? | ||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||
| 187 | elsif ($flag == PA_CATCHER) { | ||||||||||||||||||||||||||||||
| 188 | 0 | $pkg_info->catcher($sym_info); | |||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||
| 191 | elsif ($flag == PA_REAPER) { | ||||||||||||||||||||||||||||||
| 192 | 2 | $pkg_info->reaper($sym_info); | |||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||
| 195 | elsif ($flag == PA_SIGHANDLER) { | ||||||||||||||||||||||||||||||
| 196 | 2 | ▶ | if(!ref $data) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 197 | 0 | push @opt_array, $data; | |||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||
| 199 | 2 | foreach my $signame (@opt_array) { | |||||||||||||||||||||||||||||
| 200 | 2 | log_debug("Found signal $signame"); | |||||||||||||||||||||||||||||
| 201 | 2 | $pkg_info->sigs->{$signame} = $sym_info; | |||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||
| 204 | 5 | ▶ | } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||
| 206 | 5 | ▶ | sub Start :ATTR(CODE) { goto &_poe_attr_handler } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
Start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 207 | 5 | ▶ | sub Stop :ATTR(CODE) { goto &_poe_attr_handler } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
Stop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 208 | 5 | ▶ | sub Event :ATTR(CODE) { goto &_poe_attr_handler } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
Event: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub State :ATTR(CODE) { goto &_poe_attr_handler } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
State: not called CC=1 SCAR=0.2
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 210 | 5 | ▶ | sub Recurring:ATTR(CODE) { goto &_poe_attr_handler } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
Recurring: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub Catcher :ATTR(CODE) { goto &_poe_attr_handler } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
Catcher: not called CC=1 SCAR=0.2
Pod
documented
| |||||||||||||||||||||||||||||||
| 212 | 5 | ▶ | sub Reaper :ATTR(CODE) { goto &_poe_attr_handler } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
Reaper: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 213 | 5 | ▶ | sub SigHandler:ATTR(CODE){ goto &_poe_attr_handler } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
SigHandler: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||
| 215 | 6 | ▶ | sub _get_params { | ||||||||||||||||||||||||||||
|
Subroutine
_get_params: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||
| 216 | 6 | my $pkg = shift; | |||||||||||||||||||||||||||||
| 217 | 6 | my $pkg_info = $pkgcache{$pkg}; | |||||||||||||||||||||||||||||
| 218 | 6 | ▶ | die("Don't have anything registered for $pkg") | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 219 | unless defined $pkg_info; | ||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||
| 221 | 6 | my ($ctor,$dtor,$catcher,$reaper); | |||||||||||||||||||||||||||||
| 222 | 6 | my @events; | |||||||||||||||||||||||||||||
| 223 | 6 | my @timers; | |||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||
| 225 | 6 | foreach my $sym_info (values %{$pkg_info->syms}) { | |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||
| 227 | 25 | my $symname = $sym_info->name(); | |||||||||||||||||||||||||||||
| 228 | 25 | $symname = $pkg ."::$symname"; | |||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||
| 230 | 25 | ▶ | if($sym_info->flags & PA_EVENT) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 231 | 6 | foreach my $evname (@{$sym_info->events}) { | |||||||||||||||||||||||||||||
| 232 | 7 | ▶ | if(ref $evname) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 233 | 3 | log_debug("Event is the symbol name itself.. converting"); | |||||||||||||||||||||||||||||
| 234 | 3 | $evname = $sym_info->name(); | |||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||
| 236 | 7 | push @events, [$evname, $symname ]; | |||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||
| 240 | 25 | ▶ | if($sym_info->flags & PA_TIMER) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 241 | 5 | my ($evname,$interval) = @{$sym_info->data->[PA_TIMER] }; | |||||||||||||||||||||||||||||
| 242 | 5 | ▶ | if(ref $evname) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 243 | 3 | log_debug("Timer event name is the symbol itsef.. converting"); | |||||||||||||||||||||||||||||
| 244 | 3 | $evname = $sym_info->name(); | |||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||
| 246 | 5 | push @timers, [ $evname, $symname, $interval ]; | |||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||
| 249 | 25 | ▶ | if($sym_info->flags & PA_CTOR) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 250 | 5 | $ctor = $symname; | |||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||
| 252 | 25 | ▶ | if($sym_info->flags & PA_DTOR) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 253 | 5 | $dtor = $symname; | |||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||
| 257 | 6 | my $params = { | |||||||||||||||||||||||||||||
| 258 | Events => \@events, | ||||||||||||||||||||||||||||||
| 259 | Timers => \@timers, | ||||||||||||||||||||||||||||||
| 260 | Ctor => $ctor, | ||||||||||||||||||||||||||||||
| 261 | Dtor => $dtor | ||||||||||||||||||||||||||||||
| 262 | }; | ||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||
| 265 | 6 | foreach ( | |||||||||||||||||||||||||||||
| 266 | ['reaper', 'Reaper'], | ||||||||||||||||||||||||||||||
| 267 | ['catcher', 'Catcher'] | ||||||||||||||||||||||||||||||
| 268 | ) { | ||||||||||||||||||||||||||||||
| 269 | 12 | my ($meth,$key) = @$_; | |||||||||||||||||||||||||||||
| 270 | 12 | ▶ | if(my $handler = $pkg_info->can($meth)->($pkg_info)) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 271 | 2 | my $symname = $handler->name; | |||||||||||||||||||||||||||||
| 272 | 2 | push @events, [ $symname, $pkg . "::$symname" ]; | |||||||||||||||||||||||||||||
| 273 | 2 | $params->{$key} = $symname; | |||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||
| 277 | 6 | ▶ | while (my ($signame,$sighandler) = each %{$pkg_info->sigs} ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 278 | 2 | my $symname = $sighandler->name(); | |||||||||||||||||||||||||||||
| 279 | 2 | push @events, [ $symname, $pkg ."::$symname" ] ; | |||||||||||||||||||||||||||||
| 280 | 2 | $params->{Signals}->{$signame} = $symname; | |||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||
| 283 | 6 | return $params; | |||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||
| 286 | 6 | ▶ | sub _setup_events { | ||||||||||||||||||||||||||||
|
Subroutine
_setup_events: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 287 | 6 | my ($events,$poe_kernel) = @_; | |||||||||||||||||||||||||||||
| 288 | 6 | foreach (@$events) { | |||||||||||||||||||||||||||||
| 289 | 11 | my ($evname,$subname) = @$_; | |||||||||||||||||||||||||||||
| 290 | 11 | log_debug("$evname:$subname"); | |||||||||||||||||||||||||||||
| 291 | 11 | ▶ | $poe_kernel->state($evname, sub { goto &{$subname} } ); | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||
| 295 | 6 | ▶ | sub _setup_timers { | ||||||||||||||||||||||||||||
|
Subroutine
_setup_timers: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 296 | 6 | my ($timers,$poe_kernel) = @_; | |||||||||||||||||||||||||||||
| 297 | 6 | foreach (@$timers) { | |||||||||||||||||||||||||||||
| 298 | 5 | my ($evname, $symname, $interval) = @$_; | |||||||||||||||||||||||||||||
| 299 | 53 | ▶ | my $wrap = sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 300 | 53 | $poe_kernel->delay($evname, $interval); | |||||||||||||||||||||||||||||
| 301 | 53 | goto &{$symname}; | |||||||||||||||||||||||||||||
| 302 | 5 | }; | |||||||||||||||||||||||||||||
| 303 | 5 | $poe_kernel->state($evname, $wrap); | |||||||||||||||||||||||||||||
| 304 | 5 | $poe_kernel->delay($evname, $interval); | |||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||
| 308 | 3 | ▶ | sub _setup_signals { | ||||||||||||||||||||||||||||
|
Subroutine
_setup_signals: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||
| 309 | 3 | my ($signals, $poe_kernel) = @_; | |||||||||||||||||||||||||||||
| 310 | 3 | ▶ | return unless $signals; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 311 | 2 | ▶ | while (my ($signame,$evname) = each %$signals) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 312 | 2 | log_debugf("$signame => $evname"); | |||||||||||||||||||||||||||||
| 313 | 2 | $poe_kernel->sig($signame, $evname); | |||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||
| 317 | 5 | ▶ | sub inline_states { | ||||||||||||||||||||||||||||
|
Subroutine
inline_states: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||
| 318 | 5 | my ($cls,$pkg,$alias) = @_; | |||||||||||||||||||||||||||||
| 319 | 5 | ▶ | $pkg ||= caller(); | ||||||||||||||||||||||||||||
|
Condition33%1/3
$pkg ||= caller()
MC/DC0%0/2
$pkg ||= caller()
$pkg
caller()
Truth table33%1/3
A ||= B
A= $pkgB= caller()
| |||||||||||||||||||||||||||||||
| 320 | 5 | my $params = _get_params($pkg); | |||||||||||||||||||||||||||||
| 321 | my $sess_hash = { | ||||||||||||||||||||||||||||||
| 322 | 5 | ▶ | _start => sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||
| 323 | 5 | ▶ | if($alias) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 324 | 1 | $_[KERNEL]->alias_set($alias); | |||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||
| 326 | 5 | _setup_timers($params->{Timers}, $_[KERNEL]); | |||||||||||||||||||||||||||||
| 327 | 5 | _setup_events($params->{Events}, $_[KERNEL]); | |||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||
| 329 | 5 | ▶ | if($params->{Catcher}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 330 | 0 | log_debug("Setting DIE handler: ", $params->{Catcher}); | |||||||||||||||||||||||||||||
| 331 | 0 | $_[KERNEL]->sig(DIE => $params->{Catcher}); | |||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||
| 334 | 5 | ▶ | if(my $reaper = $params->{Reaper}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 335 | 2 | log_debugf("Setting CHLD handler: %s", $reaper); | |||||||||||||||||||||||||||||
| 336 | 2 | $_[KERNEL]->sig(CHLD => $reaper); | |||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||
| 339 | 5 | ▶ | if($params->{Signals}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 340 | 2 | _setup_signals($params->{Signals}, $_[KERNEL]); | |||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||
| 343 | 5 | ▶ | if($params->{Ctor}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 344 | 5 | goto &{ $params->{Ctor} }; | |||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||
| 346 | }, | ||||||||||||||||||||||||||||||
| 347 | 5 | ▶ | _stop => sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||
| 348 | 5 | ▶ | if($params->{Dtor}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 349 | 5 | goto &{ $params->{Dtor} }; | |||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||
| 352 | 5 | }; | |||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||
| 354 | 5 | return $sess_hash; | |||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||
| 357 | #This is for other modules which inject themselves, in-situ, into a session | ||||||||||||||||||||||||||||||
| 358 | 1 | ▶ | sub wire_current_session { | ||||||||||||||||||||||||||||
|
Subroutine
wire_current_session: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||
| 359 | 1 | my ($cls,$poe_kernel,$pkg) = @_; | |||||||||||||||||||||||||||||
| 360 | 1 | ▶ | $pkg ||= caller(); | ||||||||||||||||||||||||||||
|
Condition33%1/3
$pkg ||= caller()
MC/DC0%0/2
$pkg ||= caller()
$pkg
caller()
Truth table33%1/3
A ||= B
A= $pkgB= caller()
| |||||||||||||||||||||||||||||||
| 361 | 1 | my $params = _get_params($pkg); | |||||||||||||||||||||||||||||
| 362 | 1 | _setup_timers($params->{Timers}, $poe_kernel); | |||||||||||||||||||||||||||||
| 363 | 1 | _setup_events($params->{Events}, $poe_kernel); | |||||||||||||||||||||||||||||
| 364 | 1 | _setup_signals($params->{Signals}, $poe_kernel); | |||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||
| 368 | 4 | ▶ | sub wire_new_session { | ||||||||||||||||||||||||||||
|
Subroutine
wire_new_session: called CC=4 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||
| 369 | 4 | my $alias = shift; | |||||||||||||||||||||||||||||
| 370 | 4 | ▶ | if( $alias && $alias eq __PACKAGE__) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$alias and $alias eq __PACKAGE__
MC/DC0%0/2
$alias and $alias eq __PACKAGE__
$alias
$alias eq __PACKAGE__
Truth table33%1/3
A and B
A= $aliasB= $alias eq __PACKAGE__
| |||||||||||||||||||||||||||||||
| 371 | 0 | $alias = shift; | |||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||
| 374 | 4 | my $pkg = shift; | |||||||||||||||||||||||||||||
| 375 | 4 | ▶ | $pkg ||= caller(); | ||||||||||||||||||||||||||||
|
Condition33%1/3
$pkg ||= caller()
MC/DC0%0/2
$pkg ||= caller()
$pkg
caller()
Truth table33%1/3
A ||= B
A= $pkgB= caller()
| |||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||
| 377 | 4 | POE::Session->create( | |||||||||||||||||||||||||||||
| 378 | inline_states => __PACKAGE__->inline_states($pkg, $alias) | ||||||||||||||||||||||||||||||
| 379 | ); | ||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||
| 382 | 5 | 1; | |||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||
| 384 | __END__ | ||||||||||||||||||||||||||||||