blib/lib/ExtUtils/Typemaps/InputMap.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran 83.3% 10 / 12 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 7 / 7 Podpod 100% 4 / 4 totaltotal 84.1% 53 / 63 CC 9 SCAR 16.3
CC
9
Cov
88%
new
8.4
code
2.1
BEGIN
1.0
CRAP 5.1
« blib/lib/ExtUtils/Typemaps/Cmd.pm ↑ Summary blib/lib/ExtUtils/Typemaps/OutputMap.pm »
1 package ExtUtils::Typemaps::InputMap;
2 24 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 24 our $VERSION = '3.64';
6  
7 =head1 NAME
8  
9 ExtUtils::Typemaps::InputMap - Entry in the INPUT section of a typemap
10  
11 =head1 SYNOPSIS
12  
13 use ExtUtils::Typemaps;
14 ...
15 my $input = $typemap->get_input_map('T_NV');
16 my $code = $input->code();
17 $input->code("...");
18  
19 =head1 DESCRIPTION
20  
21 Refer to L<ExtUtils::Typemaps> for details.
22  
23 =head1 METHODS
24  
25 =cut
26  
27 =head2 new
28  
29 Requires C<xstype> and C<code> parameters.
30  
31 =cut
32  
33 112843 ▶sub new {
Subroutine new: called CC=8 SCAR=21.3
Pod documented
34 112843 my $prot = shift;
35 112843 ▶ my $class = ref($prot)||$prot;
Condition66%2/3
ref $prot || $prot
l!l&&r!l&&!r
75216376270
MC/DC0%0/2
ref $prot || $prot
ref $prot $prot
Truth table66%2/3
A || B
A= ref $protB= $prot
ABresult
1X1
011
000
36 112843 my %args = @_;
37  
38 112843 ▶ if (!ref($prot)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $prot) 37627 75216 112843
39 37627 ▶ if (not defined $args{xstype} or not defined $args{code}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"xstype"} and defined $args{"code"}) 0 37627 37627
Condition33%1/3
defined $args{"xstype"} and defined $args{"code"}
!ll&&!rl&&r
0037627
MC/DC0%0/2
defined $args{"xstype"} and defined $args{"code"}
defined $args{"xstype"} defined $args{"code"}
Truth table33%1/3
A and B
A= defined $args{"xstype"}B= defined $args{"code"}
ABresult
0X0
100
111
40 0 die("Need xstype and code parameters");
41 }
42 }
43  
44 112843 ▶ my $self = bless(
Branch: 1 branch
BranchTrueFalseTotal
ref $prot ? : 75216 37627 112843
45 (ref($prot) ? {%$prot} : {})
46 => $class
47 );
48  
49 112843 ▶ $self->{xstype} = $args{xstype} if defined $args{xstype};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"xstype"} 37627 75216 112843
50 112843 ▶ $self->{code} = $args{code} if defined $args{code};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"code"} 37627 75216 112843
51 112843 $self->{code} =~ s/^(?=\S)/\t/mg;
52  
53 112843 return $self;
54 }
55  
56 =head2 code
57  
58 Returns or sets the INPUT mapping code for this entry.
59  
60 =cut
61  
62 528 ▶sub code {
Subroutine code: called CC=2 SCAR=7.2
Pod documented
63 528 ▶ $_[0]->{code} = $_[1] if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 528 528
64 528 return $_[0]->{code};
65 }
66  
67 =head2 xstype
68  
69 Returns the name of the XS type of the INPUT map.
70  
71 =cut
72  
73 150482 ▶sub xstype {
Subroutine xstype: called CC=1 SCAR=0.0
Pod documented
74 150482 return $_[0]->{xstype};
75 }
76  
77 =head2 cleaned_code
78  
79 Returns a cleaned-up copy of the code to which certain transformations
80 have been applied to make it more ANSI compliant.
81  
82 =cut
83  
84 398 ▶sub cleaned_code {
Subroutine cleaned_code: called CC=1 SCAR=0.0
Pod documented
85 398 my $self = shift;
86 398 my $code = $self->code;
87  
88 398 $code =~ s/(?:;+\s*|;*\s+)\z//s;
89  
90 # Move C pre-processor instructions to column 1 to be strictly ANSI
91 # conformant. Some pre-processors are fussy about this.
92 398 $code =~ s/^\s+#/#/mg;
93 398 $code =~ s/\s*\z/\n/;
94  
95 398 return $code;
96 }
97  
98 =head1 SEE ALSO
99  
100 L<ExtUtils::Typemaps>
101  
102 =head1 AUTHOR
103  
104 Steffen Mueller C<<smueller@cpan.org>>
105  
106 =head1 COPYRIGHT & LICENSE
107  
108 Copyright 2009, 2010, 2011, 2012 Steffen Mueller
109  
110 This program is free software; you can redistribute it and/or
111 modify it under the same terms as Perl itself.
112  
113 =cut
114  
115 24 1;
116  
« blib/lib/ExtUtils/Typemaps/Cmd.pm ↑ Summary blib/lib/ExtUtils/Typemaps/OutputMap.pm »