blib/lib/ExtUtils/XSpp/Node/Type.pm

filter: Statementstmt 100% 48 / 48 Branchbran 95.0% 19 / 20 Conditioncond 85.0% 17 / 20 MC/DCmcdc 70.0% 7 / 10 Subroutinesub 100% 14 / 14 Podpod 18.1% 2 / 11 totaltotal 86.9% 107 / 123 CC 18 SCAR 13.8
CC
18
Cov
95%
equals
7.0
init
6.0
print
4.0
CRAP 4.0
« blib/lib/ExtUtils/XSpp/Node.pm ↑ Summary blib/lib/ExtUtils/XSpp/Typemap/parsed.pm »
1 package ExtUtils::XSpp::Node::Type;
2 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use base 'ExtUtils::XSpp::Node';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # TODO: Document...
7  
8 # normalized names for some integral C types
9 21 my %normalize =
10 ( 'unsigned' => 'unsigned int',
11 'long int' => 'long',
12 'unsigned long int' => 'unsigned long',
13 'short int' => 'short',
14 'unsigned short int' => 'unsigned short',
15 );
16  
17 3468 ▶sub init {
Subroutine init: called CC=6 SCAR=17.9
Pod documented
18 3468 my $this = shift;
19 3468 my %args = @_;
20  
21 3468 ▶ $this->{BASE} = $normalize{$args{base}} || $args{base};
Condition66%2/3
$normalize{$args{'base'}} || $args{'base'}
l!l&&r!l&&!r
03281187
MC/DC50%1/2
$normalize{$args{'base'}} || $args{'base'}
$normalize{$args{'base'}} $args{'base'}
Truth table66%2/3
A || B
A= $normalize{$args{'base'}}B= $args{'base'}
ABresult
1X1
011
000
22 3468 ▶ $this->{POINTER} = $args{pointer} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$args{'pointer'} ? : 441 3027 3468
23 3468 ▶ $this->{REFERENCE} = $args{reference} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$args{'reference'} ? : 54 3414 3468
24 3468 ▶ $this->{CONST} = $args{const} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$args{'const'} ? : 187 3281 3468
25 3468 ▶ $this->{TEMPLATE_ARGS} = $args{template_args} || [];
Condition100%2/2
$args{'template_args'} || []
l!l
93459
MC/DC100%1/1
$args{'template_args'} || []
$args{'template_args'}
Truth table100%2/2
A
A= $args{'template_args'}
Aresult
11
00
26 }
27  
28 3 ▶sub clone {
Subroutine clone: called CC=1 SCAR=0.0
Pod undocumented
29 3 my $this = shift;
30 3 my $clone = bless {%$this} => ref($this);
31 3 $clone->{TEMPLATE_ARGS} = [map $_->clone, @{$clone->template_args}];
32 3 return $clone;
33 }
34  
35 5135 ▶sub is_const { $_[0]->{CONST} }
Subroutine is_const: called CC=1 SCAR=0.0
Pod undocumented
36 4737 ▶sub is_reference { $_[0]->{REFERENCE} }
Subroutine is_reference: called CC=1 SCAR=0.0
Pod undocumented
37 4741 ▶sub is_pointer { $_[0]->{POINTER} }
Subroutine is_pointer: called CC=1 SCAR=0.0
Pod undocumented
38 4301 ▶sub base_type { $_[0]->{BASE} }
Subroutine base_type: called CC=1 SCAR=0.0
Pod undocumented
39 7612 ▶sub template_args { $_[0]->{TEMPLATE_ARGS} }
Subroutine template_args: called CC=1 SCAR=0.0
Pod undocumented
40  
41 2414 ▶sub equals {
Subroutine equals: called CC=7 SCAR=19.5
Pod undocumented
42 2414 my( $f, $s ) = @_;
43  
44 2414 ▶ return 0 if @{$f->template_args} != @{$s->template_args};
Branch: 1 branch
BranchTrueFalseTotal
if @{$f->template_args;} != @{$s->template_args;} 18 2396 2414
45  
46 2396 ▶ for( my $i = 0; $i < @{$f->template_args}; ++$i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$f->template_args;}) 7 2396 2403
47 7 ▶ return 0
Branch: 1 branch
BranchTrueFalseTotal
unless $f->template_args->[$i]->equals($s->template_args->[$i]) 0 7 7
48 unless $f->template_args->[$i]->equals( $s->template_args->[$i] );
49 }
50  
51 2396 ▶ return $f->is_const == $s->is_const
Condition100%9/9
$f->is_const == $s->is_const && $f->is_reference == $s->is_reference && $f->is_pointer == $s->is_pointer && $f->base_type eq $s->base_type
!ll&&!rl&&r
4781684234
$f->is_const == $s->is_const and $f->is_reference == $s->is_reference and $f->is_pointer == $s->is_pointer
!ll&&!rl&&r
2342441918
$f->is_const == $s->is_const and $f->is_reference == $s->is_reference
!ll&&!rl&&r
199352162
MC/DC100%4/4
$f->is_const == $s->is_const && $f->is_reference == $s->is_reference && $f->is_pointer == $s->is_pointer && $f->base_type eq $s->base_type
$f->is_const == $s->is_const $f->is_reference == $s->is_reference $f->is_pointer == $s->is_pointer $f->base_type eq $s->base_type
Truth table100%5/5
A and B and C && D
A= $f->is_const == $s->is_constB= $f->is_reference == $s->is_referenceC= $f->is_pointer == $s->is_pointerD= $f->base_type eq $s->base_type
ABCDresult
0XXX0
10XX0
110X0
11100
11111
52 && $f->is_reference == $s->is_reference
53 && $f->is_pointer == $s->is_pointer
54 && $f->base_type eq $s->base_type;
55 }
56  
57 106 ▶sub is_void { return $_[0]->base_type eq 'void' &&
Subroutine is_void: called CC=3 SCAR=11.7
Pod undocumented
Condition66%4/6
$_[0]->base_type eq 'void' && !$_[0]->is_pointer && !$_[0]->is_reference
!ll&&!rl&&r
76030
$_[0]->base_type eq "void" and not $_[0]->is_pointer
!ll&&!rl&&r
76030
MC/DC33%1/3
$_[0]->base_type eq 'void' && !$_[0]->is_pointer && !$_[0]->is_reference
$_[0]->base_type eq "void" not $_[0]->is_pointer !$_[0]->is_reference
Truth table50%2/4
A and not(B) && not(C)
A= $_[0]->base_type eq "void"B= not $_[0]->is_pointerC= !$_[0]->is_reference
ABCresult
0XX0
10X0
1100
1111
58 !$_[0]->is_pointer && !$_[0]->is_reference }
59  
60 359 ▶sub print_tmpl_args {
Subroutine print_tmpl_args: called CC=2 SCAR=6.9
Pod undocumented
61 359 my $this = shift;
62 359 my $state = shift;
63 359 my $tmpl_args = '';
64 359 ▶ if( @{$this->template_args} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$this->template_args;}) 5 354 359
65 $tmpl_args = '< '
66 . join( ', ',
67 5 map $_->print( $state ), @{$this->template_args} )
68 . ' >';
69 }
70 359 return $tmpl_args;
71 }
72  
73 343 ▶sub print {
Subroutine print: called CC=4 SCAR=13.9
Pod documented
74 343 my $this = shift;
75 343 my $state = shift;
76  
77 343 ▶ return join( '',
Branch: 3 branches
BranchTrueFalseTotal
$this->is_const ? : 5 338 343
$this->is_pointer ? : 30 313 343
$this->is_reference ? : 1 312 313
78 ( $this->is_const ? 'const ' : '' ),
79 $this->base_type,
80 $this->print_tmpl_args,
81 ( $this->is_pointer ? ( '*' x $this->is_pointer ) :
82 $this->is_reference ? '&' : '' ) );
83 }
84  
85  
86 21 1;
« blib/lib/ExtUtils/XSpp/Node.pm ↑ Summary blib/lib/ExtUtils/XSpp/Typemap/parsed.pm »