blib/lib/ExtUtils/Typemaps/Magic.pm

filter: Statementstmt 50.0% 11 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 50.0% 1 / 2 totaltotal 51.7% 15 / 29 CC 1 SCAR 3.4
CC
1
Cov
50%
new
2.0
minimum_pxs
2.0
BEGIN
1.0
CRAP 1.4
↑ Summary
1 package ExtUtils::Typemaps::Magic;
2 1 $ExtUtils::Typemaps::Magic::VERSION = '0.003';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use parent 'ExtUtils::Typemaps';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
10  
11 0 my $self = $class->SUPER::new(@_);
12  
13 0 my $input = <<'END';
14 {
15 MAGIC* magic = SvROK($arg) && SvMAGICAL(SvRV($arg)) ? mg_findext(SvRV($arg), PERL_MAGIC_ext, %s) : NULL;
16 if (magic)
17 $var = (${type})magic->mg_ptr;
18 else
19 Perl_croak(aTHX_ \"${ntype} object is lacking magic\");
20 }
21 END
22  
23 0 $self->add_inputmap(xstype => 'T_MAGIC', code => sprintf $input, 'NULL');
24 0 $self->add_inputmap(xstype => 'T_MAGICBUF', code => sprintf $input, 'NULL');
25 0 $self->add_inputmap(xstype => 'T_MAGICEXT', code => sprintf $input, '&${type}_magic');
26  
27 0 $self->add_outputmap(xstype => 'T_MAGIC', code => ' sv_magic(newSVrv($arg, \"${ntype}\"), NULL, PERL_MAGIC_ext, (const char*)$var, 0);');
28 0 $self->add_outputmap(xstype => 'T_MAGICBUF', code => ' sv_magic(newSVrv($arg, \"${ntype}\"), NULL, PERL_MAGIC_ext, (const char*)$var, sizeof(*$var));');
29  
30 0 $self->add_outputmap(xstype => 'T_MAGICEXT', code => <<'END');
31 {
32 MAGIC* magic = sv_magicext(newSVrv($arg, \"${ntype}\"), NULL, PERL_MAGIC_ext, &${type}_magic, (const char*)$var, 0);
33 magic->mg_flags |= MGf_COPY|MGf_DUP;
34 }
35 END
36  
37 0 return $self;
38 }
39  
40 sub minimum_pxs {
41 0 ▶ return '3.50';
Subroutine minimum_pxs: not called CC=1 SCAR=6.9
Pod undocumented
42 }
43  
44 1 1;
45  
46 # ABSTRACT: Typemap for storing objects in magic
47  
48 __END__
↑ Summary