mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-392 cleaning code for proper exports in libraries/urename.h generation
X-SVN-Rev: 6384
This commit is contained in:
parent
41ead0259d
commit
e15e833b00
8 changed files with 97 additions and 100 deletions
|
@ -31,8 +31,8 @@
|
|||
|
||||
/* prototypes ------------------------------------------------------------- */
|
||||
|
||||
#define DATA_NAME "unames"
|
||||
#define DATA_TYPE "dat"
|
||||
static const char DATA_NAME[] = "unames";
|
||||
static const char DATA_TYPE[] = "dat";
|
||||
|
||||
#define GROUP_SHIFT 5
|
||||
#define LINES_PER_GROUP (1UL<<GROUP_SHIFT)
|
||||
|
@ -130,7 +130,7 @@ enumAlgNames(AlgorithmicRange *range,
|
|||
static UChar32
|
||||
findAlgName(AlgorithmicRange *range, UCharNameChoice nameChoice, const char *otherName);
|
||||
|
||||
U_CFUNC UBool
|
||||
static UBool
|
||||
findNameDummy(void *context,
|
||||
UChar32 code, UCharNameChoice nameChoice,
|
||||
const char *name, UTextOffset length);
|
||||
|
@ -1180,7 +1180,7 @@ findAlgName(AlgorithmicRange *range, UCharNameChoice nameChoice, const char *oth
|
|||
}
|
||||
|
||||
/* this is a dummy function that is used as a "find not enumerate" flag */
|
||||
U_CFUNC UBool
|
||||
static UBool
|
||||
findNameDummy(void *context,
|
||||
UChar32 code, UCharNameChoice nameChoice,
|
||||
const char *name, UTextOffset length) {
|
||||
|
|
|
@ -160,7 +160,7 @@ llong& llong::operator/=(const llong& rhs)
|
|||
llong r;
|
||||
llong m((int32_t)1);
|
||||
|
||||
while (ule(b, a)) { // a positive so topmost bit is 0, this will always terminate
|
||||
while (b.ule(a)) { // a positive so topmost bit is 0, this will always terminate
|
||||
m <<= 1;
|
||||
b <<= 1;
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ static const uint8_t digitInfo[] = {
|
|||
0xa1u, 0xa2u, 0xa3u, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
llong atoll(const char* str, uint32_t radix)
|
||||
llong llong::atoll(const char* str, uint32_t radix)
|
||||
{
|
||||
if (radix > 36) {
|
||||
radix = 36;
|
||||
|
@ -240,7 +240,7 @@ llong atoll(const char* str, uint32_t radix)
|
|||
return result;
|
||||
}
|
||||
|
||||
llong u_atoll(const UChar* str, uint32_t radix)
|
||||
llong llong::u_atoll(const UChar* str, uint32_t radix)
|
||||
{
|
||||
if (radix > 36) {
|
||||
radix = 36;
|
||||
|
@ -267,7 +267,7 @@ llong u_atoll(const UChar* str, uint32_t radix)
|
|||
return result;
|
||||
}
|
||||
|
||||
uint32_t lltoa(const llong& val, char* buf, uint32_t len, uint32_t radix, UBool raw)
|
||||
uint32_t llong::lltoa(char* buf, uint32_t len, uint32_t radix, UBool raw) const
|
||||
{
|
||||
if (radix > 36) {
|
||||
radix = 36;
|
||||
|
@ -277,7 +277,7 @@ uint32_t lltoa(const llong& val, char* buf, uint32_t len, uint32_t radix, UBool
|
|||
llong base(radix);
|
||||
|
||||
char* p = buf;
|
||||
llong w(val);
|
||||
llong w(*this);
|
||||
if (len && w.isNegative()) {
|
||||
w.negate();
|
||||
*p++ = kMinus;
|
||||
|
@ -287,7 +287,7 @@ uint32_t lltoa(const llong& val, char* buf, uint32_t len, uint32_t radix, UBool
|
|||
while (len && w.notZero()) {
|
||||
llong n = w / base;
|
||||
llong m = n * base;
|
||||
int32_t d = llong_asInt(w-m);
|
||||
int32_t d = (w-m).asInt();
|
||||
*p++ = raw ? (char)d : asciiDigits[d];
|
||||
w = n;
|
||||
--len;
|
||||
|
@ -310,7 +310,7 @@ uint32_t lltoa(const llong& val, char* buf, uint32_t len, uint32_t radix, UBool
|
|||
return len;
|
||||
}
|
||||
|
||||
uint32_t u_lltoa(const llong& val, UChar* buf, uint32_t len, uint32_t radix, UBool raw)
|
||||
uint32_t llong::u_lltoa(UChar* buf, uint32_t len, uint32_t radix, UBool raw) const
|
||||
{
|
||||
if (radix > 36) {
|
||||
radix = 36;
|
||||
|
@ -320,7 +320,7 @@ uint32_t u_lltoa(const llong& val, UChar* buf, uint32_t len, uint32_t radix, UBo
|
|||
llong base(radix);
|
||||
|
||||
UChar* p = buf;
|
||||
llong w(val);
|
||||
llong w(*this);
|
||||
if (len && w.isNegative()) {
|
||||
w.negate();
|
||||
*p++ = kUMinus;
|
||||
|
@ -330,7 +330,7 @@ uint32_t u_lltoa(const llong& val, UChar* buf, uint32_t len, uint32_t radix, UBo
|
|||
while (len && w.notZero()) {
|
||||
llong n = w / base;
|
||||
llong m = n * base;
|
||||
int32_t d = llong_asInt(w-m);
|
||||
int32_t d = (w-m).asInt();
|
||||
*p++ = (UChar)(raw ? d : asciiDigits[d]);
|
||||
w = n;
|
||||
--len;
|
||||
|
|
|
@ -71,14 +71,14 @@ public:
|
|||
// operator const uint32_t() const;
|
||||
// operator const double() const;
|
||||
|
||||
friend int32_t llong_asInt(const llong& lhs);
|
||||
friend uint32_t llong_asUInt(const llong& lhs);
|
||||
friend double llong_asDouble(const llong& lhs);
|
||||
inline int32_t asInt() const;
|
||||
inline uint32_t asUInt() const;
|
||||
inline double asDouble() const;
|
||||
|
||||
llong& operator=(const llong& rhs) { lo = rhs.lo; hi = rhs.hi; return *this; }
|
||||
inline llong& operator=(const llong& rhs) { lo = rhs.lo; hi = rhs.hi; return *this; }
|
||||
|
||||
// left shift
|
||||
llong& operator<<=(int32_t shift) {
|
||||
inline llong& operator<<=(int32_t shift) {
|
||||
shift &= 63; // like java spec
|
||||
if (shift < 32) {
|
||||
hi = (int32_t)(hi << shift | lo >> (32 - shift)); // no sign extension on lo since unsigned
|
||||
|
@ -89,10 +89,10 @@ public:
|
|||
}
|
||||
return *this;
|
||||
}
|
||||
llong operator<<(int32_t shift) const { llong r(*this); r <<= shift; return r; }
|
||||
inline llong operator<<(int32_t shift) const { llong r(*this); r <<= shift; return r; }
|
||||
|
||||
// right shift with sign extension
|
||||
llong& operator>>=(int32_t shift) {
|
||||
inline llong& operator>>=(int32_t shift) {
|
||||
shift &= 63; // like java spec
|
||||
if (shift < 32) {
|
||||
lo >>= shift;
|
||||
|
@ -104,31 +104,31 @@ public:
|
|||
}
|
||||
return *this;
|
||||
}
|
||||
llong operator>>(int32_t shift) const { llong r(*this); r >>= shift; return r; }
|
||||
inline llong operator>>(int32_t shift) const { llong r(*this); r >>= shift; return r; }
|
||||
|
||||
// unsigned right shift
|
||||
friend llong ushr(const llong& lhs, int32_t shift);
|
||||
inline llong ushr(int32_t shift) const;
|
||||
|
||||
// bit operations
|
||||
friend llong operator&(const llong& lhs, const llong& rhs);
|
||||
friend llong operator|(const llong& lhs, const llong& rhs);
|
||||
friend llong operator^(const llong& lhs, const llong& rhs);
|
||||
inline llong operator&(const llong& rhs) const;
|
||||
inline llong operator|(const llong& rhs) const;
|
||||
inline llong operator^(const llong& rhs) const;
|
||||
|
||||
friend llong operator&(const llong& lhs, const uint32_t rhs);
|
||||
friend llong operator|(const llong& lhs, const uint32_t rhs);
|
||||
friend llong operator^(const llong& lhs, const uint32_t rhs);
|
||||
inline llong operator&(const uint32_t rhs) const;
|
||||
inline llong operator|(const uint32_t rhs) const;
|
||||
inline llong operator^(const uint32_t rhs) const;
|
||||
|
||||
llong operator~() const { return llong(~hi, ~lo); }
|
||||
// is this useful?
|
||||
// UBool operator!() const { return !(hi | lo); }
|
||||
|
||||
llong& operator&=(const llong& rhs) { hi &= rhs.hi; lo &= rhs.lo; return *this; }
|
||||
llong& operator|=(const llong& rhs) { hi |= rhs.hi; lo |= rhs.lo; return *this; }
|
||||
llong& operator^=(const llong& rhs) { hi ^= rhs.hi; lo ^= rhs.lo; return *this; }
|
||||
inline llong& operator&=(const llong& rhs) { hi &= rhs.hi; lo &= rhs.lo; return *this; }
|
||||
inline llong& operator|=(const llong& rhs) { hi |= rhs.hi; lo |= rhs.lo; return *this; }
|
||||
inline llong& operator^=(const llong& rhs) { hi ^= rhs.hi; lo ^= rhs.lo; return *this; }
|
||||
|
||||
llong& operator&=(const uint32_t rhs) { hi = 0; lo &= rhs; return *this; }
|
||||
llong& operator|=(const uint32_t rhs) { lo |= rhs; return *this; }
|
||||
llong& operator^=(const uint32_t rhs) { lo ^= rhs; return *this; }
|
||||
inline llong& operator&=(const uint32_t rhs) { hi = 0; lo &= rhs; return *this; }
|
||||
inline llong& operator|=(const uint32_t rhs) { lo |= rhs; return *this; }
|
||||
inline llong& operator^=(const uint32_t rhs) { lo ^= rhs; return *this; }
|
||||
|
||||
// no logical ops since we can't enforce order of evaluation, not much use anyway?
|
||||
|
||||
|
@ -149,10 +149,10 @@ public:
|
|||
inline UBool operator<=(const int32_t rhs) const;
|
||||
|
||||
// unsigned comparison
|
||||
friend UBool ugt(const llong& lhs, const llong& rhs);
|
||||
friend UBool ult(const llong& lhs, const llong& rhs);
|
||||
friend UBool uge(const llong& lhs, const llong& rhs);
|
||||
friend UBool ule(const llong& lhs, const llong& rhs);
|
||||
inline UBool ugt(const llong& rhs) const;
|
||||
inline UBool ult(const llong& rhs) const;
|
||||
inline UBool uge(const llong& rhs) const;
|
||||
inline UBool ule(const llong& rhs) const;
|
||||
|
||||
// prefix inc/dec
|
||||
llong& operator++() { if (!++lo) ++hi; return *this; }
|
||||
|
@ -180,22 +180,21 @@ public:
|
|||
inline llong operator/(const llong& rhs) const { llong r(*this); r /= rhs; return r; }
|
||||
|
||||
llong& operator%=(const llong& rhs) { return operator-=((*this / rhs) * rhs); }
|
||||
inline llong operator%(const llong& rhs) const { llong r(*this); r %= rhs; return
|
||||
r; }
|
||||
inline llong operator%(const llong& rhs) const { llong r(*this); r %= rhs; return r; }
|
||||
|
||||
// power function, positive integral powers only
|
||||
friend llong llong_pow(const llong& lhs, uint32_t n);
|
||||
inline llong pow(uint32_t n) const;
|
||||
|
||||
// absolute value
|
||||
friend llong llong_abs(const llong& lhs);
|
||||
llong abs() const;
|
||||
|
||||
// simple construction from ASCII and Unicode strings
|
||||
friend llong atoll(const char* str, uint32_t radix = 10);
|
||||
friend llong u_atoll(const UChar* str, uint32_t radix = 10);
|
||||
static llong atoll(const char* str, uint32_t radix = 10);
|
||||
static llong u_atoll(const UChar* str, uint32_t radix = 10);
|
||||
|
||||
// output as ASCII or Unicode strings or as raw values, preceeding '-' if signed
|
||||
friend uint32_t lltoa(const llong& lhs, char* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE);
|
||||
friend uint32_t u_lltoa(const llong& lhs, UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE);
|
||||
uint32_t lltoa(char* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE) const;
|
||||
uint32_t u_lltoa(UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE) const;
|
||||
|
||||
// useful public constants - perhaps should not have class statics
|
||||
// static const llong getZero();
|
||||
|
@ -223,13 +222,13 @@ private:
|
|||
friend void llong_test();
|
||||
};
|
||||
|
||||
inline llong operator& (const llong& lhs, const llong& rhs) { return llong(lhs.hi & rhs.hi, lhs.lo & rhs.lo); }
|
||||
inline llong operator| (const llong& lhs, const llong& rhs) { return llong(lhs.hi | rhs.hi, lhs.lo | rhs.lo); }
|
||||
inline llong operator^ (const llong& lhs, const llong& rhs) { return llong(lhs.hi ^ rhs.hi, lhs.lo ^ rhs.lo); }
|
||||
inline llong llong::operator& (const llong& rhs) const { return llong(hi & rhs.hi, lo & rhs.lo); }
|
||||
inline llong llong::operator| (const llong& rhs) const { return llong(hi | rhs.hi, lo | rhs.lo); }
|
||||
inline llong llong::operator^ (const llong& rhs) const { return llong(hi ^ rhs.hi, lo ^ rhs.lo); }
|
||||
|
||||
inline llong operator& (const llong& lhs, const uint32_t rhs) { return llong(0, lhs.lo & rhs); }
|
||||
inline llong operator| (const llong& lhs, const uint32_t rhs) { return llong(lhs.hi, lhs.lo | rhs); }
|
||||
inline llong operator^ (const llong& lhs, const uint32_t rhs) { return llong(lhs.hi, lhs.lo ^ rhs); }
|
||||
inline llong llong::operator& (const uint32_t rhs) const { return llong(0, lo & rhs); }
|
||||
inline llong llong::operator| (const uint32_t rhs) const { return llong(hi, lo | rhs); }
|
||||
inline llong llong::operator^ (const uint32_t rhs) const { return llong(hi, lo ^ rhs); }
|
||||
|
||||
inline UBool llong::operator==(const llong& rhs) const { return lo == rhs.lo && hi == rhs.hi; }
|
||||
inline UBool llong::operator!=(const llong& rhs) const { return lo != rhs.lo || hi != rhs.hi; }
|
||||
|
@ -249,32 +248,32 @@ inline UBool llong::operator>=(const int32_t rhs) const { return rhs < 0 ? (hi =
|
|||
inline UBool llong::operator<=(const int32_t rhs) const { return rhs < 0 ? (hi == -1 ? lo <= (unsigned)rhs : hi < -1)
|
||||
: (hi == 0 ? lo <= (unsigned)rhs : hi < 0); }
|
||||
|
||||
inline UBool ugt(const llong& lhs, const llong& rhs) { return lhs.hi == rhs.hi ? lhs.lo > rhs.lo : (unsigned)lhs.hi > (unsigned)rhs.hi; }
|
||||
inline UBool ult(const llong& lhs, const llong& rhs) { return lhs.hi == rhs.hi ? lhs.lo < rhs.lo : (unsigned)lhs.hi < (unsigned)rhs.hi; }
|
||||
inline UBool uge(const llong& lhs, const llong& rhs) { return lhs.hi == rhs.hi ? lhs.lo >= rhs.lo : (unsigned)lhs.hi >= (unsigned)rhs.hi; }
|
||||
inline UBool ule(const llong& lhs, const llong& rhs) { return lhs.hi == rhs.hi ? lhs.lo <= rhs.lo : (unsigned)lhs.hi <= (unsigned)rhs.hi; }
|
||||
inline UBool llong::ugt(const llong& rhs) const { return hi == rhs.hi ? lo > rhs.lo : (unsigned)hi > (unsigned)rhs.hi; }
|
||||
inline UBool llong::ult(const llong& rhs) const { return hi == rhs.hi ? lo < rhs.lo : (unsigned)hi < (unsigned)rhs.hi; }
|
||||
inline UBool llong::uge(const llong& rhs) const { return hi == rhs.hi ? lo >= rhs.lo : (unsigned)hi >= (unsigned)rhs.hi; }
|
||||
inline UBool llong::ule(const llong& rhs) const { return hi == rhs.hi ? lo <= rhs.lo : (unsigned)hi <= (unsigned)rhs.hi; }
|
||||
|
||||
inline llong ushr(const llong& lhs, int32_t shift) { llong r(lhs); r.ushr(shift); return r; }
|
||||
inline llong llong::ushr(int32_t shift) const { llong r(*this); r.ushr(shift); return r; }
|
||||
|
||||
inline int32_t llong_asInt(const llong& lhs) { return (int32_t)(lhs.lo | (lhs.hi < 0 ? 0x80000000 : 0)); }
|
||||
inline uint32_t llong_asUInt(const llong& lhs) { return lhs.lo; }
|
||||
inline double llong_asDouble(const llong& lhs) { return llong::kD32 * lhs.hi + lhs.lo; }
|
||||
inline int32_t llong::asInt() const { return (int32_t)(lo | (hi < 0 ? 0x80000000 : 0)); }
|
||||
inline uint32_t llong::asUInt() const { return lo; }
|
||||
inline double llong::asDouble() const { return llong::kD32 * hi + lo; }
|
||||
|
||||
inline llong llong_pow(const llong& lhs, uint32_t n) {
|
||||
if (lhs.isZero()) {
|
||||
inline llong llong::pow(uint32_t n) const {
|
||||
if (isZero()) {
|
||||
return llong(0, 0); /* zero */
|
||||
} else if (n == 0) {
|
||||
return llong(0, 1); /* one */
|
||||
} else {
|
||||
llong r(lhs);
|
||||
llong r(*this);
|
||||
while (--n > 0) {
|
||||
r *= lhs;
|
||||
r *= *this;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
inline llong llong_abs(const llong& lhs) { return lhs.isNegative() ? -lhs : lhs; }
|
||||
inline llong llong::abs() const { return isNegative() ? -(*this) : *this; }
|
||||
|
||||
// Originally, I thought that overloading on int32 was too complex or to large to get inlined, and
|
||||
// since I mainly wanted to optimize comparisons to zero, I overloaded on uint32_t instead
|
||||
|
|
|
@ -355,7 +355,7 @@ NFRuleSet::findNormalRule(llong number) const
|
|||
// to find the rule (we should only go into this clause if the
|
||||
// value is 0)
|
||||
if (fIsFractionRuleSet) {
|
||||
return findFractionRuleSetRule(llong_asDouble(number));
|
||||
return findFractionRuleSetRule(number.asDouble());
|
||||
}
|
||||
|
||||
// if the number is negative, return the negative-number rule
|
||||
|
@ -401,7 +401,7 @@ NFRuleSet::findNormalRule(llong number) const
|
|||
// an explanation of the rollback rule). If we do, roll back
|
||||
// one rule and return that one instead of the one we'd normally
|
||||
// return
|
||||
if (result->shouldRollBack(llong_asDouble(number))) {
|
||||
if (result->shouldRollBack(number.asDouble())) {
|
||||
result = rules[hi - 2];
|
||||
}
|
||||
|
||||
|
@ -441,7 +441,7 @@ NFRuleSet::findFractionRuleSetRule(double number) const
|
|||
for (uint32_t i = 1; i < rules.size(); ++i) {
|
||||
leastCommonMultiple = util_lcm(leastCommonMultiple, rules[i]->getBaseValue());
|
||||
}
|
||||
numerator = number * llong_asDouble(leastCommonMultiple) + 0.5;
|
||||
numerator = number * leastCommonMultiple.asDouble() + 0.5;
|
||||
}
|
||||
// for each rule, do the following...
|
||||
llong tempDifference;
|
||||
|
@ -485,7 +485,7 @@ NFRuleSet::findFractionRuleSetRule(double number) const
|
|||
// a whole bunch of extra rule sets)
|
||||
if ((unsigned)(winner + 1) < rules.size() &&
|
||||
rules[winner + 1]->getBaseValue() == rules[winner]->getBaseValue()) {
|
||||
double n = llong_asDouble(rules[winner]->getBaseValue()) * number;
|
||||
double n = rules[winner]->getBaseValue().asDouble() * number;
|
||||
if (n < 0.5 || n >= 2) {
|
||||
++winner;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ NFRule::makeRules(UnicodeString& description,
|
|||
// base value is an even multiple of its divisor (or it's one
|
||||
// of the special rules)
|
||||
if ((rule1->baseValue > 0
|
||||
&& (rule1->baseValue % llong_pow((int32_t)rule1->radix, (int32_t)rule1->exponent)) == 0)
|
||||
&& (rule1->baseValue % ((llong)rule1->radix).pow((int32_t)rule1->exponent)) == 0)
|
||||
|| rule1->getType() == kImproperFractionRule
|
||||
|| rule1->getType() == kMasterRule) {
|
||||
|
||||
|
@ -306,7 +306,7 @@ NFRule::parseRuleDescriptor(UnicodeString& description, UErrorCode& status)
|
|||
|
||||
// tempValue now contain's the rule's radix. Set it
|
||||
// accordingly, and recalculate the rule's exponent
|
||||
radix = (int16_t)llong_asInt(val);
|
||||
radix = (int16_t)val.asInt();
|
||||
if (radix == 0) {
|
||||
// throw new IllegalArgumentException("Rule can't have radix of 0");
|
||||
status = U_PARSE_ERROR;
|
||||
|
@ -492,8 +492,8 @@ NFRule::expectedExponent() const
|
|||
// we get rounding error in some cases-- for example, log 1000 / log 10
|
||||
// gives us 1.9999999996 instead of 2. The extra logic here is to take
|
||||
// that into account
|
||||
int16_t tempResult = (int16_t)(uprv_log(llong_asDouble(baseValue)) / uprv_log((double)radix));
|
||||
llong temp = llong_pow(radix, tempResult + 1);
|
||||
int16_t tempResult = (int16_t)(uprv_log(baseValue.asDouble()) / uprv_log((double)radix));
|
||||
llong temp = ((llong)radix).pow(tempResult + 1);
|
||||
if (temp <= baseValue) {
|
||||
tempResult += 1;
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ util_append_llong(UnicodeString& result, const llong& value)
|
|||
static void util_append64(UnicodeString& result, const llong& n)
|
||||
{
|
||||
UChar buffer[256];
|
||||
int32_t len = u_lltoa(n, buffer, sizeof(buffer));
|
||||
int32_t len = n.u_lltoa(buffer, sizeof(buffer));
|
||||
UnicodeString temp(buffer, len);
|
||||
result.append(temp);
|
||||
}
|
||||
|
@ -647,7 +647,7 @@ NFRule::appendRuleText(UnicodeString& result) const
|
|||
* should be inserted
|
||||
*/
|
||||
void
|
||||
NFRule::doFormat(llong number, UnicodeString& toInsertInto, int32_t pos) const
|
||||
NFRule::doFormat(const llong &number, UnicodeString& toInsertInto, int32_t pos) const
|
||||
{
|
||||
// first, insert the rule's rule text into toInsertInto at the
|
||||
// specified position, then insert the results of the substitutions
|
||||
|
@ -710,8 +710,8 @@ NFRule::shouldRollBack(double number) const
|
|||
// of 100, and the value we're trying to format _is_ an even
|
||||
// multiple of 100. This is called the "rollback rule."
|
||||
if ((sub1->isModulusSubstitution()) || (sub2->isModulusSubstitution())) {
|
||||
llong re = llong_pow(radix, exponent);
|
||||
return uprv_fmod(number, llong_asDouble(re)) == 0 && (baseValue % re) != 0;
|
||||
llong re = ((llong)radix).pow(exponent);
|
||||
return uprv_fmod(number, re.asDouble()) == 0 && (baseValue % re) != 0;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -828,7 +828,7 @@ NFRule::doParse(const UnicodeString& text,
|
|||
int highWaterMark = 0;
|
||||
double result = 0;
|
||||
int start = 0;
|
||||
double tempBaseValue = (baseValue <= 0) ? 0 : llong_asDouble(baseValue);
|
||||
double tempBaseValue = (baseValue <= 0) ? 0 : baseValue.asDouble();
|
||||
|
||||
UnicodeString temp;
|
||||
do {
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
UBool operator==(const NFRule& rhs) const;
|
||||
UBool operator!=(const NFRule& rhs) const { return !operator==(rhs); }
|
||||
|
||||
ERuleType getType() const { return (ERuleType)(baseValue <= 0 ? llong_asInt(baseValue) : kOtherRule); }
|
||||
ERuleType getType() const { return (ERuleType)(baseValue <= 0 ? baseValue.asInt() : kOtherRule); }
|
||||
void setType(ERuleType ruleType) { baseValue = (int32_t)ruleType; }
|
||||
|
||||
llong getBaseValue() const { return baseValue; }
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
double getDivisor() const { return uprv_pow(radix, exponent); }
|
||||
|
||||
void doFormat(llong number, UnicodeString& toAppendTo, int32_t pos) const;
|
||||
void doFormat(const llong &number, UnicodeString& toAppendTo, int32_t pos) const;
|
||||
void doFormat(double number, UnicodeString& toAppendTo, int32_t pos) const;
|
||||
|
||||
UBool doParse(const UnicodeString& text,
|
||||
|
|
|
@ -72,7 +72,7 @@ NFSubstitution::makeSubstitution(int32_t pos,
|
|||
// if the rule set containing the rule is a fraction
|
||||
// rule set, return a NumeratorSubstitution
|
||||
else if (ruleSet->isFractionRuleSet()) {
|
||||
return new NumeratorSubstitution(pos, llong_asDouble(rule->getBaseValue()),
|
||||
return new NumeratorSubstitution(pos, rule->getBaseValue().asDouble(),
|
||||
formatter->getDefaultRuleSet(), formatter, description, status);
|
||||
}
|
||||
|
||||
|
@ -276,21 +276,19 @@ NFSubstitution::toString(UnicodeString& text) const
|
|||
* position to determine exactly where to insert the new text)
|
||||
*/
|
||||
void
|
||||
NFSubstitution::doSubstitution(llong number, UnicodeString& toInsertInto, int32_t _pos) const
|
||||
NFSubstitution::doSubstitution(const llong &number, UnicodeString& toInsertInto, int32_t _pos) const
|
||||
{
|
||||
if (ruleSet != NULL) {
|
||||
// perform a transformation on the number that is dependent
|
||||
// on the type of substitution this is, then just call its
|
||||
// rule set's format() method to format the result
|
||||
llong numberToFormat = transformNumber(number);
|
||||
|
||||
ruleSet->format(numberToFormat, toInsertInto, _pos + this->pos);
|
||||
ruleSet->format(transformNumber(number), toInsertInto, _pos + this->pos);
|
||||
} else {
|
||||
// or perform the transformation on the number (preserving
|
||||
// the result's fractional part if the formatter it set
|
||||
// to show it), then use that formatter's format() method
|
||||
// to format the result
|
||||
double numberToFormat = transformNumber(llong_asDouble(number));
|
||||
double numberToFormat = transformNumber(number.asDouble());
|
||||
if (numberFormat->getMaximumFractionDigits() == 0) {
|
||||
numberToFormat = uprv_floor(numberToFormat);
|
||||
}
|
||||
|
@ -579,7 +577,7 @@ UBool ModulusSubstitution::operator==(const NFSubstitution& rhs) const
|
|||
* @param pos The position of the rule text in toInsertInto
|
||||
*/
|
||||
void
|
||||
ModulusSubstitution::doSubstitution(llong number, UnicodeString& toInsertInto, int32_t _pos) const
|
||||
ModulusSubstitution::doSubstitution(const llong & number, UnicodeString& toInsertInto, int32_t _pos) const
|
||||
{
|
||||
// if this isn't a >>> substitution, just use the inherited version
|
||||
// of this function (which uses either a rule set or a DecimalFormat
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
* rule text begins (this value is added to this substitution's
|
||||
* position to determine exactly where to insert the new text)
|
||||
*/
|
||||
virtual void doSubstitution(llong number, UnicodeString& toInsertInto, int32_t pos) const;
|
||||
virtual void doSubstitution(const llong &number, UnicodeString& toInsertInto, int32_t pos) const;
|
||||
virtual void doSubstitution(double number, UnicodeString& toInsertInto, int32_t pos) const;
|
||||
|
||||
protected:
|
||||
|
@ -95,7 +95,7 @@ protected:
|
|||
* @param The number being formatted
|
||||
* @return The result of performing the opreration on the number
|
||||
*/
|
||||
virtual llong transformNumber(llong number) const = 0;
|
||||
virtual llong transformNumber(const llong &number) const = 0;
|
||||
virtual double transformNumber(double number) const = 0;
|
||||
|
||||
public:
|
||||
|
@ -211,7 +211,7 @@ public:
|
|||
const UnicodeString& description,
|
||||
UErrorCode& status);
|
||||
|
||||
llong transformNumber(llong number) const { return number; }
|
||||
llong transformNumber(const llong &number) const { return number; }
|
||||
double transformNumber(double number) const { return number; }
|
||||
double composeRuleValue(double newRuleValue, double /*oldRuleValue*/) const { return newRuleValue; }
|
||||
double calcUpperBound(double oldUpperBound) const { return oldUpperBound; }
|
||||
|
@ -247,7 +247,7 @@ public:
|
|||
|
||||
UBool operator==(const NFSubstitution& rhs) const;
|
||||
|
||||
llong transformNumber(llong number) const {
|
||||
llong transformNumber(const llong &number) const {
|
||||
return number / ldivisor;
|
||||
}
|
||||
|
||||
|
@ -290,10 +290,10 @@ public:
|
|||
|
||||
UBool operator==(const NFSubstitution& rhs) const;
|
||||
|
||||
void doSubstitution(llong number, UnicodeString& toInsertInto, int32_t pos) const;
|
||||
void doSubstitution(const llong &number, UnicodeString& toInsertInto, int32_t pos) const;
|
||||
void doSubstitution(double number, UnicodeString& toInsertInto, int32_t pos) const;
|
||||
|
||||
llong transformNumber(llong number) const { return number % ldivisor; }
|
||||
llong transformNumber(const llong &number) const { return number % ldivisor; }
|
||||
double transformNumber(double number) const { return uprv_fmod(number, divisor); }
|
||||
|
||||
UBool doParse(const UnicodeString& text,
|
||||
|
@ -329,7 +329,7 @@ public:
|
|||
UErrorCode& status)
|
||||
: NFSubstitution(_pos, _ruleSet, formatter, description, status) {}
|
||||
|
||||
llong transformNumber(llong number) const { return number; }
|
||||
llong transformNumber(const llong &number) const { return number; }
|
||||
double transformNumber(double number) const { return uprv_floor(number); }
|
||||
double composeRuleValue(double newRuleValue, double oldRuleValue) const { return newRuleValue + oldRuleValue; }
|
||||
double calcUpperBound(double /*oldUpperBound*/) const { return DBL_MAX; }
|
||||
|
@ -356,8 +356,8 @@ public:
|
|||
UBool operator==(const NFSubstitution& rhs) const;
|
||||
|
||||
void doSubstitution(double number, UnicodeString& toInsertInto, int32_t pos) const;
|
||||
void doSubstitution(llong /*number*/, UnicodeString& /*toInsertInto*/, int32_t /*_pos*/) const {}
|
||||
llong transformNumber(llong /*number*/) const { return llong(0,0); }
|
||||
void doSubstitution(const llong &/*number*/, UnicodeString& /*toInsertInto*/, int32_t /*_pos*/) const {}
|
||||
llong transformNumber(const llong &/*number*/) const { return llong(0,0); }
|
||||
double transformNumber(double number) const { return number - uprv_floor(number); }
|
||||
|
||||
UBool doParse(const UnicodeString& text,
|
||||
|
@ -387,7 +387,7 @@ public:
|
|||
UErrorCode& status)
|
||||
: NFSubstitution(_pos, _ruleSet, formatter, description, status) {}
|
||||
|
||||
llong transformNumber(llong number) const { return llong_abs(number); }
|
||||
llong transformNumber(const llong &number) const { return number.abs(); }
|
||||
double transformNumber(double number) const { return uprv_fabs(number); }
|
||||
double composeRuleValue(double newRuleValue, double /*oldRuleValue*/) const { return -newRuleValue; }
|
||||
double calcUpperBound(double /*oldUpperBound*/) const { return DBL_MAX; }
|
||||
|
@ -417,7 +417,7 @@ public:
|
|||
|
||||
UBool operator==(const NFSubstitution& rhs) const;
|
||||
|
||||
llong transformNumber(llong number) const { return number * ldenominator; }
|
||||
llong transformNumber(const llong &number) const { return number * ldenominator; }
|
||||
double transformNumber(double number) const { return uprv_round(number * denominator); }
|
||||
|
||||
UBool doParse(const UnicodeString& text,
|
||||
|
@ -454,8 +454,8 @@ public:
|
|||
|
||||
void toString(UnicodeString& /*result*/) const {}
|
||||
void doSubstitution(double /*number*/, UnicodeString& /*toInsertInto*/, int32_t /*_pos*/) const {}
|
||||
void doSubstitution(llong /*number*/, UnicodeString& /*toInsertInto*/, int32_t /*_pos*/) const {}
|
||||
llong transformNumber(llong /*number*/) const { return llong(0,0); }
|
||||
void doSubstitution(const llong &/*number*/, UnicodeString& /*toInsertInto*/, int32_t /*_pos*/) const {}
|
||||
llong transformNumber(const llong &/*number*/) const { return llong(0,0); }
|
||||
double transformNumber(double /*number*/) const { return 0; }
|
||||
UBool doParse(const UnicodeString& /*text*/,
|
||||
ParsePosition& /*parsePosition*/,
|
||||
|
|
Loading…
Add table
Reference in a new issue