gsl_cdf.pd (PDL-2.077) | : | gsl_cdf.pd (PDL-2.078) | ||
---|---|---|---|---|
skipping to change at line 143 | skipping to change at line 143 | |||
} | } | |||
@func_defs = sort { $a->[1] cmp $b->[1] } @func_defs; # sort by function name | @func_defs = sort { $a->[1] cmp $b->[1] } @func_defs; # sort by function name | |||
for my $f (@func_defs) { | for my $f (@func_defs) { | |||
my $out_type = $f->[0]; | my $out_type = $f->[0]; | |||
my $function = $f->[1]; | my $function = $f->[1]; | |||
(my $func_short = $function) =~ s/^([^_]+_[^_]+_[^_]+).*$/$1/; | (my $func_short = $function) =~ s/^([^_]+_[^_]+_[^_]+).*$/$1/; | |||
my $desc = delete $func_desc{$func_short}; | my $desc = delete $func_desc{$func_short}; | |||
my @pars = @{$f->[2]}; | my @pars = @{$f->[2]}; | |||
my ($p, $code, $badcode) = print_ppdef($out_type, $function, @pars); | my ($p, $code) = print_ppdef($out_type, $function, @pars); | |||
pp_addpm(qq{\n=head2 $desc->[0] (${func_short}_*)\n\n$desc->[1]\n\n=cut\n\n}) if $desc; | pp_addpm(qq{\n=head2 $desc->[0] (${func_short}_*)\n\n$desc->[1]\n\n=cut\n\n}) if $desc; | |||
pp_def($function, | pp_def($function, | |||
HandleBad => 1, | HandleBad => 1, | |||
GenericTypes => ['D'], | GenericTypes => ['D'], | |||
Pars => $p, | Pars => $p, | |||
Code => $code, | Code => $code, | |||
BadCode => $badcode, | ||||
Doc => '', | Doc => '', | |||
); | ); | |||
} | } | |||
sub print_ppdef { | sub print_ppdef { | |||
my ($out_type, $function, @pars) = @_; | my ($out_type, $function, @pars) = @_; | |||
my $pars = join ' ', map "@$_[0,1]();", @pars, [$out_type, '[o]out']; | ||||
my ($pars, $code, $badcode); | my $code = pp_line_numbers(__LINE__, <<EOF); | |||
for (@pars) { | ||||
my ($type, $par) = @$_; | ||||
$pars .= "$type $par(); "; | ||||
} | ||||
$pars .= "$out_type [o]out()"; | ||||
$code = pp_line_numbers(__LINE__, <<EOF); | ||||
gsl_error_handler_t *current_handler; | gsl_error_handler_t *current_handler; | |||
funcname = "$function"; | funcname = "$function"; | |||
current_handler = gsl_set_error_handler(cdf_error_handler); | current_handler = gsl_set_error_handler(cdf_error_handler); | |||
\$out() = $function( | \$out() = $function( | |||
EOF | EOF | |||
$code .= "\$" . $_->[1] . "(), " | $code .= "\$" . $_->[1] . "(), " | |||
for (@pars); | for (@pars); | |||
$code .= "); | $code .= "); | |||
gsl_set_error_handler(current_handler); | gsl_set_error_handler(current_handler); | |||
"; | "; | |||
$code =~ s/, \);/ );/; | $code =~ s/, \);/ );/; | |||
$code = | ||||
$badcode | "PDL_IF_BAD(if ( !(" . join(' && ', map { "\$ISGOOD($_->[1]())" } @pars ) . | |||
= "if ( " . join(' && ', map { "\$ISGOOD($_->[1]())" } @pars ) . " ) {\n"; | ") ) {" . | |||
$badcode .= ' ' . $code . "\n}\n"; | "\$SETBAD(out()); }" . | |||
$badcode .= "else {\n \$SETBAD(out());\n}"; | 'else,) {' . $code . "}\n"; | |||
return ($pars, $code); | ||||
# print "pp_def('$function',\n"; | ||||
# print " HandleBad => 1,\n"; | ||||
# print " GenericTypes => [D],\n"; | ||||
# print " Pars => '$pars',\n"; | ||||
# print " Code => '\n$code\n',\n"; | ||||
# print " BadCode => '\n$badcode\n',\n"; | ||||
# print " Doc => '',\n"; | ||||
# print ");\n\n"; | ||||
return ($pars, $code, $badcode); | ||||
} | } | |||
pp_addpm({At=>'Bot'},<<'EOD'); | pp_addpm({At=>'Bot'},<<'EOD'); | |||
=head1 AUTHOR | =head1 AUTHOR | |||
Copyright (C) 2009 Maggie J. Xiong <maggiexyz users.sourceforge.net> | Copyright (C) 2009 Maggie J. Xiong <maggiexyz users.sourceforge.net> | |||
The GSL CDF module was written by J. Stover. | The GSL CDF module was written by J. Stover. | |||
End of changes. 4 change blocks. | ||||
26 lines changed or deleted | 9 lines changed or added |