Changeset 92706 in webkit for trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
- Timestamp:
- Aug 9, 2011, 1:46:17 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
r91194 r92706 43 43 namespace JSC { 44 44 45 template <class Base>46 inline JSCallbackObject< Base>* JSCallbackObject<Base>::asCallbackObject(JSValue value)45 template <class Parent> 46 inline JSCallbackObject<Parent>* JSCallbackObject<Parent>::asCallbackObject(JSValue value) 47 47 { 48 48 ASSERT(asObject(value)->inherits(&s_info)); … … 50 50 } 51 51 52 template <class Base>53 JSCallbackObject< Base>::JSCallbackObject(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, JSClassRef jsClass, void* data)54 : Base(globalObject, structure)52 template <class Parent> 53 JSCallbackObject<Parent>::JSCallbackObject(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, JSClassRef jsClass, void* data) 54 : Parent(globalObject, structure) 55 55 , m_callbackObjectData(adoptPtr(new JSCallbackObjectData(data, jsClass))) 56 56 { 57 ASSERT( Base::inherits(&s_info));57 ASSERT(Parent::inherits(&s_info)); 58 58 init(exec); 59 59 } … … 61 61 // Global object constructor. 62 62 // FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one. 63 template <class Base>64 JSCallbackObject< Base>::JSCallbackObject(JSGlobalData& globalData, JSClassRef jsClass, Structure* structure)65 : Base(globalData, structure)63 template <class Parent> 64 JSCallbackObject<Parent>::JSCallbackObject(JSGlobalData& globalData, JSClassRef jsClass, Structure* structure) 65 : Parent(globalData, structure) 66 66 , m_callbackObjectData(adoptPtr(new JSCallbackObjectData(0, jsClass))) 67 67 { 68 ASSERT( Base::inherits(&s_info));69 ASSERT( Base::isGlobalObject());68 ASSERT(Parent::inherits(&s_info)); 69 ASSERT(Parent::isGlobalObject()); 70 70 init(static_cast<JSGlobalObject*>(this)->globalExec()); 71 71 } 72 72 73 template <class Base>74 void JSCallbackObject< Base>::init(ExecState* exec)73 template <class Parent> 74 void JSCallbackObject<Parent>::init(ExecState* exec) 75 75 { 76 76 ASSERT(exec); … … 101 101 } 102 102 103 template <class Base>104 UString JSCallbackObject< Base>::className() const103 template <class Parent> 104 UString JSCallbackObject<Parent>::className() const 105 105 { 106 106 UString thisClassName = classRef()->className(); … … 108 108 return thisClassName; 109 109 110 return Base::className();111 } 112 113 template <class Base>114 bool JSCallbackObject< Base>::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)110 return Parent::className(); 111 } 112 113 template <class Parent> 114 bool JSCallbackObject<Parent>::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 115 115 { 116 116 JSContextRef ctx = toRef(exec); … … 166 166 } 167 167 168 return Base::getOwnPropertySlot(exec, propertyName, slot);169 } 170 171 template <class Base>172 bool JSCallbackObject< Base>::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)168 return Parent::getOwnPropertySlot(exec, propertyName, slot); 169 } 170 171 template <class Parent> 172 bool JSCallbackObject<Parent>::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) 173 173 { 174 174 PropertySlot slot; … … 185 185 } 186 186 187 return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor);188 } 189 190 template <class Base>191 void JSCallbackObject< Base>::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)187 return Parent::getOwnPropertyDescriptor(exec, propertyName, descriptor); 188 } 189 190 template <class Parent> 191 void JSCallbackObject<Parent>::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) 192 192 { 193 193 JSContextRef ctx = toRef(exec); … … 237 237 if (entry->attributes & kJSPropertyAttributeReadOnly) 238 238 return; 239 JSCallbackObject< Base>::putDirect(exec->globalData(), propertyName, value); // put as override property239 JSCallbackObject<Parent>::putDirect(exec->globalData(), propertyName, value); // put as override property 240 240 return; 241 241 } … … 243 243 } 244 244 245 return Base::put(exec, propertyName, value, slot);246 } 247 248 template <class Base>249 bool JSCallbackObject< Base>::deleteProperty(ExecState* exec, const Identifier& propertyName)245 return Parent::put(exec, propertyName, value, slot); 246 } 247 248 template <class Parent> 249 bool JSCallbackObject<Parent>::deleteProperty(ExecState* exec, const Identifier& propertyName) 250 250 { 251 251 JSContextRef ctx = toRef(exec); … … 286 286 } 287 287 288 return Base::deleteProperty(exec, propertyName);289 } 290 291 template <class Base>292 bool JSCallbackObject< Base>::deleteProperty(ExecState* exec, unsigned propertyName)288 return Parent::deleteProperty(exec, propertyName); 289 } 290 291 template <class Parent> 292 bool JSCallbackObject<Parent>::deleteProperty(ExecState* exec, unsigned propertyName) 293 293 { 294 294 return deleteProperty(exec, Identifier::from(exec, propertyName)); 295 295 } 296 296 297 template <class Base>298 ConstructType JSCallbackObject< Base>::getConstructData(ConstructData& constructData)297 template <class Parent> 298 ConstructType JSCallbackObject<Parent>::getConstructData(ConstructData& constructData) 299 299 { 300 300 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { … … 307 307 } 308 308 309 template <class Base>310 EncodedJSValue JSCallbackObject< Base>::construct(ExecState* exec)309 template <class Parent> 310 EncodedJSValue JSCallbackObject<Parent>::construct(ExecState* exec) 311 311 { 312 312 JSObject* constructor = exec->callee(); … … 314 314 JSObjectRef constructorRef = toRef(constructor); 315 315 316 for (JSClassRef jsClass = static_cast<JSCallbackObject< Base>*>(constructor)->classRef(); jsClass; jsClass = jsClass->parentClass) {316 for (JSClassRef jsClass = static_cast<JSCallbackObject<Parent>*>(constructor)->classRef(); jsClass; jsClass = jsClass->parentClass) { 317 317 if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callAsConstructor) { 318 318 int argumentCount = static_cast<int>(exec->argumentCount()); … … 336 336 } 337 337 338 template <class Base>339 bool JSCallbackObject< Base>::hasInstance(ExecState* exec, JSValue value, JSValue)338 template <class Parent> 339 bool JSCallbackObject<Parent>::hasInstance(ExecState* exec, JSValue value, JSValue) 340 340 { 341 341 JSContextRef execRef = toRef(exec); … … 359 359 } 360 360 361 template <class Base>362 CallType JSCallbackObject< Base>::getCallData(CallData& callData)361 template <class Parent> 362 CallType JSCallbackObject<Parent>::getCallData(CallData& callData) 363 363 { 364 364 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { … … 371 371 } 372 372 373 template <class Base>374 EncodedJSValue JSCallbackObject< Base>::call(ExecState* exec)373 template <class Parent> 374 EncodedJSValue JSCallbackObject<Parent>::call(ExecState* exec) 375 375 { 376 376 JSContextRef execRef = toRef(exec); … … 378 378 JSObjectRef thisObjRef = toRef(exec->hostThisValue().toThisObject(exec)); 379 379 380 for (JSClassRef jsClass = static_cast<JSCallbackObject< Base>*>(toJS(functionRef))->classRef(); jsClass; jsClass = jsClass->parentClass) {380 for (JSClassRef jsClass = static_cast<JSCallbackObject<Parent>*>(toJS(functionRef))->classRef(); jsClass; jsClass = jsClass->parentClass) { 381 381 if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) { 382 382 int argumentCount = static_cast<int>(exec->argumentCount()); … … 400 400 } 401 401 402 template <class Base>403 void JSCallbackObject< Base>::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)402 template <class Parent> 403 void JSCallbackObject<Parent>::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) 404 404 { 405 405 JSContextRef execRef = toRef(exec); … … 435 435 } 436 436 437 Base::getOwnPropertyNames(exec, propertyNames, mode);438 } 439 440 template <class Base>441 double JSCallbackObject< Base>::toNumber(ExecState* exec) const437 Parent::getOwnPropertyNames(exec, propertyNames, mode); 438 } 439 440 template <class Parent> 441 double JSCallbackObject<Parent>::toNumber(ExecState* exec) const 442 442 { 443 443 // We need this check to guard against the case where this object is rhs of … … 467 467 } 468 468 469 return Base::toNumber(exec);470 } 471 472 template <class Base>473 UString JSCallbackObject< Base>::toString(ExecState* exec) const469 return Parent::toNumber(exec); 470 } 471 472 template <class Parent> 473 UString JSCallbackObject<Parent>::toString(ExecState* exec) const 474 474 { 475 475 JSContextRef ctx = toRef(exec); … … 492 492 } 493 493 494 return Base::toString(exec);495 } 496 497 template <class Base>498 void JSCallbackObject< Base>::setPrivate(void* data)494 return Parent::toString(exec); 495 } 496 497 template <class Parent> 498 void JSCallbackObject<Parent>::setPrivate(void* data) 499 499 { 500 500 m_callbackObjectData->privateData = data; 501 501 } 502 502 503 template <class Base>504 void* JSCallbackObject< Base>::getPrivate()503 template <class Parent> 504 void* JSCallbackObject<Parent>::getPrivate() 505 505 { 506 506 return m_callbackObjectData->privateData; 507 507 } 508 508 509 template <class Base>510 bool JSCallbackObject< Base>::inherits(JSClassRef c) const509 template <class Parent> 510 bool JSCallbackObject<Parent>::inherits(JSClassRef c) const 511 511 { 512 512 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) … … 517 517 } 518 518 519 template <class Base>520 JSValue JSCallbackObject< Base>::getStaticValue(ExecState* exec, const Identifier& propertyName)519 template <class Parent> 520 JSValue JSCallbackObject<Parent>::getStaticValue(ExecState* exec, const Identifier& propertyName) 521 521 { 522 522 JSObjectRef thisRef = toRef(this); … … 546 546 } 547 547 548 template <class Base>549 JSValue JSCallbackObject< Base>::staticFunctionGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)550 { 551 JSCallbackObject* thisObj = asCallbackObject(slot Base);548 template <class Parent> 549 JSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, JSValue slotParent, const Identifier& propertyName) 550 { 551 JSCallbackObject* thisObj = asCallbackObject(slotParent); 552 552 553 553 // Check for cached or override property. 554 554 PropertySlot slot2(thisObj); 555 if (thisObj-> Base::getOwnPropertySlot(exec, propertyName, slot2))555 if (thisObj->Parent::getOwnPropertySlot(exec, propertyName, slot2)) 556 556 return slot2.getValue(exec, propertyName); 557 557 … … 572 572 } 573 573 574 template <class Base>575 JSValue JSCallbackObject< Base>::callbackGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)576 { 577 JSCallbackObject* thisObj = asCallbackObject(slot Base);574 template <class Parent> 575 JSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, JSValue slotParent, const Identifier& propertyName) 576 { 577 JSCallbackObject* thisObj = asCallbackObject(slotParent); 578 578 579 579 JSObjectRef thisRef = toRef(thisObj);
Note:
See TracChangeset
for help on using the changeset viewer.