File Coverage

blib/lib/ExtUtils/XSpp/Typemap/reference.pm
Criterion Covered Total %
statement 15 16 93.7
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 4 5 80.0
total 26 29 89.6


line stmt bran cond sub pod time code
1             package ExtUtils::XSpp::Typemap::reference;
2              
3 21     21   168 use base 'ExtUtils::XSpp::Typemap';
  21         87  
  21         773  
4              
5             sub init {
6 59     59 0 79 my $this = shift;
7 59         157 my %args = @_;
8              
9 59 50       128 if( my $base = $args{base} ) {
10             %args = ( xs_type => $base->{XS_TYPE},
11             xs_input_code => $base->{XS_INPUT_CODE},
12             xs_output_code => $base->{XS_OUTPUT_CODE},
13 0         0 %args );
14             }
15              
16 59         133 $this->{XS_TYPE} = $args{xs_type};
17 59         104 $this->{NAME} = $args{name};
18 59         122 $this->{TYPE} = $args{type};
19             }
20              
21             sub cpp_type {
22 14     14 1 52 my $type = $_[0]->type;
23 14         46 $type->base_type . $type->print_tmpl_args . ('*' x ($type->is_pointer+1))
24             }
25 1     1 1 3 sub output_code { undef }
26 5     5 1 11 sub call_parameter_code { "*( $_[1] )" }
27             sub call_function_code {
28 2     2 1 4 my $type = $_[0]->type;
29 2         4 $_[2] . ' = new ' . $type->base_type . $type->print_tmpl_args . '( ' . $_[1] . " )";
30             }
31              
32             1;