blib/lib/ExtUtils/Typemaps/Type.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 81.2% 13 / 16 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 5 / 5 totaltotal 83.5% 56 / 67 CC 11 SCAR 16.9
CC
11
Cov
86%
new
9.4
ctype
2.1
proto
2.1
CRAP 5.4
« blib/lib/ExtUtils/Typemaps.pm ↑ Summary blib/lib/ExtUtils/Typemaps/Cmd.pm »
1 package ExtUtils::Typemaps::Type;
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 require ExtUtils::Typemaps;
6  
7 24 our $VERSION = '3.64';
8  
9 =head1 NAME
10  
11 ExtUtils::Typemaps::Type - Entry in the TYPEMAP section of a typemap
12  
13 =head1 SYNOPSIS
14  
15 use ExtUtils::Typemaps;
16 ...
17 my $type = $typemap->get_type_map('char*');
18 my $input = $typemap->get_input_map($type->xstype);
19  
20 =head1 DESCRIPTION
21  
22 Refer to L<ExtUtils::Typemaps> for details.
23 Object associates C<ctype> with C<xstype>, which is the index
24 into the in- and output mapping tables.
25  
26 =head1 METHODS
27  
28 =cut
29  
30 =head2 new
31  
32 Requires C<xstype> and C<ctype> parameters.
33  
34 Optionally takes C<prototype> parameter. Note however that the method to
35 get/set the value is called C<proto> rather than <prototype>.
36  
37 =cut
38  
39 135344 ▶sub new {
Subroutine new: called CC=9 SCAR=22.4
Pod documented
40 135344 my $prot = shift;
41 135344 ▶ my $class = ref($prot)||$prot;
Condition66%2/3
ref $prot || $prot
l!l&&r!l&&!r
90213451310
MC/DC0%0/2
ref $prot || $prot
ref $prot $prot
Truth table66%2/3
A || B
A= ref $protB= $prot
ABresult
1X1
011
000
42 135344 my %args = @_;
43  
44 135344 ▶ if (!ref($prot)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $prot) 45131 90213 135344
45 45131 ▶ if (not defined $args{xstype} or not defined $args{ctype}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"xstype"} and defined $args{"ctype"}) 0 45131 45131
Condition33%1/3
defined $args{"xstype"} and defined $args{"ctype"}
!ll&&!rl&&r
0045131
MC/DC0%0/2
defined $args{"xstype"} and defined $args{"ctype"}
defined $args{"xstype"} defined $args{"ctype"}
Truth table33%1/3
A and B
A= defined $args{"xstype"}B= defined $args{"ctype"}
ABresult
0X0
100
111
46 0 die("Need xstype and ctype parameters");
47 }
48 }
49  
50 135344 ▶ my $self = bless(
Branch: 1 branch
BranchTrueFalseTotal
ref $prot ? : 90213 45131 135344
51 (ref($prot) ? {%$prot} : {proto => ''})
52 => $class
53 );
54  
55 135344 ▶ $self->{xstype} = $args{xstype} if defined $args{xstype};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"xstype"} 45131 90213 135344
56 135344 ▶ $self->{ctype} = $args{ctype} if defined $args{ctype};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"ctype"} 45131 90213 135344
57 135344 $self->{tidy_ctype} = ExtUtils::Typemaps::tidy_type($self->{ctype});
58 135344 ▶ $self->{proto} = $args{'prototype'} if defined $args{'prototype'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"prototype"} 110 135234 135344
59  
60 135344 return $self;
61 }
62  
63 =head2 proto
64  
65 Returns or sets the prototype.
66  
67 =cut
68  
69 649 ▶sub proto {
Subroutine proto: called CC=2 SCAR=7.2
Pod documented
70 649 ▶ $_[0]->{proto} = $_[1] if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 649 649
71 649 return $_[0]->{proto};
72 }
73  
74 =head2 xstype
75  
76 Returns the name of the XS type that this C type is associated to.
77  
78 =cut
79  
80 1784 ▶sub xstype {
Subroutine xstype: called CC=1 SCAR=0.0
Pod documented
81 1784 return $_[0]->{xstype};
82 }
83  
84 =head2 ctype
85  
86 Returns the name of the C type as it was set on construction.
87  
88 =cut
89  
90 90270 ▶sub ctype {
Subroutine ctype: called CC=2 SCAR=7.6
Pod documented
91 90270 ▶ return defined($_[0]->{ctype}) ? $_[0]->{ctype} : $_[0]->{tidy_ctype};
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0]{'ctype'} ? : 90270 0 90270
92 }
93  
94 =head2 tidy_ctype
95  
96 Returns the canonicalized name of the C type.
97  
98 =cut
99  
100 90230 ▶sub tidy_ctype {
Subroutine tidy_ctype: called CC=1 SCAR=0.0
Pod documented
101 90230 return $_[0]->{tidy_ctype};
102 }
103  
104 =head1 SEE ALSO
105  
106 L<ExtUtils::Typemaps>
107  
108 =head1 AUTHOR
109  
110 Steffen Mueller C<<smueller@cpan.org>>
111  
112 =head1 COPYRIGHT & LICENSE
113  
114 Copyright 2009, 2010, 2011, 2012 Steffen Mueller
115  
116 This program is free software; you can redistribute it and/or
117 modify it under the same terms as Perl itself.
118  
119 =cut
120  
121 24 1;
122  
« blib/lib/ExtUtils/Typemaps.pm ↑ Summary blib/lib/ExtUtils/Typemaps/Cmd.pm »