Qt 4.8
qdeclarativeobjectscriptclass_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDECLARATIVEOBJECTSCRIPTCLASS_P_H
43 #define QDECLARATIVEOBJECTSCRIPTCLASS_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "private/qdeclarativepropertycache_p.h"
57 #include "private/qdeclarativetypenamecache_p.h"
58 
59 #include <private/qscriptdeclarativeclass_p.h>
60 #include <QtScript/qscriptengine.h>
61 
63 
64 class QDeclarativeEngine;
65 class QScriptContext;
66 class QScriptEngine;
68 struct MethodData;
69 
71 {
72 public:
75 
77 
78 protected:
79  virtual Value call(Object *, QScriptContext *);
80  virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags);
81  virtual Value property(Object *, const Identifier &);
82 
83 private:
84  int enumType(const QMetaObject *, const QString &);
85 
87  Value callOverloaded(MethodData *, QScriptContext *);
88  Value callMethod(QObject *, int index, int returnType, int argCount, int *argTypes, QScriptContext *ctxt);
89 
90  int matchScore(const QScriptValue &, int, const QByteArray &);
93 
98 
99  static QScriptValue connect(QScriptContext *context, QScriptEngine *engine);
100  static QScriptValue disconnect(QScriptContext *context, QScriptEngine *engine);
101 
103 };
104 
106 {
107 public:
110 
111  QScriptValue newQObject(QObject *, int type = QMetaType::QObjectStar);
112 
113  QObject *toQObject(const QScriptValue &) const;
114  int objectType(const QScriptValue &) const;
115 
116  enum QueryHint {
117  ImplicitObject = 0x01,
118  SkipAttachedProperties = 0x02
119  };
120  Q_DECLARE_FLAGS(QueryHints, QueryHint)
121 
122  QScriptClass::QueryFlags queryProperty(QObject *, const Identifier &,
123  QScriptClass::QueryFlags flags,
124  QDeclarativeContextData *evalContext,
125  QueryHints hints = 0);
126 
127  Value property(QObject *, const Identifier &);
128 
129  void setProperty(QObject *, const Identifier &name, const QScriptValue &,
130  QScriptContext *context, QDeclarativeContextData *evalContext = 0);
131  virtual QStringList propertyNames(Object *);
132  virtual bool compare(Object *, Object *);
133 
134 protected:
135  virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
136  QScriptClass::QueryFlags flags);
137 
138  virtual Value property(Object *, const Identifier &);
139  virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
140  virtual bool isQObject() const;
141  virtual QObject *toQObject(Object *, bool *ok = 0);
142 
143 private:
146 
150 
155 
158 
160 };
161 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeObjectScriptClass::QueryHints);
162 
164 
165 #endif // QDECLARATIVEOBJECTSCRIPTCLASS_P_H
166 
The QScriptContext class represents a Qt Script function invocation.
virtual Value call(Object *, QScriptContext *)
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeObjectScriptClass::QueryHints)
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
The QScriptDeclarativeClass::Value class acts as a container for JavaScript data types.
virtual void setProperty(Object *, const Identifier &name, const QScriptValue &)
virtual bool compare(Object *, Object *)
QDeclarativePropertyCache::Data local
The QScriptEngine class provides an environment for evaluating Qt Script code.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags)
QDeclarativePropertyCache::Data * lastData
const char * name
QScriptEngine * engine() const
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QDeclarativeObjectMethodScriptClass methods
QDeclarativeTypeNameCache::Data * lastTNData
The QDeclarativeEngine class provides an environment for instantiating QML components.
virtual QObject * toQObject(Object *, bool *ok=0)
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
quint16 index
QScriptContext * context() const
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
static QScriptValue property(const QScriptValue &, const Identifier &)
virtual QStringList propertyNames(Object *)