line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ExtUtils::Typemaps::STL::Extra; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
146595
|
use 5.006; |
|
2
|
|
|
|
|
6
|
|
4
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
37
|
|
5
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
37
|
|
6
|
2
|
|
|
2
|
|
965
|
use utf8; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
7
|
|
7
|
2
|
|
|
2
|
|
491
|
use ExtUtils::Typemaps; |
|
2
|
|
|
|
|
23125
|
|
|
2
|
|
|
|
|
212
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=encoding utf-8 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
ExtUtils::Typemaps::STL::Extra - Extra typemaps for STL types |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.01 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
22
|
|
|
|
|
|
|
our @ISA = qw(ExtUtils::Typemaps); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Module::Build::WithXSpp; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $build = Module::Build::WithXSpp->new( |
29
|
|
|
|
|
|
|
extra_typemap_modules => { |
30
|
|
|
|
|
|
|
'ExtUtils::Typemaps::STL::Extra' => '0' |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This module add extra typemaps for STL types to make it easier wrapping C++ using L |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Creates a new ExtUtils::Typemaps::STL::Extra object. It acts as any other ExtUtils::Typemaps object, except that it has the extra type maps initialized. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new { |
50
|
1
|
|
|
1
|
1
|
216
|
my $class = shift; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
6
|
my $self = $class->SUPER::new(@_); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
14
|
my $typemap = <<'END_TYPEMAP'; |
55
|
|
|
|
|
|
|
TYPEMAP |
56
|
|
|
|
|
|
|
std::vector > T_STD_VECTOR_STD_VECTOR_DOUBLE |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
INPUT |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
T_STD_VECTOR_STD_VECTOR_DOUBLE |
61
|
|
|
|
|
|
|
if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) { |
62
|
|
|
|
|
|
|
AV* av = (AV*)SvRV($arg); |
63
|
|
|
|
|
|
|
const unsigned int len = av_len(av)+1; |
64
|
|
|
|
|
|
|
$var = std::vector>(len); |
65
|
|
|
|
|
|
|
SV** elem; |
66
|
|
|
|
|
|
|
for (unsigned int i = 0; i < len; i++) { |
67
|
|
|
|
|
|
|
elem = av_fetch(av, i, 0); |
68
|
|
|
|
|
|
|
if (elem != NULL && SvROK(*elem) && SvTYPE(SvRV(*elem))==SVt_PVAV) { |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
AV* av_inner = (AV*)SvRV(*elem); |
71
|
|
|
|
|
|
|
const unsigned int len_j = av_len(av_inner) + 1; |
72
|
|
|
|
|
|
|
std::vector inner_vector(len_j); |
73
|
|
|
|
|
|
|
SV** inner_elem; |
74
|
|
|
|
|
|
|
for (unsigned int j = 0; j < len_j; j++) { |
75
|
|
|
|
|
|
|
inner_elem = av_fetch(av_inner, j, 0); |
76
|
|
|
|
|
|
|
if (inner_elem != NULL) |
77
|
|
|
|
|
|
|
inner_vector[j] = SvNV(*inner_elem); |
78
|
|
|
|
|
|
|
else |
79
|
|
|
|
|
|
|
inner_vector[j] = 0; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
${var}[i] = inner_vector; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else |
84
|
|
|
|
|
|
|
${var}[i] = std::vector(); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else |
88
|
|
|
|
|
|
|
Perl_croak(aTHX_ \"%s: %s is not an array reference\", |
89
|
|
|
|
|
|
|
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, |
90
|
|
|
|
|
|
|
\"$var\"); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
OUTPUT |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
T_STD_VECTOR_STD_VECTOR_DOUBLE |
95
|
|
|
|
|
|
|
AV* av = newAV(); |
96
|
|
|
|
|
|
|
$arg = newRV_noinc((SV*)av); |
97
|
|
|
|
|
|
|
const unsigned int len = $var.size(); |
98
|
|
|
|
|
|
|
if (len) |
99
|
|
|
|
|
|
|
av_extend(av, len-1); |
100
|
|
|
|
|
|
|
for (unsigned int i = 0; i < len; i++) { |
101
|
|
|
|
|
|
|
const unsigned int len_j = ${var}[i].size(); |
102
|
|
|
|
|
|
|
AV *inner_av = newAV(); |
103
|
|
|
|
|
|
|
if (len_j) av_extend(inner_av, len_j - 1); |
104
|
|
|
|
|
|
|
for (unsigned int j = 0; j < len_j; j++) { |
105
|
|
|
|
|
|
|
av_store(inner_av, j, newSVnv(${var}[i][j])); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
av_store(av, i, newRV_noinc((SV*)inner_av)); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
END_TYPEMAP |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
6
|
$self->add_string( string => $typemap ); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#die $typemap; |
116
|
1
|
|
|
|
|
1060
|
return $self; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; # End of ExtUtils::Typemaps::STL::Extra |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |