Ignore:
Timestamp:
Jan 9, 2009, 4:14:25 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-01-09 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Stage two of converting JSValue from a pointer to a class type.
Remove the class JSValue. The functionallity has been transitioned
into the wrapper class type JSValuePtr.

The last stage will be to rename JSValuePtr to JSValue, remove the
overloaded -> operator, and switch operations on JSValuePtrs from
using '->' to use '.' instead.

  • API/APICast.h:
  • JavaScriptCore.exp:
  • runtime/JSCell.h: (JSC::asCell): (JSC::JSValuePtr::asCell): (JSC::JSValuePtr::isNumber): (JSC::JSValuePtr::isString): (JSC::JSValuePtr::isGetterSetter): (JSC::JSValuePtr::isObject): (JSC::JSValuePtr::getNumber): (JSC::JSValuePtr::getString): (JSC::JSValuePtr::getObject): (JSC::JSValuePtr::getCallData): (JSC::JSValuePtr::getConstructData): (JSC::JSValuePtr::getUInt32): (JSC::JSValuePtr::getTruncatedInt32): (JSC::JSValuePtr::getTruncatedUInt32): (JSC::JSValuePtr::mark): (JSC::JSValuePtr::marked): (JSC::JSValuePtr::toPrimitive): (JSC::JSValuePtr::getPrimitiveNumber): (JSC::JSValuePtr::toBoolean): (JSC::JSValuePtr::toNumber): (JSC::JSValuePtr::toString): (JSC::JSValuePtr::toObject): (JSC::JSValuePtr::toThisObject): (JSC::JSValuePtr::needsThisConversion): (JSC::JSValuePtr::toThisString): (JSC::JSValuePtr::getJSNumber):
  • runtime/JSImmediate.h: (JSC::JSValuePtr::isUndefined): (JSC::JSValuePtr::isNull): (JSC::JSValuePtr::isUndefinedOrNull): (JSC::JSValuePtr::isBoolean): (JSC::JSValuePtr::getBoolean): (JSC::JSValuePtr::toInt32): (JSC::JSValuePtr::toUInt32):
  • runtime/JSNumberCell.h: (JSC::JSValuePtr::uncheckedGetNumber): (JSC::JSValuePtr::toJSNumber):
  • runtime/JSObject.h: (JSC::JSValuePtr::isObject): (JSC::JSValuePtr::get): (JSC::JSValuePtr::put):
  • runtime/JSString.h: (JSC::JSValuePtr::toThisJSString):
  • runtime/JSValue.cpp: (JSC::JSValuePtr::toInteger): (JSC::JSValuePtr::toIntegerPreserveNaN): (JSC::JSValuePtr::toInt32SlowCase): (JSC::JSValuePtr::toUInt32SlowCase):
  • runtime/JSValue.h: (JSC::JSValuePtr::makeImmediate): (JSC::JSValuePtr::immediateValue): (JSC::JSValuePtr::JSValuePtr): (JSC::JSValuePtr::operator->): (JSC::JSValuePtr::operator bool): (JSC::JSValuePtr::operator==): (JSC::JSValuePtr::operator!=): (JSC::JSValuePtr::encode): (JSC::JSValuePtr::decode): (JSC::JSValuePtr::toFloat): (JSC::JSValuePtr::asValue): (JSC::operator==): (JSC::operator!=):

WebCore:

