-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pp_defc to just make obvious xform without wrapper
- Loading branch information
Showing
1 changed file
with
6 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,18 @@ | ||
sub pp_defc { | ||
my ($function, %hash) = @_; | ||
$hash{GenericTypes} ||= [qw(F D)]; | ||
my $doc = $hash{Doc} || "\n=for ref\n\nComplex version of L<PDL::LinearAlgebra::Real/$function>\n\n"; | ||
$hash{Doc} = undef; | ||
my $decl = delete $hash{_decl}; | ||
$hash{Doc} ||= "\n=for ref\n\nComplex version of L<PDL::LinearAlgebra::Real/$function>\n\n"; | ||
my $decl = delete($hash{_decl}) || ''; | ||
$decl =~ s/\$GENERIC\(\)\s*\*/void */g; # dodge float vs float complex ptr problem | ||
$hash{Code} = "$decl\n$hash{Code}"; | ||
my %hash2 = %hash; | ||
$hash2{Pars} = join ';', map s/\(2(?:,|(?=\)))/(/ ? "complex $_" : $_, split /;/, $hash2{Pars}; | ||
if ($hash2{RedoDimsCode}) { | ||
$hash{Pars} = join ';', map s/\(2(?:,|(?=\)))/(/ ? "complex $_" : $_, split /;/, $hash{Pars}; | ||
if ($hash{RedoDimsCode}) { | ||
# decrement numbers being compared to, or dims offsets | ||
$hash2{RedoDimsCode} =~ s/(>\s*)(\d+)|(\[\s*)(\d+)(\s*\])/ | ||
$hash{RedoDimsCode} =~ s/(>\s*)(\d+)|(\[\s*)(\d+)(\s*\])/ | ||
$1 | ||
? $1.($2 - 1) | ||
: $3.($4 - 1).$5 | ||
/ge; | ||
} | ||
pp_def("__Nc$function", %hash2); | ||
pp_add_exported("c$function"); | ||
my $sig = join ';', grep defined, @hash2{qw(Pars OtherPars)}; | ||
pp_addpm(<<EOF); | ||
=head2 c$function | ||
=for sig | ||
Signature: ($sig) | ||
|
||
$doc | ||
|
||
=cut | ||
|
||
sub PDL::c$function { | ||
goto &PDL::__Nc$function; | ||
} | ||
*c$function = \\&PDL::c$function; | ||
|
||
EOF | ||
pp_def("c$function", %hash); | ||
} |