Changeset 39809 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Jan 11, 2009, 1:58:23 PM (16 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/DatePrototype.cpp
r39670 r39809 102 102 static JSValuePtr dateProtoFuncToTimeString(ExecState*, JSObject*, JSValuePtr, const ArgList&); 103 103 static JSValuePtr dateProtoFuncToUTCString(ExecState*, JSObject*, JSValuePtr, const ArgList&); 104 static JSValuePtr dateProtoFuncValueOf(ExecState*, JSObject*, JSValuePtr, const ArgList&);105 104 106 105 } … … 110 109 namespace JSC { 111 110 111 enum LocaleDateTimeFormat { LocaleDateAndTime, LocaleDate, LocaleTime }; 112 112 113 #if PLATFORM(MAC) 114 115 // FIXME: Since this is superior to the strftime-based version, why limit this to PLATFORM(MAC)? 116 // Instead we should consider using this whenever PLATFORM(CF) is true. 113 117 114 118 static CFDateFormatterStyle styleFromArgString(const UString& string, CFDateFormatterStyle defaultStyle) … … 125 129 } 126 130 127 static UString formatLocaleDate(ExecState* exec, double time, bool includeDate, bool includeTime, const ArgList& args)128 { 129 CFDateFormatterStyle dateStyle = ( includeDate ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle);130 CFDateFormatterStyle timeStyle = ( includeTime ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle);131 static JSCell* formatLocaleDate(ExecState* exec, DateInstance*, double timeInMilliseconds, LocaleDateTimeFormat format, const ArgList& args) 132 { 133 CFDateFormatterStyle dateStyle = (format != LocaleTime ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle); 134 CFDateFormatterStyle timeStyle = (format != LocaleDate ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle); 131 135 132 136 bool useCustomFormat = false; … … 137 141 useCustomFormat = true; 138 142 customFormatString = args.at(exec, 1)->toString(exec); 139 } else if ( includeDate && includeTime && !args.at(exec, 1)->isUndefined()) {143 } else if (format == LocaleDateAndTime && !args.at(exec, 1)->isUndefined()) { 140 144 dateStyle = styleFromArgString(arg0String, dateStyle); 141 145 timeStyle = styleFromArgString(args.at(exec, 1)->toString(exec), timeStyle); 142 } else if ( includeDate && !args.at(exec, 0)->isUndefined())146 } else if (format != LocaleTime && !args.at(exec, 0)->isUndefined()) 143 147 dateStyle = styleFromArgString(arg0String, dateStyle); 144 else if ( includeTime && !args.at(exec, 0)->isUndefined())148 else if (format != LocaleDate && !args.at(exec, 0)->isUndefined()) 145 149 timeStyle = styleFromArgString(arg0String, timeStyle); 146 150 … … 150 154 151 155 if (useCustomFormat) { 152 CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, (UniChar *)customFormatString.data(), customFormatString.size());156 CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, customFormatString.data(), customFormatString.size()); 153 157 CFDateFormatterSetFormat(formatter, customFormatCFString); 154 158 CFRelease(customFormatCFString); 155 159 } 156 160 157 CFStringRef string = CFDateFormatterCreateStringWithAbsoluteTime(0, formatter, time- kCFAbsoluteTimeIntervalSince1970);161 CFStringRef string = CFDateFormatterCreateStringWithAbsoluteTime(0, formatter, floor(timeInMilliseconds / msPerSecond) - kCFAbsoluteTimeIntervalSince1970); 158 162 159 163 CFRelease(formatter); … … 167 171 if (length > bufferLength) 168 172 length = bufferLength; 169 CFStringGetCharacters(string, CFRangeMake(0, length), reinterpret_cast<UniChar *>(buffer));173 CFStringGetCharacters(string, CFRangeMake(0, length), buffer); 170 174 171 175 CFRelease(string); 172 176 173 return UString(buffer, length); 174 } 175 176 #else 177 178 enum LocaleDateTimeFormat { LocaleDateAndTime, LocaleDate, LocaleTime }; 179 180 static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, const LocaleDateTimeFormat format) 181 { 182 static const char* formatStrings[] = {"%#c", "%#x", "%X"}; 177 return jsNontrivialString(exec, UString(buffer, length)); 178 } 179 180 #else // !PLATFORM(MAC) 181 182 static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, LocaleDateTimeFormat format) 183 { 184 static const char* const formatStrings[] = { "%#c", "%#x", "%X" }; 183 185 184 186 // Offset year if needed … … 212 214 } 213 215 214 #endif // PLATFORM(WIN_OS) 216 static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, double timeInMilliseconds, LocaleDateTimeFormat format, const ArgList&) 217 { 218 GregorianDateTime gregorianDateTime; 219 const bool notUTC = false; 220 dateObject->msToGregorianDateTime(timeInMilliseconds, notUTC, gregorianDateTime); 221 return formatLocaleDate(exec, gregorianDateTime, format); 222 } 223 224 #endif // !PLATFORM(MAC) 215 225 216 226 // Converts a list of arguments sent to a Date member function into milliseconds, updating … … 296 306 297 307 /* Source for DatePrototype.lut.h 298 FIXME: We could use templates to simplify the UTC variants.299 308 @begin dateTable 300 309 toString dateProtoFuncToString DontEnum|Function 0 … … 305 314 toLocaleDateString dateProtoFuncToLocaleDateString DontEnum|Function 0 306 315 toLocaleTimeString dateProtoFuncToLocaleTimeString DontEnum|Function 0 307 valueOf dateProtoFunc ValueOfDontEnum|Function 0316 valueOf dateProtoFuncGetTime DontEnum|Function 0 308 317 getTime dateProtoFuncGetTime DontEnum|Function 0 309 318 getFullYear dateProtoFuncGetFullYear DontEnum|Function 0 … … 344 353 @end 345 354 */ 355 346 356 // ECMA 15.9.4 347 357 … … 438 448 return jsNontrivialString(exec, "Invalid Date"); 439 449 440 #if PLATFORM(MAC) 441 double secs = floor(milli / msPerSecond); 442 return jsNontrivialString(exec, formatLocaleDate(exec, secs, true, true, args)); 443 #else 444 UNUSED_PARAM(args); 445 446 const bool utc = false; 447 448 GregorianDateTime t; 449 thisDateObj->msToGregorianDateTime(milli, utc, t); 450 return formatLocaleDate(exec, t, LocaleDateAndTime); 451 #endif 450 return formatLocaleDate(exec, thisDateObj, milli, LocaleDateAndTime, args); 452 451 } 453 452 … … 462 461 return jsNontrivialString(exec, "Invalid Date"); 463 462 464 #if PLATFORM(MAC) 465 double secs = floor(milli / msPerSecond); 466 return jsNontrivialString(exec, formatLocaleDate(exec, secs, true, false, args)); 467 #else 468 UNUSED_PARAM(args); 469 470 const bool utc = false; 471 472 GregorianDateTime t; 473 thisDateObj->msToGregorianDateTime(milli, utc, t); 474 return formatLocaleDate(exec, t, LocaleDate); 475 #endif 463 return formatLocaleDate(exec, thisDateObj, milli, LocaleDate, args); 476 464 } 477 465 … … 486 474 return jsNontrivialString(exec, "Invalid Date"); 487 475 488 #if PLATFORM(MAC) 489 double secs = floor(milli / msPerSecond); 490 return jsNontrivialString(exec, formatLocaleDate(exec, secs, false, true, args)); 491 #else 492 UNUSED_PARAM(args); 493 494 const bool utc = false; 495 496 GregorianDateTime t; 497 thisDateObj->msToGregorianDateTime(milli, utc, t); 498 return formatLocaleDate(exec, t, LocaleTime); 499 #endif 500 } 501 502 JSValuePtr dateProtoFuncValueOf(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList&) 503 { 504 if (!thisValue->isObject(&DateInstance::info)) 505 return throwError(exec, TypeError); 506 507 DateInstance* thisDateObj = asDateInstance(thisValue); 508 double milli = thisDateObj->internalNumber(); 509 if (isnan(milli)) 510 return jsNaN(exec); 511 512 return jsNumber(exec, milli); 476 return formatLocaleDate(exec, thisDateObj, milli, LocaleTime, args); 513 477 } 514 478 -
trunk/JavaScriptCore/runtime/JSNotAnObject.cpp
r39670 r39809 70 70 JSObject* JSNotAnObject::toObject(ExecState* exec) const 71 71 { 72 UNUSED_PARAM(exec); 73 ASSERT(exec->hadException() && exec->exception() == m_exception); 72 ASSERT_UNUSED(exec, exec->hadException() && exec->exception() == m_exception); 74 73 return m_exception; 75 74 } -
trunk/JavaScriptCore/runtime/RegExp.cpp
r39162 r39809 45 45 , m_numSubpatterns(0) 46 46 { 47 UNUSED_PARAM(globalData);48 47 #if ENABLE(WREC) 49 48 m_wrecFunction = Generator::compileRegExp(globalData, pattern, &m_numSubpatterns, &m_constructionError, m_executablePool); … … 51 50 return; 52 51 // Fall through to non-WREC case. 52 #else 53 UNUSED_PARAM(globalData); 53 54 #endif 54 55 m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(pattern.data()), pattern.size(), … … 69 70 , m_numSubpatterns(0) 70 71 { 71 UNUSED_PARAM(globalData);72 73 72 // NOTE: The global flag is handled on a case-by-case basis by functions like 74 73 // String::match and RegExpObject::match. … … 94 93 return; 95 94 // Fall through to non-WREC case. 95 #else 96 UNUSED_PARAM(globalData); 96 97 #endif 97 98 m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(pattern.data()), pattern.size(),
Note:
See TracChangeset
for help on using the changeset viewer.