2009-01-09 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Delete references to JSValue, removing this class.

  • bindings/js/JSWorkerContextCustom.cpp: (WebCore::JSWorkerContext::self):
  • bindings/js/ScriptCallStack.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSValue.h

    r39670 r39769  
    2929#include "CallData.h"
    3030#include "ConstructData.h"
    31 #include <wtf/Noncopyable.h>
    3231
    3332namespace JSC {
     
    4645    enum PreferredPrimitiveType { NoPreference, PreferNumber, PreferString };
    4746
    48     class JSValue : Noncopyable {
    49     protected:
    50         JSValue() { }
    51         virtual ~JSValue() { }
    52 
     47    class JSImmediate;
     48    class JSValueEncodedAsPointer;
     49
     50    class JSValuePtr {
     51        friend class JSImmediate;
     52
     53        static JSValuePtr makeImmediate(intptr_t value)
     54        {
     55            return JSValuePtr(reinterpret_cast<JSCell*>(value));
     56        }
     57
     58        intptr_t immediateValue()
     59        {
     60            return reinterpret_cast<intptr_t>(m_ptr);
     61        }
     62       
    5363    public:
     64        JSValuePtr()
     65            : m_ptr(0)
     66        {
     67        }
     68
     69        JSValuePtr(JSCell* ptr)
     70            : m_ptr(ptr)
     71        {
     72        }
     73
     74        JSValuePtr(const JSCell* ptr)
     75            : m_ptr(const_cast<JSCell*>(ptr))
     76        {
     77        }
     78
     79        JSValuePtr* operator->() const
     80        {
     81            return const_cast<JSValuePtr*>(this);
     82        }
     83
     84        operator bool() const
     85        {
     86            return m_ptr;
     87        }
     88
     89        bool operator==(const JSValuePtr other) const
     90        {
     91            return m_ptr == other.m_ptr;
     92        }
     93
     94        bool operator!=(const JSValuePtr other) const
     95        {
     96            return m_ptr != other.m_ptr;
     97        }
     98
     99        static JSValueEncodedAsPointer* encode(JSValuePtr value)
     100        {
     101            return reinterpret_cast<JSValueEncodedAsPointer*>(value.m_ptr);
     102        }
     103
     104        static JSValuePtr decode(JSValueEncodedAsPointer* ptr)
     105        {
     106            return JSValuePtr(reinterpret_cast<JSCell*>(ptr));
     107        }
     108
    54109        // Querying the type.
    55110        bool isUndefined() const;
     
    90145        double toNumber(ExecState*) const;
    91146        JSValuePtr toJSNumber(ExecState*) const; // Fast path for when you expect that the value is an immediate number.
    92 
    93147        UString toString(ExecState*) const;
    94148        JSObject* toObject(ExecState*) const;
     
    103157
    104158        // Floating point conversions.
    105         float toFloat(ExecState*) const;
     159        float toFloat(ExecState* exec) const { return static_cast<float>(toNumber(exec)); }
    106160
    107161        // Garbage collection.
     
    116170        void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&);
    117171        void put(ExecState*, unsigned propertyName, JSValuePtr);
    118         bool deleteProperty(ExecState*, const Identifier& propertyName);
    119         bool deleteProperty(ExecState*, unsigned propertyName);
    120172
    121173        bool needsThisConversion() const;
     
    126178        JSValuePtr getJSNumber(); // 0 if this is not a JSNumber or number object
    127179
    128         JSValuePtr asValue() const;
    129 
    130180        JSCell* asCell() const;
    131181
    132182    private:
    133         bool getPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    134         bool getPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
     183        inline const JSValuePtr asValue() const { return *this; }
     184
    135185        int32_t toInt32SlowCase(ExecState*, bool& ok) const;
    136186        uint32_t toUInt32SlowCase(ExecState*, bool& ok) const;
     187
     188        JSCell* m_ptr;
    137189    };
    138 
    139     class JSImmediate;
    140     class JSValueEncodedAsPointer;
    141 
    142     class JSValuePtr {
    143         friend class JSImmediate;
    144 
    145         static JSValuePtr makeImmediate(intptr_t value)
    146         {
    147             return JSValuePtr(reinterpret_cast<JSValue*>(value));
    148         }
    149 
    150         intptr_t immediateValue()
    151         {
    152             return reinterpret_cast<intptr_t>(m_ptr);
    153         }
    154        
    155     public:
    156         JSValuePtr()
    157             : m_ptr(0)
    158         {
    159         }
    160 
    161         JSValuePtr(JSValue* ptr)
    162             : m_ptr(ptr)
    163         {
    164         }
    165 
    166         JSValuePtr(const JSValue* ptr)
    167             : m_ptr(const_cast<JSValue*>(ptr))
    168         {
    169         }
    170 
    171         JSValue* operator->() const
    172         {
    173             return m_ptr;
    174         }
    175 
    176         operator bool() const
    177         {
    178             return m_ptr;
    179         }
    180 
    181         bool operator==(const JSValuePtr other) const
    182         {
    183             return m_ptr == other.m_ptr;
    184         }
    185 
    186         bool operator!=(const JSValuePtr other) const
    187         {
    188             return m_ptr != other.m_ptr;
    189         }
    190 
    191         static JSValueEncodedAsPointer* encode(JSValuePtr value)
    192         {
    193             return reinterpret_cast<JSValueEncodedAsPointer*>(value.m_ptr);
    194         }
    195 
    196         static JSValuePtr decode(JSValueEncodedAsPointer* ptr)
    197         {
    198             return JSValuePtr(reinterpret_cast<JSValue*>(ptr));
    199         }
    200 
    201     private:
    202         JSValue* m_ptr;
    203     };
    204 
    205     inline JSValuePtr JSValue::asValue() const
    206     {
    207         return JSValuePtr(this);
    208     }
    209190
    210191    inline JSValuePtr noValue()
     
    213194    }
    214195
    215     inline bool operator==(const JSValuePtr a, const JSValue* b) { return a == JSValuePtr(b); }
    216     inline bool operator==(const JSValue* a, const JSValuePtr b) { return JSValuePtr(a) == b; }
    217 
    218     inline bool operator!=(const JSValuePtr a, const JSValue* b) { return a != JSValuePtr(b); }
    219     inline bool operator!=(const JSValue* a, const JSValuePtr b) { return JSValuePtr(a) != b; }
     196    inline bool operator==(const JSValuePtr a, const JSCell* b) { return a == JSValuePtr(b); }
     197    inline bool operator==(const JSCell* a, const JSValuePtr b) { return JSValuePtr(a) == b; }
     198
     199    inline bool operator!=(const JSValuePtr a, const JSCell* b) { return a != JSValuePtr(b); }
     200    inline bool operator!=(const JSCell* a, const JSValuePtr b) { return JSValuePtr(a) != b; }
    220201
    221202} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.