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


Ignore:
Timestamp:
Aug 15, 2005, 5:47:46 PM (20 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Geoff.

  • bindings/NP_jsobject.cpp: (_NPN_SetException):
  • bindings/jni/jni_instance.cpp: (JavaInstance::invokeMethod):
  • bindings/jni/jni_runtime.cpp: (JavaField::dispatchValueFromInstance): (JavaField::dispatchSetValueToInstance):
  • bindings/objc/WebScriptObject.mm: (-[WebScriptObject _initializeWithObjectImp:originExecutionContext:executionContext:]): (-[WebScriptObject _initWithObjectImp:originExecutionContext:executionContext:]): (+[WebScriptObject throwException:]): (-[WebScriptObject setException:]): (+[WebScriptObject _convertValueToObjcValue:originExecutionContext:executionContext:]):
  • bindings/objc/objc_class.h: (KJS::Bindings::ObjcClass::~ObjcClass): (KJS::Bindings::ObjcClass::ObjcClass): (KJS::Bindings::ObjcClass::operator=): (KJS::Bindings::ObjcClass::constructorAt): (KJS::Bindings::ObjcClass::numConstructors):
  • bindings/objc/objc_header.h:
  • bindings/objc/objc_runtime.h: (KJS::Bindings::ObjcField::~ObjcField): (KJS::Bindings::ObjcField::ObjcField): (KJS::Bindings::ObjcField::operator=): (KJS::Bindings::ObjcMethod::ObjcMethod): (KJS::Bindings::ObjcMethod::~ObjcMethod): (KJS::Bindings::ObjcMethod::operator=):
  • bindings/objc/objc_runtime.mm: (ObjcField::valueFromInstance): (ObjcField::setValueToInstance): (ObjcArray::setValueAt): (ObjcArray::valueAt):
  • bindings/objc/objc_utility.h:
  • bindings/objc/objc_utility.mm: (KJS::Bindings::JSMethodNameToObjCMethodName): (KJS::Bindings::convertValueToObjcValue): (KJS::Bindings::convertNSStringToString): (KJS::Bindings::convertObjcValueToValue): (KJS::Bindings::objcValueTypeForType): (KJS::Bindings::createObjcInstanceForValue): (KJS::Bindings::throwError):
  • bindings/runtime.h: (KJS::Bindings::Parameter::~Parameter): (KJS::Bindings::Method::~Method): (KJS::Bindings::Instance::Instance): (KJS::Bindings::Instance::begin): (KJS::Bindings::Instance::end): (KJS::Bindings::Instance::getValueOfUndefinedField): (KJS::Bindings::Instance::supportsSetValueOfUndefinedField): (KJS::Bindings::Instance::setValueOfUndefinedField): (KJS::Bindings::Instance::valueOf):
  • bindings/runtime_array.cpp: (RuntimeArrayImp::put):
  • bindings/runtime_object.h: (KJS::RuntimeObjectImp::setInternalInstance): (KJS::RuntimeObjectImp::getInternalInstance):
  • kjs/array_object.cpp: (getProperty): (ArrayProtoFuncImp::callAsFunction): (ArrayObjectImp::construct):
  • kjs/bool_object.cpp: (BooleanProtoFuncImp::callAsFunction):
  • kjs/date_object.cpp: (KJS::DateProtoFuncImp::callAsFunction):
  • kjs/function.cpp: (KJS::decode): (KJS::GlobalFuncImp::callAsFunction):
  • kjs/function_object.cpp: (FunctionProtoFuncImp::callAsFunction): (FunctionObjectImp::construct):
  • kjs/internal.cpp: (KJS::UndefinedImp::toObject): (KJS::NullImp::toObject): (KJS::InterpreterImp::evaluate): (KJS::InternalFunctionImp::hasInstance):
  • kjs/nodes.cpp: (Node::throwError): (substitute): (Node::setExceptionDetailsIfNeeded): (undefinedVariableError): (ProgramNode::ProgramNode):
  • kjs/number_object.cpp: (NumberProtoFuncImp::callAsFunction):
  • kjs/object.cpp: (KJS::ObjectImp::call): (KJS::ObjectImp::defaultValue): (KJS::Error::create): (KJS::throwError):
  • kjs/object.h: (KJS::ObjectImp::clearProperties): (KJS::ObjectImp::getPropertySlot): (KJS::ObjectImp::getOwnPropertySlot):
  • kjs/object_object.cpp: (ObjectProtoFuncImp::callAsFunction):
  • kjs/reference.cpp: (KJS::Reference::getBase): (KJS::Reference::getValue): (KJS::Reference::putValue): (KJS::Reference::deleteValue):
  • kjs/regexp_object.cpp: (RegExpProtoFuncImp::callAsFunction): (RegExpObjectImp::construct):
  • kjs/string_object.cpp: (StringProtoFuncImp::callAsFunction):

WebCore:

Reviewed by Geoff.

  • khtml/css/cssstyleselector.cpp: (khtml::CSSStyleSelector::CSSStyleSelector): (khtml::parseUASheet): (khtml::CSSStyleSelector::initElementAndPseudoState): (khtml::checkPseudoState): (khtml::CSSStyleSelector::locateCousinList): (khtml::CSSStyleSelector::locateSharedStyle): (khtml::CSSStyleSelector::adjustRenderStyle): (khtml::CSSStyleSelector::checkOneSelector): (khtml::CSSRuleSet::addToRuleSet): (khtml::colorForCSSValue): (khtml::CSSStyleSelector::applyProperty): (khtml::CSSStyleSelector::mapBackgroundAttachment): (khtml::CSSStyleSelector::mapBackgroundImage): (khtml::CSSStyleSelector::mapBackgroundRepeat): (khtml::CSSStyleSelector::mapBackgroundXPosition): (khtml::CSSStyleSelector::mapBackgroundYPosition): (khtml::CSSStyleSelector::getComputedSizeFromSpecifiedSize):
  • khtml/ecma/domparser.cpp: (KJS::DOMParserProtoFunc::callAsFunction):
  • khtml/ecma/kjs_binding.cpp: (KJS::ScriptInterpreter::putDOMObject): (KJS::ScriptInterpreter::putDOMNodeForDocument): (KJS::setDOMException):
  • khtml/ecma/kjs_css.cpp: (KJS::DOMCSSStyleDeclarationProtoFunc::callAsFunction): (KJS::DOMStyleSheetListFunc::callAsFunction): (KJS::KJS::DOMMediaListProtoFunc::callAsFunction): (KJS::DOMCSSStyleSheetProtoFunc::callAsFunction): (KJS::DOMCSSRuleListFunc::callAsFunction): (KJS::DOMCSSRuleFunc::callAsFunction): (KJS::DOMCSSPrimitiveValueProtoFunc::callAsFunction): (KJS::DOMCSSValueListFunc::callAsFunction):
  • khtml/ecma/kjs_dom.cpp: (KJS::DOMNodeProtoFunc::callAsFunction): (KJS::DOMNodeListFunc::callAsFunction): (KJS::DOMDocumentProtoFunc::callAsFunction): (KJS::DOMElementProtoFunc::callAsFunction): (KJS::DOMDOMImplementationProtoFunc::callAsFunction): (KJS::DOMNamedNodeMapProtoFunc::callAsFunction): (KJS::DOMCharacterDataProtoFunc::callAsFunction): (KJS::DOMTextProtoFunc::callAsFunction):
  • khtml/ecma/kjs_events.cpp: (KJS::DOMEventProtoFunc::callAsFunction): (KJS::DOMUIEventProtoFunc::callAsFunction): (KJS::DOMMouseEventProtoFunc::callAsFunction): (KJS::DOMKeyboardEventProtoFunc::callAsFunction): (KJS::DOMMutationEventProtoFunc::callAsFunction): (KJS::DOMWheelEventProtoFunc::callAsFunction): (KJS::ClipboardProtoFunc::callAsFunction):
  • khtml/ecma/kjs_html.cpp: (KJS::KJS::HTMLDocFunction::callAsFunction): (KJS::KJS::HTMLElementFunction::callAsFunction): (KJS::KJS::HTMLCollectionProtoFunc::callAsFunction): (KJS::KJS::Context2DFunction::callAsFunction): (KJS::Context2D::putValueProperty): (KJS::GradientFunction::callAsFunction):
  • khtml/ecma/kjs_navigator.cpp: (KJS::NavigatorFunc::callAsFunction):
  • khtml/ecma/kjs_range.cpp: (KJS::DOMRangeProtoFunc::callAsFunction):
  • khtml/ecma/kjs_traversal.cpp: (KJS::DOMNodeIteratorProtoFunc::callAsFunction): (KJS::DOMNodeFilterProtoFunc::callAsFunction): (KJS::DOMTreeWalkerProtoFunc::callAsFunction):
  • khtml/ecma/kjs_views.cpp: (KJS::DOMAbstractViewFunc::callAsFunction):
  • khtml/ecma/kjs_window.cpp: (KJS::Window::interpreter): (KJS::Window::retrieveWindow): (KJS::Window::retrieveActive): (KJS::Window::isSafeScript): (KJS::Window::clear): (KJS::WindowFunc::callAsFunction): (KJS::ScheduledAction::execute): (KJS::WindowQObject::pauseTimeouts): (KJS::LocationFunc::callAsFunction): (KJS::Selection::toString): (KJS::SelectionFunc::callAsFunction): (KJS::HistoryFunc::callAsFunction):
  • khtml/ecma/xmlhttprequest.cpp: (KJS::XMLHttpRequestProtoFunc::callAsFunction):
  • khtml/ecma/xmlserializer.cpp: (KJS::XMLSerializerProtoFunc::callAsFunction):
File:
1 edited

Legend:

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

    r10180 r10207  
    9191
    9292    /**
    93      * Creates a new ObjectImp with a prototype of Null()
     93     * Creates a new ObjectImp with a prototype of jsNull()
    9494     * (that is, the ECMAScript "null" value, not a null object pointer).
    95      *
    9695     */
    9796    ObjectImp();
    9897
    9998    virtual void mark();
    100 
    101     Type type() const;
     99    virtual Type type() const;
    102100
    103101    /**
     
    178176     * @return The object's prototype
    179177     */
    180     /**
    181      * Implementation of the [[Prototype]] internal property (implemented by
    182      * all Objects)
    183      */
    184178    ValueImp *prototype() const;
    185179    void setPrototype(ValueImp *proto);
     
    215209     * @return The specified property, or Undefined
    216210     */
    217     /**
    218      * Implementation of the [[Get]] internal property (implemented by all
    219      * Objects)
    220      */
    221     // [[Get]] - must be implemented by all Objects
    222211    ValueImp *get(ExecState *exec, const Identifier &propertyName) const;
    223212    ValueImp *get(ExecState *exec, unsigned propertyName) const;
    224213
    225     bool getProperty(ExecState *exec, const Identifier& propertyName, ValueImp*& result) const;
    226     bool getProperty(ExecState *exec, unsigned propertyName, ValueImp*& result) const;
    227 
    228214    bool getPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    229215    bool getPropertySlot(ExecState *, unsigned, PropertySlot&);
     
    241227     * @param propertyValue The value to set
    242228     */
    243     /**
    244      * Implementation of the [[Put]] internal property (implemented by all
    245      * Objects)
    246      */
    247     virtual void put(ExecState *exec, const Identifier &propertyName,
    248                      ValueImp *value, int attr = None);
    249     virtual void put(ExecState *exec, unsigned propertyName,
    250                      ValueImp *value, int attr = None);
     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);
    251231
    252232    /**
     
    276256     * @return true if the object has the property, otherwise false
    277257     */
    278     /**
    279      * Implementation of the [[HasProperty]] internal property (implemented by
    280      * all Objects)
    281      */
    282     bool hasProperty(ExecState *exec,
    283                              const Identifier &propertyName) const;
     258    bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
    284259    bool hasProperty(ExecState *exec, unsigned propertyName) const;
    285 
    286     /**
    287      * Checks to see whether the object has a property with the specified name.
    288      *
    289      * See ECMA 15.2.4.5
    290      *
    291      * @param exec The current execution state
    292      * @param propertyName The name of the property to check for
    293      * @return true if the object has the property, otherwise false
    294      */
    295     virtual bool hasOwnProperty(ExecState *exec, const Identifier &propertyName) const;
    296     virtual bool hasOwnProperty(ExecState *exec, unsigned propertyName) const;
    297260
    298261    /**
     
    307270     * allowed.
    308271     */
    309     /**
    310      * Implementation of the [[Delete]] internal property (implemented by all
    311      * Objects)
    312      */
    313     virtual bool deleteProperty(ExecState *exec,
    314                                 const Identifier &propertyName);
     272    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    315273    virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
    316 
    317     /**
    318      * Remove all properties from this object.
    319      * This doesn't take DontDelete into account, and isn't in the ECMA spec.
    320      * It's simply a quick way to remove everything before destroying.
    321      */
    322     void deleteAllProperties(ExecState *);
    323274
    324275    /**
     
    408359     * @return The return value from the function
    409360     */
    410     /**
    411      * Implementation of the [[Call]] internal property
    412      */
    413361    ValueImp *call(ExecState *exec, ObjectImp *thisObj, const List &args);
    414362    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
     
    432380     * @return true if value delegates behavior to this object, otherwise
    433381     * false
    434      */
    435     /**
    436      * Implementation of the [[HasInstance]] internal property
    437382     */
    438383    virtual bool hasInstance(ExecState *exec, ValueImp *value);
     
    463408     * @param exec The current execution state
    464409     * @return The function's scope
    465      */
    466     /**
    467      * Implementation of the [[Scope]] internal property
    468410     */
    469411    const ScopeChain &scope() const { return _scope; }
     
    505447     * @param v The new internal value
    506448     */
    507 
    508449    void setInternalValue(ValueImp *v);
    509450
     
    514455    ObjectImp *toObject(ExecState *exec) const;
    515456
    516     // This get method only looks at the property map.
    517     // A bit like hasProperty(recursive=false), this doesn't go to the prototype.
     457    // This get function only looks at the property map.
    518458    // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want
    519459    // to look up in the prototype, it might already exist there)
     
    525465    void putDirect(const Identifier &propertyName, int value, int attr = 0);
    526466   
     467    /**
     468     * Remove all properties from this object.
     469     * This doesn't take DontDelete into account, and isn't in the ECMA spec.
     470     * It's simply a quick way to remove everything stored in the property map.
     471     */
     472    void clearProperties() { _prop.clear(); }
     473
    527474    void saveProperties(SavedProperties &p) const { _prop.save(p); }
    528475    void restoreProperties(const SavedProperties &p) { _prop.restore(p); }
     
    537484    ScopeChain _scope;
    538485  };
    539 
    540   // it may seem crazy to inline a function this large but it makes a big difference
    541   // since this is function very hot in variable lookup
    542   inline bool ObjectImp::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
    543   {
    544     ObjectImp *imp = this;
    545 
    546     while (true) {
    547       if (imp->getOwnPropertySlot(exec, propertyName, slot))
    548         return true;
    549      
    550       ValueImp *proto = imp->_proto;
    551       if (!proto->isObject())
    552         break;
    553      
    554       imp = static_cast<ObjectImp *>(proto);
    555     }
    556    
    557     return false;
    558   }
    559 
    560   // it may seem crazy to inline a function this large, especially a virtual function,
    561   // but it makes a big difference to property lookup if subclasses can inline their
    562   // superclass call to this
    563   inline bool ObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
    564   {
    565       ValueImp **impLocation = getDirectLocation(propertyName);
    566       if (impLocation) {
    567         slot.setValueSlot(this, impLocation);
    568         return true;
    569       }
    570 
    571       // non-standard netscape extension
    572       if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
    573         slot.setValueSlot(this, &_proto);
    574         return true;
    575       }
    576 
    577       return false;
    578   }
    579486
    580487  /**
     
    590497                   URIError       = 6};
    591498
    592   ObjectImp *error(ExecState *exec, ErrorType type = GeneralError,
    593     const char *message = 0, int lineno = -1, int sourceId = -1, const UString *sourceURL = 0);
    594 
    595499  /**
    596500   * @short Factory methods for error objects.
     
    604508     * @param errtype Type of error.
    605509     * @param message Optional error message.
    606      * @param lineno Optional line number.
    607      * @param lineno Optional source id.
    608      */
    609     static ObjectImp *create(ExecState *exec, ErrorType errtype = GeneralError,
    610                              const char *message = 0, int lineno = -1,
    611                              int sourceId = -1, const UString *sourceURL = 0);
     510     * @param lineNumber Optional line number.
     511     * @param sourceId Optional source id.
     512     * @param sourceURL Optional source URL.
     513     */
     514    static ObjectImp *create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL);
     515    static ObjectImp *create(ExecState *, ErrorType, const char *message);
    612516
    613517    /**
     
    617521  };
    618522
     523ObjectImp *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL);
     524ObjectImp *throwError(ExecState *, ErrorType, const UString &message);
     525ObjectImp *throwError(ExecState *, ErrorType, const char *message);
     526ObjectImp *throwError(ExecState *, ErrorType);
     527 
    619528inline bool AllocatedValueImp::isObject(const ClassInfo *info) const
    620529{
     
    662571}
    663572
     573// It may seem crazy to inline a function this large but it makes a big difference
     574// since this is function very hot in variable lookup
     575inline bool ObjectImp::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
     576{
     577    ObjectImp *object = this;
     578    while (true) {
     579        if (object->getOwnPropertySlot(exec, propertyName, slot))
     580            return true;
     581
     582        ValueImp *proto = object->_proto;
     583        if (!proto->isObject())
     584            return false;
     585
     586        object = static_cast<ObjectImp *>(proto);
     587    }
     588}
     589
     590// It may seem crazy to inline a function this large, especially a virtual function,
     591// but it makes a big difference to property lookup that derived classes can inline their
     592// base class call to this.
     593inline bool ObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
     594{
     595    if (ValueImp **location = getDirectLocation(propertyName)) {
     596        slot.setValueSlot(this, location);
     597        return true;
     598    }
     599
     600    // non-standard Netscape extension
     601    if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
     602        slot.setValueSlot(this, &_proto);
     603        return true;
     604    }
     605
     606    return false;
     607}
     608
    664609} // namespace
    665610
Note: See TracChangeset for help on using the changeset viewer.