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