/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
+** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
**
**
**
#include "qdeclarativecontext.h"
-#include "private/qdeclarativedata_p.h"
-#include "private/qdeclarativeintegercache_p.h"
-#include "private/qdeclarativetypenamecache_p.h"
-#include "private/qdeclarativenotifier_p.h"
+#include "qdeclarativedata_p.h"
+#include "qdeclarativeintegercache_p.h"
+#include "qdeclarativetypenamecache_p.h"
+#include "qdeclarativenotifier_p.h"
#include "qdeclarativelist.h"
-#include "private/qdeclarativeparser_p.h"
+#include "qdeclarativescript_p.h"
#include <QtCore/qhash.h>
-#include <QtScript/qscriptvalue.h>
+#include <QtDeclarative/qjsvalue.h>
#include <QtCore/qset.h>
#include <private/qobject_p.h>
-#include "private/qdeclarativeguard_p.h"
+#include <private/qflagpointer_p.h>
+#include <private/qdeclarativeguard_p.h>
+
+#include <private/qv8_p.h>
+
QT_BEGIN_NAMESPACE
+class QV8Bindings;
class QDeclarativeContext;
class QDeclarativeExpression;
class QDeclarativeEngine;
class QDeclarativeExpression;
class QDeclarativeExpressionPrivate;
class QDeclarativeAbstractExpression;
-class QDeclarativeV4Bindings;
+class QV4Bindings;
class QDeclarativeContextData;
class QDeclarativeContextPrivate : public QObjectPrivate
static QObject *context_at(QDeclarativeListProperty<QObject> *, int);
};
+class QDeclarativeVME;
class QDeclarativeComponentAttached;
class QDeclarativeGuardedContextData;
-class Q_AUTOTEST_EXPORT QDeclarativeContextData
+class Q_DECLARATIVE_EXPORT QDeclarativeContextData
{
public:
QDeclarativeContextData();
QDeclarativeContextPrivate *asQDeclarativeContextPrivate();
quint32 isInternal:1;
quint32 ownedByParent:1; // unrelated to isInternal; parent context deletes children if true.
- quint32 dummy:30;
+ quint32 isJSContext:1;
+ quint32 isPragmaLibraryContext:1;
+ quint32 unresolvedNames:1; // True if expressions in this context failed to resolve a toplevel name
+ quint32 dummy:28;
QDeclarativeContext *publicContext;
+ // VME data that is constructing this context if any
+ void *activeVMEData;
+
// Property name cache
QDeclarativeIntegerCache *propertyNames;
QObject *contextObject;
// Any script blocks that exist on this context
- QList<QScriptValue> importedScripts;
+ QList<v8::Persistent<v8::Object> > importedScripts;
// Context base url
QUrl url;
// id guards
struct ContextGuard : public QDeclarativeGuard<QObject>
{
- ContextGuard() : context(0) {}
- inline ContextGuard &operator=(QObject *obj)
- { QDeclarativeGuard<QObject>::operator=(obj); return *this; }
- virtual void objectDestroyed(QObject *) {
- if (context->contextObject && !QObjectPrivate::get(context->contextObject)->wasDeleted) bindings.notify();
- }
- QDeclarativeContextData *context;
+ inline ContextGuard();
+ inline ContextGuard &operator=(QObject *obj);
+ inline void objectDestroyed(QObject *);
+
+ inline bool wasSet() const;
+
+ QFlagPointer<QDeclarativeContextData> context;
QDeclarativeNotifier bindings;
};
ContextGuard *idValues;
void setIdProperty(int, QObject *);
void setIdPropertyData(QDeclarativeIntegerCache *);
- // Optimized binding pointer
- QDeclarativeV4Bindings *optimizedBindings;
-
// Linked contexts. this owns linkedContext.
QDeclarativeContextData *linkedContext;
// context
QDeclarativeComponentAttached *componentAttached;
+ // Optimized binding objects. Needed for deferred properties.
+ QV4Bindings *v4bindings;
+ QV8Bindings *v8bindings;
+
// Return the outermost id for obj, if any.
QString findObjectId(const QObject *obj) const;
}
private:
+ void refreshExpressionsRecursive(bool isGlobal);
+ void refreshExpressionsRecursive(QDeclarativeAbstractExpression *);
~QDeclarativeContextData() {}
};
inline QDeclarativeGuardedContextData(QDeclarativeContextData *);
inline ~QDeclarativeGuardedContextData();
+ inline QDeclarativeContextData *contextData();
inline void setContextData(QDeclarativeContextData *);
- inline QDeclarativeContextData *contextData();
+ inline bool isNull() const { return !m_contextData; }
inline operator QDeclarativeContextData*() const { return m_contextData; }
inline QDeclarativeContextData* operator->() const { return m_contextData; }
return *this;
}
+QDeclarativeContextData::ContextGuard::ContextGuard()
+: context(0)
+{
+}
+
+QDeclarativeContextData::ContextGuard &QDeclarativeContextData::ContextGuard::operator=(QObject *obj)
+{
+ QDeclarativeGuard<QObject>::operator=(obj);
+ context.setFlag();
+ bindings.notify(); // For alias connections
+ return *this;
+}
+
+void QDeclarativeContextData::ContextGuard::objectDestroyed(QObject *)
+{
+ if (context->contextObject && !QObjectPrivate::get(context->contextObject)->wasDeleted)
+ bindings.notify();
+}
+
+bool QDeclarativeContextData::ContextGuard::wasSet() const
+{
+ return context.flag();
+}
+
QT_END_NAMESPACE
#endif // QDECLARATIVECONTEXT_P_H