File Coverage

lib/ExtUtils/Typemaps/Basic.pm
Criterion Covered Total %
statement 27 27 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 32 32 100.0


line stmt bran cond sub pod time code
1             package ExtUtils::Typemaps::Basic;
2              
3 1     1   978 use strict;
  1         2  
  1         34  
4 1     1   5 use warnings;
  1         2  
  1         25  
5 1     1   5 use ExtUtils::Typemaps;
  1         2  
  1         435  
6              
7             our $VERSION = '1.05';
8              
9             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 is an C
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 object.
41             It acts as any other C object, except that
42             it has the object maps initialized.
43              
44             =cut
45              
46             sub new {
47 2     2 1 1034 my $class = shift;
48              
49 2         8 my @iv_types = (qw(int short long char), "short int", "long int", "long long");
50 2         7 my @uv_types = ((map {"unsigned $_"} @iv_types), qw(unsigned Uint16 Uint32 Uint64 size_t bool));
  14         36  
51 2         6 @iv_types = map {($_, "signed $_")} @iv_types;
  14         37  
52 2         11 push @iv_types, qw(time_t Sint16 Sint32 Sint64);
53 2         5 my @nv_types = (qw(float double), "long double");
54              
55 2         7 my $map = "TYPEMAP\n";
56 2         38 $map .= "$_\tT_IV\n" for @iv_types;
57 2         22 $map .= "$_\tT_UV\n" for @uv_types;
58 2         12 $map .= "$_\tT_NV\n" for @nv_types;
59              
60 2         28 $map .= "const $_\tT_IV\n" for @iv_types;
61 2         23 $map .= "const $_\tT_UV\n" for @uv_types;
62 2         12 $map .= "const $_\tT_NV\n" for @nv_types;
63              
64 2         16 my $self = $class->SUPER::new(@_);
65 2         58 $self->add_string(string => $map);
66              
67 2         33627 return $self;
68             }
69              
70             1;
71              
72             __END__