XSBuilder/StructureMap.pm

filter: Statementstmt 12.3% 14 / 113 Branchbran 0.0% 0 / 50 Conditioncond 0.0% 0 / 17 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 33.3% 4 / 12 Podpod 0.0% 0 / 8 totaltotal 8.5% 18 / 211 CC 39 SCAR 47.4
CC
39
Cov
8%
parse
272.0
check
72.0
generate
42.0
CRAP 114.1
« XSBuilder/TypeMap.pm ↑ Summary XSBuilder/C/grammar.pm »
1 package ExtUtils::XSBuilder::StructureMap;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use ExtUtils::XSBuilder::MapUtil qw(function_table structure_table);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Data::Dumper ;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our @ISA = qw(ExtUtils::XSBuilder::MapBase);
9  
10 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
11 0 my $class = shift;
12 0 my $self = bless {wrapxs => shift}, $class;
13 0 $self->{IGNORE_RE} = qr{^$};
14 0 return $self ;
15 }
16  
17 0 ▶sub generate {
Subroutine generate: not called CC=6 SCAR=37.4
Pod undocumented
18 0 my $self = shift;
19 0 my $map = $self->get;
20  
21 0 for my $entry (@{ structure_table($self -> {wrapxs}) }) {
22 0 my $type = $entry->{type};
23 0 my $elts = $entry->{elts};
24  
25 0 ▶ next unless @$elts;
Branch: 1 branch
BranchTrueFalseTotal
unless @$elts 0 0 0
26 0 ▶ next if $type =~ $self->{IGNORE_RE};
Branch: 1 branch
BranchTrueFalseTotal
if $type =~ /$self->{"IGNORE_RE"}/ 0 0 0
27 next unless grep {
28 0 ▶ not exists $map->{$type}->{ $_->{name} }
Branch: 1 branch
BranchTrueFalseTotal
unless grep {not exists $map->{$type}{$_->{"name"}};} @$elts 0 0 0
29 0 } @$elts;
30  
31 0 print "<$type>\n";
32 0 for my $e (@$elts) {
33 0 print " $e->{name}\n";
34 }
35 0 print "</$type>\n\n";
36 }
37 }
38  
39 0 ▶sub disabled { shift->{disabled} }
Subroutine disabled: not called CC=1 SCAR=6.9
Pod undocumented
40  
41 0 ▶sub check {
Subroutine check: not called CC=8 SCAR=42.8
Pod undocumented
42 0 my $self = shift;
43 0 my $map = $self->get;
44  
45 0 my @missing;
46 0 my $parsesource = $self -> {wrapxs} -> parsesource_objects ;
47  
48 loop:
49 0 for my $entry (@{ structure_table($self -> {wrapxs}) }) {
50 0 my $type = $entry->{type};
51  
52 0 for my $name (map $_->{name}, @{ $entry->{elts} }) {
53 0 ▶ next if exists $map->{$type}->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $map->{$type}{$name} 0 0 0
54 0 ▶ next if $type =~ $self->{IGNORE_RE};
Branch: 1 branch
BranchTrueFalseTotal
if $type =~ /$self->{"IGNORE_RE"}/ 0 0 0
55 0 push @missing, "$type.$name";
56 }
57 0 ▶ push @missing, "$type.new" if (!exists $map->{$type}->{'new'}) ;
Branch: 1 branch
BranchTrueFalseTotal
unless exists $map->{$type}{"new"} 0 0 0
58 0 ▶ push @missing, "$type.private" if (!exists $map->{$type}->{'private'}) ;
Branch: 1 branch
BranchTrueFalseTotal
unless exists $map->{$type}{"private"} 0 0 0
59 }
60  
61 0 ▶ return @missing ? \@missing : undef;
Branch: 1 branch
BranchTrueFalseTotal
@missing ? : 0 0 0
62 }
63  
64 0 ▶sub check_exists {
Subroutine check_exists: not called CC=6 SCAR=37.4
Pod undocumented
65 0 my $self = shift;
66  
67 0 my %structures;
68 0 for my $entry (@{ structure_table($self -> {wrapxs}) }) {
69 $structures{ $entry->{type} } = { map {
70 0 $_->{name}, 1
71 0 } @{ $entry->{elts} } };
72 }
73  
74 0 my @missing;
75  
76 0 ▶ while (my($type, $elts) = each %{ $self->{map} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"map"};}) 0 0 0
77 0 for my $name (keys %$elts) {
78 0 ▶ next if exists $structures{$type}->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $structures{$type}{$name} 0 0 0
79 0 push @missing, "$type.$name";
80 }
81 }
82  
83 0 ▶ return @missing ? \@missing : undef;
Branch: 1 branch
BranchTrueFalseTotal
@missing ? : 0 0 0
84 }
85  
86 0 ▶sub parse {
Subroutine parse: not called CC=16 SCAR=56.1
Pod undocumented
87 0 my($self, $fh, $map) = @_;
88  
89 0 my($disabled, $class, $class2);
90 0 my %cur;
91 0 my %malloc;
92 0 my %free;
93  
94 0 ▶ while ($fh->readline) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh->readline) 0 0 0
95 0 ▶ if (/MALLOC=\s*(.*?)\s*:\s*(.*?)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/MALLOC=\s*(.*?)\s*:\s*(.*?)$/) 0 0 0
96 0 $malloc{$1} = $2 ;
97 0 next;
98 }
99 0 ▶ if (/FREE=\s*(.*?)\s*:\s*(.*?)$/) {
Branch: 4 branches
BranchTrueFalseTotal
if (/FREE=\s*(.*?)\s*:\s*(.*?)$/) { } 0 0 0
elsif (m[^(\W?)</([^>]+)>]) { } 0 0 0
elsif (m[^(\W?)</?([^>]+)>]) { } 0 0 0
elsif (s/^(\w+):\s*//) { } 0 0 0
100 0 $free{$1} = $2 ;
101 0 next;
102 }
103 elsif (m:^(\W?)</([^>]+)>:) {
104 0 $map->{$class}{-malloc} = { %malloc } ;
105 0 $map->{$class}{-free} = { %free } ;
106 0 next;
107 }
108 elsif (m:^(\W?)</?([^>]+)>:) {
109 0 my $args;
110 0 $disabled = $1;
111 0 ($class, $args) = split /\s+/, $2, 2;
112 0 ▶ if ($class eq 'struct')
Branch: 1 branch
BranchTrueFalseTotal
if ($class eq "struct") 0 0 0
113 {
114 0 ($class2, $args) = split /\s+/, $args, 2;
115 0 $class .= ' ' . $class2 ;
116 }
117  
118 0 %cur = ();
119 0 ▶ if ($args and $args =~ /E=/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args and $args =~ /E=/) 0 0 0
Condition0%0/3
$args and $args =~ /E=/
!ll&&!rl&&r
000
MC/DC0%0/2
$args and $args =~ /E=/
$args $args =~ /E=/
Truth table0%0/3
A and B
A= $argsB= $args =~ /E=/
ABresult
0X0
100
111
120 0 %cur = $self->parse_keywords($args);
121 }
122  
123 0 ▶ $self->{MODULES}->{$class} = $cur{MODULE} if $cur{MODULE};
Branch: 1 branch
BranchTrueFalseTotal
if $cur{"MODULE"} 0 0 0
124  
125 0 next;
126 }
127 elsif (s/^(\w+):\s*//) {
128 0 push @{ $self->{$1} }, split /\s+/;
129 0 next;
130 }
131  
132 0 ▶ if (s/^(\W)\s*// or $disabled) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^(\W)\s*// or $disabled) { } 0 0 0
Condition0%0/3
s/^(\W)\s*// or $disabled
l!l&&r!l&&!r
000
MC/DC0%0/2
s/^(\W)\s*// or $disabled
s/^(\W)\s*// $disabled
Truth table0%0/3
A or B
A= s/^(\W)\s*//B= $disabled
ABresult
1X1
011
000
133 0 my @parts = split /\s*\|\s*/ ;
134 0 $map->{$class}->{$parts[0]} = undef;
135 0 ▶ push @{ $self->{disabled}->{ $1 || '!' } }, "$class.$_";
Condition0%0/2
$1 || '!'
l!l
00
MC/DC0%0/1
$1 || '!'
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
136 }
137 else {
138 0 my @parts = split /\s*\|\s*/ ;
139 0 ▶ $map->{$class}->{$parts[0]} = { name => $parts[0],
Condition0%0/3
$parts[1] || $parts[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$parts[1] || $parts[0]
$parts[1] $parts[0]
Truth table0%0/3
A || B
A= $parts[1]B= $parts[0]
ABresult
1X1
011
000
140 perl_name => $parts[1] || $parts[0],
141 type => $parts[2] } ;
142  
143 }
144 }
145  
146 0 ▶ if (my $ignore = $self->{IGNORE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ignore = $self->{'IGNORE'}) { } 0 0 0
147 0 $ignore = join '|', @$ignore;
148 0 $self->{IGNORE_RE} = qr{^($ignore)};
149 }
150 else {
151 0 $self->{IGNORE_RE} = qr{^$};
152 }
153 }
154  
155 0 ▶sub get {
Subroutine get: not called CC=2 SCAR=17.9
Pod undocumented
156 0 my $self = shift;
157  
158 0 ▶ $self->{map} ||= $self->parse_map_files;
Condition0%0/3
$self->{"map"} ||= $self->parse_map_files
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"map"} ||= $self->parse_map_files
$self->{"map"} $self->parse_map_files
Truth table0%0/3
A ||= B
A= $self->{"map"}B= $self->parse_map_files
ABresult
1X1
011
000
159 }
160  
161  
162 0 ▶sub write {
Subroutine write: not called CC=6 SCAR=37.4
Pod undocumented
163 0 my ($self, $fh, $newentries, $prefix) = @_ ;
164  
165 0 my $last = '' ;
166 0 foreach my $type (@$newentries)
167 {
168 0 my ($struct, $elem) = split (/\./, $type) ;
169 0 ▶ $fh -> print ("$prefix</$last>\n") if ($last && $last ne $struct) ;
Branch: 1 branch
BranchTrueFalseTotal
if $last and $last ne $struct 0 0 0
Condition0%0/3
$last and $last ne $struct
!ll&&!rl&&r
000
MC/DC0%0/2
$last and $last ne $struct
$last $last ne $struct
Truth table0%0/3
A and B
A= $lastB= $last ne $struct
ABresult
0X0
100
111
170 0 ▶ $fh -> print ("$prefix<$struct>\n") if ($last ne $struct) ;
Branch: 1 branch
BranchTrueFalseTotal
if $last ne $struct 0 0 0
171 0 $last = $struct ;
172 0 $fh -> print ($prefix, ' ', $self -> {wrapxs} -> mapline_elem ($elem), "\n") ;
173 }
174 0 ▶ $fh -> print ("$prefix</$last>\n") if ($last) ;
Branch: 1 branch
BranchTrueFalseTotal
if $last 0 0 0
175 }
176  
177  
178  
179 1 1;
180 __END__
« XSBuilder/TypeMap.pm ↑ Summary XSBuilder/C/grammar.pm »