| 1 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Here starts the actual thing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## This is way too messy and uncommented. Still. :( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # DJB August 24 2006 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # begin cleaning up the code so that it all runs under use strict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # DJB August 31 2006 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # moved to use objects for the rule table (ie defvar) in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # hope it's more declarative (since the addition of "::" to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # a statement makes it so much-more meaningful :-) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # How to convert from the old deftbl format to the new, object-based, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # system: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # What used to be, in $PDL::PP::deftbl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # [["Name1"], ["Name2"], $ref_to_sub]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # is now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # PDL::PP::Rule->new("Name1", "Name2", $ref_to_sub) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # where Name1 represents the target of the rule, Name2 the condition, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # and the subroutine reference is the routine called when the rule is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # applied. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # If their is no condition, the argument can be left out of the call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # (unless there is a doc string), so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # [["Name1"], [], $ref_to_sub]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # becomes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # PDL::PP::Rule->new("Name1", $ref_to_sub) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # The target and conditions can also be an array reference, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # [["Name1"], ["Name2","Name3"], $ref_to_sub]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # [["Name1","Name2"], ["Name3"], $ref_to_sub]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # [["Name1","Name2"], ["Name3","Name4"], $ref_to_sub]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # become, respectively | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # PDL::PP::Rule->new("Name1", ["Name2","Name3"], $ref_to_sub) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # PDL::PP::Rule->new(["Name1","Name2"], "Name3", $ref_to_sub) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # PDL::PP::Rule->new(["Name1","Name2"], ["Name3","Name4], $ref_to_sub) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # If the old rule had a document string, this is placed between | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # the condition and the subroutine reference. To make processing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # simpler, if a doc string exists then the condition must also | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # be supplied, even if it is just [] (ie no condition). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # There are specialized rules for common situations. The rules for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # target, condition, and doc arguments hold from the base class (ie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # whether scalar or array values are used, ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # Return a constant: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # PDL::PP::Rule::Returns->new($targets [,$conditions [,$doc]], $value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # is used to return a constant. So | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # [["Name1"], [], sub { "foo" }] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # becomes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # PDL::PP::Rule::Returns->new("Name1", "foo") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # This class is specialized since there are some common return values: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # PDL::PP::Rule::Returns::Zero->new($targets [,$conditions [,$doc]]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # PDL::PP::Rule::Returns::One->new($targets [,$conditions [,$doc]]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # PDL::PP::Rule::Returns::EmptyString->new($targets [,$conditions [,$doc]]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # PDL::PP::Rule::Returns::NULL->new($targets [,$conditions [,$doc]]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # which return 0, 1, "", and "NULL" respectively | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # The InsertName class exists to allow you to return something like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # "foo<routine name>bar" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # The old rules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # [["Foo"], ["Name"], sub { return "_pdl_$_[0]_bar"; }] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # [["Foo"], ["Name","Arg2"], sub { return "_pdl_$_[0]_bar"; }] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # become | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # PDL::PP::Rule::InsertName->new("Foo", '_pdl_${name}_bar') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # PDL::PP::Rule::InsertName->new("Foo", "Arg2", '_pdl_${name}_bar') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # Note that the Name argument is automatically used as a condition, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # it does not need to be supplied, and the return value should be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # given as a single-quoted string and use the $name variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # The Substitute rule replaces dollar-signed macros ($P(), $ISBAD(), etc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # with the low-level C code to perform the macro. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # The Substitute class replaces the dosubst rule. The old rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # [["NewXSCoerceMustSubs"], ["NewXSCoerceMustSub1","NewXSSymTab","Name"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # \&dosubst] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # becomes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # PDL::PP::Rule::Substitute("NewXSCoerceMustSubs", "NewXSCoerceMustSub1") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # PDL::PP::Rule::Substitute->new($target,$condition) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # $target and $condition must be scalars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # Implicit conditions are NewXSSymTab and Name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # The Substitute:Usual class replaces the dousualsubsts rule. The old rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # [["CacheBadFlagInit"], ["CacheBadFlagInitNS","NewXSSymTab","Name"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # \&dousualsubsts], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # becomes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # PDL::PP::Rule::Substitute::Usual->new("CacheBadFlagInit", "CacheBadFlagInitNS") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # PDL::PP::Rule::Substitute::Usual->new($target, $condition) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # $target and $condition must be scalars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # Implicit conditions are NewXSSymTab and Name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # The MakeComp rule replaces the subst_makecomp routine. The old rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # [["MakeCompiledRepr"], ["MakeComp","CompNames","CompObjs"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # sub {subst_makecomp("COMP",@_)}] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # becomes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # PDL::PP::Rule::MakeComp->new("MakeCompiledRepr", ["MakeComp","CompNames","CompObjs"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # "COMP") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # PDL::PP::Rule::MakeComp->new($target,$conditions,$symbol) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # $target and $symbol must be scalars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # Notes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # InsertName could become a subclass of Insert since there are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # a few rules that just insert conditions into a text string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # Substitute, Substitute::Usual, MakeComp classes feel a bit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # ugly. See next point. Also the get_std_childparent method is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # a bit of a hack. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # DJB thinks that the code fragments themselves could be objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # since they should 'know' what needs doing to them (eg the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # substitutions). Not sure whether it would really clarify things. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # To do: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # wrap_vfn could propbably be moved into a class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # move the PDL::PP::Rule and subclasses into their own file? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | package PDL::PP::Rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | require PDL::Core::Dev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | our @CARP_NOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | my $INVALID_OTHERPARS_RE = qr/^(?:magicno|flags|vtable|freeproc|bvalflag|has_badvalue|badvalue|pdls|__datatype)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | ▶ | use overload ("\"\"" => \&PDL::PP::Rule::stringify); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | sub stringify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 205 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringify: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 205 | my $str = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 205 | ▶ | if ("PDL::PP::Rule" eq $str) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 120 | $str = "Rule"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 85 | $str =~ s/PDL::PP::Rule:://; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 205 | $str = "($str) "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | $str .= exists $self->{doc} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 205 | ▶ | $self->{doc} : join(",", @{$self->{targets}}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 205 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # Takes two args: the calling object and the message, but we only care | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # about the message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 619 | ▶ | sub report ($$) { print $_[1] if $::PP_VERBOSE; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
report: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # Very limited error checking. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # Allow scalars for targets and conditions to be optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # At present you have to have a conditions argument if you supply | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # a doc string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # It seems strange to make the subroutine reference an optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # argument but this is being used to transition to a slightly-different | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # object design | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 270 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 270 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 270 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 270 | my $usage = "Usage: PDL::PP::Rule->new(\$targets[,\$conditions[,\$doc],] [,\$ref])\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # handle arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 270 | my $nargs = $#_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 270 | ▶ | die $usage if $nargs < 0 or $nargs > 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$nargs < 0 or $nargs > 3
MC/DC0%0/2
$nargs < 0 or $nargs > 3
$nargs < 0
$nargs > 3
Truth table33%1/3
A or B
A= $nargs < 0B= $nargs > 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 270 | my $targets = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 270 | ▶ | $targets = [$targets] unless ref $targets eq "ARRAY"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 270 | $self->{targets} = $targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 270 | ▶ | if ($#_ != -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 236 | ▶ | if (ref $_[-1] eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 200 | $self->{ref} = pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 236 | my ($conditions,$doc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 236 | ▶ | if (defined $conditions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 234 | ▶ | $conditions = [$conditions] unless ref $conditions eq "ARRAY"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | $conditions = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 236 | $self->{conditions} = $conditions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 236 | ▶ | $self->{doc} = $doc if defined $doc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 270 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # $rule->check_if_targets_exist($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # Returns 1 if any of the targets exist in $pars, 0 otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # A return value of 1 means that the rule should not be applied. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # Not 100% happy with use of report here. Needs re-thinking. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | sub check_if_targets_exist { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 209 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_if_targets_exist: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 209 | my $pars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 209 | my $targets = $self->{targets}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 209 | foreach my $target (@$targets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 226 | ▶ | if (exists $pars->{$target}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 8 | $self->report("--skipping since TARGET $target exists\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 8 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 201 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # $rule->check_if_conditions_exist($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # Returns 1 if all of the required conditions exist in $pars, 0 otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # A return value of 0 means that the rule should not be applied. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # Not 100% happy with use of report here. Needs re-thinking. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | sub check_if_conditions_exist { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 201 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_if_conditions_exist: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 201 | my $pars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 201 | my $conditions = $self->{conditions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 201 | foreach my $condition (@$conditions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # skip if not a required condition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 403 | ▶ | next if substr($condition,0,1) eq "_"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 365 | ▶ | unless (exists $pars->{$condition}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 61 | $self->report("--skipping since CONDITION $condition does not exist\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 61 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 140 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # $rule->is_valid($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # Returns 1 if the rule should be applied (ie no targets already | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # exist in $pars and all the required conditions exist in $pars), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # otherwise 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | sub is_valid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 209 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 209 | my $pars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 209 | ▶ | return 0 if $self->check_if_targets_exist($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 201 | ▶ | return 0 unless $self->check_if_conditions_exist($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 140 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # my @args = $self->extract_args($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # If this method is called we assume that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # $self->check_if_conditions_exist($pars) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # returns 1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | sub extract_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 83 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_args: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 83 | my $pars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 83 | my $conditions = $self->{conditions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 83 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 83 | foreach (@$conditions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # make a copy of each condition so that any changes to it are not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # also made to the original array! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 291 | my $condition = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # Remove any possible underscores (which indicate optional conditions): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 291 | $condition =~ s/^_//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # Note: This will *not* create $pars->{$condition} if it did not already | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # exist: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 291 | push @args, $pars->{$condition}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 83 | return @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # Apply the rule using the supplied $pars hash reference. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | sub apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 146 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 146 | my $pars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | carp "Unable to apply rule $self as there is no subroutine reference!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 146 | ▶ | unless exists $self->{ref}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 146 | my $targets = $self->{targets}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 146 | my $conditions = $self->{conditions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 146 | my $ref = $self->{ref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 146 | $self->report("Applying: $self\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # Is the rule valid? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 146 | ▶ | return unless $self->is_valid($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # Create the argument array for the routine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 98 | my @args = $self->extract_args($pars); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # Run this rule's subroutine: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 98 | my @retval = $self->{ref}(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # Check for any inconsistencies: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 97 | ▶ | confess "Internal error: rule '$self' returned " . (1+$#retval) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | . " items and expected " . (1+$#$targets) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | unless $#retval == $#$targets; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 97 | $self->report("--setting:"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 97 | foreach my $target (@$targets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 109 | $self->report(" $target"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | confess "Cannot have multiple meanings for target $target!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 109 | ▶ | if exists $pars->{$target}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 109 | my $result = shift @retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # The following test suggests that things could/should be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # improved in the code generation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 109 | ▶ | if (defined $result and $result eq 'DO NOT SET!!') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $result and $result eq "DO NOT SET!!"
MC/DC0%0/2
defined $result and $result eq "DO NOT SET!!"
defined $result
$result eq "DO NOT SET!!"
Truth table66%2/3
A and B
A= defined $resultB= $result eq "DO NOT SET!!"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $self->report (" is 'DO NOT SET!!'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 109 | $pars->{$target} = $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 97 | $self->report("\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | package PDL::PP::Rule::Croak; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # Croaks if all of the input variables are defined. Use this to identify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # incompatible arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 2 | our @ISA = qw(PDL::PP::Rule); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | our @CARP_NOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 4 | ▶ | croak('Usage: PDL::PP::Ruel::Croak->new(["incompatible", "arguments"], "Croaking message")') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | unless @_ == 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 4 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 4 | my $self = $class->SUPER::new([], @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 4 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | sub apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 4 | ▶ | my ($self, $pars) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 4 | ▶ | croak($self->{doc}) if $self->is_valid($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | package PDL::PP::Rule::Returns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 2 | our @CARP_NOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | ##use PDL::PP::Rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 2 | our @ISA = qw (PDL::PP::Rule); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # This class does not treat return values of "DO NOT SET!!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # as special. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 50 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 50 | my $value = pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 50 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 50 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 50 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 50 | $self->{"returns.value"} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 50 | my $targets = $self->{targets}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 50 | ▶ | croak "There can only be 1 target for a $self, not " . (1+$#$targets) . "!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | unless $#$targets == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 50 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | sub apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 44 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 44 | my $pars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | carp "Unable to apply rule $self as there is no return value!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 44 | ▶ | unless exists $self->{"returns.value"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 44 | my $target = $self->{targets}->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 44 | $self->report("Applying: $self\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # Is the rule valid? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 44 | ▶ | return unless $self->is_valid($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # Set the value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 28 | $self->report ("--setting: $target\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 28 | $pars->{$target} = $self->{"returns.value"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | package PDL::PP::Rule::Returns::Zero; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | ##use PDL::PP::Rule::Returns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 2 | our @ISA = qw (PDL::PP::Rule::Returns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 6 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 6 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 6 | my $self = $class->SUPER::new(@args,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 6 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | package PDL::PP::Rule::Returns::One; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | ##use PDL::PP::Rule::Returns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 2 | our @ISA = qw (PDL::PP::Rule::Returns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 4 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 4 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 4 | my $self = $class->SUPER::new(@args,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 4 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | package PDL::PP::Rule::Returns::EmptyString; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | ##use PDL::PP::Rule::Returns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 2 | our @ISA = qw (PDL::PP::Rule::Returns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 12 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 12 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 12 | my $self = $class->SUPER::new(@args,""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 12 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 12 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | package PDL::PP::Rule::Returns::NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | ##use PDL::PP::Rule::Returns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 2 | our @ISA = qw (PDL::PP::Rule::Returns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 8 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 8 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 8 | my $self = $class->SUPER::new(@args,"NULL"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 8 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | package PDL::PP::Rule::InsertName; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 2 | our @CARP_NOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | ##use PDL::PP::Rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 2 | our @ISA = qw (PDL::PP::Rule); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # This class does not treat return values of "DO NOT SET!!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # as special. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 16 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 16 | my $value = pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 16 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 16 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 16 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 16 | $self->{"insertname.value"} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # Generate a defaul doc string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 16 | ▶ | unless (exists $self->{doc}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 16 | $self->{doc} = 'Sets ' . $self->{targets}->[0] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | . ' to "' . $value . '"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 16 | my $targets = $self->{targets}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 16 | ▶ | croak "There can only be 1 target for a $self, not " . (1+$#$targets) . "!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | unless $#$targets == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # we add "Name" as the first condition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 16 | my $conditions = $self->{conditions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 16 | unshift @$conditions, "Name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 16 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | sub apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 15 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 15 | my $pars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | carp "Unable to apply rule $self as there is no return value!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 15 | ▶ | unless exists $self->{"insertname.value"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 15 | $self->report("Applying: $self\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | # Is the rule valid? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 15 | ▶ | return unless $self->is_valid($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | # Set the value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 14 | my $target = $self->{targets}->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 14 | my $name = $pars->{Name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 14 | $self->report ("--setting: $target (name=$name)\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 14 | $pars->{$target} = eval "return \"" . $self->{"insertname.value"} . "\";"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # Poor name. This is the old "dosubst" routine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # PDL::PP::Rule->new("NewXSCoerceMustSubs", ["NewXSCoerceMustSub1","NewXSSymTab","Name"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # \&dosubst), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | # PDL::PP::Rule::Substitute->new($target,$condition) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # $target and $condition must be scalars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | # Implicit conditions are NewXSSymTab and Name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | package PDL::PP::Rule::Substitute; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 2 | our @CARP_NOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | ##use PDL::PP::Rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 2 | our @ISA = qw (PDL::PP::Rule); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # Probably want this directly in the apply routine but leave as is for now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | sub dosubst_private { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 16 | ▶ | my ($src,$symtab,$name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dosubst_private: called CC=6 SCAR=18.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 16 | ▶ | my $ret = (ref $src ? $src->[0] : $src); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | my %syms = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 15 | ((ref $src) ? %{$src->[1]} : ()), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 99 | ▶ | PRIV => sub {return "".$symtab->get_symname('_PDL_ThisTrans'). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | "->$_[0]"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 1 | ▶ | CROAK => sub {return "PDL->pdl_barf(\"Error in $name:\" $_[0])"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 1 | ▶ | NAME => sub {return $name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 1 | ▶ | MODULE => sub {return $::PDLMOD}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | SETPDLSTATEBAD => sub { return "$_[0]\->state |= PDL_BADVAL"; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | SETPDLSTATEGOOD => sub { return "$_[0]\->state &= ~PDL_BADVAL"; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 1 | ▶ | ISPDLSTATEBAD => sub { return "(($_[0]\->state & PDL_BADVAL) > 0)"; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | ISPDLSTATEGOOD => sub { return "(($_[0]\->state & PDL_BADVAL) == 0)"; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 5 | ▶ | BADFLAGCACHE => sub { return "badflag_cache"; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | SETREVERSIBLE => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | return "if($_[0]) \$PRIV(flags) |= PDL_ITRANS_REVERSIBLE;\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | " else \$PRIV(flags) &= ~PDL_ITRANS_REVERSIBLE;\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 16 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 16 | ▶ | while( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | $ret =~ s/\$(\w+)\(([^()]*)\)/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | (defined $syms{$1} or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | confess("$1 not defined in '$ret'!")) and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 108 | ▶ | (&{$syms{$1}}($2))/ge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $syms{$1} or confess("$1 not defined in '${ret}'!")
MC/DC0%0/2
defined $syms{$1} or confess("$1 not defined in '${ret}'!")
defined $syms{$1}
confess("$1 not defined in '${ret}'!")
Truth table33%1/3
A or B
A= defined $syms{$1}B= confess("$1 not defined in '${ret}'!")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | ) {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 16 | $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 32 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 32 | ▶ | die "Usage: PDL::PP::Rule::Substitute->new(\$target,\$condition);" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | unless $#_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 32 | my $target = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 32 | my $condition = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 32 | ▶ | die "\$target must be a scalar for PDL::PP::Rule->Substitute" if ref $target; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 32 | ▶ | die "\$condition must be a scalar for PDL::PP::Rule->Substitute" if ref $condition; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 32 | my $self = $class->SUPER::new($target, [$condition, "NewXSSymTab", "Name"], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | \&dosubst_private); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 32 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 32 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | # Poor name. This is the old "dousualsubsts" routine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | # PDL::PP::Rule->new("CacheBadFlagInit", ["CacheBadFlagInitNS","NewXSSymTab","Name"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | # \&dousualsubsts), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | # PDL::PP::Rule::Substitute::Usual->new($target, $condition) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | # $target and $condition must be scalars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | # Implicit conditions are NewXSSymTab and Name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | # Need to think about @std_childparent as it is also used by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | # other bits of code. At the moment provide a class method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # to access the array but there has to be better ways of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | # doing this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | package PDL::PP::Rule::Substitute::Usual; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 2 | our @CARP_NOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | ##use PDL::PP::Rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 2 | our @ISA = qw (PDL::PP::Rule::Substitute); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | # This is a copy of the main one for now. Need a better solution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | my @std_childparent = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | CHILD => sub {return '$PRIV(pdls[1]->'.(join ',',@_).")"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | PARENT => sub {return '$PRIV(pdls[0]->'.(join ',',@_).")"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | CHILD_P => sub {return '$PRIV(pdls[1]->'.(join ',',@_).")"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | PARENT_P => sub {return '$PRIV(pdls[0]->'.(join ',',@_).")"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | CHILD_PTR => sub {return '$PRIV(pdls[1])'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | PARENT_PTR => sub {return '$PRIV(pdls[0])'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | COMP => sub {return '$PRIV('.(join ',',@_).")"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 3 | ▶ | sub get_std_childparent { return @std_childparent; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_std_childparent: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 22 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 22 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 22 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 22 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 22 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | # We modify the arguments from the conditions to include the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # extra information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # We simplify the base-class version since we assume that all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | # conditions are required here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | sub extract_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_args: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 12 | my $pars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | # The conditions are [<code>, NewXSSymTab, Name] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 12 | my $code = $pars->{$self->{conditions}[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 12 | my $symtab = $pars->{$self->{conditions}[1]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 12 | my $name = $pars->{$self->{conditions}[2]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 12 | return ([$code,{@std_childparent}],$symtab,$name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | # Poor name. This is the old "subst_makecomp" routine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | # PDL::PP::Rule->new("MakeCompiledRepr", ["MakeComp","CompNames","CompObjs"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | # sub {subst_makecomp("COMP",@_)}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | # PDL::PP::Rule::MakeComp->new($target,$conditions,$symbol) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | # $target and $symbol must be scalars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | package PDL::PP::Rule::MakeComp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 2 | our @CARP_NOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | ##use PDL::PP::Rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 2 | our @ISA = qw (PDL::PP::Rule); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # This is a copy of the main one for now. Need a better solution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | my @std_redodims = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | ▶ | SETNDIMS => sub {return "PDL->reallocdims(__it,$_[0])"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | SETDIMS => sub {return "PDL->setdims_careful(__it)"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | SETDELTATHREADIDS => sub {return ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | {int __ind; PDL->reallocthreadids($CHILD_PTR(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | $PARENT(nthreadids)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | for(__ind=0; __ind<$PARENT(nthreadids)+1; __ind++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | $CHILD(threadids[__ind]) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | $PARENT(threadids[__ind]) + ('.$_[0].'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 2 | '}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | ##sub get_std_redodims { return @std_redodims; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # Probably want this directly in the apply routine but leave as is for now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | sub subst_makecomp_private { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 3 | ▶ | my($which,$mc,$cn,$co) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subst_makecomp_private: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | return [$mc,{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | # @::std_childparent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | PDL::PP::Rule::Substitute::Usual::get_std_childparent(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | ($cn ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | (('DO'.$which.'DIMS') => sub {return join '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | map{$$co{$_}->need_malloc ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | $$co{$_}->get_malloc('$PRIV('.$_.')') : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 3 | ▶ | ()} @$cn}) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | ($which eq "PRIV" ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | @std_redodims : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 10 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 10 | ▶ | die "Usage: PDL::PP::Rule::MakeComp->new(\$target,\$conditions,\$symbol);" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | unless $#_ == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 10 | my $target = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 10 | my $condition = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 10 | my $symbol = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 10 | ▶ | die "\$target must be a scalar for PDL::PP::Rule->MakeComp" if ref $target; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 10 | ▶ | die "\$symbol must be a scalar for PDL::PP::Rule->MakeComp" if ref $symbol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 10 | my $self = $class->SUPER::new($target, $condition, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | \&subst_makecomp_private); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 10 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 10 | $self->{"makecomp.value"} = $symbol; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 10 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | # We modify the arguments from the conditions to include the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | # extra information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | # We simplify the base-class version since we assume that all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | # conditions are required here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | sub extract_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_args: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 3 | my $pars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | # The conditions are [<symbol>, conditions...] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | # - could use slicing here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 3 | my @args = ($self->{"makecomp.value"}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 3 | foreach my $condition (@{$self->{conditions}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 5 | push @args, $pars->{$condition}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 3 | return @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | package PDL::PP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 2 | our $VERSION = "2.3"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 2 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 2 | ▶ | use PDL::Types ':All'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 2 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 2 | ▶ | use FileHandle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 2 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 2 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 2 | @PDL::PP::EXPORT = qw/pp_addhdr pp_addpm pp_bless pp_def pp_done pp_add_boot | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | pp_add_exported pp_addxs pp_add_isa pp_export_nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | pp_core_importList pp_beginwrap pp_setversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | pp_addbegin pp_boundscheck pp_line_numbers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | pp_deprecate_module/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 2 | $PP::boundscheck = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 2 | $::PP_VERBOSE = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 2 | $PDL::PP::done = 0; # pp_done has not been called yet | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | ▶ | END { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | #you can uncomment this for testing, but this should remain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | #commented in production code. This causes pp_done to be called | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | #even when a .pd file aborts with die(), potentially bypassing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | #problem code when build is re-attempted. Having this commented | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | #means we are a bit more strict: a module must call pp_done in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | #order to have .xs and .pm files written. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | # pp_done() unless $PDL::PP::done; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 2 | our @CARP_NOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | # check for bad value support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 2 | ▶ | use PDL::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 2 | ▶ | my $bvalflag = $PDL::Config{WITH_BADVAL} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$PDL::Config{'WITH_BADVAL'} || 0
MC/DC0%0/1
$PDL::Config{'WITH_BADVAL'} || 0
$PDL::Config{'WITH_BADVAL'}
Truth table50%1/2
A
A= $PDL::Config{'WITH_BADVAL'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 2 | my $ntypes = $#PDL::Types::names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 2 | ▶ | sub nopm { $::PDLPACK eq 'NONE' } # flag that we don't want to generate a PM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nopm: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 2 | ▶ | my ($mod,$modname, $packname, $prefix, $callpack) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | # Allow for users to not specify the packname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 2 | ▶ | ($packname, $prefix, $callpack) = ($modname, $packname, $prefix) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | if ($packname =~ m|/|); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 2 | $::PDLMOD=$modname; $::PDLPACK=$packname; $::PDLPREF=$prefix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 2 | ▶ | $::CALLPACK = defined $callpack ? $callpack : $::PDLMOD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 2 | $::PDLOBJ = "PDL"; # define pp-funcs in this package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 2 | $::PDLXS=""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 2 | $::PDLBEGIN=""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 2 | $::PDLPMROUT=""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 2 | for ('Top','Bot','Middle') { $::PDLPM{$_}="" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 2 | @::PDLPMISA=('PDL::Exporter', 'DynaLoader'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 2 | @::PDL_IFBEGINWRAP = ('',''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 2 | $::PDLVERSIONSET = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 2 | $::PDLMODVERSION = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 2 | $::DOCUMENTED = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 2 | $::PDLCOREIMPORT = ""; #import list from core, defaults to everything, i.e. use Core | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | # could be set to () for importing nothing from core. or qw/ barf / for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | # importing barf only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 2 | @_=("PDL::PP"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 2 | goto &Exporter::import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | # query/set boundschecking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # if on the generated XS code will have optional boundschecking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | # that can be turned on/off at runtime(!) using | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | # __PACKAGE__::set_boundscheck(arg); # arg should be 0/1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | # if off code is speed optimized and no runtime boundschecking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | # can be performed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | # ON by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | sub pp_boundscheck { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | my $ret = $PP::boundscheck; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_boundscheck: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | $PP::boundscheck = $_[0] if $#_ > -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | sub pp_beginwrap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | @::PDL_IFBEGINWRAP = ('BEGIN {','}'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_beginwrap: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | sub pp_setversion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | ▶ | my ($ver) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_setversion: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | $::PDLMODVERSION = '$VERSION'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | $::PDLVERSIONSET = "\$$::PDLPACK\::VERSION = $ver;"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | sub pp_addhdr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | my ($hdr) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_addhdr: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | $::PDLXSC .= $hdr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | sub pp_addpm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 3 | ▶ | my $pm = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_addpm: called CC=4 SCAR=20.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 3 | my $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 3 | ▶ | if (ref $pm) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | my $opt = $pm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | $pm = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | croak "unknown option" unless defined $opt->{At} && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | $opt->{At} =~ /^(Top|Bot|Middle)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $opt->{"At"} and $opt->{"At"} =~ /^(Top|Bot|Middle)$/
MC/DC0%0/2
defined $opt->{"At"} and $opt->{"At"} =~ /^(Top|Bot|Middle)$/
defined $opt->{"At"}
$opt->{"At"} =~ /^(Top|Bot|Middle)$/
Truth table0%0/3
A and B
A= defined $opt->{"At"}B= $opt->{"At"} =~ /^(Top|Bot|Middle)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | $pos = $opt->{At}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 3 | $pos = 'Middle'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 3 | $::PDLPM{$pos} .= "$pm\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | sub pp_add_exported { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | # my ($this,$exp) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 1 | ▶ | my $exp = join ' ', @_; # get rid of this silly $this argument | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_add_exported: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 1 | $::PDLPMROUT .= $exp." "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | sub pp_addbegin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | my ($cmd) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_addbegin: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | if ($cmd =~ /^\s*BOOT\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | pp_beginwrap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | $::PDLBEGIN .= $cmd."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | # Sub to call to export nothing (i.e. for building OO package/object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | sub pp_export_nothing { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | ▶ | $::PDLPMROUT = ' '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_export_nothing: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | sub pp_add_isa { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | ▶ | push @::PDLPMISA,@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_add_isa: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | sub pp_add_boot { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 1 | ▶ | my ($boot) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_add_boot: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 1 | $::PDLXSBOOT .= $boot." "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | sub pp_bless{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | ▶ | my($new_package)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_bless: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | $::PDLOBJ = $new_package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | # sub to call to set the import list from core on the 'Use Core' line in the .pm file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | # set to '()' to not import anything from Core, or 'qw/ barf /' to import barf. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | sub pp_core_importList{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | ▶ | $::PDLCOREIMPORT = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_core_importList: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | sub printxs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 1 | ▶ | shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
printxs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 1 | $::PDLXS .= join'',@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | sub pp_addxs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | ▶ | PDL::PP->printxs("\nMODULE = $::PDLMOD PACKAGE = $::CALLPACK\n\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_addxs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | "\nMODULE = $::PDLMOD PACKAGE = $::PDLOBJ\n\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | # inserts #line directives into source text. Use like this: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | # ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | # FirstKey => ..., | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | # Code => pp_line_numbers (__LINE__, $a . $b . $c), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | # OtherKey => ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | sub pp_line_numbers ($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 1 | ▶ | my ($line, $string) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_line_numbers: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | # The line needs to be incremented by one for the bookkeeping to work | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 1 | $line++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | # Get the source filename using caller() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 1 | my (undef, $filename) = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | # Escape backslashes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 1 | $filename =~ s/\\/\\\\/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 1 | my @to_return = "#line $line \"$filename\""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | # Look for threadloops and loops and add # line directives | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 1 | foreach (split (/(\n)/, $string)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | # Always add the current line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 21 | push @to_return, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | # If we need to add a # line directive, do so before incrementing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 21 | ▶ | push (@to_return, "\n#line $line \"$filename\"") if (/%\{/ or /%}/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
/%\{/ or /%}/
MC/DC100%2/2
/%\{/ or /%}/
/%\{/
/%}/
Truth table100%3/3
A or B
A= /%\{/B= /%}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 21 | ▶ | $line++ if /\n/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 1 | return join('', @to_return); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | sub printxsc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 1 | ▶ | shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
printxsc: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 1 | $::PDLXSC .= join '',@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | sub pp_done { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 1 | ▶ | return if $PDL::PP::done; # do only once! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_done: called CC=9 SCAR=23.7
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 1 | $PDL::PP::done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 1 | ▶ | $::FUNCSPOD = $::DOCUMENTED ? "\n\n=head1 FUNCTIONS\n\n\n\n=cut\n\n\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 1 | ▶ | print "DONE!\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 1 | ▶ | print "Inline running PDL::PP version $PDL::PP::VERSION...\n" if nopm(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 1 | ▶ | (my $fh = FileHandle->new(">$::PDLPREF.xs")) or die "Couldn't open xs file\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 1 | my $pdl_boot = PDL::Core::Dev::PDL_BOOT('PDL', $::PDLMOD); # don't hardcode in more than one place | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 1 | $fh->print(qq% | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | /* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | * THIS FILE WAS GENERATED BY PDL::PP! Do not modify! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | #define PDL_COMMENT(comment) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | PDL_COMMENT("This preprocessor symbol is used to add commentary in the PDL ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | PDL_COMMENT("autogenerated code. Normally, one would use typical C-style ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | PDL_COMMENT("multiline comments (i.e. /* comment */). However, because such ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | PDL_COMMENT("comments do not nest, it's not possible for PDL::PP users to ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | PDL_COMMENT("comment-out sections of code using multiline comments, as is ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | PDL_COMMENT("often the practice when debugging, for example. So, when you ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | PDL_COMMENT("see something like this: ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | PDL_COMMENT(" ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | PDL_COMMENT("Memory access") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | PDL_COMMENT(" ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | PDL_COMMENT("just think of it as a C multiline comment like: ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | PDL_COMMENT(" ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | PDL_COMMENT(" /* Memory access */ ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | #include "EXTERN.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | #include "perl.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | #include "XSUB.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | #include "pdl.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | #include "pdlcore.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | static Core* PDL; PDL_COMMENT("Structure hold core C functions") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | static int __pdl_debugging = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | static int __pdl_boundscheck = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | static SV* CoreSV; PDL_COMMENT("Gets pointer to perl var holding core structure") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | #if ! $PP::boundscheck | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | # define PP_INDTERM(max, at) at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | #else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | # define PP_INDTERM(max, at) (__pdl_boundscheck? PDL->safe_indterm(max,at, __FILE__, __LINE__) : at) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | $::PDLXSC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | MODULE = $::PDLMOD PACKAGE = $::PDLMOD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | PROTOTYPES: ENABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | set_debugging(i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | int i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | CODE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | RETVAL = __pdl_debugging; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | __pdl_debugging = i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | OUTPUT: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | RETVAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | set_boundscheck(i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | int i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | CODE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | if (! $PP::boundscheck) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | warn("Bounds checking is disabled for $::PDLMOD"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | RETVAL = __pdl_boundscheck; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | __pdl_boundscheck = i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | OUTPUT: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | RETVAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | MODULE = $::PDLMOD PACKAGE = $::PDLOBJ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | $::PDLXS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | BOOT: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | PDL_COMMENT("Get pointer to structure of core shared C routines") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | PDL_COMMENT("make sure PDL::Core is loaded") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | $pdl_boot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | $::PDLXSBOOT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | %); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 1 | ▶ | unless (nopm) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 1 | $::PDLPMISA = "'".join("','",@::PDLPMISA)."'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 1 | ▶ | $::PDLBEGIN = "BEGIN {\n$::PDLBEGIN\n}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | unless $::PDLBEGIN =~ /^\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 1 | ▶ | ($fh = FileHandle->new(">$::PDLPREF.pm")) or die "Couldn't open pm file\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 1 | $fh->print(qq% | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | # GENERATED WITH PDL::PP! Don't modify! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | package $::PDLPACK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | \@EXPORT_OK = qw( $::PDLPMROUT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | \%EXPORT_TAGS = (Func=>[\@EXPORT_OK]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | use PDL::Core$::PDLCOREIMPORT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | use PDL::Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | use DynaLoader; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | $::PDL_IFBEGINWRAP[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | $::PDLVERSIONSET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | \@ISA = ( $::PDLPMISA ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | push \@PDL::Core::PP, __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | bootstrap $::PDLMOD $::PDLMODVERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | $::PDL_IFBEGINWRAP[-1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | $::PDLBEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | $::PDLPM{Top} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | $::FUNCSPOD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | $::PDLPM{Middle}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | $::PDLPM{Bot} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | # Exit with OK status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | %); # end of print | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | } # unless (nopm) {... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | } # end pp_done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | sub pp_def { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 2 | ▶ | my($name,%obj) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_def: called CC=11 SCAR=31.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 2 | ▶ | print "*** Entering pp_def for $name\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | # See if the 'name' is multiline, in which case we extract the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | # name and add the FullDoc field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 2 | ▶ | if ($name =~ /\n/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | my $fulldoc = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | # See if the very first thing is a word. That is going to be the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | # name of the function under consideration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | ▶ | if ($fulldoc =~ s/^(\w+)//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | $name = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | elsif ($fulldoc =~ /=head2 (\w+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | $name = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | croak('Unable to extract name'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | $obj{FullDoc} = $fulldoc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 2 | $obj{Name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 2 | translate(\%obj,$PDL::PP::deftbl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | print "Output of translate for $name:\n" . Dumper(\%obj) . "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 1 | ▶ | if exists $obj{Dump} and $obj{Dump} and $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $obj{"Dump"} and $obj{"Dump"} and $main::PP_VERBOSE
exists $obj{"Dump"} and $obj{"Dump"}
MC/DC0%0/3
exists $obj{"Dump"} and $obj{"Dump"} and $main::PP_VERBOSE
exists $obj{"Dump"}
$obj{"Dump"}
$main::PP_VERBOSE
Truth table25%1/4
A and B and C
A= exists $obj{"Dump"}B= $obj{"Dump"}C= $main::PP_VERBOSE
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | croak("ERROR: No FreeFunc for pp_def=$name!\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 1 | ▶ | unless exists $obj{FreeFunc}; # and $obj{FreeFunc}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 1 | PDL::PP->printxsc(join "\n\n",@obj{'StructDecl','RedoDimsFunc', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 'CopyFunc', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 'ReadDataFunc','WriteBackDataFunc', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 'FreeFunc', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 'FooFunc', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 'VTableDef','NewXSInPrelude', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 1 | PDL::PP->printxs($obj{NewXSCode}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 1 | pp_add_boot($obj{XSBootCode} . $obj{BootSetNewXS}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 1 | PDL::PP->pp_add_exported($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 1 | ▶ | PDL::PP::pp_addpm("\n".$obj{PdlDoc}."\n") if $obj{PdlDoc}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 1 | PDL::PP::pp_addpm($obj{PMCode}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 1 | PDL::PP::pp_addpm($obj{PMFunc}."\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 1 | ▶ | print "*** Leaving pp_def for $name\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | # marks this module as deprecated. This handles the user warnings, and adds a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | # notice into the documentation. Can take a {infavor => "newmodule"} option | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | sub pp_deprecate_module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | ▶ | my $options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp_deprecate_module: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | ▶ | if( ref $_[0] eq 'HASH' ) { $options = shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | else { $options = { @_ }; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | my $infavor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | ▶ | if( $options && ref $options eq 'HASH' && $options->{infavor} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$options and ref $options eq "HASH" and $options->{"infavor"}
$options and ref $options eq "HASH"
MC/DC0%0/3
$options and ref $options eq "HASH" and $options->{"infavor"}
$options
ref $options eq "HASH"
$options->{"infavor"}
Truth table0%0/4
A and B and C
A= $optionsB= ref $options eq "HASH"C= $options->{"infavor"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | $infavor = $options->{infavor}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | my $mod = $::PDLMOD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | my $envvar = 'PDL_SUPPRESS_DEPRECATION_WARNING__' . uc $mod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | $envvar =~ s/::/_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | my $warning_main = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | "$mod is deprecated."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | ▶ | $warning_main .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | " Please use $infavor instead." if $infavor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | my $warning_suppression_runtime = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | "This module will be removed in the future; please update your code.\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | "Set the environment variable $envvar\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | "to suppress this warning\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | my $warning_suppression_pod = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | "A warning will be generated at runtime upon a C<use> of this module\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | "This warning can be suppressed by setting the $envvar\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | "environment variable\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | my $deprecation_notice = <<EOF ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | XXX=head1 DEPRECATION NOTICE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | $warning_main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | $warning_suppression_pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | XXX=cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | $deprecation_notice =~ s/^XXX=/=/gms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | pp_addpm( {At => 'Top'}, $deprecation_notice ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | pp_addpm {At => 'Top'}, <<EOF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | warn \"$warning_main\n$warning_suppression_runtime\" unless \$ENV{$envvar}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | # Worst memleaks: not freeing things at redodims or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | # final free time (thread, dimmed things). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | ▶ | $SIG{__DIE__} = sub {print Carp::longmess(@_); die;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 2 | ▶ | if $::PP_VERBOSE; # seems to give us trouble with 5.6.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 2 | ▶ | use PDL::PP::Signature; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 2 | ▶ | use PDL::PP::Dims; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 2 | ▶ | use PDL::PP::CType; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 2 | ▶ | use PDL::PP::XS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 2 | ▶ | use PDL::PP::SymTab; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 2 | ▶ | use PDL::PP::PDLCode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 2 | $|=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | # This is ripped from xsubpp to ease the parsing of the typemap. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 2 | our $proto_re = "[" . quotemeta('\$%&*@;[]') . "]" ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | sub ValidProtoString ($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | ▶ | my($string) = @_ ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ValidProtoString: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | ▶ | if ( $string =~ /^$proto_re+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | return $string ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | return 0 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | sub C_string ($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | ▶ | my($string) = @_ ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
C_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | $string =~ s[\\][\\\\]g ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | $string ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | sub TrimWhitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | ▶ | $_[0] =~ s/^\s+|\s+$//go ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TrimWhitespace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | sub TidyType | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 0 | ▶ | local ($_) = @_ ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TidyType: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | # rationalise any '*' by joining them into bunches and removing whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | s#\s*(\*+)\s*#$1#g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | s#(\*+)# $1 #g ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | # change multiple whitespace into a single space | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | s/\s+/ /g ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | # trim leading & trailing whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | TrimWhitespace($_) ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | $_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | # Typemap handling in PP. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | # This subroutine does limited input typemap conversion. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | # Given a variable name (to set), its type, and the source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | # for the variable, returns the correct input typemap entry. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | # Original version: D. Hunt 4/13/00 - Current version J. Brinchmann (06/05/05) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | # This is an extended typemap handler from the one earlier written by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | # Doug Hunt. It should work exactly as the older version, but with extensions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | # Instead of handling a few special cases explicitly we now use Perl's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | # built-in typemap handling using code taken straight from xsubpp. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | # I have infact kept the old part of the code here because I belive any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | # subsequent hackers might find it very helpful to refer to this code to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | # understand what the following does. So here goes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | # ------------ OLD TYPEMAP PARSING: ------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | # # Note that I now just look at the basetype. I don't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | # # test whether it is a pointer to the base type or not. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | # # This is done because it is simpler and I know that the otherpars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | # # belong to a restricted set of types. I know a char will really | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | # # be a char *, for example. I also know that an SV will be an SV *. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | # # yes, but how about catching syntax errors in OtherPars (CS)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | # # shouldn't we really parse the perl typemap (we can steal the code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | # # from xsubpp)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | # my $OLD_PARSING=0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | # if ($OLD_PARSING) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | # my %typemap = (char => "(char *)SvPV($arg,PL_na)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | # short => "(short)SvIV($arg)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | # int => "(int)SvIV($arg)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | # long => "(long)SvIV($arg)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | # double => "(double)SvNV($arg)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | # float => "(float)SvNV($arg)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | # SV => "$arg", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | # ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | # my $basetype = $type->{Base}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | # $basetype =~ s/\s+//g; # get rid of whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | # die "Cannot find $basetype in my (small) typemap" unless exists($typemap{$basetype}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | # return ($typemap{$basetype}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | #--------- END OF THE OLD CODE --------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | # The code loads the typemap from the Perl typemap using the loading logic of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | # xsubpp. Do note that I made the assumption that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | # $Config{}installprivlib}/ExtUtils was the right root directory for the search. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | # This could break on some systems? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | # Also I do _not_ parse the Typemap argument from ExtUtils::MakeMaker because I don't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | # know how to catch it here! This would be good to fix! It does look for a file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | # called typemap in the current directory however. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | # The parsing of the typemap is mechanical and taken straight from xsubpp and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | # the resulting hash lookup is then used to convert the input type to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | # necessary outputs (as seen in the old code above) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | # JB 06/05/05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | sub typemap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | ▶ | my $oname = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
typemap: not called CC=20 SCAR=60.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 0 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | # Modification to parse Perl's typemap here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | # The default search path for the typemap taken from xsubpp. It seems it is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | # necessary to prepend the installprivlib/ExtUtils directory to find the typemap. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | # It is not clear to me how this is to be done. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | my ($typemap, $mode, $junk, $current, %input_expr, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | %proto_letter, %output_expr, %type_kind); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | # according to MM_Unix 'privlibexp' is the right directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | # seems to work even on OS X (where installprivlib breaks things) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | # if this does not work portably we should split out the typemap finding code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | # and make it as complex as necessary + save the typemap location | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | # in the PDL::Config hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 0 | my $_rootdir = $Config{privlibexp}.'/ExtUtils/'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | # print "_rootdir set to '$_rootdir'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | # First the system typemaps.. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 0 | my @tm = ($_rootdir.'../../../../lib/ExtUtils/typemap', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | $_rootdir.'../../../lib/ExtUtils/typemap', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | $_rootdir.'../../lib/ExtUtils/typemap', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | $_rootdir.'../../../typemap', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | $_rootdir.'../../typemap', $_rootdir.'../typemap', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | $_rootdir.'typemap'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | # Finally tag onto the end, the current directory typemap. Ideally we should here pick | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | # up the TYPEMAPS flag from ExtUtils::MakeMaker, but a) I don't know how and b) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | # it is only a slight inconvenience hopefully! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | # Note that the OUTPUT typemap is unlikely to be of use here, but I have kept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | # the source code from xsubpp for tidiness. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | push @tm, 'typemap'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | my $foundtm = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | foreach $typemap (@tm) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | ▶ | next unless -f $typemap ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | # skip directories, binary files etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | ▶ | warn("Warning: ignoring non-text typemap file '$typemap'\n"), next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | unless -T $typemap ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | $foundtm = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | ▶ | open(TYPEMAP, $typemap) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | or warn ("Warning: could not open typemap file '$typemap': $!\n"), next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | $mode = 'Typemap'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | $junk = "" ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | $current = \$junk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | ▶ | while (<TYPEMAP>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | ▶ | next if /^\s*#/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | my $line_no = $. + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | ▶ | if (/^INPUT\s*$/) { $mode = 'Input'; $current = \$junk; next; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | ▶ | if (/^OUTPUT\s*$/) { $mode = 'Output'; $current = \$junk; next; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 0 | ▶ | if (/^TYPEMAP\s*$/) { $mode = 'Typemap'; $current = \$junk; next; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | ▶ | if ($mode eq 'Typemap') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | my $line = $_ ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 0 | TrimWhitespace($_) ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | # skip blank lines and comment lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 0 | ▶ | next if /^$/ or /^#/ ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
/^$/ or /^#/
MC/DC0%0/2
/^$/ or /^#/
/^$/
/^#/
Truth table0%0/3
A or B
A= /^$/B= /^#/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | ▶ | my($t_type,$kind, $proto) = /^\s*(.*?\S)\s+(\S+)\s*($proto_re*)\s*$/ or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | warn("Warning: File '$typemap' Line $. '$line' TYPEMAP entry needs 2 or 3 columns\n"), next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | $t_type = TidyType($t_type) ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | $type_kind{$t_type} = $kind ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | # prototype defaults to '$' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | ▶ | $proto = "\$" unless $proto ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | ▶ | warn("Warning: File '$typemap' Line $. '$line' Invalid prototype '$proto'\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | unless ValidProtoString($proto) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | $proto_letter{$t_type} = C_string($proto) ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | elsif (/^\s/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 0 | $$current .= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | elsif ($mode eq 'Input') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 0 | s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 0 | $input_expr{$_} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | $current = \$input_expr{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 0 | s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 0 | $output_expr{$_} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 0 | $current = \$output_expr{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | close(TYPEMAP); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 0 | ▶ | carp "**CRITICAL** PP found no typemap in $_rootdir/typemap; this will cause problems..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | unless $foundtm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | # Do checks... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | # First reconstruct the type declaration to look up in type_kind | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 0 | my $full_type=TidyType($type->get_decl('')); # Skip the variable name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | ▶ | die "The type =$full_type= does not have a typemap entry!\n" unless exists($type_kind{$full_type}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 0 | my $typemap_kind = $type_kind{$full_type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | # Look up the conversion from the INPUT typemap. Note that we need to do some | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | # massaging of this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 0 | my $input = $input_expr{$typemap_kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | # Remove all before =: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 0 | $input =~ s/^(.*?)=\s*//; # This should not be very expensive | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | # Replace $arg with $arg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | $input =~ s/\$arg/$arg/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | # And type with $full_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | $input =~ s/\$type/$full_type/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | return ($input); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | sub identity2priv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | ▶ | return ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
identity2priv: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | int i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | $SETNDIMS($PARENT(ndims)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | for(i=0; i<$CHILD(ndims); i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | $CHILD(dims[i]) = $PARENT(dims[i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | $SETDIMS(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | $SETDELTATHREADIDS(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | sub pdimexpr2priv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 0 | ▶ | my($pdimexpr,$hdr,$dimcheck) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pdimexpr2priv: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 0 | $pdimexpr =~ s/\$CDIM\b/i/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 0 | return ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | int i,cor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | '.$dimcheck.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | $SETNDIMS($PARENT(ndims)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | $DOPRIVDIMS(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | $PRIV(offs) = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | for(i=0; i<$CHILD(ndims); i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | cor = '.$pdimexpr.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | $CHILD(dims[i]) = $PARENT(dims[cor]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | $PRIV(incs[i]) = $PARENT(dimincs[cor]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | $SETDIMS(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | $SETDELTATHREADIDS(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | # something to do with copying values between parent and children | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | # we can NOT assume that PARENT and CHILD have the same type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | # hence the version for bad code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | # NOTE: we use the same code for 'good' and 'bad' cases - it's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | # just that when we use it for 'bad' data, we have to change the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | # definition of the EQUIVCPOFFS macro - see the Code rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | sub equivcpoffscode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | 0 | ▶ | 'PDL_Indx i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
equivcpoffscode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | for(i=0; i<$CHILD_P(nvals); i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | $EQUIVCPOFFS(i,i); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | }'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | } # sub: equivcpoffscode() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | # Pars -> ParNames, Parobjs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | # XXX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | # - the need for BadFlag is due to hacked get_xsdatapdecl() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | # in PP/PdlParObj and because the PdlParObjs are created by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | # PDL::PP::Signature (Doug Burke 07/08/00) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | sub Pars_nft { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 2 | ▶ | my($str,$badflag) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Pars_nft: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 2 | my $sig = PDL::PP::Signature->new($str,$badflag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 2 | return ($sig->names,$sig->objs,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | # ParNames,Parobjs -> DimObjs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | sub ParObjs_DimObjs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 2 | ▶ | my($pnames,$pobjs) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ParObjs_DimObjs: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 2 | my ($dimobjs) = PDL::PP::PdlDimsObj->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | 2 | for(@$pnames) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | 2 | $pobjs->{$_}->add_inds($dimobjs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 2 | return ($dimobjs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | # Eliminate whitespace entries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 3 | ▶ | sub nospacesplit {map {/^\s*$/?():$_} split $_[0],$_[1]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nospacesplit: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | sub OtherPars_nft { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 3 | ▶ | my($otherpars,$dimobjs) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
OtherPars_nft: called CC=7 SCAR=26.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 3 | my(@names,%types,$type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | # support 'int ndim => n;' syntax | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 3 | for (nospacesplit ';',$otherpars) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 3 | ▶ | if (/^\s*([^=]+)\s*=>\s*(\S+)\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | my ($ctype,$dim) = ($1,$2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 0 | $ctype =~ s/(\S+)\s+$/$1/; # get rid of trailing ws | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | 0 | ▶ | print "OtherPars: setting dim '$dim' from '$ctype'\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 0 | $type = C::Type->new(undef,$ctype); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | croak "can't set unknown dimension" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | 0 | ▶ | unless defined($dimobjs->{$dim}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 0 | $dimobjs->{$dim}->set_from($type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | } elsif(/^\s*pdl\s+\*\s*(\w+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | # It is a piddle -> make it a controlling one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 0 | die("Not supported yet"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 3 | $type = C::Type->new(undef,$_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 3 | my $name = $type->protoname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 3 | ▶ | if ($name =~ /$INVALID_OTHERPARS_RE/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 0 | croak "Invalid OtherPars name: $name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 3 | push @names,$name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 3 | $types{$name} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 3 | return (\@names,\%types); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | sub NXArgs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 2 | ▶ | my($parnames,$parobjs,$onames,$oobjs) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NXArgs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | 2 | my $pdltype = C::Type->new(undef,"pdl *__foo__"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | my $nxargs = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 2 | ( map {[$_,$pdltype]} @$parnames ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 2 | ( map {[$_,$oobjs->{$_}]} @$onames ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 2 | return $nxargs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | # XXX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | # - the need for BadFlag is due to hacked get_xsdatapdecl() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | # in PP/PdlParObj and because the PdlParObjs are created by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | # PDL::PP::Signature (Doug Burke 07/08/00) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | sub NewParentChildPars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 0 | ▶ | my($p2child,$name,$badflag) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NewParentChildPars: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | 0 | return (Pars_nft("PARENT(); [oca]CHILD();",$badflag),0,"${name}_NN"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | # XXX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | # - the need for BadFlag is due to hacked get_xsdatapdecl() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | # in PP/PdlParObj and because the PdlParObjs are created by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | # PDL::PP::Signature (Doug Burke 07/08/00) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | # however, it looks like this isn't being used anymore, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | # so commenting out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | #sub ParentChildPars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | # my($p2child,$name,$badflag) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | # return (Pars_nft("PARENT(); [oca]CHILD();",$badflag),0,"${name}_XX", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | # " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | # *$name = \\&PDL::$name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | # sub PDL::$name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | # my \$this = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | # my \$foo=\$this->null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | # PDL::${name}_XX(\$this,\$foo,\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | # \$foo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | # "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | sub mkstruct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 1 | ▶ | my($pnames,$pobjs,$comp,$priv,$name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkstruct: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 1 | my $npdls = $#$pnames+1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 1 | my $decl = qq{typedef struct $name { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | PDL_TRANS_START($npdls); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | $priv | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | $comp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | char __ddone; PDL_COMMENT("Dims done") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | } $name;}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 1 | return $decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | sub def_vtable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 1 | ▶ | my($vname,$sname,$rdname,$rfname,$wfname,$cpfname,$ffname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
def_vtable: called CC=5 SCAR=17.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | $pnames,$pobjs,$affine_ok,$foofname) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 1 | my $nparents = 0 + grep {! $pobjs->{$_}->{FlagW}} @$pnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 1 | ▶ | my $aff = ($affine_ok ? "PDL_TPDL_VAFFINE_OK" : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 1 | my $npdls = scalar @$pnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | 1 | my $join_flags = join",",map {$pobjs->{$pnames->[$_]}->{FlagPhys} ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 1 | ▶ | 0 : $aff} 0..$npdls-1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 1 | ▶ | if($Config{cc} eq 'cl') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | ▶ | $join_flags = '""' if $join_flags eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 1 | return "static char ${vname}_flags[] = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | { ". $join_flags . "}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | pdl_transvtable $vname = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 0,0, $nparents, $npdls, ${vname}_flags, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | $rdname, $rfname, $wfname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | $ffname,NULL,NULL,$cpfname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | sizeof($sname),\"$vname\" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | };"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | sub sort_pnobjs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | 2 | ▶ | my($pnames,$pobjs) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_pnobjs: called CC=6 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | 2 | my (@nn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 2 | ▶ | for(@$pnames) { push ( @nn, $_ ) unless $pobjs->{$_}{FlagW}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 2 | ▶ | for(@$pnames) { push ( @nn, $_ ) if $pobjs->{$_}{FlagW}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 2 | my $no = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 2 | for(@nn) { $pobjs->{$_}{Number} = $no++; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 2 | return (\@nn,$pobjs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | # XXX __privtrans explicit :( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | sub wrap_vfn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | 4 | ▶ | my($code,$hdrinfo,$rout,$p2child,$name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wrap_vfn: called CC=5 SCAR=18.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | 4 | ▶ | my $type = ($name eq "copy" ? "pdl_trans *" : "void"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 4 | my $sname = $hdrinfo->{StructName}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 4 | ▶ | my $oargs = ($name eq "foo" ? ",int i1,int i2,int i3" : ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | # print "$rout\_$name: $p2child\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 4 | my $p2decl = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | # Put p2child in simple boolean context rather than strict numerical equality | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 4 | ▶ | if ( $p2child ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | $p2decl = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | "pdl *__it = ((pdl_trans_affine *)(__tr))->pdls[1]; pdl *__parent = __tr->pdls[0];"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | ▶ | if ( $name eq "redodims" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | 0 | $p2decl .= ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | if (__parent->hdrsv && (__parent->state & PDL_HDRCPY)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | PDL_COMMENT("call the perl routine _hdr_copy.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | int count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | dSP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | ENTER ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | SAVETMPS ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | PUSHMARK(SP) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | XPUSHs( sv_mortalcopy((SV*)__parent->hdrsv) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | PUTBACK ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | count = call_pv("PDL::_hdr_copy",G_SCALAR); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | SPAGAIN ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | if(count != 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | croak("PDL::_hdr_copy didn\'t return a single value - please report this bug (B)."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | { PDL_COMMENT("convenience block for tmp var") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | SV *tmp = (SV *) POPs ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | __it->hdrsv = (void*) tmp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | if(tmp != &PL_sv_undef ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | (void)SvREFCNT_inc(tmp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | __it->state |= PDL_HDRCPY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | FREETMPS ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | LEAVE ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | } # if: $p2child == 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | qq|$type $rout(pdl_trans *__tr $oargs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | int __dim; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | $sname *__privtrans = ($sname *) __tr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | $p2decl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | $code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | 4 | |; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | } # sub: wrap_vfn() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | sub makesettrans { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 2 | ▶ | my($pnames,$pobjs,$symtab) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makesettrans: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | 2 | my $trans = $symtab->get_symname('_PDL_ThisTrans'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 2 | my $no=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | return (join '',map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 2 | "$trans->pdls[".($no++)."] = $_;\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | } @$pnames). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | "PDL->make_trans_mutual((pdl_trans *)$trans);\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | sub CopyOtherPars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 1 | ▶ | my($onames,$otypes,$symtab) = @_; my $repr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CopyOtherPars: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | 1 | my $sname = $symtab->get_symname('_PDL_ThisTrans'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | 1 | for(@$onames) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | $repr .= $otypes->{$_}->get_copy("$_","$sname->$_"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 1 | return $repr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | sub mkxscat { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 0 | ▶ | my($glb,$xs_c_headers,$hdr,@bits) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkxscat: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 0 | my($boot,$prelude,$str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 0 | ▶ | if($glb) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | 0 | $prelude = join '' => ($xs_c_headers->[0], @bits, $xs_c_headers->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 0 | $boot = $xs_c_headers->[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 0 | $str = "$hdr\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 0 | my $xscode = join '' => @bits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 0 | $str = "$hdr CODE:\n { $xscode XSRETURN(0);\n}\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | 0 | $str =~ s/(\s*\n)+/\n/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | 0 | ($str,$boot,$prelude) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | sub mkVarArgsxscat { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | 1 | ▶ | my($glb,$xs_c_headers,$hdr,@bits) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkVarArgsxscat: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | 1 | my($boot,$prelude,$str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 1 | ▶ | if($glb) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | $prelude = join '' => ($xs_c_headers->[0], @bits, $xs_c_headers->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | 0 | $boot = $xs_c_headers->[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | $str = "$hdr\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | 1 | my $xscode = join '' => @bits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 1 | $str = "$hdr \n { $xscode \n}\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | 1 | $str =~ s/(\s*\n)+/\n/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | 1 | ($str,$boot,$prelude) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | sub MakeNows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | 2 | ▶ | my($pnames, $symtab) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
MakeNows: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | 2 | my $str = "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | 2 | for(@$pnames) { $str .= "$_ = PDL->make_now($_);\n"; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | 2 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | 2 | ▶ | sub Sym2Loc { return $_[0]->decl_locals(); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Sym2Loc: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | sub MkPrivStructInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 2 | ▶ | my( $symtab, $vtable, $affflag, $nopdlthread ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
MkPrivStructInit: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | 2 | my $sname = $symtab->get_symname('_PDL_ThisTrans'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | 2 | my $ci = ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 2 | ▶ | "\n${ci}$sname = malloc(sizeof(*$sname));\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | ($nopdlthread ? "" : "${ci}PDL_THR_CLRMAGIC(&$sname->__pdlthread);\n") . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | "${ci}PDL_TR_SETMAGIC($sname);\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | "${ci}$sname->flags = $affflag;\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | "${ci}$sname->__ddone = 0;\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | "${ci}$sname->vtable = &$vtable;\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | "${ci}$sname->freeproc = PDL->trans_mallocfreeproc;\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | } # sub: MkPrivStructInit() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | sub MkDefSyms { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | 2 | ▶ | return SymTab->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
MkDefSyms: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | _PDL_ThisTrans => ["__privtrans",C::Type->new(undef,"$_[0] *foo")], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | sub AddArgsyms { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 2 | ▶ | my($symtab,$args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AddArgsyms: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | $symtab->add_params( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 2 | map {($_->[0],$_->[0])} @$args | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | 2 | return $symtab; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | sub indent($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 4 | ▶ | my ($text,$ind) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indent: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 4 | $text =~ s/^(.*)$/$ind$1/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 4 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | # This subroutine generates the XS code needed to call the perl 'initialize' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | # routine in order to create new output PDLs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | sub callPerlInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | 4 | ▶ | my $names = shift; # names of variables to initialize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
callPerlInit: called CC=4 SCAR=17.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | 4 | my $ci = shift; # current indenting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | 4 | ▶ | my $callcopy = $#_ > -1 ? shift : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 4 | my $ret = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 4 | foreach my $name (@$names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | ▶ | unless ($callcopy) { $ret .= << "EOC"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | if (strcmp(objname,"PDL") == 0) { PDL_COMMENT("shortcut if just PDL") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | $name\_SV = sv_newmortal(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | $name = PDL->null(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | PDL->SetSV_PDL($name\_SV,$name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | if (bless_stash) $name\_SV = sv_bless($name\_SV, bless_stash); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | PUSHMARK(SP); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | XPUSHs(sv_2mortal(newSVpv(objname, 0))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | PUTBACK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | perl_call_method(\"initialize\", G_SCALAR); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | SPAGAIN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | $name\_SV = POPs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | PUTBACK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | $name = PDL->SvPDLV($name\_SV); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | EOC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | 0 | else { $ret .= << "EOD" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | if (strcmp(objname,"PDL") == 0) { PDL_COMMENT("shortcut if just PDL") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | $name\_SV = sv_newmortal(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | $name = PDL->null(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | PDL->SetSV_PDL($name\_SV,$name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | if (bless_stash) $name\_SV = sv_bless($name\_SV, bless_stash); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | /* XXX should these commented lines be removed? See also a 8 lines down */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | /* warn("possibly relying on deprecated automatic copy call in derived class\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | warn("please modify your initialize method to avoid future problems\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | PUSHMARK(SP); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | XPUSHs(parent); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | PUTBACK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | perl_call_method(\"copy\", G_SCALAR); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | /* perl_call_method(\"initialize\", G_SCALAR); */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | SPAGAIN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | $name\_SV = POPs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | PUTBACK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | $name = PDL->SvPDLV($name\_SV); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | } # doreach: $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | 4 | return indent($ret,$ci); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | } #sub callPerlInit() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | # This subroutine is called when no 'otherpars' exist. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | # This writes an XS header which handles variable argument lists, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | # thus avoiding the perl layer in calling the routine. D. Hunt 4/11/00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | # The use of 'DO NOT SET!!' looks ugly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | # Removing useless use of hasp2child in this function. DCM Sept 12, 2011 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | sub VarArgsXSHdr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | 2 | ▶ | my($name,$xsargs,$parobjs,$optypes,#$hasp2child, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
VarArgsXSHdr: called CC=23 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | $pmcode,$hdrcode,$inplacecode,$globalnew,$callcopy) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | # Don't do var args processing if the user has pre-defined pmcode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | 2 | ▶ | return 'DO NOT SET!!' if ($pmcode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | # don't generate a HDR if globalnew is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | # globalnew implies internal usage, not XS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | 2 | ▶ | return undef if $globalnew; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | 2 | my $ci = ' '; # current indenting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | 2 | my $pars = join "\n",map {$ci.$_->[1]->get_decl($_->[0]).";"} @$xsargs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | 2 | my @args = map { $_->[0] } @$xsargs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | 2 | my %out = map { $_ => exists($$parobjs{$_}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | && exists($$parobjs{$_}{FlagOut}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 2 | ▶ | && !exists($$parobjs{$_}{FlagCreateAlways})} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $parobjs->{$_} and exists $parobjs->{$_}{"FlagOut"}
MC/DC0%0/2
exists $parobjs->{$_} and exists $parobjs->{$_}{"FlagOut"}
exists $parobjs->{$_}
exists $parobjs->{$_}{"FlagOut"}
Truth table33%1/3
A and B
A= exists $parobjs->{$_}B= exists $parobjs->{$_}{"FlagOut"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | 2 | my %outca = map { $_ => exists($$parobjs{$_}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | && exists($$parobjs{$_}{FlagOut}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | 2 | ▶ | && exists($$parobjs{$_}{FlagCreateAlways})} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $parobjs->{$_} and exists $parobjs->{$_}{"FlagOut"}
MC/DC0%0/2
exists $parobjs->{$_} and exists $parobjs->{$_}{"FlagOut"}
exists $parobjs->{$_}
exists $parobjs->{$_}{"FlagOut"}
Truth table33%1/3
A and B
A= exists $parobjs->{$_}B= exists $parobjs->{$_}{"FlagOut"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | 2 | ▶ | my %tmp = map { $_ => exists($$parobjs{$_}) && exists($$parobjs{$_}{FlagTemp}) } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | 2 | my %other = map { $_ => exists($$optypes{$_}) } @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | # remember, othervars *are* input vars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | 2 | my $nout = (grep { $_ } values %out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | 2 | my $noutca = (grep { $_ } values %outca); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 2 | my $nother = (grep { $_ } values %other); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | 2 | my $ntmp = (grep { $_ } values %tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | 2 | my $ntot = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | 2 | my $nmaxonstack = $ntot - $noutca; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | 2 | my $nin = $ntot - ($nout + $noutca + $ntmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | 2 | my $ninout = $nin + $nout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | 2 | my $nallout = $nout + $noutca; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | 2 | my $usageargs = join (",", @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | 2 | $ci = ' '; # Current indenting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | # Generate declarations for SV * variables corresponding to pdl * output variables. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | # These are used in creating output and temp variables. One variable (ex: SV * outvar1_SV;) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | # is needed for each output and output create always argument | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | 2 | ▶ | my $svdecls = join ("\n", map { "${ci}SV *${_}_SV;" } grep { $out{$_} || $outca{$_} || $tmp{$_} } @args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$out{$_} or $outca{$_}
MC/DC0%0/2
$out{$_} or $outca{$_}
$out{$_}
$outca{$_}
Truth table33%1/3
A or B
A= $out{$_}B= $outca{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | 2 | my @create = (); # The names of variables which need to be created by calling | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | # the 'initialize' perl routine from the correct package. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | 2 | $ci = ' '; # Current indenting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | # clause for reading in all variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | 2 | my $clause1 = ''; my $cnt = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 2 | foreach my $i ( 0 .. $#args ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | 2 | my $x = $args[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | 2 | ▶ | if ($other{$x}) { # other par | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | 0 | $clause1 .= "$ci$x = " . typemap($x, $$optypes{$x}, "ST($cnt)") . ";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | 0 | $cnt++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | } elsif ($outca{$x}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | 0 | push (@create, $x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | 2 | $clause1 .= "$ci$x = PDL->SvPDLV(ST($cnt));\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | 2 | $cnt++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | # Add code for creating output variables via call to 'initialize' perl routine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | 2 | $clause1 .= callPerlInit (\@create, $ci, $callcopy); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | 2 | @create = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | # clause for reading in input and output vars and creating temps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 2 | my $clause2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | # skip this clause if there are no temps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | 2 | ▶ | if ($nmaxonstack == $ninout) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | 2 | $clause2 = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | 0 | $clause2 = "\n else if (items == $ninout) { PDL_COMMENT(\"all but temps on stack, read in output, create temps\")" . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | " nreturn = $noutca;\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | 0 | $cnt = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | 0 | foreach my $i ( 0 .. $#args ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | 0 | my $x = $args[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | 0 | ▶ | if ($other{$x}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | 0 | $clause2 .= "$ci$x = " . typemap($x, $$optypes{$x}, "ST($cnt)") . ";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | 0 | $cnt++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | ▶ | } elsif ($tmp{$x} || $outca{$x}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$tmp{$x} or $outca{$x}
MC/DC0%0/2
$tmp{$x} or $outca{$x}
$tmp{$x}
$outca{$x}
Truth table0%0/3
A or B
A= $tmp{$x}B= $outca{$x}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | # a temporary or always create variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 0 | push (@create, $x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | } else { # an input or output variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | 0 | $clause2 .= "$ci$x = PDL->SvPDLV(ST($cnt));\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | 0 | $cnt++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | # Add code for creating output variables via call to 'initialize' perl routine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | 0 | $clause2 .= callPerlInit (\@create, $ci, $callcopy); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | 0 | $clause2 .= "}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | 0 | @create = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | # clause for reading in input and creating output and temp vars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | 2 | my $clause3 = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | 2 | $cnt = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | 2 | foreach my $i ( 0 .. $#args ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | 2 | my $x = $args[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | 2 | ▶ | if ($other{$x}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | 0 | $clause3 .= "$ci$x = " . typemap($x, $$optypes{$x}, "ST($cnt)") . ";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | 0 | $cnt++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | ▶ | } elsif ($out{$x} || $tmp{$x} || $outca{$x}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$out{$x} or $tmp{$x} or $outca{$x}
$out{$x} or $tmp{$x}
MC/DC0%0/3
$out{$x} or $tmp{$x} or $outca{$x}
$out{$x}
$tmp{$x}
$outca{$x}
Truth table25%1/4
A or B or C
A= $out{$x}B= $tmp{$x}C= $outca{$x}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | 0 | push (@create, $x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | 2 | $clause3 .= "$ci$x = PDL->SvPDLV(ST($cnt));\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | 2 | $cnt++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | # Add code for creating output variables via call to 'initialize' perl routine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | 2 | $clause3 .= callPerlInit (\@create, $ci, $callcopy); @create = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | 2 | return<<END; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | $name(...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | PREINIT: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | char *objname = "PDL"; /* XXX maybe that class should actually depend on the value set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | by pp_bless ? (CS) */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | HV *bless_stash = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | SV *parent = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | int nreturn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | $svdecls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | $pars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | PPCODE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | PDL_COMMENT("Check if you can get a package name for this input value. ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | PDL_COMMENT("It can be either a PDL (SVt_PVMG) or a hash which is a ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | PDL_COMMENT("derived PDL subclass (SVt_PVHV) ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | if (SvROK(ST(0)) && ((SvTYPE(SvRV(ST(0))) == SVt_PVMG) || (SvTYPE(SvRV(ST(0))) == SVt_PVHV))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | parent = ST(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | if (sv_isobject(parent)){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | bless_stash = SvSTASH(SvRV(ST(0))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | objname = HvNAME((bless_stash)); PDL_COMMENT("The package to bless output vars into is taken from the first input var") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | if (items == $nmaxonstack) { PDL_COMMENT("all variables on stack, read in output and temp vars") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | nreturn = $noutca; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | $clause1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | $clause2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | else if (items == $nin) { PDL_COMMENT("only input variables on stack, create outputs and temps") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | nreturn = $nallout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | $clause3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | croak (\"Usage: PDL::$name($usageargs) (you may leave temporaries or output variables out of list)\"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | $hdrcode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | $inplacecode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | END | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | } # sub: VarArgsXSHdr() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | # This subroutine produces the code which returns output variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | # or leaves them as modified input variables. D. Hunt 4/10/00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | sub VarArgsXSReturn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | 2 | ▶ | my($xsargs, $parobjs, $globalnew ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
VarArgsXSReturn: called CC=6 SCAR=19.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | # don't generate a HDR if globalnew is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | # globalnew implies internal usage, not XS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | 2 | ▶ | return undef if $globalnew; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | # names of output variables (in calling order) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | 2 | my @outs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | # beware of existance tests like this: $$parobjs{$arg->[0]}{FlagOut} ! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | # this will cause $$parobjs{$arg->[0]} to spring into existance even if $$parobjs{$arg->[0]}{FlagOut} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | # does not exist!! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | 2 | foreach my $arg (@$xsargs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | 2 | my $x = $arg->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | 2 | ▶ | push (@outs, $x) if (exists ($$parobjs{$x}) and exists ($$parobjs{$x}{FlagOut})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $parobjs->{$x} and exists $parobjs->{$x}{"FlagOut"}
MC/DC0%0/2
exists $parobjs->{$x} and exists $parobjs->{$x}{"FlagOut"}
exists $parobjs->{$x}
exists $parobjs->{$x}{"FlagOut"}
Truth table33%1/3
A and B
A= exists $parobjs->{$x}B= exists $parobjs->{$x}{"FlagOut"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | 2 | my $ci = ' '; # Current indenting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | 2 | my $clause1 = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | 2 | foreach my $i ( 0 .. $#outs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | 0 | $clause1 .= "${ci}ST($i) = $outs[$i]_SV;\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | return <<"END" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | if (nreturn) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | if (nreturn - items > 0) EXTEND (SP, nreturn - items); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | $clause1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | XSRETURN(nreturn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | XSRETURN(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | END | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | 2 | } # sub: VarArgsXSReturn() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | sub XSCHdrs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | 0 | ▶ | my($name,$pars,$gname) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XSCHdrs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | # Hmmm, do we need $shortpars at all? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | #my $shortpars = join ',',map {$_->[0]} @$pars; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | 0 | my $longpars = join ",",map {$_->[1]->get_decl($_->[0])} @$pars; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | 0 | return ["void $name($longpars) {","}","", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | "PDL->$gname = $name;"]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | # abstract the access to the bad value status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | # - means we can easily change the representation without too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | # many changes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | # it's also used in one place in PP/PDLCode.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | # -- there it's hard-coded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | 1 | ▶ | sub set_badflag { return '$PRIV(bvalflag) = 1;' . "\n"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_badflag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | 1 | ▶ | sub clear_badflag { return '$PRIV(bvalflag) = 0;' . "\n"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_badflag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | 1 | ▶ | sub get_badflag { return '$PRIV(bvalflag)'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_badflag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | 0 | ▶ | sub get_badflag_priv { return '$PRIV(bvalflag)'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_badflag_priv: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | sub set_badstate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | 0 | ▶ | my $pdl = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_badstate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | 0 | return "\$SETPDLSTATEBAD($pdl)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | sub clear_badstate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | 0 | ▶ | my $pdl = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_badstate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | 0 | return "\$SETPDLSTATEGOOD($pdl)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | sub get_badstate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | 1 | ▶ | my $pdl = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_badstate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | 1 | return "\$ISPDLSTATEBAD($pdl)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | # checks the input piddles to see if the routine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | # is being any data containing bad values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | # if FindBadStatusCode is set, use it, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | # otherwise create the code automatically. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | # - in the automatic code creation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | # if $badflag is 0, rather than being undefined, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | # we issue a warning if any piddles contain bad values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | # (and set the bvalflag to 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | # XXX it looks like output piddles are included in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | # check. I *think* this is just wasted code, but I'm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | # not sure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | sub findbadstatus { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | 1 | ▶ | my ( $badflag, $badcode, $xsargs, $parobjs, $optypes, $symtab, $name ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
findbadstatus: called CC=19 SCAR=37.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | 1 | ▶ | return '' unless $bvalflag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | 1 | ▶ | return $badcode if defined $badcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | 1 | my $sname = $symtab->get_symname('_PDL_ThisTrans'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | 1 | my @args = map { $_->[0] } @$xsargs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | my %out = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | 1 | $_ => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | exists($$parobjs{$_}) && exists($$parobjs{$_}{FlagOut}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | && !exists($$parobjs{$_}{FlagCreateAlways}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | 1 | ▶ | } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $parobjs->{$_} and exists $parobjs->{$_}{"FlagOut"}
MC/DC0%0/2
exists $parobjs->{$_} and exists $parobjs->{$_}{"FlagOut"}
exists $parobjs->{$_}
exists $parobjs->{$_}{"FlagOut"}
Truth table33%1/3
A and B
A= exists $parobjs->{$_}B= exists $parobjs->{$_}{"FlagOut"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | my %outca = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | 1 | $_ => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | exists($$parobjs{$_}) && exists($$parobjs{$_}{FlagOut}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | && exists($$parobjs{$_}{FlagCreateAlways}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | 1 | ▶ | } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $parobjs->{$_} and exists $parobjs->{$_}{"FlagOut"}
MC/DC0%0/2
exists $parobjs->{$_} and exists $parobjs->{$_}{"FlagOut"}
exists $parobjs->{$_}
exists $parobjs->{$_}{"FlagOut"}
Truth table33%1/3
A and B
A= exists $parobjs->{$_}B= exists $parobjs->{$_}{"FlagOut"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | my %tmp = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | 1 | $_ => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | exists($$parobjs{$_}) && exists($$parobjs{$_}{FlagTemp}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | 1 | ▶ | } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | 1 | my %other = map { $_ => exists($$optypes{$_}) } @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | 1 | my $clear_bad = clear_badflag(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | 1 | my $set_bad = set_badflag(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | 1 | my $get_bad = get_badflag(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | 1 | my $str = $clear_bad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | # set the badflag_cache variable if any input piddle has the bad flag set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | 1 | my $add = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | 1 | my $badflag_str = " \$BADFLAGCACHE() = "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | 1 | foreach my $i ( 0 .. $#args ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | 1 | my $x = $args[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | 1 | ▶ | unless ( $other{$x} or $out{$x} or $tmp{$x} or $outca{$x}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$other{$x} or $out{$x} or $tmp{$x} or $outca{$x}
$other{$x} or $out{$x} or $tmp{$x}
$other{$x} or $out{$x}
MC/DC0%0/4
$other{$x} or $out{$x} or $tmp{$x} or $outca{$x}
$other{$x}
$out{$x}
$tmp{$x}
$outca{$x}
Truth table20%1/5
A or B or C or D
A= $other{$x}B= $out{$x}C= $tmp{$x}D= $outca{$x}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | 1 | ▶ | if ($add) { $badflag_str .= " || "; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | 1 | else { $add = 1; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | 1 | $badflag_str .= get_badstate($args[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | # It is possible, at present, for $add to be 0. I think this is when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | # the routine has no input piddles, such as fibonacci in primitive.pd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | # but there may be other cases. These routines could/should (?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | # be marked as NoBadCode to avoid this, or maybe the code here made | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | # smarter. Left as is for now as do not want to add instability into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | # the 2.4.3 release if I can help it - DJB 23 Jul 2006 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | 1 | ▶ | if ($add != 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | 1 | $str .= $badflag_str . ";\n if (\$BADFLAGCACHE()) ${set_bad}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | 0 | ▶ | print "\nNOTE: $name has no input bad piddles.\n\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | 1 | ▶ | if ( defined($badflag) and $badflag == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $badflag and $badflag == 0
MC/DC0%0/2
defined $badflag and $badflag == 0
defined $badflag
$badflag == 0
Truth table33%1/3
A and B
A= defined $badflagB= $badflag == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | 0 | $str .= | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | " if ( $get_bad ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | printf(\"WARNING: $name does not handle bad values.\\n\"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | $clear_bad | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | }\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | 0 | ▶ | print "\nNOTE: $name does not handle bad values.\n\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | } # if: $badflag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | 1 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | } # sub: findbadstatus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | # copies over the bad value state to the output piddles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | # if CopyBadStatusCode is set, use it, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | # otherwise create the code automatically. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | # note: this is executed before the trans_mutual call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | # is made, since the state may be changed by the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | # Code section | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | sub copybadstatus { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | 1 | ▶ | my ( $badflag, $badcode, $xsargs, $parobjs, $symtab ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copybadstatus: called CC=8 SCAR=25.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | ## return '' unless $bvalflag or $badflag == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | 1 | ▶ | return '' unless $bvalflag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | 1 | ▶ | if (defined $badcode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | # realised in 2.4.3 testing that use of $PRIV at this stage is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | # dangerous since it may have been freed. So I introduced the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | # $BFLACACHE variable which stores the $PRIV(bvalflag) value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | # for use here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | # For now make the substitution automatic but it will likely become an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | # error to use $PRIV(bvalflag) here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | 0 | ▶ | if ($badcode =~ m/\$PRIV(bvalflag)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | 0 | $badcode =~ s/\$PRIV(bvalflag)/\$BADFLAGCACHE()/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | 0 | print "\nPDL::PP WARNING: copybadstatus contains '\$PRIV(bvalflag)'; replace with \$BADFLAGCACHE()\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | 0 | return $badcode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | # names of output variables (in calling order) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | 1 | my @outs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | # beware of existance tests like this: $$parobjs{$arg->[0]}{FlagOut} ! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | # this will cause $$parobjs{$arg->[0]} to spring into existance even if $$parobjs{$arg->[0]}{FlagOut} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | # does not exist!! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | 1 | foreach my $arg (@$xsargs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | 1 | my $x = $arg->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | 1 | ▶ | push (@outs, $x) if (exists ($$parobjs{$x}) and exists ($$parobjs{$x}{FlagOut})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $parobjs->{$x} and exists $parobjs->{$x}{"FlagOut"}
MC/DC0%0/2
exists $parobjs->{$x} and exists $parobjs->{$x}{"FlagOut"}
exists $parobjs->{$x}
exists $parobjs->{$x}{"FlagOut"}
Truth table33%1/3
A and B
A= exists $parobjs->{$x}B= exists $parobjs->{$x}{"FlagOut"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | 1 | my $sname = $symtab->get_symname('_PDL_ThisTrans'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | 1 | my $str = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | # It appears that some code in Bad.xs sets the cache value but then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | # this bit of code never gets called. Is this an efficiency issue (ie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | # should we try and optimise away those ocurrences) or does it perform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | # some purpose? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | 1 | $str = "if (\$BADFLAGCACHE()) {\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | 1 | foreach my $arg ( @outs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | 0 | $str .= " " . set_badstate($arg) . ";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | 1 | $str .= "}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | 1 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | } # sub: copybadstatus() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | # insert code, after the autogenerated xs argument processing code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | # produced by VarArgsXSHdr and AFTER any in HdrCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | # - this code flags the routine as working inplace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | # Inplace can be supplied several values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | # => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | # assumes fn has an inout and output piddle (eg 'a(); [o] b();') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | # => [ 'a' ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | # assumes several input piddles in sig, so 'a' labels which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | # one is to be marked inplace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | # => [ 'a', 'b' ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | # input piddle is a(), output pidle is 'b' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | sub InplaceCode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | 2 | ▶ | my ( $ppname, $xsargs, $parobjs, $arg ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
InplaceCode: called CC=15 SCAR=53.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | 2 | ▶ | return '' unless defined $arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | # find input and output piddles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | 0 | my ( @in, @out ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | 0 | foreach my $arg (@$xsargs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | 0 | my $name = $arg->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | 0 | ▶ | if ( exists $$parobjs{$name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | 0 | ▶ | if ( exists $$parobjs{$name}{FlagOut} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | 0 | push @out, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | } elsif ( ! exists $$parobjs{$name}{FlagTemp} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | 0 | push @in, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | # handle different values of arg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | 0 | my ( $in, $out ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | # default vals - only set if we have one input/output piddle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | 0 | ▶ | $in = $in[0] if $#in == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | 0 | ▶ | $out = $out[0] if $#out == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | 0 | ▶ | if ( ref($arg) eq "ARRAY" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | 0 | my $narg = $#$arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | 0 | ▶ | if ( $narg > -1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | 0 | $in = $$arg[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | 0 | ▶ | $out = $$arg[1] if $narg > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | } elsif ( ref($arg) eq "" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | 0 | ▶ | return '' unless $arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2297 | # use default values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2298 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2299 | 0 | die "ERROR: Inplace rule [$ppname] must be sent either an array ref or a scalar.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2302 | 0 | ▶ | die "ERROR: Inplace [$ppname] does not know name of input piddle\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2303 | unless defined $in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2304 | 0 | ▶ | die "ERROR: Inplace [$ppname] does not know name of output piddle\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2305 | unless defined $out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2307 | 0 | my $instate = $in . "->state"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2308 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2309 | 0 | qq{\tif ( $instate & PDL_INPLACE && ($out != $in)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2310 | $instate &= ~PDL_INPLACE; PDL_COMMENT("unset") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2311 | $out = $in; PDL_COMMENT("discard output value, leak ?") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2312 | PDL->SetSV_PDL(${out}_SV,${out}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2313 | }}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2315 | } # sub: InplaceCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2317 | # If there is an EquivCPOffsCOde and: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2318 | # no bad-value support ==> use that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2319 | # bad value support ==> write a bit of code that does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2320 | # if ( $PRIV(bvalflag) ) { bad-EquivCPOffsCode } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2321 | # else { good-EquivCPOffsCode } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2322 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2323 | # Note: since EquivCPOffsCOde doesn't (or I haven't seen any that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2324 | # do) use 'loop %{' or 'threadloop %{', we can't rely on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2325 | # PDLCode to automatically write code like above, hence the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2326 | # explicit definition here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2327 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2328 | # Note: I *assume* that bad-Equiv..Code == good-Equiv..Code *EXCEPT* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2329 | # that we re-define the meaning of the $EQUIVCPOFFS macro to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2330 | # check for bad values when copying things over. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2331 | # This means having to write less code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2332 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2333 | # Since PARENT & CHILD need NOT be the same type we cannot just copy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2334 | # values from one to the other - we have to check for the presence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2335 | # of bad values, hence the expansion for the $bad code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2336 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2337 | # Some operators (notably range) also have an out-of-range flag; they use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2338 | # the macro EQUIVCPTRUNC instead of EQUIVCPOFFS. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2339 | # $EQUIVCPTRUNC does the same as EQUIVCPOFFS but accepts a child-out-of-bounds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2340 | # flag. If the out-of-bounds flag is set, the forward code puts BAD/0 into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2341 | # the child, and reverse code refrains from copying. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2342 | # --CED 27-Jan-2003 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2343 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2344 | # sent [EquivCPOffsCode,BadFlag] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2346 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2347 | # NOTE: EQUIVCPOFFS and EQUIVCPTRUNC both suffer from the macro-block | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2348 | # wart of C preprocessing. They look like statements but sometimes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2349 | # process into blocks, so if/then/else constructs can get broken. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2350 | # Either (1) use blocks for if/then/else, or (2) get excited and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2351 | # use the "do {BLOCK} while(0)" block-to-statement conversion construct | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2352 | # in the substitution. I'm too Lazy. --CED 27-Jan-2003 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2353 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2354 | sub CodefromEquivCPOffsCode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2355 | 0 | ▶ | my $good = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CodefromEquivCPOffsCode: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2356 | 0 | my $bflag = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2358 | 0 | my $bad = $good; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2360 | # parse 'good' code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2361 | 0 | $good =~ s/\$EQUIVCPOFFS\(([^()]+),([^()]+)\)/\$PP(CHILD)[$1] = \$PP(PARENT)[$2]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2362 | 0 | $good =~ s/\$EQUIVCPTRUNC\(([^()]+),([^()]+),([^()]+)\)/\$PP(CHILD)[$1] = ($3) ? 0 : \$PP(PARENT)[$2]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2364 | 0 | my $str = $good; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2366 | 0 | ▶ | if ( defined $bflag and $bflag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $bflag and $bflag
MC/DC0%0/2
defined $bflag and $bflag
defined $bflag
$bflag
Truth table0%0/3
A and B
A= defined $bflagB= $bflag
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2367 | # parse 'bad' code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2368 | 0 | $bad =~ s/\$EQUIVCPOFFS\(([^()]+),([^()]+)\)/if( \$PPISBAD(PARENT,[$2]) ) { \$PPSETBAD(CHILD,[$1]); } else { \$PP(CHILD)[$1] = \$PP(PARENT)[$2]; }/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2369 | 0 | $bad =~ s/\$EQUIVCPTRUNC\(([^()]+),([^()]+),([^()]+)\)/ if( ($3) || \$PPISBAD(PARENT,[$2]) ) { \$PPSETBAD(CHILD,[$1]); } else {\$PP(CHILD)[$1] = \$PP(PARENT)[$2]; }/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2371 | 0 | $str = 'if( $PRIV(bvalflag) ) { ' . $bad . ' } else { ' . $good . '}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2374 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2376 | } # sub: CodefromEquivCPOffsCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2378 | # this just reverses PARENT & CHILD in the expansion of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2379 | # the $EQUIVCPOFFS macro (ie compared to CodefromEquivCPOffsCode) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2380 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2381 | sub BackCodefromEquivCPOffsCode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2382 | 0 | ▶ | my $good = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BackCodefromEquivCPOffsCode: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2383 | 0 | my $bflag = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2385 | 0 | my $bad = $good; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2387 | # parse 'good' code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2388 | 0 | $good =~ s/\$EQUIVCPOFFS\(([^()]+),([^()]+)\)/\$PP(PARENT)[$2] = \$PP(CHILD)[$1]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2389 | 0 | $good =~ s/\$EQUIVCPTRUNC\(([^()]+),([^()]+),([^()]+)\)/if(!($3)) \$PP(PARENT)[$2] = \$PP(CHILD)[$1] /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2391 | 0 | my $str = $good; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2393 | 0 | ▶ | if ( defined $bflag and $bflag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $bflag and $bflag
MC/DC0%0/2
defined $bflag and $bflag
defined $bflag
$bflag
Truth table0%0/3
A and B
A= defined $bflagB= $bflag
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2394 | # parse 'bad' code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2395 | 0 | $bad =~ s/\$EQUIVCPOFFS\(([^()]+),([^()]+)\)/if( \$PPISBAD(CHILD,[$1]) ) { \$PPSETBAD(PARENT,[$2]); } else { \$PP(PARENT)[$2] = \$PP(CHILD)[$1]; }/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2396 | 0 | $bad =~ s/\$EQUIVCPTRUNC\(([^()]+),([^()]+),([^()]+)\)/if(!($3)) { if( \$PPISBAD(CHILD,[$1]) ) { \$PPSETBAD(PARENT,[$2]); } else { \$PP(PARENT)[$2] = \$PP(CHILD)[$1]; } } /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2398 | 0 | $str = 'if ( $PRIV(bvalflag) ) { ' . $bad . ' } else { ' . $good . '}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2401 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2403 | } # sub: BackCodefromEquivCPOffsCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2405 | sub GenDocs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2406 | 2 | ▶ | my ($name,$pars,$otherpars,$doc,$baddoc) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GenDocs: called CC=11 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2408 | # Allow explcit non-doc using Doc=>undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2410 | 2 | ▶ | return '' if $doc eq '' && (!defined $doc) && $doc==undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$doc eq "" and not defined $doc and $doc == undef
$doc eq "" and not defined $doc
MC/DC0%0/3
$doc eq "" and not defined $doc and $doc == undef
$doc eq ""
not defined $doc
$doc == undef
Truth table25%1/4
A and not(B) and C
A= $doc eq ""B= not defined $docC= $doc == undef
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2411 | 2 | ▶ | return '' if $doc =~ /^\s*internal\s*$/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2413 | # remove any 'bad' documentation if we're not compiling support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2414 | 2 | ▶ | $baddoc = undef unless $bvalflag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2416 | # If the doc string is one line let's have to for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2417 | # reference card information as well | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2418 | 2 | my @splitRes; # temp split variable to get rid of | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2419 | # 'implicit split to @_ is deprecated' messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2420 | 2 | ▶ | $doc = "=for ref\n\n".$doc if( scalar(@splitRes = split("\n", $doc)) <= 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2422 | 2 | $::DOCUMENTED++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2423 | 2 | ▶ | $pars = "P(); C()" unless $pars; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2424 | # Strip leading whitespace and trailing semicolons and whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2425 | 2 | $pars =~ s/^\s*(.+[^;])[;\s]*$/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2426 | 2 | ▶ | $otherpars =~ s/^\s*(.+[^;])[;\s]*$/$1/ if $otherpars; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2427 | 2 | ▶ | my $sig = "$pars".( $otherpars ? "; $otherpars" : ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2429 | 2 | $doc =~ s/\n(=cut\s*\n)+(\s*\n)*$/\n/m; # Strip extra =cut's | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2430 | 2 | ▶ | if ( defined $baddoc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2431 | # Strip leading newlines and any =cut markings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2432 | 2 | $baddoc =~ s/\n(=cut\s*\n)+(\s*\n)*$/\n/m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2433 | 2 | $baddoc =~ s/^\n+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2434 | 2 | $baddoc = "=for bad\n\n$baddoc"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2437 | 2 | my $baddoc_function_pod = <<"EOD" ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2439 | XXX=head2 $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2441 | XXX=for sig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2443 | Signature: ($sig) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2445 | $doc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2447 | $baddoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2449 | XXX=cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2451 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2453 | 2 | $baddoc_function_pod =~ s/^XXX=/=/gms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2454 | 2 | return $baddoc_function_pod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2457 | sub ToIsReversible { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2458 | 0 | ▶ | my($rev) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ToIsReversible: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2459 | 0 | ▶ | if($rev eq "1") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2460 | 0 | '$SETREVERSIBLE(1)' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2461 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2462 | 0 | $rev | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2466 | sub make_newcoerce { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2467 | 0 | ▶ | my($ftypes) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_newcoerce: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2468 | join '',map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2469 | 0 | "$_->datatype = $ftypes->{$_}; " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2470 | } (keys %$ftypes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2473 | # Assuming that, if HASP2Child is true, we only have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2474 | # PARENT; CHILD parameters, so we can just take the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2475 | # datatype to be that of PARENT (which is set up by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2476 | # find_datatype()). Little bit complicated because | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2477 | # we need to set CHILD's datatype under certain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2478 | # circumstances | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2479 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2480 | sub coerce_types { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2481 | 2 | ▶ | my($parnames,$parobjs,$ignore,$newstab,$hasp2child) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coerce_types: called CC=11 SCAR=33.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2483 | # assume [oca]CHILD();, although there might be an ignore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2484 | 2 | ▶ | if ( $hasp2child ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2485 | 0 | my $child = $$parnames[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2486 | 0 | ▶ | return "" if $ignore->{$child}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2488 | die "ERROR: expected $child to be [oca]\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2489 | 0 | ▶ | unless $parobjs->{$child}{FlagCreateAlways}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2491 | 0 | ▶ | return "$child\->datatype = \$PRIV(__datatype);\n$child\->has_badvalue = \$PRIV(has_badvalue);\n$child\->badvalue = \$PRIV(badvalue);\n" if $hasp2child; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2494 | 2 | my $str = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2495 | 2 | foreach ( @$parnames ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2496 | 2 | ▶ | next if $ignore->{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2498 | 2 | my $po = $parobjs->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2500 | 2 | my $dtype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2501 | 2 | ▶ | if ( $po->{FlagTyped} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2502 | 0 | $dtype = $po->cenum(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2503 | $dtype = "PDLMAX($dtype,\$PRIV(__datatype))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2504 | 0 | ▶ | if $po->{FlagTplus}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2505 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2506 | 2 | $dtype = "\$PRIV(__datatype)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2509 | 2 | ▶ | if ( $po->{FlagCreateAlways} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2510 | 0 | $str .= "$_->datatype = $dtype; "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2511 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2512 | $str .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2513 | "if( ($_->state & PDL_NOMYDIMS) && $_->trans == NULL ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2514 | $_->datatype = $dtype; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2515 | } else " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2516 | 2 | ▶ | if $po->{FlagCreat}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2517 | 2 | $str .= "if($dtype != $_->datatype) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2518 | $_ = PDL->get_convertedpdl($_,$dtype); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2519 | }"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2521 | } # foreach: @$parnames | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2523 | 2 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2524 | } # sub: coerce_types() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2526 | # First, finds the greatest datatype, then, if not supported, takes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2527 | # the largest type supported by the function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2528 | # Not yet optimal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2529 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2530 | # Assuming that, if HASP2Child is true, we only have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2531 | # PARENT; CHILD parameters, so we can just take the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2532 | # datatype to be that of PARENT (see also coerce_types()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2533 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2534 | sub find_datatype { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2535 | 2 | ▶ | my($parnames,$parobjs,$ignore,$newstab,$gentypes,$hasp2child) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_datatype: called CC=9 SCAR=24.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2537 | 2 | my $dtype = "\$PRIV(__datatype)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2539 | # TODO XXX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2540 | # the check can probably be removed, but left in since I don't know | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2541 | # what I'm doing (DJB) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2542 | 2 | ▶ | die "ERROR: gentypes != $ntypes with p2child\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$hasp2child and $gentypes->$#* != $ntypes
MC/DC0%0/2
$hasp2child and $gentypes->$#* != $ntypes
$hasp2child
$gentypes->$#* != $ntypes
Truth table33%1/3
A and B
A= $hasp2childB= $gentypes->$#* != $ntypes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2543 | if $hasp2child and $#$gentypes != $ntypes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2545 | 2 | ▶ | return "$dtype = $$parnames[0]\->datatype;\n\$PRIV(has_badvalue) = $$parnames[0]\->has_badvalue;\n\$PRIV(badvalue) = $$parnames[0]\->badvalue;\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2546 | if $hasp2child; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2548 | 2 | my $str = "$dtype = 0;"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2549 | 2 | foreach ( @$parnames ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2550 | 2 | my $po = $parobjs->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2551 | 2 | ▶ | next if $ignore->{$_} or $po->{FlagTyped} or $po->{FlagCreateAlways}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$ignore->{$_} or $po->{"FlagTyped"} or $po->{"FlagCreateAlways"}
$ignore->{$_} or $po->{"FlagTyped"}
MC/DC0%0/3
$ignore->{$_} or $po->{"FlagTyped"} or $po->{"FlagCreateAlways"}
$ignore->{$_}
$po->{"FlagTyped"}
$po->{"FlagCreateAlways"}
Truth table25%1/4
A or B or C
A= $ignore->{$_}B= $po->{"FlagTyped"}C= $po->{"FlagCreateAlways"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2553 | 2 | $str .= "if("; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2554 | $str .= "!(($_->state & PDL_NOMYDIMS) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2555 | $_->trans == NULL) && " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2556 | 2 | ▶ | if $po->{FlagCreat}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2557 | 2 | $str .= "$dtype < $_->datatype) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2558 | $dtype = $_->datatype; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2559 | }\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2560 | } # foreach: @$parnames | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2562 | 2 | $str .= join '', map { "if($dtype == PDL_$_) {}\nelse " }(@$gentypes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2564 | 2 | return $str .= "$dtype = PDL_$gentypes->[-1];\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2565 | } # sub: find_datatype() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2567 | 1 | ▶ | sub NT2Decls_p {&NT2Decls__({ToPtrs=>1},@_);} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NT2Decls_p: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2569 | 1 | ▶ | sub NT2Copies_p {&NT2Copies__({ToPtrs=>1},@_);} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NT2Copies_p: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2571 | 2 | ▶ | sub NT2Free_p {&NT2Free__({ToPtrs=>1},@_);} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NT2Free_p: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2573 | 1 | ▶ | sub NT2Decls {&NT2Decls__({},@_);} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NT2Decls: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2575 | sub NT2Decls__ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2576 | 2 | ▶ | my($opts,$onames,$otypes) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NT2Decls__: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2577 | 2 | my $decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2578 | 2 | my $dopts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2579 | 2 | ▶ | $dopts->{VarArrays2Ptrs} = 1 if $opts->{ToPtrs}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2580 | 2 | for(@$onames) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2581 | 3 | $decl .= $otypes->{$_}->get_decl($_,$dopts).";"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2583 | 2 | return $decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2586 | sub NT2Copies__ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2587 | 1 | ▶ | my($opts,$onames,$otypes,$copyname) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NT2Copies__: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2588 | 1 | my $decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2589 | 1 | my $dopts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2590 | 1 | ▶ | $dopts->{VarArrays2Ptrs} = 1 if $opts->{ToPtrs}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2591 | 1 | for(@$onames) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2592 | 0 | $decl .= $otypes->{$_}->get_copy("\$PRIV($_)","$copyname->$_", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2593 | $dopts).";"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2595 | 1 | return $decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2598 | sub NT2Free__ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2599 | 2 | ▶ | my($opts,$onames,$otypes) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NT2Free__: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2600 | 2 | my $decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2601 | 2 | my $dopts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2602 | 2 | ▶ | $dopts->{VarArrays2Ptrs} = 1 if $opts->{ToPtrs}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2603 | 2 | for(@$onames) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2604 | 3 | $decl .= $otypes->{$_}->get_free("\$PRIV($_)", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2605 | $dopts).";"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2607 | 2 | return $decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2610 | # The undef is just so that PrivIsInc gets set. Is this really | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2611 | # needed (well, it is since the rule fails if there aren't 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2612 | # return values; what I meant is what does PrivIsInc do for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2613 | # us?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2614 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2615 | sub make_incsizes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2616 | 1 | ▶ | my($parnames,$parobjs,$dimobjs,$havethreading) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_incsizes: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2617 | my $str = ($havethreading?"pdl_thread __pdlthread; ":""). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2618 | 1 | (join '',map {$parobjs->{$_}->get_incdecls} @$parnames). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2619 | 1 | ▶ | (join '',map {$_->get_decldim} sort values %$dimobjs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2620 | 1 | return ($str,undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2623 | sub make_incsize_copy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2624 | 1 | ▶ | my($parnames,$parobjs,$dimobjs,$copyname,$havethreading) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_incsize_copy: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2625 | ($havethreading? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2626 | "PDL->thread_copy(&(\$PRIV(__pdlthread)),&($copyname->__pdlthread));" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2627 | : ""). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2628 | 1 | ▶ | (join '',map {$parobjs->{$_}->get_incdecl_copy(sub{"\$PRIV($_[0])"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2629 | 1 | ▶ | sub{"$copyname->$_[0]"})} @$parnames). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2630 | 1 | ▶ | (join '',map {$_->get_copydim(sub{"\$PRIV($_[0])"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2631 | 1 | ▶ | sub{"$copyname->$_[0]"})} sort values %$dimobjs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2635 | sub make_incsize_free { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2636 | 1 | ▶ | my($parnames,$parobjs,$dimobjs,$havethreading) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_incsize_free: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2637 | 1 | ▶ | $havethreading ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2638 | 'PDL->freethreadloop(&($PRIV(__pdlthread)));' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2639 | : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2642 | sub make_parnames { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2643 | 1 | ▶ | my($pnames,$pobjs,$dobjs) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_parnames: called CC=4 SCAR=15.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2644 | 1 | my @pdls = map {$pobjs->{$_}} @$pnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2645 | 1 | my $npdls = $#pdls+1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2646 | 1 | my $join__parnames = join ",",map {qq|"$_"|} @$pnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2647 | 1 | my $join__realdims = join ",",map {$#{$_->{IndObjs}}+1} @pdls; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2648 | 1 | ▶ | if($Config{cc} eq 'cl') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2649 | 0 | ▶ | $join__parnames = '""' if $join__parnames eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2650 | 0 | ▶ | $join__realdims = '0' if $join__realdims eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2652 | 1 | return("static char *__parnames[] = {". $join__parnames ."}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2653 | static PDL_Indx __realdims[] = {". $join__realdims . "}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2654 | static char __funcname[] = \"\$MODULE()::\$NAME()\"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2655 | static pdl_errorinfo __einfo = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2656 | __funcname, __parnames, $npdls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2657 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2658 | "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2661 | ############################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2662 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2663 | # hdrcheck -- examine the various PDLs that form the output PDL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2664 | # and copy headers as necessary. The last header found with the hdrcpy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2665 | # bit set is used. This used to do just a simple ref copy but now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2666 | # it uses the perl routine PDL::_hdr_copy to do the dirty work. That | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2667 | # routine makes a deep copy of the header. Copies of the deep copy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2668 | # are distributed to all the names of the piddle that are not the source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2669 | # of the header. I believe that is the Right Thing to do but I could be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2670 | # wrong. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2671 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2672 | # It's hard to read this sort of macro stuff so here's the flow: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2673 | # - Check the hdrcpy flag. If it's set, then check the header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2674 | # to see if it exists. If it doees, we need to call the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2675 | # perl-land PDL::_hdr_copy routine. There are some shenanigans | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2676 | # to keep the return value from evaporating before we've had a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2677 | # chance to do our bit with it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2678 | # - For each output argument in the function signature, try to put | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2679 | # a reference to the new header into that argument's header slot. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2680 | # (For functions with multiple outputs, this produces multiple linked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2681 | # headers -- that could be Wrong; fixing it would require making | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2682 | # yet more explicit copies!) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2683 | # - Remortalize the return value from PDL::_hdr_copy, so that we don't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2684 | # leak memory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2685 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2686 | # --CED 12-Apr-2003 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2687 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2689 | sub hdrcheck { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2690 | 1 | ▶ | my ($pnames,$pobjs) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hdrcheck: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2692 | 1 | my $nn = $#$pnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2693 | 1 | my @names = map { "\$PRIV(pdls[$_])" } 0..$nn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2695 | # from make_redodims_thread() we know that __creating[] == 0 unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2696 | # ...{FlagCreat} is true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2697 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2698 | 1 | my $str = " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2699 | { PDL_COMMENT(\"convenience block\") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2700 | void *hdrp = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2701 | char propagate_hdrcpy = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2702 | SV *hdr_copy = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2703 | "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2705 | # Find a header among the possible names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2706 | 1 | foreach ( 0 .. $nn ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2707 | 1 | ▶ | my $aux = $pobjs->{$pnames->[$_]}{FlagCreat} ? "!__creating[$_] && \n" : ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2708 | 1 | $str .= <<"HdRCHECK1" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2709 | if(!hdrp && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2710 | $aux $names[$_]\->hdrsv && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2711 | ($names[$_]\->state & PDL_HDRCPY) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2712 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2713 | hdrp = $names[$_]\->hdrsv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2714 | propagate_hdrcpy = (($names[$_]\->state & PDL_HDRCPY) != 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2716 | HdRCHECK1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2717 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2720 | $str .= << 'DeePcOPY' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2721 | if (hdrp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2722 | if(hdrp == &PL_sv_undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2723 | hdr_copy = &PL_sv_undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2724 | else { PDL_COMMENT("Call the perl routine _hdr_copy...") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2725 | int count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2726 | PDL_COMMENT("Call the perl routine PDL::_hdr_copy(hdrp)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2727 | dSP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2728 | ENTER ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2729 | SAVETMPS ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2730 | PUSHMARK(SP) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2731 | XPUSHs( hdrp ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2732 | PUTBACK ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2733 | count = call_pv("PDL::_hdr_copy",G_SCALAR); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2734 | SPAGAIN ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2735 | if(count != 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2736 | croak("PDL::_hdr_copy didn't return a single value - please report this bug (A)."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2738 | hdr_copy = (SV *)POPs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2740 | if(hdr_copy && hdr_copy != &PL_sv_undef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2741 | (void)SvREFCNT_inc(hdr_copy); PDL_COMMENT("Keep hdr_copy from vanishing during FREETMPS") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2744 | FREETMPS ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2745 | LEAVE ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2748 | } PDL_COMMENT("end of callback block") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2750 | DeePcOPY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2751 | 1 | ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2752 | # if(hdrp) block is still open -- now reassign all the aliases... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2754 | # Found the header -- now copy it into all the right places. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2755 | 1 | foreach ( 0 .. $nn ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2756 | $str .= <<"HdRCHECK2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2757 | if ( $names[$_]\->hdrsv != hdrp ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2758 | if( $names[$_]\->hdrsv && $names[$_]\->hdrsv != &PL_sv_undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2759 | (void)SvREFCNT_dec( $names[$_]\->hdrsv ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2760 | if( hdr_copy != &PL_sv_undef ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2761 | (void)SvREFCNT_inc(hdr_copy); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2762 | $names[$_]\->hdrsv = hdr_copy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2764 | if(propagate_hdrcpy) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2765 | $names[$_]\->state |= PDL_HDRCPY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2766 | HdRCHECK2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2768 | # QUESTION: what is the following line doing? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2769 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2770 | 1 | ▶ | if ( $pobjs->{$pnames->[$_]}{FlagCreat} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2773 | 1 | $str .= ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2774 | if(hdr_copy != &PL_sv_undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2775 | SvREFCNT_dec(hdr_copy); PDL_COMMENT("make hdr_copy mortal again") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2776 | } PDL_COMMENT("end of if(hdrp) block") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2777 | } PDL_COMMENT("end of conv. block") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2778 | '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2779 | 1 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2781 | } # sub: hdrcheck() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2783 | sub make_redodims_thread { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2784 | #my($pnames,$pobjs,$dobjs,$dpars,$pcode ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2785 | 1 | ▶ | my($pnames,$pobjs,$dobjs,$dpars,$pcode, $noPthreadFlag) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_redodims_thread: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2786 | 1 | my $str; my $npdls = @$pnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2788 | 1 | ▶ | $noPthreadFlag = 0 unless( defined $noPthreadFlag ); # assume we can pthread, unless indicated otherwise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2790 | 1 | my $nn = $#$pnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2791 | 1 | my @privname = map { "\$PRIV(pdls[$_])" } ( 0 .. $nn ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2792 | 1 | ▶ | $str .= $npdls ? "PDL_Indx __creating[$npdls];\n" : "PDL_Indx __creating[1];\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2793 | 1 | $str .= join '',map {$_->get_initdim."\n"} sort values %$dobjs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2795 | # if FlagCreat is NOT true, then we set __creating[] to 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2796 | # and we can use this knowledge below, and in hdrcheck() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2797 | # and in PP/PdlParObj (get_xsnormdimchecks()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2798 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2799 | 1 | foreach ( 0 .. $nn ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2800 | 1 | $str .= "__creating[$_] = "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2801 | 1 | ▶ | if ( $pobjs->{$pnames->[$_]}{FlagCreat} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2802 | 0 | $str .= "PDL_CR_SETDIMSCOND(__privtrans,$privname[$_]);\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2803 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2804 | 1 | $str .= "0;\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2805 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2806 | } # foreach: 0 .. $nn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2808 | 1 | $str .= " {\n$pcode\n}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2809 | 1 | $str .= " {\n " . make_parnames($pnames,$pobjs,$dobjs) . " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2810 | PDL->initthreadstruct(2,\$PRIV(pdls), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2811 | __realdims,__creating,$npdls, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2812 | &__einfo,&(\$PRIV(__pdlthread)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2813 | \$PRIV(vtable->per_pdl_flags), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2814 | $noPthreadFlag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2815 | }\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2816 | 1 | $str .= join '',map {$pobjs->{$_}->get_xsnormdimchecks()} @$pnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2817 | 1 | $str .= hdrcheck($pnames,$pobjs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2818 | 1 | $str .= join '',map {$pobjs->{$pnames->[$_]}-> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2819 | get_incsets($privname[$_])} 0..$nn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2820 | 1 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2822 | } # sub: make_redodims_thread() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2824 | sub XSHdr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2825 | 2 | ▶ | my($xsname,$nxargs) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XSHdr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2826 | 2 | return XS::mkproto($xsname,$nxargs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2829 | ########################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2830 | # Name : extract_signature_from_fulldoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2831 | # Usage : $sig = extract_signature_from_fulldoc($fulldoc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2832 | # Purpose : pull out the signature from the fulldoc string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2833 | # Returns : whatever is in parentheses in the signature, or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2834 | # Parameters : $fulldoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2835 | # Throws : never | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2836 | # Notes : the signature must have the following form: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2837 | # : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2838 | # : =for sig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2839 | # : <blank> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2840 | # : Signature: (<signature can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2841 | # : be multiline>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2842 | # : <blank> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2843 | # : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2844 | # : The two spaces before "Signature" are required, as are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2845 | # : the parentheses. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2846 | sub extract_signature_from_fulldoc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2847 | 0 | ▶ | my $fulldoc = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_signature_from_fulldoc: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2848 | 0 | ▶ | if ($fulldoc =~ /=for sig\n\n Signature: \(([^\n]*)\n/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2849 | # Extract the signature and remove the final parenthesis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2850 | 0 | my $sig = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2851 | 0 | ▶ | $sig .= $1 while $fulldoc =~ /\G\h+([^\n]*)\n/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2852 | 0 | $sig =~ s/\)\s*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2853 | 0 | return $sig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2854 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2855 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2856 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2859 | # Build the valid-types regex and valid Pars argument only once. These are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2860 | # also used in PDL::PP::PdlParObj, which is why they are globally available. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2861 | 2 | ▶ | use PDL::PP::PdlParObj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2862 | 2 | my $pars_re = $PDL::PP::PdlParObj::pars_re; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2864 | ########################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2865 | # Name : build_pars_from_fulldoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2866 | # Usage : $pars = build_pars_from_fulldoc($fulldoc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2867 | # Purpose : extract the Pars from the signature from the fulldoc string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2868 | # : the part of the signature that specifies the piddles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2869 | # Returns : a string appropriate for the Pars key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2870 | # Parameters : $fulldoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2871 | # Throws : if there is no signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2872 | # : if there is no extractable Pars section | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2873 | # : if some PDL arguments come after the OtherPars arguments start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2874 | # Notes : This is meant to be used directly in a Rule. Therefore, it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2875 | # : is only called if the Pars key does not yet exist, so if it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2876 | # : is not possible to extract the Pars section, it dies. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2877 | sub build_pars_from_fulldoc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2878 | 0 | ▶ | my $fulldoc = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_pars_from_fulldoc: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2880 | # Get the signature or die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2881 | 0 | ▶ | my $sig = extract_signature_from_fulldoc($fulldoc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2882 | or confess('No Pars specified and none could be extracted from FullDoc'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2884 | # Everything is semicolon-delimited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2885 | 0 | my @args = split /\s*;\s*/, $sig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2886 | 0 | my @pars; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2887 | 0 | my $switched_to_other_pars = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2888 | 0 | for my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2889 | 0 | ▶ | confess('All PDL args must come before other pars in FullDoc signature') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$switched_to_other_pars and $arg =~ /$pars_re/
MC/DC0%0/2
$switched_to_other_pars and $arg =~ /$pars_re/
$switched_to_other_pars
$arg =~ /$pars_re/
Truth table0%0/3
A and B
A= $switched_to_other_parsB= $arg =~ /$pars_re/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2890 | if $switched_to_other_pars and $arg =~ $pars_re; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2891 | 0 | ▶ | if ($arg =~ $pars_re) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2892 | 0 | push @pars, $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2893 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2894 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2895 | 0 | $switched_to_other_pars = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2899 | # Make sure there's something there | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2900 | 0 | ▶ | confess('FullDoc signature contains no PDL arguments') if @pars == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2902 | # All done! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2903 | 0 | return join('; ', @pars); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2904 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2906 | ########################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2907 | # Name : build_otherpars_from_fulldoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2908 | # Usage : $otherpars = build_otherpars_from_fulldoc($fulldoc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2909 | # Purpose : extract the OtherPars from the signature from the fulldoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2910 | # : string, the part of the signature that specifies non-piddle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2911 | # : arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2912 | # Returns : a string appropriate for the OtherPars key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2913 | # Parameters : $fulldoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2914 | # Throws : if some OtherPars arguments come before the last PDL argument | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2915 | # Notes : This is meant to be used directly in a Rule. Therefore, it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2916 | # : is only called if the OtherPars key does not yet exist. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2917 | sub build_otherpars_from_fulldoc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2918 | 0 | ▶ | my $fulldoc = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_otherpars_from_fulldoc: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2920 | # Get the signature or do not set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2921 | 0 | ▶ | my $sig = extract_signature_from_fulldoc($fulldoc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2922 | or return 'DO NOT SET!!'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2923 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2924 | # Everything is semicolon-delimited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2925 | 0 | my @args = split /\s*;\s*/, $sig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2926 | 0 | my @otherpars; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2927 | 0 | for my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2928 | 0 | ▶ | confess('All PDL args must come before other pars in FullDoc signature') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@otherpars > 0 and $arg =~ /$pars_re/
MC/DC0%0/2
@otherpars > 0 and $arg =~ /$pars_re/
@otherpars > 0
$arg =~ /$pars_re/
Truth table0%0/3
A and B
A= @otherpars > 0B= $arg =~ /$pars_re/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2929 | if @otherpars > 0 and $arg =~ $pars_re; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2930 | 0 | ▶ | if ($arg !~ $pars_re) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2931 | 0 | push @otherpars, $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2932 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2935 | # All done! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2936 | 0 | ▶ | return 'DO NOT SET!!'if @otherpars == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2937 | 0 | return join('; ', @otherpars); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2940 | # Set up the rules for translating the pp_def contents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2941 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2942 | $PDL::PP::deftbl = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2943 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2944 | # used as a flag for many of the routines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2945 | # ie should we bother with bad values for this routine? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2946 | # 1 - yes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2947 | # 0 - no, maybe issue a warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2948 | # undef - we're not compiling with bad value support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2949 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2950 | PDL::PP::Rule->new("BadFlag", "_HandleBad", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2951 | "Sets BadFlag based upon HandleBad key and PDL's ability to handle bad values", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2952 | 2 | ▶ | sub { return (defined $_[0]) ? ($bvalflag and $_[0]) : undef; }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=17.3
Branch: 1 branch
Condition0%0/3
$bvalflag and $_[0]
MC/DC0%0/2
$bvalflag and $_[0]
$bvalflag
$_[0]
Truth table0%0/3
A and B
A= $bvalflagB= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2954 | #################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2955 | # FullDoc Handling # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2956 | #################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2958 | # Error processing: does FullDoc contain BadDoc, yet BadDoc specified? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2959 | PDL::PP::Rule::Croak->new(['FullDoc', 'BadDoc'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2960 | 'Cannot have both FullDoc and BadDoc defined'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2961 | PDL::PP::Rule::Croak->new(['FullDoc', 'Doc'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2962 | 'Cannot have both FullDoc and Doc defined'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2963 | # Note: no error processing on Pars; it's OK for the docs to gloss over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2964 | # the details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2966 | # Add the Pars section based on the signature of the FullDoc if the Pars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2967 | # section doesn't already exist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2968 | PDL::PP::Rule->new('Pars', 'FullDoc', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2969 | 'Sets the Pars from the FullDoc if Pars is not explicitly specified', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2970 | \&build_pars_from_fulldoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2971 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2972 | PDL::PP::Rule->new('OtherPars', 'FullDoc', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2973 | 'Sets the OtherPars from the FullDoc if OtherPars is not explicitly specified', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2974 | \&build_otherpars_from_fulldoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2975 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2977 | ################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2978 | # Other Documentation Handling # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2979 | ################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2981 | # no docs by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2982 | PDL::PP::Rule::Returns->new("Doc", [], 'Sets the default doc string', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2983 | "\n=for ref\n\ninfo not available\n"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2985 | # try and automate the docs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2986 | # could be really clever and include the sig to see about | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2987 | # input/output params, for instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2989 | PDL::PP::Rule->new("BadDoc", ["BadFlag","Name","_CopyBadStatusCode"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2990 | 'Sets the default documentation for handling of bad values', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2991 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2992 | 2 | ▶ | return undef unless $bvalflag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=24.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2993 | 2 | my ( $bf, $name, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2994 | 2 | my $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2995 | 2 | ▶ | if ( not defined($bf) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2996 | 2 | $str = "$name does not process bad values.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2997 | } elsif ( $bf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2998 | 0 | $str = "$name processes bad values.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2999 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3000 | 0 | $str = "$name ignores the bad-value flag of the input piddles.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3001 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3002 | 2 | ▶ | if ( not defined($code) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3003 | 2 | $str .= "It will set the bad-value flag of all output piddles if " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3004 | "the flag is set for any of the input piddles.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3005 | } elsif ( $code eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3006 | 0 | $str .= "The output piddles will NOT have their bad-value flag set.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3007 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3008 | 0 | $str .= "The state of the bad-value flag of the output piddles is unknown.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3009 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3010 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3011 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3013 | # Default: no otherpars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3014 | PDL::PP::Rule::Returns::EmptyString->new("OtherPars"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3016 | # the docs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3017 | PDL::PP::Rule->new("PdlDoc", "FullDoc", sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3018 | 0 | ▶ | my $fulldoc = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3019 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3020 | # Remove bad documentation if bad values are not supported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3021 | 0 | ▶ | $fulldoc =~ s/=for bad\n\n.*?\n\n//s unless $bvalflag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3023 | # Append a final cut if it doesn't exist due to heredoc shinanigans | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3024 | 0 | ▶ | $fulldoc .= "\n\n=cut\n" unless $fulldoc =~ /\n=cut\n*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3026 | # Make sure the =head1 FUNCTIONS section gets added | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3027 | 0 | $::DOCUMENTED++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3029 | 0 | return $fulldoc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3030 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3031 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3032 | PDL::PP::Rule->new("PdlDoc", ["Name","_Pars","OtherPars","Doc","_BadDoc"], \&GenDocs), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3033 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3034 | ################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3035 | # Done with Docs # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3036 | ################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3037 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3038 | # Notes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3039 | # Suffix 'NS' means, "Needs Substitution". In other words, the string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3040 | # associated with a key that has the suffix "NS" must be run through a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3041 | # Substitute or Substitute::Usual | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3042 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3043 | # some defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3044 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3045 | PDL::PP::Rule::Returns->new("CopyName", [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3046 | 'Sets the CopyName key to the default: __copy', "__copy"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3047 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3048 | PDL::PP::Rule->new("DefaultFlowCodeNS", "_DefaultFlow", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3049 | 'Sets the code to handle dataflow flags, if applicable', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3050 | 2 | ▶ | sub { $_[0] ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3051 | '$PRIV(flags) |= PDL_ITRANS_DO_DATAFLOW_F | PDL_ITRANS_DO_DATAFLOW_B;' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3052 | : 'PDL_COMMENT("No flow")'}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3053 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3054 | # Question: where is ppdefs defined? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3055 | # Answer: Core/Types.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3056 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3057 | PDL::PP::Rule->new("GenericTypes", [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3058 | 'Sets GenericTypes flag to all types known to PDL::Types', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3059 | 1 | ▶ | sub {[ppdefs]}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3061 | PDL::PP::Rule->new("ExtraGenericLoops", "FTypes", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3062 | 'Makes ExtraGenericLoops identical to FTypes if the latter exists and the former does not', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3063 | 0 | ▶ | sub {return $_[0]}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3064 | PDL::PP::Rule::Returns->new("ExtraGenericLoops", [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3065 | 'Sets ExtraGenericLoops to an empty hash if it does not already exist', {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3067 | PDL::PP::Rule::InsertName->new("StructName", 'pdl_${name}_struct'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3068 | PDL::PP::Rule::InsertName->new("VTableName", 'pdl_${name}_vtable'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3070 | PDL::PP::Rule->new("FHdrInfo", ["Name","StructName"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3071 | 2 | ▶ | sub { return { Name => $_[0], StructName => $_[1], }; }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3073 | # Treat exchanges as affines. Affines assumed to be parent->child. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3074 | # Exchanges may, if the want, handle threadids as well. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3075 | # Same number of dimensions is assumed, though. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3076 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3077 | 0 | ▶ | PDL::PP::Rule->new("AffinePriv", "XCHGOnly", sub { return @_; }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3078 | PDL::PP::Rule::Returns->new("Priv", "AffinePriv", 'PDL_Indx incs[$CHILD(ndims)];PDL_Indx offs; '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3079 | PDL::PP::Rule::Returns->new("IsAffineFlag", "AffinePriv", "PDL_ITRANS_ISAFFINE"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3081 | PDL::PP::Rule->new("RedoDims", ["EquivPDimExpr","FHdrInfo","_EquivDimCheck"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3082 | \&pdimexpr2priv), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3083 | PDL::PP::Rule->new("RedoDims", ["Identity","FHdrInfo"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3084 | \&identity2priv), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3086 | # NOTE: we use the same bit of code for all-good and bad data - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3087 | # see the Code rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3088 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3089 | PDL::PP::Rule->new("EquivCPOffsCode", "Identity", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3090 | "something to do with dataflow between CHILD & PARENT, I think.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3091 | \&equivcpoffscode), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3093 | PDL::PP::Rule->new("Code", ["EquivCPOffsCode","BadFlag"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3094 | "create Code from EquivCPOffsCode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3095 | \&CodefromEquivCPOffsCode), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3097 | PDL::PP::Rule->new("BackCode", ["EquivCPOffsCode","BadFlag"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3098 | "create BackCode from EquivCPOffsCode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3099 | \&BackCodefromEquivCPOffsCode), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3101 | PDL::PP::Rule::Returns::Zero->new("Affine_Ok", "EquivCPOffsCode"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3102 | PDL::PP::Rule::Returns::One->new("Affine_Ok"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3104 | PDL::PP::Rule::Returns::NULL->new("ReadDataFuncName", "AffinePriv"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3105 | PDL::PP::Rule::Returns::NULL->new("WriteBackDataFuncName", "AffinePriv"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3107 | PDL::PP::Rule::InsertName->new("ReadDataFuncName", 'pdl_${name}_readdata'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3108 | PDL::PP::Rule::InsertName->new("CopyFuncName", 'pdl_${name}_copy'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3109 | PDL::PP::Rule::InsertName->new("FreeFuncName", 'pdl_${name}_free'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3110 | PDL::PP::Rule::InsertName->new("RedoDimsFuncName", 'pdl_${name}_redodims'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3112 | # There used to be a BootStruct rule which just became copied to the XSBootCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3113 | # rule, so it has been removed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3114 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3115 | PDL::PP::Rule->new("XSBootCode", ["AffinePriv","VTableName"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3116 | 0 | ▶ | sub {return " $_[1].readdata = PDL->readdata_affine;\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3117 | " $_[1].writebackdata = PDL->writebackdata_affine;\n"}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3119 | # Parameters in the form 'parent and child(this)'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3120 | # The names are PARENT and CHILD. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3121 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3122 | # P2Child implicitly means "no data type changes". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3124 | PDL::PP::Rule->new(["USParNames","USParObjs","FOOFOONoConversion","HaveThreading","NewXSName"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3125 | ["P2Child","Name","BadFlag"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3126 | \&NewParentChildPars), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3128 | PDL::PP::Rule::InsertName->new("NewXSName", '_${name}_int'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3130 | PDL::PP::Rule::Returns->new("EquivPThreadIdExpr", "P2Child", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3131 | '$CTID-$PARENT(ndims)+$CHILD(ndims)'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3133 | PDL::PP::Rule::Returns::One->new("HaveThreading"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3135 | # Parameters in the 'a(x,y); [o]b(y)' format, with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3136 | # fixed nos of real, unthreaded-over dims. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3137 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3138 | # XXX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3139 | # - the need for BadFlag is due to hacked get_xsdatapdecl() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3140 | # in PP/PdlParObj and because the PdlParObjs are created by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3141 | # PDL::PP::Signature (Doug Burke 07/08/00) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3143 | PDL::PP::Rule->new(["USParNames","USParObjs","DimmedPars"], ["Pars","BadFlag"], \&Pars_nft), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3144 | PDL::PP::Rule->new("DimObjs", ["USParNames","USParObjs"], \&ParObjs_DimObjs), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3146 | # Set CallCopy flag for simple functions (2-arg with 0-dim signatures) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3147 | # This will copy the $object->copy method, instead of initialize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3148 | # for PDL-subclassed objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3149 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3150 | PDL::PP::Rule->new("CallCopy", ["DimObjs", "USParNames", "USParObjs", "Name", "_P2Child"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3151 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3152 | 2 | ▶ | my ($dimObj, $USParNames, $USParObjs, $Name, $hasp2c) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=21.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3153 | 2 | ▶ | return 0 if $hasp2c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3154 | 2 | my $noDimmedArgs = scalar(keys %$dimObj); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3155 | 2 | my $noArgs = scalar(@$USParNames); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3156 | 2 | ▶ | if( $noDimmedArgs == 0 and $noArgs == 2 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$noDimmedArgs == 0 and $noArgs == 2
MC/DC0%0/2
$noDimmedArgs == 0 and $noArgs == 2
$noDimmedArgs == 0
$noArgs == 2
Truth table33%1/3
A and B
A= $noDimmedArgs == 0B= $noArgs == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3157 | # Check for 2-arg functgion with 0-dim signatures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3158 | # Check to see if output arg is _not_ explicitly typed: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3159 | 0 | my $arg2 = $USParNames->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3160 | 0 | my $ParObj = $USParObjs->{$arg2}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3161 | 0 | ▶ | if( $ParObj->ctype('generic') eq 'generic'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3162 | # print "Calling Copy for function '$Name'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3163 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3166 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3167 | }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3169 | # "Other pars", the parameters which are usually not pdls. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3171 | PDL::PP::Rule->new(["OtherParNames","OtherParTypes"], ["OtherPars","DimObjs"], \&OtherPars_nft), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3173 | PDL::PP::Rule->new(["ParNames","ParObjs"], ["USParNames","USParObjs"], \&sort_pnobjs), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3175 | PDL::PP::Rule->new("DefSyms", "StructName", \&MkDefSyms), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3176 | PDL::PP::Rule->new("NewXSArgs", ["USParNames","USParObjs","OtherParNames","OtherParTypes"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3177 | \&NXArgs), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3179 | PDL::PP::Rule::Returns->new("PMCode", undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3181 | PDL::PP::Rule->new("NewXSSymTab", ["DefSyms","NewXSArgs"], \&AddArgsyms), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3183 | PDL::PP::Rule->new("InplaceCode", ["Name","NewXSArgs","USParObjs","_Inplace"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3184 | 'Insert code (just after HdrCode) to ensure the routine can be done inplace', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3185 | \&InplaceCode), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3187 | PDL::PP::Rule::Returns::EmptyString->new("HdrCode", [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3188 | 'Code that will be inserted at the end of the autogenerated xs argument processing code VargArgsXSHdr'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3191 | # Create header for variable argument list. Used if no 'other pars' specified. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3192 | # D. Hunt 4/11/00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3193 | # make sure it is not used when the GlobalNew flag is set ; CS 4/15/00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3194 | PDL::PP::Rule->new("VarArgsXSHdr", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3195 | ["Name","NewXSArgs","USParObjs","OtherParTypes", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3196 | "PMCode","HdrCode","InplaceCode","_GlobalNew","_CallCopy"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3197 | 'XS code to process arguments on stack based on supplied Pars argument to pp_def; GlobalNew has implications how/if this is done', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3198 | \&VarArgsXSHdr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3200 | ## Added new line for returning (or not returning) variables. D. Hunt 4/7/00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3201 | # make sure it is not used when the GlobalNew flag is set ; CS 4/15/00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3202 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3203 | PDL::PP::Rule->new("VarArgsXSReturn", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3204 | ["NewXSArgs","USParObjs","_GlobalNew"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3205 | "Generate XS trailer for returning output variables", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3206 | \&VarArgsXSReturn), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3208 | PDL::PP::Rule->new("NewXSHdr", ["NewXSName","NewXSArgs"], \&XSHdr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3209 | PDL::PP::Rule->new("NewXSCHdrs", ["NewXSName","NewXSArgs","GlobalNew"], \&XSCHdrs), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3210 | PDL::PP::Rule->new("NewXSLocals", "NewXSSymTab", \&Sym2Loc), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3212 | PDL::PP::Rule::Returns::Zero->new("IsAffineFlag"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3213 | PDL::PP::Rule::Returns::Zero->new("NoPdlThread"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3215 | # hmm, need to check on conditional check here (or rather, other bits of code prob need | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3216 | # to include it too; see Ops.xs, PDL::assgn) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3217 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3218 | ## sub { return (defined $_[0]) ? "int \$BADFLAGCACHE() = 0;" : ""; } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3219 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3220 | ## why have I got a "_HandleBad" condition here? it isn't used in the routine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3221 | ## and isn't required to fire the rule. Or should we actually check the value of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3222 | ## HandleBad (ie to optimize for code that explicitly doesn't handle bad code)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3223 | ## TO DO: Check assgn in ops for this? Not obvious, or at least we need other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3224 | ## bits of code work with us (eg the checking of $BADFLAGCACHE in some other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3225 | ## rule) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3226 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3227 | ## PDL::PP::Rule->new("CacheBadFlagInitNS", "_HandleBad", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3228 | ## sub { return $bvalflag ? "\n int \$BADFLAGCACHE() = 0;\n" : ""; }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3229 | PDL::PP::Rule->new("CacheBadFlagInitNS", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3230 | 2 | ▶ | sub { return $bvalflag ? "\n int \$BADFLAGCACHE() = 0;\n" : ""; }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3231 | # The next rule, if done in place of the above, causes Ops.xs to fail to compile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3232 | # PDL::PP::Rule->new("CacheBadFlagInitNS", "BadFlag", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3233 | # sub { return $_[0] ? "\n int \$BADFLAGCACHE() = 0;\n" : ""; }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3234 | PDL::PP::Rule::Substitute::Usual->new("CacheBadFlagInit", "CacheBadFlagInitNS"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3236 | # need special cases for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3237 | # a) bad values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3238 | # b) bad values + GlobalNew | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3239 | # c) bad values + PMCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3240 | # - perhaps I should have separate rules (but b and c produce the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3241 | # same output...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3242 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3243 | PDL::PP::Rule->new("NewXSStructInit0", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3244 | ["NewXSSymTab","VTableName","IsAffineFlag","NoPdlThread"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3245 | "Rule to create and initialise the private trans structure", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3246 | \&MkPrivStructInit), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3248 | PDL::PP::Rule->new("NewXSMakeNow", ["ParNames","NewXSSymTab"], \&MakeNows), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3249 | 0 | ▶ | PDL::PP::Rule->new("IgnoreTypesOf", "FTypes", sub {return {map {($_,1)} keys %{$_[0]}}}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3250 | PDL::PP::Rule::Returns->new("IgnoreTypesOf", {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3252 | PDL::PP::Rule->new("NewXSCoerceMustNS", "FTypes", \&make_newcoerce), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3253 | PDL::PP::Rule::Substitute::Usual->new("NewXSCoerceMust", "NewXSCoerceMustNS"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3255 | PDL::PP::Rule::Substitute::Usual->new("DefaultFlowCode", "DefaultFlowCodeNS"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3257 | PDL::PP::Rule->new("NewXSFindDatatypeNS", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3258 | ["ParNames","ParObjs","IgnoreTypesOf","NewXSSymTab","GenericTypes","_P2Child"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3259 | \&find_datatype), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3260 | PDL::PP::Rule::Substitute::Usual->new("NewXSFindDatatype", "NewXSFindDatatypeNS"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3262 | PDL::PP::Rule::Returns::EmptyString->new("NewXSTypeCoerce", "NoConversion"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3264 | PDL::PP::Rule->new("NewXSTypeCoerceNS", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3265 | ["ParNames","ParObjs","IgnoreTypesOf","NewXSSymTab","_P2Child"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3266 | \&coerce_types), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3267 | PDL::PP::Rule::Substitute::Usual->new("NewXSTypeCoerce", "NewXSTypeCoerceNS"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3269 | PDL::PP::Rule::Returns::EmptyString->new("NewXSStructInit1", ["ParNames","NewXSSymTab"]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3271 | PDL::PP::Rule->new("NewXSSetTrans", ["ParNames","ParObjs","NewXSSymTab"], \&makesettrans), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3273 | PDL::PP::Rule->new("ParsedCode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3274 | ["Code","_BadCode","ParNames","ParObjs","DimObjs","GenericTypes", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3275 | "ExtraGenericLoops","HaveThreading","Name"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3276 | 2 | ▶ | sub { return PDL::PP::Code->new(@_); }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3277 | PDL::PP::Rule->new("ParsedBackCode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3278 | ["BackCode","_BadBackCode","ParNames","ParObjs","DimObjs","GenericTypes", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3279 | "ExtraGenericLoops","HaveThreading","Name"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3280 | 0 | ▶ | sub { return PDL::PP::Code->new(@_, undef, undef, 'BackCode2'); }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3282 | # Compiled representations i.e. what the xsub function leaves | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3283 | # in the trans structure. By default, copies of the parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3284 | # but in many cases (e.g. slice) a benefit can be obtained | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3285 | # by parsing the string in that function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3287 | # If the user wishes to specify his own code and compiled representation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3288 | # The next two definitions allow this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3289 | # Because of substitutions that will be there, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3290 | # makecompiledrepr et al are array refs, 0th element = string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3291 | # 1th element = hashref of translated names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3292 | # This makes the objects: type + ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3293 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3294 | PDL::PP::Rule->new(["CompNames","CompObjs"], "Comp", \&OtherPars_nft), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3295 | PDL::PP::Rule->new("CompiledRepr", ["CompNames","CompObjs"], \&NT2Decls_p), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3296 | PDL::PP::Rule::MakeComp->new("MakeCompiledRepr", ["MakeComp","CompNames","CompObjs"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3297 | "COMP"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3299 | PDL::PP::Rule->new("CompCopyCode", ["CompNames","CompObjs","CopyName"], \&NT2Copies_p), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3300 | PDL::PP::Rule->new("CompFreeCode", ["CompNames","CompObjs"], \&NT2Free_p), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3302 | # This is the default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3303 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3304 | PDL::PP::Rule->new("MakeCompiledRepr", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3305 | ["OtherParNames","OtherParTypes","NewXSSymTab"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3306 | \&CopyOtherPars), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3307 | PDL::PP::Rule->new("CompiledRepr", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3308 | ["OtherParNames","OtherParTypes"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3309 | \&NT2Decls), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3310 | PDL::PP::Rule->new("CompCopyCode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3311 | ["OtherParNames","OtherParTypes","CopyName"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3312 | \&NT2Copies_p), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3313 | PDL::PP::Rule->new("CompFreeCode", ["OtherParNames","OtherParTypes"], \&NT2Free_p), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3315 | # Threads | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3316 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3317 | PDL::PP::Rule->new(["Priv","PrivIsInc"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3318 | ["ParNames","ParObjs","DimObjs","HaveThreading"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3319 | \&make_incsizes), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3320 | PDL::PP::Rule->new("PrivCopyCode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3321 | ["ParNames","ParObjs","DimObjs","CopyName","HaveThreading"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3322 | \&make_incsize_copy), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3323 | PDL::PP::Rule->new("PrivFreeCode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3324 | ["ParNames","ParObjs","DimObjs","HaveThreading"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3325 | "Frees the thread", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3326 | \&make_incsize_free), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3328 | PDL::PP::Rule::Returns->new("RedoDimsCode", [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3329 | 'Code that can be inserted to set the size of output piddles dynamically based on input piddles; is parsed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3330 | 'PDL_COMMENT("none")'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3331 | PDL::PP::Rule->new("RedoDimsParsedCode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3332 | ["RedoDimsCode","_BadRedoDimsCode","ParNames","ParObjs","DimObjs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3333 | "GenericTypes","ExtraGenericLoops","HaveThreading","Name"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3334 | 'makes the parsed representation from the supplied RedoDimsCode', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3335 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3336 | 1 | ▶ | return 'PDL_COMMENT("no RedoDimsCode")' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3337 | if $_[0] =~ m|^/[*] none [*]/$|; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3338 | 1 | PDL::PP::Code->new(@_,1); }), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3339 | PDL::PP::Rule->new("RedoDims", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3340 | ["ParNames","ParObjs","DimObjs","DimmedPars","RedoDimsParsedCode", '_NoPthread'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3341 | 'makes the redodims function from the various bits and pieces', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3342 | \&make_redodims_thread), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3344 | PDL::PP::Rule::Returns::EmptyString->new("Priv"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3346 | PDL::PP::Rule->new(["PrivNames","PrivObjs"], "Priv", \&OtherPars_nft), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3347 | PDL::PP::Rule->new("PrivateRepr", ["PrivNames","PrivObjs"], \&NT2Decls_p), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3348 | PDL::PP::Rule->new("PrivCopyCode", ["PrivNames","PrivObjs","CopyName"], \&NT2Copies_p), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3350 | # avoid clash with freecode above? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3351 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3352 | PDL::PP::Rule->new("NTPrivFreeCode", ["PrivNames","PrivObjs"], \&NT2Free_p), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3354 | PDL::PP::Rule->new("IsReversibleCodeNS", "Reversible", \&ToIsReversible), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3355 | PDL::PP::Rule::Substitute::Usual->new("IsReversibleCode", "IsReversibleCodeNS"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3357 | # Needs cleaning up. NewXSStructInit2DJB has been added to make use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3358 | # of the PDL::PP::Rule::Substitute class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3359 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3360 | PDL::PP::Rule::Substitute->new("NewXSStructInit2DJB", "MakeCompiledRepr"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3361 | PDL::PP::Rule->new("NewXSStructInit2", "NewXSStructInit2DJB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3362 | 1 | ▶ | sub { return "{".$_[0]."}"; }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3364 | PDL::PP::Rule->new("CopyCodeNS", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3365 | ["PrivCopyCode","CompCopyCode","StructName","NoPdlThread"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3366 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3367 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3368 | 1 | ▶ | "$_[2] *__copy = malloc(sizeof($_[2]));\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3369 | ($_[3] ? "" : "PDL_THR_CLRMAGIC(&__copy->__pdlthread);") . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3370 | " PDL_TR_CLRMAGIC(__copy); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3371 | __copy->has_badvalue = \$PRIV(has_badvalue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3372 | __copy->badvalue = \$PRIV(badvalue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3373 | __copy->flags = \$PRIV(flags); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3374 | __copy->vtable = \$PRIV(vtable); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3375 | __copy->__datatype = \$PRIV(__datatype); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3376 | __copy->freeproc = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3377 | __copy->__ddone = \$PRIV(__ddone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3378 | {int i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3379 | for(i=0; i<__copy->vtable->npdls; i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3380 | __copy->pdls[i] = \$PRIV(pdls[i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3382 | $_[1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3383 | if(__copy->__ddone) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3384 | $_[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3386 | return (pdl_trans*)__copy;"; }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3388 | PDL::PP::Rule->new("FreeCodeNS", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3389 | ["PrivFreeCode","CompFreeCode","NTPrivFreeCode"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3390 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3391 | 1 | ▶ | return " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3392 | PDL_TR_CLRMAGIC(__privtrans); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3393 | $_[1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3394 | if(__privtrans->__ddone) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3395 | $_[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3396 | $_[2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3398 | "; }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3400 | PDL::PP::Rule::Substitute::Usual->new("CopyCode", "CopyCodeNS"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3401 | PDL::PP::Rule::Substitute::Usual->new("FreeCode", "FreeCodeNS"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3402 | PDL::PP::Rule::Substitute::Usual->new("FooCodeSub", "FooCode"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3404 | PDL::PP::Rule::Returns::EmptyString->new("NewXSCoerceMust"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3406 | PDL::PP::Rule::MakeComp->new("NewXSCoerceMustSub1", "NewXSCoerceMust", "FOO"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3407 | PDL::PP::Rule::Substitute->new("NewXSCoerceMustSub1d", "NewXSCoerceMustSub1"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3409 | PDL::PP::Rule->new("NewXSClearThread", "HaveThreading", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3410 | 1 | ▶ | sub {$_[0] ? "__privtrans->__pdlthread.inds = 0;" : ""}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3412 | PDL::PP::Rule->new("NewXSFindBadStatusNS", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3413 | ["BadFlag","_FindBadStatusCode","NewXSArgs","USParObjs","OtherParTypes","NewXSSymTab","Name"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3414 | "Rule to find the bad value status of the input piddles", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3415 | \&findbadstatus), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3417 | # this can be removed once the default bad values are stored in a C structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3418 | # (rather than as a perl array in PDL::Types) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3419 | # which it now is, hence the comments (DJB 07/10/00) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3420 | # - left around in case we move to per-piddle bad values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3421 | # - NOTE: now we have the experimental per-piddle bad values I need to remember | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3422 | # what I was doing here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3423 | # [[NewXSCopyBadValues], [BadFlag,NewXSSymTab], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3424 | # "copybadvalues", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3425 | # "Rule to copy the default bad values into the trnas structure"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3427 | PDL::PP::Rule->new("NewXSCopyBadStatusNS", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3428 | ["BadFlag","_CopyBadStatusCode","NewXSArgs","USParObjs","NewXSSymTab"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3429 | "Rule to copy the bad value status to the output piddles", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3430 | \©badstatus), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3432 | # expand macros in ...BadStatusCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3433 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3434 | PDL::PP::Rule::Substitute::Usual->new("NewXSFindBadStatus", "NewXSFindBadStatusNS"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3435 | PDL::PP::Rule::Substitute::Usual->new("NewXSCopyBadStatus", "NewXSCopyBadStatusNS"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3437 | # Generates XS code with variable argument list. If this rule succeeds, the next rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3438 | # will not be executed. D. Hunt 4/11/00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3439 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3440 | PDL::PP::Rule->new(["NewXSCode","BootSetNewXS","NewXSInPrelude"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3441 | ["_GlobalNew","_NewXSCHdrs","VarArgsXSHdr","NewXSLocals", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3442 | "CacheBadFlagInit", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3443 | "NewXSStructInit0", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3444 | "NewXSFindBadStatus", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3445 | # NewXSCopyBadValues, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3446 | # NewXSMakeNow, # this is unnecessary since families never got implemented | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3447 | "NewXSFindDatatype","NewXSTypeCoerce", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3448 | "NewXSStructInit1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3449 | "NewXSStructInit2", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3450 | "NewXSCoerceMustSub1d","_IsReversibleCode","DefaultFlowCode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3451 | "NewXSClearThread", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3452 | "NewXSSetTrans", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3453 | "NewXSCopyBadStatus", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3454 | "VarArgsXSReturn" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3455 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3456 | "Rule to print out XS code when variable argument list XS processing is enabled", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3457 | \&mkVarArgsxscat), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3459 | # This rule will fail if the preceding rule succeeds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3460 | # D. Hunt 4/11/00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3461 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3462 | PDL::PP::Rule->new(["NewXSCode","BootSetNewXS","NewXSInPrelude"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3463 | ["_GlobalNew","_NewXSCHdrs","NewXSHdr","NewXSLocals", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3464 | "CacheBadFlagInit", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3465 | "NewXSStructInit0", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3466 | "NewXSFindBadStatus", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3467 | # NewXSCopyBadValues, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3468 | # NewXSMakeNow, # this is unnecessary since families never got implemented | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3469 | "NewXSFindDatatype","NewXSTypeCoerce", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3470 | "NewXSStructInit1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3471 | "NewXSStructInit2", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3472 | "NewXSCoerceMustSub1d","_IsReversibleCode","DefaultFlowCode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3473 | "NewXSClearThread", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3474 | "NewXSSetTrans", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3475 | "NewXSCopyBadStatus" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3476 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3477 | "Rule to print out XS code when variable argument list XS processing is disabled", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3478 | \&mkxscat), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3480 | PDL::PP::Rule->new("StructDecl", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3481 | ["ParNames","ParObjs","CompiledRepr","PrivateRepr","StructName"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3482 | \&mkstruct), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3484 | # The RedoDimsSub rule is a bit weird since it takes in the RedoDims target | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3485 | # twice (directly and via RedoDims-PostComp). Can this be cleaned up? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3486 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3487 | PDL::PP::Rule->new("RedoDims-PreComp", "RedoDims", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3488 | 1 | ▶ | sub { return $_[0] . ' $PRIV(__ddone) = 1;'; }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3489 | PDL::PP::Rule::MakeComp->new("RedoDims-PostComp", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3490 | ["RedoDims-PreComp", "PrivNames", "PrivObjs"], "PRIV"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3491 | PDL::PP::Rule->new("RedoDimsSub", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3492 | ["RedoDims", "RedoDims-PostComp", "_DimObjs"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3493 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3494 | 1 | ▶ | my $redodims = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3495 | 1 | my $result = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3496 | 1 | my $dimobjs = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3498 | $result->[1]{"SIZE"} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3499 | croak "can't get SIZE of undefined dimension (RedoDims=$redodims)." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3500 | 0 | ▶ | unless defined $dimobjs->{$redodims}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3501 | 0 | return $dimobjs->{$redodims}->get_size(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3502 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3503 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3504 | }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3505 | PDL::PP::Rule::Substitute->new("RedoDimsSubd", "RedoDimsSub"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3506 | PDL::PP::Rule->new("RedoDimsFunc", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3507 | ["RedoDimsSubd","FHdrInfo","RedoDimsFuncName","_P2Child"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3508 | 1 | ▶ | sub {wrap_vfn(@_,"redodims")}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3510 | PDL::PP::Rule::MakeComp->new("ReadDataSub", "ParsedCode", "FOO"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3511 | PDL::PP::Rule::Substitute->new("ReadDataSubd", "ReadDataSub"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3512 | PDL::PP::Rule->new("ReadDataFunc", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3513 | ["ReadDataSubd","FHdrInfo","ReadDataFuncName","_P2Child"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3514 | 1 | ▶ | sub {wrap_vfn(@_,"readdata")}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3516 | PDL::PP::Rule::MakeComp->new("WriteBackDataSub", "ParsedBackCode", "FOO"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3517 | PDL::PP::Rule::Substitute->new("WriteBackDataSubd", "WriteBackDataSub"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3519 | PDL::PP::Rule::InsertName->new("WriteBackDataFuncName", "BackCode", 'pdl_${name}_writebackdata'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3520 | PDL::PP::Rule::Returns::NULL->new("WriteBackDataFuncName", "Code"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3522 | PDL::PP::Rule->new("WriteBackDataFunc", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3523 | ["WriteBackDataSubd","FHdrInfo","WriteBackDataFuncName","_P2Child"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3524 | 0 | ▶ | sub {wrap_vfn(@_,"writebackdata")}),, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3526 | PDL::PP::Rule->new("CopyFunc", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3527 | ["CopyCode","FHdrInfo","CopyFuncName","_P2Child"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3528 | 1 | ▶ | sub {wrap_vfn(@_,"copy")}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3529 | PDL::PP::Rule->new("FreeFunc", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3530 | ["FreeCode","FHdrInfo","FreeFuncName","_P2Child"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3531 | 1 | ▶ | sub {wrap_vfn(@_,"free")}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3533 | PDL::PP::Rule::Returns->new("FoofName", "FooCodeSub", "foomethod"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3534 | PDL::PP::Rule->new("FooFunc", ["FooCodeSub","FHdrInfo","FoofName","_P2Child"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3535 | 0 | ▶ | sub {wrap_vfn(@_,"foo")}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3537 | PDL::PP::Rule::Returns::NULL->new("FoofName"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3539 | PDL::PP::Rule->new("VTableDef", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3540 | ["VTableName","StructName","RedoDimsFuncName","ReadDataFuncName", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3541 | "WriteBackDataFuncName","CopyFuncName","FreeFuncName", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3542 | "ParNames","ParObjs","Affine_Ok","FoofName"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3543 | \&def_vtable), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3545 | # Maybe accomplish this with an InsertName rule? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3546 | PDL::PP::Rule->new('PMFunc', 'Name', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3547 | 'Sets PMFunc to default symbol table manipulations', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3548 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3549 | 1 | ▶ | my ($name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3550 | 1 | $::PDL_IFBEGINWRAP[0].'*'.$name.' = \&'.$::PDLOBJ. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3551 | '::'.$name.";\n".$::PDL_IFBEGINWRAP[1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3553 | 2 | ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3555 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3557 | sub printtrans { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3558 | 0 | ▶ | my($bar) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
printtrans: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3559 | 0 | for (qw/StructDecl RedoDimsFunc ReadDataFunc WriteBackFunc | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3560 | VTableDef NewXSCode/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3561 | print "\n\n================================================ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3562 | $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3563 | 0 | ▶ | =========================================\n",$bar->{$_},"\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3567 | sub translate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3568 | 2 | ▶ | my ($pars,$tbl) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
translate: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3570 | 2 | foreach my $rule (@$tbl) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3571 | 209 | $rule->apply($pars); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3574 | # print Dumper($pars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3575 | 1 | ▶ | print "GOING OUT!\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3576 | 1 | return $pars; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3577 | } # sub: translate() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3579 | ## End | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3580 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||