Changeset 18712 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jan 9, 2007, 6:54:26 AM (18 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r18658 r18712 1 2007-01-09 Darin Adler <[email protected]> 2 3 Reviewed by Maciej. 4 5 - fix http://bugs.webkit.org/show_bug.cgi?id=12174 6 improve Unicode use (less WTF::Unicode:: prefix, centralized character names) 7 8 * wtf/unicode/icu/UnicodeIcu.h: Change parameter and return types 9 to UChar32 and UChar. Removed unneeded type casts and added some 10 const to functions that lacked it. Removed WTF::Unicode::memcmp. 11 (WTF::Unicode::umemcasecmp): Renamed from strcasecmp since this 12 doesn't work on 0-terminated strings as the str functions do. 13 * wtf/unicode/qt4/UnicodeQt4.h: Ditto. 14 15 - got rid of namespace prefixes from most uses of WTF::Unicode 16 17 * kjs/function.cpp: 18 (KJS::isStrWhiteSpace): 19 (KJS::escapeStringForPrettyPrinting): 20 * kjs/lexer.cpp: 21 (KJS::Lexer::isWhiteSpace): 22 (KJS::Lexer::isIdentStart): 23 (KJS::Lexer::isIdentPart): 24 * kjs/string_object.cpp: 25 (KJS::StringProtoFunc::callAsFunction): 26 1 27 2007-01-07 David Kilzer <[email protected]> 2 28 -
trunk/JavaScriptCore/kjs/function.cpp
r17507 r18712 42 42 43 43 #include <wtf/unicode/Unicode.h> 44 45 using namespace WTF; 46 using namespace Unicode; 44 47 45 48 namespace KJS { … … 691 694 return true; 692 695 default: 693 return WTF::Unicode::isSeparatorSpace(c);696 return isSeparatorSpace(c); 694 697 } 695 698 } … … 966 969 break; 967 970 default: 968 if (c < 128 && WTF::Unicode::isPrintableChar(c))971 if (c < 128 && isPrintableChar(c)) 969 972 escapedString.append(c); 970 973 else { -
trunk/JavaScriptCore/kjs/lexer.cpp
r17862 r18712 32 32 #include <wtf/unicode/Unicode.h> 33 33 34 static bool isDecimalDigit(int); 34 using namespace WTF; 35 using namespace Unicode; 35 36 36 37 // we can't specify the namespace in yacc's C output, so do it here 37 38 using namespace KJS; 38 39 static Lexer *currLexer = 0;40 39 41 40 #ifndef KDE_USE_FINAL … … 53 52 return Lexer::curr()->lex(); 54 53 } 54 55 namespace KJS { 56 57 static Lexer* currLexer = 0; 58 59 static bool isDecimalDigit(int); 55 60 56 61 Lexer::Lexer() … … 566 571 bool Lexer::isWhiteSpace() const 567 572 { 568 return current == '\t' || current == 0x0b || current == 0x0c || WTF::Unicode::isSeparatorSpace(current);573 return current == '\t' || current == 0x0b || current == 0x0c || isSeparatorSpace(current); 569 574 } 570 575 … … 582 587 bool Lexer::isIdentStart(int c) 583 588 { 584 return (WTF::Unicode::category(c) & (WTF::Unicode::Letter_Uppercase 585 | WTF::Unicode::Letter_Lowercase 586 | WTF::Unicode::Letter_Titlecase 587 | WTF::Unicode::Letter_Modifier 588 | WTF::Unicode::Letter_Other)) 589 return (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other)) 589 590 || c == '$' || c == '_'; 590 591 } … … 592 593 bool Lexer::isIdentPart(int c) 593 594 { 594 return (WTF::Unicode::category(c) & (WTF::Unicode::Letter_Uppercase 595 | WTF::Unicode::Letter_Lowercase 596 | WTF::Unicode::Letter_Titlecase 597 | WTF::Unicode::Letter_Modifier 598 | WTF::Unicode::Letter_Other 599 | WTF::Unicode::Mark_NonSpacing 600 | WTF::Unicode::Mark_SpacingCombining 601 | WTF::Unicode::Number_DecimalDigit 602 | WTF::Unicode::Punctuation_Connector)) 595 return (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other 596 | Mark_NonSpacing | Mark_SpacingCombining | Number_DecimalDigit | Punctuation_Connector)) 603 597 || c == '$' || c == '_'; 604 598 } … … 912 906 return string; 913 907 } 908 909 } -
trunk/JavaScriptCore/kjs/string_object.cpp
r18356 r18712 38 38 #endif 39 39 40 using namespace KJS; 40 using namespace WTF; 41 42 namespace KJS { 41 43 42 44 // ------------------------------ StringInstance ---------------------------- … … 684 686 uint16_t* destIfNeeded; 685 687 686 int len = WTF::Unicode::toLower(dataPtr, u.size(), destIfNeeded);688 int len = Unicode::toLower(dataPtr, u.size(), destIfNeeded); 687 689 if (len >= 0) 688 690 result = jsString(UString(reinterpret_cast<UChar *>(destIfNeeded ? destIfNeeded : dataPtr), len)); … … 700 702 uint16_t* destIfNeeded; 701 703 702 int len = WTF::Unicode::toUpper(dataPtr, u.size(), destIfNeeded);704 int len = Unicode::toUpper(dataPtr, u.size(), destIfNeeded); 703 705 if (len >= 0) 704 706 result = jsString(UString(reinterpret_cast<UChar *>(destIfNeeded ? destIfNeeded : dataPtr), len)); … … 826 828 return jsString(s); 827 829 } 830 831 } -
trunk/JavaScriptCore/wtf/unicode/icu/UnicodeIcu.h
r18247 r18712 4 4 * Copyright (C) 2006 George Staikos <[email protected]> 5 5 * Copyright (C) 2006 Alexey Proskuryakov <[email protected]> 6 * Copyright (C) 2007 Apple Computer, Inc. All rights reserved. 6 7 * 7 8 * This library is free software; you can redistribute it and/or … … 118 119 }; 119 120 120 inline uint32_t foldCase(uint32_tc)121 inline UChar32 foldCase(UChar32 c) 121 122 { 122 123 return u_foldCase(c, U_FOLD_CASE_DEFAULT); 123 124 } 124 125 125 inline int foldCase(UChar* result, int resultLength, UChar* src, int srcLength,bool* error)126 inline int foldCase(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) 126 127 { 127 128 UErrorCode status = U_ZERO_ERROR; 128 int 32_trealLength = u_strFoldCase(result, resultLength, src, srcLength, U_FOLD_CASE_DEFAULT, &status);129 int realLength = u_strFoldCase(result, resultLength, src, srcLength, U_FOLD_CASE_DEFAULT, &status); 129 130 *error = !U_SUCCESS(status); 130 131 return realLength; 131 132 } 132 133 133 inline int toLower( uint16_t* str, int strLength, uint16_t*& destIfNeeded)134 inline int toLower(UChar* str, int strLength, UChar*& destIfNeeded) 134 135 { 135 136 UErrorCode err = U_ZERO_ERROR; … … 137 138 destIfNeeded = 0; 138 139 139 resultLength = u_strToLower(0, 0, reinterpret_cast< ::UChar*>(str), strLength, "", &err);140 resultLength = u_strToLower(0, 0, str, strLength, "", &err); 140 141 141 142 if (resultLength <= strLength) { 142 143 err = U_ZERO_ERROR; 143 u_strToLower( reinterpret_cast< ::UChar*>(str), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);144 u_strToLower(str, resultLength, str, strLength, "", &err); 144 145 } else { 145 146 err = U_ZERO_ERROR; 146 destIfNeeded = (uint16_t*)malloc(resultLength * sizeof(uint16_t));147 u_strToLower( reinterpret_cast< ::UChar*>(destIfNeeded), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);147 destIfNeeded = static_cast<UChar*>(malloc(resultLength * sizeof(UChar))); 148 u_strToLower(destIfNeeded, resultLength, str, strLength, "", &err); 148 149 } 149 150 … … 151 152 } 152 153 153 inline int toLower(UChar* result, int resultLength, UChar* src, int srcLength,bool* error)154 inline int toLower(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) 154 155 { 155 156 UErrorCode status = U_ZERO_ERROR; 156 int 32_trealLength = u_strToLower(result, resultLength, src, srcLength, "", &status);157 int realLength = u_strToLower(result, resultLength, src, srcLength, "", &status); 157 158 *error = !!U_FAILURE(status); 158 159 return realLength; 159 160 } 160 161 161 inline int32_t toLower(int32_tc)162 inline UChar32 toLower(UChar32 c) 162 163 { 163 164 return u_tolower(c); 164 165 } 165 166 166 inline int32_t toUpper(int32_tc)167 inline UChar32 toUpper(UChar32 c) 167 168 { 168 169 return u_toupper(c); 169 170 } 170 171 171 inline int toUpper( uint16_t* str, int strLength, uint16_t*& destIfNeeded)172 inline int toUpper(UChar* str, int strLength, UChar*& destIfNeeded) 172 173 { 173 174 UErrorCode err = U_ZERO_ERROR; … … 175 176 destIfNeeded = 0; 176 177 177 resultLength = u_strToUpper(0, 0, reinterpret_cast< ::UChar*>(str), strLength, "", &err);178 resultLength = u_strToUpper(0, 0, str, strLength, "", &err); 178 179 179 180 if (resultLength <= strLength) { 180 181 err = U_ZERO_ERROR; 181 u_strToUpper( reinterpret_cast< ::UChar*>(str), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);182 u_strToUpper(str, resultLength, str, strLength, "", &err); 182 183 } else { 183 184 err = U_ZERO_ERROR; 184 destIfNeeded = ( uint16_t*)malloc(resultLength * sizeof(uint16_t));185 u_strToUpper( reinterpret_cast< ::UChar*>(destIfNeeded), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);185 destIfNeeded = (UChar*)malloc(resultLength * sizeof(UChar)); 186 u_strToUpper(destIfNeeded, resultLength, str, strLength, "", &err); 186 187 } 187 188 … … 189 190 } 190 191 191 inline int toUpper(UChar* result, int resultLength, UChar* src, int srcLength,bool* error)192 inline int toUpper(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) 192 193 { 193 194 UErrorCode status = U_ZERO_ERROR; 194 int 32_trealLength = u_strToUpper(result, resultLength, src, srcLength, "", &status);195 int realLength = u_strToUpper(result, resultLength, src, srcLength, "", &status); 195 196 *error = !!U_FAILURE(status); 196 197 return realLength; 197 198 } 198 199 199 inline int toTitleCase (uint32_tc)200 inline UChar32 toTitleCase(UChar32 c) 200 201 { 201 202 return u_totitle(c); 202 203 } 203 204 204 inline bool isFormatChar( int32_tc)205 inline bool isFormatChar(UChar32 c) 205 206 { 206 207 return u_charType(c) == U_FORMAT_CHAR; 207 208 } 208 209 209 inline bool isSeparatorSpace( int32_tc)210 inline bool isSeparatorSpace(UChar32 c) 210 211 { 211 212 return u_charType(c) == U_SPACE_SEPARATOR; 212 213 } 213 214 214 inline bool isPrintableChar( int32_tc)215 inline bool isPrintableChar(UChar32 c) 215 216 { 216 217 return !!u_isprint(c); 217 218 } 218 219 219 inline bool isDigit( int32_tc)220 inline bool isDigit(UChar32 c) 220 221 { 221 222 return !!u_isdigit(c); 222 223 } 223 224 224 inline bool isPunct( int32_tc)225 inline bool isPunct(UChar32 c) 225 226 { 226 227 return !!u_ispunct(c); 227 228 } 228 229 229 inline int32_t mirroredChar(int32_tc)230 inline UChar32 mirroredChar(UChar32 c) 230 231 { 231 232 return u_charMirror(c); 232 233 } 233 234 234 inline CharCategory category( int32_tc)235 inline CharCategory category(UChar32 c) 235 236 { 236 237 return static_cast<CharCategory>(U_GET_GC_MASK(c)); 237 238 } 238 239 239 inline Direction direction(int c) { 240 return (Direction)u_charDirection(c); 241 } 242 243 inline bool isLower(int32_t c) 240 inline Direction direction(UChar32 c) 241 { 242 return static_cast<Direction>(u_charDirection(c)); 243 } 244 245 inline bool isLower(UChar32 c) 244 246 { 245 247 return !!u_islower(c); 246 248 } 247 249 248 inline bool isUpper( int32_tc)250 inline bool isUpper(UChar32 c) 249 251 { 250 252 return !!u_isUUppercase(c); 251 253 } 252 254 253 inline int digitValue( int32_tc)255 inline int digitValue(UChar32 c) 254 256 { 255 257 return u_charDigitValue(c); … … 266 268 } 267 269 268 inline int strcasecmp(const UChar *a, const UChar *b, int len)270 inline int umemcasecmp(const UChar* a, const UChar* b, int len) 269 271 { 270 272 return u_memcasecmp(a, b, len, U_FOLD_CASE_DEFAULT); 271 273 } 272 274 273 inline void memset(UChar* dest, UChar ch, int32_t count)274 {275 u_memset(dest, ch, count);276 }277 275 } 278 276 } -
trunk/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h
r18161 r18712 143 143 }; 144 144 145 inline int toLower( uint16_t* str, int strLength, uint16_t*& destIfNeeded)145 inline int toLower(UChar* str, int strLength, UChar*& destIfNeeded) 146 146 { 147 147 destIfNeeded = 0; … … 153 153 } 154 154 155 inline uint16_t toLower(uint16_t ch) 156 { 157 return QChar(ch).toLower().unicode(); 158 } 159 160 inline int toLower(UChar* result, int resultLength, UChar* src, int srcLength, bool* error) 155 inline UChar32 toLower(UChar32 ch) 156 { 157 if (ch > 0xffff) 158 return ch; 159 return QChar((unsigned short)ch).toLower().unicode(); 160 } 161 162 inline int toLower(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) 161 163 { 162 164 *error = false; … … 169 171 } 170 172 171 inline int toUpper( uint16_t* str, int strLength, uint16_t*& destIfNeeded)173 inline int toUpper(UChar* str, int strLength, UChar*& destIfNeeded) 172 174 { 173 175 destIfNeeded = 0; … … 179 181 } 180 182 181 inline uint16_t toUpper(uint16_t ch) 182 { 183 return QChar(ch).toUpper().unicode(); 183 inline UChar32 toUpper(UChar32 ch) 184 { 185 if (ch > 0xffff) 186 return ch; 187 return QChar((unsigned short)ch).toUpper().unicode(); 184 188 } 185 189 … … 195 199 } 196 200 197 inline int toTitleCase (uint32_tc)201 inline int toTitleCase(UChar32 c) 198 202 { 199 203 if (c > 0xffff) 200 204 return c; 201 return QChar( c).toUpper().unicode();202 } 203 204 inline uint32_t foldCase(uint32_tc)205 return QChar((unsigned short)c).toUpper().unicode(); 206 } 207 208 inline UChar32 foldCase(UChar32 c) 205 209 { 206 210 if (c > 0xffff) 207 211 return c; 208 return QChar( c).toLower().unicode();212 return QChar((unsigned short)c).toLower().unicode(); 209 213 } 210 214 … … 214 218 } 215 219 216 inline bool isFormatChar( int32_tc)220 inline bool isFormatChar(UChar32 c) 217 221 { 218 222 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Other_Format; 219 223 } 220 224 221 inline bool isPrintableChar( int32_tc)225 inline bool isPrintableChar(UChar32 c) 222 226 { 223 227 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isPrint(); 224 228 } 225 229 226 inline bool isSeparatorSpace( int32_tc)230 inline bool isSeparatorSpace(UChar32 c) 227 231 { 228 232 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Separator_Space; 229 233 } 230 234 231 inline bool isPunct( int32_tc)235 inline bool isPunct(UChar32 c) 232 236 { 233 237 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isPunct(); 234 238 } 235 239 236 inline bool isDigit( int32_tc)240 inline bool isDigit(UChar32 c) 237 241 { 238 242 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isDigit(); 239 243 } 240 244 241 inline bool isLower( int32_tc)245 inline bool isLower(UChar32 c) 242 246 { 243 247 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Letter_Lowercase; 244 248 } 245 249 246 inline bool isUpper( int32_tc)250 inline bool isUpper(UChar32 c) 247 251 { 248 252 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Letter_Uppercase; 249 253 } 250 254 251 inline int digitValue( int32_tc)255 inline int digitValue(UChar32 c) 252 256 { 253 257 if (c > 0xffff) … … 256 260 } 257 261 258 inline uint16_t mirroredChar(uint16_t c) 259 { 262 inline UChar32 mirroredChar(UChar32 c) 263 { 264 if (c > 0xffff) 265 return c; 260 266 return QChar(c).mirroredChar().unicode(); 261 267 } … … 275 281 } 276 282 277 278 inline int strcasecmp(const UChar *a, const UChar *b, int len) 283 inline int umemcasecmp(const UChar* a, const UChar* b, int len) 279 284 { 280 285 for (int i = 0; i < len; ++i) { … … 287 292 } 288 293 289 inline void memset(UChar* dest, UChar ch, int32_t count) 290 { 291 UChar *end = dest + count; 292 while (dest < end) 293 *dest++ = ch; 294 } 295 296 inline Direction direction(int c) { 294 inline Direction direction(UChar32 c) { 297 295 if (c > 0xffff) 298 296 return LeftToRight; … … 300 298 } 301 299 302 inline CharCategory category( intc) {300 inline CharCategory category(UChar32 c) { 303 301 if (c > 0xffff) 304 302 return (CharCategory) U_MASK(QChar::Letter_Other); 305 303 return (CharCategory) U_MASK(QChar(c).category()); 306 304 } 305 307 306 } 308 307 }
Note:
See TracChangeset
for help on using the changeset viewer.