Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / v8 / qv8contextwrapper.cpp
index 4984102..8b7fbe8 100644 (file)
@@ -1,34 +1,34 @@
 /****************************************************************************
 **
-** 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.
 **
 **
 **
@@ -258,6 +258,7 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
     // Its possible we could delay the calculation of the "actual" context (in the case
     // of sub contexts) until it is definately needed.
     QDeclarativeContextData *context = resource->getContext();
+    QDeclarativeContextData *expressionContext = context;
 
     if (!context)
         return v8::Undefined();
@@ -282,19 +283,19 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
 
     if (context->imports && QV8Engine::startsWithUpper(property)) {
         // Search for attached properties, enums and imported scripts
-        QDeclarativeTypeNameCache::Data *data = context->imports->data(propertystring);
-
-        if (data) {
-            if (data->importedScriptIndex != -1) {
-                int index = data->importedScriptIndex;
+        QDeclarativeTypeNameCache::Result r = context->imports->query(propertystring);
+        
+        if (r.isValid()) { 
+            if (r.scriptIndex != -1) {
+                int index = r.scriptIndex;
                 if (index < context->importedScripts.count())
                     return context->importedScripts.at(index);
                 else
                     return v8::Undefined();
-            } else if (data->type) {
-                return engine->typeWrapper()->newObject(scopeObject, data->type);
-            } else if (data->typeNamespace) {
-                return engine->typeWrapper()->newObject(scopeObject, data->typeNamespace);
+            } else if (r.type) {
+                return engine->typeWrapper()->newObject(scopeObject, r.type);
+            } else if (r.importNamespace) {
+                return engine->typeWrapper()->newObject(scopeObject, context->imports, r.importNamespace);
             }
             Q_ASSERT(!"Unreachable");
         }
@@ -317,21 +318,17 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
             int propertyIdx = context->propertyNames->value(propertystring);
 
             if (propertyIdx != -1) {
-                typedef QDeclarativeEnginePrivate::CapturedProperty CapturedProperty;
 
                 if (propertyIdx < context->idValueCount) {
 
-                    if (ep->captureProperties)
-                        ep->capturedProperties << CapturedProperty(&context->idValues[propertyIdx].bindings);
-
+                    ep->captureProperty(&context->idValues[propertyIdx].bindings);
                     return engine->newQObject(context->idValues[propertyIdx]);
                 } else {
 
                     QDeclarativeContextPrivate *cp = context->asQDeclarativeContextPrivate();
 
-                    if (ep->captureProperties)
-                        ep->capturedProperties << CapturedProperty(context->asQDeclarativeContext(), -1, 
-                                                                   propertyIdx + cp->notifyIndex);
+                    ep->captureProperty(context->asQDeclarativeContext(), -1,
+                                        propertyIdx + cp->notifyIndex);
 
                     const QVariant &value = cp->propertyValues.at(propertyIdx);
                     if (value.userType() == qMetaTypeId<QList<QObject*> >()) {
@@ -366,6 +363,8 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
         context = context->parent;
     }
 
+    expressionContext->unresolvedNames = true;
+
     QString error = QLatin1String("Can't find variable: ") + engine->toString(property);
     v8::ThrowException(v8::Exception::ReferenceError(engine->toString(error)));
     return v8::Undefined();
@@ -398,6 +397,7 @@ v8::Handle<v8::Value> QV8ContextWrapper::Setter(v8::Local<v8::String> property,
     // Its possible we could delay the calculation of the "actual" context (in the case
     // of sub contexts) until it is definately needed.
     QDeclarativeContextData *context = resource->getContext();
+    QDeclarativeContextData *expressionContext = context;
 
     if (!context)
         return v8::Undefined();
@@ -440,6 +440,8 @@ v8::Handle<v8::Value> QV8ContextWrapper::Setter(v8::Local<v8::String> property,
         context = context->parent;
     }
 
+    expressionContext->unresolvedNames = true;
+
     if (!resource->readOnly) {
         return v8::Handle<v8::Value>();
     } else {