Skip to content

Commit

Permalink
[sipify] Replace std::numeric_limits with old style DBL_MAX/etc
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 16, 2018
1 parent 47e7a10 commit a4c8386
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Expand Up @@ -1264,8 +1264,8 @@ to determine what units the distance values are in.
const QVariant &defaultValue = QVariant(),
const QString &parentParameterName = QString(),
bool optional = false,
double minValue = std::numeric_limits<double>::lowest() + 1,
double maxValue = std::numeric_limits<double>::max() );
double minValue = -DBL_MAX + 1,
double maxValue = DBL_MAX );
%Docstring
Constructor for QgsProcessingParameterDistance.
%End
Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/qgis.sip.in
Expand Up @@ -100,7 +100,7 @@ Returns a string representation of a double
:param precision: number of decimal places to retain
%End

bool qgsDoubleNear( double a, double b, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
bool qgsDoubleNear( double a, double b, double epsilon = 4 * DBL_EPSILON );
%Docstring
Compare two doubles (but allow some difference)

Expand Down
9 changes: 9 additions & 0 deletions scripts/sipify.pl
Expand Up @@ -432,6 +432,14 @@ sub fix_annotations {
return $line;
}

sub fix_constants {
my $line = $_[0];
$line =~ s/\bstd::numeric_limits<double>::max\(\)/DBL_MAX/;
$line =~ s/\bstd::numeric_limits<double>::lowest\(\)/-DBL_MAX/;
$line =~ s/\bstd::numeric_limits<double>::epsilon\(\)/DBL_EPSILON/;
return $line;
}

# detect a comment block, return 1 if found
# if STRICT comment block shall begin at beginning of line (no code in front)
sub detect_comment_block{
Expand Down Expand Up @@ -1087,6 +1095,7 @@ sub detect_non_method_member{
$IS_OVERRIDE = 0;
}

$LINE = fix_constants($LINE);
$LINE = fix_annotations($LINE);

# fix astyle placing space after % character
Expand Down

0 comments on commit a4c8386

Please sign in to comment.