Changeset 34754 in webkit for trunk/JavaScriptCore/kjs/JSObject.h
- Timestamp:
- Jun 23, 2008, 10:23:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSObject.h
r34664 r34754 85 85 JSType type() const { return GetterSetterType; } 86 86 87 GetterSetter() : getter(0), setter(0) { } 88 89 virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const; 90 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 91 virtual bool toBoolean(ExecState *exec) const; 92 virtual double toNumber(ExecState *exec) const; 93 virtual UString toString(ExecState *exec) const; 94 virtual JSObject *toObject(ExecState *exec) const; 87 GetterSetter() : m_getter(0), m_setter(0) { } 95 88 96 89 virtual void mark(); 97 90 98 JSObject *getGetter() { returngetter; }99 void setGetter(JSObject *g) { getter = g; }100 JSObject *getSetter() { returnsetter; }101 void setSetter(JSObject *s) { setter = s; }91 JSObject* getter() const { return m_getter; } 92 void setGetter(JSObject* getter) { m_getter = getter; } 93 JSObject* setter() const { return m_setter; } 94 void setSetter(JSObject* setter) { m_setter = setter; } 102 95 103 96 private: 104 // Object operations, with the toObject operation included.105 virtual bool get OwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);106 virtual bool getOwnPropertySlot(ExecState*, unsigned index, PropertySlot&);107 virtual void put(ExecState*, const Identifier& propertyName, JSValue*);108 virtual void put(ExecState*, unsigned propertyName, JSValue*);109 virtual JSObject* to ThisObject(ExecState*) const;110 111 JSObject *getter;112 JSObject *setter;97 virtual JSValue* toPrimitive(ExecState*, JSType preferred) const; 98 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 99 virtual bool toBoolean(ExecState*) const; 100 virtual double toNumber(ExecState*) const; 101 virtual UString toString(ExecState*) const; 102 virtual JSObject* toObject(ExecState*) const; 103 104 JSObject* m_getter; 105 JSObject* m_setter; 113 106 }; 114 107 … … 168 161 * @see inherits() 169 162 */ 170 virtual const ClassInfo *classInfo() const;171 163 172 164 /** … … 196 188 * ClassInfo pointer specified in cinfo 197 189 */ 198 bool inherits(const ClassInfo *cinfo) const;190 bool inherits(const ClassInfo* classInfo) const { return isObject(classInfo); } // FIXME: Merge with isObject. 199 191 200 192 // internal properties (ECMA 262-3 8.6.2) … … 231 223 /** 232 224 * Retrieves the specified property from the object. If neither the object 233 * or any other object in it 's prototype chain have the property, this225 * or any other object in its prototype chain have the property, this 234 226 * function will return Undefined. 235 227 * … … 277 269 278 270 /** 279 * Checks to see whether the object (or any object in it 's prototype chain)271 * Checks to see whether the object (or any object in its prototype chain) 280 272 * has a property with the specified name. 281 273 * … … 320 312 * all Objects) 321 313 */ 322 virtual JSValue *defaultValue(ExecState *exec, JSType hint) const; 323 324 /** 325 * Creates a new object based on this object. Typically this means the 326 * following: 327 * 1. A new object is created 328 * 2. The prototype of the new object is set to the value of this object's 329 * "prototype" property 330 * 3. The call() method of this object is called, with the new object 331 * passed as the this value 332 * 4. The new object is returned 333 * 334 * In some cases, Host objects may differ from these semantics, although 335 * this is discouraged. 336 * 337 * If an error occurs during construction, the execution state's exception 338 * will be set. This can be tested for with ExecState::hadException(). 339 * Under some circumstances, the exception object may also be returned. 340 * 341 * Note: This function should not be called if getConstructData() returns 342 * ConstructTypeNone, in which case it will result in an assertion failure. 343 * 344 * @param exec The current execution state 345 * @param args The arguments to be passed to call() once the new object has 346 * been created 347 * @return The newly created & initialized object 348 */ 349 /** 350 * Implementation of the [[Construct]] internal property 351 */ 352 virtual JSObject* construct(ExecState* exec, const ArgList& args); 353 virtual JSObject* construct(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber); 354 355 /** 356 * Calls this object as if it is a function. 357 * 358 * Note: This function should not be called if implementsCall() returns 359 * false, in which case it will result in an assertion failure. 360 * 361 * See ECMA 8.6.2.3 362 * 363 * @param exec The current execution state 364 * @param thisObj The obj to be used as "this" within function execution. 365 * Note that in most cases this will be different from the C++ "this" 366 * object. For example, if the ECMAScript code "window.location->toString()" 367 * is executed, call() will be invoked on the C++ object which implements 368 * the toString method, with the thisObj being window.location 369 * @param args ArgList of arguments to be passed to the function 370 * @return The return value from the function 371 */ 372 bool implementsCall(); 373 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args); 314 virtual JSValue* defaultValue(ExecState*, JSType hint) const; 374 315 375 316 /** … … 447 388 }; 448 389 390 JSObject* constructEmptyObject(ExecState*); 391 449 392 /** 450 393 * Types of Native Errors available. For custom errors, GeneralError … … 506 449 } 507 450 508 inline bool JS Object::inherits(const ClassInfo *info) const509 { 510 for (const ClassInfo *ci = classInfo(); ci; ci = ci->parentClass)451 inline bool JSCell::isObject(const ClassInfo* info) const 452 { 453 for (const ClassInfo* ci = classInfo(); ci; ci = ci->parentClass) { 511 454 if (ci == info) 512 455 return true; 456 } 513 457 return false; 514 458 } 515 459 516 // this method is here to be after the inline declaration of JSObject::inherits517 inline bool JSCell::isObject(const ClassInfo *info) const518 {519 return isObject() && static_cast<const JSObject *>(this)->inherits(info);520 }521 522 460 // this method is here to be after the inline declaration of JSCell::isObject 523 inline bool JSValue::isObject(const ClassInfo *c) const524 { 525 return !JSImmediate::isImmediate(this) && asCell()->isObject(c );461 inline bool JSValue::isObject(const ClassInfo* classInfo) const 462 { 463 return !JSImmediate::isImmediate(this) && asCell()->isObject(classInfo); 526 464 } 527 465
Note:
See TracChangeset
for help on using the changeset viewer.