Changeset 11527 in webkit for trunk/JavaScriptCore/kjs/object.h


Ignore:
Timestamp:
Dec 10, 2005, 6:06:17 PM (19 years ago)
Author:
darin
Message:

JavaScriptCore:

Rubber stamped by Maciej.

  • did long-promised KJS renaming:

ValueImp -> JSValue
ObjectImp -> JSObject
AllocatedValueImp -> JSCell

A renaming to get a class out of the way

KJS::Bindings::JSObject -> JavaJSObject

and some other "imp-reduction" renaming

*InstanceImp -> *Instance
*ProtoFuncImp -> *ProtoFunc
*PrototypeImp -> *Prototype
ArgumentsImp -> Arguments
RuntimeArrayImp -> RuntimeArray
RuntimeMethodImp -> RuntimeMethod

  • most files and functions

WebCore:

Rubber stamped by Maciej.

  • updated for KJS class renaming
  • many files and functions
File:
1 edited

Legend:

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

    r11447 r11527  
    8181  };
    8282 
    83   class ObjectImp : public AllocatedValueImp {
     83  class JSObject : public JSCell {
    8484  public:
    8585    /**
    86      * Creates a new ObjectImp with the specified prototype
     86     * Creates a new JSObject with the specified prototype
    8787     *
    8888     * @param proto The prototype
    8989     */
    90     ObjectImp(ObjectImp *proto);
    91 
    92     /**
    93      * Creates a new ObjectImp with a prototype of jsNull()
     90    JSObject(JSObject *proto);
     91
     92    /**
     93     * Creates a new JSObject with a prototype of jsNull()
    9494     * (that is, the ECMAScript "null" value, not a null object pointer).
    9595     */
    96     ObjectImp();
     96    JSObject();
    9797
    9898    virtual void mark();
     
    114114     *
    115115     * \code
    116      *   class BarImp : public ObjectImp {
     116     *   class BarImp : public JSObject {
    117117     *     virtual const ClassInfo *classInfo() const { return &info; }
    118118     *     static const ClassInfo info;
     
    120120     *   };
    121121     *
    122      *   class FooImp : public ObjectImp {
     122     *   class FooImp : public JSObject {
    123123     *     virtual const ClassInfo *classInfo() const { return &info; }
    124124     *     static const ClassInfo info;
     
    144144     * it will return false).
    145145     *
    146      * For example, for two ObjectImp pointers obj1 and obj2, you can check
     146     * For example, for two JSObject pointers obj1 and obj2, you can check
    147147     * if obj1's class inherits from obj2's class using the following:
    148148     *
     
    176176     * @return The object's prototype
    177177     */
    178     ValueImp *prototype() const;
    179     void setPrototype(ValueImp *proto);
     178    JSValue *prototype() const;
     179    void setPrototype(JSValue *proto);
    180180
    181181    /**
     
    209209     * @return The specified property, or Undefined
    210210     */
    211     ValueImp *get(ExecState *exec, const Identifier &propertyName) const;
    212     ValueImp *get(ExecState *exec, unsigned propertyName) const;
     211    JSValue *get(ExecState *exec, const Identifier &propertyName) const;
     212    JSValue *get(ExecState *exec, unsigned propertyName) const;
    213213
    214214    bool getPropertySlot(ExecState *, const Identifier&, PropertySlot&);
     
    227227     * @param propertyValue The value to set
    228228     */
    229     virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
    230     virtual void put(ExecState *exec, unsigned propertyName, ValueImp *value, int attr = None);
     229    virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
     230    virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None);
    231231
    232232    /**
     
    300300     * all Objects)
    301301     */
    302     virtual ValueImp *defaultValue(ExecState *exec, Type hint) const;
     302    virtual JSValue *defaultValue(ExecState *exec, Type hint) const;
    303303
    304304    /**
     
    340340     * Implementation of the [[Construct]] internal property
    341341     */
    342     virtual ObjectImp *construct(ExecState *exec, const List &args);
    343     virtual ObjectImp *construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
     342    virtual JSObject *construct(ExecState *exec, const List &args);
     343    virtual JSObject *construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
    344344
    345345    /**
     
    370370     * @return The return value from the function
    371371     */
    372     ValueImp *call(ExecState *exec, ObjectImp *thisObj, const List &args);
    373     virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
     372    JSValue *call(ExecState *exec, JSObject *thisObj, const List &args);
     373    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
    374374
    375375    /**
     
    392392     * false
    393393     */
    394     virtual bool hasInstance(ExecState *exec, ValueImp *value);
     394    virtual bool hasInstance(ExecState *exec, JSValue *value);
    395395
    396396    /**
     
    449449     * @return The internal value of the object
    450450     */
    451     ValueImp *internalValue() const;
     451    JSValue *internalValue() const;
    452452
    453453    /**
     
    458458     * @param v The new internal value
    459459     */
    460     void setInternalValue(ValueImp *v);
    461 
    462     ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
     460    void setInternalValue(JSValue *v);
     461
     462    JSValue *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
    463463    bool toBoolean(ExecState *exec) const;
    464464    double toNumber(ExecState *exec) const;
    465465    UString toString(ExecState *exec) const;
    466     ObjectImp *toObject(ExecState *exec) const;
     466    JSObject *toObject(ExecState *exec) const;
    467467
    468468    bool getPropertyAttributes(const Identifier& propertyName, int& attributes) const;
     
    471471    // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want
    472472    // to look up in the prototype, it might already exist there)
    473     ValueImp *getDirect(const Identifier& propertyName) const
     473    JSValue *getDirect(const Identifier& propertyName) const
    474474        { return _prop.get(propertyName); }
    475     ValueImp **getDirectLocation(const Identifier& propertyName)
     475    JSValue **getDirectLocation(const Identifier& propertyName)
    476476        { return _prop.getLocation(propertyName); }
    477     void putDirect(const Identifier &propertyName, ValueImp *value, int attr = 0);
     477    void putDirect(const Identifier &propertyName, JSValue *value, int attr = 0);
    478478    void putDirect(const Identifier &propertyName, int value, int attr = 0);
    479479   
     
    493493  private:
    494494    const HashEntry* findPropertyHashEntry( const Identifier& propertyName ) const;
    495     ValueImp *_proto;
    496     ValueImp *_internalValue;
     495    JSValue *_proto;
     496    JSValue *_internalValue;
    497497    ScopeChain _scope;
    498498  };
     
    525525     * @param sourceURL Optional source URL.
    526526     */
    527     static ObjectImp *create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL);
    528     static ObjectImp *create(ExecState *, ErrorType, const char *message);
     527    static JSObject *create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL);
     528    static JSObject *create(ExecState *, ErrorType, const char *message);
    529529
    530530    /**
     
    534534  };
    535535
    536 ObjectImp *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL);
    537 ObjectImp *throwError(ExecState *, ErrorType, const UString &message);
    538 ObjectImp *throwError(ExecState *, ErrorType, const char *message);
    539 ObjectImp *throwError(ExecState *, ErrorType);
     536JSObject *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL);
     537JSObject *throwError(ExecState *, ErrorType, const UString &message);
     538JSObject *throwError(ExecState *, ErrorType, const char *message);
     539JSObject *throwError(ExecState *, ErrorType);
    540540 
    541 inline bool AllocatedValueImp::isObject(const ClassInfo *info) const
    542 {
    543     return isObject() && static_cast<const ObjectImp *>(this)->inherits(info);
    544 }
    545 
    546 inline ObjectImp::ObjectImp(ObjectImp *proto)
     541inline bool JSCell::isObject(const ClassInfo *info) const
     542{
     543    return isObject() && static_cast<const JSObject *>(this)->inherits(info);
     544}
     545
     546inline JSObject::JSObject(JSObject *proto)
    547547    : _proto(proto), _internalValue(0)
    548548{
     
    550550}
    551551
    552 inline ObjectImp::ObjectImp()
     552inline JSObject::JSObject()
    553553    : _proto(jsNull()), _internalValue(0)
    554554{
    555555}
    556556
    557 inline ValueImp *ObjectImp::internalValue() const
     557inline JSValue *JSObject::internalValue() const
    558558{
    559559    return _internalValue;
    560560}
    561561
    562 inline void ObjectImp::setInternalValue(ValueImp *v)
     562inline void JSObject::setInternalValue(JSValue *v)
    563563{
    564564    _internalValue = v;
    565565}
    566566
    567 inline ValueImp *ObjectImp::prototype() const
     567inline JSValue *JSObject::prototype() const
    568568{
    569569    return _proto;
    570570}
    571571
    572 inline void ObjectImp::setPrototype(ValueImp *proto)
     572inline void JSObject::setPrototype(JSValue *proto)
    573573{
    574574    assert(proto);
     
    576576}
    577577
    578 inline bool ObjectImp::inherits(const ClassInfo *info) const
     578inline bool JSObject::inherits(const ClassInfo *info) const
    579579{
    580580    for (const ClassInfo *ci = classInfo(); ci; ci = ci->parentClass)
     
    586586// It may seem crazy to inline a function this large but it makes a big difference
    587587// since this is function very hot in variable lookup
    588 inline bool ObjectImp::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
    589 {
    590     ObjectImp *object = this;
     588inline bool JSObject::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
     589{
     590    JSObject *object = this;
    591591    while (true) {
    592592        if (object->getOwnPropertySlot(exec, propertyName, slot))
    593593            return true;
    594594
    595         ValueImp *proto = object->_proto;
     595        JSValue *proto = object->_proto;
    596596        if (!proto->isObject())
    597597            return false;
    598598
    599         object = static_cast<ObjectImp *>(proto);
     599        object = static_cast<JSObject *>(proto);
    600600    }
    601601}
     
    604604// but it makes a big difference to property lookup that derived classes can inline their
    605605// base class call to this.
    606 inline bool ObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
    607 {
    608     if (ValueImp **location = getDirectLocation(propertyName)) {
     606inline bool JSObject::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
     607{
     608    if (JSValue **location = getDirectLocation(propertyName)) {
    609609        slot.setValueSlot(this, location);
    610610        return true;
     
    620620}
    621621
    622 // FIXME: Put this function in a separate file named something like scope_chain_mark.h -- can't put it in scope_chain.h since it depends on ObjectImp.
     622// FIXME: Put this function in a separate file named something like scope_chain_mark.h -- can't put it in scope_chain.h since it depends on JSObject.
    623623
    624624inline void ScopeChain::mark()
    625625{
    626626    for (ScopeChainNode *n = _node; n; n = n->next) {
    627         ObjectImp *o = n->object;
     627        JSObject *o = n->object;
    628628        if (!o->marked())
    629629            o->mark();
Note: See TracChangeset for help on using the changeset viewer.