WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
unicode/wince subdir with style fixes, minus generated files
bug27305.patch (text/plain), 29.56 KB, created by
Joe Mason
on 2009-08-03 16:09:03 PDT
(
hide
)
Description:
unicode/wince subdir with style fixes, minus generated files
Filename:
MIME Type:
Creator:
Joe Mason
Created:
2009-08-03 16:09:03 PDT
Size:
29.56 KB
patch
obsolete
>diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog >index 24fc7e7..16cd3f0 100644 >--- a/JavaScriptCore/ChangeLog >+++ b/JavaScriptCore/ChangeLog >@@ -1,3 +1,50 @@ >+2009-07-15 George Staikos <george.staikos@torchmobile.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ https://bugs.webkit.org/show_bug.cgi?id=27305 >+ Implement WinCE-specific unicode layer. >+ Written by George Staikos <george.staikos@torchmobile.com> (using code taken from ICU), >+ with bug fixes by Yong Li <yong.li@torchmobile.com> >+ and style cleanup by Joe Mason <joe.mason@torchmobile.com> >+ >+ * wtf/Platform.h: >+ * wtf/unicode/Unicode.h: >+ * wtf/unicode/wince/UnicodeWince.cpp: Added. >+ (WTF::Unicode::toLower): >+ (WTF::Unicode::toUpper): >+ (WTF::Unicode::foldCase): >+ (WTF::Unicode::isPrintableChar): >+ (WTF::Unicode::isSpace): >+ (WTF::Unicode::isLetter): >+ (WTF::Unicode::isUpper): >+ (WTF::Unicode::isLower): >+ (WTF::Unicode::isDigit): >+ (WTF::Unicode::isPunct): >+ (WTF::Unicode::toTitleCase): >+ (utrie_defaultGetFoldingOffset): >+ (NormProp::getFoldingNormOffset): >+ (NormProp::getFoldingAuxOffset): >+ (u_getUnicodeProperties): >+ (WTF::Unicode::direction): >+ (WTF::Unicode::category): >+ (WTF::Unicode::decompositionType): >+ (WTF::Unicode::combiningClass): >+ (WTF::Unicode::mirroredChar): >+ (WTF::Unicode::digitValue): >+ * wtf/unicode/wince/UnicodeWince.h: Added. >+ (WTF::Unicode::): >+ (WTF::Unicode::isSeparatorSpace): >+ (WTF::Unicode::isHighSurrogate): >+ (WTF::Unicode::isLowSurrogate): >+ (WTF::Unicode::isArabicChar): >+ (WTF::Unicode::hasLineBreakingPropertyComplexContext): >+ (WTF::Unicode::umemcasecmp): >+ (WTF::Unicode::surrogateToUcs4): >+ * wtf/unicode/wince/ubidi_props_data.c: Added. >+ * wtf/unicode/wince/uchar_props_data.c: Added. >+ * wtf/unicode/wince/unorm_props_data.c: Added. >+ > 2009-07-28 Xan Lopez <xlopez@igalia.com> > > Add new files, fixes distcheck. >diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h >index 3f64c77..6307cc2 100644 >--- a/JavaScriptCore/wtf/Platform.h >+++ b/JavaScriptCore/wtf/Platform.h >@@ -368,6 +368,8 @@ > /* for Unicode, KDE uses Qt */ > #if PLATFORM(KDE) || PLATFORM(QT) > #define WTF_USE_QT4_UNICODE 1 >+#elif PLATFORM(WINCE) >+#define WTF_USE_WINCE_UNICODE 1 > #elif PLATFORM(GTK) > /* The GTK+ Unicode backend is configurable */ > #else >diff --git a/JavaScriptCore/wtf/unicode/Unicode.h b/JavaScriptCore/wtf/unicode/Unicode.h >index f86a9b7..d59439d 100644 >--- a/JavaScriptCore/wtf/unicode/Unicode.h >+++ b/JavaScriptCore/wtf/unicode/Unicode.h >@@ -1,6 +1,7 @@ > /* > * Copyright (C) 2006 George Staikos <staikos@kde.org> > * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved. >+ * Copyright (C) 2007-2009 Torch Mobile, Inc. > * > * This library is free software; you can redistribute it and/or > * modify it under the terms of the GNU Library General Public >@@ -30,6 +31,8 @@ > #include <wtf/unicode/icu/UnicodeIcu.h> > #elif USE(GLIB_UNICODE) > #include <wtf/unicode/glib/UnicodeGLib.h> >+#elif USE(WINCE_UNICODE) >+#include <wtf/unicode/wince/UnicodeWince.h> > #else > #error "Unknown Unicode implementation" > #endif >diff --git a/JavaScriptCore/wtf/unicode/wince/UnicodeWince.cpp b/JavaScriptCore/wtf/unicode/wince/UnicodeWince.cpp >new file mode 100644 >index 0000000..0a72432 >--- /dev/null >+++ b/JavaScriptCore/wtf/unicode/wince/UnicodeWince.cpp >@@ -0,0 +1,465 @@ >+/* >+ * Copyright (C) 2006 George Staikos <staikos@kde.org> >+ * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> >+ * Copyright (C) 2007-2008 Torch Mobile, Inc. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ * >+ * Some code was adapted from ICU, originally released under the following license: >+ * >+ * Copyright (C) 1996-2007, International Business Machines Corporation and others. >+ * >+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software >+ * and associated documentation files (the "Software"), to deal in the Software without >+ * restriction, including without limitation the rights to use, copy, modify, merge, publish, >+ * distribute, and/or sell copies of the Software, and to permit persons to whom the Software is >+ * furnished to do so, provided that the above copyright notice(s) and this permission notice appear >+ * in all copies of the Software and that both the above copyright notice(s) and this permission >+ * notice appear in supporting documentation. >+ * >+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT >+ * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND >+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED >+ * IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY >+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, >+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE >+ * OF THIS SOFTWARE. >+ * >+ * Except as contained in this notice, the name of a copyright holder shall not be used in >+ * advertising or otherwise to promote the sale, use or other dealings in this Software without >+ * prior written authorization of the copyright holder. >+ */ >+ >+#include "UnicodeWince.h" >+ >+#include <wchar.h> >+ >+namespace WTF { >+namespace Unicode { >+ >+wchar_t toLower(wchar_t c) >+{ >+ return towlower(c); >+} >+ >+wchar_t toUpper(wchar_t c) >+{ >+ return towupper(c); >+} >+ >+wchar_t foldCase(wchar_t c) >+{ >+ return towlower(c); >+} >+ >+bool isPrintableChar(wchar_t c) >+{ >+ return iswprint(c); >+} >+ >+bool isSpace(wchar_t c) >+{ >+ return iswspace(c); >+} >+ >+bool isLetter(wchar_t c) >+{ >+ return iswalpha(c); >+} >+ >+bool isUpper(wchar_t c) >+{ >+ return iswupper(c); >+} >+ >+bool isLower(wchar_t c) >+{ >+ return iswlower(c); >+} >+ >+bool isDigit(wchar_t c) >+{ >+ return iswdigit(c); >+} >+ >+bool isPunct(wchar_t c) >+{ >+ return iswpunct(c); >+} >+ >+int toLower(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError) >+{ >+ const UChar *sourceIterator = source; >+ const UChar *sourceEnd = source + sourceLength; >+ UChar *resultIterator = result; >+ UChar *resultEnd = result + resultLength; >+ >+ int remainingCharacters = 0; >+ if (sourceLength <= resultLength) >+ while (sourceIterator < sourceEnd) >+ *resultIterator++ = towlower(*sourceIterator++); >+ else >+ while (resultIterator < resultEnd) >+ *resultIterator++ = towlower(*sourceIterator++); >+ >+ if (sourceIterator < sourceEnd) >+ remainingCharacters += sourceEnd - sourceIterator; >+ *isError = (remainingCharacters != 0); >+ if (resultIterator < resultEnd) >+ *resultIterator = 0; >+ >+ return (resultIterator - result) + remainingCharacters; >+} >+ >+int toUpper(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError) >+{ >+ const UChar *sourceIterator = source; >+ const UChar *sourceEnd = source + sourceLength; >+ UChar *resultIterator = result; >+ UChar *resultEnd = result + resultLength; >+ >+ int remainingCharacters = 0; >+ if (sourceLength <= resultLength) >+ while (sourceIterator < sourceEnd) >+ *resultIterator++ = towupper(*sourceIterator++); >+ else >+ while (resultIterator < resultEnd) >+ *resultIterator++ = towupper(*sourceIterator++); >+ >+ if (sourceIterator < sourceEnd) >+ remainingCharacters += sourceEnd - sourceIterator; >+ *isError = (remainingCharacters != 0); >+ if (resultIterator < resultEnd) >+ *resultIterator = 0; >+ >+ return (resultIterator - result) + remainingCharacters; >+} >+ >+int foldCase(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError) >+{ >+ *isError = false; >+ if (resultLength < sourceLength) { >+ *isError = true; >+ return sourceLength; >+ } >+ for (int i = 0; i < sourceLength; ++i) >+ result[i] = foldCase(source[i]); >+ return sourceLength; >+} >+ >+wchar_t toTitleCase(wchar_t c) >+{ >+ return towupper(c); >+} >+ >+} // namespace Unicode >+} // namespace WTF >+ >+ >+// Implemented with ICU code >+ >+typedef __int32 int32_t; >+typedef __int16 int16_t; >+typedef __int8 int8_t; >+typedef unsigned __int32 uint32_t; >+typedef unsigned __int16 uint16_t; >+typedef unsigned __int8 uint8_t; >+typedef bool UBool; >+#define FALSE false >+#define TRUE true >+ >+enum { >+ UTRIE_SHIFT = 5, >+ UTRIE_DATA_BLOCK_LENGTH = 1 << UTRIE_SHIFT, >+ UTRIE_MASK = UTRIE_DATA_BLOCK_LENGTH - 1, >+ UTRIE_LEAD_INDEX_DISP = 0x2800 >> UTRIE_SHIFT, >+ UTRIE_INDEX_SHIFT = 2, >+ UTRIE_DATA_GRANULARITY = 1 << UTRIE_INDEX_SHIFT, >+ UTRIE_SURROGATE_BLOCK_BITS = 10 - UTRIE_SHIFT, >+ UTRIE_SURROGATE_BLOCK_COUNT = (1 << UTRIE_SURROGATE_BLOCK_BITS), >+ UTRIE_BMP_INDEX_LENGTH = 0x10000 >> UTRIE_SHIFT >+}; >+ >+typedef int32_t UTrieGetFoldingOffset(uint32_t data); >+ >+struct UTrie { >+ const uint16_t *index; >+ const uint32_t *data32; /* NULL if 16b data is used via index */ >+ >+ /** >+ * This function is not used in _FROM_LEAD, _FROM_BMP, and _FROM_OFFSET_TRAIL macros. >+ * If convenience macros like _GET16 or _NEXT32 are used, this function must be set. >+ * >+ * utrie_unserialize() sets a default function which simply returns >+ * the lead surrogate's value itself - which is the inverse of the default >+ * folding function used by utrie_serialize(). >+ * >+ * @see UTrieGetFoldingOffset >+ */ >+ UTrieGetFoldingOffset *getFoldingOffset; >+ >+ int32_t indexLength, dataLength; >+ uint32_t initialValue; >+ UBool isLatin1Linear; >+}; >+ >+int32_t utrie_defaultGetFoldingOffset(uint32_t data) >+{ >+ return (int32_t)data; >+} >+ >+#define _UTRIE_GET_RAW(trie, data, offset, c16) \ >+ (trie)->data[ \ >+ ((int32_t)((trie)->index[(offset) + ((c16) >> UTRIE_SHIFT)]) << UTRIE_INDEX_SHIFT) + \ >+ ((c16) & UTRIE_MASK) \ >+ ] >+ >+#define _UTRIE_GET_FROM_PAIR(trie, data, c, c2, result, resultType) { \ >+ int32_t __offset; \ >+\ >+ /* get data for lead surrogate */ \ >+ (result) = _UTRIE_GET_RAW((trie), data, 0, (c)); \ >+ __offset = (trie)->getFoldingOffset(result); \ >+\ >+ /* get the real data from the folded lead/trail units */ \ >+ if (__offset > 0) { \ >+ (result) = _UTRIE_GET_RAW((trie), data, __offset, (c2) & 0x3ff); \ >+ } else { \ >+ (result) = (resultType)((trie)->initialValue); \ >+ } \ >+} >+ >+#define _UTRIE_GET_FROM_BMP(trie, data, c16) \ >+ _UTRIE_GET_RAW(trie, data, 0xd800 <= (c16) && (c16) <= 0xdbff ? UTRIE_LEAD_INDEX_DISP : 0, c16); >+ >+#define _UTRIE_GET(trie, data, c32, result, resultType) \ >+ if ((uint32_t)(c32) <= 0xffff) { \ >+ /* BMP code points */ \ >+ (result) = _UTRIE_GET_FROM_BMP(trie, data, c32); \ >+ } else if ((uint32_t)(c32) <= 0x10ffff) { \ >+ /* supplementary code point */ \ >+ UChar __lead16 = (UChar)(((c32) >> 10) + 0xd7c0); \ >+ _UTRIE_GET_FROM_PAIR(trie, data, __lead16, c32, result, resultType); \ >+ } else { \ >+ /* out of range */ \ >+ (result) = (resultType)((trie)->initialValue); \ >+ } >+ >+#define UTRIE_GET16(trie, c16, result) _UTRIE_GET(trie, index, c16, result, uint16_t) >+#define UTRIE_GET32(trie, c32, result) _UTRIE_GET(trie, data32, c32, result, uint32_t) >+ >+#define GET_PROPS(c, result) UTRIE_GET16(&CharProp::propsTrie, c, result); >+ >+typedef uint8_t UVersionInfo[4]; >+ >+enum { >+ UPROPS_INDEX_COUNT = 16, >+ >+ /* general category shift == 0 0 (5 bits) */ >+ UPROPS_NUMERIC_TYPE_SHIFT = 5, /* 5 (3 bits) */ >+ UPROPS_NUMERIC_VALUE_SHIFT = 8 /* 8 (8 bits) */ >+}; >+ >+namespace CharProp { >+#include "uchar_props_data.c" >+} >+ >+#define GET_BIDI_PROPS(bdp, c, result) \ >+ UTRIE_GET16(&(bdp)->trie, c, result); >+ >+enum { >+ UBIDI_IX_MIRROR_LENGTH = 3, >+ >+ UBIDI_MAX_VALUES_INDEX = 15, >+ UBIDI_IX_TOP = 16, >+ >+ /* UBIDI_CLASS_SHIFT = 0, */ /* bidi class: 5 bits (4..0) */ >+ UBIDI_JT_SHIFT = 5, /* joining type: 3 bits (7..5) */ >+ >+ /* UBIDI__SHIFT = 8, reserved: 2 bits (9..8) */ >+ >+ UBIDI_JOIN_CONTROL_SHIFT = 10, >+ UBIDI_BIDI_CONTROL_SHIFT = 11, >+ >+ UBIDI_IS_MIRRORED_SHIFT = 12, /* 'is mirrored' */ >+ UBIDI_MIRROR_DELTA_SHIFT = 13, /* bidi mirroring delta: 3 bits (15..13) */ >+ >+ UBIDI_MAX_JG_SHIFT = 16, /* max JG value in indexes[UBIDI_MAX_VALUES_INDEX] bits 23..16 */ >+ >+ UBIDI_ESC_MIRROR_DELTA = -4, >+ UBIDI_MIN_MIRROR_DELTA = -3, >+ UBIDI_MAX_MIRROR_DELTA = 3, >+ >+ /* the source Unicode code point takes 21 bits (20..0) */ >+ UBIDI_MIRROR_INDEX_SHIFT = 21, >+ UBIDI_MAX_MIRROR_INDEX = 0x7ff >+}; >+ >+#define UBIDI_GET_MIRROR_CODE_POINT(m) (UChar32)((m) & 0x1fffff) >+#define UBIDI_GET_MIRROR_INDEX(m) ((m) >> UBIDI_MIRROR_INDEX_SHIFT) >+ >+#define UBIDI_CLASS_MASK 0x0000001f >+#define UBIDI_JT_MASK 0x000000e0 >+#define UBIDI_MAX_JG_MASK 0x00ff0000 >+#define UBIDI_GET_CLASS(props) ((props) & UBIDI_CLASS_MASK) >+#define UBIDI_GET_FLAG(props, shift) (((props) >> (shift))&1) >+#define UPROPS_DT_MASK 0x0000001f >+ >+namespace BidiProp { >+ >+struct UBiDiProps { >+ void *mem; >+ const int32_t *indexes; >+ const uint32_t *mirrors; >+ const uint8_t *jgArray; >+ >+ UTrie trie; >+ uint8_t formatVersion[4]; >+}; >+ >+#include "ubidi_props_data.c" >+} // namespace BidiProp >+ >+#define _NORM_MIN_SPECIAL 0xfc000000 >+#define _NORM_SURROGATES_TOP 0xfff00000 >+#define _NORM_AUX_FNC_MASK (uint32_t)(_NORM_AUX_MAX_FNC - 1) >+#define _NORM_AUX_MAX_FNC ((int32_t)1 << _NORM_AUX_COMP_EX_SHIFT) >+ >+enum { >+ _NORM_AUX_COMP_EX_SHIFT = 10, >+ _NORM_AUX_UNSAFE_SHIFT = 11, >+ _NORM_AUX_NFC_SKIPPABLE_F_SHIFT = 12, >+ >+ _NORM_INDEX_TOP = 32, /* changing this requires a new formatVersion */ >+ >+ _NORM_CC_SHIFT = 8, /* UnicodeData.txt combining class in bits 15..8 */ >+ >+ _NORM_EXTRA_SHIFT = 16, /* 16 bits for the index to UChars and other extra data */ >+}; >+ >+namespace NormProp { >+ >+static int32_t getFoldingNormOffset(uint32_t norm32) >+{ >+ if (_NORM_MIN_SPECIAL <= norm32 && norm32 < _NORM_SURROGATES_TOP) { >+ return UTRIE_BMP_INDEX_LENGTH + ( >+ ((int32_t) norm32 >> (_NORM_EXTRA_SHIFT-UTRIE_SURROGATE_BLOCK_BITS)) & >+ (0x3ff << UTRIE_SURROGATE_BLOCK_BITS) >+ ); >+ } else >+ return 0; >+} >+ >+static int32_t getFoldingAuxOffset(uint32_t data) >+{ >+ return (int32_t)(data & _NORM_AUX_FNC_MASK) << UTRIE_SURROGATE_BLOCK_BITS; >+} >+ >+#include "unorm_props_data.c" >+} // namespace NormProp >+ >+uint32_t u_getUnicodeProperties(UChar32 c, int32_t column) >+{ >+ uint16_t vecIndex; >+ >+ if (column == -1) { >+ uint32_t props; >+ GET_PROPS(c, props); >+ return props; >+ } >+ >+ if (column < 0 || column >= CharProp::propsVectorsColumns) >+ return 0; >+ >+ UTRIE_GET16(&CharProp::propsVectorsTrie, c, vecIndex); >+ return CharProp::propsVectors[vecIndex + column]; >+} >+ >+namespace WTF { >+namespace Unicode { >+ >+Direction direction(UChar32 c) >+{ >+ uint32_t props; >+ GET_BIDI_PROPS(&BidiProp::ubidi_props_singleton, c, props); >+ return static_cast<Direction>(UBIDI_GET_CLASS(props)); >+} >+ >+CharCategory category(unsigned int c) >+{ >+ uint32_t props; >+ GET_PROPS(c, props); >+ return static_cast<CharCategory>(TO_MASK((int8_t)(props & 0x1f))); >+} >+ >+DecompositionType decompositionType(UChar32 c) >+{ >+ return static_cast<DecompositionType>(u_getUnicodeProperties(c, 2) & UPROPS_DT_MASK); >+} >+ >+unsigned char combiningClass(UChar32 c) >+{ >+ uint32_t norm32; >+ >+ UTRIE_GET32(&NormProp::normTrie, c, norm32); >+ return (uint8_t)(norm32 >> _NORM_CC_SHIFT); >+} >+ >+wchar_t mirroredChar(UChar32 c) >+{ >+ const BidiProp::UBiDiProps *bidiProps = &BidiProp::ubidi_props_singleton; >+ >+ uint32_t props; >+ int32_t delta; >+ >+ GET_BIDI_PROPS(bidiProps, c, props); >+ delta = ((int16_t)props) >> UBIDI_MIRROR_DELTA_SHIFT; >+ if (delta != UBIDI_ESC_MIRROR_DELTA) >+ return c + delta; >+ >+ /* look for mirror code point in the mirrors[] table */ >+ const uint32_t *mirrors = bidiProps->mirrors; >+ int32_t length = bidiProps->indexes[UBIDI_IX_MIRROR_LENGTH]; >+ >+ /* linear search */ >+ for (int32_t i = 0; i < length; ++i) { >+ uint32_t mirror = mirrors[i]; >+ UChar32 mirroredCodePoint = UBIDI_GET_MIRROR_CODE_POINT(mirror); >+ if (c == mirroredCodePoint) >+ /* found c, return its mirror code point using the index in m */ >+ return UBIDI_GET_MIRROR_CODE_POINT(mirrors[UBIDI_GET_MIRROR_INDEX(mirror)]); >+ >+ if (c < mirroredCodePoint) >+ break; >+ } >+ >+ /* c not found, return it itself */ >+ return c; >+} >+ >+int digitValue(wchar_t c) >+{ >+ uint32_t props; >+ GET_PROPS(c, props); >+ >+ if (((props >> UPROPS_NUMERIC_TYPE_SHIFT) & 7) == 1) >+ return (props >> UPROPS_NUMERIC_VALUE_SHIFT) & 0xff; >+ return -1; >+} >+ >+} // namespace Unicode >+} // namespace WTF >\ No newline at end of file >diff --git a/JavaScriptCore/wtf/unicode/wince/UnicodeWince.h b/JavaScriptCore/wtf/unicode/wince/UnicodeWince.h >new file mode 100644 >index 0000000..89317aa >--- /dev/null >+++ b/JavaScriptCore/wtf/unicode/wince/UnicodeWince.h >@@ -0,0 +1,297 @@ >+/* >+ * Copyright (C) 2006 George Staikos <staikos@kde.org> >+ * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> >+ * Copyright (C) 2007 Apple Computer, Inc. All rights reserved. >+ * Copyright (C) 2007-2008 Torch Mobile, Inc. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#ifndef KJS_UNICODE_WINCE_H >+#define KJS_UNICODE_WINCE_H >+ >+#define TO_MASK(x) (1 << (x)) >+ >+typedef wchar_t UChar; >+typedef unsigned __int32 UChar32; >+ >+// some defines from ICU needed one or two places >+ >+#define U16_IS_LEAD(c) (((c) & 0xfffffc00) == 0xd800) >+#define U16_IS_TRAIL(c) (((c) & 0xfffffc00) == 0xdc00) >+#define U16_SURROGATE_OFFSET ((0xd800 << 10UL) + 0xdc00 - 0x10000) >+#define U16_GET_SUPPLEMENTARY(lead, trail) \ >+ (((UChar32)(lead) << 10UL) + (UChar32)(trail) - U16_SURROGATE_OFFSET) >+ >+#define U16_LEAD(supplementary) (UChar)(((supplementary) >> 10) + 0xd7c0) >+#define U16_TRAIL(supplementary) (UChar)(((supplementary) & 0x3ff) | 0xdc00) >+ >+#define U_IS_SURROGATE(c) (((c) & 0xfffff800) == 0xd800) >+#define U16_IS_SURROGATE(c) U_IS_SURROGATE(c) >+#define U16_IS_SURROGATE_LEAD(c) (((c) & 0x400) == 0) >+ >+#define U16_NEXT(s, i, length, c) { \ >+ (c)=(s)[(i)++]; \ >+ if (U16_IS_LEAD(c)) { \ >+ uint16_t __c2; \ >+ if ((i) < (length) && U16_IS_TRAIL(__c2 = (s)[(i)])) { \ >+ ++(i); \ >+ (c) = U16_GET_SUPPLEMENTARY((c), __c2); \ >+ } \ >+ } \ >+} >+ >+#define U16_PREV(s, start, i, c) { \ >+ (c)=(s)[--(i)]; \ >+ if (U16_IS_TRAIL(c)) { \ >+ uint16_t __c2; \ >+ if ((i) > (start) && U16_IS_LEAD(__c2 = (s)[(i) - 1])) { \ >+ --(i); \ >+ (c) = U16_GET_SUPPLEMENTARY(__c2, (c)); \ >+ } \ >+ } \ >+} >+ >+#define U16_IS_SINGLE(c) !U_IS_SURROGATE(c) >+ >+namespace WTF { >+ >+ namespace Unicode { >+ >+ enum IcuCharDirection { >+ U_LEFT_TO_RIGHT = 0, >+ U_RIGHT_TO_LEFT = 1, >+ U_EUROPEAN_NUMBER = 2, >+ U_EUROPEAN_NUMBER_SEPARATOR = 3, >+ U_EUROPEAN_NUMBER_TERMINATOR = 4, >+ U_ARABIC_NUMBER = 5, >+ U_COMMON_NUMBER_SEPARATOR = 6, >+ U_BLOCK_SEPARATOR = 7, >+ U_SEGMENT_SEPARATOR = 8, >+ U_WHITE_SPACE_NEUTRAL = 9, >+ U_OTHER_NEUTRAL = 10, >+ U_LEFT_TO_RIGHT_EMBEDDING = 11, >+ U_LEFT_TO_RIGHT_OVERRIDE = 12, >+ U_RIGHT_TO_LEFT_ARABIC = 13, >+ U_RIGHT_TO_LEFT_EMBEDDING = 14, >+ U_RIGHT_TO_LEFT_OVERRIDE = 15, >+ U_POP_DIRECTIONAL_FORMAT = 16, >+ U_DIR_NON_SPACING_MARK = 17, >+ U_BOUNDARY_NEUTRAL = 18, >+ U_CHAR_DIRECTION_COUNT >+ }; >+ >+ enum IcuDecompositionType { >+ U_DT_NONE, /*[none]*/ /*See note !!*/ >+ U_DT_CANONICAL, /*[can]*/ >+ U_DT_COMPAT, /*[com]*/ >+ U_DT_CIRCLE, /*[enc]*/ >+ U_DT_FINAL, /*[fin]*/ >+ U_DT_FONT, /*[font]*/ >+ U_DT_FRACTION, /*[fra]*/ >+ U_DT_INITIAL, /*[init]*/ >+ U_DT_ISOLATED, /*[iso]*/ >+ U_DT_MEDIAL, /*[med]*/ >+ U_DT_NARROW, /*[nar]*/ >+ U_DT_NOBREAK, /*[nb]*/ >+ U_DT_SMALL, /*[sml]*/ >+ U_DT_SQUARE, /*[sqr]*/ >+ U_DT_SUB, /*[sub]*/ >+ U_DT_SUPER, /*[sup]*/ >+ U_DT_VERTICAL, /*[vert]*/ >+ U_DT_WIDE, /*[wide]*/ >+ U_DT_COUNT /* 18 */ >+ }; >+ >+ enum IcuCharCategory { >+ U_UNASSIGNED = 0, >+ U_GENERAL_OTHER_TYPES = 0, >+ U_UPPERCASE_LETTER = 1, >+ U_LOWERCASE_LETTER = 2, >+ U_TITLECASE_LETTER = 3, >+ U_MODIFIER_LETTER = 4, >+ U_OTHER_LETTER = 5, >+ U_NON_SPACING_MARK = 6, >+ U_ENCLOSING_MARK = 7, >+ U_COMBINING_SPACING_MARK = 8, >+ U_DECIMAL_DIGIT_NUMBER = 9, >+ U_LETTER_NUMBER = 10, >+ U_OTHER_NUMBER = 11, >+ U_SPACE_SEPARATOR = 12, >+ U_LINE_SEPARATOR = 13, >+ U_PARAGRAPH_SEPARATOR = 14, >+ U_CONTROL_CHAR = 15, >+ U_FORMAT_CHAR = 16, >+ U_PRIVATE_USE_CHAR = 17, >+ U_SURROGATE = 18, >+ U_DASH_PUNCTUATION = 19, >+ U_START_PUNCTUATION = 20, >+ U_END_PUNCTUATION = 21, >+ U_CONNECTOR_PUNCTUATION = 22, >+ U_OTHER_PUNCTUATION = 23, >+ U_MATH_SYMBOL = 24, >+ U_CURRENCY_SYMBOL = 25, >+ U_MODIFIER_SYMBOL = 26, >+ U_OTHER_SYMBOL = 27, >+ U_INITIAL_PUNCTUATION = 28, >+ U_FINAL_PUNCTUATION = 29, >+ U_CHAR_CATEGORY_COUNT >+ }; >+ >+ enum Direction { >+ LeftToRight = U_LEFT_TO_RIGHT, >+ RightToLeft = U_RIGHT_TO_LEFT, >+ EuropeanNumber = U_EUROPEAN_NUMBER, >+ EuropeanNumberSeparator = U_EUROPEAN_NUMBER_SEPARATOR, >+ EuropeanNumberTerminator = U_EUROPEAN_NUMBER_TERMINATOR, >+ ArabicNumber = U_ARABIC_NUMBER, >+ CommonNumberSeparator = U_COMMON_NUMBER_SEPARATOR, >+ BlockSeparator = U_BLOCK_SEPARATOR, >+ SegmentSeparator = U_SEGMENT_SEPARATOR, >+ WhiteSpaceNeutral = U_WHITE_SPACE_NEUTRAL, >+ OtherNeutral = U_OTHER_NEUTRAL, >+ LeftToRightEmbedding = U_LEFT_TO_RIGHT_EMBEDDING, >+ LeftToRightOverride = U_LEFT_TO_RIGHT_OVERRIDE, >+ RightToLeftArabic = U_RIGHT_TO_LEFT_ARABIC, >+ RightToLeftEmbedding = U_RIGHT_TO_LEFT_EMBEDDING, >+ RightToLeftOverride = U_RIGHT_TO_LEFT_OVERRIDE, >+ PopDirectionalFormat = U_POP_DIRECTIONAL_FORMAT, >+ NonSpacingMark = U_DIR_NON_SPACING_MARK, >+ BoundaryNeutral = U_BOUNDARY_NEUTRAL >+ }; >+ >+ enum DecompositionType { >+ DecompositionNone = U_DT_NONE, >+ DecompositionCanonical = U_DT_CANONICAL, >+ DecompositionCompat = U_DT_COMPAT, >+ DecompositionCircle = U_DT_CIRCLE, >+ DecompositionFinal = U_DT_FINAL, >+ DecompositionFont = U_DT_FONT, >+ DecompositionFraction = U_DT_FRACTION, >+ DecompositionInitial = U_DT_INITIAL, >+ DecompositionIsolated = U_DT_ISOLATED, >+ DecompositionMedial = U_DT_MEDIAL, >+ DecompositionNarrow = U_DT_NARROW, >+ DecompositionNoBreak = U_DT_NOBREAK, >+ DecompositionSmall = U_DT_SMALL, >+ DecompositionSquare = U_DT_SQUARE, >+ DecompositionSub = U_DT_SUB, >+ DecompositionSuper = U_DT_SUPER, >+ DecompositionVertical = U_DT_VERTICAL, >+ DecompositionWide = U_DT_WIDE, >+ }; >+ >+ enum CharCategory { >+ NoCategory = 0, >+ Other_NotAssigned = TO_MASK(U_GENERAL_OTHER_TYPES), >+ Letter_Uppercase = TO_MASK(U_UPPERCASE_LETTER), >+ Letter_Lowercase = TO_MASK(U_LOWERCASE_LETTER), >+ Letter_Titlecase = TO_MASK(U_TITLECASE_LETTER), >+ Letter_Modifier = TO_MASK(U_MODIFIER_LETTER), >+ Letter_Other = TO_MASK(U_OTHER_LETTER), >+ >+ Mark_NonSpacing = TO_MASK(U_NON_SPACING_MARK), >+ Mark_Enclosing = TO_MASK(U_ENCLOSING_MARK), >+ Mark_SpacingCombining = TO_MASK(U_COMBINING_SPACING_MARK), >+ >+ Number_DecimalDigit = TO_MASK(U_DECIMAL_DIGIT_NUMBER), >+ Number_Letter = TO_MASK(U_LETTER_NUMBER), >+ Number_Other = TO_MASK(U_OTHER_NUMBER), >+ >+ Separator_Space = TO_MASK(U_SPACE_SEPARATOR), >+ Separator_Line = TO_MASK(U_LINE_SEPARATOR), >+ Separator_Paragraph = TO_MASK(U_PARAGRAPH_SEPARATOR), >+ >+ Other_Control = TO_MASK(U_CONTROL_CHAR), >+ Other_Format = TO_MASK(U_FORMAT_CHAR), >+ Other_PrivateUse = TO_MASK(U_PRIVATE_USE_CHAR), >+ Other_Surrogate = TO_MASK(U_SURROGATE), >+ >+ Punctuation_Dash = TO_MASK(U_DASH_PUNCTUATION), >+ Punctuation_Open = TO_MASK(U_START_PUNCTUATION), >+ Punctuation_Close = TO_MASK(U_END_PUNCTUATION), >+ Punctuation_Connector = TO_MASK(U_CONNECTOR_PUNCTUATION), >+ Punctuation_Other = TO_MASK(U_OTHER_PUNCTUATION), >+ >+ Symbol_Math = TO_MASK(U_MATH_SYMBOL), >+ Symbol_Currency = TO_MASK(U_CURRENCY_SYMBOL), >+ Symbol_Modifier = TO_MASK(U_MODIFIER_SYMBOL), >+ Symbol_Other = TO_MASK(U_OTHER_SYMBOL), >+ >+ Punctuation_InitialQuote = TO_MASK(U_INITIAL_PUNCTUATION), >+ Punctuation_FinalQuote = TO_MASK(U_FINAL_PUNCTUATION) >+ }; >+ >+ CharCategory category(unsigned int c); >+ >+ bool isSpace(wchar_t c); >+ bool isLetter(wchar_t c); >+ bool isPrintableChar(wchar_t c); >+ bool isUpper(wchar_t c); >+ bool isLower(wchar_t c); >+ bool isPunct(wchar_t c); >+ bool isDigit(wchar_t c); >+ inline bool isSeparatorSpace(wchar_t c) { return category(c) == Separator_Space; } >+ inline bool isHighSurrogate(wchar_t c) { return (c & 0xfc00) == 0xd800; } >+ inline bool isLowSurrogate(wchar_t c) { return (c & 0xfc00) == 0xdc00; } >+ >+ wchar_t toLower(wchar_t c); >+ wchar_t toUpper(wchar_t c); >+ wchar_t foldCase(wchar_t c); >+ wchar_t toTitleCase(wchar_t c); >+ int toLower(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError); >+ int toUpper(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError); >+ int foldCase(UChar* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError); >+ >+ int digitValue(wchar_t c); >+ >+ wchar_t mirroredChar(UChar32 c); >+ unsigned char combiningClass(UChar32 c); >+ DecompositionType decompositionType(UChar32 c); >+ Direction direction(UChar32 c); >+ inline bool isArabicChar(UChar32 c) >+ { >+ return false; // FIXME: implement! >+ } >+ >+ inline bool hasLineBreakingPropertyComplexContext(UChar32 c) >+ { >+ return false; // FIXME: implement! >+ } >+ >+ inline int umemcasecmp(const wchar_t* a, const wchar_t* b, int len) >+ { >+ for (int i = 0; i < len; ++i) { >+ wchar_t c1 = foldCase(a[i]); >+ wchar_t c2 = foldCase(b[i]); >+ if (c1 != c2) >+ return c1 - c2; >+ } >+ return 0; >+ } >+ >+ inline UChar32 surrogateToUcs4(wchar_t high, wchar_t low) >+ { >+ return (UChar32(high) << 10) + low - 0x35fdc00; >+ } >+ >+ } // namespace Unicode >+ >+} // namespace WTF >+ >+#endif >+// vim: ts=2 sw=2 et
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 27305
:
32792
|
34013
|
34014
|
34223
|
34225
|
34277