This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Implement 'skip' option for merging typemaps
[perl5.git] / dist / ExtUtils-ParseXS / lib / ExtUtils / Typemaps / OutputMap.pm
CommitLineData
7320491e 1package ExtUtils::Typemaps::OutputMap;
297f4492
S
2use 5.006001;
3use strict;
4use warnings;
5our $VERSION = '0.05';
6use Carp qw(croak);
7
8=head1 NAME
9
7320491e 10ExtUtils::Typemaps::OutputMap - Entry in the OUTPUT section of a typemap
297f4492
S
11
12=head1 SYNOPSIS
13
7320491e 14 use ExtUtils::Typemaps;
297f4492
S
15 ...
16 my $output = $typemap->get_output_map('T_NV');
17 my $code = $output->code();
18 $output->code("...");
19
20=head1 DESCRIPTION
21
7320491e 22Refer to L<ExtUtils::Typemaps> for details.
297f4492
S
23
24=head1 METHODS
25
26=cut
27
28=head2 new
29
30Requires C<xstype> and C<code> parameters.
31
32=cut
33
34sub new {
35 my $prot = shift;
36 my $class = ref($prot)||$prot;
37 my %args = @_;
38
39 if (!ref($prot)) {
40 if (not defined $args{xstype} or not defined $args{code}) {
41 croak("Need xstype and code parameters");
42 }
43 }
44
45 my $self = bless(
46 (ref($prot) ? {%$prot} : {})
47 => $class
48 );
49
50 $self->{xstype} = $args{xstype} if defined $args{xstype};
51 $self->{code} = $args{code} if defined $args{code};
52 $self->{code} =~ s/^(?=\S)/\t/mg;
53
54 return $self;
55}
56
57=head2 code
58
59Returns or sets the OUTPUT mapping code for this entry.
60
61=cut
62
63sub code {
64 $_[0]->{code} = $_[1] if @_ > 1;
65 return $_[0]->{code};
66}
67
68=head2 xstype
69
70Returns the name of the XS type of the OUTPUT map.
71
72=cut
73
74sub xstype {
75 return $_[0]->{xstype};
76}
77
78=head1 SEE ALSO
79
7320491e 80L<ExtUtils::Typemaps>
297f4492
S
81
82=head1 AUTHOR
83
84Steffen Mueller C<<smueller@cpan.org>>
85
86=head1 COPYRIGHT & LICENSE
87
0b19625b 88Copyright 2009-2011 Steffen Mueller
297f4492
S
89
90This program is free software; you can redistribute it and/or
91modify it under the same terms as Perl itself.
92
93=cut
94
951;
96