16fb12b70Safresh1package ExtUtils::ParseXS::Eval; 26fb12b70Safresh1use strict; 36fb12b70Safresh1use warnings; 46fb12b70Safresh1 5*e0680481Safresh1our $VERSION = '3.51'; 66fb12b70Safresh1 76fb12b70Safresh1=head1 NAME 86fb12b70Safresh1 96fb12b70Safresh1ExtUtils::ParseXS::Eval - Clean package to evaluate code in 106fb12b70Safresh1 116fb12b70Safresh1=head1 SYNOPSIS 126fb12b70Safresh1 136fb12b70Safresh1 use ExtUtils::ParseXS::Eval; 146fb12b70Safresh1 my $rv = ExtUtils::ParseXS::Eval::eval_typemap_code( 156fb12b70Safresh1 $parsexs_obj, "some Perl code" 166fb12b70Safresh1 ); 176fb12b70Safresh1 186fb12b70Safresh1=head1 SUBROUTINES 196fb12b70Safresh1 206fb12b70Safresh1=head2 $pxs->eval_output_typemap_code($typemapcode, $other_hashref) 216fb12b70Safresh1 226fb12b70Safresh1Sets up various bits of previously global state 236fb12b70Safresh1(formerly ExtUtils::ParseXS package variables) 246fb12b70Safresh1for eval'ing output typemap code that may refer to these 256fb12b70Safresh1variables. 266fb12b70Safresh1 276fb12b70Safresh1Warns the contents of C<$@> if any. 286fb12b70Safresh1 296fb12b70Safresh1Not all these variables are necessarily considered "public" wrt. use in 306fb12b70Safresh1typemaps, so beware. Variables set up from the ExtUtils::ParseXS object: 316fb12b70Safresh1 329f11ffb7Safresh1 $Package $ALIAS $func_name $Full_func_name $pname 336fb12b70Safresh1 346fb12b70Safresh1Variables set up from C<$other_hashref>: 356fb12b70Safresh1 366fb12b70Safresh1 $var $type $ntype $subtype $arg 376fb12b70Safresh1 386fb12b70Safresh1=cut 396fb12b70Safresh1 406fb12b70Safresh1sub eval_output_typemap_code { 416fb12b70Safresh1 my ($_pxs, $_code, $_other) = @_; 426fb12b70Safresh1 436fb12b70Safresh1 my ($Package, $ALIAS, $func_name, $Full_func_name, $pname) 446fb12b70Safresh1 = @{$_pxs}{qw(Package ALIAS func_name Full_func_name pname)}; 456fb12b70Safresh1 466fb12b70Safresh1 my ($var, $type, $ntype, $subtype, $arg) 476fb12b70Safresh1 = @{$_other}{qw(var type ntype subtype arg)}; 486fb12b70Safresh1 496fb12b70Safresh1 my $rv = eval $_code; 506fb12b70Safresh1 warn $@ if $@; 516fb12b70Safresh1 return $rv; 526fb12b70Safresh1} 536fb12b70Safresh1 546fb12b70Safresh1=head2 $pxs->eval_input_typemap_code($typemapcode, $other_hashref) 556fb12b70Safresh1 566fb12b70Safresh1Sets up various bits of previously global state 576fb12b70Safresh1(formerly ExtUtils::ParseXS package variables) 586fb12b70Safresh1for eval'ing output typemap code that may refer to these 596fb12b70Safresh1variables. 606fb12b70Safresh1 616fb12b70Safresh1Warns the contents of C<$@> if any. 626fb12b70Safresh1 636fb12b70Safresh1Not all these variables are necessarily considered "public" wrt. use in 646fb12b70Safresh1typemaps, so beware. Variables set up from the ExtUtils::ParseXS object: 656fb12b70Safresh1 669f11ffb7Safresh1 $Package $ALIAS $func_name $Full_func_name $pname 676fb12b70Safresh1 686fb12b70Safresh1Variables set up from C<$other_hashref>: 696fb12b70Safresh1 706fb12b70Safresh1 $var $type $ntype $subtype $num $init $printed_name $arg $argoff 716fb12b70Safresh1 726fb12b70Safresh1=cut 736fb12b70Safresh1 746fb12b70Safresh1sub eval_input_typemap_code { 756fb12b70Safresh1 my ($_pxs, $_code, $_other) = @_; 766fb12b70Safresh1 776fb12b70Safresh1 my ($Package, $ALIAS, $func_name, $Full_func_name, $pname) 786fb12b70Safresh1 = @{$_pxs}{qw(Package ALIAS func_name Full_func_name pname)}; 796fb12b70Safresh1 806fb12b70Safresh1 my ($var, $type, $num, $init, $printed_name, $arg, $ntype, $argoff, $subtype) 816fb12b70Safresh1 = @{$_other}{qw(var type num init printed_name arg ntype argoff subtype)}; 826fb12b70Safresh1 836fb12b70Safresh1 my $rv = eval $_code; 846fb12b70Safresh1 warn $@ if $@; 856fb12b70Safresh1 return $rv; 866fb12b70Safresh1} 876fb12b70Safresh1 886fb12b70Safresh1=head1 TODO 896fb12b70Safresh1 906fb12b70Safresh1Eventually, with better documentation and possible some cleanup, 916fb12b70Safresh1this could be part of C<ExtUtils::Typemaps>. 926fb12b70Safresh1 936fb12b70Safresh1=cut 946fb12b70Safresh1 956fb12b70Safresh11; 966fb12b70Safresh1 976fb12b70Safresh1# vim: ts=2 sw=2 et: 98