Bug 620604 - Description of "histogram" procedure is slightly inaccurate
Fix totally broken value ranges of integer PDB parameters. Magically, the bug was affecting only exactly the two cases mentioned in above bug report. * tools/pdbgen/pdb.pl (arg_parse): return <, <=, > and >= literally instead of applying a mapping that was originally meant for generated C code that would e.g. transform "0 <= int32 < 10" into "if (value < 0 || value >= 10) fail". This inversion of all operators is now wrong because PDB parameters have been turned into GParamSpecs which always need inclusive ranges as min and max values. * tools/pdbgen/pdbgen.pl (arrayexpand): generated array length type specs must be "0 <= int32", not "0 < int32". * tools/pdbgen/app.pl: when generating integer param specs, check if the value range is specified in terms of < instead of <=, and add/subtract 1, resuting in the inclusive range needed for integer GParamSpecs. * app/pdb/color-cmds.c: regenerated, fixing the two broken ranges mentioned in the bug report.
This commit is contained in:
parent
2e08321691
commit
9dd373d86e
4 changed files with 41 additions and 25 deletions
|
|
@ -1116,13 +1116,13 @@ register_color_procs (GimpPDB *pdb)
|
|||
gimp_param_spec_int32 ("start-range",
|
||||
"start range",
|
||||
"Start of the intensity measurement range",
|
||||
0, 256, 0,
|
||||
0, 255, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_int32 ("end-range",
|
||||
"end range",
|
||||
"End of the intensity measurement range",
|
||||
0, 256, 0,
|
||||
0, 255, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_double ("mean",
|
||||
|
|
|
|||
|
|
@ -324,8 +324,18 @@ g_param_spec_double ("$name",
|
|||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'int32') {
|
||||
$min = defined $typeinfo[0] ? $typeinfo[0] : G_MININT32;
|
||||
$max = defined $typeinfo[2] ? $typeinfo[2] : G_MAXINT32;
|
||||
if (defined $typeinfo[0]) {
|
||||
$min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
|
||||
}
|
||||
else {
|
||||
$min = G_MININT32;
|
||||
}
|
||||
if (defined $typeinfo[2]) {
|
||||
$max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
|
||||
}
|
||||
else {
|
||||
$max = G_MAXINT32;
|
||||
}
|
||||
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0;
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_int32 ("$name",
|
||||
|
|
@ -336,8 +346,18 @@ gimp_param_spec_int32 ("$name",
|
|||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'int16') {
|
||||
$min = defined $typeinfo[0] ? $typeinfo[0] : G_MININT16;
|
||||
$max = defined $typeinfo[2] ? $typeinfo[2] : G_MAXINT16;
|
||||
if (defined $typeinfo[0]) {
|
||||
$min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
|
||||
}
|
||||
else {
|
||||
$min = G_MININT16;
|
||||
}
|
||||
if (defined $typeinfo[2]) {
|
||||
$max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
|
||||
}
|
||||
else {
|
||||
$max = G_MAXINT16;
|
||||
}
|
||||
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0;
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_int16 ("$name",
|
||||
|
|
@ -348,8 +368,18 @@ gimp_param_spec_int16 ("$name",
|
|||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'int8') {
|
||||
$min = defined $typeinfo[0] ? $typeinfo[0] : 0;
|
||||
$max = defined $typeinfo[2] ? $typeinfo[2] : G_MAXUINT8;
|
||||
if (defined $typeinfo[0]) {
|
||||
$min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
|
||||
}
|
||||
else {
|
||||
$min = 0;
|
||||
}
|
||||
if (defined $typeinfo[2]) {
|
||||
$max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
|
||||
}
|
||||
else {
|
||||
$max = G_MAXUINT8;
|
||||
}
|
||||
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0;
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_int8 ("$name",
|
||||
|
|
|
|||
|
|
@ -228,20 +228,6 @@ package Gimp::CodeGen::pdb;
|
|||
|
||||
# Split out the parts of an arg constraint
|
||||
sub arg_parse {
|
||||
my %premap = (
|
||||
'<' => '<=',
|
||||
'>' => '>=',
|
||||
'<=' => '<',
|
||||
'>=' => '>'
|
||||
);
|
||||
|
||||
my %postmap = (
|
||||
'<' => '>=',
|
||||
'>' => '<=',
|
||||
'<=' => '>',
|
||||
'>=' => '<'
|
||||
);
|
||||
|
||||
my $arg = shift;
|
||||
|
||||
if ($arg =~ /^enum (\w+)(.*)/) {
|
||||
|
|
@ -264,7 +250,7 @@ sub arg_parse {
|
|||
\s* (\w+) \s*
|
||||
(?:(<=|<) \s* ([+-.\dA-Z_][^\s]*))?
|
||||
/x) {
|
||||
return ($3, $1, $2 ? $premap{$2} : $2, $5, $4 ? $postmap{$4} : $4);
|
||||
return ($3, $1, $2, $5, $4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,10 +164,10 @@ sub arrayexpand {
|
|||
|
||||
# We can't have negative lengths, but let them set a min number
|
||||
unless (exists $arg->{type}) {
|
||||
$arg->{type} = '0 < int32';
|
||||
$arg->{type} = '0 <= int32';
|
||||
}
|
||||
elsif ($arg->{type} !~ /^\s*\d+\s*</) {
|
||||
$arg->{type} = '0 < ' . $arg->{type};
|
||||
$arg->{type} = '0 <= ' . $arg->{type};
|
||||
}
|
||||
|
||||
$arg->{void_ret} = 1 if exists $_->{void_ret};
|
||||
|
|
|
|||
Loading…
Reference in a new issue