Skip to content

Commit

Permalink
pp_defc to just make obvious xform without wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Jan 4, 2025
1 parent 6ab5286 commit e3d176d
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions pp_defc.pl
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);
}

0 comments on commit e3d176d

Please sign in to comment.