Changeset 35807 in webkit for trunk/JavaScriptCore/kjs/JSObject.h
- Timestamp:
- Aug 17, 2008, 1:23:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSObject.h
r35657 r35807 70 70 virtual JSType type() const; 71 71 72 /**73 * A pointer to a ClassInfo struct for this class. This provides a basic74 * facility for run-time type information, and can be used to check an75 * object's class an inheritance (see inherits()). This should76 * always return a statically declared pointer, or 0 to indicate that77 * there is no class information.78 *79 * This is primarily useful if you have application-defined classes that you80 * wish to check against for casting purposes.81 *82 * For example, to specify the class info for classes FooImp and BarImp,83 * where FooImp inherits from BarImp, you would add the following in your84 * class declarations:85 *86 * \code87 * class BarImp : public JSObject {88 * virtual const ClassInfo *classInfo() const { return &info; }89 * static const ClassInfo info;90 * // ...91 * };92 *93 * class FooImp : public JSObject {94 * virtual const ClassInfo *classInfo() const { return &info; }95 * static const ClassInfo info;96 * // ...97 * };98 * \endcode99 *100 * And in your source file:101 *102 * \code103 * const ClassInfo BarImp::info = { "Bar", 0, 0, 0 }; // no parent class104 * const ClassInfo FooImp::info = { "Foo", &BarImp::info, 0, 0 };105 * \endcode106 *107 * @see inherits()108 */109 110 /**111 * Checks whether this object inherits from the class with the specified112 * classInfo() pointer. This requires that both this class and the other113 * class return a non-NULL pointer for their classInfo() methods (otherwise114 * it will return false).115 *116 * For example, for two JSObject pointers obj1 and obj2, you can check117 * if obj1's class inherits from obj2's class using the following:118 *119 * if (obj1->inherits(obj2->classInfo())) {120 * // ...121 * }122 *123 * If you have a handle to a statically declared ClassInfo, such as in the124 * classInfo() example, you can check for inheritance without needing125 * an instance of the other class:126 *127 * if (obj1->inherits(FooImp::info)) {128 * // ...129 * }130 *131 * @param cinfo The ClassInfo pointer for the class you want to check132 * inheritance against.133 * @return true if this object's class inherits from class with the134 * ClassInfo pointer specified in cinfo135 */136 72 bool inherits(const ClassInfo* classInfo) const { return isObject(classInfo); } // FIXME: Merge with isObject. 137 73 138 // internal properties (ECMA 262-3 8.6.2)139 140 /**141 * Returns the prototype of this object. Note that this is not the same as142 * the "prototype" property.143 *144 * See ECMA 8.6.2145 *146 * @return The object's prototype147 */148 74 JSValue* prototype() const; 149 75 void setPrototype(JSValue* prototype); 150 76 151 /**152 * Returns the class name of the object153 *154 * See ECMA 8.6.2155 *156 * @return The object's class name157 */158 /**159 * Implementation of the [[Class]] internal property (implemented by all160 * Objects)161 *162 * The default implementation uses classInfo().163 * You should either implement classInfo(), or164 * if you simply need a classname, you can reimplement className()165 * instead.166 */167 77 virtual UString className() const; 168 78 169 /**170 * Retrieves the specified property from the object. If neither the object171 * or any other object in its prototype chain have the property, this172 * function will return Undefined.173 *174 * See ECMA 8.6.2.1175 *176 * @param exec The current execution state177 * @param propertyName The name of the property to retrieve178 *179 * @return The specified property, or Undefined180 */181 79 JSValue* get(ExecState*, const Identifier& propertyName) const; 182 80 JSValue* get(ExecState*, unsigned propertyName) const; … … 188 86 virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); 189 87 190 /**191 * Sets the specified property.192 *193 * See ECMA 8.6.2.2194 *195 * @param exec The current execution state196 * @param propertyName The name of the property to set197 * @param propertyValue The value to set198 */199 88 virtual void put(ExecState*, const Identifier& propertyName, JSValue* value); 200 89 virtual void put(ExecState*, unsigned propertyName, JSValue* value); … … 203 92 virtual void putWithAttributes(ExecState*, unsigned propertyName, JSValue* value, unsigned attributes); 204 93 205 /**206 * Checks if a property is enumerable, that is if it doesn't have the DontEnum207 * flag set208 *209 * See ECMA 15.2.4210 * @param exec The current execution state211 * @param propertyName The name of the property212 * @return true if the property is enumerable, otherwise false213 */214 94 bool propertyIsEnumerable(ExecState*, const Identifier& propertyName) const; 215 95 216 /**217 * Checks to see whether the object (or any object in its prototype chain)218 * has a property with the specified name.219 *220 * See ECMA 8.6.2.4221 *222 * @param exec The current execution state223 * @param propertyName The name of the property to check for224 * @return true if the object has the property, otherwise false225 */226 96 bool hasProperty(ExecState*, const Identifier& propertyName) const; 227 97 bool hasProperty(ExecState*, unsigned propertyName) const; 228 98 bool hasOwnProperty(ExecState*, const Identifier& propertyName) const; 229 99 230 /**231 * Removes the specified property from the object.232 *233 * See ECMA 8.6.2.5234 *235 * @param exec The current execution state236 * @param propertyName The name of the property to delete237 * @return true if the property was successfully deleted or did not238 * exist on the object. false if deleting the specified property is not239 * allowed.240 */241 100 virtual bool deleteProperty(ExecState*, const Identifier& propertyName); 242 101 virtual bool deleteProperty(ExecState*, unsigned propertyName); 243 102 244 /**245 * Converts the object into a primitive value. The value return may differ246 * depending on the supplied hint247 *248 * See ECMA 8.6.2.6249 *250 * @param exec The current execution state251 * @param hint The desired primitive type to convert to252 * @return A primitive value converted from the objetc. Note that the253 * type of primitive value returned may not be the same as the requested254 * hint.255 */256 /**257 * Implementation of the [[DefaultValue]] internal property (implemented by258 * all Objects)259 */260 103 virtual JSValue* defaultValue(ExecState*, JSType hint) const; 261 104 262 /**263 * Whether or not the object implements the hasInstance() method. If this264 * returns false you should not call the hasInstance() method on this265 * object (typically, an assertion will fail to indicate this).266 *267 * @return true if this object implements the hasInstance() method,268 * otherwise false269 */270 105 virtual bool implementsHasInstance() const; 271 272 /**273 * Checks whether value delegates behavior to this object. Used by the274 * instanceof operator.275 *276 * @param exec The current execution state277 * @param value The value to check278 * @return true if value delegates behavior to this object, otherwise279 * false280 */281 106 virtual bool hasInstance(ExecState*, JSValue*); 282 107 … … 299 124 300 125 // This get function only looks at the property map. 301 // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want302 // to look up in the prototype, it might already exist there)303 126 JSValue* getDirect(const Identifier& propertyName) const { return m_propertyMap.get(propertyName); } 304 127 JSValue** getDirectLocation(const Identifier& propertyName) { return m_propertyMap.getLocation(propertyName); } … … 310 133 311 134 // convenience to add a function property under the function's own built-in name 312 void putDirectFunction( InternalFunction*, unsigned attr = 0);135 void putDirectFunction(ExecState*, InternalFunction*, unsigned attr = 0); 313 136 314 137 void fillGetterPropertySlot(PropertySlot&, JSValue** location);
Note:
See TracChangeset
for help on using the changeset viewer.