Skip to content
Permalink
Browse files

[sipify] Replace std::numeric_limits with old style DBL_MAX/etc

  • Loading branch information
nyalldawson committed Jun 16, 2018
1 parent 47e7a10 commit a4c8386e884c1458ffeb4ffee789f5797387a23b
@@ -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
@@ -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)

@@ -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{
@@ -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

0 comments on commit a4c8386

Please sign in to comment.
You can’t perform that action at this time.