XSBuilder/CallbackMap.pm

filter: Statementstmt 19.6% 10 / 51 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 4 totaltotal 15.2% 13 / 85 CC 17 SCAR 34.2
CC
17
Cov
14%
write
56.0
parse
30.0
check
20.0
CRAP 30.7
« XSBuilder/C/grammar.pm ↑ Summary XSBuilder/MapUtil.pm »
1 package ExtUtils::XSBuilder::CallbackMap;
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(callback_table);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our @ISA = qw(ExtUtils::XSBuilder::FunctionMap);
8  
9 # ============================================================================
10  
11 #look for callbacks that do not exist in *.map
12 0 ▶sub check {
Subroutine check: not called CC=4 SCAR=30.0
Pod undocumented
13 0 my $self = shift;
14 0 my $map = $self->get;
15  
16 0 my @missing;
17 0 my $parsesource = $self -> {wrapxs} -> parsesource_objects ;
18  
19 loop:
20 0 for my $name (map $_->{name}, @{ callback_table($self -> {wrapxs}) }) {
21 0 ▶ next if exists $map->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $map->{$name} 0 0 0
22 0 push @missing, $name ;
23 }
24  
25 0 ▶ return @missing ? \@missing : undef;
Branch: 1 branch
BranchTrueFalseTotal
@missing ? : 0 0 0
26 }
27  
28 # ============================================================================
29  
30 #look for callbacks in *.map that do not exist
31  
32 0 ▶sub check_exists {
Subroutine check_exists: not called CC=4 SCAR=30.0
Pod undocumented
33 0 my $self = shift;
34  
35 0 my %callbacks = map { $_->{name}, 1 } @{ callback_table($self -> {wrapxs}) };
36 0 my @missing = ();
37  
38 #print Data::Dumper -> Dump ([\%callbacks, $self->{map}]) ;
39  
40 0 for my $name (keys %{ $self->{map} }) {
41 0 ▶ next if $callbacks{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $callbacks{$name} 0 0 0
42 0 push @missing, $name ;
43 }
44  
45 0 ▶ return @missing ? \@missing : undef;
Branch: 1 branch
BranchTrueFalseTotal
@missing ? : 0 0 0
46 }
47  
48  
49 # ============================================================================
50  
51 0 ▶sub parse {
Subroutine parse: not called CC=5 SCAR=34.0
Pod undocumented
52 0 my($self, $fh, $map) = @_;
53 0 my %cur;
54 0 my $disabled = 0;
55  
56 0 ▶ while ($fh->readline) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh->readline) 0 0 0
57 0 my($type, $argspec) = split /\s*\|\s*/;
58  
59 0 ▶ my $entry = $map->{$type} = {
Branch: 1 branch
BranchTrueFalseTotal
$argspec ? : 0 0 0
60 name => $type,
61 argspec => $argspec ? [split /\s*,\s*/, $argspec] : "",
62 };
63  
64  
65 #avoid 'use of uninitialized value' warnings
66 0 ▶ $entry->{$_} ||= "" for keys %{ $entry };
Condition0%0/2
$entry->{$_} ||= ""
l!l
00
MC/DC0%0/1
$entry->{$_} ||= ""
$entry->{$_}
Truth table0%0/2
A
A= $entry->{$_}
Aresult
11
00
67 }
68 }
69  
70  
71  
72 0 ▶sub write {
Subroutine write: not called CC=7 SCAR=40.3
Pod undocumented
73 0 my ($self, $fh, $newentries, $prefix) = @_ ;
74  
75 0 foreach (@$newentries)
76 {
77 0 my $line = $self -> {wrapxs} -> mapline_func ($_) ;
78  
79 0 ▶ if ($line =~ /\)\((.*?)\)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /\)\((.*?)\)/) 0 0 0
80 {
81 0 my @args = split (/,/, $1) ;
82 0 ▶ $line .= ' | ' if (@args) ;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
83 0 my $i = 0 ;
84 0 foreach (@args)
85 {
86 0 ▶ $line .= ',' if ($i++ > 0) ;
Branch: 1 branch
BranchTrueFalseTotal
if $i++ > 0 0 0 0
87 0 /([^ ]+)$/ ;
88 0 my $arg = $1 ;
89 0 ▶ $line .= '<' if (/\* \*/) ;
Branch: 1 branch
BranchTrueFalseTotal
if /\* \*/ 0 0 0
90 0 $line .= $arg ;
91 }
92 }
93
94 0 $fh -> print ($prefix, $line, "\n") ;
95 }
96 }
97  
« XSBuilder/C/grammar.pm ↑ Summary XSBuilder/MapUtil.pm »