mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-22 16:37:31 +09:00
Issue #1971 - Part 2: Update ICU source to 63.2.
This commit is contained in:
parent
8df84683be
commit
1e69214382
3160 changed files with 275815 additions and 234203 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// © 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: ucharstrie.h
|
||||
* encoding: US-ASCII
|
||||
* encoding: UTF-8
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
|
|
@ -36,7 +36,7 @@ class UVector32;
|
|||
|
||||
/**
|
||||
* Light-weight, non-const reader class for a UCharsTrie.
|
||||
* Traverses a UChar-serialized data structure with minimal state,
|
||||
* Traverses a char16_t-serialized data structure with minimal state,
|
||||
* for mapping strings (16-bit-unit sequences) to non-negative integer values.
|
||||
*
|
||||
* This class owns the serialized trie data only if it was constructed by
|
||||
|
|
@ -52,18 +52,18 @@ public:
|
|||
/**
|
||||
* Constructs a UCharsTrie reader instance.
|
||||
*
|
||||
* The trieUChars must contain a copy of a UChar sequence from the UCharsTrieBuilder,
|
||||
* starting with the first UChar of that sequence.
|
||||
* The UCharsTrie object will not read more UChars than
|
||||
* The trieUChars must contain a copy of a char16_t sequence from the UCharsTrieBuilder,
|
||||
* starting with the first char16_t of that sequence.
|
||||
* The UCharsTrie object will not read more char16_ts than
|
||||
* the UCharsTrieBuilder generated in the corresponding build() call.
|
||||
*
|
||||
* The array is not copied/cloned and must not be modified while
|
||||
* the UCharsTrie object is in use.
|
||||
*
|
||||
* @param trieUChars The UChar array that contains the serialized trie.
|
||||
* @param trieUChars The char16_t array that contains the serialized trie.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
UCharsTrie(const UChar *trieUChars)
|
||||
UCharsTrie(ConstChar16Ptr trieUChars)
|
||||
: ownedArray_(NULL), uchars_(trieUChars),
|
||||
pos_(uchars_), remainingMatchLength_(-1) {}
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
/**
|
||||
* Copy constructor, copies the other trie reader object and its state,
|
||||
* but not the UChar array which will be shared. (Shallow copy.)
|
||||
* but not the char16_t array which will be shared. (Shallow copy.)
|
||||
* @param other Another UCharsTrie object.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
|
|
@ -109,8 +109,8 @@ public:
|
|||
private:
|
||||
friend class UCharsTrie;
|
||||
|
||||
const UChar *uchars;
|
||||
const UChar *pos;
|
||||
const char16_t *uchars;
|
||||
const char16_t *pos;
|
||||
int32_t remainingMatchLength;
|
||||
};
|
||||
|
||||
|
|
@ -148,14 +148,14 @@ public:
|
|||
|
||||
/**
|
||||
* Determines whether the string so far matches, whether it has a value,
|
||||
* and whether another input UChar can continue a matching string.
|
||||
* and whether another input char16_t can continue a matching string.
|
||||
* @return The match/value Result.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
UStringTrieResult current() const;
|
||||
|
||||
/**
|
||||
* Traverses the trie from the initial state for this input UChar.
|
||||
* Traverses the trie from the initial state for this input char16_t.
|
||||
* Equivalent to reset().next(uchar).
|
||||
* @param uchar Input char value. Values below 0 and above 0xffff will never match.
|
||||
* @return The match/value Result.
|
||||
|
|
@ -177,7 +177,7 @@ public:
|
|||
UStringTrieResult firstForCodePoint(UChar32 cp);
|
||||
|
||||
/**
|
||||
* Traverses the trie from the current state for this input UChar.
|
||||
* Traverses the trie from the current state for this input char16_t.
|
||||
* @param uchar Input char value. Values below 0 and above 0xffff will never match.
|
||||
* @return The match/value Result.
|
||||
* @stable ICU 4.8
|
||||
|
|
@ -208,7 +208,7 @@ public:
|
|||
* @return The match/value Result.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
UStringTrieResult next(const UChar *s, int32_t length);
|
||||
UStringTrieResult next(ConstChar16Ptr s, int32_t length);
|
||||
|
||||
/**
|
||||
* Returns a matching string's value if called immediately after
|
||||
|
|
@ -220,7 +220,7 @@ public:
|
|||
* @stable ICU 4.8
|
||||
*/
|
||||
inline int32_t getValue() const {
|
||||
const UChar *pos=pos_;
|
||||
const char16_t *pos=pos_;
|
||||
int32_t leadUnit=*pos++;
|
||||
// U_ASSERT(leadUnit>=kMinValueLead);
|
||||
return leadUnit&kValueIsFinal ?
|
||||
|
|
@ -237,16 +237,16 @@ public:
|
|||
* @stable ICU 4.8
|
||||
*/
|
||||
inline UBool hasUniqueValue(int32_t &uniqueValue) const {
|
||||
const UChar *pos=pos_;
|
||||
const char16_t *pos=pos_;
|
||||
// Skip the rest of a pending linear-match node.
|
||||
return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds each UChar which continues the string from the current state.
|
||||
* That is, each UChar c for which it would be next(c)!=USTRINGTRIE_NO_MATCH now.
|
||||
* @param out Each next UChar is appended to this object.
|
||||
* @return the number of UChars which continue the string from here
|
||||
* Finds each char16_t which continues the string from the current state.
|
||||
* That is, each char16_t c for which it would be next(c)!=USTRINGTRIE_NO_MATCH now.
|
||||
* @param out Each next char16_t is appended to this object.
|
||||
* @return the number of char16_ts which continue the string from here
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
int32_t getNextUChars(Appendable &out) const;
|
||||
|
|
@ -258,8 +258,8 @@ public:
|
|||
class U_COMMON_API Iterator : public UMemory {
|
||||
public:
|
||||
/**
|
||||
* Iterates from the root of a UChar-serialized UCharsTrie.
|
||||
* @param trieUChars The trie UChars.
|
||||
* Iterates from the root of a char16_t-serialized UCharsTrie.
|
||||
* @param trieUChars The trie char16_ts.
|
||||
* @param maxStringLength If 0, the iterator returns full strings.
|
||||
* Otherwise, the iterator returns strings with this maximum length.
|
||||
* @param errorCode Standard ICU error code. Its input value must
|
||||
|
|
@ -268,7 +268,7 @@ public:
|
|||
* function chaining. (See User Guide for details.)
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
Iterator(const UChar *trieUChars, int32_t maxStringLength, UErrorCode &errorCode);
|
||||
Iterator(ConstChar16Ptr trieUChars, int32_t maxStringLength, UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Iterates from the current state of the specified UCharsTrie.
|
||||
|
|
@ -336,11 +336,11 @@ public:
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
const UChar *branchNext(const UChar *pos, int32_t length, UErrorCode &errorCode);
|
||||
const char16_t *branchNext(const char16_t *pos, int32_t length, UErrorCode &errorCode);
|
||||
|
||||
const UChar *uchars_;
|
||||
const UChar *pos_;
|
||||
const UChar *initialPos_;
|
||||
const char16_t *uchars_;
|
||||
const char16_t *pos_;
|
||||
const char16_t *initialPos_;
|
||||
int32_t remainingMatchLength_;
|
||||
int32_t initialRemainingMatchLength_;
|
||||
UBool skipValue_; // Skip intermediate value which was already delivered.
|
||||
|
|
@ -368,7 +368,7 @@ private:
|
|||
* this constructor adopts the builder's array.
|
||||
* This constructor is only called by the builder.
|
||||
*/
|
||||
UCharsTrie(UChar *adoptUChars, const UChar *trieUChars)
|
||||
UCharsTrie(char16_t *adoptUChars, const char16_t *trieUChars)
|
||||
: ownedArray_(adoptUChars), uchars_(trieUChars),
|
||||
pos_(uchars_), remainingMatchLength_(-1) {}
|
||||
|
||||
|
|
@ -381,7 +381,7 @@ private:
|
|||
|
||||
// Reads a compact 32-bit integer.
|
||||
// pos is already after the leadUnit, and the lead unit has bit 15 reset.
|
||||
static inline int32_t readValue(const UChar *pos, int32_t leadUnit) {
|
||||
static inline int32_t readValue(const char16_t *pos, int32_t leadUnit) {
|
||||
int32_t value;
|
||||
if(leadUnit<kMinTwoUnitValueLead) {
|
||||
value=leadUnit;
|
||||
|
|
@ -392,7 +392,7 @@ private:
|
|||
}
|
||||
return value;
|
||||
}
|
||||
static inline const UChar *skipValue(const UChar *pos, int32_t leadUnit) {
|
||||
static inline const char16_t *skipValue(const char16_t *pos, int32_t leadUnit) {
|
||||
if(leadUnit>=kMinTwoUnitValueLead) {
|
||||
if(leadUnit<kThreeUnitValueLead) {
|
||||
++pos;
|
||||
|
|
@ -402,12 +402,12 @@ private:
|
|||
}
|
||||
return pos;
|
||||
}
|
||||
static inline const UChar *skipValue(const UChar *pos) {
|
||||
static inline const char16_t *skipValue(const char16_t *pos) {
|
||||
int32_t leadUnit=*pos++;
|
||||
return skipValue(pos, leadUnit&0x7fff);
|
||||
}
|
||||
|
||||
static inline int32_t readNodeValue(const UChar *pos, int32_t leadUnit) {
|
||||
static inline int32_t readNodeValue(const char16_t *pos, int32_t leadUnit) {
|
||||
// U_ASSERT(kMinValueLead<=leadUnit && leadUnit<kValueIsFinal);
|
||||
int32_t value;
|
||||
if(leadUnit<kMinTwoUnitNodeValueLead) {
|
||||
|
|
@ -419,7 +419,7 @@ private:
|
|||
}
|
||||
return value;
|
||||
}
|
||||
static inline const UChar *skipNodeValue(const UChar *pos, int32_t leadUnit) {
|
||||
static inline const char16_t *skipNodeValue(const char16_t *pos, int32_t leadUnit) {
|
||||
// U_ASSERT(kMinValueLead<=leadUnit && leadUnit<kValueIsFinal);
|
||||
if(leadUnit>=kMinTwoUnitNodeValueLead) {
|
||||
if(leadUnit<kThreeUnitNodeValueLead) {
|
||||
|
|
@ -431,7 +431,7 @@ private:
|
|||
return pos;
|
||||
}
|
||||
|
||||
static inline const UChar *jumpByDelta(const UChar *pos) {
|
||||
static inline const char16_t *jumpByDelta(const char16_t *pos) {
|
||||
int32_t delta=*pos++;
|
||||
if(delta>=kMinTwoUnitDeltaLead) {
|
||||
if(delta==kThreeUnitDeltaLead) {
|
||||
|
|
@ -444,7 +444,7 @@ private:
|
|||
return pos+delta;
|
||||
}
|
||||
|
||||
static const UChar *skipDelta(const UChar *pos) {
|
||||
static const char16_t *skipDelta(const char16_t *pos) {
|
||||
int32_t delta=*pos++;
|
||||
if(delta>=kMinTwoUnitDeltaLead) {
|
||||
if(delta==kThreeUnitDeltaLead) {
|
||||
|
|
@ -461,28 +461,28 @@ private:
|
|||
}
|
||||
|
||||
// Handles a branch node for both next(uchar) and next(string).
|
||||
UStringTrieResult branchNext(const UChar *pos, int32_t length, int32_t uchar);
|
||||
UStringTrieResult branchNext(const char16_t *pos, int32_t length, int32_t uchar);
|
||||
|
||||
// Requires remainingLength_<0.
|
||||
UStringTrieResult nextImpl(const UChar *pos, int32_t uchar);
|
||||
UStringTrieResult nextImpl(const char16_t *pos, int32_t uchar);
|
||||
|
||||
// Helper functions for hasUniqueValue().
|
||||
// Recursively finds a unique value (or whether there is not a unique one)
|
||||
// from a branch.
|
||||
static const UChar *findUniqueValueFromBranch(const UChar *pos, int32_t length,
|
||||
static const char16_t *findUniqueValueFromBranch(const char16_t *pos, int32_t length,
|
||||
UBool haveUniqueValue, int32_t &uniqueValue);
|
||||
// Recursively finds a unique value (or whether there is not a unique one)
|
||||
// starting from a position on a node lead unit.
|
||||
static UBool findUniqueValue(const UChar *pos, UBool haveUniqueValue, int32_t &uniqueValue);
|
||||
static UBool findUniqueValue(const char16_t *pos, UBool haveUniqueValue, int32_t &uniqueValue);
|
||||
|
||||
// Helper functions for getNextUChars().
|
||||
// getNextUChars() when pos is on a branch node.
|
||||
static void getNextBranchUChars(const UChar *pos, int32_t length, Appendable &out);
|
||||
static void getNextBranchUChars(const char16_t *pos, int32_t length, Appendable &out);
|
||||
|
||||
// UCharsTrie data structure
|
||||
//
|
||||
// The trie consists of a series of UChar-serialized nodes for incremental
|
||||
// Unicode string/UChar sequence matching. (UChar=16-bit unsigned integer)
|
||||
// The trie consists of a series of char16_t-serialized nodes for incremental
|
||||
// Unicode string/char16_t sequence matching. (char16_t=16-bit unsigned integer)
|
||||
// The root node is at the beginning of the trie data.
|
||||
//
|
||||
// Types of nodes are distinguished by their node lead unit ranges.
|
||||
|
|
@ -491,9 +491,9 @@ private:
|
|||
//
|
||||
// Node types:
|
||||
// - Final-value node: Stores a 32-bit integer in a compact, variable-length format.
|
||||
// The value is for the string/UChar sequence so far.
|
||||
// The value is for the string/char16_t sequence so far.
|
||||
// - Match node, optionally with an intermediate value in a different compact format.
|
||||
// The value, if present, is for the string/UChar sequence so far.
|
||||
// The value, if present, is for the string/char16_t sequence so far.
|
||||
//
|
||||
// Aside from the value, which uses the node lead unit's high bits:
|
||||
//
|
||||
|
|
@ -560,15 +560,15 @@ private:
|
|||
|
||||
static const int32_t kMaxTwoUnitDelta=((kThreeUnitDeltaLead-kMinTwoUnitDeltaLead)<<16)-1; // 0x03feffff
|
||||
|
||||
UChar *ownedArray_;
|
||||
char16_t *ownedArray_;
|
||||
|
||||
// Fixed value referencing the UCharsTrie words.
|
||||
const UChar *uchars_;
|
||||
const char16_t *uchars_;
|
||||
|
||||
// Iterator variables.
|
||||
|
||||
// Pointer to next trie unit to read. NULL if no more matches.
|
||||
const UChar *pos_;
|
||||
const char16_t *pos_;
|
||||
// Remaining length of a linear-match node, minus 1. Negative if not in such a node.
|
||||
int32_t remainingMatchLength_;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue