blib/lib/Tie/Array/Packed/Auto.pm

filter: Statementstmt 95.2% 60 / 63 Branchbran 66.6% 4 / 6 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 2 totaltotal 83.7% 77 / 92 CC 4 SCAR 6.6
CC
4
Cov
89%
AUTOLOAD
4.0
make_with_packed
2.0
BEGIN
1.0
CRAP 1.9
↑ Summary
1 package Tie::Array::Packed::Auto;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.03';
8  
9 2 our $force_pure_perl_backend;
10  
11 2 ▶if ($force_pure_perl_backend or
Branch: 1 branch
BranchTrueFalseTotal
if ($Tie::Array::Packed::Auto::force_pure_perl_backend or not eval { do { require Tie::Array::Packed } }) 2 0 2
Condition66%2/3
$Tie::Array::Packed::Auto::force_pure_perl_backend or not eval { do { require Tie::Array::Packed } }
l!l&&r!l&&!r
110
MC/DC0%0/2
$Tie::Array::Packed::Auto::force_pure_perl_backend or not eval { do { require Tie::Array::Packed } }
$Tie::Array::Packed::Auto::force_pure_perl_backend not eval { do { require Tie::Array::Packed } }
Truth table66%2/3
A or not(B)
A= $Tie::Array::Packed::Auto::force_pure_perl_backendB= not eval { do { require Tie::Array::Packed } }
ABresult
1X1
011
000
12 1 not eval { require Tie::Array::Packed }) {
13  
14 2 our @ISA = 'Tie::Array::Packed';
15  
16 2 require Tie::Array::PackedC;
17  
18 2 my @short = qw(c C F f d i I i! I! s! S! l! L! n N v V);
19  
20 2 my %map = ( Char => 'c',
21 UnsignedChar => 'C',
22 NV => 'F',
23 Number => 'F',
24 FloatNative => 'f',
25 DoubleNative => 'd',
26 Integer => 'i',
27 UnsignedInteger => 'I',
28 IntegerNative => 'i!',
29 UnsignedIntegerNative => 'I!',
30 ShortNative => 's!',
31 UnsignedShortNative => 'S!',
32 LongNative => 'l!',
33 UnsignedLongNative => 'L!',
34 UnsignedShortNet => 'n',
35 UnsignedShortBE => 'n',
36 UnsignedLongNet => 'N',
37 UnsignedLongBE => 'N',
38 UnsignedShortVax => 'v',
39 UnsignedShortLE => 'v',
40 UnsignedLongVax => 'V',
41 UnsignedLongLE => 'V' );
42  
43 2 @map{@short} = @short;
44  
45 2 for my $name (keys %map) {
46 78 my $type = $map{$name};
47  
48 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
49 78 @{"Tie::Array::Packed::${name}::ISA"} = __PACKAGE__;
50 36 ▶ *{"Tie::Array::Packed::${name}::packer"} = sub { $type };
Subroutine __ANON__: called CC=1 SCAR=0.0
51 }
52  
53 }
54  
55 2 my $next_id = 'TieArrayPackedAuto0000';
56 2 my %id;
57 my %class;
58  
59 2 our $AUTOLOAD;
60  
61 36 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=4 SCAR=13.9
62 36 my $self = shift;
63 36 ▶ my $class = ref $self || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
0360
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
64 36 ▶ $class{$class} and croak qq(Can't locate object method "$AUTOLOAD" via package "$class");
Branch: 1 branch
BranchTrueFalseTotal
$class{$class} and croak(qq[Can't locate object method "$Tie::Array::Packed::Auto::AUTOLOAD" via package "$class"]) 0 36 36
65 36 $class{$class} = 1;
66 36 my $packer = $self->packer;
67 36 ▶ unless ($id{$packer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($id{$packer}) 32 4 36
68 32 $next_id++;
69 32 $id{$packer} = $next_id;
70 32 Tie::Array::PackedC->import($id{$packer}, $packer);
71  
72 32 my $parent = "Tie::Array::PackedC::$id{$packer}";
73 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
74 32 *{$parent.'::_TieArrayPackedAuto_TIEARRAY'} = *{$parent.'::TIEARRAY'};
75 }
76 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
77 36 push @{$class.'::ISA'}, "Tie::Array::PackedC::$id{$packer}";
78 36 $self->$AUTOLOAD(@_);
79 }
80  
81 38 ▶sub make {
Subroutine make: called CC=1 SCAR=0.0
Pod undocumented
82 38 my $class = shift;
83 38 tie my(@self), $class, '', @_;
84 return \@self
85 38 }
86  
87 0 ▶sub make_with_packed {
Subroutine make_with_packed: not called CC=1 SCAR=6.9
Pod undocumented
88 0 my $class = shift;
89 0 tie my(@self), $class, @_;
90 return \@self
91 0 }
92  
93 42 ▶sub TIEARRAY {
Subroutine TIEARRAY: called CC=1 SCAR=0.0
94 # local $_[1] = $_[1];
95 # shift->_TieArrayPackedAuto_TIEARRAY(@_);
96  
97 42 my $class = shift;
98 42 my $str = shift;
99 42 $class->_TieArrayPackedAuto_TIEARRAY($str, @_);
100 }
101  
102 2 1;
103  
104 __END__
↑ Summary