Ignore:
Timestamp:
Jul 6, 2010, 6:55:34 AM (15 years ago)
Author:
[email protected]
Message:

2010-07-06 Jedrzej Nowacki <[email protected]>

Reviewed by Kenneth Rohde Christiansen.

Implementation of QScriptValue properties accessors.

The patch contains implementation of the QScriptValue::property() and
the QScriptValue::setProperty(). It is not full functionality, as these
method are too complex for one patch, but it is enough to cover about
95% of use cases.

Missing functionality:

  • Few of the PropertyFlags are ignored.
  • Only a public part of the ResolveFlags can be used (ResolveLocal, ResolvePrototype).

A lot of new test cases were added.

[Qt] QScriptValue should have API for accessing object properties
https://bugs.webkit.org/show_bug.cgi?id=40903

  • api/qscriptconverter_p.h: (QScriptConverter::toPropertyFlags):
  • api/qscriptstring_p.h: (QScriptStringPrivate::operator JSStringRef):
  • api/qscriptvalue.cpp: (QScriptValue::property): (QScriptValue::setProperty):
  • api/qscriptvalue.h: (QScriptValue::):
  • api/qscriptvalue_p.h: (QScriptValuePrivate::assignEngine): (QScriptValuePrivate::property): (QScriptValuePrivate::hasOwnProperty): (QScriptValuePrivate::setProperty): (QScriptValuePrivate::deleteProperty):
  • tests/qscriptvalue/tst_qscriptvalue.cpp: (tst_QScriptValue::getPropertySimple_data): (tst_QScriptValue::getPropertySimple): (tst_QScriptValue::setPropertySimple): (tst_QScriptValue::getPropertyResolveFlag): (tst_QScriptValue::getSetProperty): (tst_QScriptValue::setProperty_data): (tst_QScriptValue::setProperty):
  • tests/qscriptvalue/tst_qscriptvalue.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/qt/api/qscriptvalue.h

    r62007 r62547  
    2121#define qscriptvalue_h
    2222
     23#include "qscriptstring.h"
    2324#include <QtCore/qlist.h>
    2425#include <QtCore/qshareddata.h>
     
    3536public:
    3637    enum ResolveFlag {
    37         ResolveLocal     = 0x00,
    38         ResolvePrototype = 0x01
     38        ResolveLocal        = 0x00,
     39        ResolvePrototype    = 0x01,
     40        ResolveScope        = 0x02,
     41        ResolveFull         = ResolvePrototype | ResolveScope
    3942    };
     43    Q_DECLARE_FLAGS(ResolveFlags, ResolveFlag)
    4044
    41     Q_DECLARE_FLAGS(ResolveFlags, ResolveFlag)
     45    enum PropertyFlag {
     46        ReadOnly            = 0x00000001,
     47        Undeletable         = 0x00000002,
     48        SkipInEnumeration   = 0x00000004,
     49        PropertyGetter      = 0x00000008,
     50        PropertySetter      = 0x00000010,
     51        QObjectMember       = 0x00000020,
     52        KeepExistingFlags   = 0x00000800,
     53        UserRange           = 0xff000000 // Users may use these as they see fit.
     54    };
     55    Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag)
    4256
    4357    enum SpecialValue {
     
    7690
    7791    QScriptValue property(const QString& name, const ResolveFlags& mode = ResolvePrototype) const;
     92    QScriptValue property(const QScriptString& name, const ResolveFlags& mode = ResolvePrototype) const;
    7893    QScriptValue property(quint32 arrayIndex, const ResolveFlags& mode = ResolvePrototype) const;
     94
     95    void setProperty(const QString& name, const QScriptValue& value, const PropertyFlags& flags = KeepExistingFlags);
     96    void setProperty(quint32 arrayIndex, const QScriptValue& value, const PropertyFlags& flags = KeepExistingFlags);
     97    void setProperty(const QScriptString& name, const QScriptValue& value, const PropertyFlags& flags = KeepExistingFlags);
    7998
    8099    QScriptEngine* engine() const;
     
    103122    QScriptValue call(const QScriptValue& thisObject = QScriptValue(),
    104123                      const QScriptValueList& args = QScriptValueList());
    105 
    106124private:
    107125    QScriptValue(void*);
Note: See TracChangeset for help on using the changeset viewer.