Changeset 34372 in webkit for trunk/JavaScriptCore/kjs/value.h


Ignore:
Timestamp:
Jun 4, 2008, 10:36:55 PM (17 years ago)
Author:
[email protected]
Message:

2008-06-04 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak.

Big cleanup of formatting and whitespace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/value.h

    r34355 r34372  
    5353    friend class JSCell; // so it can derive from this class
    5454    friend class Collector; // so it can call asCell()
    55 
    5655private:
    5756    JSValue();
     
    6867    bool isString() const;
    6968    bool isObject() const;
    70     bool isObject(const ClassInfo *) const;
     69    bool isObject(const ClassInfo*) const;
    7170
    7271    // Extracting the value.
     
    7877    bool getString(UString&) const;
    7978    UString getString() const; // null string if not a string
    80     JSObject *getObject(); // NULL if not an object
    81     const JSObject *getObject() const; // NULL if not an object
     79    JSObject* getObject(); // NULL if not an object
     80    const JSObject* getObject() const; // NULL if not an object
    8281
    8382    CallType getCallData(CallData&);
     
    9089   
    9190    // 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;
    9695
    9796    // toNumber conversion is expected to be side effect free if an exception has
    9897    // been set in the ExecState already.
    99     double toNumber(ExecState *exec) const;
     98    double toNumber(ExecState*) const;
    10099    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;
    103102
    104103    // Integer conversions.
     
    138137
    139138    // Implementation details.
    140     JSCell *asCell();
    141     const JSCell *asCell() const;
     139    JSCell* asCell();
     140    const JSCell* asCell() const;
    142141};
    143142
     
    152151    JSCell();
    153152    virtual ~JSCell();
     153
    154154public:
    155155    // Querying the type.
     
    158158    bool isString() const;
    159159    bool isObject() const;
    160     bool isObject(const ClassInfo *) const;
     160    bool isObject(const ClassInfo*) const;
    161161
    162162    // Extracting the value.
     
    165165    bool getString(UString&) const;
    166166    UString getString() const; // null string if not a string
    167     JSObject *getObject(); // NULL if not an object
    168     const JSObject *getObject() const; // NULL if not an object
     167    JSObject* getObject(); // NULL if not an object
     168    const JSObject* getObject() const; // NULL if not an object
    169169   
    170170    virtual CallType getCallData(CallData&);
     
    177177
    178178    // 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;
    185185
    186186    // Garbage collection.
    187     void *operator new(size_t);
     187    void* operator new(size_t);
    188188    virtual void mark();
    189189    bool marked() const;
     
    200200
    201201class NumberImp : public JSCell {
    202   friend JSValue* jsNumberCell(double);
    203 
     202    friend JSValue* jsNumberCell(double);
    204203public:
    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;
    215214    virtual JSObject* toThisObject(ExecState*) const;
    216215
    217   void* operator new(size_t size)
    218   {
     216    void* operator new(size_t size)
     217    {
    219218#ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
    220       return Collector::inlineAllocateNumber(size);
     219        return Collector::inlineAllocateNumber(size);
    221220#else
    222       return Collector::allocateNumber(size);
     221        return Collector::allocateNumber(size);
    223222#endif
    224   }
     223    }
    225224
    226225private:
    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;
    234236};
    235237
    236 JSCell *jsString(const UString&); // returns empty string if passed null string
    237 JSCell *jsString(const char* = ""); // returns empty string if passed 0
     238JSCell* jsString(const UString&); // returns empty string if passed null string
     239JSCell* jsString(const char* = ""); // returns empty string if passed 0
    238240
    239241// should be used for strings that are owned by an object that will
    240242// likely outlive the JSValue this makes, such as the parse tree or a
    241243// DOM object that contains a UString
    242 JSCell *jsOwnedString(const UString&);
     244JSCell* jsOwnedString(const UString&);
    243245
    244246extern const double NaN;
     
    252254}
    253255
    254 ALWAYS_INLINE JSValue *jsUndefined()
     256ALWAYS_INLINE JSValue* jsUndefined()
    255257{
    256258    return JSImmediate::undefinedImmediate();
    257259}
    258260
    259 inline JSValue *jsNull()
     261inline JSValue* jsNull()
    260262{
    261263    return JSImmediate::nullImmediate();
    262264}
    263265
    264 inline JSValue *jsNaN()
     266inline JSValue* jsNaN()
    265267{
    266268    return jsNumberCell(NaN);
    267269}
    268270
    269 inline JSValue *jsBoolean(bool b)
     271inline JSValue* jsBoolean(bool b)
    270272{
    271273    return b ? JSImmediate::trueImmediate() : JSImmediate::falseImmediate();
     
    608610}
    609611
    610 } // namespace
     612} // namespace KJS
    611613
    612614#endif // KJS_VALUE_H
Note: See TracChangeset for help on using the changeset viewer.