[Webkit-unassigned] [Bug 63392] Indirectly including TextPosition.h and XPathGrammar.h causes compile errors

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jun 27 18:44:42 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=63392





--- Comment #13 from Peter Rybin <peter.rybin at gmail.com>  2011-06-27 18:44:42 PST ---
This is how merge could be done. In place of ZeroBasedNumber and OneBasedNumber the following code could be placed:

class BasedNumber {
public:
    static BasedNumber fromZeroBasedInt(int zeroBasedInt) { return BasedNumber(zeroBasedInt); }
    static BasedNumber fromOneBasedInt(int oneBasedInt) { return BasedNumber(oneBasedInt - 1); }

    BasedNumber() {}

    int zeroBasedInt() const { return m_value0; }
    int oneBasedInt() const { return m_value0 + 1; }

    int convertAsOneBasedInt() const { return m_value0 + 1; }
    int convertAsZeroBasedInt() const { return m_value0; }

    BasedNumber convertToOneBased() const { return *this; }
    BasedNumber convertToZeroBased() const { return *this; }

    bool operator==(BasedNumber other) { return m_value0 == other.m_value0; }
    bool operator!=(BasedNumber other) { return !((*this) == other); }

    static BasedNumber base() { return BasedNumber(0); }
    static BasedNumber belowBase() { return BasedNumber(-1); }

private:
    BasedNumber(int value0) : m_value0(value0) {}
    int m_value0;
};


typedef BasedNumber ZeroBasedNumber;
typedef BasedNumber OneBasedNumber;


This should compile. Obviously, this is only a first step of refactoring.
I would be happy to help doing this, but probably I'm not ready to start this whole thing myself.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list