| 1 | package # hide from CPAN indexer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | XS::Install::ParseXS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 feature 'state'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use ExtUtils::ParseXS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use XS::Install::FrozenShit::ParseXS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use XS::Install::FrozenShit::ParseXS::Eval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use XS::Install::FrozenShit::ParseXS::Utilities; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use XS::Install::FrozenShit::Typemaps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use XS::Install::FrozenShit::Typemaps::InputMap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use XS::Install::FrozenShit::Typemaps::OutputMap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | *ExtUtils::ParseXS::new = *XS::Install::FrozenShit::ParseXS::new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | my (@pre_callbacks, @no_typemap_callbacks); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | our ($top_typemaps, $cur_typemaps); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | our $cplus = grep { /-C\+\+/ } @ARGV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $re_quot1 = qr/"(?:[^"\\]+|\\.)*"/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | my $re_quot2 = qr/'(?:[^'\\]+|\\.)*'/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | my $re_quot = qr/(?:$re_quot1|$re_quot2)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my $re_comment_single = qr#//[^\n]*\n#; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | my $re_comment_multi = qr#/\*.*?\*/#ms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | my $re_ignored = qr/(?:$re_quot|$re_comment_single|$re_comment_multi)/ms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | my $re_braces = qr#(?<braces>\{(?>[^/"'{}]+|$re_ignored|(?&braces)|/)*\})#ms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | our $re_xsub = qr/(XS_EUPXS\(XS_[a-zA-Z0-9_]+\))[^{]+($re_braces)/ms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | our $re_boot = qr/(XS_EXTERNAL\(boot_[a-zA-Z0-9_]+\))[^{]+($re_braces)/ms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | my $new_parsexs = $XS::Install::FrozenShit::ParseXS::VERSION >= 3.53; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub add_pre_callback { push @pre_callbacks, shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_pre_callback: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub add_post_callback { push @CatchEnd::post_callbacks, shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_post_callback: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub add_no_typemap_callback { push @no_typemap_callbacks, shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_no_typemap_callback: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | ▶ | sub call { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 5 | my ($cbs, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | $_->(@args) for @$cbs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 8 | ▶ | sub code_start_idx { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code_start_idx: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 8 | my $lines = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | my $idx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 8 | ▶ | for (my $i = 2; $i < @$lines; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 8 | ▶ | return $i+1 if $lines->[$i] =~ /^(PP)?CODE\s*:/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | die "code start not found"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | ▶ | sub code_end_idx { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code_end_idx: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | my $lines = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | my $idx = code_start_idx($lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 4 | ▶ | for (; $idx < @$lines; ++$idx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 30 | ▶ | return $idx if $lines->[$idx] =~ /^[a-zA-Z0-9]+\s*:/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | return $idx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | ▶ | sub is_empty { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_empty: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | my $lines = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | return code_start_idx($lines) == code_end_idx($lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub insert_code_top { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_code_top: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my ($parser, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $lines = $parser->{line}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $linno = $parser->{line_no}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $idx = code_start_idx($lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | splice(@$lines, $idx, 0, $code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | splice(@$linno, $idx, 0, $linno->[$idx] // $linno->[-1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$linno->[$idx] // $linno->[-1]
MC/DC0%0/2
$linno->[$idx] // $linno->[-1]
$linno->[$idx]
$linno->[-1]
Truth table0%0/3
A // B
A= $linno->[$idx]B= $linno->[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub insert_code_bottom { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_code_bottom: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my ($parser, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $lines = $parser->{line}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $linno = $parser->{line_no}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $idx = code_end_idx($lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | splice(@$lines, $idx, 0, $code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | splice(@$linno, $idx, 0, $linno->[$idx] // $linno->[-1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$linno->[$idx] // $linno->[-1]
MC/DC0%0/2
$linno->[$idx] // $linno->[-1]
$linno->[$idx]
$linno->[-1]
Truth table0%0/3
A // B
A= $linno->[$idx]B= $linno->[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | my $orig_new = \&XS::Install::FrozenShit::ParseXS::new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | ▶ | *XS::Install::FrozenShit::ParseXS::new = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | $class = 'XS::Install::FrozenShit::ParseXS'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | my $self = $orig_new->($class, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | if ($new_parsexs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | Hash::Util::unlock_keys(%$self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | my $orig_pmxl = \&XS::Install::FrozenShit::ParseXS::_process_module_xs_line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | *XS::Install::FrozenShit::ParseXS::_process_module_xs_line = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | my ($self, $module, $pkg, $prefix) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | $orig_pmxl->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | $self->{xsi}{package} = $pkg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | $self->{xsi}{module} = $module; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | $self->{xsi}{inline_mode} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 7 | ▶ | sub get_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_mode: called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 7 | ▶ | return '' unless $_[0] =~ /^MODE\s*:\s*(\w+)\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return uc($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # pre process XS function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | my $orig_fetch_para = \&XS::Install::FrozenShit::ParseXS::fetch_para; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 | ▶ | *XS::Install::FrozenShit::ParseXS::fetch_para = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=71 SCAR=64.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 10 | my $ret = $orig_fetch_para->($self, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 10 | my $lines = $self->{line}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 10 | my $linno = $self->{line_no}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 10 | ▶ | return $ret unless @$lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 7 | ▶ | if (get_mode($lines->[0]) eq 'INLINE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $self->{xsi}{inline_mode} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | shift @$lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | shift @$linno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 7 | ▶ | if ($self->{xsi}{inline_mode}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | while (@$lines) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $line = shift @$lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | shift @$linno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if (get_mode($line) eq 'XS') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $self->{xsi}{inline_mode} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | print "$line\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | return $ret unless @$lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # concat 2 lines codes (functions with default behaviour) to make it preprocessed like C-like synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 7 | ▶ | if (@$lines == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $lines->[0] .= ' '.$lines->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | splice(@$lines, 1, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | splice(@$linno, 1, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 7 | ▶ | if ($lines->[0] and $lines->[0] =~ /^([A-Z]+)\s*\{/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lines->[0] and $lines->[0] =~ /^([A-Z]+)\s*\{/
MC/DC50%1/2
$lines->[0] and $lines->[0] =~ /^([A-Z]+)\s*\{/
$lines->[0]
$lines->[0] =~ /^([A-Z]+)\s*\{/
Truth table66%2/3
A and B
A= $lines->[0]B= $lines->[0] =~ /^([A-Z]+)\s*\{/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | $lines->[0] = "$1:"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | ▶ | if ($lines->[-1] =~ /^\}/) { pop @$lines; pop @$linno; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 7 | my %attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 7 | ▶ | if ($lines->[0] and $lines->[0] =~ /^(.+?)\s+([^\s()]+\s*(\((?:[^()]|(?3))*\)))\s*(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lines->[0] and $lines->[0] =~ /^(.+?)\s+([^\s()]+\s*(\((?:[^()]|(?3))*\)))\s*(.*)/
MC/DC50%1/2
$lines->[0] and $lines->[0] =~ /^(.+?)\s+([^\s()]+\s*(\((?:[^()]|(?3))*\)))\s*(.*)/
$lines->[0]
$lines->[0] =~ /^(.+?)\s+([^\s()]+\s*(\((?:[^()]|(?3))*\)))\s*(.*)/
Truth table66%2/3
A and B
A= $lines->[0]B= $lines->[0] =~ /^(.+?)\s+([^\s()]+\s*(\((?:[^()]|(?3))*\)))\s*(.*)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 4 | my ($type, $sig, $rest) = ($1, $2, $4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 4 | shift @$lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | my $deflinno = shift @$linno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | my $remove_closing; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 4 | ▶ | if ((my $idx = index($rest, '{')) >= 0) { # move following text on next line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 4 | $remove_closing = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | my $content = substr($rest, $idx+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 4 | substr($rest, $idx) = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | ▶ | if ($content =~ /\S/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | unshift @$lines, $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | unshift @$linno, $deflinno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ▶ | } elsif ($lines->[0] and $lines->[0] =~ s/^\s*\{//) { # '{' on next line | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$lines->[0] and $lines->[0] =~ s/^\s*\{//
MC/DC0%0/2
$lines->[0] and $lines->[0] =~ s/^\s*\{//
$lines->[0]
$lines->[0] =~ s/^\s*\{//
Truth table0%0/3
A and B
A= $lines->[0]B= $lines->[0] =~ s/^\s*\{//
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $remove_closing = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if ($lines->[0] !~ /\S/) { # nothing remains, delete entire line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | shift @$lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | shift @$linno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | ▶ | if ($remove_closing) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 4 | $lines->[-1] =~ s/}\s*;?\s*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | ▶ | if ($lines->[-1] !~ /\S/) { pop @$lines; pop @$linno; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 4 | ▶ | if (!$lines->[0] or $lines->[0] !~ /\S/) { # no code remains, but body was present ({}), add empty code to prevent default behaviour | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$lines->[0] and $lines->[0] =~ /\S/
MC/DC0%0/2
$lines->[0] and $lines->[0] =~ /\S/
$lines->[0]
$lines->[0] =~ /\S/
Truth table33%1/3
A and B
A= $lines->[0]B= $lines->[0] =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $lines->[0] = ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $linno->[0] ||= $deflinno; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$linno->[0] ||= $deflinno
MC/DC0%0/2
$linno->[0] ||= $deflinno
$linno->[0]
$deflinno
Truth table0%0/3
A ||= B
A= $linno->[0]B= $deflinno
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 4 | ▶ | if (length $lines->[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 4 | ▶ | unshift @$lines, $type =~ /^void(\s|$)/ ? 'PPCODE:' : 'CODE:'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 4 | unshift @$linno, $deflinno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 4 | ▶ | if ($rest =~ /:(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $attrs_str = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | %attrs = ($attrs_str =~ /\s*([A-Za-z]+)\s*(?:\(([^()]*)\)|)\s*/g); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 4 | ▶ | while (my ($attr, $val) = each %attrs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $attr = uc($attr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ($attr eq 'ALIAS' && (my @alias = split /\s*,\s*/, $val)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$attr eq "ALIAS" and my @alias = split(/\s*,\s*/, $val, 0)
MC/DC0%0/2
$attr eq "ALIAS" and my @alias = split(/\s*,\s*/, $val, 0)
$attr eq "ALIAS"
my @alias = split(/\s*,\s*/, $val, 0)
Truth table0%0/3
A and B
A= $attr eq "ALIAS"B= my @alias = split(/\s*,\s*/, $val, 0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | foreach my $alias_entry (reverse @alias) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | unshift @$lines, " $alias_entry"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | unshift @$linno, $deflinno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | unshift @$lines, 'ALIAS:'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | unshift @$linno, $deflinno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | elsif ($attr eq 'CONST') { next } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | elsif (defined $val) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | unshift @$lines, "$attr: $val"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | unshift @$linno, $deflinno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 4 | unshift @$lines, $sig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | unshift @$lines, $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 4 | unshift @$linno, $deflinno for 1..2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # make BOOT's code in personal scope | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 7 | ▶ | if ($lines->[0] =~ /^BOOT\s*:/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | splice(@$lines, 1, 0, " {"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | splice(@$linno, 1, 0, $linno->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | push @$lines, " }"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | push @$linno, $linno->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 7 | s/\b__PACKAGE__\b/"$self->{xsi}{package}"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 49 | s/\b__MODULE__\b/"$self->{xsi}{module}"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } @$lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 7 | ▶ | my $out_type = $lines->[0] or return $ret; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # filter out junk, because first line might be "BOOT:", "PROTOTYPES: ...", "INCLUDE: ...", "#ifdef", etc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 7 | ▶ | return $ret if !$out_type or $out_type =~ /^#/ or $out_type =~ /^[_A-Z]+\s*:([^:]|$)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not $out_type or $out_type =~ /^#/ or $out_type =~ /^[_A-Z]+\s*:([^:]|$)/
not $out_type or $out_type =~ /^#/
MC/DC33%1/3
not $out_type or $out_type =~ /^#/ or $out_type =~ /^[_A-Z]+\s*:([^:]|$)/
not $out_type
$out_type =~ /^#/
$out_type =~ /^[_A-Z]+\s*:([^:]|$)/
Truth table50%2/4
not(A) or B or C
A= not $out_typeB= $out_type =~ /^#/C= $out_type =~ /^[_A-Z]+\s*:([^:]|$)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # parse signature -> $func and @args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 4 | my $sig = $lines->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 4 | ▶ | $sig =~ /^([^(]+)\((.*)\)\s*$/ or die "bad signature: '$sig', at $self->{filepathname}, function $self->{pname}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 4 | my $func = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 4 | my $args_str = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 4 | $func =~ s/^\s+//; $func =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 4 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | my $variadic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 4 | for my $str (split /\s*,\s*/, $args_str) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 8 | my %info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 8 | ▶ | $info{default} = $1 if $str =~ s/\s*=\s*(.+)$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 8 | ▶ | $info{name} = $1 if $str =~ s/([a-zA-Z0-9_\$]+)\s*$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 8 | $str =~ s/^\s+//g; $str =~ s/\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 8 | $info{type} = $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 8 | ▶ | if ($str eq '...') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | $variadic = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ▶ | elsif (!$info{type} && !$info{name}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$info{'type'} || $info{'name'}
MC/DC0%0/2
$info{'type'} || $info{'name'}
$info{'type'}
$info{'name'}
Truth table33%1/3
A || B
A= $info{'type'}B= $info{'name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | ▶ | elsif (!$info{type} || !$info{name}) { # arg with no name (unused arg) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$info{'type'} && $info{'name'}
MC/DC50%1/2
$info{'type'} && $info{'name'}
$info{'type'}
$info{'name'}
Truth table66%2/3
A && B
A= $info{'type'}B= $info{'name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 2 | ▶ | $info{type} ||= $info{name}; # (for signatures like "string, " name will consume type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$info{"type"} ||= $info{"name"}
MC/DC0%0/2
$info{"type"} ||= $info{"name"}
$info{"type"}
$info{"name"}
Truth table33%1/3
A ||= B
A= $info{"type"}B= $info{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | ▶ | die "bad argument: '$sig', at $self->{filepathname}, function $self->{pname}" unless $info{type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | state $unused_no = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | ▶ | $info{name} = $new_parsexs ? '_____unused'.($unused_no++) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 6 | map { s/^\s+//; s/\s+$// } values %info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 6 | push @args, \%info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 4 | ▶ | if ($func =~ s/^(.+):://) { # replace 'Class::meth' with 'meth(Class* THIS)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | unshift @args, $func eq 'new' ? {name => 'CLASS', type => 'SV*', orig_type => $1} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | {name => 'THIS', type => "$1*"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 4 | my $first_arg = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 4 | ▶ | $first_arg->{type} = 'const '.$first_arg->{type} if exists($attrs{const}) or exists($attrs{CONST}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $attrs{"const"} or exists $attrs{"CONST"}
MC/DC0%0/2
exists $attrs{"const"} or exists $attrs{"CONST"}
exists $attrs{"const"}
exists $attrs{"CONST"}
Truth table33%1/3
A or B
A= exists $attrs{"const"}B= exists $attrs{"CONST"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 4 | ▶ | my $is_method = $first_arg && $first_arg->{name} eq 'THIS'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$first_arg && $first_arg->{'name'} eq 'THIS'
MC/DC0%0/2
$first_arg && $first_arg->{'name'} eq 'THIS'
$first_arg
$first_arg->{'name'} eq 'THIS'
Truth table33%1/3
A && B
A= $first_argB= $first_arg->{'name'} eq 'THIS'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 4 | my $para = join("\n", @$lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 4 | ▶ | if ($para !~ /^(PP)?CODE\s*:/m) { # empty function, replace with $func(@args) or $first_arg->$func(@rest_args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $void = $out_type =~ /^void(?:\s|$)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | push @$lines, $void ? 'PPCODE:' : 'CODE:'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | push @$linno, $linno->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if ($func ne 'new' and ($func ne 'DESTROY' or !$is_method)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$func ne "new" and $func ne "DESTROY" || !$is_method
$func ne "DESTROY" or not $is_method
MC/DC0%0/3
$func ne "new" and $func ne "DESTROY" || !$is_method
$func ne "new"
$func ne "DESTROY"
not $is_method
Truth table0%0/4
A and B or not(C)
A= $func ne "new"B= $func ne "DESTROY"C= not $is_method
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $code = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my @real_args = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if ($is_method) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | shift @real_args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $code = $first_arg->{name}.'->'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $code .= $func.'('.join(', ', map { $_->{name} } @real_args).')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | $code = "RETVAL = $code" unless $void; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | push @$lines, " $code;"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | push @$linno, $linno->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $para = join("\n", @$lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 4 | ▶ | if ($para =~ /^CODE\s*:/m and $para !~ /^OUTPUT\s*:/m) { # add OUTPUT:RETVAL unless any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$para =~ /^CODE\s*:/m and not $para =~ /^OUTPUT\s*:/m
MC/DC50%1/2
$para =~ /^CODE\s*:/m and not $para =~ /^OUTPUT\s*:/m
$para =~ /^CODE\s*:/m
not $para =~ /^OUTPUT\s*:/m
Truth table66%2/3
A and not(B)
A= $para =~ /^CODE\s*:/mB= not $para =~ /^OUTPUT\s*:/m
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | push @$lines, 'OUTPUT:', ' RETVAL'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | push @$linno, $linno->[-1] for 1..2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | $para = join("\n", @$lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 4 | my $cb_args = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | ret => $out_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | func => $func, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | args => \@args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | variadic => $variadic, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 4 | call(\@pre_callbacks, $self, $cb_args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # form final signature for ParseXS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 4 | ▶ | my @args_lines = map { "$_->{type} $_->{name}".(defined($_->{default}) ? " = $_->{default}" : '') } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 4 | ▶ | push @args_lines, '...' if $variadic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 4 | $sig = $func.' ('.join(', ', @args_lines).')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 4 | $lines->[0] = $out_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 4 | $lines->[1] = $sig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 4 | ▶ | if (is_empty($lines)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if ($func eq 'DESTROY' and $is_method) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$func eq "DESTROY" and $is_method
MC/DC0%0/2
$func eq "DESTROY" and $is_method
$func eq "DESTROY"
$is_method
Truth table0%0/3
A and B
A= $func eq "DESTROY"B= $is_method
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | insert_code_top($self, " delete THIS;"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | elsif ($func eq 'new') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | insert_code_top($self, " RETVAL = ".default_constructor($out_type, \@args).';'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 4 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | ▶ | if ($new_parsexs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | my $orig_node_param_as_code = \&XS::Install::FrozenShit::ParseXS::Node::Param::as_code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 8 | ▶ | *XS::Install::FrozenShit::ParseXS::Node::Param::as_code = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 8 | my XS::Install::FrozenShit::ParseXS::Node::Param $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 8 | ▶ | return '' if $self->{var} =~ /^_____unused/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 6 | return $orig_node_param_as_code->($self, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | sub default_constructor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_constructor: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my ($ret_type, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my @pass_args = @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $fa = shift @pass_args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $args_str = join(', ', map { $_->{name} } @pass_args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $new_type = $fa->{orig_type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | unless ($new_type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $new_type = $ret_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $new_type =~ s/\s*\*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $ret = "new $new_type($args_str)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | $ret = "$ret_type($ret)" unless $ret_type =~ /\*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 1 | my $orig_merge = \&XS::Install::FrozenShit::Typemaps::merge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 1 | my $orig_parse = \&XS::Install::FrozenShit::Typemaps::_parse; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | my $orig_get = \&XS::Install::FrozenShit::Typemaps::get_typemap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 14 | ▶ | *XS::Install::FrozenShit::Typemaps::get_typemap = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 14 | my $ret = $orig_get->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 14 | ▶ | return $ret if $ret; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | call(\@no_typemap_callbacks, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | return $orig_get->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 2 | ▶ | *XS::Install::FrozenShit::Typemaps::merge = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 2 | $top_typemaps = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 2 | return $orig_merge->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 2 | ▶ | *XS::Install::FrozenShit::Typemaps::_parse = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | local $cur_typemaps = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 2 | return $orig_parse->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | # remove ugly default behaviour, it always overrides typemaps in xsubpp's command line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | ▶ | *XS::Install::FrozenShit::ParseXS::Utilities::standard_typemap_locations = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | my $inc = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | ▶ | push @ret, 'typemap' if -e 'typemap'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | package # hide from CPAN | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | CatchEnd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 1 | ▶ | use feature 'say'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | our @post_callbacks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 1 | my ($out, $orig_stdout); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | open $orig_stdout, '>&', STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | close STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | ▶ | open STDOUT, '>', \$out or die $!; # This shouldn't fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | #post-process XS out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | ▶ | sub END { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | ▶ | $out //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$out //= ""
MC/DC0%0/1
$out //= ""
$out
Truth table50%1/2
A
A= $out
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | select $orig_stdout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | $out =~ s/^MODE\s*:.+//mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # remove XS function C-prototype (it causes warnings on many compilers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | $out =~ s/XS_EUPXS\(XS_[a-zA-Z0-9_]+\);.*\n/\n/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | # remove XS BOOT function C-prototype | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | $out =~ s/XS_EXTERNAL\(boot_[a-zA-Z0-9_]+\);.*\n/\n/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | XS::Install::ParseXS::call(\@post_callbacks, \$out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | print $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | package #hide from CPAN | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | XS::Install::FrozenShit::ParseXS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | my $END = "!End!\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | my $BLOCK_regexp = '\s*(' . $XS::Install::FrozenShit::ParseXS::Constants::XSKeywordsAlternation . "|$END)\\s*:"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # copy-paste from XS::Install::FrozenShit::ParseXS to fix Typemaps with references (&). ParseXS was simply removing it from type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # only one line changed with regexp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # my ($var_type, $var_addr, $var_name) = /^(.*?[^&\s])\s*(\&?)\s*\b(\w+)$/s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 4 | ▶ | *INPUT_handler = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=25 SCAR=63.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 4 | $_ = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | for (; !/^$BLOCK_regexp/o; $_ = shift(@{ $self->{line} })) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | last if /^\s*NOT_IMPLEMENTED_YET/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | next unless /\S/; # skip blank lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | trim_whitespace($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my $ln = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # remove trailing semicolon if no initialisation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | s/\s*;$//g unless /[=;+].*\S/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # Process the length(foo) declarations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | if (s/^([^=]*)\blength\(\s*(\w+)\s*\)\s*$/$1 XSauto_length_of_$2=NO_INIT/x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | print "\tSTRLEN\tSTRLEN_length_of_$2;\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $self->{lengthof}->{$2} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $self->{deferred} .= "\n\tXSauto_length_of_$2 = STRLEN_length_of_$2;\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # check for optional initialisation code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my $var_init = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | $var_init = $1 if s/\s*([=;+].*)$//s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $var_init =~ s/"/\\"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # *sigh* It's valid to supply explicit input typemaps in the argument list... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my $is_overridden_typemap = $var_init =~ /ST\s*\(|\$arg\b/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my $var_addr = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | my ($var_type, $var_name) = /^(.*?[^\s])\s*\b(\w+)$/s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | or $self->blurt("Error: invalid argument declaration '$ln'"), next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # Check for duplicate definitions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | $self->blurt("Error: duplicate definition of argument '$var_name' ignored"), next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | if $self->{arg_list}->{$var_name}++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | or defined $self->{argtype_seen}->{$var_name} and not $self->{processing_arg_with_types}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"arg_list"}{$var_name}++ or defined $self->{"argtype_seen"}{$var_name} and not $self->{"processing_arg_with_types"}
defined $self->{"argtype_seen"}{$var_name} and not $self->{"processing_arg_with_types"}
MC/DC0%0/3
$self->{"arg_list"}{$var_name}++ or defined $self->{"argtype_seen"}{$var_name} and not $self->{"processing_arg_with_types"}
$self->{"arg_list"}{$var_name}++
defined $self->{"argtype_seen"}{$var_name}
not $self->{"processing_arg_with_types"}
Truth table0%0/4
A or B and not(C)
A= $self->{"arg_list"}{$var_name}++B= defined $self->{"argtype_seen"}{$var_name}C= not $self->{"processing_arg_with_types"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $self->{thisdone} |= $var_name eq "THIS"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | $self->{retvaldone} |= $var_name eq "RETVAL"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $self->{var_types}->{$var_name} = $var_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # XXXX This check is a safeguard against the unfinished conversion of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | # generate_init(). When generate_init() is fixed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # one can use 2-args map_type() unconditionally. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my $printed_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if ($var_type =~ / \( \s* \* \s* \) /x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # Function pointers are not yet supported with output_init()! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | print "\t" . map_type($self, $var_type, $var_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $printed_name = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | print "\t" . map_type($self, $var_type, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $printed_name = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $self->{var_num} = $self->{args_match}->{$var_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | if ($self->{var_num}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $typemap = $self->{typemap}->get_typemap(ctype => $var_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | $self->report_typemap_failure($self->{typemap}, $var_type, "death") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$typemap or $is_overridden_typemap
MC/DC0%0/2
$typemap or $is_overridden_typemap
$typemap
$is_overridden_typemap
Truth table0%0/3
A or B
A= $typemapB= $is_overridden_typemap
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | if not $typemap and not $is_overridden_typemap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | $self->{proto_arg}->[$self->{var_num}] = ($typemap && $typemap->proto) || "\$"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$typemap && $typemap->proto || '$'
$typemap and $typemap->proto
MC/DC0%0/2
$typemap && $typemap->proto || '$'
$typemap
$typemap->proto
Truth table0%0/3
A and B
A= $typemapB= $typemap->proto
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | $self->{func_args} =~ s/\b($var_name)\b/&$1/ if $var_addr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if ($var_init =~ /^[=;]\s*NO_INIT\s*;?\s*$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/9
$var_init =~ /^[=;]\s*NO_INIT\s*;?\s*$/ or $self->{"in_out"}{$var_name} and $self->{"in_out"}{$var_name} =~ /^OUT/ and not $var_init =~ /\S/
$self->{"in_out"}{$var_name} and $self->{"in_out"}{$var_name} =~ /^OUT/ and not $var_init =~ /\S/
$self->{"in_out"}{$var_name} and $self->{"in_out"}{$var_name} =~ /^OUT/
MC/DC0%0/4
$var_init =~ /^[=;]\s*NO_INIT\s*;?\s*$/ or $self->{"in_out"}{$var_name} and $self->{"in_out"}{$var_name} =~ /^OUT/ and not $var_init =~ /\S/
$var_init =~ /^[=;]\s*NO_INIT\s*;?\s*$/
$self->{"in_out"}{$var_name}
$self->{"in_out"}{$var_name} =~ /^OUT/
not $var_init =~ /\S/
Truth table0%0/5
A or B and C and not(D)
A= $var_init =~ /^[=;]\s*NO_INIT\s*;?\s*$/B= $self->{"in_out"}{$var_name}C= $self->{"in_out"}{$var_name} =~ /^OUT/D= not $var_init =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | or $self->{in_out}->{$var_name} and $self->{in_out}->{$var_name} =~ /^OUT/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | and $var_init !~ /\S/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if ($printed_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | print ";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | print "\t$var_name;\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | elsif ($var_init =~ /\S/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | $self->output_init( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | type => $var_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | num => $self->{var_num}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | var => $var_name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | init => $var_init, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | printed_name => $printed_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | elsif ($self->{var_num}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | $self->generate_init( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | type => $var_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | num => $self->{var_num}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | var => $var_name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | printed_name => $printed_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | print ";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||