From 9740b994a4376ac82f82e0437a9cfe702156f98f Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 11 Feb 2013 21:42:02 -0800 Subject: [PATCH 1/2] Tiny cleanup. --- src/cpp/ripple/TaggedCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/ripple/TaggedCache.h b/src/cpp/ripple/TaggedCache.h index 7b373acf27..627361eeee 100644 --- a/src/cpp/ripple/TaggedCache.h +++ b/src/cpp/ripple/TaggedCache.h @@ -56,7 +56,7 @@ protected: mutable boost::recursive_mutex mLock; std::string mName; // Used for logging - unsigned int mTargetSize; // Desired number of cache entries (0 = ignore) + int mTargetSize; // Desired number of cache entries (0 = ignore) int mTargetAge; // Desired maximum cache age int mCacheCount; // Number of items cached From 33154e4ef52218070585a8f4f581c5d3f8603290 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 11 Feb 2013 22:01:55 -0800 Subject: [PATCH 2/2] Two more missing constructor bugs. Cleanup. --- src/cpp/ripple/SerializedTypes.h | 45 +++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/cpp/ripple/SerializedTypes.h b/src/cpp/ripple/SerializedTypes.h index de87ed0ecf..89b687c9a9 100644 --- a/src/cpp/ripple/SerializedTypes.h +++ b/src/cpp/ripple/SerializedTypes.h @@ -233,6 +233,20 @@ protected: : SerializedType(name), mCurrency(cur), mIssuer(iss), mValue(val), mOffset(off), mIsNative(isNat), mIsNegative(isNeg) { ; } + void set(int64_t v) + { + if (v < 0) + { + mIsNegative = true; + mValue = static_cast(-v); + } + else + { + mIsNegative = false; + mValue = static_cast(v); + } + } + public: static const int cMinOffset = -96, cMaxOffset = 80; static const uint64 cMinValue = 1000000000000000ull, cMaxValue = 9999999999999999ull; @@ -249,28 +263,33 @@ public: : SerializedType(n), mValue(v), mOffset(0), mIsNative(true), mIsNegative(isNeg) { ; } - STAmount(SField::ref n, int64 v) - : SerializedType(n), mOffset(0), mIsNative(true), mIsNegative(false) - { - if (v < 0) - { - mIsNegative = true; - mValue = static_cast(-v); - } - else - mValue = static_cast(v); - } + STAmount(SField::ref n, int64 v) : SerializedType(n), mOffset(0), mIsNative(true) + { set(v); } - STAmount(const uint160& uCurrencyID, const uint160& uIssuerID, uint64 uV = 0, int iOff = 0, bool bNegative = false) + STAmount(const uint160& uCurrencyID, const uint160& uIssuerID, + uint64 uV = 0, int iOff = 0, bool bNegative = false) : mCurrency(uCurrencyID), mIssuer(uIssuerID), mValue(uV), mOffset(iOff), mIsNegative(bNegative) { canonicalize(); } - // YYY This should probably require issuer too. STAmount(SField::ref n, const uint160& currency, const uint160& issuer, uint64 v = 0, int off = 0, bool isNeg = false) : SerializedType(n), mCurrency(currency), mIssuer(issuer), mValue(v), mOffset(off), mIsNegative(isNeg) { canonicalize(); } + STAmount(const uint160& uCurrencyID, const uint160& uIssuerID, int64 v, int iOff = 0) + : mCurrency(uCurrencyID), mIssuer(uIssuerID), mOffset(iOff) + { + set(v); + canonicalize(); + } + + STAmount(SField::ref n, const uint160& currency, const uint160& issuer, int64 v, int off = 0) + : SerializedType(n), mCurrency(currency), mIssuer(issuer), mOffset(off) + { + set(v); + canonicalize(); + } + STAmount(SField::ref, const Json::Value&); static STAmount createFromInt64(SField::ref n, int64 v);