PdlParObj.pm (PDL-2.080) | : | PdlParObj.pm (PDL-2.081) | ||
---|---|---|---|---|
skipping to change at line 14 | skipping to change at line 14 | |||
use warnings; | use warnings; | |||
use Carp; | use Carp; | |||
use PDL::Types ':All'; | use PDL::Types ':All'; | |||
our %INVALID_PAR = map +($_=>1), qw( | our %INVALID_PAR = map +($_=>1), qw( | |||
I | I | |||
); | ); | |||
my $typeregex = join '|', map $_->ppforcetype, types; | my $typeregex = join '|', map $_->ppforcetype, types; | |||
my $complex_regex = join '|', qw(real complex); | my $complex_regex = join '|', qw(real complex); | |||
our $sqbr_re = qr/\[([^]]*)\]/x; | ||||
our $pars_re = qr/^ | our $pars_re = qr/^ | |||
\s*(?:($complex_regex|$typeregex)\b([+]*)|)\s* # $1,2: first option then plus | \s*(?:($complex_regex|$typeregex)\b([+]*)|)\s* # $1,2: first option then plus | |||
(?: | (?:$sqbr_re)?\s* # $3: The initial [option] part | |||
\[([^]]*)\] # $3: The initial [option] part | (\w+) # $4: The name | |||
)?\s* | \(([^)]*)\) # $5: The indices | |||
(\w+) # $4: The name | ||||
\(([^)]*)\) # $5: The indices | ||||
/x; | /x; | |||
my %flag2info = ( | my %flag2info = ( | |||
io => [[qw(FlagW)]], | io => [[qw(FlagW)]], | |||
nc => [[qw(FlagNCreat)]], | nc => [[qw(FlagNCreat)]], | |||
o => [[qw(FlagOut FlagCreat FlagW)]], | o => [[qw(FlagOut FlagCreat FlagW)]], | |||
oca => [[qw(FlagOut FlagCreat FlagW FlagCreateAlways)]], | oca => [[qw(FlagOut FlagCreat FlagW FlagCreateAlways)]], | |||
t => [[qw(FlagTemp FlagCreat FlagW)]], | t => [[qw(FlagTemp FlagCreat FlagW)]], | |||
phys => [[qw(FlagPhys)]], | phys => [[qw(FlagPhys)]], | |||
real => [[qw(FlagReal)]], | real => [[qw(FlagReal)]], | |||
complex => [[qw(FlagComplex)]], | complex => [[qw(FlagComplex)]], | |||
skipping to change at line 54 | skipping to change at line 53 | |||
FlagIgnore PDL_PARAM_ISIGNORE | FlagIgnore PDL_PARAM_ISIGNORE | |||
); | ); | |||
sub new { | sub new { | |||
my($type,$string,$badflag,$sig) = @_; | my($type,$string,$badflag,$sig) = @_; | |||
$badflag ||= 0; | $badflag ||= 0; | |||
my $this = bless {Number => "PDL_UNDEF_NUMBER", BadFlag => $badflag, Sig => $sig},$type; | my $this = bless {Number => "PDL_UNDEF_NUMBER", BadFlag => $badflag, Sig => $sig},$type; | |||
# Parse the parameter string. Note that the regexes for this match were | # Parse the parameter string. Note that the regexes for this match were | |||
# originally defined here, but were moved to PDL::PP for FullDoc parsing. | # originally defined here, but were moved to PDL::PP for FullDoc parsing. | |||
$string =~ $pars_re | $string =~ $pars_re | |||
or confess "Invalid pdl def $string (regex $pars_re)\n"; | or confess "Invalid pdl def $string (regex $pars_re)\n"; | |||
my($opt1,$opt_plus,$opt2,$name,$inds) = map $_ // '', ($1,$2,$3,$4,$5); | my($opt1,$opt_plus,$sqbr_opt,$name,$inds) = map $_ // '', $1,$2,$3,$4,$5; | |||
print "PDL: '$opt1$opt_plus', '$opt2', '$name', '$inds'\n" | print "PDL: '$opt1$opt_plus', '$sqbr_opt', '$name', '$inds'\n" | |||
if $::PP_VERBOSE; | if $::PP_VERBOSE; | |||
croak "Invalid Pars name: $name" | croak "Invalid Pars name: $name" | |||
if $INVALID_PAR{$name}; | if $INVALID_PAR{$name}; | |||
# Set my internal variables | # Set my internal variables | |||
$this->{Name} = $name; | $this->{Name} = $name; | |||
$this->{Flags} = [(split ',',$opt2),($opt1?$opt1:())]; | $this->{Flags} = [(split ',',$sqbr_opt),($opt1?$opt1:())]; | |||
for(@{$this->{Flags}}) { | for(@{$this->{Flags}}) { | |||
confess("Invalid flag $_ given for $string\n") | confess("Invalid flag $_ given for $string\n") | |||
unless my ($set, $store) = @{ $flag2info{$_} || [] }; | unless my ($set, $store) = @{ $flag2info{$_} || [] }; | |||
$this->{$store} = $_ if $store; | $this->{$store} = $_ if $store; | |||
$this->{$_} = 1 for @$set; | $this->{$_} = 1 for @$set; | |||
} | } | |||
if ($this->{FlagTyped} && $opt_plus) { | if ($this->{FlagTyped} && $opt_plus) { | |||
$this->{FlagTplus} = 1; | $this->{FlagTplus} = 1; | |||
} | } | |||
$this->{Type} &&= PDL::Type->new($this->{Type}); | $this->{Type} &&= PDL::Type->new($this->{Type}); | |||
End of changes. 4 change blocks. | ||||
8 lines changed or deleted | 7 lines changed or added |