Changeset 34372 in webkit for trunk/JavaScriptCore/kjs/value.h
- Timestamp:
- Jun 4, 2008, 10:36:55 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/value.h
r34355 r34372 53 53 friend class JSCell; // so it can derive from this class 54 54 friend class Collector; // so it can call asCell() 55 56 55 private: 57 56 JSValue(); … … 68 67 bool isString() const; 69 68 bool isObject() const; 70 bool isObject(const ClassInfo 69 bool isObject(const ClassInfo*) const; 71 70 72 71 // Extracting the value. … … 78 77 bool getString(UString&) const; 79 78 UString getString() const; // null string if not a string 80 JSObject *getObject(); // NULL if not an object81 const JSObject *getObject() const; // NULL if not an object79 JSObject* getObject(); // NULL if not an object 80 const JSObject* getObject() const; // NULL if not an object 82 81 83 82 CallType getCallData(CallData&); … … 90 89 91 90 // Basic conversions. 92 JSValue* toPrimitive(ExecState* exec, JSType preferredType = UnspecifiedType) const;93 bool getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value);94 95 bool toBoolean(ExecState *exec) const;91 JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const; 92 bool getPrimitiveNumber(ExecState*, double& number, JSValue*&); 93 94 bool toBoolean(ExecState*) const; 96 95 97 96 // toNumber conversion is expected to be side effect free if an exception has 98 97 // been set in the ExecState already. 99 double toNumber(ExecState *exec) const;98 double toNumber(ExecState*) const; 100 99 JSValue* toJSNumber(ExecState*) const; // Fast path for when you expect that the value is an immediate number. 101 UString toString(ExecState *exec) const;102 JSObject* toObject(ExecState *exec) const;100 UString toString(ExecState*) const; 101 JSObject* toObject(ExecState*) const; 103 102 104 103 // Integer conversions. … … 138 137 139 138 // Implementation details. 140 JSCell *asCell();141 const JSCell *asCell() const;139 JSCell* asCell(); 140 const JSCell* asCell() const; 142 141 }; 143 142 … … 152 151 JSCell(); 153 152 virtual ~JSCell(); 153 154 154 public: 155 155 // Querying the type. … … 158 158 bool isString() const; 159 159 bool isObject() const; 160 bool isObject(const ClassInfo 160 bool isObject(const ClassInfo*) const; 161 161 162 162 // Extracting the value. … … 165 165 bool getString(UString&) const; 166 166 UString getString() const; // null string if not a string 167 JSObject *getObject(); // NULL if not an object168 const JSObject *getObject() const; // NULL if not an object167 JSObject* getObject(); // NULL if not an object 168 const JSObject* getObject() const; // NULL if not an object 169 169 170 170 virtual CallType getCallData(CallData&); … … 177 177 178 178 // Basic conversions. 179 virtual JSValue *toPrimitive(ExecState *exec, JSType preferredType = UnspecifiedType) const = 0;180 virtual bool getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value) = 0;181 virtual bool toBoolean(ExecState *exec) const = 0;182 virtual double toNumber(ExecState *exec) const = 0;183 virtual UString toString(ExecState *exec) const = 0;184 virtual JSObject *toObject(ExecState *exec) const = 0;179 virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const = 0; 180 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&) = 0; 181 virtual bool toBoolean(ExecState*) const = 0; 182 virtual double toNumber(ExecState*) const = 0; 183 virtual UString toString(ExecState*) const = 0; 184 virtual JSObject* toObject(ExecState*) const = 0; 185 185 186 186 // Garbage collection. 187 void *operator new(size_t);187 void* operator new(size_t); 188 188 virtual void mark(); 189 189 bool marked() const; … … 200 200 201 201 class NumberImp : public JSCell { 202 friend JSValue* jsNumberCell(double); 203 202 friend JSValue* jsNumberCell(double); 204 203 public: 205 double value() const { return val; }206 207 virtual JSType type() const;208 209 virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;210 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);211 virtual bool toBoolean(ExecState* exec) const;212 virtual double toNumber(ExecState* exec) const;213 virtual UString toString(ExecState* exec) const;214 virtual JSObject* toObject(ExecState* exec) const;204 double value() const { return val; } 205 206 virtual JSType type() const; 207 208 virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const; 209 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 210 virtual bool toBoolean(ExecState*) const; 211 virtual double toNumber(ExecState*) const; 212 virtual UString toString(ExecState*) const; 213 virtual JSObject* toObject(ExecState*) const; 215 214 virtual JSObject* toThisObject(ExecState*) const; 216 215 217 void* operator new(size_t size)218 {216 void* operator new(size_t size) 217 { 219 218 #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE 220 return Collector::inlineAllocateNumber(size);219 return Collector::inlineAllocateNumber(size); 221 220 #else 222 return Collector::allocateNumber(size);221 return Collector::allocateNumber(size); 223 222 #endif 224 }223 } 225 224 226 225 private: 227 NumberImp(double v) : val(v) { } 228 229 virtual bool getUInt32(uint32_t&) const; 230 virtual bool getTruncatedInt32(int32_t&) const; 231 virtual bool getTruncatedUInt32(uint32_t&) const; 232 233 double val; 226 NumberImp(double v) 227 : val(v) 228 { 229 } 230 231 virtual bool getUInt32(uint32_t&) const; 232 virtual bool getTruncatedInt32(int32_t&) const; 233 virtual bool getTruncatedUInt32(uint32_t&) const; 234 235 double val; 234 236 }; 235 237 236 JSCell *jsString(const UString&); // returns empty string if passed null string237 JSCell *jsString(const char* = ""); // returns empty string if passed 0238 JSCell* jsString(const UString&); // returns empty string if passed null string 239 JSCell* jsString(const char* = ""); // returns empty string if passed 0 238 240 239 241 // should be used for strings that are owned by an object that will 240 242 // likely outlive the JSValue this makes, such as the parse tree or a 241 243 // DOM object that contains a UString 242 JSCell *jsOwnedString(const UString&);244 JSCell* jsOwnedString(const UString&); 243 245 244 246 extern const double NaN; … … 252 254 } 253 255 254 ALWAYS_INLINE JSValue *jsUndefined()256 ALWAYS_INLINE JSValue* jsUndefined() 255 257 { 256 258 return JSImmediate::undefinedImmediate(); 257 259 } 258 260 259 inline JSValue *jsNull()261 inline JSValue* jsNull() 260 262 { 261 263 return JSImmediate::nullImmediate(); 262 264 } 263 265 264 inline JSValue *jsNaN()266 inline JSValue* jsNaN() 265 267 { 266 268 return jsNumberCell(NaN); 267 269 } 268 270 269 inline JSValue *jsBoolean(bool b)271 inline JSValue* jsBoolean(bool b) 270 272 { 271 273 return b ? JSImmediate::trueImmediate() : JSImmediate::falseImmediate(); … … 608 610 } 609 611 610 } // namespace 612 } // namespace KJS 611 613 612 614 #endif // KJS_VALUE_H
Note:
See TracChangeset
for help on using the changeset viewer.