Qt 4.8
qdeclarativevmemetaobject_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 QDECLARATIVEVMEMETAOBJECT_P_H
43 #define QDECLARATIVEVMEMETAOBJECT_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 "qdeclarative.h"
57 
58 #include <QtCore/QMetaObject>
59 #include <QtCore/QBitArray>
60 #include <QtCore/QPair>
61 #include <QtGui/QColor>
62 #include <QtCore/QDate>
63 #include <QtCore/qlist.h>
64 #include <QtCore/qdebug.h>
65 
66 #include <private/qobject_p.h>
67 
68 #include "private/qdeclarativeguard_p.h"
69 #include "private/qdeclarativecompiler_p.h"
70 #include "private/qdeclarativecontext_p.h"
71 
73 
74 #define QML_ALIAS_FLAG_PTR 0x00000001
75 
77 {
79  short aliasCount;
80  short signalCount;
81  short methodCount;
82 
83  struct AliasData {
86  int flags;
87 
88  bool isObjectAlias() const {
89  return propertyIdx == -1;
90  }
91  bool isPropertyAlias() const {
92  return !isObjectAlias() && !(propertyIdx & 0xFF000000);
93  }
94  bool isValueTypeAlias() const {
95  return !isObjectAlias() && (propertyIdx & 0xFF000000);
96  }
97  int propertyIndex() const {
98  return propertyIdx & 0x0000FFFF;
99  }
100  int valueTypeIndex() const {
101  return (propertyIdx & 0x00FF0000) >> 16;
102  }
103  int valueType() const {
104  return ((unsigned int)propertyIdx) >> 24;
105  }
106  };
107 
108  struct PropertyData {
110  };
111 
112  struct MethodData {
117  };
118 
120  return (PropertyData *)(((const char *)this) + sizeof(QDeclarativeVMEMetaData));
121  }
122 
123  AliasData *aliasData() const {
124  return (AliasData *)(propertyData() + propertyCount);
125  }
126 
128  return (MethodData *)(aliasData() + aliasCount);
129  }
130 };
131 
135 {
136 public:
138  QDeclarativeCompiledData *compiledData);
140 
141  bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const;
142  void registerInterceptor(int index, int valueIndex, QDeclarativePropertyValueInterceptor *interceptor);
143  QScriptValue vmeMethod(int index);
144  int vmeMethodLineNumber(int index);
145  void setVmeMethod(int index, const QScriptValue &);
146  QScriptValue vmeProperty(int index);
147  void setVMEProperty(int index, const QScriptValue &);
148 
149  void connectAliasSignal(int index);
150 
151 protected:
152  virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
153 
154 private:
158 
162 
164 
165  void connectAlias(int aliasId);
169 
171  QScriptValue method(int);
172 
173  QScriptValue readVarProperty(int);
174  QVariant readVarPropertyAsVariant(int);
175  void writeVarProperty(int, const QScriptValue &);
176  void writeVarProperty(int, const QVariant &);
177 
179 
180  void listChanged(int);
181  class List : public QList<QObject*>
182  {
183  public:
184  List(int lpi) : notifyIndex(lpi) {}
186  };
188 
189  static void list_append(QDeclarativeListProperty<QObject> *, QObject *);
190  static int list_count(QDeclarativeListProperty<QObject> *);
191  static QObject *list_at(QDeclarativeListProperty<QObject> *, int);
192  static void list_clear(QDeclarativeListProperty<QObject> *);
193 };
194 
196 
197 #endif // QDECLARATIVEVMEMETAOBJECT_P_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDeclarativeCompiledData * compiledData
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QAbstractDynamicMetaObject * parent
PropertyData * propertyData() const
QHash< int, QPair< int, QDeclarativePropertyValueInterceptor * > > interceptors
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
const QDeclarativeVMEMetaData * metaData
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static const char * data(const QByteArray &arr)
The QBitArray class provides an array of bits.
Definition: qbitarray.h:54
quint16 index
QDeclarativeGuardedContextData ctxt
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
The QDeclarativePropertyValueInterceptor class is inherited by property interceptors such as Behavior...
The QList class is a template class that provides lists.
Definition: qdatastream.h:62