Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | diff --git a/mfbt/decimal/Decimal.h b/mfbt/decimal/Decimal.h |
michael@0 | 2 | --- a/mfbt/decimal/Decimal.h |
michael@0 | 3 | +++ b/mfbt/decimal/Decimal.h |
michael@0 | 4 | @@ -26,16 +26,18 @@ |
michael@0 | 5 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 6 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 7 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 8 | */ |
michael@0 | 9 | |
michael@0 | 10 | #ifndef Decimal_h |
michael@0 | 11 | #define Decimal_h |
michael@0 | 12 | |
michael@0 | 13 | +#include "mozilla/Types.h" |
michael@0 | 14 | + |
michael@0 | 15 | #include <stdint.h> |
michael@0 | 16 | #include <wtf/Assertions.h> |
michael@0 | 17 | #include <wtf/text/WTFString.h> |
michael@0 | 18 | |
michael@0 | 19 | namespace WebCore { |
michael@0 | 20 | |
michael@0 | 21 | namespace DecimalPrivate { |
michael@0 | 22 | class SpecialValueHandler; |
michael@0 | 23 | @@ -88,92 +90,92 @@ public: |
michael@0 | 24 | FormatClass formatClass() const { return m_formatClass; } |
michael@0 | 25 | |
michael@0 | 26 | uint64_t m_coefficient; |
michael@0 | 27 | int16_t m_exponent; |
michael@0 | 28 | FormatClass m_formatClass; |
michael@0 | 29 | Sign m_sign; |
michael@0 | 30 | }; |
michael@0 | 31 | |
michael@0 | 32 | - Decimal(int32_t = 0); |
michael@0 | 33 | - Decimal(Sign, int exponent, uint64_t coefficient); |
michael@0 | 34 | - Decimal(const Decimal&); |
michael@0 | 35 | + MFBT_API Decimal(int32_t = 0); |
michael@0 | 36 | + MFBT_API Decimal(Sign, int exponent, uint64_t coefficient); |
michael@0 | 37 | + MFBT_API Decimal(const Decimal&); |
michael@0 | 38 | |
michael@0 | 39 | - Decimal& operator=(const Decimal&); |
michael@0 | 40 | - Decimal& operator+=(const Decimal&); |
michael@0 | 41 | - Decimal& operator-=(const Decimal&); |
michael@0 | 42 | - Decimal& operator*=(const Decimal&); |
michael@0 | 43 | - Decimal& operator/=(const Decimal&); |
michael@0 | 44 | + MFBT_API Decimal& operator=(const Decimal&); |
michael@0 | 45 | + MFBT_API Decimal& operator+=(const Decimal&); |
michael@0 | 46 | + MFBT_API Decimal& operator-=(const Decimal&); |
michael@0 | 47 | + MFBT_API Decimal& operator*=(const Decimal&); |
michael@0 | 48 | + MFBT_API Decimal& operator/=(const Decimal&); |
michael@0 | 49 | |
michael@0 | 50 | - Decimal operator-() const; |
michael@0 | 51 | + MFBT_API Decimal operator-() const; |
michael@0 | 52 | |
michael@0 | 53 | - bool operator==(const Decimal&) const; |
michael@0 | 54 | - bool operator!=(const Decimal&) const; |
michael@0 | 55 | - bool operator<(const Decimal&) const; |
michael@0 | 56 | - bool operator<=(const Decimal&) const; |
michael@0 | 57 | - bool operator>(const Decimal&) const; |
michael@0 | 58 | - bool operator>=(const Decimal&) const; |
michael@0 | 59 | + MFBT_API bool operator==(const Decimal&) const; |
michael@0 | 60 | + MFBT_API bool operator!=(const Decimal&) const; |
michael@0 | 61 | + MFBT_API bool operator<(const Decimal&) const; |
michael@0 | 62 | + MFBT_API bool operator<=(const Decimal&) const; |
michael@0 | 63 | + MFBT_API bool operator>(const Decimal&) const; |
michael@0 | 64 | + MFBT_API bool operator>=(const Decimal&) const; |
michael@0 | 65 | |
michael@0 | 66 | - Decimal operator+(const Decimal&) const; |
michael@0 | 67 | - Decimal operator-(const Decimal&) const; |
michael@0 | 68 | - Decimal operator*(const Decimal&) const; |
michael@0 | 69 | - Decimal operator/(const Decimal&) const; |
michael@0 | 70 | + MFBT_API Decimal operator+(const Decimal&) const; |
michael@0 | 71 | + MFBT_API Decimal operator-(const Decimal&) const; |
michael@0 | 72 | + MFBT_API Decimal operator*(const Decimal&) const; |
michael@0 | 73 | + MFBT_API Decimal operator/(const Decimal&) const; |
michael@0 | 74 | |
michael@0 | 75 | int exponent() const |
michael@0 | 76 | { |
michael@0 | 77 | ASSERT(isFinite()); |
michael@0 | 78 | return m_data.exponent(); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | bool isFinite() const { return m_data.isFinite(); } |
michael@0 | 82 | bool isInfinity() const { return m_data.isInfinity(); } |
michael@0 | 83 | bool isNaN() const { return m_data.isNaN(); } |
michael@0 | 84 | bool isNegative() const { return sign() == Negative; } |
michael@0 | 85 | bool isPositive() const { return sign() == Positive; } |
michael@0 | 86 | bool isSpecial() const { return m_data.isSpecial(); } |
michael@0 | 87 | bool isZero() const { return m_data.isZero(); } |
michael@0 | 88 | |
michael@0 | 89 | - Decimal abs() const; |
michael@0 | 90 | - Decimal ceiling() const; |
michael@0 | 91 | - Decimal floor() const; |
michael@0 | 92 | - Decimal remainder(const Decimal&) const; |
michael@0 | 93 | - Decimal round() const; |
michael@0 | 94 | + MFBT_API Decimal abs() const; |
michael@0 | 95 | + MFBT_API Decimal ceiling() const; |
michael@0 | 96 | + MFBT_API Decimal floor() const; |
michael@0 | 97 | + MFBT_API Decimal remainder(const Decimal&) const; |
michael@0 | 98 | + MFBT_API Decimal round() const; |
michael@0 | 99 | |
michael@0 | 100 | - double toDouble() const; |
michael@0 | 101 | + MFBT_API double toDouble() const; |
michael@0 | 102 | // Note: toString method supports infinity and nan but fromString not. |
michael@0 | 103 | - String toString() const; |
michael@0 | 104 | + MFBT_API String toString() const; |
michael@0 | 105 | |
michael@0 | 106 | - static Decimal fromDouble(double); |
michael@0 | 107 | + static MFBT_API Decimal fromDouble(double); |
michael@0 | 108 | // fromString supports following syntax EBNF: |
michael@0 | 109 | // number ::= sign? digit+ ('.' digit*) (exponent-marker sign? digit+)? |
michael@0 | 110 | // | sign? '.' digit+ (exponent-marker sign? digit+)? |
michael@0 | 111 | // sign ::= '+' | '-' |
michael@0 | 112 | // exponent-marker ::= 'e' | 'E' |
michael@0 | 113 | // digit ::= '0' | '1' | ... | '9' |
michael@0 | 114 | // Note: fromString doesn't support "infinity" and "nan". |
michael@0 | 115 | - static Decimal fromString(const String&); |
michael@0 | 116 | - static Decimal infinity(Sign); |
michael@0 | 117 | - static Decimal nan(); |
michael@0 | 118 | - static Decimal zero(Sign); |
michael@0 | 119 | + static MFBT_API Decimal fromString(const String&); |
michael@0 | 120 | + static MFBT_API Decimal infinity(Sign); |
michael@0 | 121 | + static MFBT_API Decimal nan(); |
michael@0 | 122 | + static MFBT_API Decimal zero(Sign); |
michael@0 | 123 | |
michael@0 | 124 | // You should not use below methods. We expose them for unit testing. |
michael@0 | 125 | - explicit Decimal(const EncodedData&); |
michael@0 | 126 | + MFBT_API explicit Decimal(const EncodedData&); |
michael@0 | 127 | const EncodedData& value() const { return m_data; } |
michael@0 | 128 | |
michael@0 | 129 | private: |
michael@0 | 130 | struct AlignedOperands { |
michael@0 | 131 | uint64_t lhsCoefficient; |
michael@0 | 132 | uint64_t rhsCoefficient; |
michael@0 | 133 | int exponent; |
michael@0 | 134 | }; |
michael@0 | 135 | |
michael@0 | 136 | - Decimal(double); |
michael@0 | 137 | - Decimal compareTo(const Decimal&) const; |
michael@0 | 138 | + MFBT_API Decimal(double); |
michael@0 | 139 | + MFBT_API Decimal compareTo(const Decimal&) const; |
michael@0 | 140 | |
michael@0 | 141 | - static AlignedOperands alignOperands(const Decimal& lhs, const Decimal& rhs); |
michael@0 | 142 | + static MFBT_API AlignedOperands alignOperands(const Decimal& lhs, const Decimal& rhs); |
michael@0 | 143 | static inline Sign invertSign(Sign sign) { return sign == Negative ? Positive : Negative; } |
michael@0 | 144 | |
michael@0 | 145 | Sign sign() const { return m_data.sign(); } |
michael@0 | 146 | |
michael@0 | 147 | EncodedData m_data; |
michael@0 | 148 | }; |
michael@0 | 149 | |
michael@0 | 150 | } // namespace WebCore |