From 54e78b62e2fc01d323896ca0cb5e6cec9983c936 Mon Sep 17 00:00:00 2001 From: Ed J Date: Thu, 11 Apr 2024 15:30:14 +0100 Subject: [PATCH] ensure dims from COMP are set first --- Basic/Gen/PP.pm | 4 ++-- Basic/Gen/PP/Dims.pm | 2 ++ Basic/Gen/PP/Signature.pm | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Basic/Gen/PP.pm b/Basic/Gen/PP.pm index 5c6746818..f146c229f 100644 --- a/Basic/Gen/PP.pm +++ b/Basic/Gen/PP.pm @@ -1479,7 +1479,7 @@ EOD PDL::PP::Rule->new("CallCopy", ["SignatureObj", "Name"], sub { my ($sig, $Name, $hasp2c) = @_; - my $noDimmedArgs = $sig->dims_count; + my $noDimmedArgs = $sig->dims_obj->ind_names; my $noArgs = @{$sig->names}; # Check for 2-arg function with 0-dim signatures return 0 if !($noDimmedArgs == 0 and $noArgs == 2); @@ -1855,7 +1855,7 @@ sub make_vfn_args { sub { "PDL_RETERROR(PDL_err, PDL->redodims_default($_[0]));\n" }), PDL::PP::Rule->new("DimsSetters", ["SignatureObj"], - sub { join "\n", sort map $_->get_initdim, $_[0]->dims_values }), + sub { $_[0]->dims_init }), PDL::PP::Rule->new("RedoDimsFuncName", [qw(Name RedoDims? RedoDimsCode? DimsSetters)], sub { (scalar grep $_ && /\S/, @_[1..$#_]) ? "pdl_$_[0]_redodims" : 'NULL'}), PDL::PP::Rule::Returns->new("RedoDimsCode", [], diff --git a/Basic/Gen/PP/Dims.pm b/Basic/Gen/PP/Dims.pm index c23b3f481..22bb007b5 100644 --- a/Basic/Gen/PP/Dims.pm +++ b/Basic/Gen/PP/Dims.pm @@ -19,6 +19,8 @@ sub get_indobj_make { sub ind_obj {$_[0]{$_[1]}} sub ind_names {keys %{$_[0]}} +sub ind_fromcomp {grep defined $_->{From}, values %{$_[0]}} +sub ind_notfromcomp {grep !defined $_->{From}, values %{$_[0]}} ##################################################################### # diff --git a/Basic/Gen/PP/Signature.pm b/Basic/Gen/PP/Signature.pm index 4b71808f1..cc0818a83 100644 --- a/Basic/Gen/PP/Signature.pm +++ b/Basic/Gen/PP/Signature.pm @@ -99,8 +99,12 @@ sub names_out_nca { my $o=$_[0]->objs; grep $o->{$_}{FlagOut} && !$o->{$_}{FlagC sub names_tmp { my $o=$_[0]->objs; grep $o->{$_}{FlagTemp}, @{$_[0]{Names}} } sub dims_obj { $_[0]->{DimsObj} } -sub dims_count { scalar keys %{$_[0]{DimsObj}} } -sub dims_values { values %{$_[0]{DimsObj}} } +sub dims_init { + my ($self) = @_; + join "\n", + (sort map $_->get_initdim, $self->{DimsObj}->ind_fromcomp), + (sort map $_->get_initdim, $self->{DimsObj}->ind_notfromcomp); +} sub othernames { my ($self, $omit_count, $with_xs, $except) = @_;