File: reference.pm

package info (click to toggle)
libextutils-xspp-perl 0.1800-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 996 kB
  • ctags: 1,861
  • sloc: perl: 8,324; cpp: 125; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 779 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package ExtUtils::XSpp::Typemap::reference;

use base 'ExtUtils::XSpp::Typemap';

sub init {
  my $this = shift;
  my %args = @_;

  if( my $base = $args{base} ) {
    %args = ( xs_type => $base->{XS_TYPE},
              xs_input_code => $base->{XS_INPUT_CODE},
              xs_output_code => $base->{XS_OUTPUT_CODE},
              %args );
  }

  $this->{XS_TYPE} = $args{xs_type};
  $this->{NAME} = $args{name};
  $this->{TYPE} = $args{type};
}

sub cpp_type {
  my $type = $_[0]->type;
  $type->base_type . $type->print_tmpl_args . ('*' x ($type->is_pointer+1))
}
sub output_code { undef }
sub call_parameter_code { "*( $_[1] )" }
sub call_function_code {
  my $type = $_[0]->type;
  $_[2] . ' = new ' . $type->base_type . $type->print_tmpl_args . '( ' . $_[1] . " )";
}

1;