Changeset 37712 in webkit for trunk/JavaScriptCore/kjs/JSValue.h


Ignore:
Timestamp:
Oct 19, 2008, 10:58:02 PM (17 years ago)
Author:
Darin Adler
Message:

2008-10-19 Darin Adler <Darin Adler>

Reviewed by Cameron Zwarich.

Change JSValuePtr from a typedef into a class. This allows us to support
conversion from JSCell* to JSValuePtr even if JSCell isn't derived from
JSValue.

  • JavaScriptCore.exp: Updated symbols that involve JSValuePtr, since it's now a distinct type.
  • API/APICast.h: (toRef): Extract the JSValuePtr payload explicitly since we can't just cast any more.
  • VM/CTI.cpp: (JSC::CTI::asInteger): Ditto.
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::addConstant): Get at the payload directly. (JSC::CodeGenerator::emitLoad): Added an overload of JSCell* because otherwise classes derived from JSValue end up calling the bool overload instead of JSValuePtr.
  • VM/CodeGenerator.h: Ditto. Also update traits to use JSValue* and the payload functions.
  • VM/Register.h: Added a JSCell* overload and use of payload functions.
  • kjs/JSCell.h: (JSC::asCell): Use payload function. (JSC::JSValue::asCell): Use JSValue* instead of JSValuePtr. (JSC::JSValuePtr::JSValuePtr): Added. Constructor that takes JSCell* and creates a JSValuePtr.
  • kjs/JSImmediate.h: Added JSValuePtr class. Also updated makeValue and makeInt to work with JSValue* and the payload function.
  • kjs/JSValue.h: Added == and != operators for JSValuePtr. Put them here because eventually all the JSValue functions should go here except what's needed by JSImmediate. Also fix asValue to use JSValue* instead of JSValuePtr.
  • kjs/PropertySlot.h: Change constructor to take JSValuePtr.
  • kjs/protect.h: Update gcProtect functions to work with JSCell* as well as JSValuePtr. Also updated the ProtectedPtr<JSValuePtr> specialization to work more directly. Also changed all the call sites to use gcProtectNullTolerant.
File:
1 edited

Legend:

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

    r37706 r37712  
    151151    };
    152152
     153    bool operator==(JSValuePtr, JSValuePtr);
     154    bool operator!=(JSValuePtr, JSValuePtr);
     155
    153156    // These are identical logic to the JSValue functions above, and faster than jsNumber(number)->toInt32().
    154157    int32_t toInt32(double);
     
    167170    inline JSValuePtr JSValue::asValue() const
    168171    {
    169         return const_cast<JSValuePtr>(this);
     172        return const_cast<JSValue*>(this);
    170173    }
    171174
     
    261264    }
    262265
     266    inline bool operator==(JSValuePtr a, JSValuePtr b)
     267    {
     268        return a.payload() == b.payload();
     269    }
     270
     271    inline bool operator!=(JSValuePtr a, JSValuePtr b)
     272    {
     273        return a.payload() != b.payload();
     274    }
     275
    263276} // namespace JSC
    264277
Note: See TracChangeset for help on using the changeset viewer.