Commit | Line | Data |
---|---|---|
7320491e | 1 | package ExtUtils::Typemaps::OutputMap; |
297f4492 S |
2 | use 5.006001; |
3 | use strict; | |
4 | use warnings; | |
5 | our $VERSION = '0.05'; | |
6 | use Carp qw(croak); | |
7 | ||
8 | =head1 NAME | |
9 | ||
7320491e | 10 | ExtUtils::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 | 22 | Refer to L<ExtUtils::Typemaps> for details. |
297f4492 S |
23 | |
24 | =head1 METHODS | |
25 | ||
26 | =cut | |
27 | ||
28 | =head2 new | |
29 | ||
30 | Requires C<xstype> and C<code> parameters. | |
31 | ||
32 | =cut | |
33 | ||
34 | sub 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 | ||
59 | Returns or sets the OUTPUT mapping code for this entry. | |
60 | ||
61 | =cut | |
62 | ||
63 | sub code { | |
64 | $_[0]->{code} = $_[1] if @_ > 1; | |
65 | return $_[0]->{code}; | |
66 | } | |
67 | ||
68 | =head2 xstype | |
69 | ||
70 | Returns the name of the XS type of the OUTPUT map. | |
71 | ||
72 | =cut | |
73 | ||
74 | sub xstype { | |
75 | return $_[0]->{xstype}; | |
76 | } | |
77 | ||
78 | =head1 SEE ALSO | |
79 | ||
7320491e | 80 | L<ExtUtils::Typemaps> |
297f4492 S |
81 | |
82 | =head1 AUTHOR | |
83 | ||
84 | Steffen Mueller C<<smueller@cpan.org>> | |
85 | ||
86 | =head1 COPYRIGHT & LICENSE | |
87 | ||
0b19625b | 88 | Copyright 2009-2011 Steffen Mueller |
297f4492 S |
89 | |
90 | This program is free software; you can redistribute it and/or | |
91 | modify it under the same terms as Perl itself. | |
92 | ||
93 | =cut | |
94 | ||
95 | 1; | |
96 |