blib/lib/ExtUtils/ParseXS/Eval.pm

filter: Statementstmt 100% 20 / 20 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 93.3% 28 / 30 CC 3 SCAR 5.1
CC
3
Cov
92%
eval_output_typemap_code
2.0
eval_input_typemap_code
2.0
BEGIN
1.0
CRAP 1.7
« blib/lib/ExtUtils/ParseXS/CountLines.pm ↑ Summary blib/lib/ExtUtils/ParseXS/Constants.pm »
1 package ExtUtils::ParseXS::Eval;
2 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 28 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 28 our $VERSION = '3.64';
6  
7 =head1 NAME
8  
9 ExtUtils::ParseXS::Eval - Clean package to evaluate code in
10  
11 =head1 SYNOPSIS
12  
13 use ExtUtils::ParseXS::Eval;
14 my $rv = ExtUtils::ParseXS::Eval::eval_typemap_code(
15 $parsexs_obj, "some Perl code"
16 );
17  
18 =head1 SUBROUTINES
19  
20 =head2 $pxs->eval_output_typemap_code($typemapcode, $other_hashref)
21  
22 Sets up various bits of previously global state
23 (formerly ExtUtils::ParseXS package variables)
24 for eval'ing output typemap code that may refer to these
25 variables.
26  
27 Warns the contents of C<$@> if any.
28  
29 Not all these variables are necessarily considered "public" wrt. use in
30 typemaps, so beware. Variables set up from C<$other_hashref>:
31  
32 $Package $func_name $Full_func_name $pname
33 $var $type $ntype $subtype $arg $ALIAS
34  
35 =cut
36  
37 283 ▶sub eval_output_typemap_code {
Subroutine eval_output_typemap_code: called CC=2 SCAR=7.0
Pod documented
38 283 my ($_pxs, $_code, $_other) = @_;
39  
40 my ($Package, $var, $type, $ntype, $subtype, $arg, $ALIAS, $func_name, $Full_func_name, $pname)
41 283 = @{$_other}{qw(Package var type ntype subtype arg alias func_name full_C_name full_perl_name)};
42  
43 283 my $rv = eval $_code;
44 283 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 283 283
45 283 return $rv;
46 }
47  
48 =head2 $pxs->eval_input_typemap_code($typemapcode, $other_hashref)
49  
50 Sets up various bits of previously global state
51 (formerly ExtUtils::ParseXS package variables)
52 for eval'ing output typemap code that may refer to these
53 variables.
54  
55 Warns the contents of C<$@> if any.
56  
57 Not all these variables are necessarily considered "public" wrt. use in
58 typemaps, so beware. Variables set up from C<$other_hashref>:
59  
60 $Package $func_name $Full_func_name $pname
61 $var $type $ntype $subtype $num $init $printed_name $arg $argoff $ALIAS
62  
63 =cut
64  
65 435 ▶sub eval_input_typemap_code {
Subroutine eval_input_typemap_code: called CC=2 SCAR=7.0
Pod documented
66 435 my ($_pxs, $_code, $_other) = @_;
67  
68 my ($Package, $var, $type, $num, $init, $printed_name, $arg, $ntype, $argoff, $subtype, $ALIAS, $func_name, $Full_func_name, $pname)
69 435 = @{$_other}{qw(Package var type num init printed_name arg ntype argoff subtype alias func_name full_C_name full_perl_name)};
70  
71 435 my $rv = eval $_code;
72 435 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 435 435
73 435 return $rv;
74 }
75  
76 =head1 TODO
77  
78 Eventually, with better documentation and possible some cleanup,
79 this could be part of C<ExtUtils::Typemaps>.
80  
81 =cut
82  
83 28 1;
84  
85 # vim: ts=2 sw=2 et:
« blib/lib/ExtUtils/ParseXS/CountLines.pm ↑ Summary blib/lib/ExtUtils/ParseXS/Constants.pm »