Typemaps/Basic.pm

filter: Statementstmt 100% 30 / 30 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 35 / 35 CC 7 SCAR 16.5
CC
7
Cov
100%
new
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.2
↑ Summary Typemap/Basic.pm »
1 package ExtUtils::Typemaps::Basic;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use ExtUtils::Typemaps;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '1.06';
8  
9 1 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 2 ▶sub new {
Subroutine new: called CC=7 SCAR=19.5
Pod documented
47 2 my $class = shift;
48  
49 2 my @iv_types = (qw(int short long char), "short int", "long int", "long long");
50 2 my @uv_types = ((map {"unsigned $_"} @iv_types), qw(unsigned Uint16 Uint32 Uint64 size_t bool));
51 2 @iv_types = map {($_, "signed $_")} @iv_types;
52 2 push @iv_types, qw(time_t Sint16 Sint32 Sint64);
53 2 my @nv_types = (qw(float double), "long double");
54  
55 2 my $map = "TYPEMAP\n";
56 2 $map .= "$_\tT_IV\n" for @iv_types;
57 2 $map .= "$_\tT_UV\n" for @uv_types;
58 2 $map .= "$_\tT_NV\n" for @nv_types;
59  
60 2 $map .= "const $_\tT_IV\n" for @iv_types;
61 2 $map .= "const $_\tT_UV\n" for @uv_types;
62 2 $map .= "const $_\tT_NV\n" for @nv_types;
63  
64 2 my $self = $class->SUPER::new(@_);
65 2 $self->add_string(string => $map);
66  
67 2 return $self;
68 }
69  
70 1 1;
71  
72 __END__
↑ Summary Typemap/Basic.pm »