| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtDeclarative module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL-ONLY$
|
|---|
| 10 | ** GNU Lesser General Public License Usage
|
|---|
| 11 | ** This file may be used under the terms of the GNU Lesser
|
|---|
| 12 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 13 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 14 | ** packaging of this file. Please review the following information to
|
|---|
| 15 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 16 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 17 | **
|
|---|
| 18 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 19 | ** Nokia at [email protected].
|
|---|
| 20 | ** $QT_END_LICENSE$
|
|---|
| 21 | **
|
|---|
| 22 | ****************************************************************************/
|
|---|
| 23 |
|
|---|
| 24 | #ifndef QSCRIPTDECLARATIVECLASS_P_H
|
|---|
| 25 | #define QSCRIPTDECLARATIVECLASS_P_H
|
|---|
| 26 |
|
|---|
| 27 | //
|
|---|
| 28 | // W A R N I N G
|
|---|
| 29 | // -------------
|
|---|
| 30 | //
|
|---|
| 31 | // This file is not part of the Qt API. It exists purely as an
|
|---|
| 32 | // implementation detail. This header file may change from version to
|
|---|
| 33 | // version without notice, or even be removed.
|
|---|
| 34 | //
|
|---|
| 35 | // We mean it.
|
|---|
| 36 | //
|
|---|
| 37 |
|
|---|
| 38 | #include <QtCore/qobjectdefs.h>
|
|---|
| 39 | #include <QtScript/qscriptvalue.h>
|
|---|
| 40 | #include <QtScript/qscriptclass.h>
|
|---|
| 41 |
|
|---|
| 42 | QT_BEGIN_NAMESPACE
|
|---|
| 43 |
|
|---|
| 44 | class QScriptDeclarativeClassPrivate;
|
|---|
| 45 | class PersistentIdentifierPrivate;
|
|---|
| 46 | class QScriptContext;
|
|---|
| 47 | class Q_SCRIPT_EXPORT QScriptDeclarativeClass
|
|---|
| 48 | {
|
|---|
| 49 | public:
|
|---|
| 50 | #define QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE
|
|---|
| 51 | class Q_SCRIPT_EXPORT Value
|
|---|
| 52 | {
|
|---|
| 53 | public:
|
|---|
| 54 | Value();
|
|---|
| 55 | Value(const Value &);
|
|---|
| 56 |
|
|---|
| 57 | Value(QScriptContext *, int);
|
|---|
| 58 | Value(QScriptContext *, uint);
|
|---|
| 59 | Value(QScriptContext *, bool);
|
|---|
| 60 | Value(QScriptContext *, double);
|
|---|
| 61 | Value(QScriptContext *, float);
|
|---|
| 62 | Value(QScriptContext *, const QString &);
|
|---|
| 63 | Value(QScriptContext *, const QScriptValue &);
|
|---|
| 64 | Value(QScriptEngine *, int);
|
|---|
| 65 | Value(QScriptEngine *, uint);
|
|---|
| 66 | Value(QScriptEngine *, bool);
|
|---|
| 67 | Value(QScriptEngine *, double);
|
|---|
| 68 | Value(QScriptEngine *, float);
|
|---|
| 69 | Value(QScriptEngine *, const QString &);
|
|---|
| 70 | Value(QScriptEngine *, const QScriptValue &);
|
|---|
| 71 | ~Value();
|
|---|
| 72 |
|
|---|
| 73 | QScriptValue toScriptValue(QScriptEngine *) const;
|
|---|
| 74 | private:
|
|---|
| 75 | char dummy[8];
|
|---|
| 76 | };
|
|---|
| 77 |
|
|---|
| 78 | typedef void* Identifier;
|
|---|
| 79 |
|
|---|
| 80 | struct Object { virtual ~Object() {} };
|
|---|
| 81 |
|
|---|
| 82 | static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *);
|
|---|
| 83 | static Value newObjectValue(QScriptEngine *, QScriptDeclarativeClass *, Object *);
|
|---|
| 84 | static QScriptDeclarativeClass *scriptClass(const QScriptValue &);
|
|---|
| 85 | static Object *object(const QScriptValue &);
|
|---|
| 86 |
|
|---|
| 87 | static QScriptValue function(const QScriptValue &, const Identifier &);
|
|---|
| 88 | static QScriptValue property(const QScriptValue &, const Identifier &);
|
|---|
| 89 | static Value functionValue(const QScriptValue &, const Identifier &);
|
|---|
| 90 | static Value propertyValue(const QScriptValue &, const Identifier &);
|
|---|
| 91 |
|
|---|
| 92 | static QScriptValue scopeChainValue(QScriptContext *, int index);
|
|---|
| 93 | static QScriptContext *pushCleanContext(QScriptEngine *);
|
|---|
| 94 |
|
|---|
| 95 | static QScriptValue newStaticScopeObject(
|
|---|
| 96 | QScriptEngine *, int propertyCount, const QString *names,
|
|---|
| 97 | const QScriptValue *values, const QScriptValue::PropertyFlags *flags);
|
|---|
| 98 | static QScriptValue newStaticScopeObject(QScriptEngine *);
|
|---|
| 99 |
|
|---|
| 100 | class Q_SCRIPT_EXPORT PersistentIdentifier
|
|---|
| 101 | {
|
|---|
| 102 | public:
|
|---|
| 103 | Identifier identifier;
|
|---|
| 104 |
|
|---|
| 105 | PersistentIdentifier();
|
|---|
| 106 | ~PersistentIdentifier();
|
|---|
| 107 | PersistentIdentifier(const PersistentIdentifier &other);
|
|---|
| 108 | PersistentIdentifier &operator=(const PersistentIdentifier &other);
|
|---|
| 109 |
|
|---|
| 110 | private:
|
|---|
| 111 | friend class QScriptDeclarativeClass;
|
|---|
| 112 | PersistentIdentifier(QScriptEnginePrivate *e) : identifier(0), engine(e), d(0) {}
|
|---|
| 113 | QScriptEnginePrivate *engine;
|
|---|
| 114 | void *d;
|
|---|
| 115 | };
|
|---|
| 116 |
|
|---|
| 117 | QScriptDeclarativeClass(QScriptEngine *engine);
|
|---|
| 118 | virtual ~QScriptDeclarativeClass();
|
|---|
| 119 |
|
|---|
| 120 | QScriptEngine *engine() const;
|
|---|
| 121 |
|
|---|
| 122 | bool supportsCall() const;
|
|---|
| 123 | void setSupportsCall(bool);
|
|---|
| 124 |
|
|---|
| 125 | PersistentIdentifier createPersistentIdentifier(const QString &);
|
|---|
| 126 | PersistentIdentifier createPersistentIdentifier(const Identifier &);
|
|---|
| 127 |
|
|---|
| 128 | QString toString(const Identifier &);
|
|---|
| 129 | quint32 toArrayIndex(const Identifier &, bool *ok);
|
|---|
| 130 |
|
|---|
| 131 | virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
|
|---|
| 132 | QScriptClass::QueryFlags flags);
|
|---|
| 133 |
|
|---|
| 134 | virtual Value property(Object *, const Identifier &);
|
|---|
| 135 | virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
|
|---|
| 136 | virtual QScriptValue::PropertyFlags propertyFlags(Object *, const Identifier &);
|
|---|
| 137 | virtual Value call(Object *, QScriptContext *);
|
|---|
| 138 | virtual bool compare(Object *, Object *);
|
|---|
| 139 |
|
|---|
| 140 | virtual QStringList propertyNames(Object *);
|
|---|
| 141 |
|
|---|
| 142 | virtual bool isQObject() const;
|
|---|
| 143 | virtual QObject *toQObject(Object *, bool *ok = 0);
|
|---|
| 144 | virtual QVariant toVariant(Object *, bool *ok = 0);
|
|---|
| 145 |
|
|---|
| 146 | QScriptContext *context() const;
|
|---|
| 147 | protected:
|
|---|
| 148 | friend class QScriptDeclarativeClassPrivate;
|
|---|
| 149 | QScopedPointer<QScriptDeclarativeClassPrivate> d_ptr;
|
|---|
| 150 | };
|
|---|
| 151 |
|
|---|
| 152 | QT_END_NAMESPACE
|
|---|
| 153 |
|
|---|
| 154 | #endif
|
|---|