diff options
Diffstat (limited to 'deps/icu-small/source/common/uprops.cpp')
-rw-r--r-- | deps/icu-small/source/common/uprops.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/deps/icu-small/source/common/uprops.cpp b/deps/icu-small/source/common/uprops.cpp index 21723b32aa7..2421c15d2bd 100644 --- a/deps/icu-small/source/common/uprops.cpp +++ b/deps/icu-small/source/common/uprops.cpp @@ -25,6 +25,7 @@ #include "unicode/utypes.h" #include "unicode/uchar.h" +#include "unicode/ucptrie.h" #include "unicode/unorm2.h" #include "unicode/uscript.h" #include "unicode/ustring.h" @@ -36,6 +37,10 @@ #include "ucase.h" #include "ustr_imp.h" +// ulayout_props_data.h is machine-generated by genprops +#define INCLUDED_FROM_UPROPS_CPP +#include "ulayout_props_data.h" + U_NAMESPACE_USE /* general properties API functions ----------------------------------------- */ @@ -56,7 +61,7 @@ static UBool defaultContains(const BinaryProperty &prop, UChar32 c, UProperty /* } static UBool caseBinaryPropertyContains(const BinaryProperty &/*prop*/, UChar32 c, UProperty which) { - return ucase_hasBinaryProperty(c, which); + return static_cast<UBool>(ucase_hasBinaryProperty(c, which)); } static UBool isBidiControl(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) { @@ -428,6 +433,18 @@ static int32_t getTrailCombiningClass(const IntProperty &/*prop*/, UChar32 c, UP } #endif +static int32_t getInPC(const IntProperty &, UChar32 c, UProperty) { + return ucptrie_get(&inpc_trie, c); +} + +static int32_t getInSC(const IntProperty &, UChar32 c, UProperty) { + return ucptrie_get(&insc_trie, c); +} + +static int32_t getVo(const IntProperty &, UChar32 c, UProperty) { + return ucptrie_get(&vo_trie, c); +} + static const IntProperty intProps[UCHAR_INT_LIMIT-UCHAR_INT_START]={ /* * column, mask and shift values for int-value properties from u_getUnicodeProperties(). @@ -463,6 +480,9 @@ static const IntProperty intProps[UCHAR_INT_LIMIT-UCHAR_INT_START]={ { 2, UPROPS_SB_MASK, UPROPS_SB_SHIFT, defaultGetValue, defaultGetMaxValue }, { 2, UPROPS_WB_MASK, UPROPS_WB_SHIFT, defaultGetValue, defaultGetMaxValue }, { UPROPS_SRC_BIDI, 0, 0, getBiDiPairedBracketType, biDiGetMaxValue }, + { UPROPS_SRC_INPC, 0, maxInPCValue, getInPC, getMaxValueFromShift }, + { UPROPS_SRC_INSC, 0, maxInSCValue, getInSC, getMaxValueFromShift }, + { UPROPS_SRC_VO, 0, maxVoValue, getVo, getMaxValueFromShift }, }; U_CAPI int32_t U_EXPORT2 @@ -564,6 +584,34 @@ uprops_getSource(UProperty which) { } } +U_CFUNC void U_EXPORT2 +uprops_addPropertyStarts(UPropertySource src, const USetAdder *sa, UErrorCode *pErrorCode) { + if (U_FAILURE(*pErrorCode)) { return; } + const UCPTrie *trie; + switch (src) { + case UPROPS_SRC_INPC: + trie = &inpc_trie; + break; + case UPROPS_SRC_INSC: + trie = &insc_trie; + break; + case UPROPS_SRC_VO: + trie = &vo_trie; + break; + default: + *pErrorCode = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + + // Add the start code point of each same-value range of the trie. + UChar32 start = 0, end; + while ((end = ucptrie_getRange(trie, start, UCPMAP_RANGE_NORMAL, 0, + nullptr, nullptr, nullptr)) >= 0) { + sa->add(sa->set, start); + start = end + 1; + } +} + #if !UCONFIG_NO_NORMALIZATION U_CAPI int32_t U_EXPORT2 |