File Coverage

blib/lib/ExtUtils/Typemaps/IntObj.pm
Criterion Covered Total %
statement 9 16 56.2
branch n/a
condition n/a
subroutine 3 4 75.0
pod 1 1 100.0
total 13 21 61.9


line stmt bran cond sub pod time code
1             package ExtUtils::Typemaps::IntObj;
2             $ExtUtils::Typemaps::IntObj::VERSION = '0.004';
3 2     2   505905 use strict;
  2         5  
  2         86  
4 2     2   13 use warnings;
  2         1145  
  2         162  
5              
6 2     2   23 use parent 'ExtUtils::Typemaps';
  2         3  
  2         18  
7              
8             my $output = <<'END';
9             {
10             sv_setref_uv($arg, %s, (UV)$var);
11             SvREADONLY_on(SvRV($arg));
12             }
13             END
14              
15             sub new {
16 0     0 1   my $class = shift;
17              
18 0           my $self = $class->SUPER::new(@_);
19              
20 0           $self->add_inputmap(xstype => 'T_INTOBJ', code => <<'END');
21             {
22             SV * sv = $arg;
23             if (SvROK(sv) && sv_derived_from(sv, \"$ntype\"))
24             $var = ($type)SvUV(SvRV(sv));
25             else
26             croak(\"%s: %s is not of type %s\", ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, \"$var\", \"$ntype\");
27             }
28             END
29 0           $self->add_inputmap(xstype => 'T_INTREF', code => <<'END');
30             {
31             SV * sv = $arg;
32             if (SvROK(sv) && SvIOK(SvRV(sv)))
33             $var = ($type)SvUV(SvRV(sv));
34             else
35             croak(\"%s: %s is not a reference\", ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, \"$var\");
36             }
37             END
38              
39 0           $self->add_outputmap(xstype => 'T_INTOBJ', code => sprintf $output, '\\"$ntype\\"');
40 0           $self->add_outputmap(xstype => 'T_INTREF', code => sprintf $output, 'NULL');
41              
42 0           return $self;
43             }
44              
45             1;
46              
47             # ABSTRACT: Typemap for storing int-like handles as objects
48              
49             __END__