line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Imager::ExtUtils; |
2
|
2
|
|
|
2
|
|
1188
|
use 5.006; |
|
2
|
|
|
|
|
6
|
|
3
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
34
|
|
4
|
2
|
|
|
2
|
|
6
|
use File::Spec; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
747
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "1.003"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Imager::ExtUtils - functions handy in writing Imager extensions |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# make Imager easier to use with Inline |
15
|
|
|
|
|
|
|
# perldoc Imager::Inline |
16
|
|
|
|
|
|
|
use Inline with => 'Imager'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=over |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item base_dir |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Returns the base directory where Imager is installed. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# figure out where Imager is installed |
29
|
|
|
|
|
|
|
sub base_dir { |
30
|
3
|
|
|
3
|
1
|
10
|
for my $inc_dir (@INC) { |
31
|
6
|
100
|
|
|
|
66
|
if (-e "$inc_dir/Imager.pm") { |
32
|
3
|
|
|
|
|
7
|
my $base_dir = $inc_dir; |
33
|
3
|
100
|
|
|
|
20
|
unless (File::Spec->file_name_is_absolute($base_dir)) { |
34
|
1
|
|
|
|
|
27
|
$base_dir = File::Spec->rel2abs($base_dir); |
35
|
|
|
|
|
|
|
} |
36
|
3
|
|
|
|
|
9
|
return $base_dir; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
die "Cannot locate an installed Imager!"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item inline_config |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Implements Imager's Inline::C C hook. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub inline_config { |
50
|
0
|
|
|
0
|
1
|
0
|
my ($class) = @_; |
51
|
0
|
|
|
|
|
0
|
my $base = base_dir(); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
|
|
0
|
INC => $class->includes, |
56
|
|
|
|
|
|
|
TYPEMAPS => $class->typemap, |
57
|
|
|
|
|
|
|
AUTO_INCLUDE => <
|
58
|
|
|
|
|
|
|
/* Inserted by Imager $Imager::VERSION */ |
59
|
|
|
|
|
|
|
#include "imext.h" |
60
|
|
|
|
|
|
|
#include "imperl.h" |
61
|
|
|
|
|
|
|
DEFINE_IMAGER_CALLBACKS; |
62
|
|
|
|
|
|
|
CODE |
63
|
|
|
|
|
|
|
BOOT => 'PERL_INITIALIZE_IMAGER_CALLBACKS;', |
64
|
|
|
|
|
|
|
FILTERS => \&_inline_filter, |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my @inline_replace = |
69
|
|
|
|
|
|
|
qw( |
70
|
|
|
|
|
|
|
Imager::ImgRaw |
71
|
|
|
|
|
|
|
Imager::Color::Float |
72
|
|
|
|
|
|
|
Imager::Color |
73
|
|
|
|
|
|
|
Imager::IO |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my %inline_replace = |
77
|
|
|
|
|
|
|
map { (my $tmp = $_) =~ s/::/__/g; $_ => $tmp } @inline_replace; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $inline_replace_re = "\\b(" . join('|', @inline_replace) . ")\\b"; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _inline_filter { |
82
|
0
|
|
|
0
|
|
0
|
my $code = shift; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
0
|
$code =~ s/$inline_replace_re/$inline_replace{$1}/g; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
$code; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item includes |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns -I options suitable for use with ExtUtils::MakeMaker's INC |
92
|
|
|
|
|
|
|
option. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub includes { |
97
|
1
|
|
|
1
|
1
|
434
|
my $class = shift; |
98
|
1
|
|
|
|
|
3
|
my $base = $class->base_dir(); |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
4
|
"-I" . $base . '/Imager/include', |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item typemap |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns the full path to Imager's installed typemap. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub typemap { |
110
|
1
|
|
|
1
|
1
|
487
|
my $class = shift; |
111
|
1
|
|
|
|
|
2
|
my $base = $class->base_dir(); |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
5
|
$base . '/Imager/typemap'; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |