Skip to content

Commit bb98bb0

Browse files
committed
Add option 'CallFQ' to pp_def
1 parent bda65d4 commit bb98bb0

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/PDL/Ops.pd

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ EOF
136136
NoBadifNaN => 1,
137137
Inplace => [ 'a' ],
138138
Overload => [$op, $mutator, $bitwise],
139+
CallFQ => 1,
139140
Code => pp_line_numbers(__LINE__, <<EOF),
140141
PDL_IF_BAD(char anybad = 0;,)
141142
broadcastloop %{

lib/PDL/PP.pm

+8-6
Original file line numberDiff line numberDiff line change
@@ -1390,10 +1390,10 @@ $PDL::PP::deftbl =
13901390
}),
13911391
PDL::PP::Rule::Returns::EmptyString->new("InplaceCode", []),
13921392
PDL::PP::Rule->new("InplaceDocValues",
1393-
[qw(Name SignatureObj InplaceNormalised)],
1393+
[qw(Name SignatureObj InplaceNormalised CallFQ?)],
13941394
'doc describing usage inplace',
13951395
sub {
1396-
my ($name, $sig, $inplace) = @_;
1396+
my ($name, $sig, $inplace, $call_fq) = @_;
13971397
my @args = @{ $sig->args_callorder };
13981398
my %inplace_involved = map +($_=>1), my ($in, $out) = @$inplace;
13991399
my $meth_call = $args[0] eq $in;
@@ -1403,7 +1403,8 @@ $PDL::PP::deftbl =
14031403
!@args ? '' : "(@{[join ',', map qq{\$$_}, @args]})"
14041404
).";", []
14051405
];
1406-
push @vals, [ "$name(\$$in->inplace".(
1406+
my $prefix = $call_fq ? "$::PDLOBJ\::" : "";
1407+
push @vals, [ "$prefix$name(\$$in->inplace".(
14071408
!@args ? '' : ",@{[join ',', map qq{\$$_}, @args]}"
14081409
).");", []];
14091410
$vals[0][1] = ["can be used inplace"];
@@ -1475,12 +1476,12 @@ EOF
14751476

14761477
PDL::PP::Rule->new([qw(UsageDoc ParamDoc)],
14771478
[qw(Name Doc? SignatureObj OtherParsDefaults? ArgOrder?
1478-
OverloadDocValues InplaceDocValues ParamDesc? Lvalue?
1479+
OverloadDocValues InplaceDocValues ParamDesc? Lvalue? CallFQ?
14791480
)],
14801481
'generate "usage" section of doc',
14811482
sub {
14821483
my ($name, $doc, $sig, $otherdefaults, $argorder,
1483-
$overloadvals, $inplacevals, $paramdesc, $lvalue,
1484+
$overloadvals, $inplacevals, $paramdesc, $lvalue, $call_fq,
14841485
) = @_;
14851486
$otherdefaults ||= {};
14861487
$paramdesc ||= {};
@@ -1523,10 +1524,11 @@ EOF
15231524
push @argsets, [\@args, [], ['all arguments given']];
15241525
}
15251526
my @invocs = @$overloadvals;
1527+
my $prefix = $call_fq ? "$::PDLOBJ\::" : "";
15261528
push @invocs, map [(!@{$_->[1]} ? '' :
15271529
@{$_->[1]} == 1 ? "\$$_->[1][0] = " :
15281530
"(".join(", ", map "\$$_", @{$_->[1]}).") = "
1529-
)."$name(".join(", ", map "\$$_", @{$_->[0]}).");",
1531+
)."$prefix$name(".join(", ", map "\$$_", @{$_->[0]}).");",
15301532
[@{$_->[2]}]], @argsets;
15311533
$argsets[0][2] = ['method call'];
15321534
$argsets[$_][2] = [] for 1..$#argsets; # they get the idea

0 commit comments

Comments
 (0)