General tidy and refactoring:

* Use nullptr (C++11) instead of NULL.
* Put each file into its own namespace declaration.
* Remove "using namespace" directives and add scope qualifiers.
* Control when beast's implementation of std::equal (C++14) is used.
* Tidy up some const declarations.

Conflicts:
	src/ripple_app/shamap/SHAMapSync.cpp
	src/ripple_app/tx/TransactionEngine.cpp
This commit is contained in:
Howard Hinnant
2014-03-07 18:54:11 -05:00
committed by Vinnie Falco
parent c581ffb8a4
commit cad50c68a8
519 changed files with 3618 additions and 2726 deletions

View File

@@ -17,7 +17,7 @@
*/
//==============================================================================
void STAmount::canonicalizeRound (bool isNative, uint64& value, int& offset, bool roundUp)
void STAmount::canonicalizeRound (bool isNative, beast::uint64& value, int& offset, bool roundUp)
{
if (!roundUp) // canonicalize already rounds down
return;
@@ -72,7 +72,7 @@ STAmount STAmount::addRound (const STAmount& v1, const STAmount& v2, bool roundU
return STAmount (v1.getFName (), v1.getSNValue () + v2.getSNValue ());
int ov1 = v1.mOffset, ov2 = v2.mOffset;
int64 vv1 = static_cast<int64> (v1.mValue), vv2 = static_cast<uint64> (v2.mValue);
beast::int64 vv1 = static_cast<beast::int64> (v1.mValue), vv2 = static_cast<beast::uint64> (v2.mValue);
if (v1.mIsNegative)
vv1 = -vv1;
@@ -110,19 +110,19 @@ STAmount STAmount::addRound (const STAmount& v1, const STAmount& v2, bool roundU
++ov2;
}
int64 fv = vv1 + vv2;
beast::int64 fv = vv1 + vv2;
if ((fv >= -10) && (fv <= 10))
return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer);
else if (fv >= 0)
{
uint64 v = static_cast<uint64> (fv);
beast::uint64 v = static_cast<beast::uint64> (fv);
canonicalizeRound (false, v, ov1, roundUp);
return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer, v, ov1, false);
}
else
{
uint64 v = static_cast<uint64> (-fv);
beast::uint64 v = static_cast<beast::uint64> (-fv);
canonicalizeRound (false, v, ov1, !roundUp);
return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer, v, ov1, true);
}
@@ -142,7 +142,7 @@ STAmount STAmount::subRound (const STAmount& v1, const STAmount& v2, bool roundU
return STAmount (v1.getFName (), v1.getSNValue () - v2.getSNValue ());
int ov1 = v1.mOffset, ov2 = v2.mOffset;
int64 vv1 = static_cast<int64> (v1.mValue), vv2 = static_cast<uint64> (v2.mValue);
beast::int64 vv1 = static_cast<beast::int64> (v1.mValue), vv2 = static_cast<beast::uint64> (v2.mValue);
if (v1.mIsNegative)
vv1 = -vv1;
@@ -180,19 +180,19 @@ STAmount STAmount::subRound (const STAmount& v1, const STAmount& v2, bool roundU
++ov2;
}
int64 fv = vv1 + vv2;
beast::int64 fv = vv1 + vv2;
if ((fv >= -10) && (fv <= 10))
return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer);
else if (fv >= 0)
{
uint64 v = static_cast<uint64> (fv);
beast::uint64 v = static_cast<beast::uint64> (fv);
canonicalizeRound (false, v, ov1, roundUp);
return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer, v, ov1, false);
}
else
{
uint64 v = static_cast<uint64> (-fv);
beast::uint64 v = static_cast<beast::uint64> (-fv);
canonicalizeRound (false, v, ov1, !roundUp);
return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer, v, ov1, true);
}
@@ -206,8 +206,8 @@ STAmount STAmount::mulRound (const STAmount& v1, const STAmount& v2,
if (v1.mIsNative && v2.mIsNative && uCurrencyID.isZero ())
{
uint64 minV = (v1.getSNValue () < v2.getSNValue ()) ? v1.getSNValue () : v2.getSNValue ();
uint64 maxV = (v1.getSNValue () < v2.getSNValue ()) ? v2.getSNValue () : v1.getSNValue ();
beast::uint64 minV = (v1.getSNValue () < v2.getSNValue ()) ? v1.getSNValue () : v2.getSNValue ();
beast::uint64 maxV = (v1.getSNValue () < v2.getSNValue ()) ? v2.getSNValue () : v1.getSNValue ();
if (minV > 3000000000ull) // sqrt(cMaxNative)
throw std::runtime_error ("Native value overflow");
@@ -218,7 +218,7 @@ STAmount STAmount::mulRound (const STAmount& v1, const STAmount& v2,
return STAmount (v1.getFName (), minV * maxV);
}
uint64 value1 = v1.mValue, value2 = v2.mValue;
beast::uint64 value1 = v1.mValue, value2 = v2.mValue;
int offset1 = v1.mOffset, offset2 = v2.mOffset;
if (v1.mIsNative)
@@ -250,13 +250,13 @@ STAmount STAmount::mulRound (const STAmount& v1, const STAmount& v2,
if (resultNegative != roundUp) // rounding down is automatic when we divide
BN_add_word64 (&v, tenTo14m1);
if (BN_div_word64 (&v, tenTo14) == ((uint64) - 1))
if (BN_div_word64 (&v, tenTo14) == ((beast::uint64) - 1))
throw std::runtime_error ("internal bn error");
// 10^16 <= product <= 10^18
assert (BN_num_bytes (&v) <= 64);
uint64 amount = v.getuint64 ();
beast::uint64 amount = v.getuint64 ();
int offset = offset1 + offset2 + 14;
canonicalizeRound (uCurrencyID.isZero (), amount, offset, resultNegative != roundUp);
return STAmount (uCurrencyID, uIssuerID, amount, offset, resultNegative);
@@ -271,7 +271,7 @@ STAmount STAmount::divRound (const STAmount& num, const STAmount& den,
if (num.isZero ())
return STAmount (uCurrencyID, uIssuerID);
uint64 numVal = num.mValue, denVal = den.mValue;
beast::uint64 numVal = num.mValue, denVal = den.mValue;
int numOffset = num.mOffset, denOffset = den.mOffset;
if (num.mIsNative)
@@ -299,13 +299,13 @@ STAmount STAmount::divRound (const STAmount& num, const STAmount& den,
if (resultNegative != roundUp) // Rounding down is automatic when we divide
BN_add_word64 (&v, denVal - 1);
if (BN_div_word64 (&v, denVal) == ((uint64) - 1))
if (BN_div_word64 (&v, denVal) == ((beast::uint64) - 1))
throw std::runtime_error ("internal bn error");
// 10^16 <= quotient <= 10^18
assert (BN_num_bytes (&v) <= 64);
uint64 amount = v.getuint64 ();
beast::uint64 amount = v.getuint64 ();
int offset = numOffset - denOffset - 17;
canonicalizeRound (uCurrencyID.isZero (), amount, offset, resultNegative != roundUp);
return STAmount (uCurrencyID, uIssuerID, amount, offset, resultNegative);