Install/FrozenShit/Typemaps/Type.pm

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