XSBuilder/WrapXS.pm

filter: Statementstmt 4.5% 38 / 829 Branchbran 0.0% 0 / 344 Conditioncond 0.0% 0 / 98 MC/DCmcdc 0.0% 0 / 61 Subroutinesub 14.8% 11 / 74 Podpod 29.5% 18 / 61 totaltotal 4.5% 67 / 1467 CC 242 SCAR 63.0
CC
242
Cov
3%
write_docs
1640.0
get_function
1260.0
get_callback_function
1190.0
CRAP 545.4
↑ Summary XSBuilder/FunctionMap.pm »
1 package ExtUtils::XSBuilder::WrapXS;
2
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 1 ▶use constant GvSHARED => 0; #$^V gt v5.7.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 1 ▶use File::Spec ;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use ExtUtils::XSBuilder::TypeMap ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use ExtUtils::XSBuilder::MapUtil qw(function_table structure_table callback_table);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use ExtUtils::XSBuilder::PODTemplate ;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use File::Path qw(rmtree mkpath);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Cwd qw(fastcwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
15
16 1 ▶use Carp qw(confess) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
17
18 1 our $VERSION = '0.03';
19
20 1 my %warnings;
21 1 my $verbose = 0 ;
22
23 =pod
24
25 =head1 NAME
26
27 ExtUtils::XSBuilder::WrapXS - create perl XS wrappers for C functions
28
29 =head2 DESCRIPTION
30
31 For more information, see L<ExtUtils::XSBuilder>
32
33 =cut
34
35 # ============================================================================
36
37 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
38 0 my $class = shift;
39
40 0 my $self = bless {
41 }, $class;
42
43 0 $self -> {glue_dirs} = [$self -> xs_glue_dirs()] ;
44 0 $self -> {typemap} = $self -> new_typemap ;
45 0 $self -> {parsesource} = $self -> new_parsesource ;
46 0 $self -> {xs_includes} = $self -> xs_includes ;
47 0 $self -> {callbackno} = 1 ;
48
49 0 for (qw(c hash)) {
50 0 my $w = "noedit_warning_$_";
51 0 my $method = $w ;
52 0 $self->{$w} = $self->$method();
53 }
54
55 0 $self->typemap->get;
56 0 $self;
57 }
58
59 # ============================================================================
60
61 0 ▶sub classname {
Subroutine classname: not called CC=3 SCAR=24.8
Pod undocumented
62 0 ▶ my $self = shift || __PACKAGE__;
Condition0%0/2
shift() || __PACKAGE__
l!l
00
MC/DC0%0/1
shift() || __PACKAGE__
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
63 0 ▶ ref($self) || $self;
Branch: 1 branch
BranchTrueFalseTotal
ref $self or $self 0 0 0
64 }
65
66 # ============================================================================
67
68 0 ▶sub calls_trace {
Subroutine calls_trace: not called CC=2 SCAR=17.9
Pod undocumented
69 0 my $frame = 1;
70 0 my $trace = '';
71
72 0 while (1) {
73 0 my($package, $filename, $line) = caller($frame);
74 0 ▶ last unless $filename;
Branch: 1 branch
BranchTrueFalseTotal
unless $filename 0 0 0
75 0 $trace .= "$frame. $filename:$line\n";
76 0 $frame++;
77 }
78
79 0 return $trace;
80 }
81
82 # ============================================================================
83
84 0 ▶sub noedit_warning_c {
Subroutine noedit_warning_c: not called CC=2 SCAR=17.9
Pod undocumented
85 0 my $class = classname(shift);
86 0 my $warning = \$warnings{C}->{$class};
87 0 ▶ return $$warning if $$warning;
Branch: 1 branch
BranchTrueFalseTotal
if $$warning 0 0 0
88 0 my $v = join '/', $class, $class->VERSION;
89 0 my $trace = calls_trace();
90 0 $trace =~ s/^/ * /mg;
91 0 $$warning = <<EOF;
92
93 /*
94 * *********** WARNING **************
95 * This file generated by $v
96 * Any changes made here will be lost
97 * ***********************************
98 $trace */
99
100 EOF
101 }
102
103 # ============================================================================
104
105 #this is named hash after the `#' character
106 #rather than named perl, since #comments are used
107 #non-Perl files, e.g. Makefile, typemap, etc.
108 0 ▶sub noedit_warning_hash {
Subroutine noedit_warning_hash: not called CC=2 SCAR=17.9
Pod undocumented
109 0 my $class = classname(shift);
110 0 my $warning = \$warnings{hash}->{$class};
111 0 ▶ return $$warning if $$warning;
Branch: 1 branch
BranchTrueFalseTotal
if $$warning 0 0 0
112 0 ($$warning = noedit_warning_c($class)) =~ s/^/\# /mg;
113 0 $$warning;
114 }
115
116
117 # ============================================================================
118 =pod
119
120 =head2 new_parsesource (o)
121
122 Returns an array ref of new ParseSource objects for all source files that
123 should be used to generate XS files
124
125 =cut
126
127 0 ▶sub new_parsesource { [ ExtUtils::XSBuilder::ParseSource->new ] }
Subroutine new_parsesource: not called CC=1 SCAR=6.9
Pod documented
128
129
130 # ============================================================================
131 =pod
132
133 =head2 new_typemap (o)
134
135 Returns a new typemap object
136
137 =cut
138
139 0 ▶sub new_typemap { ExtUtils::XSBuilder::TypeMap->new (shift) }
Subroutine new_typemap: not called CC=1 SCAR=6.9
Pod documented
140
141 # ============================================================================
142 =pod
143
144 =head2 new_podtemplate (o)
145
146 Returns a new podtemplate object
147
148 =cut
149
150 0 ▶sub new_podtemplate { ExtUtils::XSBuilder::PODTemplate->new }
Subroutine new_podtemplate: not called CC=1 SCAR=6.9
Pod documented
151
152 # ============================================================================
153 =pod
154
155 =head2 xs_includes (o)
156
157 Returns a list of XS include files.
158
159 Default: use all include files that C<ParseSource::find_includes> returns, but
160 strip path info
161
162 =cut
163
164 sub xs_includes
165 0 ▶ {
Subroutine xs_includes: not called CC=9 SCAR=45.0
Pod documented
166 0 my $self = shift ;
167 0 my $parsesource = $self -> parsesource_objects ;
168
169 0 my @includes ;
170 my @paths ;
171 0 foreach my $src (@$parsesource) {
172 0 push @includes, @{ $src -> find_includes } ;
173 0 push @paths, @{ $src -> include_paths } ;
174 }
175
176 0 foreach (@paths)
177 {
178 0 s#(\\|/)$## ;
179 0 s#\\#/# ;
180 }
181 0 foreach (@includes)
182 {
183 0 s#\\#/# ;
184 }
185
186
187 # strip include paths
188 0 foreach my $file (@includes)
189 {
190 0 foreach my $path (@paths)
191 {
192 0 ▶ if ($file =~ /^\Q$path\E(\/|\\)(.*?)$/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ m[^\Q$path\E(/|\\)(.*?)$]i) 0 0 0
193 {
194 0 $file = $2 ;
195 0 last ;
196 }
197 }
198 }
199
200
201 0 my %includes = map { $_ => 1 } @includes ;
202 0 my $fixup1 = $self -> h_filename_prefix . 'preperl.h' ;
203 0 my $fixup2 = $self -> h_filename_prefix . 'postperl.h' ;
204
205
206
207 return [
208 0 ▶ keys %includes,
Branch: 2 branches
BranchTrueFalseTotal
-f $self->xs_include_dir . '/' . $fixup1 ? : 0 0 0
-f $self->xs_include_dir . '/' . $fixup2 ? : 0 0 0
209 -f $self -> xs_include_dir . '/'. $fixup1?$fixup1:(),
210 'EXTERN.h', 'perl.h', 'XSUB.h',
211 -f $self -> xs_include_dir . '/'. $fixup2?$fixup2:(),
212 $self -> h_filename_prefix . 'sv_convert.h',
213 $self -> h_filename_prefix . 'typedefs.h',
214 ] ;
215 }
216
217
218
219 # ============================================================================
220 =pod
221
222 =head2 xs_glue_dirs (o)
223
224 Returns a list of additional XS glue directories to seach for maps in.
225
226 =cut
227
228
229 0 ▶sub xs_glue_dirs {
Subroutine xs_glue_dirs: not called CC=1 SCAR=6.9
Pod documented
230 0 () ;
231 }
232
233
234 # ============================================================================
235 =pod
236
237 =head2 xs_base_dir (o)
238
239 Returns a directory which serves as a base for other directories.
240
241 Default: C<'.'>
242
243 =cut
244
245
246 0 ▶sub xs_base_dir { '.' } ;
Subroutine xs_base_dir: not called CC=1 SCAR=6.9
Pod documented
247
248
249
250 # ============================================================================
251 =pod
252
253 =head2 xs_map_dir (o)
254
255 Returns the directory to search for map files in
256
257 Default: C<<xs_base_dir>/xsbuilder/maps>
258
259 =cut
260
261
262 0 ▶sub xs_map_dir { File::Spec -> catdir ($_[0] -> xs_base_dir, 'xsbuilder', 'maps') } ;
Subroutine xs_map_dir: not called CC=1 SCAR=6.9
Pod documented
263
264 # ============================================================================
265 =pod
266
267 =head2 xs_incsrc_dir (o)
268
269 Returns the directory to search for files to include into the source. For
270 example, C<<xs_incsrc_dir>/Apache/DAV/Resource/Resource_pm> will be included into
271 the C<Apache::DAV::Resource> module.
272
273 Default: C<<xs_base_dir>/xsbuilder>
274
275
276 =cut
277
278
279 0 ▶sub xs_incsrc_dir { File::Spec -> catdir ($_[0] -> xs_base_dir, 'xsbuilder') ; } ;
Subroutine xs_incsrc_dir: not called CC=1 SCAR=6.9
Pod documented
280
281 # ============================================================================
282 =pod
283
284 =head2 xs_include_dir (o)
285
286 Returns a directory to search for include files for pm and XS
287
288 Default: C<<xs_base_dir>/xsinclude>
289
290 =cut
291
292
293 0 ▶sub xs_include_dir { File::Spec -> catdir ($_[0] -> xs_base_dir, 'xsinclude') ; } ;
Subroutine xs_include_dir: not called CC=1 SCAR=6.9
Pod documented
294
295 # ============================================================================
296 =pod
297
298 =head2 xs_target_dir (o)
299
300 Returns the directory to write generated XS and header files in
301
302 Default: C<<xs_base_dir>/xs>
303
304 =cut
305
306
307 0 ▶sub xs_target_dir { File::Spec -> catdir ($_[0] -> xs_base_dir, 'xs') ; }
Subroutine xs_target_dir: not called CC=1 SCAR=6.9
Pod documented
308
309
310 # ============================================================================
311
312 0 ▶sub typemap { shift->{typemap} }
Subroutine typemap: not called CC=1 SCAR=6.9
Pod undocumented
313
314 # ============================================================================
315
316 0 ▶sub includes { shift->{xs_includes} || [] }
Subroutine includes: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->{"xs_includes"} or [] 0 0 0
317
318 # ============================================================================
319
320 0 ▶sub parsesource_objects { shift->{parsesource} }
Subroutine parsesource_objects: not called CC=1 SCAR=6.9
Pod undocumented
321
322 # ============================================================================
323
324 0 ▶sub function_list {
Subroutine function_list: not called CC=3 SCAR=24.8
Pod undocumented
325 0 my $self = shift;
326 0 my(@list) = @{ function_table($self) };
327
328 0 ▶ while (my($name, $val) = each %{ $self->typemap->function_map }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$self->typemap->function_map;}) 0 0 0
329 #entries that do not exist in C::Scan generated tables
330 0 ▶ next unless $name =~ /^DEFINE_/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /^DEFINE_/ 0 0 0
331 0 push @list, $val;
332 }
333
334 0 return \@list;
335 }
336
337 # ============================================================================
338
339 0 ▶sub callback_list {
Subroutine callback_list: not called CC=3 SCAR=24.8
Pod undocumented
340 0 my $self = shift;
341 0 my(@list) = @{ callback_table($self) };
342
343 0 ▶ while (my($name, $val) = each %{ $self->typemap->callback_map }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$self->typemap->callback_map;}) 0 0 0
344 #entries that do not exist in C::Scan generated tables
345 0 ▶ next unless $name =~ /^DEFINE_/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /^DEFINE_/ 0 0 0
346 0 push @list, $val;
347 }
348
349 0 return \@list;
350 }
351
352 # ============================================================================
353
354 0 ▶sub get_callback_function {
Subroutine get_callback_function: not called CC=34 SCAR=70.8
Pod undocumented
355 0 my ($self, $func, $struct, $elt) = @_ ;
356
357 0 my $myprefix = $self -> my_xs_prefix ;
358 0 my $n ;
359 0 $elt -> {callbackno} = $n = $self -> {callbackno}++ ;
360 0 my $structelt = $elt -> {name} ;
361 0 my $class = $struct -> {class} ;
362 0 my $cclass = $self -> cname($class) ;
363
364 my($name, $args, $retargs, $return_type, $orig_args, $userdataarg) =
365 0 @{ $func } { qw(perl_name args retargs return_type orig_args userdataarg) };
366
367 0 ▶ $struct -> {staticcnt} ||= 4 ;
Condition0%0/2
$struct->{"staticcnt"} ||= 4
l!l
00
MC/DC0%0/1
$struct->{"staticcnt"} ||= 4
$struct->{"staticcnt"}
Truth table0%0/2
A
A= $struct->{"staticcnt"}
Aresult
11
00
368 0 my $staticcnt = $struct -> {staticcnt} ;
369 #print "get_callback_function: ", Data::Dumper -> Dump([$func]), "\n" ;
370
371 0 my $code = "\n/* --- $class -> $structelt --- */\n\n" ;
372 0 my $cbname = "${myprefix}cb_${cclass}__$structelt" ;
373 0 my %retargs = map { $_->{name} => $_ } @$retargs ;
374 0 my %args = map { $_->{name} => $_ } @$args ;
375 0 ▶ my @args = map { my $name = /^(?:\*|&)(.*?)$/?$1:$_ ; ($args{$name}{rtype} || $retargs{$name}{rtype}) . (/^&/?" * $name":" $name") } @$orig_args ;
Branch: 2 branches
BranchTrueFalseTotal
/^(?:\*|&)(.*?)$/ ? : 0 0 0
/^&/ ? : 0 0 0
Condition0%0/3
$args{$name}{'rtype'} || $retargs{$name}{'rtype'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{$name}{'rtype'} || $retargs{$name}{'rtype'}
$args{$name}{'rtype'} $retargs{$name}{'rtype'}
Truth table0%0/3
A || B
A= $args{$name}{'rtype'}B= $retargs{$name}{'rtype'}
ABresult
1X1
011
000
376 0 $return_type = $self -> cname($return_type) ;
377 0 ▶ my $return_class = $self -> typemap -> map_class ($return_type) || $return_type;
Condition0%0/3
$self->typemap->map_class($return_type) || $return_type
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->typemap->map_class($return_type) || $return_type
$self->typemap->map_class($return_type) $return_type
Truth table0%0/3
A || B
A= $self->typemap->map_class($return_type)B= $return_type
ABresult
1X1
011
000
378 0 ▶ if ($return_class =~ / /)
Branch: 1 branch
BranchTrueFalseTotal
if ($return_class =~ / /) 0 0 0
379 {
380 0 print "ERROR: return class '$return_class' contains spaces" ;
381 }
382
383 0 my $desttype = 'CV' ;
384 0 ▶ if ($structelt)
Branch: 1 branch
BranchTrueFalseTotal
if ($structelt) 0 0 0
385 {
386 0 $desttype = 'SV' ;
387 }
388
389 0 ▶ my $numret = $return_type eq 'void'?0:1 ;
Branch: 1 branch
BranchTrueFalseTotal
$return_type eq 'void' ? : 0 0 0
390 0 $numret += @$retargs ;
391 0 ▶ my $callflags = $numret == 0?'G_VOID':$numret == 1?'G_SCALAR':'G_ARRAY' ;
Branch: 2 branches
BranchTrueFalseTotal
$numret == 0 ? : 0 0 0
$numret == 1 ? : 0 0 0
392
393 0 $code .= qq[
394
395 static $return_type $cbname (] . join (',', "$desttype * __cbdest", @args) . qq[)
396 {
397 ] ;
398 0 ▶ $code .= " $return_type __retval ;\n" if ($return_type && $return_type ne 'void') ;
Branch: 1 branch
BranchTrueFalseTotal
if $return_type and $return_type ne "void" 0 0 0
Condition0%0/3
$return_type and $return_type ne "void"
!ll&&!rl&&r
000
MC/DC0%0/2
$return_type and $return_type ne "void"
$return_type $return_type ne "void"
Truth table0%0/3
A and B
A= $return_typeB= $return_type ne "void"
ABresult
0X0
100
111
399 0 ▶ $code .= " SV * __retsv ;\n" if ($numret) ;
Branch: 1 branch
BranchTrueFalseTotal
if $numret 0 0 0
400 0 $code .= qq[
401 int __cnt ;
402
403 dSP ;
404 ENTER ;
405 SAVETMPS ;
406 PUSHMARK(SP) ;
407 ];
408
409 0 ▶ if ($structelt)
Branch: 1 branch
BranchTrueFalseTotal
if ($structelt) 0 0 0
410 {
411 0 $code .= " PUSHs(__cbdest) ;\n" ;
412 }
413
414 0 foreach (@$orig_args) {
415 0 ▶ my $type = /^(?:\*|\&)(.*?)$/?$1:$_ ;
Branch: 1 branch
BranchTrueFalseTotal
/^(?:\*|\&)(.*?)$/ ? : 0 0 0
416 0 ▶ my $name = /^\*(.*?)$/?"&$1":$_ ;
Branch: 1 branch
BranchTrueFalseTotal
/^\*(.*?)$/ ? : 0 0 0
417 0 ▶ next if ($retargs{$type}{class}) ;
Branch: 1 branch
BranchTrueFalseTotal
if $retargs{$type}{"class"} 0 0 0
418 0 ▶ if (!$args{$type}{class} && !$args{$type}{type})
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{$type}{"class"} or $args{$type}{"type"}) 0 0 0
Condition0%0/3
$args{$type}{"class"} or $args{$type}{"type"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{$type}{"class"} or $args{$type}{"type"}
$args{$type}{"class"} $args{$type}{"type"}
Truth table0%0/3
A or B
A= $args{$type}{"class"}B= $args{$type}{"type"}
ABresult
1X1
011
000
419 {
420 0 print "WARNING: unknown type for argument '$name' in struct member '$structelt'\n" ;
421 0 print Dumper ($args) ;
422 0 next ;
423 }
424 0 ▶ my $class = $args{$type}{class} || $args{$type}{type} ;
Condition0%0/3
$args{$type}{'class'} || $args{$type}{'type'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{$type}{'class'} || $args{$type}{'type'}
$args{$type}{'class'} $args{$type}{'type'}
Truth table0%0/3
A || B
A= $args{$type}{'class'}B= $args{$type}{'type'}
ABresult
1X1
011
000
425 0 ▶ if ($class =~/\s/)
Branch: 1 branch
BranchTrueFalseTotal
if ($class =~ /\s/) 0 0 0
426 {
427 0 print "WARNING: type '$class' for argument '$name' in struct member '$structelt' contains spaces\n" ;
428 0 print Dumper ($args) ;
429 0 next ;
430 }
431
432 0 $code .= ' PUSHs(' . $self -> convert_2obj ($class, $name) . ") ;\n" ;
433 }
434
435 0 $code .= qq[
436 PUTBACK ;
437 ] ;
438
439 0 ▶ if ($structelt)
Branch: 1 branch
BranchTrueFalseTotal
if ($structelt) { } 0 0 0
440 {
441 0 $code .= " __cnt = perl_call_method(\"cb_$structelt\", $callflags) ;\n" ;
442 }
443 else
444 {
445 0 $code .= " __cnt = perl_call_sv(__cbdest, $callflags) ;\n" ;
446 }
447
448 0 ▶ $code .= qq[
Branch: 1 branch
BranchTrueFalseTotal
if $numret > 0 0 0 0
449
450 if (__cnt != $numret)
451 croak (\"$cbname expected $numret return values\") ;
452 ] if ($numret > 0) ;
453
454 0 $code .= qq[
455 SPAGAIN ;
456 ] ;
457
458 0 ▶ if ($return_type && $return_type ne 'void')
Branch: 1 branch
BranchTrueFalseTotal
if ($return_type and $return_type ne "void") 0 0 0
Condition0%0/3
$return_type and $return_type ne "void"
!ll&&!rl&&r
000
MC/DC0%0/2
$return_type and $return_type ne "void"
$return_type $return_type ne "void"
Truth table0%0/3
A and B
A= $return_typeB= $return_type ne "void"
ABresult
0X0
100
111
459 {
460 0 $code .= " __retsv = POPs;\n" ;
461 0 $code .= ' __retval = ' . $self -> convert_sv2 ($return_type, $return_class, '__retsv') . ";\n"
462 }
463 0 foreach (@$retargs) {
464 0 $code .= " __retsv = POPs;\n" ;
465 0 $code .= " *$_->{name} = " . $self -> convert_sv2 ($_->{rtype}, $_->{class}, '__retsv') . ";\n" ;
466 }
467
468 0 $code .= qq[
469 PUTBACK ;
470 FREETMPS ;
471 LEAVE ;
472
473
474 ] ;
475 0 ▶ $code .= " return __retval ;\n" if ($return_type && $return_type ne 'void') ;
Branch: 1 branch
BranchTrueFalseTotal
if $return_type and $return_type ne "void" 0 0 0
Condition0%0/3
$return_type and $return_type ne "void"
!ll&&!rl&&r
000
MC/DC0%0/2
$return_type and $return_type ne "void"
$return_type $return_type ne "void"
Truth table0%0/3
A and B
A= $return_typeB= $return_type ne "void"
ABresult
0X0
100
111
476 0 $code .= qq[
477 }
478
479 ] ;
480
481 0 ▶ if (!$userdataarg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($userdataarg) 0 0 0
482 0 ▶ $staticcnt ||= 4 ;
Condition0%0/2
$staticcnt ||= 4
l!l
00
MC/DC0%0/1
$staticcnt ||= 4
$staticcnt
Truth table0%0/2
A
A= $staticcnt
Aresult
11
00
483
484 0 ▶ for (my $i = 0 ; $i < $staticcnt; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $staticcnt) 0 0 0
485 $code .= qq[
486
487 static $return_type ${cbname}_obj$i (] . join (',', @args) . qq[)
488 {
489 ] . ($return_type eq 'void'?'':'return') . qq[ ${cbname} (] .
490 0 ▶ join (',', "${myprefix}${cclass}_obj[$i]", map { /^(?:\*|\&)?(.*?)$/ } @$orig_args) . qq[) ;
Branch: 1 branch
BranchTrueFalseTotal
$return_type eq 'void' ? : 0 0 0
491 }
492
493 ] ;
494
495
496 }
497 0 $code .= "typedef $return_type (*t${cbname}_func)(" . join (',', @args) . qq") ;\n" ;
498 $code .= "static t${cbname}_func ${myprefix}${cbname}_func [$staticcnt] = {\n " .
499 0 join (",\n ", map { "${cbname}_obj$_" } (0..$staticcnt-1)) . "\n } ;\n\n\n" ;
500 }
501
502 0 unshift @{ $self->{XS}->{ $func->{module} } }, {
503 code => $code,
504 class => '',
505 name => $name,
506 };
507
508 }
509
510
511
512 # ============================================================================
513
514
515
516 0 ▶sub get_function {
Subroutine get_function: not called CC=35 SCAR=71.4
Pod undocumented
517 0 my ($self, $func) = @_ ;
518
519 0 my $myprefix = $self -> my_xs_prefix ;
520
521 my($name, $module, $class, $args, $retargs) =
522 0 @{ $func } { qw(perl_name module class args retargs) };
523
524 0 my %retargs = map { $_->{name} => $_ } @$retargs ;
525
526 0 ▶ print "get_function: ", Data::Dumper -> Dump([$func]), "\n" if ($verbose);
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 0 0
527 #eg ap_fputs()
528 0 ▶ if ($name =~ s/^DEFINE_//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s/^DEFINE_//) 0 0 0
529 0 $func->{name} =~ s/^DEFINE_//;
530
531 0 ▶ if (needs_prefix($func->{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (needs_prefix($func->{"name"})) 0 0 0
532 #e.g. DEFINE_add_output_filter
533 0 $func->{name} = make_prefix($func->{name}, $class);
534 }
535 }
536
537 my $xs_parms = join ', ',
538 0 map { defined $_->{default} ?
539 0 ▶ "$_->{name}=$_->{default}" : $_->{name} } @$args;
Branch: 1 branch
BranchTrueFalseTotal
defined $_->{'default'} ? : 0 0 0
540
541 0 my $parms ;
542 0 ▶ if ($func -> {dispatch_argspec})
Branch: 1 branch
BranchTrueFalseTotal
if ($func->{'dispatch_argspec'}) { } 0 0 0
543 {
544 0 $parms = $func -> {dispatch_argspec} ;
545 }
546 else
547 {
548 ($parms = join (',', $xs_parms,
549 0 map { "\&$_->{name}" } @$retargs)) =~
550 s/=[^,]+//g; #strip defaults
551 }
552
553 0 my $proto = join "\n",
554 (map " $_->{type} $_->{name}", @$args) ;
555
556 my $return_type =
557 0 ▶ $name =~ /^DESTROY$/ ? 'void' : $func->{return_type};
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /^DESTROY$/ ? : 0 0 0
558
559 my $retdecl = @$retargs?(join "\n",
560 0 ▶ (map { my $type = $self -> cname($_->{class}) ; $type =~ s/\*$//; ' ' . $type . " $_->{name};"} @$retargs),
Branch: 1 branch
BranchTrueFalseTotal
@$retargs ? : 0 0 0
561 #' ' . $self -> cname($return_type) . ' RETVAL',
562 ''):'';
563
564 my($dispatch, $orig_args) =
565 0 @{ $func } {qw(dispatch orig_args)};
566
567 0 ▶ if ($dispatch =~ /^$myprefix/io) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dispatch =~ /^$myprefix/io) 0 0 0
568 0 $name =~ s/^$myprefix//;
569 0 $name =~ s/^$func->{prefix}//;
570 0 push @{ $self->{newXS}->{ $module } },
571 ["$class\::$name", $dispatch];
572 0 return;
573 }
574
575 0 ▶ my $passthru = @$args && $args->[0]->{name} eq '...';
Condition0%0/3
@$args && $args->[0]{'name'} eq '...'
!ll&&!rl&&r
000
MC/DC0%0/2
@$args && $args->[0]{'name'} eq '...'
@$args $args->[0]{'name'} eq '...'
Truth table0%0/3
A && B
A= @$argsB= $args->[0]{'name'} eq '...'
ABresult
0X0
100
111
576 0 ▶ if ($passthru) {
Branch: 1 branch
BranchTrueFalseTotal
if ($passthru) 0 0 0
577 0 $parms = '...';
578 0 $proto = '';
579 }
580
581 0 my $attrs = $self->attrs($name);
582
583 0 my $code = <<EOF;
584 $return_type
585 $name($xs_parms)
586 EOF
587 0 ▶ $code .= "$proto\n" if ($proto) ;
Branch: 1 branch
BranchTrueFalseTotal
if $proto 0 0 0
588 0 ▶ $code .= "$attrs\n" if ($attrs) ;
Branch: 1 branch
BranchTrueFalseTotal
if $attrs 0 0 0
589 0 ▶ $code .= "PREINIT:\n$retdecl" if ($retdecl) ;
Branch: 1 branch
BranchTrueFalseTotal
if $retdecl 0 0 0
590
591 0 ▶ if ($dispatch || $orig_args) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dispatch or $orig_args) 0 0 0
Condition0%0/3
$dispatch or $orig_args
l!l&&r!l&&!r
000
MC/DC0%0/2
$dispatch or $orig_args
$dispatch $orig_args
Truth table0%0/3
A or B
A= $dispatchB= $orig_args
ABresult
1X1
011
000
592 0 my $thx = "";
593
594 0 ▶ if ($dispatch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dispatch) { } 0 0 0
595 0 ▶ $thx = 'aTHX_ ' if $dispatch =~ /^$myprefix/i;
Branch: 1 branch
BranchTrueFalseTotal
if $dispatch =~ /^$myprefix/i 0 0 0
596 0 ▶ if ($orig_args && !$func -> {dispatch_argspec}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orig_args and not $func->{"dispatch_argspec"}) 0 0 0
Condition0%0/3
$orig_args and not $func->{"dispatch_argspec"}
!ll&&!rl&&r
000
MC/DC0%0/2
$orig_args and not $func->{"dispatch_argspec"}
$orig_args not $func->{"dispatch_argspec"}
Truth table0%0/3
A and not(B)
A= $orig_argsB= not $func->{"dispatch_argspec"}
ABresult
0X0
100
111
597 0 ▶ $parms = join ', ', map { $retargs{$_}?"&$_":$_} @$orig_args;
Branch: 1 branch
BranchTrueFalseTotal
$retargs{$_} ? : 0 0 0
598 }
599 }
600 else {
601 ### ??? gr ### if ($orig_args and @$orig_args == @$args) {
602 0 ▶ if ($orig_args && @$orig_args) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orig_args and @$orig_args) 0 0 0
Condition0%0/3
$orig_args and @$orig_args
!ll&&!rl&&r
000
MC/DC0%0/2
$orig_args and @$orig_args
$orig_args @$orig_args
Truth table0%0/3
A and B
A= $orig_argsB= @$orig_args
ABresult
0X0
100
111
603 #args were reordered
604 0 ▶ $parms = join ', ', map { $retargs{$_}?"&$_":$_} @$orig_args;
Branch: 1 branch
BranchTrueFalseTotal
$retargs{$_} ? : 0 0 0
605 }
606
607 0 $dispatch = $func->{name};
608 }
609
610 0 ▶ if ($passthru) {
Branch: 1 branch
BranchTrueFalseTotal
if ($passthru) 0 0 0
611 0 ▶ $thx ||= 'aTHX_ ';
Condition0%0/2
$thx ||= "aTHX_ "
l!l
00
MC/DC0%0/1
$thx ||= "aTHX_ "
$thx
Truth table0%0/2
A
A= $thx
Aresult
11
00
612 0 $parms = 'items, MARK+1, SP';
613 }
614
615 0 ▶ my $retval = $return_type eq 'void' ?
Branch: 1 branch
BranchTrueFalseTotal
$return_type eq 'void' ? : 0 0 0
616 ["", ""] : ["RETVAL = ", "OUTPUT:\n RETVAL\n"];
617
618 0 ▶ my $retnum = $retdecl?scalar(@$retargs) + ($return_type eq 'void' ?0:1):0 ;
Branch: 2 branches
BranchTrueFalseTotal
$retdecl ? : 0 0 0
$return_type eq 'void' ? : 0 0 0
619 0 ▶ $code .= $retdecl?"PPCODE:":"CODE:" ;
Branch: 1 branch
BranchTrueFalseTotal
$retdecl ? : 0 0 0
620 0 $code .= "\n $retval->[0]$dispatch($thx$parms);\n" ;
621 0 ▶ if ($retdecl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retdecl) { } 0 0 0
622 0 ▶ my $retclass = $self -> typemap -> map_class ($return_type) || $return_type ;
Condition0%0/3
$self->typemap->map_class($return_type) || $return_type
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->typemap->map_class($return_type) || $return_type
$self->typemap->map_class($return_type) $return_type
Truth table0%0/3
A || B
A= $self->typemap->map_class($return_type)B= $return_type
ABresult
1X1
011
000
623 0 ▶ if ($retclass =~ / /)
Branch: 1 branch
BranchTrueFalseTotal
if ($retclass =~ / /) 0 0 0
624 {
625 0 print "ERROR: return class '$retclass' contains spaces" ;
626 }
627 0 $code .= " XSprePUSH;\n" ;
628 0 $code .= " EXTEND(SP, $retnum) ;\n" ;
629 0 $code .= ' PUSHs(' . $self -> convert_2obj ($retclass, 'RETVAL') . ") ;\n" ;
630 0 foreach (@$retargs) {
631 0 ▶ if ($_->{class} =~ / /)
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"class"} =~ / /) 0 0 0
632 {
633 0 print "ERROR: $_->{class} contains spaces; retargs = ", Dumper ($_) ;
634 }
635 0 $code .= ' PUSHs(' . $self -> convert_2obj ($_->{class}, $_->{name}) . ") ;\n" ;
636 }
637 }
638 else {
639 0 $code .= "$retval->[1]\n" ;
640 }
641 }
642
643 0 $code .= "\n" ;
644
645 0 $func->{code} = $code;
646 0 push @{ $self->{XS}->{ $module } }, $func;
647 }
648
649 # ============================================================================
650
651
652 0 ▶sub get_functions {
Subroutine get_functions: not called CC=4 SCAR=30.0
Pod undocumented
653 0 my $self = shift;
654
655 0 my $typemap = $self->typemap;
656 0 my %seen ;
657 0 for my $entry (@{ $self->function_list() }) {
658 #print "get_func ", Dumper ($entry) ;
659 0 my $func = $typemap->map_function($entry);
660 #print "FAILED to map $entry->{name}\n" unless $func;
661 0 ▶ next unless $func;
Branch: 1 branch
BranchTrueFalseTotal
unless $func 0 0 0
662 0 ▶ print "WARNING: Duplicate function: $entry->{name}\n" if ($seen{$entry->{name}}++) ;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$entry->{"name"}}++ 0 0 0
663 0 $self -> get_function ($func) ;
664 }
665 }
666
667
668 # ============================================================================
669
670 0 ▶sub get_value {
Subroutine get_value: not called CC=3 SCAR=24.8
Pod undocumented
671 0 my $e = shift;
672 0 my $val = 'val';
673
674 0 ▶ if ($e->{class} eq 'PV') {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->{"class"} eq "PV") 0 0 0
675 0 ▶ if (my $pool = $e->{pool}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pool = $e->{"pool"}) 0 0 0
676 0 $pool .= '(obj)';
677 0 $val = "((ST(1) == &PL_sv_undef) ? NULL :
678 apr_pstrndup($pool, val, val_len))"
679 }
680 }
681
682 0 return $val;
683 }
684 # ============================================================================
685
686 0 ▶sub get_structure_callback_init {
Subroutine get_structure_callback_init: not called CC=3 SCAR=24.8
Pod undocumented
687 0 my ($self, $class, $struct) = @_ ;
688
689 0 my $cclass = $self -> cname($class) ;
690
691 0 my $myprefix = $self -> my_xs_prefix ;
692 0 my $staticcnt = $struct -> {staticcnt} ;
693
694 0 my $cnv = $self -> convert_sv2 ($cclass, $class, 'obj') ;
695 0 my $code = qq[
696
697 void
698 init_callbacks (obj, val=NULL)
699 SV * obj
700 SV * val
701 PREINIT:
702 int n = -1 ;
703 int i ;
704 $cclass cobj = $cnv ;
705 SV * ref ;
706 SV * perl_obj ;
707 CODE:
708 if (items > 1)
709 obj = val ;
710
711 perl_obj = SvRV(obj) ;
712 ref = newRV_noinc(perl_obj) ;
713
714 for (i=0;i < $staticcnt;i++)
715 {
716 if ($myprefix${cclass}_obj[i] == ref)
717 {
718 n = i ;
719 break ;
720 }
721 }
722
723 if (n < 0)
724 for (i=0;i < $staticcnt;i++)
725 {
726 if ($myprefix${cclass}_obj[i] == NULL)
727 {
728 n = i ;
729 break ;
730 }
731 }
732
733 if (n < 0)
734 croak ("Limit for concurrent object callbacks reached for $class. Limit is $staticcnt") ;
735
736 $myprefix${cclass}_obj[n] = ref ;
737 ] ;
738
739
740 0 foreach my $e (@{ $struct->{elts} }) {
741 0 ▶ if ($e -> {callback}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->{"callback"}) 0 0 0
742 0 my $cbname = "${myprefix}cb_${cclass}__$e->{name}" ;
743 0 $code .= " cobj -> $e->{name} = ${myprefix}${cbname}_func[n] ;\n" ;
744 }
745 }
746 0 $code .= qq[
747
748 ] ;
749
750 0 my $ccode = "static SV * ${myprefix}${cclass}_obj[$staticcnt] ;\n\n" ;
751
752
753 0 push @{ $self->{XS}->{ $struct->{module} } }, {
754 code => $code,
755 class => $class,
756 name => 'init_callbacks',
757 };
758
759 0 unshift @{ $self->{XS}->{ $struct->{module} } }, {
760 code => $ccode,
761 class => '',
762 name => 'init_callbacks',
763 };
764
765 }
766
767 # ============================================================================
768
769 0 ▶sub get_structure_new {
Subroutine get_structure_new: not called CC=8 SCAR=42.8
Pod undocumented
770 0 my ($self, $class, $struct) = @_ ;
771
772 0 my $cclass = $self -> cname($class) ;
773 0 my $cnvprefix = $self -> my_cnv_prefix ;
774 0 ▶ my $alloc = $struct -> {alloc} || 'malloc(sizeof(*cobj))' ;
Condition0%0/2
$struct->{'alloc'} || 'malloc(sizeof(*cobj))'
l!l
00
MC/DC0%0/1
$struct->{'alloc'} || 'malloc(sizeof(*cobj))'
$struct->{'alloc'}
Truth table0%0/2
A
A= $struct->{'alloc'}
Aresult
11
00
775 0 my $code = qq[
776
777 SV *
778 new (class,initializer=NULL)
779 char * class
780 SV * initializer
781 PREINIT:
782 SV * svobj ;
783 $cclass cobj ;
784 SV * tmpsv ;
785 CODE:
786 ${cnvprefix}${cclass}_create_obj(cobj,svobj,RETVAL,$alloc) ;
787
788 if (initializer) {
789 if (!SvROK(initializer) || !(tmpsv = SvRV(initializer)))
790 croak ("initializer for ${class}::new is not a reference") ;
791
792 if (SvTYPE(tmpsv) == SVt_PVHV || SvTYPE(tmpsv) == SVt_PVMG)
793 ${cclass}_new_init (aTHX_ cobj, tmpsv, 0) ;
794 else if (SvTYPE(tmpsv) == SVt_PVAV) {
795 int i ;
796 SvGROW(svobj, sizeof (*cobj) * av_len((AV *)tmpsv)) ;
797 for (i = 0; i <= av_len((AV *)tmpsv); i++) {
798 SV * * itemrv = av_fetch((AV *)tmpsv, i, 0) ;
799 SV * item ;
800 if (!itemrv || !*itemrv || !SvROK(*itemrv) || !(item = SvRV(*itemrv)))
801 croak ("array element of initializer for ${class}::new is not a reference") ;
802 ${cclass}_new_init (aTHX_ &cobj[i], item, 1) ;
803 }
804 }
805 else {
806 croak ("initializer for ${class}::new is not a hash/array/object reference") ;
807 }
808 }
809 OUTPUT:
810 RETVAL
811
812 ] ;
813
814
815 0 my $c_code = qq[
816
817 void ${cclass}_new_init (pTHX_ $cclass obj, SV * item, int overwrite) {
818
819 SV * * tmpsv ;
820
821 if (SvTYPE(item) == SVt_PVMG)
822 memcpy (obj, (void *)SvIVX(item), sizeof (*obj)) ;
823 else if (SvTYPE(item) == SVt_PVHV) {
824 ] ;
825 0 foreach my $e (@{ $struct->{elts} }) {
826 0 ▶ if ($e -> {name} =~ /^(.*?)\[(.*?)\]$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($e->{'name'} =~ /^(.*?)\[(.*?)\]$/) { } 0 0 0
elsif (not $e->{'class'} =~ /::/ or $e->{'rtype'} =~ /\*$/) { } 0 0 0
827 0 my $strncpy = $2 ;
828 0 my $name = $1 ;
829 0 my $perl_name ;
830 0 ($perl_name = $e -> {perl_name}) =~ s/\[.*?\]$// ;
831 0 $c_code .= " if ((tmpsv = hv_fetch((HV *)item, \"$perl_name\", sizeof(\"$perl_name\") - 1, 0)) || overwrite) {\n" ;
832 0 $c_code .= " STRLEN l = 0;\n" ;
833 0 $c_code .= " if (tmpsv) {\n" ;
834 0 $c_code .= " char * s = SvPV(*tmpsv,l) ;\n" ;
835 0 $c_code .= " if (l > ($strncpy)-1) l = ($strncpy) - 1 ;\n" ;
836 0 $c_code .= " strncpy(obj->$name, s, l) ;\n" ;
837 0 $c_code .= " }\n" ;
838 0 $c_code .= " obj->$name\[l] = '\\0';\n" ;
839 0 $c_code .= " }\n" ;
840 ▶ } elsif (($e -> {class} !~ /::/) || ($e -> {rtype} =~ /\*$/)) {
Condition0%0/3
not $e->{"class"} =~ /::/ or $e->{"rtype"} =~ /\*$/
l!l&&r!l&&!r
000
MC/DC0%0/2
not $e->{"class"} =~ /::/ or $e->{"rtype"} =~ /\*$/
not $e->{"class"} =~ /::/ $e->{"rtype"} =~ /\*$/
Truth table0%0/3
not(A) or B
A= not $e->{"class"} =~ /::/B= $e->{"rtype"} =~ /\*$/
ABresult
1X1
011
000
841 0 $c_code .= " if ((tmpsv = hv_fetch((HV *)item, \"$e->{perl_name}\", sizeof(\"$e->{perl_name}\") - 1, 0)) || overwrite) {\n" ;
842
843 0 ▶ if ($e -> {malloc}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->{'malloc'}) { } 0 0 0
844 0 my $type = $e->{rtype} ;
845 0 my $dest = "obj -> $e->{name}" ;
846 0 my $src = 'tmpobj' ;
847 0 my $expr = eval ('"' . $e -> {malloc} . '"') ;
848 0 ▶ print $@ if ($@) ;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
849 0 $c_code .= " $type tmpobj = (" . $self -> convert_sv2 ($e->{rtype}, $e->{class}, '(tmpsv && *tmpsv?*tmpsv:&PL_sv_undef)') . ");\n" ;
850 0 $c_code .= " if (tmpobj)\n" ;
851 0 $c_code .= " $expr;\n" ;
852 0 $c_code .= " else\n" ;
853 0 $c_code .= " $dest = NULL ;\n" ;
854 }
855 else {
856 0 $c_code .= ' ' . "obj -> $e->{name} = " . $self -> convert_sv2 ($e->{rtype}, $e->{class}, '(tmpsv && *tmpsv?*tmpsv:&PL_sv_undef)') . " ;\n" ;
857 }
858 0 $c_code .= " }\n" ;
859 }
860 }
861 0 $c_code .= qq[ ; }
862
863 else
864 croak ("initializer for ${class}::new is not a hash or object reference") ;
865
866 } ;
867
868
869 ] ;
870
871
872 0 push @{ $self->{XS}->{ $struct->{module} } }, {
873 code => $code,
874 class => $class,
875 name => 'new',
876 };
877
878 0 unshift @{ $self->{XS}->{ $struct->{module} } }, {
879 code => $c_code,
880 class => '',
881 name => 'new',
882 };
883
884 }
885
886
887 # ============================================================================
888
889 0 ▶sub get_structure_destroy {
Subroutine get_structure_destroy: not called CC=7 SCAR=40.3
Pod undocumented
890 0 my ($self, $class, $struct) = @_ ;
891
892 0 my $cclass = $self -> cname($class) ;
893 0 my $cnvprefix = $self -> my_cnv_prefix ;
894 0 my $code = qq[
895
896 void
897 DESTROY (obj)
898 $class obj
899 CODE:
900 ${cclass}_destroy (aTHX_ obj) ;
901
902 ] ;
903
904 0 my $numfree = 0 ;
905 0 my $c_code = qq[
906
907 void ${cclass}_destroy (pTHX_ $cclass obj) {
908 ];
909
910 0 foreach my $e (@{ $struct->{elts} }) {
911 0 ▶ if (($e -> {class} !~ /::/) || ($e -> {rtype} =~ /\*$/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $e->{"class"} =~ /::/ or $e->{"rtype"} =~ /\*$/) 0 0 0
Condition0%0/3
not $e->{"class"} =~ /::/ or $e->{"rtype"} =~ /\*$/
l!l&&r!l&&!r
000
MC/DC0%0/2
not $e->{"class"} =~ /::/ or $e->{"rtype"} =~ /\*$/
not $e->{"class"} =~ /::/ $e->{"rtype"} =~ /\*$/
Truth table0%0/3
not(A) or B
A= not $e->{"class"} =~ /::/B= $e->{"rtype"} =~ /\*$/
ABresult
1X1
011
000
912 0 ▶ if ($e -> {free}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->{"free"}) 0 0 0
913 0 my $src = "obj -> $e->{name}" ;
914 0 my $type = $e->{rtype} ;
915 0 my $expr = eval ('"' . $e -> {free} . '"') ;
916 0 ▶ print $@ if ($@) ;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
917 0 $c_code .= " if (obj -> $e->{name})\n" ;
918 0 $c_code .= ' ' . $expr . ";\n" ;
919 0 $numfree++ ;
920 }
921 }
922 }
923 0 $c_code .= "\n};\n\n" ;
924
925 0 ▶ if ($numfree) {
Branch: 1 branch
BranchTrueFalseTotal
if ($numfree) 0 0 0
926 0 push @{ $self->{XS}->{ $struct->{module} } }, {
927 code => $code,
928 class => $class,
929 name => 'destroy',
930 };
931
932 0 unshift @{ $self->{XS}->{ $struct->{module} } }, {
933 code => $c_code,
934 class => '',
935 name => 'destroy',
936 };
937 }
938
939 }
940
941 # ============================================================================
942
943 0 ▶sub get_structures {
Subroutine get_structures: not called CC=19 SCAR=59.4
Pod undocumented
944 0 my $self = shift;
945 0 my $typemap = $self->typemap;
946 0 my $has_callbacks = 0 ;
947
948 0 for my $entry (@{ structure_table($self) }) {
949 0 ▶ print 'struct ', $entry->{type} || '???', "...\n" ;
Condition0%0/2
$entry->{'type'} || '???'
l!l
00
MC/DC0%0/1
$entry->{'type'} || '???'
$entry->{'type'}
Truth table0%0/2
A
A= $entry->{'type'}
Aresult
11
00
950
951 0 my $struct = $typemap->map_structure($entry);
952 0 ▶ print Data::Dumper -> Dump ([$entry, $struct], ['Table Entry', 'Mapfile Entry']) if ($verbose) ;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 0 0
953 0 ▶ if (!$struct)
Branch: 1 branch
BranchTrueFalseTotal
unless ($struct) 0 0 0
954 {
955 0 print "WARNING: Struture '$entry->{type}' not found in map file\n" ;
956 0 next ;
957 }
958
959 0 my $class = $struct->{class};
960 0 $has_callbacks = 0 ;
961
962 0 for my $e (@{ $struct->{elts} }) {
963 my($name, $default, $type, $perl_name ) =
964 0 @{$e}{qw(name default type perl_name)};
965
966 0 print " $name...\n" ;
967
968 0 ▶ if ($e -> {callback}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->{'callback'}) { } 0 0 0
969 #print "callback < ", Dumper ($e) , "\n" ;
970 0 $self -> get_function ($e -> {func}) ;
971 0 $self -> get_callback_function ($e -> {func}, $struct, $e) ;
972 0 $has_callbacks++ ;
973 }
974 else {
975 0 (my $cast = $type) =~ s/:/_/g;
976 0 my $val = get_value($e);
977
978 0 my $type_in = $type;
979 0 my $preinit = "/*nada*/";
980 0 my $address = '' ;
981 0 my $rdonly = 0 ;
982 0 my $strncpy ;
983 0 ▶ if ($e->{class} eq 'PV' and $val ne 'val') {
Branch: 3 branches
BranchTrueFalseTotal
if ($e->{'class'} eq 'PV' and $val ne 'val') { } 0 0 0
elsif ($e->{'class'} =~ /::/ and not $e->{'rtype'} =~ /\*\s*$/) { } 0 0 0
elsif ($name =~ /^(.*?)\[(.*?)\]$/) { } 0 0 0
Condition0%0/3
$e->{"class"} eq "PV" and $val ne "val"
!ll&&!rl&&r
000
MC/DC0%0/2
$e->{"class"} eq "PV" and $val ne "val"
$e->{"class"} eq "PV" $val ne "val"
Truth table0%0/3
A and B
A= $e->{"class"} eq "PV"B= $val ne "val"
ABresult
0X0
100
111
984 0 $type_in =~ s/char/char_len/;
985 0 $preinit = "STRLEN val_len;";
986 ▶ } elsif (($e->{class} =~ /::/) && ($e -> {rtype} !~ /\*\s*$/)) {
Condition0%0/3
$e->{"class"} =~ /::/ and not $e->{"rtype"} =~ /\*\s*$/
!ll&&!rl&&r
000
MC/DC0%0/2
$e->{"class"} =~ /::/ and not $e->{"rtype"} =~ /\*\s*$/
$e->{"class"} =~ /::/ not $e->{"rtype"} =~ /\*\s*$/
Truth table0%0/3
A and not(B)
A= $e->{"class"} =~ /::/B= not $e->{"rtype"} =~ /\*\s*$/
ABresult
0X0
100
111
987 # an inlined struct is read only
988 0 $rdonly = 1 ;
989 0 $address = '&' ;
990 } elsif ($name =~ /^(.*?)\[(.*?)\]$/) {
991 0 $strncpy = $2 ;
992 0 $name = $1 ;
993 0 $perl_name =~ s/\[.*?\]$// ;
994 0 $type = 'char *' ;
995 0 $type_in = 'char *' ;
996 0 $cast = 'char *' ;
997 }
998
999 0 my $attrs = $self->attrs($name);
1000
1001 0 my $code = <<EOF;
1002 $type
1003 $perl_name(obj, val=$default)
1004 $class obj
1005 $type_in val
1006 PREINIT:
1007 $preinit
1008 $attrs
1009 CODE:
1010 RETVAL = ($cast) $address obj->$name;
1011 EOF
1012 0 ▶ if ($rdonly) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdonly) { } 0 0 0
1013 0 $code .= <<EOF
1014 if (items > 1) {
1015 croak (\"$name is read only\") ;
1016 }
1017 EOF
1018 }
1019 else {
1020 0 $code .= "\n if (items > 1) {\n" ;
1021 0 ▶ if ($e -> {malloc}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($e->{'malloc'}) { } 0 0 0
elsif ($strncpy) { } 0 0 0
1022 0 my $dest = "obj->$name" ;
1023 0 my $src = $val ;
1024 0 my $type = $cast ;
1025 0 my $expr = eval ('"' . $e -> {malloc} . '"') ;
1026 0 ▶ print $@ if ($@) ;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1027 0 $code .= ' ' . $expr . ";\n" ;
1028 }
1029 elsif ($strncpy) {
1030 0 $code .= " strncpy(obj->$name, ($cast) $val, ($strncpy) - 1) ;\n" ;
1031 0 $code .= " obj->$name\[($strncpy)-1] = '\\0';\n" ;
1032 }
1033 else {
1034 0 $code .= " obj->$name = ($cast) $val;\n" ;
1035 }
1036 0 $code .= " }\n" ;
1037 }
1038
1039 0 $code .= <<EOF;
1040 OUTPUT:
1041 RETVAL
1042
1043 EOF
1044 0 push @{ $self->{XS}->{ $struct->{module} } }, {
1045 code => $code,
1046 class => $class,
1047 name => $name,
1048 perl_name => $e -> {perl_name},
1049 comment => $e -> {comment},
1050 0 struct_member => $e,
1051 };
1052 }
1053 }
1054 0 ▶ $self -> get_structure_new($class, $struct) if ($struct->{has_new}) ;
Branch: 1 branch
BranchTrueFalseTotal
if $struct->{"has_new"} 0 0 0
1055 0 ▶ $self -> get_structure_destroy($class, $struct) if ($struct->{has_new}) ;
Branch: 1 branch
BranchTrueFalseTotal
if $struct->{"has_new"} 0 0 0
1056 0 ▶ $self -> get_structure_callback_init ($class, $struct) if ($has_callbacks);
Branch: 1 branch
BranchTrueFalseTotal
if $has_callbacks 0 0 0
1057
1058 }
1059 }
1060
1061 # ============================================================================
1062
1063 0 ▶sub prepare {
Subroutine prepare: not called CC=2 SCAR=17.9
Pod undocumented
1064 0 my $self = shift;
1065 0 $self->{DIR} = $self -> xs_target_dir;
1066 0 $self->{XS_DIR} = $self -> xs_target_dir ;
1067
1068 0 ▶ if (-e $self->{DIR}) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $self->{"DIR"}) 0 0 0
1069 0 rmtree([$self->{DIR}], 1, 1);
1070 }
1071
1072 0 mkpath [$self->{DIR}], 1, 0755;
1073 }
1074
1075 # ============================================================================
1076
1077 0 ▶sub class_dirname {
Subroutine class_dirname: not called CC=1 SCAR=6.9
Pod undocumented
1078 0 my($self, $class) = @_;
1079 # my($base, $sub) = split '::', $class;
1080 # return "$self->{DIR}/$base" unless $sub; #Apache | APR
1081 # return $sub if $sub eq $self->{DIR}; #WrapXS
1082 # return "$base/$sub";
1083
1084 0 $class =~ s/::/\//g ;
1085 0 return $class ;
1086 }
1087
1088 # ============================================================================
1089
1090 0 ▶sub class_dir {
Subroutine class_dir: not called CC=2 SCAR=17.9
Pod undocumented
1091 0 my($self, $class) = @_;
1092
1093 0 my $dirname = $self->class_dirname($class);
1094 #my $dir = ($dirname =~ m:/: and $dirname !~ m:^$self->{DIR}:) ?
1095 # join('/', $self->{DIR}, $dirname) : $dirname;
1096 0 my $dir = join('/', $self->{DIR}, $dirname) ;
1097
1098 0 ▶ mkpath [$dir], 1, 0755 unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 0 0
1099
1100 0 $dir;
1101 }
1102
1103 # ============================================================================
1104
1105 0 ▶sub class_file {
Subroutine class_file: not called CC=1 SCAR=6.9
Pod undocumented
1106 0 my($self, $class, $file) = @_;
1107 0 join '/', $self->class_dir($class), $file;
1108 }
1109
1110 # ============================================================================
1111
1112 0 ▶sub cname {
Subroutine cname: not called CC=2 SCAR=17.9
Pod undocumented
1113 0 my($self, $class) = @_;
1114 0 ▶ confess ('ERROR: class is undefined in cname') if (!defined ($class)) ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $class 0 0 0
1115 0 $class =~ s/::$// ;
1116 0 $class =~ s/:/_/g;
1117 0 $class;
1118 }
1119
1120
1121
1122 # ============================================================================
1123
1124 0 ▶sub convert_2obj {
Subroutine convert_2obj: not called CC=1 SCAR=6.9
Pod undocumented
1125 0 my($self, $class, $name) = @_;
1126
1127 0 $self -> my_cnv_prefix . $self -> cname($class) . "_2obj($name)" ;
1128 }
1129
1130
1131 # ============================================================================
1132
1133 0 ▶sub convert_sv2 {
Subroutine convert_sv2: not called CC=1 SCAR=6.9
Pod undocumented
1134 0 my($self, $rtype, $class, $name) = @_;
1135
1136 0 $class =~ s/^const\s+// ;
1137 0 $class =~ s/char\s*\*/PV/ ;
1138 0 $class =~ s/SV\s*\*/SV/ ;
1139
1140 0 return "($rtype)" . $self -> my_cnv_prefix . 'sv2_' . $self -> cname($class) . "($name)" ;
1141 }
1142
1143
1144 # ============================================================================
1145
1146 0 ▶sub open_class_file {
Subroutine open_class_file: not called CC=3 SCAR=24.8
Pod undocumented
1147 0 my($self, $class, $file) = @_;
1148
1149 0 ▶ if ($file =~ /^\./) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /^\./) 0 0 0
1150 0 my $sub = (split '::', $class)[-1];
1151 0 $file = $sub . $file;
1152 }
1153
1154 0 my $name = $self->class_file($class, $file);
1155
1156 0 ▶ open my $fh, '>', $name or die "open $name: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $name or die "open ${name}: $!" 0 0 0
1157 0 print "writing...$name\n";
1158
1159 0 return $fh;
1160 }
1161
1162
1163 # ============================================================================
1164 =pod
1165
1166 =head2 makefilepl_text (o)
1167
1168 Returns text for Makefile.PL
1169
1170 =cut
1171
1172 0 ▶sub makefilepl_text {
Subroutine makefilepl_text: not called CC=2 SCAR=17.9
Pod documented
1173 0 my($self, $class, $deps,$typemap) = @_;
1174
1175 0 my @parts = split (/::/, $class) ;
1176 0 my $mmargspath = '../' x @parts ;
1177 0 $mmargspath .= 'mmargs.pl' ;
1178
1179 0 my $txt = qq{
1180 $self->{noedit_warning_hash}
1181
1182 use ExtUtils::MakeMaker ();
1183
1184 local \$MMARGS ;
1185
1186 if (-f '$mmargspath')
1187 {
1188 do '$mmargspath' ;
1189 die \$\@ if (\$\@) ;
1190 }
1191
1192 \$MMARGS ||= {} ;
1193
1194
1195 ExtUtils::MakeMaker::WriteMakefile(
1196 'NAME' => '$class',
1197 'VERSION' => '0.01',
1198 'TYPEMAPS' => ['$typemap'],
1199 } ;
1200 0 ▶$txt .= "'depend' => $deps,\n" if ($deps) ;
Branch: 1 branch
BranchTrueFalseTotal
if $deps 0 0 0
1201 0 $txt .= qq{
1202 \%\$MMARGS,
1203 );
1204
1205 } ;
1206
1207 }
1208
1209 # ============================================================================
1210
1211 0 ▶sub write_makefilepl {
Subroutine write_makefilepl: not called CC=5 SCAR=34.0
Pod undocumented
1212 0 my($self, $class) = @_;
1213
1214 0 $self -> {makefilepls}{$class} = 1 ;
1215
1216 0 my $fh = $self->open_class_file($class, 'Makefile.PL');
1217
1218 0 my $includes = $self->includes;
1219 0 my @parts = split '::', $class ;
1220 0 ▶ my $xs = @parts?$parts[-1] . '.c':'' ;
Branch: 1 branch
BranchTrueFalseTotal
@parts ? : 0 0 0
1221 0 my $deps = {$xs => ""};
1222
1223 0 ▶ if (my $mod_h = $self->mod_h($class, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mod_h = $self->mod_h($class, 1)) 0 0 0
1224 0 my $abs = File::Spec -> rel2abs ($mod_h) ;
1225 0 my $rel = File::Spec -> abs2rel ($abs, $self -> class_dir ($class)) ;
1226 0 $deps->{$xs} .= " $rel";
1227 }
1228
1229 0 local $Data::Dumper::Terse = 1;
1230 0 $deps = Dumper $deps;
1231 0 ▶ $deps = undef if (!$class) ;
Branch: 1 branch
BranchTrueFalseTotal
unless $class 0 0 0
1232
1233 0 ▶ $class ||= 'WrapXS' ;
Condition0%0/2
$class ||= "WrapXS"
l!l
00
MC/DC0%0/1
$class ||= "WrapXS"
$class
Truth table0%0/2
A
A= $class
Aresult
11
00
1234 0 print $fh $self -> makefilepl_text ($class, $deps, ('../' x @parts) . 'typemap') ;
1235
1236 0 close $fh;
1237 }
1238
1239 # ============================================================================
1240
1241 0 ▶sub write_missing_makefilepls {
Subroutine write_missing_makefilepls: not called CC=5 SCAR=34.0
Pod undocumented
1242 0 my($self, $class) = @_;
1243
1244 0 my %classes = ('' => 1) ;
1245 0 foreach (keys %{$self -> {makefilepls}})
1246 {
1247 0 my @parts = split (/::/, $_) ;
1248 0 my $i ;
1249 0 ▶ for ($i = 0; $i < @parts; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @parts) 0 0 0
1250 {
1251 0 $classes{join('::', @parts[0..$i])} = 1 ;
1252 }
1253 }
1254
1255 0 foreach my $class (keys %classes)
1256 {
1257 0 ▶ next if ($self -> {makefilepls}{$class}) ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"makefilepls"}{$class} 0 0 0
1258
1259 0 $self -> write_makefilepl ($class) ;
1260 }
1261 }
1262
1263 # ============================================================================
1264
1265 0 ▶sub mod_h {
Subroutine mod_h: not called CC=4 SCAR=30.0
Pod undocumented
1266 0 my($self, $module, $complete) = @_;
1267
1268 0 my $dirname = $self->class_dirname($module);
1269 0 my $cname = $self->cname($module);
1270 0 my $mod_h = "$dirname/$cname.h";
1271
1272 0 for ($self -> xs_include_dir, @{ $self->{glue_dirs} }) {
1273 0 my $file = "$_/$mod_h";
1274 0 ▶ $mod_h = $file if $complete;
Branch: 1 branch
BranchTrueFalseTotal
if $complete 0 0 0
1275 0 ▶ return $mod_h if -e $file;
Branch: 1 branch
BranchTrueFalseTotal
if -e $file 0 0 0
1276 }
1277
1278 0 undef;
1279 }
1280
1281 # ============================================================================
1282
1283 0 ▶sub mod_pm {
Subroutine mod_pm: not called CC=4 SCAR=30.0
Pod undocumented
1284 0 my($self, $module, $complete) = @_;
1285
1286 0 my $dirname = $self->class_dirname($module);
1287 0 my @parts = split '::', $module;
1288 0 my $mod_pm = "$dirname/$parts[-1]_pm";
1289
1290 0 for ($self -> xs_incsrc_dir, @{ $self->{glue_dirs} }) {
1291 0 my $file = "$_/$mod_pm";
1292 0 ▶ $mod_pm = $file if $complete;
Branch: 1 branch
BranchTrueFalseTotal
if $complete 0 0 0
1293 0 print "mod_pm $mod_pm $file $complete\n" ;
1294 0 ▶ return $mod_pm if -e $file;
Branch: 1 branch
BranchTrueFalseTotal
if -e $file 0 0 0
1295 }
1296
1297 0 undef;
1298 }
1299
1300
1301 # ============================================================================
1302 =pod
1303
1304 =head2 h_filename_prefix (o)
1305
1306 Defines a prefix for generated header files
1307
1308 Default: C<'xs_'>
1309
1310 =cut
1311
1312 0 ▶sub h_filename_prefix { 'xs_' }
Subroutine h_filename_prefix: not called CC=1 SCAR=6.9
Pod documented
1313
1314 # ============================================================================
1315 =pod
1316
1317 =head2 my_xs_prefix (o)
1318
1319 Defines a prefix used for all XS functions
1320
1321 Default: C<'xs_'>
1322
1323 =cut
1324
1325 0 ▶sub my_xs_prefix { 'xs_' }
Subroutine my_xs_prefix: not called CC=1 SCAR=6.9
Pod documented
1326
1327 # ============================================================================
1328 =pod
1329
1330 =head2 my_cnv_prefix (o)
1331
1332 Defines a prefix used for all conversion functions/macros.
1333
1334 Default: C<my_xs_prefix>
1335
1336 =cut
1337
1338 0 ▶sub my_cnv_prefix { $_[0] -> my_xs_prefix }
Subroutine my_cnv_prefix: not called CC=1 SCAR=6.9
Pod documented
1339
1340 # ============================================================================
1341 =pod
1342
1343 =head2 needs_prefix (o, name)
1344
1345 Returns true if the passed name should be prefixed
1346
1347 =cut
1348
1349 0 ▶sub needs_prefix {
Subroutine needs_prefix: not called CC=2 SCAR=17.9
Pod documented
1350 0 ▶ return 0 if (!$_[1]) ;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[1] 0 0 0
1351 0 my $pf = $_[0] -> my_xs_prefix ;
1352 0 return $_[1] !~ /^$pf/i;
1353 }
1354
1355 # ============================================================================
1356
1357
1358 0 ▶sub isa_str {
Subroutine isa_str: not called CC=3 SCAR=24.8
Pod undocumented
1359 0 my($self, $module) = @_;
1360 0 my $str = "";
1361
1362 0 ▶ if (my $isa = $self->typemap->{function_map}->{isa}->{$module}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $isa = $self->typemap->{"function_map"}{"isa"}{$module}) 0 0 0
1363 0 ▶ while (my($sub, $base) = each %$isa) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$isa) 0 0 0
1364 #XXX cannot set isa in the BOOT: section because XSLoader local-ises
1365 #ISA during bootstrap
1366 # $str .= qq{ av_push(get_av("$sub\::ISA", TRUE),
1367 # newSVpv("$base",0));}
1368 0 $str .= qq{\@$sub\::ISA = '$base';\n}
1369 }
1370 }
1371
1372 0 $str;
1373 }
1374
1375 # ============================================================================
1376
1377 0 ▶sub boot {
Subroutine boot: not called CC=2 SCAR=17.9
Pod undocumented
1378 0 my($self, $module) = @_;
1379 0 my $str = "";
1380
1381 0 ▶ if (my $boot = $self->typemap->{function_map}->{boot}->{$module}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $boot = $self->typemap->{"function_map"}{"boot"}{$module}) 0 0 0
1382 0 $str = ' ' . $self -> my_xs_prefix . $self->cname($module) . "_BOOT(aTHXo);\n";
1383 }
1384
1385 0 $str;
1386 }
1387
1388 # ============================================================================
1389
1390 1 my $notshared = join '|', qw(TIEHANDLE); #not sure why yet
1391
1392 0 ▶sub attrs {
Subroutine attrs: not called CC=2 SCAR=17.9
Pod undocumented
1393 0 my($self, $name) = @_;
1394 0 my $str = "";
1395 0 ▶ return $str if $name =~ /$notshared$/o;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /$notshared$/o 0 0 0
1396 0 $str = " ATTRS: shared\n" if GvSHARED;
1397 0 $str;
1398 }
1399
1400 # ============================================================================
1401
1402 0 ▶sub write_xs {
Subroutine write_xs: not called CC=12 SCAR=50.5
Pod undocumented
1403 0 my($self, $module, $functions) = @_;
1404
1405 0 my $fh = $self->open_class_file($module, '.xs');
1406 0 print $fh "$self->{noedit_warning_c}\n";
1407
1408 0 my @includes = @{ $self->includes };
1409
1410 0 ▶ if (my $mod_h = $self->mod_h($module)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mod_h = $self->mod_h($module)) 0 0 0
1411 0 push @includes, $mod_h;
1412 }
1413
1414 0 for (@includes) {
1415 0 print $fh qq{\#include "$_"\n\n};
1416 }
1417
1418 0 my $last_prefix = "";
1419 0 my $fmap = $self -> typemap -> {function_map} ;
1420 0 my $myprefix = $self -> my_xs_prefix ;
1421
1422 0 for my $func (@$functions) {
1423 0 my $class = $func->{class};
1424 0 ▶ if ($class)
Branch: 1 branch
BranchTrueFalseTotal
if ($class) 0 0 0
1425 {
1426 0 my $prefix = $func->{prefix};
1427 0 ▶ $last_prefix = $prefix if $prefix;
Branch: 1 branch
BranchTrueFalseTotal
if $prefix 0 0 0
1428
1429 0 ▶ if ($func->{name} =~ /^$myprefix/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($func->{"name"} =~ /^$myprefix/o) 0 0 0
1430 #e.g. mpxs_Apache__RequestRec_
1431 0 my $class_prefix = $fmap -> class_c_prefix($class);
1432 0 ▶ if ($func->{name} =~ /$class_prefix/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($func->{"name"} =~ /$class_prefix/) 0 0 0
1433 0 $prefix = $fmap -> class_xs_prefix($class);
1434 }
1435 }
1436
1437 0 ▶ $prefix = $prefix ? " PREFIX = $prefix" : "";
Branch: 1 branch
BranchTrueFalseTotal
$prefix ? : 0 0 0
1438 0 print $fh "MODULE = $module PACKAGE = $class $prefix\n\n";
1439 }
1440
1441 0 print $fh $func->{code};
1442 }
1443
1444 0 ▶ if (my $destructor = $self->typemap->destructor($last_prefix)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $destructor = $self->typemap->destructor($last_prefix)) 0 0 0
1445 0 my $arg = $destructor->{argspec}[0];
1446
1447 0 print $fh <<EOF;
1448 void
1449 $destructor->{name}($arg)
1450 $destructor->{class} $arg
1451
1452 EOF
1453 }
1454
1455 0 print $fh "PROTOTYPES: disabled\n\n";
1456 0 print $fh "BOOT:\n";
1457 0 print $fh $self->boot($module);
1458 0 print $fh " items = items; /* -Wall */\n\n";
1459
1460 0 ▶ if (my $newxs = $self->{newXS}->{$module}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $newxs = $self->{"newXS"}{$module}) 0 0 0
1461 0 for my $xs (@$newxs) {
1462 0 print $fh qq{ cv = newXS("$xs->[0]", $xs->[1], __FILE__);\n};
1463 0 print $fh qq{ GvSHARED_on(CvGV(cv));\n} if GvSHARED;
1464 }
1465 }
1466
1467 0 close $fh;
1468 }
1469
1470 # ============================================================================
1471 =pod
1472
1473 =head2 pm_text (o, module, isa, code)
1474
1475 Returns the text of a C<.pm> file, or undef if no C<.pm> file should be
1476 written.
1477
1478 Default: Create a C<.pm> file which bootstraps the XS code
1479
1480 =cut
1481
1482 0 ▶sub pm_text {
Subroutine pm_text: not called CC=1 SCAR=6.9
Pod documented
1483 0 my($self, $module, $isa, $code) = @_;
1484
1485 0 return <<EOF;
1486 $self->{noedit_warning_hash}
1487
1488 package $module;
1489 require DynaLoader ;
1490 use strict ;
1491 use vars qw{\$VERSION \@ISA} ;
1492 $isa
1493 push \@ISA, 'DynaLoader' ;
1494 \$VERSION = '0.01';
1495 bootstrap $module \$VERSION ;
1496
1497 $code
1498
1499 1;
1500 __END__
↑ Summary XSBuilder/FunctionMap.pm »