Changeset 30942 in webkit
- Timestamp:
- Mar 10, 2008 3:06:44 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSStringRef.cpp
r29663 r30942 45 45 { 46 46 JSLock lock; 47 return toRef(UString( reinterpret_cast<const KJS::UChar*>(chars), static_cast<int>(numChars)).rep()->ref());47 return toRef(UString(chars, static_cast<int>(numChars)).rep()->ref()); 48 48 } 49 49 … … 53 53 54 54 size_t length = strlen(string); 55 Vector< ::UChar, 1024> buffer(length);56 ::UChar* p = buffer.data();55 Vector<UChar, 1024> buffer(length); 56 UChar* p = buffer.data(); 57 57 if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length)) 58 58 return 0; 59 59 60 return toRef(UString( reinterpret_cast<KJS::UChar*>(buffer.data()), p - buffer.data()).rep()->ref());60 return toRef(UString(buffer.data(), p - buffer.data()).rep()->ref()); 61 61 } 62 62 -
trunk/JavaScriptCore/API/JSStringRefCF.cpp
r29663 r30942 46 46 UniChar* buffer = static_cast<UniChar*>(fastMalloc(sizeof(UniChar) * length)); 47 47 CFStringGetCharacters(string, CFRangeMake(0, length), buffer); 48 rep = UString( reinterpret_cast<UChar*>(buffer), length, false).rep()->ref();48 rep = UString(buffer, length, false).rep()->ref(); 49 49 } 50 50 return toRef(rep); -
trunk/JavaScriptCore/ChangeLog
r30920 r30942 1 2008-03-10 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Darin. 4 5 Remove KJS::UChar, use ::UChar instead 6 http://bugs.webkit.org/show_bug.cgi?id=17017 7 8 * API/JSStringRef.cpp: 9 (JSStringCreateWithCharacters): 10 (JSStringCreateWithUTF8CString): 11 * API/JSStringRefCF.cpp: 12 (JSStringCreateWithCFString): 13 * JavaScriptCore.exp: 14 * kjs/Parser.h: 15 * kjs/function.cpp: 16 (KJS::decode): 17 (KJS::parseInt): 18 (KJS::parseFloat): 19 (KJS::globalFuncEscape): 20 (KJS::globalFuncUnescape): 21 * kjs/function_object.cpp: 22 (KJS::FunctionObjectImp::construct): 23 * kjs/identifier.cpp: 24 (KJS::Identifier::equal): 25 (KJS::CStringTranslator::translate): 26 * kjs/interpreter.h: 27 * kjs/lexer.cpp: 28 (KJS::Lexer::setCode): 29 (KJS::Lexer::shift): 30 (KJS::Lexer::lex): 31 (KJS::Lexer::convertUnicode): 32 (KJS::Lexer::makeIdentifier): 33 * kjs/lookup.cpp: 34 (KJS::keysMatch): 35 * kjs/nodes2string.cpp: 36 (KJS::escapeStringForPrettyPrinting): 37 (KJS::SourceStream::operator<<): 38 * kjs/regexp.cpp: 39 (KJS::RegExp::RegExp): 40 (KJS::RegExp::match): 41 * kjs/string_object.cpp: 42 (KJS::substituteBackreferences): 43 (KJS::stringProtoFuncCharCodeAt): 44 (KJS::stringProtoFuncToLowerCase): 45 (KJS::stringProtoFuncToUpperCase): 46 (KJS::stringProtoFuncToLocaleLowerCase): 47 (KJS::stringProtoFuncToLocaleUpperCase): 48 * kjs/ustring.cpp: 49 (KJS::UString::Rep::computeHash): 50 (KJS::UString::UString): 51 (KJS::UString::append): 52 (KJS::UString::ascii): 53 (KJS::UString::operator=): 54 (KJS::UString::is8Bit): 55 (KJS::UString::toStrictUInt32): 56 (KJS::UString::find): 57 (KJS::operator==): 58 (KJS::operator<): 59 (KJS::compare): 60 (KJS::UString::UTF8String): 61 * kjs/ustring.h: 62 * pcre/pcre.h: 63 1 64 2008-03-09 Steve Falkenburg <sfalken@apple.com> 2 65 -
trunk/JavaScriptCore/JavaScriptCore.exp
r30849 r30942 78 78 __Z15jsRegExpExecutePK8JSRegExpPKtiiPii 79 79 __ZN3KJS10Identifier11addSlowCaseEPNS_7UString3RepE 80 __ZN3KJS10Identifier3addEPK NS_5UCharEi80 __ZN3KJS10Identifier3addEPKti 81 81 __ZN3KJS10Identifier3addEPKc 82 82 __ZN3KJS10Identifier5equalEPKNS_7UString3RepEPKc … … 84 84 __ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc 85 85 __ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringE 86 __ZN3KJS11Interpreter11checkSyntaxEPNS_9ExecStateERKNS_7UStringEiPK NS_5UCharEi86 __ZN3KJS11Interpreter11checkSyntaxEPNS_9ExecStateERKNS_7UStringEiPKti 87 87 __ZN3KJS11Interpreter21shouldPrintExceptionsEv 88 88 __ZN3KJS11Interpreter24setShouldPrintExceptionsEb 89 __ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiPK NS_5UCharEiPNS_7JSValueE89 __ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiPKtiPNS_7JSValueE 90 90 __ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiS5_PNS_7JSValueE 91 91 __ZN3KJS11JSImmediate4typeEPKNS_7JSValueE … … 149 149 __ZN3KJS6JSLock9lockCountEv 150 150 __ZN3KJS6Lookup9findEntryEPKNS_9HashTableERKNS_10IdentifierE 151 __ZN3KJS6Parser5parseEiPK NS_5UCharEjPiS4_PNS_7UStringE151 __ZN3KJS6Parser5parseEiPKtjPiS3_PNS_7UStringE 152 152 __ZN3KJS6parserEv 153 153 __ZN3KJS7CStringD1Ev … … 158 158 __ZN3KJS7UString6appendEPKc 159 159 __ZN3KJS7UString6appendERKS0_ 160 __ZN3KJS7UStringC1EPK NS_5UCharEi160 __ZN3KJS7UStringC1EPKti 161 161 __ZN3KJS7UStringC1EPKc 162 162 __ZN3KJS7UStringC1ERKS0_S2_ -
trunk/JavaScriptCore/kjs/Parser.h
r29059 r30942 37 37 class ProgramNode; 38 38 class UString; 39 40 struct UChar;41 39 42 40 template <typename T> struct ParserRefCountedData : ParserRefCounted { -
trunk/JavaScriptCore/kjs/function.cpp
r30871 r30942 516 516 if (c == '%') { 517 517 int charLen = 0; 518 if (k <= len - 3 && isASCIIHexDigit(p[1] .uc) && isASCIIHexDigit(p[2].uc)) {519 const char b0 = Lexer::convertHex(p[1] .uc, p[2].uc);518 if (k <= len - 3 && isASCIIHexDigit(p[1]) && isASCIIHexDigit(p[2])) { 519 const char b0 = Lexer::convertHex(p[1], p[2]); 520 520 const int sequenceLen = UTF8SequenceLength(b0); 521 521 if (sequenceLen != 0 && k <= len - sequenceLen * 3) { … … 525 525 for (int i = 1; i < sequenceLen; ++i) { 526 526 const UChar* q = p + i * 3; 527 if (q[0] == '%' && isASCIIHexDigit(q[1] .uc) && isASCIIHexDigit(q[2].uc))528 sequence[i] = Lexer::convertHex(q[1] .uc, q[2].uc);527 if (q[0] == '%' && isASCIIHexDigit(q[1]) && isASCIIHexDigit(q[2])) 528 sequence[i] = Lexer::convertHex(q[1], q[2]); 529 529 else { 530 530 charLen = 0; … … 553 553 // For that, it's good to support the wonky "%u" syntax for compatibility with WinIE. 554 554 if (k <= len - 6 && p[1] == 'u' 555 && isASCIIHexDigit(p[2] .uc) && isASCIIHexDigit(p[3].uc)556 && isASCIIHexDigit(p[4] .uc) && isASCIIHexDigit(p[5].uc)) {555 && isASCIIHexDigit(p[2]) && isASCIIHexDigit(p[3]) 556 && isASCIIHexDigit(p[4]) && isASCIIHexDigit(p[5])) { 557 557 charLen = 6; 558 u = Lexer::convertUnicode(p[2] .uc, p[3].uc, p[4].uc, p[5].uc);558 u = Lexer::convertUnicode(p[2], p[3], p[4], p[5]); 559 559 } 560 560 } 561 if (charLen && (u .uc == 0 || u.uc >= 128 || !strchr(do_not_unescape, u.low()))) {561 if (charLen && (u == 0 || u >= 128 || !strchr(do_not_unescape, u))) { 562 562 c = u; 563 563 k += charLen - 1; … … 632 632 int p = 0; 633 633 634 while (p < length && isStrWhiteSpace(s[p] .uc)) {634 while (p < length && isStrWhiteSpace(s[p])) { 635 635 ++p; 636 636 } … … 663 663 double number = 0; 664 664 while (p < length) { 665 int digit = parseDigit(s[p] .uc, radix);665 int digit = parseDigit(s[p], radix); 666 666 if (digit == -1) 667 667 break; … … 691 691 int length = s.size(); 692 692 int p = 0; 693 while (p < length && isStrWhiteSpace(s[p] .uc)) {693 while (p < length && isStrWhiteSpace(s[p])) { 694 694 ++p; 695 695 } … … 817 817 const UChar* c = str.data(); 818 818 for (int k = 0; k < str.size(); k++, c++) { 819 int u = c ->uc;819 int u = c[0]; 820 820 if (u > 255) { 821 821 char tmp[7]; … … 842 842 const UChar* c = str.data() + k; 843 843 UChar u; 844 if ( *c == UChar('%') && k <= len - 6 && *(c + 1) == UChar('u')) {845 if (Lexer::isHexDigit( (c + 2)->uc) && Lexer::isHexDigit((c + 3)->uc) && Lexer::isHexDigit((c + 4)->uc) && Lexer::isHexDigit((c + 5)->uc)) {846 u = Lexer::convertUnicode( (c + 2)->uc, (c + 3)->uc, (c + 4)->uc, (c + 5)->uc);844 if (c[0] == '%' && k <= len - 6 && c[1] == 'u') { 845 if (Lexer::isHexDigit(c[2]) && Lexer::isHexDigit(c[3]) && Lexer::isHexDigit(c[4]) && Lexer::isHexDigit(c[5])) { 846 u = Lexer::convertUnicode(c[2], c[3], c[4], c[5]); 847 847 c = &u; 848 848 k += 5; 849 849 } 850 } else if ( *c == UChar('%') && k <= len - 3 && Lexer::isHexDigit((c + 1)->uc) && Lexer::isHexDigit((c + 2)->uc)) {851 u = UChar(Lexer::convertHex( (c+1)->uc, (c+2)->uc));850 } else if (c[0] == '%' && k <= len - 3 && Lexer::isHexDigit(c[1]) && Lexer::isHexDigit(c[2])) { 851 u = UChar(Lexer::convertHex(c[1], c[2])); 852 852 c = &u; 853 853 k += 2; -
trunk/JavaScriptCore/kjs/function_object.cpp
r30679 r30942 193 193 while (*c == ' ' && i < len) 194 194 c++, i++; 195 if (Lexer::isIdentStart(c ->uc)) { // else error195 if (Lexer::isIdentStart(c[0])) { // else error 196 196 param = UString(c, 1); 197 197 c++, i++; 198 while (i < len && (Lexer::isIdentPart(c ->uc))) {198 while (i < len && (Lexer::isIdentPart(c[0]))) { 199 199 param += UString(c, 1); 200 200 c++, i++; -
trunk/JavaScriptCore/kjs/identifier.cpp
r27176 r30942 68 68 const UChar *d = r->data(); 69 69 for (int i = 0; i != length; ++i) 70 if (d[i] .uc!= (unsigned char)s[i])70 if (d[i] != (unsigned char)s[i]) 71 71 return false; 72 72 return s[length] == 0; … … 79 79 const UChar *d = r->data(); 80 80 for (int i = 0; i != length; ++i) 81 if (d[i] .uc != s[i].uc)81 if (d[i] != s[i]) 82 82 return false; 83 83 return true; … … 92 92 const UChar *s = b->data(); 93 93 for (int i = 0; i != length; ++i) 94 if (d[i] .uc != s[i].uc)94 if (d[i] != s[i]) 95 95 return false; 96 96 return true; … … 114 114 UChar *d = static_cast<UChar *>(fastMalloc(sizeof(UChar) * length)); 115 115 for (size_t i = 0; i != length; i++) 116 d[i] = c[i];116 d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend 117 117 118 118 UString::Rep *r = UString::Rep::create(d, static_cast<int>(length)).releaseRef(); -
trunk/JavaScriptCore/kjs/interpreter.h
r28468 r30942 24 24 #define KJS_Interpreter_h 25 25 26 #include <wtf/unicode/Unicode.h> 27 26 28 namespace KJS { 27 29 … … 30 32 class JSValue; 31 33 class UString; 32 33 struct UChar;34 34 35 35 class Interpreter { -
trunk/JavaScriptCore/kjs/lexer.cpp
r29538 r30942 95 95 } 96 96 97 void Lexer::setCode(int startingLineNumber, const KJS::UChar *c, unsigned int len)97 void Lexer::setCode(int startingLineNumber, const UChar* c, unsigned int len) 98 98 { 99 99 yylineno = 1 + startingLineNumber; … … 112 112 113 113 // read first characters 114 current = (length > 0) ? code[0] .uc: -1;115 next1 = (length > 1) ? code[1] .uc: -1;116 next2 = (length > 2) ? code[2] .uc: -1;117 next3 = (length > 3) ? code[3] .uc: -1;114 current = (length > 0) ? code[0] : -1; 115 next1 = (length > 1) ? code[1] : -1; 116 next2 = (length > 2) ? code[2] : -1; 117 next3 = (length > 3) ? code[3] : -1; 118 118 } 119 119 … … 127 127 next1 = next2; 128 128 next2 = next3; 129 next3 = (pos + 3 < length) ? code[pos + 3] .uc: -1;129 next3 = (pos + 3 < length) ? code[pos + 3] : -1; 130 130 } 131 131 } … … 428 428 break; 429 429 } 430 token = convertUnicode(current, next1, next2, next3) .uc;430 token = convertUnicode(current, next1, next2, next3); 431 431 shift(3); 432 432 if (!isIdentStart(token)) { … … 442 442 break; 443 443 } 444 token = convertUnicode(current, next1, next2, next3) .uc;444 token = convertUnicode(current, next1, next2, next3); 445 445 shift(3); 446 446 if (!isIdentPart(token)) { … … 793 793 } 794 794 795 KJS::UChar Lexer::convertUnicode(int c1, int c2, int c3, int c4) 796 { 797 return KJS::UChar((convertHex(c1) << 4) + convertHex(c2), 798 (convertHex(c3) << 4) + convertHex(c4)); 795 UChar Lexer::convertUnicode(int c1, int c2, int c3, int c4) 796 { 797 unsigned char highByte = (convertHex(c1) << 4) + convertHex(c2); 798 unsigned char lowByte = (convertHex(c3) << 4) + convertHex(c4); 799 return (highByte << 8 | lowByte); 799 800 } 800 801 … … 813 814 } 814 815 815 void Lexer::record16( KJS::UChar c)816 void Lexer::record16(UChar c) 816 817 { 817 818 m_buffer16.append(c); … … 881 882 } 882 883 883 Identifier* Lexer::makeIdentifier(const Vector< KJS::UChar>& buffer)884 Identifier* Lexer::makeIdentifier(const Vector<UChar>& buffer) 884 885 { 885 886 KJS::Identifier* identifier = new KJS::Identifier(buffer.data(), buffer.size()); … … 888 889 } 889 890 890 UString* Lexer::makeUString(const Vector< KJS::UChar>& buffer)891 UString* Lexer::makeUString(const Vector<UChar>& buffer) 891 892 { 892 893 UString* string = new UString(buffer); -
trunk/JavaScriptCore/kjs/lookup.cpp
r27608 r30942 32 32 const char* end = s + len; 33 33 for (; s != end; c++, s++) 34 if ( c->uc != *s)34 if (*c != *s) 35 35 return false; 36 36 return *s == 0; -
trunk/JavaScriptCore/kjs/nodes2string.cpp
r30871 r30942 79 79 80 80 for (int i = 0; i < s.size(); i++) { 81 unsigned short c = s.data()[i] .unicode();81 unsigned short c = s.data()[i]; 82 82 switch (c) { 83 83 case '\"': … … 160 160 m_numberNeedsParens = false; 161 161 m_atStartOfStatement = false; 162 UChar ch(c); 162 // use unsigned char to zero-extend instead of sign-extend 163 UChar ch(static_cast<unsigned char>(c)); 163 164 m_string.append(ch); 164 165 return *this; -
trunk/JavaScriptCore/kjs/regexp.cpp
r30408 r30942 39 39 , m_numSubpatterns(0) 40 40 { 41 m_regExp = jsRegExpCompile(reinterpret_cast<const ::UChar*>(pattern.data()), pattern.size(),41 m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(pattern.data()), pattern.size(), 42 42 JSRegExpDoNotIgnoreCase, JSRegExpSingleLine, &m_numSubpatterns, &m_constructionError); 43 43 } … … 73 73 } 74 74 75 m_regExp = jsRegExpCompile(reinterpret_cast<const ::UChar*>(pattern.data()), pattern.size(),75 m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(pattern.data()), pattern.size(), 76 76 ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError); 77 77 } … … 114 114 } 115 115 116 int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const ::UChar*>(s.data()), s.size(), i, offsetVector, offsetVectorSize);116 int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const UChar*>(s.data()), s.size(), i, offsetVector, offsetVectorSize); 117 117 118 118 if (numMatches < 0) { -
trunk/JavaScriptCore/kjs/string_object.cpp
r30842 r30942 246 246 break; 247 247 248 unsigned short ref = substitutedReplacement[i+1] .unicode();248 unsigned short ref = substitutedReplacement[i+1]; 249 249 int backrefStart = 0; 250 250 int backrefLength = 0; … … 269 269 continue; 270 270 if (substitutedReplacement.size() > i + 2) { 271 ref = substitutedReplacement[i+2] .unicode();271 ref = substitutedReplacement[i+2]; 272 272 if (ref >= '0' && ref <= '9') { 273 273 backrefIndex = 10 * backrefIndex + ref - '0'; … … 451 451 double dpos = a0->toInteger(exec); 452 452 if (dpos >= 0 && dpos < len) 453 result = jsNumber(s[static_cast<int>(dpos)] .unicode());453 result = jsNumber(s[static_cast<int>(dpos)]); 454 454 else 455 455 result = jsNaN(); … … 764 764 if (!ssize) 765 765 return sVal; 766 Vector< ::UChar> buffer(ssize);766 Vector<UChar> buffer(ssize); 767 767 bool error; 768 int length = Unicode::toLower(buffer.data(), ssize, reinterpret_cast<const ::UChar*>(s.data()), ssize, &error);768 int length = Unicode::toLower(buffer.data(), ssize, reinterpret_cast<const UChar*>(s.data()), ssize, &error); 769 769 if (error) { 770 770 buffer.resize(length); 771 length = Unicode::toLower(buffer.data(), length, reinterpret_cast<const ::UChar*>(s.data()), ssize, &error);771 length = Unicode::toLower(buffer.data(), length, reinterpret_cast<const UChar*>(s.data()), ssize, &error); 772 772 if (error) 773 773 return sVal; … … 775 775 if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) 776 776 return sVal; 777 return jsString(UString( reinterpret_cast<UChar*>(buffer.releaseBuffer()), length, false));777 return jsString(UString(buffer.releaseBuffer(), length, false)); 778 778 } 779 779 … … 789 789 if (!ssize) 790 790 return sVal; 791 Vector< ::UChar> buffer(ssize);791 Vector<UChar> buffer(ssize); 792 792 bool error; 793 int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast<const ::UChar*>(s.data()), ssize, &error);793 int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast<const UChar*>(s.data()), ssize, &error); 794 794 if (error) { 795 795 buffer.resize(length); 796 length = Unicode::toUpper(buffer.data(), length, reinterpret_cast<const ::UChar*>(s.data()), ssize, &error);796 length = Unicode::toUpper(buffer.data(), length, reinterpret_cast<const UChar*>(s.data()), ssize, &error); 797 797 if (error) 798 798 return sVal; … … 800 800 if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) 801 801 return sVal; 802 return jsString(UString( reinterpret_cast<UChar*>(buffer.releaseBuffer()), length, false));802 return jsString(UString(buffer.releaseBuffer(), length, false)); 803 803 } 804 804 … … 815 815 if (!ssize) 816 816 return sVal; 817 Vector< ::UChar> buffer(ssize);817 Vector<UChar> buffer(ssize); 818 818 bool error; 819 int length = Unicode::toLower(buffer.data(), ssize, reinterpret_cast<const ::UChar*>(s.data()), ssize, &error);819 int length = Unicode::toLower(buffer.data(), ssize, reinterpret_cast<const UChar*>(s.data()), ssize, &error); 820 820 if (error) { 821 821 buffer.resize(length); 822 length = Unicode::toLower(buffer.data(), length, reinterpret_cast<const ::UChar*>(s.data()), ssize, &error);822 length = Unicode::toLower(buffer.data(), length, reinterpret_cast<const UChar*>(s.data()), ssize, &error); 823 823 if (error) 824 824 return sVal; … … 826 826 if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) 827 827 return sVal; 828 return jsString(UString( reinterpret_cast<UChar*>(buffer.releaseBuffer()), length, false));828 return jsString(UString(buffer.releaseBuffer(), length, false)); 829 829 } 830 830 … … 840 840 if (!ssize) 841 841 return sVal; 842 Vector< ::UChar> buffer(ssize);842 Vector<UChar> buffer(ssize); 843 843 bool error; 844 int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast<const ::UChar*>(s.data()), ssize, &error);844 int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast<const UChar*>(s.data()), ssize, &error); 845 845 if (error) { 846 846 buffer.resize(length); 847 length = Unicode::toUpper(buffer.data(), length, reinterpret_cast<const ::UChar*>(s.data()), ssize, &error);847 length = Unicode::toUpper(buffer.data(), length, reinterpret_cast<const UChar*>(s.data()), ssize, &error); 848 848 if (error) 849 849 return sVal; … … 851 851 if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) 852 852 return sVal; 853 return jsString(UString( reinterpret_cast<UChar*>(buffer.releaseBuffer()), length, false));853 return jsString(UString(buffer.releaseBuffer(), length, false)); 854 854 } 855 855 -
trunk/JavaScriptCore/kjs/ustring.cpp
r29653 r30942 164 164 165 165 // Hack here to avoid a global with a constructor; point to an unsigned short instead of a UChar. 166 static unsigned short almostUChar;166 static UChar sharedEmptyChar; 167 167 UString::Rep UString::Rep::null = { 0, 0, 1, 0, 0, &UString::Rep::null, 0, 0, 0, 0, 0, 0 }; 168 UString::Rep UString::Rep::empty = { 0, 0, 1, 0, 0, &UString::Rep::empty, 0, reinterpret_cast<UChar*>(&almostUChar), 0, 0, 0, 0 };168 UString::Rep UString::Rep::empty = { 0, 0, 1, 0, 0, &UString::Rep::empty, 0, &sharedEmptyChar, 0, 0, 0, 0 }; 169 169 const int normalStatBufferSize = 4096; 170 170 static char *statBuffer = 0; // FIXME: This buffer is never deallocated. … … 265 265 // Main loop 266 266 for (; l > 0; l--) { 267 hash += s[0] .uc;268 tmp = (s[1] .uc<< 11) ^ hash;267 hash += s[0]; 268 tmp = (s[1] << 11) ^ hash; 269 269 hash = (hash << 16) ^ tmp; 270 270 s += 2; … … 274 274 // Handle end case 275 275 if (rem) { 276 hash += s[0] .uc;276 hash += s[0]; 277 277 hash ^= hash << 11; 278 278 hash += hash >> 17; … … 430 430 else { 431 431 for (size_t i = 0; i < length; i++) 432 d[i] .uc = c[i];432 d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend 433 433 m_rep = Rep::create(d, static_cast<int>(length)); 434 434 } … … 710 710 } 711 711 712 UString &UString::append(const UString &t)712 UString& UString::append(const UString &t) 713 713 { 714 714 int thisSize = size(); … … 755 755 } 756 756 757 UString &UString::append(const char *t)757 UString& UString::append(const char *t) 758 758 { 759 759 int thisSize = size(); … … 774 774 if (d) { 775 775 for (int i = 0; i < tSize; ++i) 776 d[thisSize + i] = t[i];776 d[thisSize + i] = static_cast<unsigned char>(t[i]); // use unsigned char to zero-extend instead of sign-extend 777 777 m_rep->len = length; 778 778 m_rep->_hash = 0; … … 784 784 if (d) { 785 785 for (int i = 0; i < tSize; ++i) 786 d[thisSize + i] = t[i];786 d[thisSize + i] = static_cast<unsigned char>(t[i]); // use unsigned char to zero-extend instead of sign-extend 787 787 m_rep = Rep::create(m_rep, 0, length); 788 788 } … … 796 796 memcpy(d, data(), thisSize * sizeof(UChar)); 797 797 for (int i = 0; i < tSize; ++i) 798 d[thisSize + i] = t[i];798 d[thisSize + i] = static_cast<unsigned char>(t[i]); // use unsigned char to zero-extend instead of sign-extend 799 799 m_rep = Rep::create(d, length); 800 800 m_rep->capacity = newCapacity; … … 805 805 } 806 806 807 UString &UString::append(unsigned shortc)807 UString& UString::append(UChar c) 808 808 { 809 809 int thisOffset = m_rep->offset; … … 880 880 const UChar *limit = p + length; 881 881 while (p != limit) { 882 *q = static_cast<char>(p ->uc);882 *q = static_cast<char>(p[0]); 883 883 ++p; 884 884 ++q; … … 889 889 } 890 890 891 UString &UString::operator=(const char *c)891 UString& UString::operator=(const char *c) 892 892 { 893 893 if (!c) { … … 916 916 } 917 917 for (int i = 0; i < l; i++) 918 d[i] .uc = c[i];918 d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend 919 919 920 920 return *this; … … 926 926 const UChar *limit = u + size(); 927 927 while (u < limit) { 928 if (u ->uc> 0xFF)928 if (u[0] > 0xFF) 929 929 return false; 930 930 ++u; … … 1069 1069 return 0; 1070 1070 const UChar *p = m_rep->data(); 1071 unsigned short c = p ->unicode();1071 unsigned short c = p[0]; 1072 1072 1073 1073 // If the first digit is 0, only 0 itself is OK. … … 1105 1105 1106 1106 // Get next character. 1107 c = (++p)->unicode();1107 c = *(++p); 1108 1108 } 1109 1109 } … … 1122 1122 int fsizeminusone = (fsz - 1) * sizeof(UChar); 1123 1123 const UChar *fdata = f.data(); 1124 unsigned short fchar = fdata ->uc;1124 unsigned short fchar = fdata[0]; 1125 1125 ++fdata; 1126 1126 for (const UChar *c = data() + pos; c <= end; c++) 1127 if (c ->uc== fchar && !memcmp(c + 1, fdata, fsizeminusone))1127 if (c[0] == fchar && !memcmp(c + 1, fdata, fsizeminusone)) 1128 1128 return static_cast<int>(c - data()); 1129 1129 … … 1216 1216 const UChar *uend = u + s1.size(); 1217 1217 while (u != uend && *s2) { 1218 if (u ->uc!= (unsigned char)*s2)1218 if (u[0] != (unsigned char)*s2) 1219 1219 return false; 1220 1220 s2++; … … 1239 1239 } 1240 1240 if (l < lmin) 1241 return (c1 ->uc < c2->uc);1241 return (c1[0] < c2[0]); 1242 1242 1243 1243 return (l1 < l2); … … 1259 1259 1260 1260 if (l < lmin) 1261 return (c1 ->uc > c2->uc) ? 1 : -1;1261 return (c1[0] > c2[0]) ? 1 : -1; 1262 1262 1263 1263 if (l1 == l2) … … 1275 1275 // Convert to runs of 8-bit characters. 1276 1276 char* p = buffer.data(); 1277 const ::UChar* d = reinterpret_cast<const ::UChar*>(&data()->uc);1277 const UChar* d = reinterpret_cast<const UChar*>(&data()[0]); 1278 1278 ConversionResult result = convertUTF16ToUTF8(&d, d + length, &p, p + buffer.size(), strict); 1279 1279 if (result != conversionOK) -
trunk/JavaScriptCore/kjs/ustring.h
r29660 r30942 31 31 #include <wtf/PassRefPtr.h> 32 32 #include <wtf/RefPtr.h> 33 #include <wtf/unicode/Unicode.h> 33 34 #include <wtf/Vector.h> 34 35 /* On some ARM platforms GCC won't pack structures by default so sizeof(UChar)36 will end up being != 2 which causes crashes since the code depends on that. */37 #if COMPILER(GCC) && PLATFORM(FORCE_PACK)38 #define PACK_STRUCT __attribute__((packed))39 #else40 #define PACK_STRUCT41 #endif42 35 43 36 /** … … 56 49 57 50 class UString; 58 59 /** 60 * @short Unicode character. 61 * 62 * UChar represents a 16 bit Unicode character. It's internal data 63 * representation is compatible to XChar2b and QChar. It's therefore 64 * possible to exchange data with X and Qt with shallow copies. 65 */ 66 struct UChar { 67 /** 68 * Construct a character with uninitialized value. 69 */ 70 UChar(); 71 /** 72 * Construct a character with the value denoted by the arguments. 73 * @param h higher byte 74 * @param l lower byte 75 */ 76 UChar(unsigned char h , unsigned char l); 77 /** 78 * Construct a character with the given value. 79 * @param u 16 bit Unicode value 80 */ 81 UChar(char u); 82 UChar(unsigned char u); 83 UChar(unsigned short u); 84 /** 85 * @return The higher byte of the character. 86 */ 87 unsigned char high() const { return static_cast<unsigned char>(uc >> 8); } 88 /** 89 * @return The lower byte of the character. 90 */ 91 unsigned char low() const { return static_cast<unsigned char>(uc); } 92 /** 93 * @return the 16 bit Unicode value of the character 94 */ 95 unsigned short unicode() const { return uc; } 96 97 unsigned short uc; 98 } PACK_STRUCT; 99 100 inline UChar::UChar() { } 101 inline UChar::UChar(unsigned char h , unsigned char l) : uc(h << 8 | l) { } 102 inline UChar::UChar(char u) : uc((unsigned char)u) { } 103 inline UChar::UChar(unsigned char u) : uc(u) { } 104 inline UChar::UChar(unsigned short u) : uc(u) { } 105 51 106 52 /** 107 53 * @short 8 bit char based string class … … 258 204 }; 259 205 260 UString spliceSubstringsWithSeparators(const Range *substringRanges, int rangeCount, const UString *separators, int separatorCount) const;206 UString spliceSubstringsWithSeparators(const Range* substringRanges, int rangeCount, const UString* separators, int separatorCount) const; 261 207 262 208 /** 263 209 * Append another string. 264 210 */ 265 UString &append(const UString &); 266 UString &append(const char *); 267 UString &append(unsigned short); 268 UString &append(char c) { return append(static_cast<unsigned short>(static_cast<unsigned char>(c))); } 269 UString &append(UChar c) { return append(c.uc); } 211 UString& append(const UString&); 212 UString& append(const char*); 213 UString& append(UChar); 214 UString& append(char c) { return append(static_cast<unsigned short>(static_cast<unsigned char>(c))); } 270 215 271 216 /** … … 282 227 * instances. 283 228 */ 284 char *ascii() const;229 char* ascii() const; 285 230 286 231 /** … … 404 349 }; 405 350 406 inline bool operator==(const UChar &c1, const UChar &c2) {407 return (c1.uc == c2.uc);408 }409 351 bool operator==(const UString& s1, const UString& s2); 410 352 inline bool operator!=(const UString& s1, const UString& s2) { -
trunk/JavaScriptCore/pcre/pcre.h
r28833 r30942 56 56 const int JSRegExpErrorInternal = -4; 57 57 58 JSRegExp* jsRegExpCompile(const ::UChar* pattern, int patternLength,58 JSRegExp* jsRegExpCompile(const UChar* pattern, int patternLength, 59 59 JSRegExpIgnoreCaseOption, JSRegExpMultilineOption, 60 60 unsigned* numSubpatterns, const char** errorMessage); 61 61 62 62 int jsRegExpExecute(const JSRegExp*, 63 const ::UChar* subject, int subjectLength, int startOffset,63 const UChar* subject, int subjectLength, int startOffset, 64 64 int* offsetsVector, int offsetsVectorLength); 65 65 -
trunk/WebCore/ChangeLog
r30939 r30942 1 2008-03-10 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Darin. 4 5 Remove KJS::UChar, use ::UChar instead 6 http://bugs.webkit.org/show_bug.cgi?id=17017 7 8 To functional changes, thus no tests. 9 10 * bindings/js/JSCSSStyleDeclarationCustom.cpp: 11 (WebCore::hasCSSPropertyNamePrefix): 12 (WebCore::cssPropertyName): 13 * bindings/js/JSDOMWindowBase.cpp: 14 (WebCore::windowProtoFuncAToB): 15 (WebCore::windowProtoFuncBToA): 16 * bindings/js/JSSVGPODTypeWrapper.h: 17 * bindings/js/kjs_proxy.cpp: 18 (WebCore::KJSProxy::evaluate): 19 * bridge/objc/objc_utility.mm: 20 (KJS::Bindings::throwError): 21 * dom/Document.cpp: 22 (WebCore::Document::parseQualifiedName): 23 * platform/text/AtomicString.cpp: 24 (WebCore::AtomicString::add): 25 * platform/text/String.cpp: 26 (WebCore::String::String): 27 (WebCore::String::operator Identifier): 28 (WebCore::String::operator UString): 29 * platform/text/TextCodecICU.cpp: 30 (WebCore::TextCodecICU::decode): 31 * svg/SVGAnimatedTemplate.h: 32 1 33 2008-03-10 Darin Adler <darin@apple.com> 2 34 -
trunk/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
r30534 r30942 56 56 ASSERT(length); 57 57 58 if (toASCIILower(propertyName.data()[0] .unicode()) != prefix[0])58 if (toASCIILower(propertyName.data()[0]) != prefix[0]) 59 59 return false; 60 60 61 61 for (unsigned i = 1; i < length; ++i) { 62 62 if (!prefix[i]) 63 return isASCIIUpper(propertyName.data()[i] .unicode());64 if (propertyName.data()[0] .unicode()!= prefix[0])63 return isASCIIUpper(propertyName.data()[i]); 64 if (propertyName.data()[0] != prefix[0]) 65 65 return false; 66 66 } … … 77 77 return String(); 78 78 79 Vector< ::UChar> name;79 Vector<UChar> name; 80 80 name.reserveCapacity(length); 81 81 … … 97 97 name.append('-'); 98 98 99 name.append(toASCIILower(propertyName.data()[i++] .unicode()));99 name.append(toASCIILower(propertyName.data()[i++])); 100 100 101 101 for (; i < length; ++i) { 102 ::UChar c = propertyName.data()[i].unicode();102 UChar c = propertyName.data()[i]; 103 103 if (!isASCIIUpper(c)) 104 104 name.append(c); -
trunk/WebCore/bindings/js/JSDOMWindowBase.cpp
r30923 r30942 1049 1049 Vector<char> in(s.size()); 1050 1050 for (int i = 0; i < s.size(); ++i) 1051 in[i] = static_cast<char>(s.data()[i] .unicode());1051 in[i] = static_cast<char>(s.data()[i]); 1052 1052 Vector<char> out; 1053 1053 … … 1080 1080 Vector<char> in(s.size()); 1081 1081 for (int i = 0; i < s.size(); ++i) 1082 in[i] = static_cast<char>(s.data()[i] .unicode());1082 in[i] = static_cast<char>(s.data()[i]); 1083 1083 Vector<char> out; 1084 1084 -
trunk/WebCore/bindings/js/JSSVGPODTypeWrapper.h
r30122 r30942 204 204 static unsigned hash(const PODTypeReadWriteHashInfo<PODType, PODTypeCreator>& info) 205 205 { 206 return StringImpl::computeHash( (::UChar*) &info, sizeof(PODTypeReadWriteHashInfo<PODType, PODTypeCreator>) / sizeof(::UChar));206 return StringImpl::computeHash(reinterpret_cast<const UChar*>(&info), sizeof(PODTypeReadWriteHashInfo<PODType, PODTypeCreator>) / sizeof(UChar)); 207 207 } 208 208 -
trunk/WebCore/bindings/js/kjs_proxy.cpp
r30787 r30942 86 86 87 87 m_globalObject->startTimeoutCheck(); 88 Completion comp = Interpreter::evaluate(exec, filename, baseLine, reinterpret_cast<const KJS::UChar*>(str.characters()), str.length(), thisNode);88 Completion comp = Interpreter::evaluate(exec, filename, baseLine, str.characters(), str.length(), thisNode); 89 89 m_globalObject->stopTimeoutCheck(); 90 90 -
trunk/WebCore/bridge/objc/objc_utility.mm
r30782 r30942 364 364 unichar *buffer = new unichar[length]; 365 365 [message getCharacters:buffer]; 366 JSObject *error = throwError(exec, type, UString( reinterpret_cast<UChar *>(buffer), length));366 JSObject *error = throwError(exec, type, UString(buffer, length)); 367 367 delete [] buffer; 368 368 return error; -
trunk/WebCore/dom/Document.cpp
r30840 r30942 2674 2674 bool Document::isValidName(const String &name) 2675 2675 { 2676 const UChar* s = reinterpret_cast<const UChar*>(name.characters());2676 const UChar* s = name.characters(); 2677 2677 unsigned length = name.length(); 2678 2678 … … 2707 2707 int colonPos = 0; 2708 2708 2709 const UChar* s = reinterpret_cast<const UChar*>(qualifiedName.characters());2709 const UChar* s = qualifiedName.characters(); 2710 2710 for (unsigned i = 0; i < length;) { 2711 2711 UChar32 c; -
trunk/WebCore/platform/text/AtomicString.cpp
r30501 r30942 193 193 PassRefPtr<StringImpl> AtomicString::add(const KJS::Identifier& str) 194 194 { 195 return add( reinterpret_cast<const UChar*>(str.data()), str.size());195 return add(str.data(), str.size()); 196 196 } 197 197 198 198 PassRefPtr<StringImpl> AtomicString::add(const KJS::UString& str) 199 199 { 200 return add( reinterpret_cast<const UChar*>(str.data()), str.size());200 return add(str.data(), str.size()); 201 201 } 202 202 -
trunk/WebCore/platform/text/String.cpp
r30501 r30942 593 593 if (str.isNull()) 594 594 return; 595 m_impl = StringImpl::create( reinterpret_cast<const UChar*>(str.data()), str.size());595 m_impl = StringImpl::create(str.data(), str.size()); 596 596 } 597 597 … … 600 600 if (str.isNull()) 601 601 return; 602 m_impl = StringImpl::create( reinterpret_cast<const UChar*>(str.data()), str.size());602 m_impl = StringImpl::create(str.data(), str.size()); 603 603 } 604 604 … … 607 607 if (!m_impl) 608 608 return Identifier(); 609 return Identifier( reinterpret_cast<const KJS::UChar*>(m_impl->characters()), m_impl->length());609 return Identifier(m_impl->characters(), m_impl->length()); 610 610 } 611 611 … … 614 614 if (!m_impl) 615 615 return UString(); 616 return UString( reinterpret_cast<const KJS::UChar*>(m_impl->characters()), m_impl->length());616 return UString(m_impl->characters(), m_impl->length()); 617 617 } 618 618 -
trunk/WebCore/platform/text/TextCodecICU.cpp
r30894 r30942 242 242 ucnv_toUnicode(m_converterICU, &target, targetLimit, &source, sourceLimit, offsets, flush, &err); 243 243 int count = target - buffer; 244 appendOmittingBOM(result, reinterpret_cast<const UChar*>(buffer), count);244 appendOmittingBOM(result, buffer, count); 245 245 } while (err == U_BUFFER_OVERFLOW_ERROR); 246 246 -
trunk/WebCore/svg/SVGAnimatedTemplate.h
r30122 r30942 75 75 static unsigned hash(const SVGAnimatedTypeWrapperKey& key) 76 76 { 77 return StringImpl::computeHash( (::UChar*) &key, sizeof(SVGAnimatedTypeWrapperKey) / sizeof(::UChar));77 return StringImpl::computeHash(reinterpret_cast<const UChar*>(&key), sizeof(SVGAnimatedTypeWrapperKey) / sizeof(UChar)); 78 78 } 79 79
Note: See TracChangeset
for help on using the changeset viewer.