| 1 | package Ref::Store::PP::Magic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Variable::Magic qw(cast dispell wizard getdata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Scalar::Util qw(weaken refaddr reftype isweak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Log::Fu; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Devel::Peek; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Devel::GlobalDestruction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Constant::Generate [qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | IDX_KEY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | IDX_TARGET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | )]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | hr_pp_trigger_register | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | hr_pp_trigger_free | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | hr_pp_trigger_unregister | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | hr_pp_trigger_replace_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | hr_pp_purge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | our $Wizard; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | sub _init_wizard { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_wizard: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | $Wizard = wizard( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 250 | ▶ | data => sub { $_[1] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | free => \&trigger_fire | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | _init_wizard(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub hr_pp_purge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hr_pp_purge: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my ($ref) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | &dispell($ref, $Wizard); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 250 | ▶ | sub trigger_fire { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trigger_fire: called CC=8 SCAR=25.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 250 | my ($ref,$actions) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 250 | foreach (@$actions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 550 | my ($key,$target) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 550 | ▶ | unless (defined $target && defined $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $target and defined $key
MC/DC50%1/2
defined $target and defined $key
defined $target
defined $key
Truth table66%2/3
A and B
A= defined $targetB= defined $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 546 | ▶ | if(reftype $target eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 546 | ▶ | if(ref $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $key = $key+0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 546 | delete $target->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } elsif (reftype $target eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | delete $target->[$key+0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } elsif (reftype $target eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $target->($ref,$key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | die "Unknown target $target"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 250 | @$actions = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 100 | ▶ | sub hr_pp_trigger_unregister { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hr_pp_trigger_unregister: called CC=12 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 100 | my ($ref,$target,$key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 100 | ▶ | if(!defined $target) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if(in_global_destruction) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 100 | my $actions = &getdata($ref, $Wizard); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 100 | ▶ | return unless $actions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 100 | my $i = $#{$actions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 100 | ▶ | while($i >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 100 | my ($ekey,$etarget) = @{$actions->[$i]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 100 | ▶ | if(defined $etarget && $target eq $etarget && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $etarget and $target eq $etarget and not defined $key or $key eq $ekey
defined $etarget and $target eq $etarget and not defined $key
defined $etarget and $target eq $etarget
MC/DC0%0/4
defined $etarget and $target eq $etarget and not defined $key or $key eq $ekey
defined $etarget
$target eq $etarget
not defined $key
$key eq $ekey
Truth table14%1/7
A and B and not(C) or D
A= defined $etargetB= $target eq $etargetC= not defined $keyD= $key eq $ekey
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | (!defined $key) || ($key eq $ekey)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 100 | splice(@{$actions}, $i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 100 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $i--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 100 | ▶ | if(!@$actions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | &dispell($ref, $Wizard) if (defined $ref && ref $Wizard); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $ref and ref $Ref::Store::PP::Magic::Wizard
MC/DC0%0/2
defined $ref and ref $Ref::Store::PP::Magic::Wizard
defined $ref
ref $Ref::Store::PP::Magic::Wizard
Truth table0%0/3
A and B
A= defined $refB= ref $Ref::Store::PP::Magic::Wizard
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1800 | ▶ | sub hr_pp_trigger_register { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hr_pp_trigger_register: called CC=8 SCAR=21.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1800 | my ($ref,$target,$key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1800 | my $data = &getdata($ref, $Wizard); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1800 | my $datum = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1800 | @$datum[IDX_KEY,IDX_TARGET] = ($key,$target); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1800 | weaken($datum->[IDX_TARGET]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1800 | ▶ | weaken($datum->[IDX_KEY]) if ref $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1800 | ▶ | if(!$data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 250 | $data = [ $datum ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 250 | &cast($ref, $Wizard, $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 250 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1550 | foreach (@$data) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3350 | my ($ekey,$etarget) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3350 | ▶ | if (defined $etarget && defined $ekey && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
defined $etarget and defined $ekey and $target == $etarget and $key eq $ekey
defined $etarget and defined $ekey and $target == $etarget
defined $etarget and defined $ekey
MC/DC25%1/4
defined $etarget and defined $ekey and $target == $etarget and $key eq $ekey
defined $etarget
defined $ekey
$target == $etarget
$key eq $ekey
Truth table40%2/5
A and B and C and D
A= defined $etargetB= defined $ekeyC= $target == $etargetD= $key eq $ekey
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | $target == $etarget && $key eq $ekey) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1150 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 400 | push @$data, $datum; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | use Carp qw(cluck); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | #This one exists primarily for thread duplication | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | #sub hr_pp_trigger_replace_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # my ($ref,$key,$target,$newkey) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # my $data = &getdata($ref,$Wizard); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # if(!$data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # cluck(""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # log_warn("No data yet? ($ref)"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # hr_pp_trigger_register($ref,$key,$target); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # log_warn("Casted!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # foreach (@$data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # my ($ekey,$etarget) = @$_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # if($etarget == $target && $ekey eq $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # $_->[IDX_KEY] = $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # weaken($_->[IDX_KEY]) if ref $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # hr_pp_trigger_register($ref,$key,$target); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||