| 1 | package ExtUtils::Typemaps::Basic; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use ExtUtils::Typemaps; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 2 | our $VERSION = '1.07'; | |
| 8 | |||
| 9 | 2 | our @ISA = qw(ExtUtils::Typemaps); | |
| 10 | |||
| 11 | =head1 NAME | ||
| 12 | |||
| 13 | ExtUtils::Typemaps::Basic - A set of typemaps for simple types | ||
| 14 | |||
| 15 | =head1 SYNOPSIS | ||
| 16 | |||
| 17 | use ExtUtils::Typemaps::Basic; | ||
| 18 | # First, read my own type maps: | ||
| 19 | my $private_map = ExtUtils::Typemaps->new(file => 'my.map'); | ||
| 20 | |||
| 21 | # Then, get additional typemaps and merge them into mine | ||
| 22 | $private_map->merge(typemap => ExtUtils::Typemaps::Basic->new); | ||
| 23 | |||
| 24 | # Now, write the combined map to an output file | ||
| 25 | $private_map->write(file => 'typemap'); | ||
| 26 | |||
| 27 | =head1 DESCRIPTION | ||
| 28 | |||
| 29 | C<ExtUtils::Typemaps::Basic> is an C<ExtUtils::Typemaps> | ||
| 30 | subclass that provides a set of mappings for some basic | ||
| 31 | integer, unsigned, and floating point types that aren't | ||
| 32 | in perl's builtin typemap. | ||
| 33 | |||
| 34 | =head1 METHODS | ||
| 35 | |||
| 36 | These are the overridden methods: | ||
| 37 | |||
| 38 | =head2 new | ||
| 39 | |||
| 40 | Creates a new C<ExtUtils::Typemaps::Basic> object. | ||
| 41 | It acts as any other C<ExtUtils::Typemaps> object, except that | ||
| 42 | it has the object maps initialized. | ||
| 43 | |||
| 44 | =cut | ||
| 45 | |||
| 46 | 3 | ▶ | sub new { |
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
documented
| |||
| 47 | 3 | my $class = shift; | |
| 48 | |||
| 49 | 3 | my @iv_types = (qw(int short long char), "short int", "long int", "long long"); | |
| 50 | 3 | my @uv_types = ((map {"unsigned $_"} @iv_types), qw(unsigned Uint16 Uint32 Uint64 size_t bool)); | |
| 51 | 3 | @iv_types = map {($_, "signed $_")} @iv_types; | |
| 52 | 3 | push @iv_types, qw(time_t Sint16 Sint32 Sint64); | |
| 53 | 3 | my @nv_types = (qw(float double), "long double"); | |
| 54 | |||
| 55 | 3 | my $map = "TYPEMAP\n"; | |
| 56 | 3 | $map .= "$_\tT_IV\n" for @iv_types; | |
| 57 | 3 | $map .= "$_\tT_UV\n" for @uv_types; | |
| 58 | 3 | $map .= "$_\tT_NV\n" for @nv_types; | |
| 59 | |||
| 60 | 3 | $map .= "const $_\tT_IV\n" for @iv_types; | |
| 61 | 3 | $map .= "const $_\tT_UV\n" for @uv_types; | |
| 62 | 3 | $map .= "const $_\tT_NV\n" for @nv_types; | |
| 63 | |||
| 64 | 3 | my $self = $class->SUPER::new(@_); | |
| 65 | 3 | $self->add_string(string => $map); | |
| 66 | |||
| 67 | 3 | return $self; | |
| 68 | } | ||
| 69 | |||
| 70 | 2 | 1; | |
| 71 | |||
| 72 | __END__ | ||