Changeset 70425 in webkit
- Timestamp:
- Oct 24, 2010 4:20:06 PM (13 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r70421 r70425 1 2010-10-24 Patrick Gansterer <paroga@webkit.org> 2 3 Reviewed by David Kilzer. 4 5 Add WTF_ARRAY_LENGTH macro to WTF 6 https://bugs.webkit.org/show_bug.cgi?id=32828 7 8 Unify the different implementations and usages. 9 10 * interpreter/Interpreter.cpp: 11 (JSC::Interpreter::privateExecute): 12 * runtime/DatePrototype.cpp: 13 (JSC::formatLocaleDate): 14 * runtime/JSGlobalObject.cpp: 15 (JSC::JSGlobalObject::reset): 16 * runtime/JSONObject.cpp: 17 (JSC::Stringifier::appendQuotedString): 18 (JSC::Stringifier::toJSON): 19 (JSC::Stringifier::appendStringifiedValue): 20 * runtime/UString.cpp: 21 (JSC::UString::number): 22 * wtf/DateMath.cpp: 23 (WTF::parseDateFromNullTerminatedCharacters): 24 * wtf/StdLibExtras.h: 25 1 26 2010-10-24 Dirk Schulze <krit@webkit.org> 2 27 -
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r70406 r70425 1438 1438 #define LIST_OPCODE_LABEL(id, length) &&id, 1439 1439 static Opcode labels[] = { FOR_EACH_OPCODE_ID(LIST_OPCODE_LABEL) }; 1440 for (size_t i = 0; i < sizeof(labels) / sizeof(Opcode); ++i)1440 for (size_t i = 0; i < WTF_ARRAY_LENGTH(labels); ++i) 1441 1441 m_opcodeTable[i] = labels[i]; 1442 1442 #undef LIST_OPCODE_LABEL -
trunk/JavaScriptCore/runtime/DatePrototype.cpp
r67826 r70425 183 183 // That's not great error handling, but it just won't happen so it doesn't matter. 184 184 UChar buffer[200]; 185 const size_t bufferLength = sizeof(buffer) / sizeof(buffer[0]);185 const size_t bufferLength = WTF_ARRAY_LENGTH(buffer); 186 186 size_t length = CFStringGetLength(string); 187 187 ASSERT(length <= bufferLength); -
trunk/JavaScriptCore/runtime/JSGlobalObject.cpp
r70406 r70425 308 308 }; 309 309 310 addStaticGlobals(staticGlobals, sizeof(staticGlobals) / sizeof(GlobalPropertyInfo));310 addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals)); 311 311 312 312 // Set global functions. -
trunk/JavaScriptCore/runtime/JSONObject.cpp
r69683 r70425 330 330 UChar ch = data[i]; 331 331 UChar hex[] = { '\\', 'u', hexDigits[(ch >> 12) & 0xF], hexDigits[(ch >> 8) & 0xF], hexDigits[(ch >> 4) & 0xF], hexDigits[ch & 0xF] }; 332 builder.append(hex, sizeof(hex) / sizeof(UChar));332 builder.append(hex, WTF_ARRAY_LENGTH(hex)); 333 333 break; 334 334 } … … 358 358 359 359 JSValue list[] = { propertyName.value(m_exec) }; 360 ArgList args(list, sizeof(list) / sizeof(JSValue));360 ArgList args(list, WTF_ARRAY_LENGTH(list)); 361 361 return call(m_exec, object, callType, callData, value, args); 362 362 } … … 372 372 if (m_replacerCallType != CallTypeNone) { 373 373 JSValue list[] = { propertyName.value(m_exec), value }; 374 ArgList args(list, sizeof(list) / sizeof(JSValue));374 ArgList args(list, WTF_ARRAY_LENGTH(list)); 375 375 value = call(m_exec, m_replacer, m_replacerCallType, m_replacerCallData, holder, args); 376 376 if (m_exec->hadException()) -
trunk/JavaScriptCore/runtime/UString.cpp
r66245 r70425 91 91 { 92 92 UChar buf[1 + sizeof(i) * 3]; 93 UChar* end = buf + sizeof(buf) / sizeof(UChar);93 UChar* end = buf + WTF_ARRAY_LENGTH(buf); 94 94 UChar* p = end; 95 95 … … 120 120 { 121 121 UChar buf[1 + sizeof(i) * 3]; 122 UChar* end = buf + sizeof(buf) / sizeof(UChar);122 UChar* end = buf + WTF_ARRAY_LENGTH(buf); 123 123 UChar* p = end; 124 124 … … 153 153 { 154 154 UChar buf[sizeof(u) * 3]; 155 UChar* end = buf + sizeof(buf) / sizeof(UChar);155 UChar* end = buf + WTF_ARRAY_LENGTH(buf); 156 156 UChar* p = end; 157 157 … … 171 171 { 172 172 UChar buf[1 + sizeof(l) * 3]; 173 UChar* end = buf + sizeof(buf) / sizeof(UChar);173 UChar* end = buf + WTF_ARRAY_LENGTH(buf); 174 174 UChar* p = end; 175 175 -
trunk/JavaScriptCore/wtf/DateMath.cpp
r70076 r70425 951 951 haveTZ = true; 952 952 } else { 953 for ( int i = 0; i < int(sizeof(known_zones) / sizeof(KnownZone)); i++) {953 for (size_t i = 0; i < WTF_ARRAY_LENGTH(known_zones); ++i) { 954 954 if (0 == strncasecmp(dateString, known_zones[i].tzName, strlen(known_zones[i].tzName))) { 955 955 offset = known_zones[i].tzOffset; -
trunk/JavaScriptCore/wtf/StdLibExtras.h
r70419 r70425 111 111 } 112 112 113 // Macro that returns a compile time constant with the length of an array, but gives an error if passed a non-array. 114 template<typename T, size_t Size> char (&ArrayLengthHelperFunction(T (&)[Size]))[Size]; 115 #define WTF_ARRAY_LENGTH(array) sizeof(::WTF::ArrayLengthHelperFunction(array)) 116 113 117 } // namespace WTF 114 118
Note: See TracChangeset
for help on using the changeset viewer.