File Coverage

blib/lib/ExtUtils/Typemaps/Magic.pm
Criterion Covered Total %
statement 9 14 64.2
branch n/a
condition n/a
subroutine 3 4 75.0
pod 1 1 100.0
total 13 19 68.4


line stmt bran cond sub pod time code
1             package ExtUtils::Typemaps::Magic;
2             $ExtUtils::Typemaps::Magic::VERSION = '0.009';
3 1     1   186369 use strict;
  1         3  
  1         49  
4 1     1   7 use warnings;
  1         3  
  1         123  
5              
6 1     1   14 use parent 'ExtUtils::Typemaps';
  1         2  
  1         9  
7              
8             sub new {
9 0     0 1   my $class = shift;
10 0           my $self = $class->SUPER::new(@_);
11              
12 0           $self->add_inputmap(xstype => 'T_MAGIC', code => <<'END');
13             {
14             SV* arg = $arg;
15             MAGIC* magic = SvROK(arg) && SvRMAGICAL(SvRV(arg)) ? mg_findext(SvRV(arg), PERL_MAGIC_ext, NULL) : NULL;
16             if (magic)
17             $var = ($type)magic->mg_ptr;
18             else
19             Perl_croak(aTHX_ \"%s object is lacking magic\", \"$ntype\");
20             }
21             END
22              
23 0           $self->add_outputmap(xstype => 'T_MAGIC', code => ' sv_magicext(newSVrv($arg, "$ntype"), NULL, PERL_MAGIC_ext, NULL, (const char*)$var, 0);');
24              
25 0           return $self;
26             }
27              
28             1;
29              
30             # ABSTRACT: Typemap for storing objects in magic
31              
32             __END__