Qt 4.8
qscriptdeclarativeclass_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-ONLY$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser
11 ** General Public License version 2.1 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.LGPL included in the
13 ** packaging of this file. Please review the following information to
14 ** ensure the GNU Lesser General Public License version 2.1 requirements
15 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** If you have questions regarding the use of this file, please contact
18 ** us via http://www.qt-project.org/.
19 **
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 
43 
45 class PersistentIdentifierPrivate;
46 class QScriptContext;
48 {
49 public:
50 #define QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE
52  {
53  public:
54  Value();
55  Value(const Value &);
56 
57  Value(QScriptContext *, int);
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);
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 
101  {
102  public:
103  Identifier identifier;
104 
108  PersistentIdentifier &operator=(const PersistentIdentifier &other);
109 
110  QString toString() const;
111  private:
113  PersistentIdentifier(QScriptEnginePrivate *e) : identifier(0), engine(e), d(0) {}
115  void *d;
116  };
117 
119  virtual ~QScriptDeclarativeClass();
120 
121  QScriptEngine *engine() const;
122 
123  bool supportsCall() const;
124  void setSupportsCall(bool);
125 
128 
129  QString toString(const Identifier &);
130  bool startsWithUpper(const Identifier &);
131  quint32 toArrayIndex(const Identifier &, bool *ok);
132 
133  virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
134  QScriptClass::QueryFlags flags);
135 
136  virtual Value property(Object *, const Identifier &);
137  virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
138  virtual QScriptValue::PropertyFlags propertyFlags(Object *, const Identifier &);
139  virtual Value call(Object *, QScriptContext *);
140  virtual bool compare(Object *, Object *);
141 
142  virtual QStringList propertyNames(Object *);
143 
144  virtual bool isQObject() const;
145  virtual QObject *toQObject(Object *, bool *ok = 0);
146  virtual QVariant toVariant(Object *, bool *ok = 0);
147 
148  QScriptContext *context() const;
149 protected:
152 };
153 
155 
156 #endif
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
The QScriptContext class represents a Qt Script function invocation.
virtual Value call(Object *, QScriptContext *)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
bool startsWithUpper(const Identifier &)
virtual QVariant toVariant(Object *, bool *ok=0)
QScopedPointer< QScriptDeclarativeClassPrivate > d_ptr
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
PersistentIdentifier createPersistentIdentifier(const QString &)
The QScriptDeclarativeClass::Value class acts as a container for JavaScript data types.
virtual void setProperty(Object *, const Identifier &name, const QScriptValue &)
static QString toString(Register *reg, int type, bool *ok=0)
The QScriptEngine class provides an environment for evaluating Qt Script code.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool compare(const QVariant::Private *a, const QVariant::Private *b)
Compares a to b.
Definition: qvariant.cpp:383
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags)
virtual QScriptValue::PropertyFlags propertyFlags(Object *, const Identifier &)
const char * name
QScriptEngine * engine() const
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
unsigned int uint
Definition: qglobal.h:996
quint16 values[128]
#define Q_SCRIPT_EXPORT
Definition: qglobal.h:1460
quint32 toArrayIndex(const Identifier &, bool *ok)
PropertyFlags
Definition: qmetaobject_p.h:61
virtual QObject * toQObject(Object *, bool *ok=0)
unsigned int quint32
Definition: qglobal.h:938
const char * property
Definition: qwizard.cpp:138
quint16 index
QScriptDeclarativeClass(QScriptEngine *engine)
QScriptContext * context() const
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
virtual QStringList propertyNames(Object *)