| 1 | package Devel::Monitor::Array; | ||||||||||
| 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 | |||||||||||
| 5 | 1 | ▶ | use Devel::Monitor::Common qw(:all); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | our $id = 0; | |||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | sub TIEARRAY { | ||||||||
|
Subroutine
TIEARRAY: called CC=3 SCAR=11.0
| |||||||||||
| 10 | 2 | my ($class, $varRef, $id, $isCode) = @_; | |||||||||
| 11 | 2 | my $self = {}; | |||||||||
| 12 | 2 | bless($self => $class); | |||||||||
| 13 | 2 | $self->{Devel::Monitor::Common::F_VAR()} = [@$varRef]; | |||||||||
| 14 | 2 | ▶ | if ($id) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 2 | $self->{Devel::Monitor::Common::F_ID()} = $id; | |||||||||
| 16 | } else { | ||||||||||
| 17 | 0 | $self->{Devel::Monitor::Common::F_ID()} = 'array_'.++$id; | |||||||||
| 18 | } | ||||||||||
| 19 | 2 | $self->{Devel::Monitor::Common::F_IS_CODE()} = $isCode; | |||||||||
| 20 | 2 | ▶ | if ($isCode) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 1 | Devel::Monitor::Common::printMsg("MONITOR CODE ARRAY : ".$self->{Devel::Monitor::Common::F_ID()}."\n"); | |||||||||
| 22 | } else { | ||||||||||
| 23 | 1 | Devel::Monitor::Common::printMsg("MONITOR ARRAY : ".$self->{Devel::Monitor::Common::F_ID()}."\n"); | |||||||||
| 24 | } | ||||||||||
| 25 | 2 | return $self; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub DESTROY { | ||||||||
|
Subroutine
DESTROY: not called CC=4 SCAR=30.0
| |||||||||||
| 29 | 0 | my $self = shift; | |||||||||
| 30 | 0 | ▶ | if ($self->{Devel::Monitor::Common::F_IS_CODE()}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | ▶ | Devel::Monitor::Common::printMsg("DESTROY CODE ARRAY : ".$self->{Devel::Monitor::Common::F_ID()}."\n") unless $self->{Devel::Monitor::Common::F_UNMONITORED()}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | } else { | ||||||||||
| 33 | 0 | ▶ | Devel::Monitor::Common::printMsg("DESTROY ARRAY : ".$self->{Devel::Monitor::Common::F_ID()}."\n") unless $self->{Devel::Monitor::Common::F_UNMONITORED()}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | } | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub unmonitor { | ||||||||
|
Subroutine
unmonitor: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 38 | 0 | my ($varRef) = @_; | |||||||||
| 39 | 0 | my $arrayRef; | |||||||||
| 40 | { | ||||||||||
| 41 | 0 | my $self = tied @$varRef; | |||||||||
| 42 | 0 | $arrayRef = $self->{Devel::Monitor::Common::F_VAR()}; | |||||||||
| 43 | 0 | $self->{Devel::Monitor::Common::F_UNMONITORED()} = 1; | |||||||||
| 44 | 0 | Devel::Monitor::Common::printMsg("UNMONITOR ARRAY : ".$self->{Devel::Monitor::Common::F_ID()}."\n"); | |||||||||
| 45 | } | ||||||||||
| 46 | 0 | untie @$varRef; | |||||||||
| 47 | 0 | @$varRef = @$arrayRef; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | #Copy/Pasted from Tie::StdArray into Tie::Array.pm | ||||||||||
| 51 | #Added "->{Devel::Monitor::Common::F_VAR()}" | ||||||||||
| 52 | 0 | ▶ | sub FETCHSIZE { scalar @{$_[0]->{Devel::Monitor::Common::F_VAR()}} } | ||||||||
|
Subroutine
FETCHSIZE: not called CC=1 SCAR=6.9
| |||||||||||
| 53 | 0 | ▶ | sub STORESIZE { $#{$_[0]->{Devel::Monitor::Common::F_VAR()}} = $_[1]-1 } | ||||||||
|
Subroutine
STORESIZE: not called CC=1 SCAR=6.9
| |||||||||||
| 54 | 0 | ▶ | sub STORE { $_[0]->{Devel::Monitor::Common::F_VAR()}->[$_[1]] = $_[2] } | ||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||
| 55 | 0 | ▶ | sub FETCH { $_[0]->{Devel::Monitor::Common::F_VAR()}->[$_[1]] } | ||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||
| 56 | 0 | ▶ | sub CLEAR { @{$_[0]->{Devel::Monitor::Common::F_VAR()}} = () } | ||||||||
|
Subroutine
CLEAR: not called CC=1 SCAR=6.9
| |||||||||||
| 57 | 0 | ▶ | sub POP { pop(@{$_[0]->{Devel::Monitor::Common::F_VAR()}}) } | ||||||||
|
Subroutine
POP: not called CC=1 SCAR=6.9
| |||||||||||
| 58 | 0 | ▶ | sub PUSH { my $o = shift; push(@{$o->{Devel::Monitor::Common::F_VAR()}},@_) } | ||||||||
|
Subroutine
PUSH: not called CC=1 SCAR=6.9
| |||||||||||
| 59 | 0 | ▶ | sub SHIFT { shift(@{$_[0]->{Devel::Monitor::Common::F_VAR()}}) } | ||||||||
|
Subroutine
SHIFT: not called CC=1 SCAR=6.9
| |||||||||||
| 60 | 0 | ▶ | sub UNSHIFT { my $o = shift; unshift(@{$o->{Devel::Monitor::Common::F_VAR()}},@_) } | ||||||||
|
Subroutine
UNSHIFT: not called CC=1 SCAR=6.9
| |||||||||||
| 61 | 0 | ▶ | sub EXISTS { exists $_[0]->{Devel::Monitor::Common::F_VAR()}->[$_[1]] } | ||||||||
|
Subroutine
EXISTS: not called CC=1 SCAR=6.9
| |||||||||||
| 62 | 0 | ▶ | sub DELETE { delete $_[0]->{Devel::Monitor::Common::F_VAR()}->[$_[1]] } | ||||||||
|
Subroutine
DELETE: not called CC=1 SCAR=6.9
| |||||||||||
| 63 | 0 | ▶ | sub EXTEND { } | ||||||||
|
Subroutine
EXTEND: not called CC=1 SCAR=0.0
| |||||||||||
| 64 | 0 | ▶ | sub SPLICE { | ||||||||
|
Subroutine
SPLICE: not called CC=4 SCAR=30.0
| |||||||||||
| 65 | 0 | my $ob = shift; | |||||||||
| 66 | 0 | my $sz = $ob->FETCHSIZE; | |||||||||
| 67 | 0 | ▶ | my $off = @_ ? shift : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 0 | ▶ | $off += $sz if $off < 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 0 | ▶ | my $len = @_ ? shift : $sz-$off; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 0 | return splice(@{$ob->{Devel::Monitor::Common::F_VAR()}},$off,$len,@_); | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 1 | 1; | |||||||||