Changeset 11527 in webkit for trunk/JavaScriptCore/kjs/date_object.cpp
- Timestamp:
- Dec 10, 2005, 6:06:17 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/date_object.cpp
r11331 r11527 70 70 * Date.prototype object 71 71 */ 72 class DateProtoFunc Imp: public InternalFunctionImp {72 class DateProtoFunc : public InternalFunctionImp { 73 73 public: 74 DateProtoFunc Imp(ExecState *, int i, int len);74 DateProtoFunc(ExecState *, int i, int len); 75 75 76 76 virtual bool implementsCall() const; 77 virtual ValueImp *callAsFunction(ExecState *, ObjectImp*thisObj, const List &args);77 virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args); 78 78 79 79 Completion execute(const List &); … … 99 99 class DateObjectFuncImp : public InternalFunctionImp { 100 100 public: 101 DateObjectFuncImp(ExecState *, FunctionPrototype Imp*, int i, int len);101 DateObjectFuncImp(ExecState *, FunctionPrototype *, int i, int len); 102 102 103 103 virtual bool implementsCall() const; 104 virtual ValueImp *callAsFunction(ExecState *, ObjectImp*thisObj, const List &args);104 virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args); 105 105 106 106 enum { Parse, UTC }; … … 379 379 } 380 380 381 // ------------------------------ DateInstance Imp------------------------------382 383 const ClassInfo DateInstance Imp::info = {"Date", 0, 0, 0};384 385 DateInstance Imp::DateInstanceImp(ObjectImp*proto)386 : ObjectImp(proto)387 { 388 } 389 390 // ------------------------------ DatePrototype Imp-----------------------------391 392 const ClassInfo DatePrototype Imp::info = {"Date", &DateInstanceImp::info, &dateTable, 0};381 // ------------------------------ DateInstance ------------------------------ 382 383 const ClassInfo DateInstance::info = {"Date", 0, 0, 0}; 384 385 DateInstance::DateInstance(JSObject *proto) 386 : JSObject(proto) 387 { 388 } 389 390 // ------------------------------ DatePrototype ----------------------------- 391 392 const ClassInfo DatePrototype::info = {"Date", &DateInstance::info, &dateTable, 0}; 393 393 394 394 /* Source for date_object.lut.h 395 395 We use a negative ID to denote the "UTC" variant. 396 396 @begin dateTable 61 397 toString DateProtoFunc Imp::ToString DontEnum|Function 0398 toUTCString -DateProtoFunc Imp::ToUTCString DontEnum|Function 0399 toDateString DateProtoFunc Imp::ToDateString DontEnum|Function 0400 toTimeString DateProtoFunc Imp::ToTimeString DontEnum|Function 0401 toLocaleString DateProtoFunc Imp::ToLocaleString DontEnum|Function 0402 toLocaleDateString DateProtoFunc Imp::ToLocaleDateString DontEnum|Function 0403 toLocaleTimeString DateProtoFunc Imp::ToLocaleTimeString DontEnum|Function 0404 valueOf DateProtoFunc Imp::ValueOf DontEnum|Function 0405 getTime DateProtoFunc Imp::GetTime DontEnum|Function 0406 getFullYear DateProtoFunc Imp::GetFullYear DontEnum|Function 0407 getUTCFullYear -DateProtoFunc Imp::GetFullYear DontEnum|Function 0408 toGMTString -DateProtoFunc Imp::ToGMTString DontEnum|Function 0409 getMonth DateProtoFunc Imp::GetMonth DontEnum|Function 0410 getUTCMonth -DateProtoFunc Imp::GetMonth DontEnum|Function 0411 getDate DateProtoFunc Imp::GetDate DontEnum|Function 0412 getUTCDate -DateProtoFunc Imp::GetDate DontEnum|Function 0413 getDay DateProtoFunc Imp::GetDay DontEnum|Function 0414 getUTCDay -DateProtoFunc Imp::GetDay DontEnum|Function 0415 getHours DateProtoFunc Imp::GetHours DontEnum|Function 0416 getUTCHours -DateProtoFunc Imp::GetHours DontEnum|Function 0417 getMinutes DateProtoFunc Imp::GetMinutes DontEnum|Function 0418 getUTCMinutes -DateProtoFunc Imp::GetMinutes DontEnum|Function 0419 getSeconds DateProtoFunc Imp::GetSeconds DontEnum|Function 0420 getUTCSeconds -DateProtoFunc Imp::GetSeconds DontEnum|Function 0421 getMilliseconds DateProtoFunc Imp::GetMilliSeconds DontEnum|Function 0422 getUTCMilliseconds -DateProtoFunc Imp::GetMilliSeconds DontEnum|Function 0423 getTimezoneOffset DateProtoFunc Imp::GetTimezoneOffset DontEnum|Function 0424 setTime DateProtoFunc Imp::SetTime DontEnum|Function 1425 setMilliseconds DateProtoFunc Imp::SetMilliSeconds DontEnum|Function 1426 setUTCMilliseconds -DateProtoFunc Imp::SetMilliSeconds DontEnum|Function 1427 setSeconds DateProtoFunc Imp::SetSeconds DontEnum|Function 2428 setUTCSeconds -DateProtoFunc Imp::SetSeconds DontEnum|Function 2429 setMinutes DateProtoFunc Imp::SetMinutes DontEnum|Function 3430 setUTCMinutes -DateProtoFunc Imp::SetMinutes DontEnum|Function 3431 setHours DateProtoFunc Imp::SetHours DontEnum|Function 4432 setUTCHours -DateProtoFunc Imp::SetHours DontEnum|Function 4433 setDate DateProtoFunc Imp::SetDate DontEnum|Function 1434 setUTCDate -DateProtoFunc Imp::SetDate DontEnum|Function 1435 setMonth DateProtoFunc Imp::SetMonth DontEnum|Function 2436 setUTCMonth -DateProtoFunc Imp::SetMonth DontEnum|Function 2437 setFullYear DateProtoFunc Imp::SetFullYear DontEnum|Function 3438 setUTCFullYear -DateProtoFunc Imp::SetFullYear DontEnum|Function 3439 setYear DateProtoFunc Imp::SetYear DontEnum|Function 1440 getYear DateProtoFunc Imp::GetYear DontEnum|Function 0397 toString DateProtoFunc::ToString DontEnum|Function 0 398 toUTCString -DateProtoFunc::ToUTCString DontEnum|Function 0 399 toDateString DateProtoFunc::ToDateString DontEnum|Function 0 400 toTimeString DateProtoFunc::ToTimeString DontEnum|Function 0 401 toLocaleString DateProtoFunc::ToLocaleString DontEnum|Function 0 402 toLocaleDateString DateProtoFunc::ToLocaleDateString DontEnum|Function 0 403 toLocaleTimeString DateProtoFunc::ToLocaleTimeString DontEnum|Function 0 404 valueOf DateProtoFunc::ValueOf DontEnum|Function 0 405 getTime DateProtoFunc::GetTime DontEnum|Function 0 406 getFullYear DateProtoFunc::GetFullYear DontEnum|Function 0 407 getUTCFullYear -DateProtoFunc::GetFullYear DontEnum|Function 0 408 toGMTString -DateProtoFunc::ToGMTString DontEnum|Function 0 409 getMonth DateProtoFunc::GetMonth DontEnum|Function 0 410 getUTCMonth -DateProtoFunc::GetMonth DontEnum|Function 0 411 getDate DateProtoFunc::GetDate DontEnum|Function 0 412 getUTCDate -DateProtoFunc::GetDate DontEnum|Function 0 413 getDay DateProtoFunc::GetDay DontEnum|Function 0 414 getUTCDay -DateProtoFunc::GetDay DontEnum|Function 0 415 getHours DateProtoFunc::GetHours DontEnum|Function 0 416 getUTCHours -DateProtoFunc::GetHours DontEnum|Function 0 417 getMinutes DateProtoFunc::GetMinutes DontEnum|Function 0 418 getUTCMinutes -DateProtoFunc::GetMinutes DontEnum|Function 0 419 getSeconds DateProtoFunc::GetSeconds DontEnum|Function 0 420 getUTCSeconds -DateProtoFunc::GetSeconds DontEnum|Function 0 421 getMilliseconds DateProtoFunc::GetMilliSeconds DontEnum|Function 0 422 getUTCMilliseconds -DateProtoFunc::GetMilliSeconds DontEnum|Function 0 423 getTimezoneOffset DateProtoFunc::GetTimezoneOffset DontEnum|Function 0 424 setTime DateProtoFunc::SetTime DontEnum|Function 1 425 setMilliseconds DateProtoFunc::SetMilliSeconds DontEnum|Function 1 426 setUTCMilliseconds -DateProtoFunc::SetMilliSeconds DontEnum|Function 1 427 setSeconds DateProtoFunc::SetSeconds DontEnum|Function 2 428 setUTCSeconds -DateProtoFunc::SetSeconds DontEnum|Function 2 429 setMinutes DateProtoFunc::SetMinutes DontEnum|Function 3 430 setUTCMinutes -DateProtoFunc::SetMinutes DontEnum|Function 3 431 setHours DateProtoFunc::SetHours DontEnum|Function 4 432 setUTCHours -DateProtoFunc::SetHours DontEnum|Function 4 433 setDate DateProtoFunc::SetDate DontEnum|Function 1 434 setUTCDate -DateProtoFunc::SetDate DontEnum|Function 1 435 setMonth DateProtoFunc::SetMonth DontEnum|Function 2 436 setUTCMonth -DateProtoFunc::SetMonth DontEnum|Function 2 437 setFullYear DateProtoFunc::SetFullYear DontEnum|Function 3 438 setUTCFullYear -DateProtoFunc::SetFullYear DontEnum|Function 3 439 setYear DateProtoFunc::SetYear DontEnum|Function 1 440 getYear DateProtoFunc::GetYear DontEnum|Function 0 441 441 @end 442 442 */ 443 443 // ECMA 15.9.4 444 444 445 DatePrototype Imp::DatePrototypeImp(ExecState *, ObjectPrototypeImp*objectProto)446 : DateInstance Imp(objectProto)445 DatePrototype::DatePrototype(ExecState *, ObjectPrototype *objectProto) 446 : DateInstance(objectProto) 447 447 { 448 448 setInternalValue(jsNaN()); … … 450 450 } 451 451 452 bool DatePrototype Imp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)453 { 454 return getStaticFunctionSlot<DateProtoFunc Imp, ObjectImp>(exec, &dateTable, this, propertyName, slot);455 } 456 457 // ------------------------------ DateProtoFunc Imp-----------------------------458 459 DateProtoFunc Imp::DateProtoFuncImp(ExecState *exec, int i, int len)460 : InternalFunctionImp(static_cast<FunctionPrototype Imp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())),452 bool DatePrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) 453 { 454 return getStaticFunctionSlot<DateProtoFunc, JSObject>(exec, &dateTable, this, propertyName, slot); 455 } 456 457 // ------------------------------ DateProtoFunc ----------------------------- 458 459 DateProtoFunc::DateProtoFunc(ExecState *exec, int i, int len) 460 : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())), 461 461 id(abs(i)), utc(i<0) 462 462 // We use a negative ID to denote the "UTC" variant. … … 465 465 } 466 466 467 bool DateProtoFunc Imp::implementsCall() const467 bool DateProtoFunc::implementsCall() const 468 468 { 469 469 return true; … … 476 476 } 477 477 478 ValueImp *DateProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp*thisObj, const List &args)478 JSValue *DateProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) 479 479 { 480 480 if ((id == ToString || id == ValueOf || id == GetTime || id == SetTime) && 481 !thisObj->inherits(&DateInstance Imp::info)) {481 !thisObj->inherits(&DateInstance::info)) { 482 482 // non-generic function called on non-date object 483 483 … … 488 488 489 489 490 ValueImp*result = 0;490 JSValue *result = 0; 491 491 UString s; 492 492 #if !__APPLE__ … … 498 498 // FIXME: Where's the code to set the locale back to oldlocale? 499 499 #endif 500 ValueImp*v = thisObj->internalValue();500 JSValue *v = thisObj->internalValue(); 501 501 double milli = v->toNumber(exec); 502 502 if (isNaN(milli)) { … … 682 682 683 683 DateObjectImp::DateObjectImp(ExecState *exec, 684 FunctionPrototype Imp*funcProto,685 DatePrototype Imp*dateProto)684 FunctionPrototype *funcProto, 685 DatePrototype *dateProto) 686 686 : InternalFunctionImp(funcProto) 687 687 { … … 704 704 705 705 // ECMA 15.9.3 706 ObjectImp*DateObjectImp::construct(ExecState *exec, const List &args)706 JSObject *DateObjectImp::construct(ExecState *exec, const List &args) 707 707 { 708 708 int numArgs = args.size(); … … 756 756 } 757 757 758 DateInstance Imp *ret = new DateInstanceImp(exec->lexicalInterpreter()->builtinDatePrototype());758 DateInstance *ret = new DateInstance(exec->lexicalInterpreter()->builtinDatePrototype()); 759 759 ret->setInternalValue(jsNumber(timeClip(value))); 760 760 return ret; … … 767 767 768 768 // ECMA 15.9.2 769 ValueImp *DateObjectImp::callAsFunction(ExecState * /*exec*/, ObjectImp* /*thisObj*/, const List &/*args*/)769 JSValue *DateObjectImp::callAsFunction(ExecState * /*exec*/, JSObject * /*thisObj*/, const List &/*args*/) 770 770 { 771 771 time_t t = time(0); … … 777 777 // ------------------------------ DateObjectFuncImp ---------------------------- 778 778 779 DateObjectFuncImp::DateObjectFuncImp(ExecState *exec, FunctionPrototype Imp*funcProto, int i, int len)779 DateObjectFuncImp::DateObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len) 780 780 : InternalFunctionImp(funcProto), id(i) 781 781 { … … 789 789 790 790 // ECMA 15.9.4.2 - 3 791 ValueImp *DateObjectFuncImp::callAsFunction(ExecState *exec, ObjectImp*thisObj, const List &args)791 JSValue *DateObjectFuncImp::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) 792 792 { 793 793 if (id == Parse) {
Note:
See TracChangeset
for help on using the changeset viewer.