aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarative.h11
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp45
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h3
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp21
-rw-r--r--src/declarative/qml/qdeclarativeinstruction.cpp3
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h12
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp6
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp1
-rw-r--r--src/declarative/qml/qdeclarativestringconverters.cpp33
-rw-r--r--src/declarative/qml/qdeclarativestringconverters_p.h2
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp216
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h60
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp10
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject.cpp2
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp73
-rw-r--r--src/declarative/qml/qintrusivelist.cpp6
-rw-r--r--src/declarative/qml/qintrusivelist_p.h13
-rw-r--r--src/declarative/qml/v8/qhashedstring.cpp34
-rw-r--r--src/declarative/qml/v8/qhashedstring_p.h34
-rw-r--r--src/declarative/qml/v8/qjsconverter_p.h3
-rw-r--r--src/declarative/qml/v8/qjsengine.cpp178
-rw-r--r--src/declarative/qml/v8/qjsengine.h4
-rw-r--r--src/declarative/qml/v8/qjsvalue.cpp115
-rw-r--r--src/declarative/qml/v8/qjsvalue.h4
-rw-r--r--src/declarative/qml/v8/qjsvalue_impl_p.h53
-rw-r--r--src/declarative/qml/v8/qjsvalue_p.h33
-rw-r--r--src/declarative/qml/v8/qjsvalueiterator.cpp169
-rw-r--r--src/declarative/qml/v8/qjsvalueiterator.h4
-rw-r--r--src/declarative/qml/v8/qjsvalueiterator_impl_p.h121
-rw-r--r--src/declarative/qml/v8/qjsvalueiterator_p.h68
-rw-r--r--src/declarative/qml/v8/qscript_impl_p.h1
-rw-r--r--src/declarative/qml/v8/qscriptoriginalglobalobject_p.h4
-rw-r--r--src/declarative/qml/v8/qscripttools_p.h182
-rw-r--r--src/declarative/qml/v8/qv8_p.h41
-rw-r--r--src/declarative/qml/v8/qv8bindings.cpp34
-rw-r--r--src/declarative/qml/v8/qv8bindings_p.h34
-rw-r--r--src/declarative/qml/v8/qv8contextwrapper.cpp34
-rw-r--r--src/declarative/qml/v8/qv8debug_p.h1
-rw-r--r--src/declarative/qml/v8/qv8domerrors.cpp73
-rw-r--r--src/declarative/qml/v8/qv8domerrors_p.h94
-rw-r--r--src/declarative/qml/v8/qv8engine.cpp159
-rw-r--r--src/declarative/qml/v8/qv8engine_impl_p.h30
-rw-r--r--src/declarative/qml/v8/qv8engine_p.h53
-rw-r--r--src/declarative/qml/v8/qv8include.cpp34
-rw-r--r--src/declarative/qml/v8/qv8listwrapper.cpp36
-rw-r--r--src/declarative/qml/v8/qv8listwrapper_p.h34
-rw-r--r--src/declarative/qml/v8/qv8qobjectwrapper.cpp44
-rw-r--r--src/declarative/qml/v8/qv8qobjectwrapper_p.h34
-rw-r--r--src/declarative/qml/v8/qv8stringwrapper.cpp42
-rw-r--r--src/declarative/qml/v8/qv8stringwrapper_p.h34
-rw-r--r--src/declarative/qml/v8/qv8typewrapper.cpp52
-rw-r--r--src/declarative/qml/v8/qv8valuetypewrapper.cpp105
-rw-r--r--src/declarative/qml/v8/qv8valuetypewrapper_p.h6
-rw-r--r--src/declarative/qml/v8/qv8variantwrapper.cpp47
-rw-r--r--src/declarative/qml/v8/qv8variantwrapper_p.h1
-rw-r--r--src/declarative/qml/v8/qv8worker.cpp34
-rw-r--r--src/declarative/qml/v8/qv8worker_p.h34
-rw-r--r--src/declarative/qml/v8/script.pri4
-rw-r--r--src/declarative/qml/v8/v8.pri5
61 files changed, 1691 insertions, 935 deletions
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 4c962f890e..311ecd31ca 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -550,6 +550,17 @@ inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMi
return QDeclarativePrivate::qmlregister(QDeclarativePrivate::ModuleApiRegistration, &api);
}
+// Enable debugging before any QDeclarativeEngine is created
+struct Q_DECLARATIVE_EXPORT QDeclarativeDebuggingEnabler
+{
+ QDeclarativeDebuggingEnabler();
+};
+
+// Execute code in constructor before first QDeclarativeEngine is instantiated
+#if defined(QT_DECLARATIVE_DEBUG)
+static QDeclarativeDebuggingEnabler qmlEnableDebuggingHelper;
+#endif
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QObject)
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 5e1d3f60a9..7cc8422ddd 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -312,6 +312,13 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 3D vector expected"));
}
break;
+ case QVariant::Vector4D:
+ {
+ bool ok;
+ QDeclarativeStringConverters::vector4DFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 4D vector expected"));
+ }
+ break;
default:
{
int t = prop.userType();
@@ -467,7 +474,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
instr.storeDateTime.propertyIndex = prop.propertyIndex();
instr.storeDateTime.date = dateTime.date().toJulianDay();
Q_ASSERT(sizeof(instr.storeDateTime.time) == sizeof(QTime));
- ::memcmp(&instr.storeDateTime.time, &time, sizeof(QTime));
+ ::memcpy(&instr.storeDateTime.time, &time, sizeof(QTime));
}
break;
#endif // QT_NO_DATESTRING
@@ -554,6 +561,18 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
instr.storeVector3D.vector.zp = vector.z();
}
break;
+ case QVariant::Vector4D:
+ {
+ bool ok;
+ QVector4D vector = QDeclarativeStringConverters::vector4DFromString(string, &ok);
+ instr.setType(QDeclarativeInstruction::StoreVector4D);
+ instr.storeVector4D.propertyIndex = prop.propertyIndex();
+ instr.storeVector4D.vector.xp = vector.x();
+ instr.storeVector4D.vector.yp = vector.y();
+ instr.storeVector4D.vector.zp = vector.z();
+ instr.storeVector4D.vector.wp = vector.w();
+ }
+ break;
default:
{
int t = prop.userType();
@@ -856,6 +875,9 @@ bool QDeclarativeCompiler::buildObject(QDeclarativeParser::Object *obj, const Bi
int ids = compileState.ids.count();
COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
canDefer = ids == compileState.ids.count();
+ } else if (isSignalPropertyName(prop->name) &&
+ (cp->flags() & QDeclarativeCustomParser::AcceptsSignalHandlers)) {
+ COMPILE_CHECK(buildSignal(prop,obj,objCtxt));
} else {
customProps << QDeclarativeCustomParserNodePrivate::fromProperty(prop);
}
@@ -2378,25 +2400,27 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
}
for (int ii = 0; ii < obj->dynamicSignals.count(); ++ii) {
- QByteArray name = obj->dynamicSignals.at(ii).name;
+ const QDeclarativeParser::Object::DynamicSignal &currSig = obj->dynamicSignals.at(ii);
+ QByteArray name = currSig.name;
if (methodNames.contains(name))
- COMPILE_EXCEPTION(obj, tr("Duplicate signal name"));
+ COMPILE_EXCEPTION(&currSig, tr("Duplicate signal name"));
QString nameStr = QString::fromUtf8(name);
if (nameStr.at(0).isUpper())
- COMPILE_EXCEPTION(obj, tr("Signal names cannot begin with an upper case letter"));
+ COMPILE_EXCEPTION(&currSig, tr("Signal names cannot begin with an upper case letter"));
if (enginePrivate->v8engine()->illegalNames().contains(nameStr))
- COMPILE_EXCEPTION(obj, tr("Illegal signal name"));
+ COMPILE_EXCEPTION(&currSig, tr("Illegal signal name"));
methodNames.insert(name);
}
for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
- QByteArray name = obj->dynamicSlots.at(ii).name;
+ const QDeclarativeParser::Object::DynamicSlot &currSlot = obj->dynamicSlots.at(ii);
+ QByteArray name = currSlot.name;
if (methodNames.contains(name))
- COMPILE_EXCEPTION(obj, tr("Duplicate method name"));
+ COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name"));
QString nameStr = QString::fromUtf8(name);
if (nameStr.at(0).isUpper())
- COMPILE_EXCEPTION(obj, tr("Method names cannot begin with an upper case letter"));
+ COMPILE_EXCEPTION(&currSlot, tr("Method names cannot begin with an upper case letter"));
if (enginePrivate->v8engine()->illegalNames().contains(nameStr))
- COMPILE_EXCEPTION(obj, tr("Illegal method name"));
+ COMPILE_EXCEPTION(&currSlot, tr("Illegal method name"));
methodNames.insert(name);
}
@@ -2747,6 +2771,7 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
int propIdx = -1;
int flags = 0;
bool writable = false;
+ bool resettable = false;
if (alias.count() == 2 || alias.count() == 3) {
propIdx = indexOfProperty(idObject, alias.at(1).toUtf8());
@@ -2761,6 +2786,7 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
writable = aliasProperty.isWritable();
+ resettable = aliasProperty.isResettable();
if (alias.count() == 3) {
QDeclarativeValueType *valueType = enginePrivate->valueTypes[aliasProperty.type()];
@@ -2805,6 +2831,7 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
QMetaPropertyBuilder propBuilder =
builder.addProperty(prop.name, typeName.constData(), builder.methodCount() - 1);
propBuilder.setWritable(writable);
+ propBuilder.setResettable(resettable);
return true;
}
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
index ab66b9fcdc..31452836bd 100644
--- a/src/declarative/qml/qdeclarativecustomparser_p.h
+++ b/src/declarative/qml/qdeclarativecustomparser_p.h
@@ -116,7 +116,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeCustomParser
public:
enum Flag {
NoFlag = 0x00000000,
- AcceptsAttachedProperties = 0x00000001
+ AcceptsAttachedProperties = 0x00000001,
+ AcceptsSignalHandlers = 0x00000002
};
Q_DECLARE_FLAGS(Flags, Flag)
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 4781264bde..1906612e8a 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -67,7 +67,7 @@
#include "private/qdeclarativenotifier_p.h"
#include "private/qdeclarativedebugtrace_p.h"
#include "private/qdeclarativeapplication_p.h"
-#include "private/qjsdebugservice_p.h"
+#include "private/qv8debugservice_p.h"
#include <QtCore/qmetaobject.h>
#include <QNetworkReply>
@@ -175,12 +175,6 @@ void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor)
\endcode
*/
-struct StaticQtMetaObject : public QObject
-{
- static const QMetaObject *get()
- { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
-};
-
static bool qt_QmlQtModule_registered = false;
bool QDeclarativeEnginePrivate::qml_debugging_enabled = false;
@@ -457,7 +451,7 @@ void QDeclarativeEnginePrivate::init()
QDeclarativeEngineDebugServer::isDebuggingEnabled()) {
isDebugging = true;
QDeclarativeEngineDebugServer::instance()->addEngine(q);
- QJSDebugService::instance()->addEngine(q);
+ QV8DebugService::instance()->addEngine(q);
}
}
@@ -992,6 +986,17 @@ QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
return qmlAttachedPropertiesObjectById(*idCache, object, create);
}
+QDeclarativeDebuggingEnabler::QDeclarativeDebuggingEnabler()
+{
+#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
+ if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
+ qWarning("Qml debugging is enabled. Only use this in a safe environment!");
+ }
+ QDeclarativeEnginePrivate::qml_debugging_enabled = true;
+#endif
+}
+
+
class QDeclarativeDataExtended {
public:
QDeclarativeDataExtended();
diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp
index f99351bde5..f5bd6e915a 100644
--- a/src/declarative/qml/qdeclarativeinstruction.cpp
+++ b/src/declarative/qml/qdeclarativeinstruction.cpp
@@ -132,6 +132,9 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
case QDeclarativeInstruction::StoreVector3D:
qWarning().nospace() << idx << "\t\t" << "STORE_VECTOR3D\t\t" << instr->storeVector3D.propertyIndex << "\t" << instr->storeVector3D.vector.xp << "\t" << instr->storeVector3D.vector.yp << "\t" << instr->storeVector3D.vector.zp;
break;
+ case QDeclarativeInstruction::StoreVector4D:
+ qWarning().nospace() << idx << "\t\t" << "STORE_VECTOR4D\t\t" << instr->storeVector4D.propertyIndex << "\t" << instr->storeVector4D.vector.xp << "\t" << instr->storeVector4D.vector.yp << "\t" << instr->storeVector4D.vector.zp << "\t" << instr->storeVector4D.vector.wp;
+ break;
case QDeclarativeInstruction::StoreVariant:
qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
break;
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index a48c44c32e..f98002766a 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -88,6 +88,7 @@ QT_BEGIN_NAMESPACE
F(StoreRect, storeRect) \
F(StoreRectF, storeRectF) \
F(StoreVector3D, storeVector3D) \
+ F(StoreVector4D, storeVector4D) \
F(StoreObject, storeObject) \
F(AssignCustomType, assignCustomType) \
F(AssignSignalObject, assignSignalObject) \
@@ -405,6 +406,16 @@ union QDeclarativeInstruction
float zp;
} vector;
};
+ struct instr_storeVector4D {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ struct QVector4D {
+ float xp;
+ float yp;
+ float zp;
+ float wp;
+ } vector;
+ };
instr_common common;
instr_init init;
@@ -440,6 +451,7 @@ union QDeclarativeInstruction
instr_storeRect storeRect;
instr_storeRectF storeRectF;
instr_storeVector3D storeVector3D;
+ instr_storeVector4D storeVector4D;
instr_storeObject storeObject;
instr_assignCustomType assignCustomType;
instr_storeSignal storeSignal;
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
index 0447ea3227..a405022a71 100644
--- a/src/declarative/qml/qdeclarativeparser.cpp
+++ b/src/declarative/qml/qdeclarativeparser.cpp
@@ -191,7 +191,7 @@ QDeclarativeParser::Object::DynamicSignal::DynamicSignal()
QDeclarativeParser::Object::DynamicSignal::DynamicSignal(const DynamicSignal &o)
: name(o.name), parameterTypes(o.parameterTypes),
- parameterNames(o.parameterNames)
+ parameterNames(o.parameterNames), location(o.location)
{
}
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
index 59c41ef8de..7080a8daee 100644
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -212,6 +212,7 @@ namespace QDeclarativeParser
QByteArray name;
QList<QByteArray> parameterTypes;
QList<QByteArray> parameterNames;
+ LocationSpan location;
};
struct DynamicSlot {
DynamicSlot();
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index 98c758267d..3406109a28 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -399,7 +399,7 @@ const char *QDeclarativeProperty::propertyTypeName() const
return 0;
if (d->isValueType()) {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->engine);
+ QDeclarativeEnginePrivate *ep = d->engine?QDeclarativeEnginePrivate::get(d->engine):0;
QDeclarativeValueType *valueType = 0;
if (ep) valueType = ep->valueTypes[d->core.propType];
else valueType = QDeclarativeValueTypeFactory::valueType(d->core.propType);
@@ -987,7 +987,7 @@ QVariant QDeclarativePropertyPrivate::readValueProperty()
{
if (isValueType()) {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QDeclarativeEnginePrivate *ep = engine?QDeclarativeEnginePrivate::get(engine):0;
QDeclarativeValueType *valueType = 0;
if (ep) valueType = ep->valueTypes[core.propType];
else valueType = QDeclarativeValueTypeFactory::valueType(core.propType);
@@ -1072,7 +1072,7 @@ bool QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, Writ
bool rv = false;
if (isValueType()) {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QDeclarativeEnginePrivate *ep = engine?QDeclarativeEnginePrivate::get(engine):0;
QDeclarativeValueType *writeBack = 0;
if (ep) {
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index 3f843295d7..dcd12e287a 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -528,6 +528,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
p = p->finish();
}
+ signal.location = location(node->typeToken, node->semicolonToken);
_stateStack.top().object->dynamicSignals << signal;
} else {
const QString memberType = node->memberType->asString();
diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp
index d7cfe2eca3..b949adf5ec 100644
--- a/src/declarative/qml/qdeclarativestringconverters.cpp
+++ b/src/declarative/qml/qdeclarativestringconverters.cpp
@@ -43,6 +43,7 @@
#include <QtGui/qcolor.h>
#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
#include <QtCore/qsize.h>
@@ -93,6 +94,8 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s)
if (ok) return QVariant(sz);
QVector3D v = vector3DFromString(s, &ok);
if (ok) return QVariant::fromValue(v);
+ QVector4D v4 = vector4DFromString(s, &ok);
+ if (ok) return QVariant::fromValue(v4);
return QVariant(s);
}
@@ -128,6 +131,8 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s, int p
return QVariant::fromValue(rectFFromString(s, ok).toRect());
case QMetaType::QVector3D:
return QVariant::fromValue(vector3DFromString(s, ok));
+ case QMetaType::QVector4D:
+ return QVariant::fromValue(vector4DFromString(s, ok));
default:
if (ok) *ok = false;
return QVariant();
@@ -275,4 +280,32 @@ QVector3D QDeclarativeStringConverters::vector3DFromString(const QString &s, boo
return QVector3D(xCoord, yCoord, zCoord);
}
+//expects input of "x,y,z,w"
+QVector4D QDeclarativeStringConverters::vector4DFromString(const QString &s, bool *ok)
+{
+ if (s.count(QLatin1Char(',')) != 3) {
+ if (ok)
+ *ok = false;
+ return QVector4D();
+ }
+
+ bool xGood, yGood, zGood, wGood;
+ int index = s.indexOf(QLatin1Char(','));
+ int index2 = s.indexOf(QLatin1Char(','), index+1);
+ int index3 = s.indexOf(QLatin1Char(','), index2+1);
+ qreal xCoord = s.left(index).toDouble(&xGood);
+ qreal yCoord = s.mid(index+1, index2-index-1).toDouble(&yGood);
+ qreal zCoord = s.mid(index2+1, index3-index2-1).toDouble(&zGood);
+ qreal wCoord = s.mid(index3+1).toDouble(&wGood);
+ if (!xGood || !yGood || !zGood || !wGood) {
+ if (ok)
+ *ok = false;
+ return QVector4D();
+ }
+
+ if (ok)
+ *ok = true;
+ return QVector4D(xCoord, yCoord, zCoord, wCoord);
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativestringconverters_p.h b/src/declarative/qml/qdeclarativestringconverters_p.h
index a8c63595fc..2f93cd72f9 100644
--- a/src/declarative/qml/qdeclarativestringconverters_p.h
+++ b/src/declarative/qml/qdeclarativestringconverters_p.h
@@ -67,6 +67,7 @@ class QRectF;
class QString;
class QByteArray;
class QVector3D;
+class QVector4D;
// XXX - Bauhaus currently uses these methods which is why they're exported
namespace QDeclarativeStringConverters
@@ -84,6 +85,7 @@ namespace QDeclarativeStringConverters
QSizeF Q_DECLARATIVE_PRIVATE_EXPORT sizeFFromString(const QString &, bool *ok = 0);
QRectF Q_DECLARATIVE_PRIVATE_EXPORT rectFFromString(const QString &, bool *ok = 0);
QVector3D Q_DECLARATIVE_PRIVATE_EXPORT vector3DFromString(const QString &, bool *ok = 0);
+ QVector4D Q_DECLARATIVE_PRIVATE_EXPORT vector4DFromString(const QString &, bool *ok = 0);
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index 7f77388516..3e77f4b503 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -152,6 +152,9 @@ QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
case QVariant::Font:
rv = new QDeclarativeFontValueType;
break;
+ case QVariant::Color:
+ rv = new QDeclarativeColorValueType;
+ break;
default:
break;
}
@@ -193,6 +196,16 @@ void QDeclarativePointFValueType::setValue(QVariant value)
point = qvariant_cast<QPointF>(value);
}
+QString QDeclarativePointFValueType::toString() const
+{
+ return QString(QLatin1String("QPointF(%1, %2)")).arg(point.x()).arg(point.y());
+}
+
+bool QDeclarativePointFValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(point) == value);
+}
+
qreal QDeclarativePointFValueType::x() const
{
return point.x();
@@ -241,6 +254,16 @@ void QDeclarativePointValueType::setValue(QVariant value)
point = qvariant_cast<QPoint>(value);
}
+QString QDeclarativePointValueType::toString() const
+{
+ return QString(QLatin1String("QPoint(%1, %2)")).arg(point.x()).arg(point.y());
+}
+
+bool QDeclarativePointValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(point) == value);
+}
+
int QDeclarativePointValueType::x() const
{
return point.x();
@@ -289,6 +312,16 @@ void QDeclarativeSizeFValueType::setValue(QVariant value)
size = qvariant_cast<QSizeF>(value);
}
+QString QDeclarativeSizeFValueType::toString() const
+{
+ return QString(QLatin1String("QSizeF(%1, %2)")).arg(size.width()).arg(size.height());
+}
+
+bool QDeclarativeSizeFValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(size) == value);
+}
+
qreal QDeclarativeSizeFValueType::width() const
{
return size.width();
@@ -337,6 +370,16 @@ void QDeclarativeSizeValueType::setValue(QVariant value)
size = qvariant_cast<QSize>(value);
}
+QString QDeclarativeSizeValueType::toString() const
+{
+ return QString(QLatin1String("QSize(%1, %2)")).arg(size.width()).arg(size.height());
+}
+
+bool QDeclarativeSizeValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(size) == value);
+}
+
int QDeclarativeSizeValueType::width() const
{
return size.width();
@@ -385,6 +428,16 @@ void QDeclarativeRectFValueType::setValue(QVariant value)
rect = qvariant_cast<QRectF>(value);
}
+QString QDeclarativeRectFValueType::toString() const
+{
+ return QString(QLatin1String("QRectF(%1, %2, %3, %4)")).arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
+}
+
+bool QDeclarativeRectFValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(rect) == value);
+}
+
qreal QDeclarativeRectFValueType::x() const
{
return rect.x();
@@ -453,6 +506,16 @@ void QDeclarativeRectValueType::setValue(QVariant value)
rect = qvariant_cast<QRect>(value);
}
+QString QDeclarativeRectValueType::toString() const
+{
+ return QString(QLatin1String("QRect(%1, %2, %3, %4)")).arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
+}
+
+bool QDeclarativeRectValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(rect) == value);
+}
+
int QDeclarativeRectValueType::x() const
{
return rect.x();
@@ -521,6 +584,16 @@ void QDeclarativeVector2DValueType::setValue(QVariant value)
vector = qvariant_cast<QVector2D>(value);
}
+QString QDeclarativeVector2DValueType::toString() const
+{
+ return QString(QLatin1String("QVector2D(%1, %2)")).arg(vector.x()).arg(vector.y());
+}
+
+bool QDeclarativeVector2DValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(vector) == value);
+}
+
qreal QDeclarativeVector2DValueType::x() const
{
return vector.x();
@@ -569,6 +642,16 @@ void QDeclarativeVector3DValueType::setValue(QVariant value)
vector = qvariant_cast<QVector3D>(value);
}
+QString QDeclarativeVector3DValueType::toString() const
+{
+ return QString(QLatin1String("QVector3D(%1, %2, %3)")).arg(vector.x()).arg(vector.y()).arg(vector.z());
+}
+
+bool QDeclarativeVector3DValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(vector) == value);
+}
+
qreal QDeclarativeVector3DValueType::x() const
{
return vector.x();
@@ -627,6 +710,16 @@ void QDeclarativeVector4DValueType::setValue(QVariant value)
vector = qvariant_cast<QVector4D>(value);
}
+QString QDeclarativeVector4DValueType::toString() const
+{
+ return QString(QLatin1String("QVector4D(%1, %2, %3, %4)")).arg(vector.x()).arg(vector.y()).arg(vector.z()).arg(vector.w());
+}
+
+bool QDeclarativeVector4DValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(vector) == value);
+}
+
qreal QDeclarativeVector4DValueType::x() const
{
return vector.x();
@@ -695,6 +788,16 @@ void QDeclarativeQuaternionValueType::setValue(QVariant value)
quaternion = qvariant_cast<QQuaternion>(value);
}
+QString QDeclarativeQuaternionValueType::toString() const
+{
+ return QString(QLatin1String("QQuaternion(%1, %2, %3, %4)")).arg(quaternion.scalar()).arg(quaternion.x()).arg(quaternion.y()).arg(quaternion.z());
+}
+
+bool QDeclarativeQuaternionValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(quaternion) == value);
+}
+
qreal QDeclarativeQuaternionValueType::scalar() const
{
return quaternion.scalar();
@@ -763,6 +866,20 @@ void QDeclarativeMatrix4x4ValueType::setValue(QVariant value)
matrix = qvariant_cast<QMatrix4x4>(value);
}
+QString QDeclarativeMatrix4x4ValueType::toString() const
+{
+ return QString(QLatin1String("QMatrix4x4(%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16)"))
+ .arg(matrix(0, 0)).arg(matrix(0, 1)).arg(matrix(0, 2)).arg(matrix(0, 3))
+ .arg(matrix(1, 0)).arg(matrix(1, 1)).arg(matrix(1, 2)).arg(matrix(1, 3))
+ .arg(matrix(2, 0)).arg(matrix(2, 1)).arg(matrix(2, 2)).arg(matrix(2, 3))
+ .arg(matrix(3, 0)).arg(matrix(3, 1)).arg(matrix(3, 2)).arg(matrix(3, 3));
+}
+
+bool QDeclarativeMatrix4x4ValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(matrix) == value);
+}
+
QDeclarativeEasingValueType::QDeclarativeEasingValueType(QObject *parent)
: QDeclarativeValueType(parent)
{
@@ -791,6 +908,16 @@ void QDeclarativeEasingValueType::setValue(QVariant value)
easing = qvariant_cast<QEasingCurve>(value);
}
+QString QDeclarativeEasingValueType::toString() const
+{
+ return QString(QLatin1String("QEasingCurve(%1, %2, %3, %4)")).arg(easing.type()).arg(easing.amplitude()).arg(easing.overshoot()).arg(easing.period());
+}
+
+bool QDeclarativeEasingValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(easing) == value);
+}
+
QDeclarativeEasingValueType::Type QDeclarativeEasingValueType::type() const
{
return (QDeclarativeEasingValueType::Type)easing.type();
@@ -861,6 +988,16 @@ void QDeclarativeFontValueType::setValue(QVariant value)
font = qvariant_cast<QFont>(value);
}
+QString QDeclarativeFontValueType::toString() const
+{
+ return QString(QLatin1String("QFont(%1)")).arg(font.toString());
+}
+
+bool QDeclarativeFontValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(font) == value);
+}
+
QString QDeclarativeFontValueType::family() const
{
@@ -1009,4 +1146,83 @@ void QDeclarativeFontValueType::setWordSpacing(qreal size)
font.setWordSpacing(size);
}
+QDeclarativeColorValueType::QDeclarativeColorValueType(QObject *parent)
+: QDeclarativeValueType(parent)
+{
+}
+
+void QDeclarativeColorValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &color, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QDeclarativeColorValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &color, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QDeclarativeColorValueType::value()
+{
+ return QVariant(color);
+}
+
+void QDeclarativeColorValueType::setValue(QVariant value)
+{
+ color = qvariant_cast<QColor>(value);
+}
+
+QString QDeclarativeColorValueType::toString() const
+{
+ // special case - to maintain behaviour with QtQuick 1.0, we just output normal toString() value.
+ return QVariant(color).toString();
+}
+
+bool QDeclarativeColorValueType::isEqual(const QVariant &value) const
+{
+ return (QVariant(color) == value);
+}
+
+qreal QDeclarativeColorValueType::r() const
+{
+ return color.redF();
+}
+
+qreal QDeclarativeColorValueType::g() const
+{
+ return color.greenF();
+}
+
+qreal QDeclarativeColorValueType::b() const
+{
+ return color.blueF();
+}
+
+qreal QDeclarativeColorValueType::a() const
+{
+ return color.alphaF();
+}
+
+void QDeclarativeColorValueType::setR(qreal r)
+{
+ color.setRedF(r);
+}
+
+void QDeclarativeColorValueType::setG(qreal g)
+{
+ color.setGreenF(g);
+}
+
+void QDeclarativeColorValueType::setB(qreal b)
+{
+ color.setBlueF(b);
+}
+
+void QDeclarativeColorValueType::setA(qreal a)
+{
+ color.setAlphaF(a);
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h
index 5d103a46de..03cb83fdad 100644
--- a/src/declarative/qml/qdeclarativevaluetype_p.h
+++ b/src/declarative/qml/qdeclarativevaluetype_p.h
@@ -67,6 +67,7 @@
#include <QtGui/qmatrix4x4.h>
#include <QtGui/qquaternion.h>
#include <QtGui/qfont.h>
+#include <QtGui/qcolor.h>
QT_BEGIN_NAMESPACE
@@ -79,6 +80,9 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags flags) = 0;
virtual QVariant value() = 0;
virtual void setValue(QVariant) = 0;
+
+ virtual QString toString() const = 0;
+ virtual bool isEqual(const QVariant &value) const = 0;
};
class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeValueTypeFactory
@@ -113,6 +117,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
qreal x() const;
qreal y() const;
@@ -135,6 +141,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
int x() const;
int y() const;
@@ -157,6 +165,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
qreal width() const;
qreal height() const;
@@ -179,6 +189,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
int width() const;
int height() const;
@@ -203,6 +215,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
qreal x() const;
qreal y() const;
@@ -232,6 +246,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
int x() const;
int y() const;
@@ -259,6 +275,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
qreal x() const;
qreal y() const;
@@ -282,6 +300,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
qreal x() const;
qreal y() const;
@@ -308,6 +328,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
qreal x() const;
qreal y() const;
@@ -336,6 +358,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
qreal scalar() const;
qreal x() const;
@@ -376,6 +400,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
qreal m11() const { return matrix(0, 0); }
qreal m12() const { return matrix(0, 1); }
@@ -457,6 +483,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
Type type() const;
qreal amplitude() const;
@@ -508,6 +536,8 @@ public:
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
virtual QVariant value();
virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
QString family() const;
void setFamily(const QString &);
@@ -552,6 +582,36 @@ private:
mutable QDeclarativeNullableValue<int> dpi;
};
+class Q_AUTOTEST_EXPORT QDeclarativeColorValueType : public QDeclarativeValueType
+{
+ Q_PROPERTY(qreal r READ r WRITE setR)
+ Q_PROPERTY(qreal g READ g WRITE setG)
+ Q_PROPERTY(qreal b READ b WRITE setB)
+ Q_PROPERTY(qreal a READ a WRITE setA)
+ Q_OBJECT
+public:
+ QDeclarativeColorValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ qreal r() const;
+ qreal g() const;
+ qreal b() const;
+ qreal a() const;
+ void setR(qreal);
+ void setG(qreal);
+ void setB(qreal);
+ void setA(qreal);
+
+private:
+ QColor color;
+};
+
QT_END_NAMESPACE
#endif // QDECLARATIVEVALUETYPE_P_H
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 45e4745c1a..6708b60834 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -586,6 +586,16 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEObjectStack &stack,
instr.propertyIndex, a);
QML_END_INSTR(StoreVector3D)
+ QML_BEGIN_INSTR(StoreVector4D)
+ QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.propertyIndex);
+
+ QVector4D *v = (QVector4D *)&instr.vector;
+ void *a[] = { v, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.propertyIndex, a);
+ QML_END_INSTR(StoreVector4D)
+
QML_BEGIN_INSTR(StoreObject)
QObject *assignObj = stack.pop();
QObject *target = stack.top();
diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp
index 746c9f650b..bcd46f259e 100644
--- a/src/declarative/qml/qdeclarativevmemetaobject.cpp
+++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp
@@ -458,7 +458,7 @@ int QDeclarativeVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
}
}
}
- if(c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty) {
+ if (c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty || c == QMetaObject::ResetProperty) {
if (id >= propOffset) {
id -= propOffset;
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
index abcc283610..0eb923a70c 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -49,6 +49,7 @@
#include "private/qdeclarativeengine_p.h"
#include "private/qdeclarativeexpression_p.h"
#include "qdeclarativeglobal_p.h"
+#include "qv8domerrors_p.h"
#include <QtCore/qobject.h>
#include <QtDeclarative/qjsvalue.h>
@@ -63,33 +64,6 @@
#ifndef QT_NO_XMLSTREAMREADER
-// From DOM-Level-3-Core spec
-// http://www.w3.org/TR/DOM-Level-3-Core/core.html
-#define INDEX_SIZE_ERR 1
-#define DOMSTRING_SIZE_ERR 2
-#define HIERARCHY_REQUEST_ERR 3
-#define WRONG_DOCUMENT_ERR 4
-#define INVALID_CHARACTER_ERR 5
-#define NO_DATA_ALLOWED_ERR 6
-#define NO_MODIFICATION_ALLOWED_ERR 7
-#define NOT_FOUND_ERR 8
-#define NOT_SUPPORTED_ERR 9
-#define INUSE_ATTRIBUTE_ERR 10
-#define INVALID_STATE_ERR 11
-#define SYNTAX_ERR 12
-#define INVALID_MODIFICATION_ERR 13
-#define NAMESPACE_ERR 14
-#define INVALID_ACCESS_ERR 15
-#define VALIDATION_ERR 16
-#define TYPE_MISMATCH_ERR 17
-
-#define V8THROW_DOM(error, string) { \
- v8::Local<v8::Value> v = v8::Exception::Error(v8::String::New(string)); \
- v->ToObject()->Set(v8::String::New("code"), v8::Integer::New(error)); \
- v8::ThrowException(v); \
- return v8::Handle<v8::Value>(); \
-}
-
#define V8THROW_REFERENCE(string) { \
v8::ThrowException(v8::Exception::ReferenceError(v8::String::New(string))); \
return v8::Handle<v8::Value>(); \
@@ -1518,7 +1492,7 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_open(const v8::Arguments &args)
V8THROW_REFERENCE("Not an XMLHttpRequest object");
if (args.Length() < 2 || args.Length() > 5)
- V8THROW_DOM(SYNTAX_ERR, "Incorrect argument count");
+ V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
QV8Engine *engine = r->engine;
@@ -1529,7 +1503,7 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_open(const v8::Arguments &args)
method != QLatin1String("HEAD") &&
method != QLatin1String("POST") &&
method != QLatin1String("DELETE"))
- V8THROW_DOM(SYNTAX_ERR, "Unsupported HTTP method type");
+ V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Unsupported HTTP method type");
// Argument 1 - URL
QUrl url = QUrl::fromEncoded(engine->toString(args[1]).toUtf8());
@@ -1539,7 +1513,7 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_open(const v8::Arguments &args)
// Argument 2 - async (optional)
if (args.Length() > 2 && !args[2]->BooleanValue())
- V8THROW_DOM(NOT_SUPPORTED_ERR, "Synchronous XMLHttpRequest calls are not supported");
+ V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Synchronous XMLHttpRequest calls are not supported");
// Argument 3/4 - user/pass (optional)
QString username, password;
@@ -1565,10 +1539,10 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_setRequestHeader(const v8::Argume
V8THROW_REFERENCE("Not an XMLHttpRequest object");
if (args.Length() != 2)
- V8THROW_DOM(SYNTAX_ERR, "Incorrect argument count");
+ V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
if (r->readyState() != QDeclarativeXMLHttpRequest::Opened || r->sendFlag())
- V8THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
QV8Engine *engine = r->engine;
@@ -1615,7 +1589,7 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_send(const v8::Arguments &args)
if (r->readyState() != QDeclarativeXMLHttpRequest::Opened ||
r->sendFlag())
- V8THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
QByteArray data;
if (args.Length() > 0)
@@ -1642,12 +1616,12 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_getResponseHeader(const v8::Argum
QV8Engine *engine = r->engine;
if (args.Length() != 1)
- V8THROW_DOM(SYNTAX_ERR, "Incorrect argument count");
+ V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
if (r->readyState() != QDeclarativeXMLHttpRequest::Loading &&
r->readyState() != QDeclarativeXMLHttpRequest::Done &&
r->readyState() != QDeclarativeXMLHttpRequest::HeadersReceived)
- V8THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
return engine->toString(r->header(engine->toString(args[0])));
}
@@ -1661,12 +1635,12 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_getAllResponseHeaders(const v8::A
QV8Engine *engine = r->engine;
if (args.Length() != 0)
- V8THROW_DOM(SYNTAX_ERR, "Incorrect argument count");
+ V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
if (r->readyState() != QDeclarativeXMLHttpRequest::Loading &&
r->readyState() != QDeclarativeXMLHttpRequest::Done &&
r->readyState() != QDeclarativeXMLHttpRequest::HeadersReceived)
- V8THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
return engine->toString(r->headers());
}
@@ -1691,7 +1665,7 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_status(v8::Local<v8::String> prop
if (r->readyState() == QDeclarativeXMLHttpRequest::Unsent ||
r->readyState() == QDeclarativeXMLHttpRequest::Opened)
- V8THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
if (r->errorFlag())
return v8::Integer::New(0);
@@ -1710,7 +1684,7 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_statusText(v8::Local<v8::String>
if (r->readyState() == QDeclarativeXMLHttpRequest::Unsent ||
r->readyState() == QDeclarativeXMLHttpRequest::Opened)
- V8THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
if (r->errorFlag())
return engine->toString(QString());
@@ -1812,27 +1786,6 @@ void *qt_add_qmlxmlhttprequest(QV8Engine *engine)
xmlhttprequest->Set(v8::String::New("DONE"), v8::Integer::New(4), attributes);
engine->global()->Set(v8::String::New("XMLHttpRequest"), xmlhttprequest->GetFunction());
- // DOM Exception
- v8::Local<v8::Object> domexception = v8::Object::New();
- domexception->Set(v8::String::New("INDEX_SIZE_ERR"), v8::Integer::New(INDEX_SIZE_ERR), attributes);
- domexception->Set(v8::String::New("DOMSTRING_SIZE_ERR"), v8::Integer::New(DOMSTRING_SIZE_ERR), attributes);
- domexception->Set(v8::String::New("HIERARCHY_REQUEST_ERR"), v8::Integer::New(HIERARCHY_REQUEST_ERR), attributes);
- domexception->Set(v8::String::New("WRONG_DOCUMENT_ERR"), v8::Integer::New(WRONG_DOCUMENT_ERR), attributes);
- domexception->Set(v8::String::New("INVALID_CHARACTER_ERR"), v8::Integer::New(INVALID_CHARACTER_ERR), attributes);
- domexception->Set(v8::String::New("NO_DATA_ALLOWED_ERR"), v8::Integer::New(NO_DATA_ALLOWED_ERR), attributes);
- domexception->Set(v8::String::New("NO_MODIFICATION_ALLOWED_ERR"), v8::Integer::New(NO_MODIFICATION_ALLOWED_ERR), attributes);
- domexception->Set(v8::String::New("NOT_FOUND_ERR"), v8::Integer::New(NOT_FOUND_ERR), attributes);
- domexception->Set(v8::String::New("NOT_SUPPORTED_ERR"), v8::Integer::New(NOT_SUPPORTED_ERR), attributes);
- domexception->Set(v8::String::New("INUSE_ATTRIBUTE_ERR"), v8::Integer::New(INUSE_ATTRIBUTE_ERR), attributes);
- domexception->Set(v8::String::New("INVALID_STATE_ERR"), v8::Integer::New(INVALID_STATE_ERR), attributes);
- domexception->Set(v8::String::New("SYNTAX_ERR"), v8::Integer::New(SYNTAX_ERR), attributes);
- domexception->Set(v8::String::New("INVALID_MODIFICATION_ERR"), v8::Integer::New(INVALID_MODIFICATION_ERR), attributes);
- domexception->Set(v8::String::New("NAMESPACE_ERR"), v8::Integer::New(NAMESPACE_ERR), attributes);
- domexception->Set(v8::String::New("INVALID_ACCESS_ERR"), v8::Integer::New(INVALID_ACCESS_ERR), attributes);
- domexception->Set(v8::String::New("VALIDATION_ERR"), v8::Integer::New(VALIDATION_ERR), attributes);
- domexception->Set(v8::String::New("TYPE_MISMATCH_ERR"), v8::Integer::New(TYPE_MISMATCH_ERR), attributes);
- engine->global()->Set(v8::String::New("DOMException"), domexception);
-
QDeclarativeXMLHttpRequestData *data = new QDeclarativeXMLHttpRequestData;
return data;
}
diff --git a/src/declarative/qml/qintrusivelist.cpp b/src/declarative/qml/qintrusivelist.cpp
index a94f5152a3..dabb893e91 100644
--- a/src/declarative/qml/qintrusivelist.cpp
+++ b/src/declarative/qml/qintrusivelist.cpp
@@ -113,6 +113,12 @@ Remove \a object from the list. \a object must not be null.
*/
/*!
+\fn bool QIntrusiveList::contains(N *object) const
+
+Returns true if the list contains \a object; otherwise returns false.
+*/
+
+/*!
\fn N *QIntrusiveList::first() const
Returns the first entry in this list, or null if the list is empty.
diff --git a/src/declarative/qml/qintrusivelist_p.h b/src/declarative/qml/qintrusivelist_p.h
index c1ea80a767..717b11c344 100644
--- a/src/declarative/qml/qintrusivelist_p.h
+++ b/src/declarative/qml/qintrusivelist_p.h
@@ -68,6 +68,7 @@ public:
inline bool isEmpty() const;
inline void insert(N *n);
inline void remove(N *n);
+ inline bool contains(N *) const;
class iterator {
public:
@@ -202,6 +203,18 @@ void QIntrusiveList<N, member>::remove(N *n)
}
template<class N, QIntrusiveListNode N::*member>
+bool QIntrusiveList<N, member>::contains(N *n) const
+{
+ QIntrusiveListNode *nnode = __first;
+ while (nnode) {
+ if (nodeToN(nnode) == n)
+ return true;
+ nnode = nnode->_next;
+ }
+ return false;
+}
+
+template<class N, QIntrusiveListNode N::*member>
N *QIntrusiveList<N, member>::first() const
{
return __first?nodeToN(__first):0;
diff --git a/src/declarative/qml/v8/qhashedstring.cpp b/src/declarative/qml/v8/qhashedstring.cpp
index 4a23e3b7dd..2e2af98ff4 100644
--- a/src/declarative/qml/v8/qhashedstring.cpp
+++ b/src/declarative/qml/v8/qhashedstring.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/qhashedstring_p.h b/src/declarative/qml/v8/qhashedstring_p.h
index 143bd0b995..e0ca1d466a 100644
--- a/src/declarative/qml/v8/qhashedstring_p.h
+++ b/src/declarative/qml/v8/qhashedstring_p.h
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/qjsconverter_p.h b/src/declarative/qml/v8/qjsconverter_p.h
index 4aec472c7a..c42381bc55 100644
--- a/src/declarative/qml/v8/qjsconverter_p.h
+++ b/src/declarative/qml/v8/qjsconverter_p.h
@@ -28,6 +28,7 @@
#include <QtCore/qglobal.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qregexp.h>
#include <QtCore/qdatetime.h>
@@ -70,7 +71,7 @@ public:
return qstr;
}
- static v8::Handle<v8::String> toString(const QString& string)
+ static v8::Local<v8::String> toString(const QString& string)
{
return v8::String::New(reinterpret_cast<const uint16_t*>(string.data()), string.size());
}
diff --git a/src/declarative/qml/v8/qjsengine.cpp b/src/declarative/qml/v8/qjsengine.cpp
index e80fcb4e7e..3db7fc40e0 100644
--- a/src/declarative/qml/v8/qjsengine.cpp
+++ b/src/declarative/qml/v8/qjsengine.cpp
@@ -52,6 +52,97 @@ Q_DECLARE_METATYPE(QJSValue)
Q_DECLARE_METATYPE(QObjectList)
Q_DECLARE_METATYPE(QList<int>)
+/*!
+ \since 5.0
+ \class QJSEngine
+
+ \brief The QJSEngine class provides an environment for evaluating JavaScript code.
+
+ \ingroup qtjavascript
+ \mainclass
+
+ \section1 Evaluating Scripts
+
+ Use evaluate() to evaluate script code.
+
+ \snippet doc/src/snippets/code/src_script_qjsengine.cpp 0
+
+ evaluate() returns a QJSValue that holds the result of the
+ evaluation. The QJSValue class provides functions for converting
+ the result to various C++ types (e.g. QJSValue::toString()
+ and QJSValue::toNumber()).
+
+ The following code snippet shows how a script function can be
+ defined and then invoked from C++ using QJSValue::call():
+
+ \snippet doc/src/snippets/code/src_script_qjsengine.cpp 1
+
+ As can be seen from the above snippets, a script is provided to the
+ engine in the form of a string. One common way of loading scripts is
+ by reading the contents of a file and passing it to evaluate():
+
+ \snippet doc/src/snippets/code/src_script_qjsengine.cpp 2
+
+ Here we pass the name of the file as the second argument to
+ evaluate(). This does not affect evaluation in any way; the second
+ argument is a general-purpose string that is used to identify the
+ script for debugging purposes (for example, our filename will now
+ show up in any uncaughtExceptionBacktrace() involving the script).
+
+ \section1 Engine Configuration
+
+ The globalObject() function returns the \bold {Global Object}
+ associated with the script engine. Properties of the Global Object
+ are accessible from any script code (i.e. they are global
+ variables). Typically, before evaluating "user" scripts, you will
+ want to configure a script engine by adding one or more properties
+ to the Global Object:
+
+ \snippet doc/src/snippets/code/src_script_qjsengine.cpp 3
+
+ Adding custom properties to the scripting environment is one of the
+ standard means of providing a scripting API that is specific to your
+ application. Usually these custom properties are objects created by
+ the newQObject() or newObject() functions.
+
+ \section1 Script Exceptions
+
+ evaluate() can throw a script exception (e.g. due to a syntax
+ error); in that case, the return value is the value that was thrown
+ (typically an \c{Error} object). You can check whether the
+ evaluation caused an exception by calling hasUncaughtException(). In
+ that case, you can call toString() on the error object to obtain an
+ error message. The current uncaught exception is also available
+ through uncaughtException().
+ Calling clearExceptions() will cause any uncaught exceptions to be
+ cleared.
+
+ \snippet doc/src/snippets/code/src_script_qjsengine.cpp 4
+
+ \section1 Script Object Creation
+
+ Use newObject() to create a JavaScript object; this is the
+ C++ equivalent of the script statement \c{new Object()}. You can use
+ the object-specific functionality in QJSValue to manipulate the
+ script object (e.g. QJSValue::setProperty()). Similarly, use
+ newArray() to create a JavaScript array object. Use newDate() to
+ create a \c{Date} object, and newRegExp() to create a \c{RegExp}
+ object.
+
+ \section1 QObject Integration
+
+ Use newQObject() to wrap a QObject (or subclass)
+ pointer. newQObject() returns a proxy script object; properties,
+ children, and signals and slots of the QObject are available as
+ properties of the proxy object. No binding code is needed because it
+ is done dynamically using the Qt meta object system.
+
+ \snippet doc/src/snippets/code/src_script_qjsengine.cpp 5
+
+ \sa QJSValue, {Making Applications Scriptable}
+
+*/
+
QT_BEGIN_NAMESPACE
@@ -102,6 +193,11 @@ QJSEngine::~QJSEngine()
}
/*!
+ \fn QV8Engine *QJSEngine::handle() const
+ \internal
+*/
+
+/*!
Returns true if the last script evaluation resulted in an uncaught
exception; otherwise returns false.
@@ -201,6 +297,11 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in
return QJSValuePrivate::get(d->evaluate(program, fileName, lineNumber));
}
+/*!
+ Returns a QJSValue of the primitive type Null.
+
+ \sa nullValue()
+*/
QJSValue QJSEngine::nullValue()
{
Q_D(QJSEngine);
@@ -209,6 +310,11 @@ QJSValue QJSEngine::nullValue()
return QJSValuePrivate::get(new QJSValuePrivate(d, v8::Null()));
}
+/*!
+ Returns a QJSValue of the primitive type Undefined.
+
+ \sa nullValue()
+*/
QJSValue QJSEngine::undefinedValue()
{
Q_D(QJSEngine);
@@ -217,6 +323,14 @@ QJSValue QJSEngine::undefinedValue()
return QJSValuePrivate::get(new QJSValuePrivate(d, v8::Undefined()));
}
+/*!
+ Creates a JavaScript object of class Object.
+
+ The prototype of the created object will be the Object
+ prototype object.
+
+ \sa newArray(), QJSValue::setProperty()
+*/
QJSValue QJSEngine::newObject()
{
Q_D(QJSEngine);
@@ -225,6 +339,11 @@ QJSValue QJSEngine::newObject()
return QJSValuePrivate::get(new QJSValuePrivate(d, v8::Object::New()));
}
+/*!
+ Creates a JavaScript object of class Array with the given \a length.
+
+ \sa newObject()
+*/
QJSValue QJSEngine::newArray(uint length)
{
Q_D(QJSEngine);
@@ -234,13 +353,12 @@ QJSValue QJSEngine::newArray(uint length)
}
/*!
- Creates a QtScript object that wraps the given QObject \a
+ Creates a JavaScript object that wraps the given QObject \a
object, using the given \a ownership. The given \a options control
various aspects of the interaction with the resulting script object.
Signals and slots, properties and children of \a object are
- available as properties of the created QJSValue. For more
- information, see the \l{QtScript} documentation.
+ available as properties of the created QJSValue.
If \a object is a null pointer, this function returns nullValue().
@@ -248,8 +366,8 @@ QJSValue QJSEngine::newArray(uint length)
(or its superclass, recursively), the prototype of the new script
object will be set to be that default prototype.
- If the given \a object is deleted outside of QtScript's control, any
- attempt to access the deleted QObject's members through the QtScript
+ If the given \a object is deleted outside of the engine's control, any
+ attempt to access the deleted QObject's members through the JavaScript
wrapper object (either by script code or C++) will result in a
script exception.
@@ -264,7 +382,7 @@ QJSValue QJSEngine::newQObject(QObject *object)
}
/*!
- Creates a QtScript object holding the given variant \a value.
+ Creates a JavaScript object holding the given variant \a value.
If a default prototype has been registered with the meta type id of
\a value, then the prototype of the created object will be that
@@ -282,6 +400,16 @@ QJSValue QJSEngine::newVariant(const QVariant &value)
}
+/*!
+ Returns this engine's Global Object.
+
+ By default, the Global Object contains the built-in objects that are
+ part of \l{ECMA-262}, such as Math, Date and String. Additionally,
+ you can set properties of the Global Object to make your own
+ extensions available to all script code. Non-local variables in
+ script code will be created as properties of the Global Object, as
+ well as local variables in global code.
+*/
QJSValue QJSEngine::globalObject() const
{
Q_D(const QJSEngine);
@@ -290,6 +418,23 @@ QJSValue QJSEngine::globalObject() const
return d->scriptValueFromInternal(d->global());
}
+/*!
+ Converts the given \a value to an object, if such a conversion is
+ possible; otherwise returns an invalid QJSValue. The conversion
+ is performed according to the following table:
+
+ \table
+ \header \o Input Type \o Result
+ \row \o Undefined \o An invalid QJSValue.
+ \row \o Null \o An invalid QJSValue.
+ \row \o Boolean \o A new Boolean object whose internal value is set to the value of the boolean.
+ \row \o Number \o A new Number object whose internal value is set to the value of the number.
+ \row \o String \o A new String object whose internal value is set to the value of the string.
+ \row \o Object \o The result is the object itself (no conversion).
+ \endtable
+
+ \sa newObject()
+*/
QJSValue QJSEngine::toObject(const QJSValue& value)
{
Q_D(QJSEngine);
@@ -299,7 +444,7 @@ QJSValue QJSEngine::toObject(const QJSValue& value)
}
/*!
- Creates a QtScript object of class Date from the given \a value.
+ Creates a JavaScript object of class Date from the given \a value.
\sa QJSValue::toDateTime()
*/
@@ -312,7 +457,7 @@ QJSValue QJSEngine::newDate(const QDateTime &dt)
}
/*!
- Creates a QtScript object of class Date with the given
+ Creates a JavaScript object of class Date with the given
\a value (the number of milliseconds since 01 January 1970,
UTC).
*/
@@ -325,7 +470,7 @@ QJSValue QJSEngine::newDate(double date)
}
/*!
- Creates a QtScript object of class RegExp with the given
+ Creates a JavaScript object of class RegExp with the given
\a regexp.
\sa QJSValue::toRegExp()
@@ -339,7 +484,7 @@ QJSValue QJSEngine::newRegExp(const QRegExp &regexp)
}
/*!
- Creates a QtScript object of class RegExp with the given
+ Creates a JavaScript object of class RegExp with the given
\a pattern and \a flags.
The legal flags are 'g' (global), 'i' (ignore case), and 'm'
@@ -425,6 +570,19 @@ bool QJSEngine::convertV2(const QJSValue &value, int type, void *ptr)
}
}
+/*! \fn QJSValue QJSEngine::toScriptValue(const T &value)
+
+ Creates a QJSValue with the given \a value.
+
+ \sa fromScriptValue()
+*/
+
+/*! \fn T QJSEngine::fromScriptValue(const QJSValue &value)
+
+ Returns the given \a value converted to the template type \c{T}.
+
+ \sa toScriptValue()
+*/
QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qjsengine.h b/src/declarative/qml/v8/qjsengine.h
index 5109cefcf4..759363ab84 100644
--- a/src/declarative/qml/v8/qjsengine.h
+++ b/src/declarative/qml/v8/qjsengine.h
@@ -35,7 +35,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Script)
+QT_MODULE(Declarative)
class QDateTime;
class QV8Engine;
@@ -45,7 +45,7 @@ class QRegExp;
template <typename T>
inline T qjsvalue_cast(const QJSValue &);
-class Q_SCRIPT_EXPORT QJSEngine
+class Q_DECLARATIVE_EXPORT QJSEngine
: public QObject
{
Q_OBJECT
diff --git a/src/declarative/qml/v8/qjsvalue.cpp b/src/declarative/qml/v8/qjsvalue.cpp
index eff7b4321a..bbfae8983c 100644
--- a/src/declarative/qml/v8/qjsvalue.cpp
+++ b/src/declarative/qml/v8/qjsvalue.cpp
@@ -31,23 +31,71 @@
#include <QtCore/qregexp.h>
#include <QtCore/qstring.h>
-QT_BEGIN_NAMESPACE
-
/*!
- Constructs an invalid value.
+ \since 5.0
+ \class QJSValue
+
+ \brief The QJSValue class acts as a container for Qt/JavaScript data types.
+
+ \ingroup qtjavascript
+ \mainclass
+
+ QJSValue supports the types defined in the \l{ECMA-262}
+ standard: The primitive types, which are Undefined, Null, Boolean,
+ Number, and String; and the Object type. Additionally, built-in
+ support is provided for Qt/C++ types such as QVariant and QObject.
+
+ For the object-based types (including Date and RegExp), use the
+ newT() functions in QJSEngine (e.g. QJSEngine::newObject())
+ to create a QJSValue of the desired type. For the primitive types,
+ use one of the QJSValue constructor overloads.
+
+ The methods named isT() (e.g. isBool(), isUndefined()) can be
+ used to test if a value is of a certain type. The methods named
+ toT() (e.g. toBool(), toString()) can be used to convert a
+ QJSValue to another type. You can also use the generic
+ QJSValue_cast() function.
+
+ Object values have zero or more properties which are themselves
+ QJSValues. Use setProperty() to set a property of an object, and
+ call property() to retrieve the value of a property.
+
+ \snippet doc/src/snippets/code/src_script_qjsvalue.cpp 0
+
+ The attributes of a property can be queried by calling the
+ propertyFlags() function.
+
+ If you want to iterate over the properties of a script object, use
+ the QJSValueIterator class.
+
+ Object values have an internal \c{prototype} property, which can be
+ accessed with prototype() and setPrototype().
+
+ Function objects (objects for which isFunction() returns true) can
+ be invoked by calling call(). Constructor functions can be used to
+ construct new objects by calling construct().
+
+ Use equals() or strictlyEquals() to compare a QJSValue to another.
+
+ Note that a QJSValue for which isObject() is true only carries a
+ reference to an actual object; copying the QJSValue will only
+ copy the object reference, not the object itself. If you want to
+ clone an object (i.e. copy an object's properties to another
+ object), you can do so with the help of a \c{for-in} statement in
+ script code, or QJSValueIterator in C++.
+
+ \sa QJSEngine, QJSValueIterator
*/
-QJSValue::QJSValue()
- : d_ptr(InvalidValue())
-{
-}
/*!
- Constructs a new QJSValue with a boolean \a value.
+ \enum QJSValue::SpecialValue
+
+ This enum is used to specify a single-valued type.
+
+ \value UndefinedValue An undefined value.
+
+ \value NullValue A null value.
*/
-QJSValue::QJSValue(bool value)
- : d_ptr(new QJSValuePrivate(value))
-{
-}
/*!
\enum QJSValue::PropertyFlag
@@ -59,17 +107,25 @@ QJSValue::QJSValue(bool value)
\value Undeletable Attempts by Qt Script code to \c{delete} the property will be ignored.
\value SkipInEnumeration The property is not to be enumerated by a \c{for-in} enumeration.
+*/
- \value PropertyGetter The property is defined by a function which will be called to get the property value.
-
- \value PropertySetter The property is defined by a function which will be called to set the property value.
-
- \omitvalue QObjectMember This flag is used to indicate that an existing property is a QObject member (a property or method).
+QT_BEGIN_NAMESPACE
- \value KeepExistingFlags This value is used to indicate to setProperty() that the property's flags should be left unchanged. If the property doesn't exist, the default flags (0) will be used.
+/*!
+ Constructs an invalid value.
+*/
+QJSValue::QJSValue()
+ : d_ptr(InvalidValue())
+{
+}
- \omitvalue UserRange Flags in this range are not used by Qt Script, and can be used for custom purposes.
+/*!
+ Constructs a new QJSValue with a boolean \a value.
*/
+QJSValue::QJSValue(bool value)
+ : d_ptr(new QJSValuePrivate(value))
+{
+}
/*!
Constructs a new QJSValue with a number \a value.
@@ -120,8 +176,6 @@ QJSValue::QJSValue(const QLatin1String &value)
}
/*!
- \fn QJSValue::QJSValue(const QLatin1String &value)
-
Constructs a new QJSValue with a string \a value.
*/
#ifndef QT_NO_CAST_FROM_ASCII
@@ -383,8 +437,6 @@ bool QJSValue::isUndefined() const
/*!
Returns true if this QJSValue is an object of the Error class;
otherwise returns false.
-
- \sa QScriptContext::throwError()
*/
bool QJSValue::isError() const
{
@@ -654,7 +706,7 @@ QVariant QJSValue::toVariant() const
QJSEngine::hasUncaughtException() to determine if an exception
occurred.
- \snippet doc/src/snippets/code/src_script_qscriptvalue.cpp 2
+ \snippet doc/src/snippets/code/src_script_qjsvalue.cpp 1
\sa construct()
*/
@@ -773,7 +825,7 @@ QJSValue& QJSValue::operator=(const QJSValue& other)
toString()) in an attempt to convert the object to a primitive value
(possibly resulting in an uncaught script exception).
- \sa strictlyEquals(), lessThan()
+ \sa strictlyEquals()
*/
bool QJSValue::equals(const QJSValue& other) const
{
@@ -830,9 +882,7 @@ bool QJSValue::instanceOf(const QJSValue &other) const
}
/*!
- Returns the value of this QJSValue's property with the given \a name,
- using the given \a mode to resolve the property.
-
+ Returns the value of this QJSValue's property with the given \a name.
If no such property exists, an invalid QJSValue is returned.
If the property is implemented using a getter function (i.e. has the
@@ -854,8 +904,7 @@ QJSValue QJSValue::property(const QString& name) const
/*!
\overload
- Returns the property at the given \a arrayIndex, using the given \a
- mode to resolve the property.
+ Returns the property at the given \a arrayIndex.
This function is provided for convenience and performance when
working with array objects.
@@ -878,8 +927,7 @@ QJSValue QJSValue::property(quint32 arrayIndex) const
If this QJSValue is not an object, this function does nothing.
If this QJSValue does not already have a property with name \a name,
- a new property is created; the given \a flags then specify how this
- property may be accessed by script code.
+ a new property is created.
If \a value is invalid, the property is removed.
@@ -922,8 +970,7 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value)
}
/*!
- Returns the flags of the property with the given \a name, using the
- given \a mode to resolve the property.
+ Returns the flags of the property with the given \a name.
\sa property()
*/
diff --git a/src/declarative/qml/v8/qjsvalue.h b/src/declarative/qml/v8/qjsvalue.h
index 07276bc694..8b78addd00 100644
--- a/src/declarative/qml/v8/qjsvalue.h
+++ b/src/declarative/qml/v8/qjsvalue.h
@@ -34,7 +34,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Script)
+QT_MODULE(Declarative)
class QJSValue;
class QJSEngine;
@@ -50,7 +50,7 @@ class QJSValuePrivate;
struct QScriptValuePrivatePointerDeleter;
template <class T> class QScriptPassPointer;
-class Q_SCRIPT_EXPORT QJSValue
+class Q_DECLARATIVE_EXPORT QJSValue
{
public:
enum PropertyFlag {
diff --git a/src/declarative/qml/v8/qjsvalue_impl_p.h b/src/declarative/qml/v8/qjsvalue_impl_p.h
index adff6ce945..b0ad7669d7 100644
--- a/src/declarative/qml/v8/qjsvalue_impl_p.h
+++ b/src/declarative/qml/v8/qjsvalue_impl_p.h
@@ -42,6 +42,29 @@
QT_BEGIN_NAMESPACE
+// This template is used indirectly by the Q_GLOBAL_STATIC macro below
+template<>
+class QGlobalStaticDeleter<QJSValuePrivate>
+{
+public:
+ QGlobalStatic<QJSValuePrivate> &globalStatic;
+ QGlobalStaticDeleter(QGlobalStatic<QJSValuePrivate> &_globalStatic)
+ : globalStatic(_globalStatic)
+ {
+ globalStatic.pointer->ref.ref();
+ }
+
+ inline ~QGlobalStaticDeleter()
+ {
+ if (!globalStatic.pointer->ref.deref()) { // Logic copy & paste from SharedDataPointer
+ delete globalStatic.pointer;
+ }
+ globalStatic.pointer = 0;
+ globalStatic.destroyed = true;
+ }
+};
+
+Q_GLOBAL_STATIC(QJSValuePrivate, InvalidValue)
QJSValuePrivate* QJSValuePrivate::get(const QJSValue& q) { Q_ASSERT(q.d_ptr.data()); return q.d_ptr.data(); }
@@ -803,6 +826,8 @@ inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::property(const QStri
{
if (!name.length())
return InvalidValue();
+ if (!isObject())
+ return InvalidValue();
v8::HandleScope handleScope;
return property(QJSConverter::toString(name));
@@ -1013,12 +1038,14 @@ bool QJSValuePrivate::assignEngine(QV8Engine* engine)
/*!
\internal
- reinitialize this value to an invalid value.
+ Invalidates this value.
+
+ Does not remove the value from the engine's list of
+ registered values; that's the responsibility of the caller.
*/
-void QJSValuePrivate::reinitialize()
+void QJSValuePrivate::invalidate()
{
if (isJSBased()) {
- m_engine->unregisterValue(this);
m_value.Dispose();
m_value.Clear();
} else if (isStringBased()) {
@@ -1028,26 +1055,6 @@ void QJSValuePrivate::reinitialize()
m_state = Invalid;
}
-/*!
- \internal
- reinitialize this value to an JSValue.
-*/
-void QJSValuePrivate::reinitialize(QV8Engine* engine, v8::Handle<v8::Value> value)
-{
- Q_ASSERT_X(this != InvalidValue(), Q_FUNC_INFO, "static invalid can't be reinitialized to a different value");
- if (isJSBased()) {
- m_value.Dispose();
- // avoid double registration
- m_engine->unregisterValue(this);
- } else if (isStringBased()) {
- delete u.m_string;
- }
- m_engine = engine;
- m_state = JSValue;
- m_value = v8::Persistent<v8::Value>::New(value);
- m_engine->registerValue(this);
-}
-
QV8Engine* QJSValuePrivate::engine() const
{
return m_engine;
diff --git a/src/declarative/qml/v8/qjsvalue_p.h b/src/declarative/qml/v8/qjsvalue_p.h
index 7b2a001f97..09cd38b0bf 100644
--- a/src/declarative/qml/v8/qjsvalue_p.h
+++ b/src/declarative/qml/v8/qjsvalue_p.h
@@ -43,19 +43,20 @@
#include <QtCore/qvarlengtharray.h>
#include <qdebug.h>
-#include "qscripttools_p.h"
+#include <private/qintrusivelist_p.h>
#include "qscriptshareddata_p.h"
#include "qjsvalue.h"
QT_BEGIN_NAMESPACE
+class QV8Engine;
+
/*!
\internal
\class QJSValuePrivate
*/
class QJSValuePrivate
: public QSharedData
- , public QScriptLinkedNode
{
public:
inline QJSValuePrivate();
@@ -79,8 +80,7 @@ public:
inline QJSValuePrivate(QV8Engine *engine, const QString& value);
inline QJSValuePrivate(QV8Engine *engine, QJSValue::SpecialValue value);
inline QJSValuePrivate(QV8Engine *engine, v8::Handle<v8::Value>);
- inline void reinitialize();
- inline void reinitialize(QV8Engine *engine, v8::Handle<v8::Value> value);
+ inline void invalidate();
inline bool toBool() const;
inline double toNumber() const;
@@ -147,6 +147,7 @@ public:
inline operator v8::Handle<v8::Object>() const;
inline v8::Handle<v8::Value> asV8Value(QV8Engine *engine);
private:
+ QIntrusiveListNode m_node;
QV8Engine *m_engine;
// Please, update class documentation when you change the enum.
@@ -182,32 +183,10 @@ private:
inline bool isNumberBased() const;
inline bool isStringBased() const;
inline bool prepareArgumentsForCall(v8::Handle<v8::Value> argv[], const QJSValueList& arguments) const;
-};
-// This template is used indirectly by the Q_GLOBAL_STATIC macro below
-template<>
-class QGlobalStaticDeleter<QJSValuePrivate>
-{
-public:
- QGlobalStatic<QJSValuePrivate> &globalStatic;
- QGlobalStaticDeleter(QGlobalStatic<QJSValuePrivate> &_globalStatic)
- : globalStatic(_globalStatic)
- {
- globalStatic.pointer->ref.ref();
- }
-
- inline ~QGlobalStaticDeleter()
- {
- if (!globalStatic.pointer->ref.deref()) { // Logic copy & paste from SharedDataPointer
- delete globalStatic.pointer;
- }
- globalStatic.pointer = 0;
- globalStatic.destroyed = true;
- }
+ friend class QV8Engine;
};
-Q_GLOBAL_STATIC(QJSValuePrivate, InvalidValue)
-
QT_END_NAMESPACE
#endif
diff --git a/src/declarative/qml/v8/qjsvalueiterator.cpp b/src/declarative/qml/v8/qjsvalueiterator.cpp
index ca9123f0c0..76a43c9475 100644
--- a/src/declarative/qml/v8/qjsvalueiterator.cpp
+++ b/src/declarative/qml/v8/qjsvalueiterator.cpp
@@ -22,6 +22,7 @@
****************************************************************************/
#include "qjsvalueiterator.h"
+#include "qjsvalueiterator_p.h"
#include "qscriptisolate_p.h"
#include "qjsvalue_p.h"
@@ -35,7 +36,7 @@ QT_BEGIN_NAMESPACE
\brief The QJSValueIterator class provides a Java-style iterator for QJSValue.
- \ingroup script
+ \ingroup qtjavascript
The QJSValueIterator constructor takes a QJSValue as
@@ -43,169 +44,28 @@ QT_BEGIN_NAMESPACE
beginning of the sequence of properties. Here's how to iterate over
all the properties of a QJSValue:
- \snippet doc/src/snippets/code/src_script_QJSValueIterator.cpp 0
+ \snippet doc/src/snippets/code/src_script_qjsvalueiterator.cpp 0
- The next() advances the iterator. The name(), value() and flags()
- functions return the name, value and flags of the last item that was
+ The next() advances the iterator. The name() and value()
+ functions return the name and value of the last item that was
jumped over.
- If you want to remove properties as you iterate over the
- QJSValue, use remove(). If you want to modify the value of a
- property, use setValue().
-
Note that QJSValueIterator only iterates over the QJSValue's
own properties; i.e. it does not follow the prototype chain. You can
use a loop like this to follow the prototype chain:
- \snippet doc/src/snippets/code/src_script_QJSValueIterator.cpp 1
+ \snippet doc/src/snippets/code/src_script_qjsvalueiterator.cpp 1
Note that QJSValueIterator will not automatically skip over
properties that have the QJSValue::SkipInEnumeration flag set;
that flag only affects iteration in script code. If you want, you
can skip over such properties with code like the following:
- \snippet doc/src/snippets/code/src_script_QJSValueIterator.cpp 2
+ \snippet doc/src/snippets/code/src_script_qjsvalueiterator.cpp 2
\sa QJSValue::property()
*/
-using v8::Persistent;
-using v8::Local;
-using v8::Array;
-using v8::String;
-using v8::Handle;
-using v8::Object;
-using v8::Value;
-
-// FIXME (Qt5) This class should be refactored. It should use the common Iterator interface.
-// FIXME it could be faster!
-class QJSValueIteratorPrivate {
-public:
- inline QJSValueIteratorPrivate(const QJSValuePrivate* value);
- inline ~QJSValueIteratorPrivate();
-
- inline bool hasNext() const;
- inline bool next();
-
- inline QString name() const;
-
- inline QScriptPassPointer<QJSValuePrivate> value() const;
-
- inline bool isValid() const;
- inline QV8Engine* engine() const;
-private:
- Q_DISABLE_COPY(QJSValueIteratorPrivate)
- //void dump(QString) const;
-
- QScriptSharedDataPointer<QJSValuePrivate> m_object;
- QList<v8::Persistent<v8::String> > m_names;
- QMutableListIterator<v8::Persistent<v8::String> > m_iterator;
-};
-
-inline QJSValueIteratorPrivate::QJSValueIteratorPrivate(const QJSValuePrivate* value)
- : m_object(const_cast<QJSValuePrivate*>(value))
- , m_iterator(m_names)
-{
- Q_ASSERT(value);
- QV8Engine *engine = m_object->engine();
- QScriptIsolate api(engine);
- if (!m_object->isObject())
- m_object = 0;
- else {
- v8::HandleScope scope;
- Handle<Value> tmp = *value;
- Handle<Object> obj = Handle<Object>::Cast(tmp);
- Local<Array> names;
-
- // FIXME we need newer V8!
- //names = obj->GetOwnPropertyNames();
- names = engine->getOwnPropertyNames(obj);
-
- // it is suboptimal, it would be better to write iterator instead
- uint32_t count = names->Length();
- Local<String> name;
- m_names.reserve(count); // The count is the maximal count of values.
- for (uint32_t i = count - 1; i < count; --i) {
- name = names->Get(i)->ToString();
- m_names.append(v8::Persistent<v8::String>::New(name));
- }
-
- // Reinitialize the iterator.
- m_iterator = m_names;
- }
-}
-
-inline QJSValueIteratorPrivate::~QJSValueIteratorPrivate()
-{
- QMutableListIterator<v8::Persistent<v8::String> > it = m_names;
- //FIXME: we need register this QJSVAlueIterator
- if (engine()) {
- while (it.hasNext()) {
- it.next().Dispose();
- }
- } else {
- // FIXME leak ?
- }
-}
-
-inline bool QJSValueIteratorPrivate::hasNext() const
-{
- //dump("hasNext()");
- return isValid()
- ? m_iterator.hasNext() : false;
-}
-
-inline bool QJSValueIteratorPrivate::next()
-{
- //dump("next();");
- if (m_iterator.hasNext()) {
- m_iterator.next();
- return true;
- }
- return false;
-}
-
-inline QString QJSValueIteratorPrivate::name() const
-{
- //dump("name");
- if (!isValid())
- return QString();
-
- return QJSConverter::toString(m_iterator.value());
-}
-
-inline QScriptPassPointer<QJSValuePrivate> QJSValueIteratorPrivate::value() const
-{
- //dump("value()");
- if (!isValid())
- return InvalidValue();
-
- return m_object->property(m_iterator.value());
-}
-
-inline bool QJSValueIteratorPrivate::isValid() const
-{
- bool result = m_object ? m_object->isValid() : false;
- // We know that if this object is still valid then it is an object
- // if this assumption is not correct then some other logic in this class
- // have to be changed too.
- Q_ASSERT(!result || m_object->isObject());
- return result;
-}
-
-inline QV8Engine* QJSValueIteratorPrivate::engine() const
-{
- return m_object ? m_object->engine() : 0;
-}
-
-//void QJSValueIteratorPrivate::dump(QString fname) const
-//{
-// qDebug() << " *** " << fname << " ***";
-// foreach (Persistent<String> name, m_names) {
-// qDebug() << " - " << QJSConverter::toString(name);
-// }
-//}
-
/*!
Constructs an iterator for traversing \a object. The iterator is
set to be at the front of the sequence of properties (before the
@@ -226,7 +86,7 @@ QJSValueIterator::~QJSValueIterator()
(i.e. the iterator is \e not at the back of the property sequence);
otherwise returns false.
- \sa next(), hasPrevious()
+ \sa next()
*/
bool QJSValueIterator::hasNext() const
{
@@ -237,11 +97,14 @@ bool QJSValueIterator::hasNext() const
/*!
Advances the iterator by one position.
+ Returns true if there is at least one item ahead of the iterator
+ (i.e. the iterator is \e not at the back of the property sequence);
+ otherwise returns false.
Calling this function on an iterator located at the back of the
container leads to undefined results.
- \sa hasNext(), previous(), name()
+ \sa hasNext(), name()
*/
bool QJSValueIterator::next()
{
@@ -252,9 +115,9 @@ bool QJSValueIterator::next()
/*!
Returns the name of the last property that was jumped over using
- next() or previous().
+ next().
- \sa value(), flags()
+ \sa value()
*/
QString QJSValueIterator::name() const
{
@@ -266,9 +129,9 @@ QString QJSValueIterator::name() const
/*!
Returns the value of the last property that was jumped over using
- next() or previous().
+ next().
- \sa setValue(), name()
+ \sa name()
*/
QJSValue QJSValueIterator::value() const
{
diff --git a/src/declarative/qml/v8/qjsvalueiterator.h b/src/declarative/qml/v8/qjsvalueiterator.h
index 1ec4d4b63b..575421d33e 100644
--- a/src/declarative/qml/v8/qjsvalueiterator.h
+++ b/src/declarative/qml/v8/qjsvalueiterator.h
@@ -31,12 +31,12 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Script)
+QT_MODULE(Declarative)
class QString;
class QJSValueIteratorPrivate;
-class Q_SCRIPT_EXPORT QJSValueIterator
+class Q_DECLARATIVE_EXPORT QJSValueIterator
{
public:
QJSValueIterator(const QJSValue &value);
diff --git a/src/declarative/qml/v8/qjsvalueiterator_impl_p.h b/src/declarative/qml/v8/qjsvalueiterator_impl_p.h
new file mode 100644
index 0000000000..68075e55f3
--- /dev/null
+++ b/src/declarative/qml/v8/qjsvalueiterator_impl_p.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QJSVALUEITERATOR_IMPL_P_H
+#define QJSVALUEITERATOR_IMPL_P_H
+
+#include <qjsvalueiterator_p.h>
+#include <qv8engine_p.h>
+#include <qjsconverter_p.h>
+
+inline QJSValueIteratorPrivate::QJSValueIteratorPrivate(const QJSValuePrivate* value)
+ : m_object(const_cast<QJSValuePrivate*>(value))
+ , m_index(0)
+ , m_count(0)
+{
+ Q_ASSERT(value);
+ QV8Engine *engine = m_object->engine();
+ if (!m_object->isObject())
+ m_object = 0;
+ else {
+ QScriptIsolate api(engine, QScriptIsolate::NotNullEngine);
+ v8::HandleScope scope;
+
+ v8::Handle<v8::Value> tmp = *value;
+ v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(tmp);
+ v8::Local<v8::Array> names;
+
+ // FIXME we need newer V8!
+ //names = obj->GetOwnPropertyNames();
+ names = engine->getOwnPropertyNames(obj);
+ m_names = v8::Persistent<v8::Array>::New(names);
+ m_count = names->Length();
+
+ engine->registerValueIterator(this);
+ }
+}
+
+inline QJSValueIteratorPrivate::~QJSValueIteratorPrivate()
+{
+ if (isValid()) {
+ engine()->unregisterValueIterator(this);
+ m_names.Dispose();
+ }
+}
+
+inline void QJSValueIteratorPrivate::invalidate()
+{
+ m_names.Dispose();
+ m_object.reset();
+ m_index = 0;
+ m_count = 0;
+}
+
+inline bool QJSValueIteratorPrivate::hasNext() const
+{
+ return isValid() ? m_index < m_count : false;
+}
+
+inline bool QJSValueIteratorPrivate::next()
+{
+ if (hasNext()) {
+ ++m_index;
+ return true;
+ }
+ return false;
+}
+
+inline QString QJSValueIteratorPrivate::name() const
+{
+ if (!isValid())
+ return QString();
+
+ v8::HandleScope handleScope;
+ return QJSConverter::toString(m_names->Get(m_index - 1)->ToString());
+}
+
+inline QScriptPassPointer<QJSValuePrivate> QJSValueIteratorPrivate::value() const
+{
+ if (!isValid())
+ return InvalidValue();
+
+ v8::HandleScope handleScope;
+ return m_object->property(m_names->Get(m_index - 1)->ToString());
+}
+
+inline bool QJSValueIteratorPrivate::isValid() const
+{
+ bool result = m_object ? m_object->isValid() : false;
+ // We know that if this object is still valid then it is an object
+ // if this assumption is not correct then some other logic in this class
+ // have to be changed too.
+ Q_ASSERT(!result || m_object->isObject());
+ return result;
+}
+
+inline QV8Engine* QJSValueIteratorPrivate::engine() const
+{
+ return m_object ? m_object->engine() : 0;
+}
+
+#endif // QJSVALUEITERATOR_IMPL_P_H
diff --git a/src/declarative/qml/v8/qjsvalueiterator_p.h b/src/declarative/qml/v8/qjsvalueiterator_p.h
new file mode 100644
index 0000000000..6113d3dd4f
--- /dev/null
+++ b/src/declarative/qml/v8/qjsvalueiterator_p.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QJSVALUEITERATOR_P_H
+#define QJSVALUEITERATOR_P_H
+
+#include <private/qintrusivelist_p.h>
+#include "qjsvalue_p.h"
+
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+
+class QJSValueIteratorPrivate
+{
+public:
+ inline QJSValueIteratorPrivate(const QJSValuePrivate* value);
+ inline ~QJSValueIteratorPrivate();
+
+ inline bool hasNext() const;
+ inline bool next();
+
+ inline QString name() const;
+
+ inline QScriptPassPointer<QJSValuePrivate> value() const;
+
+ inline bool isValid() const;
+ inline QV8Engine* engine() const;
+
+ inline void invalidate();
+private:
+ Q_DISABLE_COPY(QJSValueIteratorPrivate)
+
+ QIntrusiveListNode m_node;
+ QScriptSharedDataPointer<QJSValuePrivate> m_object;
+ v8::Persistent<v8::Array> m_names;
+ uint32_t m_index;
+ uint32_t m_count;
+
+ friend class QV8Engine;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QJSVALUEITERATOR_P_H
diff --git a/src/declarative/qml/v8/qscript_impl_p.h b/src/declarative/qml/v8/qscript_impl_p.h
index e66b561efe..d197d9fd6b 100644
--- a/src/declarative/qml/v8/qscript_impl_p.h
+++ b/src/declarative/qml/v8/qscript_impl_p.h
@@ -37,5 +37,6 @@
#include "qv8engine_impl_p.h"
#include "qjsvalue_impl_p.h"
+#include "qjsvalueiterator_impl_p.h"
#endif //QSCRIPT_IMPL_P_H
diff --git a/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h b/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h
index c46d0e37a0..c0a761f518 100644
--- a/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h
+++ b/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h
@@ -49,7 +49,7 @@ class QV8Engine;
class QScriptOriginalGlobalObject
{
public:
- inline QScriptOriginalGlobalObject(const QV8Engine *engine, v8::Handle<v8::Context> context);
+ inline QScriptOriginalGlobalObject(v8::Handle<v8::Context> context);
inline void destroy();
inline QJSValue::PropertyFlags getPropertyFlags(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property);
@@ -63,7 +63,7 @@ private:
v8::Persistent<v8::Object> m_globalObject;
};
-QScriptOriginalGlobalObject::QScriptOriginalGlobalObject(const QV8Engine *engine, v8::Handle<v8::Context> context)
+QScriptOriginalGlobalObject::QScriptOriginalGlobalObject(v8::Handle<v8::Context> context)
{
// Please notice that engine is not fully initialized at this point.
diff --git a/src/declarative/qml/v8/qscripttools_p.h b/src/declarative/qml/v8/qscripttools_p.h
index f74fbab83f..c8dace0b9f 100644
--- a/src/declarative/qml/v8/qscripttools_p.h
+++ b/src/declarative/qml/v8/qscripttools_p.h
@@ -36,180 +36,32 @@
#ifndef QSCRIPTTOOLS_P_H
#define QSCRIPTTOOLS_P_H
-#include <qdebug.h>
+#include <private/qintrusivelist_p.h>
QT_BEGIN_NAMESPACE
-template<class T>
-class QScriptBagContainer;
-
-/*!
- \internal
- \interface
- Helper class for a container. The purpuse of it is to add two pointer properties to a class
- inheriting this class without bloating an interface.
-
- This class exist only as a memory storage implementation. The only way to use it is to inherit it.
-*/
-class QScriptLinkedNode
+template<class N, QIntrusiveListNode N::*member>
+class QScriptIntrusiveList : public QIntrusiveList<N, member>
{
-protected:
- QScriptLinkedNode()
- : m_next(0)
- , m_prev(0)
- {}
-
- ~QScriptLinkedNode()
- {
- Q_ASSERT_X(!isUsed(), Q_FUNC_INFO, "Destorying QScriptLinkedNode instance that still is in a container");
- }
-
-private:
- bool isUsed() const
- {
- return m_next || m_prev;
- }
-
-#if defined(Q_NO_TEMPLATE_FRIENDS)
public:
-#else
- template<class T>
- friend class QScriptBagContainer;
-#endif
- QScriptLinkedNode *m_next;
- QScriptLinkedNode *m_prev;
+ inline void insert(N *n);
+ inline void remove(N *n);
};
-/*!
- \internal
- The QScriptBagContainer is a simple, low level, set like container for a pointer type castable to
- QScriptLinkedNode*.
- Algorithms complexity:
- put: O(1)
- get: O(1)
- forEach: O(n)
- \note This container doesn't take ownership of pointed values.
- \attention All values have to be unique.
-*/
-template<class T>
-class QScriptBagContainer
+template<class N, QIntrusiveListNode N::*member>
+void QScriptIntrusiveList<N, member>::insert(N *n)
{
-public:
- QScriptBagContainer()
- : m_first(0)
- {}
-
- /*!
- \internal
- Add a this \a value to this container
- */
- void insert(T* value)
- {
- //dump(Q_FUNC_INFO, value);
- Q_ASSERT_X(!contains(value), Q_FUNC_INFO, "Can't insert a value which is in the bag already");
- QScriptLinkedNode* v = static_cast<QScriptLinkedNode*>(value);
- Q_ASSERT(v);
- Q_ASSERT_X(!v->m_next && !v->m_prev, Q_FUNC_INFO, "Can't insert a value which is in an another bag");
-
- if (m_first)
- m_first->m_prev = v;
-
- v->m_next = m_first;
- v->m_prev = 0;
- m_first = v;
- }
-
- /*!
- \internal
- Remove this \a value from this container
- */
- void remove(T* value)
- {
- //dump(Q_FUNC_INFO, value);
- QScriptLinkedNode* v = static_cast<QScriptLinkedNode*>(value);
- Q_ASSERT(v);
+ Q_ASSERT_X(!contains(n), Q_FUNC_INFO, "Can't insert a value which is in the list already");
+ Q_ASSERT_X(!(n->*member).isInList(), Q_FUNC_INFO, "Can't insert a value which is in another list");
+ QIntrusiveList<N, member>::insert(n);
+}
- if (!v->m_next && !v->m_prev && m_first != v) {
- // ignore that value as it is not registered at all
- // FIXME: That may be optimized out if unregister call is removed from ~QtDataBase
- return;
- }
-
- Q_ASSERT_X(contains(value), Q_FUNC_INFO, "Can't remove a value which is not in the bag");
- Q_ASSERT(v->m_prev || (m_first == v && !v->m_prev));
-
- if (v->m_next)
- v->m_next->m_prev= v->m_prev;
-
- if (v->m_prev)
- v->m_prev->m_next = v->m_next;
- else
- m_first = v->m_next;
- // reset removed value
- v->m_next = v->m_prev = 0;
- }
-
- /*!
- \internal
- Call \a fun for each element in this container. Fun should accept T* as a parameter.
- \note In general it is not allowed to change this container by calling put() or get() unless
- given value is the same as currently procceded by forEach.
- */
- template<class Functor>
- void forEach(Functor fun)
- {
- //dump(Q_FUNC_INFO);
- QScriptLinkedNode *i = m_first;
- QScriptLinkedNode *tmp;
- while (i) {
- tmp = i;
- i = i->m_next;
- fun(static_cast<T*>(tmp));
- }
- }
-
- /*!
- \internal
- Clear this container.
- */
- void clear()
- {
- m_first = 0;
- }
-
- /*!
- \internal
- Returns true if this container is empty; false otherwise.
- */
- bool isEmpty() const
- {
- return !m_first;
- }
-
-// void dump(const char* msg, T* obj = 0) const
-// {
-// qDebug() << msg << obj;
-// qDebug() << m_first;
-// QScriptLinkedNode *i = m_first;
-// while (i) {
-// qDebug() <<" - " << i << "(" << i->m_prev << ", " << i->m_next <<")";
-// i = i->m_next;
-// }
-// }
-
-private:
- bool contains(T *value) const
- {
- QScriptLinkedNode *i = m_first;
- while (i) {
- if (static_cast<T*>(i) == value)
- return true;
- i = i->m_next;
- }
- return false;
- }
- QScriptLinkedNode *m_first;
-};
+template<class N, QIntrusiveListNode N::*member>
+void QScriptIntrusiveList<N, member>::remove(N *n)
+{
+ Q_ASSERT_X(contains(n), Q_FUNC_INFO, "Can't remove a value which is not in the list");
+ QIntrusiveList<N, member>::remove(n);
+}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8_p.h b/src/declarative/qml/v8/qv8_p.h
index 6aeb6f6458..8df007e804 100644
--- a/src/declarative/qml/v8/qv8_p.h
+++ b/src/declarative/qml/v8/qv8_p.h
@@ -1 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "../../../3rdparty/v8/include/v8.h"
diff --git a/src/declarative/qml/v8/qv8bindings.cpp b/src/declarative/qml/v8/qv8bindings.cpp
index c45274a97f..3c98af2951 100644
--- a/src/declarative/qml/v8/qv8bindings.cpp
+++ b/src/declarative/qml/v8/qv8bindings.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/qv8bindings_p.h b/src/declarative/qml/v8/qv8bindings_p.h
index f8a9407ed8..b387a50df3 100644
--- a/src/declarative/qml/v8/qv8bindings_p.h
+++ b/src/declarative/qml/v8/qv8bindings_p.h
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/qv8contextwrapper.cpp b/src/declarative/qml/v8/qv8contextwrapper.cpp
index 4984102ba2..f41c994a0d 100644
--- a/src/declarative/qml/v8/qv8contextwrapper.cpp
+++ b/src/declarative/qml/v8/qv8contextwrapper.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/qv8debug_p.h b/src/declarative/qml/v8/qv8debug_p.h
new file mode 100644
index 0000000000..51208aac8e
--- /dev/null
+++ b/src/declarative/qml/v8/qv8debug_p.h
@@ -0,0 +1 @@
+#include "../../../3rdparty/v8/include/v8-debug.h"
diff --git a/src/declarative/qml/v8/qv8domerrors.cpp b/src/declarative/qml/v8/qv8domerrors.cpp
new file mode 100644
index 0000000000..e739e4a7bd
--- /dev/null
+++ b/src/declarative/qml/v8/qv8domerrors.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8domerrors_p.h"
+#include "qv8engine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+void qt_add_domexceptions(QV8Engine *engine)
+{
+ // DOM Exception
+ v8::PropertyAttribute attributes = (v8::PropertyAttribute)(v8::ReadOnly | v8::DontEnum | v8::DontDelete);
+
+ v8::Local<v8::Object> domexception = v8::Object::New();
+ domexception->Set(v8::String::New("INDEX_SIZE_ERR"), v8::Integer::New(DOMEXCEPTION_INDEX_SIZE_ERR), attributes);
+ domexception->Set(v8::String::New("DOMSTRING_SIZE_ERR"), v8::Integer::New(DOMEXCEPTION_DOMSTRING_SIZE_ERR), attributes);
+ domexception->Set(v8::String::New("HIERARCHY_REQUEST_ERR"), v8::Integer::New(DOMEXCEPTION_HIERARCHY_REQUEST_ERR), attributes);
+ domexception->Set(v8::String::New("WRONG_DOCUMENT_ERR"), v8::Integer::New(DOMEXCEPTION_WRONG_DOCUMENT_ERR), attributes);
+ domexception->Set(v8::String::New("INVALID_CHARACTER_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_CHARACTER_ERR), attributes);
+ domexception->Set(v8::String::New("NO_DATA_ALLOWED_ERR"), v8::Integer::New(DOMEXCEPTION_NO_DATA_ALLOWED_ERR), attributes);
+ domexception->Set(v8::String::New("NO_MODIFICATION_ALLOWED_ERR"), v8::Integer::New(DOMEXCEPTION_NO_MODIFICATION_ALLOWED_ERR), attributes);
+ domexception->Set(v8::String::New("NOT_FOUND_ERR"), v8::Integer::New(DOMEXCEPTION_NOT_FOUND_ERR), attributes);
+ domexception->Set(v8::String::New("NOT_SUPPORTED_ERR"), v8::Integer::New(DOMEXCEPTION_NOT_SUPPORTED_ERR), attributes);
+ domexception->Set(v8::String::New("INUSE_ATTRIBUTE_ERR"), v8::Integer::New(DOMEXCEPTION_INUSE_ATTRIBUTE_ERR), attributes);
+ domexception->Set(v8::String::New("INVALID_STATE_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_STATE_ERR), attributes);
+ domexception->Set(v8::String::New("SYNTAX_ERR"), v8::Integer::New(DOMEXCEPTION_SYNTAX_ERR), attributes);
+ domexception->Set(v8::String::New("INVALID_MODIFICATION_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_MODIFICATION_ERR), attributes);
+ domexception->Set(v8::String::New("NAMESPACE_ERR"), v8::Integer::New(DOMEXCEPTION_NAMESPACE_ERR), attributes);
+ domexception->Set(v8::String::New("INVALID_ACCESS_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_ACCESS_ERR), attributes);
+ domexception->Set(v8::String::New("VALIDATION_ERR"), v8::Integer::New(DOMEXCEPTION_VALIDATION_ERR), attributes);
+ domexception->Set(v8::String::New("TYPE_MISMATCH_ERR"), v8::Integer::New(DOMEXCEPTION_TYPE_MISMATCH_ERR), attributes);
+ engine->global()->Set(v8::String::New("DOMException"), domexception);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8domerrors_p.h b/src/declarative/qml/v8/qv8domerrors_p.h
new file mode 100644
index 0000000000..ef8ab28c12
--- /dev/null
+++ b/src/declarative/qml/v8/qv8domerrors_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8DOMERRORS_P_H
+#define QV8DOMERRORS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+// From DOM-Level-3-Core spec
+// http://www.w3.org/TR/DOM-Level-3-Core/core.html
+#define DOMEXCEPTION_INDEX_SIZE_ERR 1
+#define DOMEXCEPTION_DOMSTRING_SIZE_ERR 2
+#define DOMEXCEPTION_HIERARCHY_REQUEST_ERR 3
+#define DOMEXCEPTION_WRONG_DOCUMENT_ERR 4
+#define DOMEXCEPTION_INVALID_CHARACTER_ERR 5
+#define DOMEXCEPTION_NO_DATA_ALLOWED_ERR 6
+#define DOMEXCEPTION_NO_MODIFICATION_ALLOWED_ERR 7
+#define DOMEXCEPTION_NOT_FOUND_ERR 8
+#define DOMEXCEPTION_NOT_SUPPORTED_ERR 9
+#define DOMEXCEPTION_INUSE_ATTRIBUTE_ERR 10
+#define DOMEXCEPTION_INVALID_STATE_ERR 11
+#define DOMEXCEPTION_SYNTAX_ERR 12
+#define DOMEXCEPTION_INVALID_MODIFICATION_ERR 13
+#define DOMEXCEPTION_NAMESPACE_ERR 14
+#define DOMEXCEPTION_INVALID_ACCESS_ERR 15
+#define DOMEXCEPTION_VALIDATION_ERR 16
+#define DOMEXCEPTION_TYPE_MISMATCH_ERR 17
+
+#define V8THROW_DOM(error, string) { \
+ v8::Local<v8::Value> v = v8::Exception::Error(v8::String::New(string)); \
+ v->ToObject()->Set(v8::String::New("code"), v8::Integer::New(error)); \
+ v8::ThrowException(v); \
+ return v8::Handle<v8::Value>(); \
+}
+class QV8Engine;
+void qt_add_domexceptions(QV8Engine *engine);
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV8DOMERRORS_P_H
diff --git a/src/declarative/qml/v8/qv8engine.cpp b/src/declarative/qml/v8/qv8engine.cpp
index acbfb92b15..4f5caa13f4 100644
--- a/src/declarative/qml/v8/qv8engine.cpp
+++ b/src/declarative/qml/v8/qv8engine.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
@@ -42,6 +42,7 @@
#include "qv8engine_p.h"
#include "qv8contextwrapper_p.h"
+#include "qv8valuetypewrapper_p.h"
#include "qv8include_p.h"
#include "../../../3rdparty/javascriptcore/DateMath.h"
@@ -63,6 +64,7 @@
#include <private/qdeclarativesqldatabase_p.h>
#include "qscript_impl_p.h"
+#include "qv8domerrors_p.h"
Q_DECLARE_METATYPE(QJSValue)
Q_DECLARE_METATYPE(QList<int>)
@@ -87,10 +89,20 @@ static bool ObjectComparisonCallback(v8::Local<v8::Object> lhs, v8::Local<v8::Ob
QV8ObjectResource::ResourceType rhst = rhsr->resourceType();
switch (lhst) {
+ case QV8ObjectResource::ValueTypeType:
+ if (rhst == QV8ObjectResource::ValueTypeType) {
+ return lhsr->engine->valueTypeWrapper()->isEqual(lhsr, lhsr->engine->valueTypeWrapper()->toVariant(rhsr));
+ } else if (rhst == QV8ObjectResource::VariantType) {
+ return lhsr->engine->valueTypeWrapper()->isEqual(lhsr, lhsr->engine->variantWrapper()->toVariant(rhsr));
+ }
+ break;
case QV8ObjectResource::VariantType:
- if (rhst == QV8ObjectResource::VariantType)
+ if (rhst == QV8ObjectResource::VariantType) {
return lhsr->engine->variantWrapper()->toVariant(lhsr) ==
lhsr->engine->variantWrapper()->toVariant(rhsr);
+ } else if (rhst == QV8ObjectResource::ValueTypeType) {
+ return rhsr->engine->valueTypeWrapper()->isEqual(rhsr, rhsr->engine->variantWrapper()->toVariant(lhsr));
+ }
break;
default:
break;
@@ -105,7 +117,7 @@ QV8Engine::QV8Engine(QJSEngine* qq, QJSEngine::ContextOwnership ownership)
, m_engine(0)
, m_ownsV8Context(ownership == QJSEngine::CreateNewContext)
, m_context((ownership == QJSEngine::CreateNewContext) ? v8::Context::New() : v8::Persistent<v8::Context>::New(v8::Context::GetCurrent()))
- , m_originalGlobalObject(this, m_context)
+ , m_originalGlobalObject(m_context)
, m_xmlHttpRequestData(0)
, m_sqlDatabaseData(0)
, m_listModelData(0)
@@ -265,55 +277,6 @@ static v8::Handle<v8::Object> objectFromVariantMap(QV8Engine *engine, const QVar
Q_CORE_EXPORT QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
-// Converts a QRegExp to a JS RegExp.
-// The conversion is not 100% exact since ECMA regexp and QRegExp
-// have different semantics/flags, but we try to do our best.
-static v8::Handle<v8::RegExp> regexpFromQRegExp(QV8Engine *engine, const QRegExp &re)
-{
- // Convert the pattern to a ECMAScript pattern.
- QString pattern = qt_regexp_toCanonical(re.pattern(), re.patternSyntax());
- if (re.isMinimal()) {
- QString ecmaPattern;
- int len = pattern.length();
- ecmaPattern.reserve(len);
- int i = 0;
- const QChar *wc = pattern.unicode();
- bool inBracket = false;
- while (i < len) {
- QChar c = wc[i++];
- ecmaPattern += c;
- switch (c.unicode()) {
- case '?':
- case '+':
- case '*':
- case '}':
- if (!inBracket)
- ecmaPattern += QLatin1Char('?');
- break;
- case '\\':
- if (i < len)
- ecmaPattern += wc[i++];
- break;
- case '[':
- inBracket = true;
- break;
- case ']':
- inBracket = false;
- break;
- default:
- break;
- }
- }
- pattern = ecmaPattern;
- }
-
- int flags = v8::RegExp::kNone;
- if (re.caseSensitivity() == Qt::CaseInsensitive)
- flags |= v8::RegExp::kIgnoreCase;
-
- return v8::RegExp::New(engine->toString(pattern), static_cast<v8::RegExp::Flags>(flags));
-}
-
v8::Handle<v8::Value> QV8Engine::fromVariant(const QVariant &variant)
{
int type = variant.userType();
@@ -356,7 +319,7 @@ v8::Handle<v8::Value> QV8Engine::fromVariant(const QVariant &variant)
case QMetaType::QTime:
return v8::Date::New(qtDateTimeToJsDate(QDateTime(QDate(1970,1,1), *reinterpret_cast<const QTime *>(ptr))));
case QMetaType::QRegExp:
- return regexpFromQRegExp(this, *reinterpret_cast<const QRegExp *>(ptr));
+ return QJSConverter::toRegExp(*reinterpret_cast<const QRegExp *>(ptr));
case QMetaType::QObjectStar:
case QMetaType::QWidgetStar:
return newQObject(*reinterpret_cast<QObject* const *>(ptr));
@@ -464,13 +427,13 @@ QVariant QV8Engine::toBasicVariant(v8::Handle<v8::Value> value)
{
if (value->IsNull() || value->IsUndefined())
return QVariant();
- else if (value->IsBoolean())
+ if (value->IsBoolean())
return value->ToBoolean()->Value();
- else if (value->IsInt32())
+ if (value->IsInt32())
return value->ToInt32()->Value();
- else if (value->IsNumber())
+ if (value->IsNumber())
return value->ToNumber()->Value();
- else if (value->IsString())
+ if (value->IsString())
return m_stringWrapper.toString(value->ToString());
if (value->IsDate())
return qtDateTimeFromJsDate(v8::Handle<v8::Date>::Cast(value)->NumberValue());
@@ -480,17 +443,9 @@ QVariant QV8Engine::toBasicVariant(v8::Handle<v8::Value> value)
if (value->IsRegExp()) {
v8::Context::Scope scope(context());
- v8::Handle<v8::RegExp> jsRegExp = v8::Handle<v8::RegExp>::Cast(value);
- // Copied from QtScript
- // Converts a JS RegExp to a QRegExp.
- // The conversion is not 100% exact since ECMA regexp and QRegExp
- // have different semantics/flags, but we try to do our best.
- QString pattern = toString(jsRegExp->GetSource());
- Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive;
- if (jsRegExp->GetFlags() & v8::RegExp::kIgnoreCase)
- caseSensitivity = Qt::CaseInsensitive;
- return QRegExp(pattern, caseSensitivity, QRegExp::RegExp2);
- } else if (value->IsArray()) {
+ return QJSConverter::toRegExp(v8::Handle<v8::RegExp>::Cast(value));
+ }
+ if (value->IsArray()) {
v8::Context::Scope scope(context());
QVariantList rv;
@@ -500,7 +455,8 @@ QVariant QV8Engine::toBasicVariant(v8::Handle<v8::Value> value)
rv << toVariant(array->Get(ii), -1);
return rv;
- } else if (!value->IsFunction()) {
+ }
+ if (!value->IsFunction()) {
v8::Context::Scope scope(context());
v8::Handle<v8::Object> object = value->ToObject();
v8::Local<v8::Array> properties = object->GetPropertyNames();
@@ -522,6 +478,7 @@ QVariant QV8Engine::toBasicVariant(v8::Handle<v8::Value> value)
#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
struct StaticQtMetaObject : public QObject
{
@@ -556,6 +513,7 @@ void QV8Engine::initializeGlobal(v8::Handle<v8::Object> global)
qt->Set(v8::String::New("point"), V8FUNCTION(point, this));
qt->Set(v8::String::New("size"), V8FUNCTION(size, this));
qt->Set(v8::String::New("vector3d"), V8FUNCTION(vector3d, this));
+ qt->Set(v8::String::New("vector4d"), V8FUNCTION(vector4d, this));
qt->Set(v8::String::New("formatDate"), V8FUNCTION(formatDate, this));
qt->Set(v8::String::New("formatTime"), V8FUNCTION(formatTime, this));
@@ -594,6 +552,7 @@ void QV8Engine::initializeGlobal(v8::Handle<v8::Object> global)
v8::Local<v8::Object> stringPrototype = v8::Local<v8::Object>::Cast(string->Get(v8::String::New("prototype")));
stringPrototype->Set(v8::String::New("arg"), V8FUNCTION(stringArg, this));
+ qt_add_domexceptions(this);
m_xmlHttpRequestData = qt_add_qmlxmlhttprequest(this);
m_sqlDatabaseData = qt_add_qmlsqldatabase(this);
@@ -891,6 +850,23 @@ v8::Handle<v8::Value> QV8Engine::vector3d(const v8::Arguments &args)
}
/*!
+\qmlmethod Qt::vector4d(real x, real y, real z, real w)
+Returns a Vector4D with the specified \c x, \c y, \c z and \c w.
+*/
+v8::Handle<v8::Value> QV8Engine::vector4d(const v8::Arguments &args)
+{
+ if (args.Length() != 4)
+ V8THROW_ERROR("Qt.vector4d(): Invalid arguments");
+
+ double x = args[0]->NumberValue();
+ double y = args[1]->NumberValue();
+ double z = args[2]->NumberValue();
+ double w = args[3]->NumberValue();
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(QVector4D(x, y, z, w)));
+}
+
+/*!
\qmlmethod color Qt::lighter(color baseColor, real factor)
Returns a color lighter than \c baseColor by the \c factor provided.
@@ -2131,14 +2107,14 @@ bool QV8Engine::metaTypeFromJS(v8::Handle<v8::Value> value, int type, void *data
}
#endif
- // Try to use magic.
+ // Try to use magic; for compatibility with qscriptvalue_cast.
QByteArray name = QMetaType::typeName(type);
if (convertToNativeQObject(value, name, reinterpret_cast<void* *>(data)))
return true;
if (isVariant(value) && name.endsWith('*')) {
int valueType = QMetaType::type(name.left(name.size()-1));
- QVariant var = variantValue(value);
+ QVariant &var = variantValue(value);
if (valueType == var.userType()) {
// We have T t, T* is requested, so return &t.
*reinterpret_cast<void* *>(data) = var.data();
@@ -2201,9 +2177,9 @@ QVariant QV8Engine::variantFromJS(v8::Handle<v8::Value> value)
return QVariant();
if (value->IsBoolean())
return value->ToBoolean()->Value();
- else if (value->IsInt32())
+ if (value->IsInt32())
return value->ToInt32()->Value();
- else if (value->IsNumber())
+ if (value->IsNumber())
return value->ToNumber()->Value();
if (value->IsString())
return QJSConverter::toString(value->ToString());
@@ -2259,10 +2235,9 @@ QObject *QV8Engine::qtObjectFromJS(v8::Handle<v8::Value> value)
}
-QVariant QV8Engine::variantValue(v8::Handle<v8::Value> value)
+QVariant &QV8Engine::variantValue(v8::Handle<v8::Value> value)
{
- Q_ASSERT(isVariant(value));
- return QV8Engine::toVariant(value, -1 /*whateever magic hint is*/);
+ return variantWrapper()->variantValue(value);
}
// Creates a QVariant wrapper object.
diff --git a/src/declarative/qml/v8/qv8engine_impl_p.h b/src/declarative/qml/v8/qv8engine_impl_p.h
index 5c56efdf39..53ce2a5acd 100644
--- a/src/declarative/qml/v8/qv8engine_impl_p.h
+++ b/src/declarative/qml/v8/qv8engine_impl_p.h
@@ -38,6 +38,7 @@
#include "qv8engine_p.h"
#include "qjsvalue_p.h"
#include "qjsconverter_p.h"
+#include "qjsvalueiterator_p.h"
QT_BEGIN_NAMESPACE
@@ -80,6 +81,10 @@ public:
{
value->reinitialize();
}
+ void operator () (QJSValueIteratorPrivate *iterator) const
+ {
+ iterator->invalidate();
+ }
};
inline void QV8Engine::registerValue(QJSValuePrivate *data)
@@ -94,9 +99,28 @@ inline void QV8Engine::unregisterValue(QJSValuePrivate *data)
inline void QV8Engine::invalidateAllValues()
{
- QtScriptBagCleaner invalidator;
- m_values.forEach(invalidator);
- m_values.clear();
+ ValueList::iterator it;
+ for (it = m_values.begin(); it != m_values.end(); it = it.erase())
+ (*it)->invalidate();
+ Q_ASSERT(m_values.isEmpty());
+}
+
+inline void QV8Engine::registerValueIterator(QJSValueIteratorPrivate *data)
+{
+ m_valueIterators.insert(data);
+}
+
+inline void QV8Engine::unregisterValueIterator(QJSValueIteratorPrivate *data)
+{
+ m_valueIterators.remove(data);
+}
+
+inline void QV8Engine::invalidateAllIterators()
+{
+ ValueIteratorList::iterator it;
+ for (it = m_valueIterators.begin(); it != m_valueIterators.end(); it = it.erase())
+ (*it)->invalidate();
+ Q_ASSERT(m_valueIterators.isEmpty());
}
/*!
diff --git a/src/declarative/qml/v8/qv8engine_p.h b/src/declarative/qml/v8/qv8engine_p.h
index b95e55002b..43ef9821ac 100644
--- a/src/declarative/qml/v8/qv8engine_p.h
+++ b/src/declarative/qml/v8/qv8engine_p.h
@@ -7,29 +7,29 @@
** 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.
**
**
**
@@ -63,6 +63,8 @@
#include <private/qv8_p.h>
#include <qjsengine.h>
#include <qjsvalue.h>
+#include "qjsvalue_p.h"
+#include "qjsvalueiterator_p.h"
#include "qscriptoriginalglobalobject_p.h"
#include "qscripttools_p.h"
@@ -125,6 +127,7 @@ private:
return rv; \
} \
+
class QV8Engine;
class QV8ObjectResource : public v8::Object::ExternalResource
{
@@ -214,6 +217,7 @@ class QDeclarativeEngine;
class QDeclarativeValueType;
class QNetworkAccessManager;
class QDeclarativeContextData;
+
class Q_DECLARATIVE_EXPORT QV8Engine
{
public:
@@ -260,11 +264,16 @@ public:
inline void unregisterValue(QJSValuePrivate *data);
inline void invalidateAllValues();
+ inline void registerValueIterator(QJSValueIteratorPrivate *data);
+ inline void unregisterValueIterator(QJSValueIteratorPrivate *data);
+ inline void invalidateAllIterators();
+
QV8ContextWrapper *contextWrapper() { return &m_contextWrapper; }
QV8QObjectWrapper *qobjectWrapper() { return &m_qobjectWrapper; }
QV8TypeWrapper *typeWrapper() { return &m_typeWrapper; }
QV8ListWrapper *listWrapper() { return &m_listWrapper; }
QV8VariantWrapper *variantWrapper() { return &m_variantWrapper; }
+ QV8ValueTypeWrapper *valueTypeWrapper() { return &m_valueTypeWrapper; }
void *xmlHttpRequestData() { return m_xmlHttpRequestData; }
void *sqlDatabaseData() { return m_sqlDatabaseData; }
@@ -378,7 +387,7 @@ public:
const QByteArray &targetType,
void **result);
- QVariant variantValue(v8::Handle<v8::Value> value);
+ QVariant &variantValue(v8::Handle<v8::Value> value);
QJSValue scriptValueFromInternal(v8::Handle<v8::Value>) const;
@@ -427,6 +436,7 @@ protected:
static v8::Handle<v8::Value> point(const v8::Arguments &args);
static v8::Handle<v8::Value> size(const v8::Arguments &args);
static v8::Handle<v8::Value> vector3d(const v8::Arguments &args);
+ static v8::Handle<v8::Value> vector4d(const v8::Arguments &args);
static v8::Handle<v8::Value> lighter(const v8::Arguments &args);
static v8::Handle<v8::Value> darker(const v8::Arguments &args);
static v8::Handle<v8::Value> tint(const v8::Arguments &args);
@@ -452,10 +462,15 @@ protected:
double qtDateTimeToJsDate(const QDateTime &dt);
QDateTime qtDateTimeFromJsDate(double jsDate);
+
private:
- QScriptBagContainer<QJSValuePrivate> m_values;
+ typedef QScriptIntrusiveList<QJSValuePrivate, &QJSValuePrivate::m_node> ValueList;
+ ValueList m_values;
+ typedef QScriptIntrusiveList<QJSValueIteratorPrivate, &QJSValueIteratorPrivate::m_node> ValueIteratorList;
+ ValueIteratorList m_valueIterators;
Q_DISABLE_COPY(QV8Engine)
+ friend class QV8DebugService;
};
// Allocate a new Persistent handle. *ALL* persistent handles in QML must be allocated
diff --git a/src/declarative/qml/v8/qv8include.cpp b/src/declarative/qml/v8/qv8include.cpp
index 71937d0aad..1d68e8e4be 100644
--- a/src/declarative/qml/v8/qv8include.cpp
+++ b/src/declarative/qml/v8/qv8include.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/qv8listwrapper.cpp b/src/declarative/qml/v8/qv8listwrapper.cpp
index 5f2d9fb91e..777ce78686 100644
--- a/src/declarative/qml/v8/qv8listwrapper.cpp
+++ b/src/declarative/qml/v8/qv8listwrapper.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
@@ -135,7 +135,7 @@ v8::Handle<v8::Value> QV8ListWrapper::Getter(v8::Local<v8::String> property,
{
Q_UNUSED(property);
Q_UNUSED(info);
- return v8::Undefined();
+ return v8::Handle<v8::Value>();
}
v8::Handle<v8::Value> QV8ListWrapper::Setter(v8::Local<v8::String> property,
diff --git a/src/declarative/qml/v8/qv8listwrapper_p.h b/src/declarative/qml/v8/qv8listwrapper_p.h
index 82fdaa7271..8cbc7db0b8 100644
--- a/src/declarative/qml/v8/qv8listwrapper_p.h
+++ b/src/declarative/qml/v8/qv8listwrapper_p.h
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/qv8qobjectwrapper.cpp b/src/declarative/qml/v8/qv8qobjectwrapper.cpp
index f97f427ede..c7ed0116e1 100644
--- a/src/declarative/qml/v8/qv8qobjectwrapper.cpp
+++ b/src/declarative/qml/v8/qv8qobjectwrapper.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
@@ -336,7 +336,8 @@ static v8::Handle<v8::Value> LoadProperty(QV8Engine *engine, QObject *object,
void *args[] = { &handle, 0 };
QMetaObject::metacall(object, QMetaObject::ReadProperty, property.coreIndex, args);
return handle.toHandle();
- } else if (QDeclarativeValueTypeFactory::isValueType((uint)property.propType)) {
+ } else if (QDeclarativeValueTypeFactory::isValueType((uint)property.propType)
+ && engine->engine()) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine->engine());
QDeclarativeValueType *valueType = ep->valueTypes[property.propType];
if (valueType)
@@ -381,7 +382,8 @@ static v8::Handle<v8::Value> LoadPropertyDirect(QV8Engine *engine, QObject *obje
void *args[] = { &handle, 0 };
object->qt_metacall(QMetaObject::ReadProperty, property.coreIndex, args);
return handle.toHandle();
- } else if (QDeclarativeValueTypeFactory::isValueType((uint)property.propType)) {
+ } else if (QDeclarativeValueTypeFactory::isValueType((uint)property.propType)
+ && engine->engine()) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine->engine());
QDeclarativeValueType *valueType = ep->valueTypes[property.propType];
if (valueType)
@@ -600,7 +602,7 @@ v8::Handle<v8::Value> QV8QObjectWrapper::Getter(v8::Local<v8::String> property,
QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
if (resource->object.isNull())
- return v8::Undefined();
+ return v8::Handle<v8::Value>();
QObject *object = resource->object;
@@ -628,7 +630,7 @@ v8::Handle<v8::Value> QV8QObjectWrapper::Getter(v8::Local<v8::String> property,
}
}
- return v8::Undefined();
+ return v8::Handle<v8::Value>();
}
v8::Handle<v8::Value> QV8QObjectWrapper::Setter(v8::Local<v8::String> property,
diff --git a/src/declarative/qml/v8/qv8qobjectwrapper_p.h b/src/declarative/qml/v8/qv8qobjectwrapper_p.h
index dd787cc476..d0a489bed8 100644
--- a/src/declarative/qml/v8/qv8qobjectwrapper_p.h
+++ b/src/declarative/qml/v8/qv8qobjectwrapper_p.h
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/qv8stringwrapper.cpp b/src/declarative/qml/v8/qv8stringwrapper.cpp
index 883c4826c5..1fea98fdc0 100644
--- a/src/declarative/qml/v8/qv8stringwrapper.cpp
+++ b/src/declarative/qml/v8/qv8stringwrapper.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qv8stringwrapper_p.h"
+#include "qjsconverter_p.h"
QT_BEGIN_NAMESPACE
@@ -73,7 +74,7 @@ void QV8StringWrapper::destroy()
v8::Local<v8::String> QV8StringWrapper::toString(const QString &qstr)
{
// return v8::String::NewExternal(new QV8StringResource(qstr));
- return v8::String::New((uint16_t*)qstr.constData(), qstr.length());
+ return QJSConverter::toString(qstr);
}
QString QV8StringWrapper::toString(v8::Handle<v8::String> jsstr)
@@ -84,10 +85,7 @@ QString QV8StringWrapper::toString(v8::Handle<v8::String> jsstr)
QV8StringResource *r = (QV8StringResource *)jsstr->GetExternalStringResource();
return r->str;
} else {
- QString qstr;
- qstr.resize(jsstr->Length());
- jsstr->Write((uint16_t*)qstr.data());
- return qstr;
+ return QJSConverter::toString(jsstr);
}
}
diff --git a/src/declarative/qml/v8/qv8stringwrapper_p.h b/src/declarative/qml/v8/qv8stringwrapper_p.h
index 36c9e24c06..beef80ff10 100644
--- a/src/declarative/qml/v8/qv8stringwrapper_p.h
+++ b/src/declarative/qml/v8/qv8stringwrapper_p.h
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/qv8typewrapper.cpp b/src/declarative/qml/v8/qv8typewrapper.cpp
index fe30670fc2..c51a2eeb7f 100644
--- a/src/declarative/qml/v8/qv8typewrapper.cpp
+++ b/src/declarative/qml/v8/qv8typewrapper.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
@@ -150,7 +150,7 @@ v8::Handle<v8::Value> QV8TypeWrapper::Getter(v8::Local<v8::String> property,
}
}
- // Fall through to undefined
+ // Fall through to return empty handle
} else if (resource->object) {
QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
@@ -158,10 +158,10 @@ v8::Handle<v8::Value> QV8TypeWrapper::Getter(v8::Local<v8::String> property,
return v8engine->qobjectWrapper()->getProperty(ao, propertystring,
QV8QObjectWrapper::IgnoreRevision);
- // Fall through to undefined
+ // Fall through to return empty handle
}
- // Fall through to undefined
+ // Fall through to return empty handle
} else if (resource->typeNamespace) {
@@ -185,21 +185,19 @@ v8::Handle<v8::Value> QV8TypeWrapper::Getter(v8::Local<v8::String> property,
if (moduleApi->qobjectApi) {
v8::Handle<v8::Value> rv = v8engine->qobjectWrapper()->getProperty(moduleApi->qobjectApi, propertystring, QV8QObjectWrapper::IgnoreRevision);
- if (rv.IsEmpty())
- return v8::Undefined();
- else
- return rv;
+ return rv;
} else {
- return v8::Undefined();
+ return v8::Handle<v8::Value>();
}
}
- // Fall through to undefined
+ // Fall through to return empty handle
} else {
Q_ASSERT(!"Unreachable");
}
- return v8::Undefined();
+
+ return v8::Handle<v8::Value>();
}
v8::Handle<v8::Value> QV8TypeWrapper::Setter(v8::Local<v8::String> property,
diff --git a/src/declarative/qml/v8/qv8valuetypewrapper.cpp b/src/declarative/qml/v8/qv8valuetypewrapper.cpp
index f3100cf7b5..e459fee71f 100644
--- a/src/declarative/qml/v8/qv8valuetypewrapper.cpp
+++ b/src/declarative/qml/v8/qv8valuetypewrapper.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
@@ -103,15 +103,21 @@ QV8ValueTypeWrapper::~QV8ValueTypeWrapper()
void QV8ValueTypeWrapper::destroy()
{
+ qPersistentDispose(m_toString);
qPersistentDispose(m_constructor);
}
void QV8ValueTypeWrapper::init(QV8Engine *engine)
{
m_engine = engine;
+ m_toString = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ToString)->GetFunction());
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetNamedPropertyHandler(Getter, Setter);
ft->InstanceTemplate()->SetHasExternalResource(true);
+ ft->InstanceTemplate()->MarkAsUseUserObjectComparison();
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("toString"), ToStringGetter, 0,
+ m_toString, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
@@ -166,26 +172,85 @@ QVariant QV8ValueTypeWrapper::toVariant(QV8ObjectResource *r)
}
}
+bool QV8ValueTypeWrapper::isEqual(QV8ObjectResource *r, const QVariant& value)
+{
+ Q_ASSERT(r->resourceType() == QV8ObjectResource::ValueTypeType);
+ QV8ValueTypeResource *resource = static_cast<QV8ValueTypeResource *>(r);
+
+ if (resource->objectType == QV8ValueTypeResource::Reference) {
+ QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(resource);
+ if (reference->object) {
+ reference->type->read(reference->object, reference->property);
+ return reference->type->isEqual(value);
+ } else {
+ return false;
+ }
+ } else {
+ Q_ASSERT(resource->objectType == QV8ValueTypeResource::Copy);
+ QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(resource);
+ return (value == copy->value);
+ }
+}
+
+v8::Handle<v8::Value> QV8ValueTypeWrapper::ToStringGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ return info.Data();
+}
+
+v8::Handle<v8::Value> QV8ValueTypeWrapper::ToString(const v8::Arguments &args)
+{
+ QV8ValueTypeResource *resource = v8_resource_cast<QV8ValueTypeResource>(args.This());
+ if (resource) {
+ if (resource->objectType == QV8ValueTypeResource::Reference) {
+ QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(resource);
+ if (reference->object) {
+ reference->type->read(reference->object, reference->property);
+ return resource->engine->toString(resource->type->toString());
+ } else {
+ return v8::Undefined();
+ }
+ } else {
+ Q_ASSERT(resource->objectType == QV8ValueTypeResource::Copy);
+ QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(resource);
+ QString result = copy->value.toString();
+ if (result.isEmpty() && !copy->value.canConvert(QVariant::String)) {
+ result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(copy->value.typeName()));
+ }
+ return resource->engine->toString(result);
+ }
+ } else {
+ return v8::Undefined();
+ }
+}
+
v8::Handle<v8::Value> QV8ValueTypeWrapper::Getter(v8::Local<v8::String> property,
const v8::AccessorInfo &info)
{
QV8ValueTypeResource *r = v8_resource_cast<QV8ValueTypeResource>(info.This());
- if (!r) return v8::Undefined();
+ if (!r) return v8::Handle<v8::Value>();
// XXX This is horribly inefficient. Sadly people seem to have taken a liking to
// value type properties, so we should probably try and optimize it a little.
// We should probably just replace all value properties with dedicated accessors.
QByteArray propName = r->engine->toString(property).toUtf8();
+ if (propName == QByteArray("toString")) {
+ return r->engine->valueTypeWrapper()->m_toString;
+ }
+
int index = r->type->metaObject()->indexOfProperty(propName.constData());
if (index == -1)
- return v8::Undefined();
+ return v8::Handle<v8::Value>();
+
if (r->objectType == QV8ValueTypeResource::Reference) {
QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(r);
if (!reference->object)
- return v8::Undefined();
+ return v8::Handle<v8::Value>();
+
r->type->read(reference->object, reference->property);
} else {
diff --git a/src/declarative/qml/v8/qv8valuetypewrapper_p.h b/src/declarative/qml/v8/qv8valuetypewrapper_p.h
index d08d89392c..2582560c0f 100644
--- a/src/declarative/qml/v8/qv8valuetypewrapper_p.h
+++ b/src/declarative/qml/v8/qv8valuetypewrapper_p.h
@@ -77,7 +77,12 @@ public:
QVariant toVariant(v8::Handle<v8::Object>);
QVariant toVariant(QV8ObjectResource *);
+ static bool isEqual(QV8ObjectResource *, const QVariant& value);
+
private:
+ static v8::Handle<v8::Value> ToStringGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> ToString(const v8::Arguments &args);
static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
const v8::AccessorInfo &info);
static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
@@ -86,6 +91,7 @@ private:
QV8Engine *m_engine;
v8::Persistent<v8::Function> m_constructor;
+ v8::Persistent<v8::Function> m_toString;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8variantwrapper.cpp b/src/declarative/qml/v8/qv8variantwrapper.cpp
index d4097d7f74..de4f0ce2d7 100644
--- a/src/declarative/qml/v8/qv8variantwrapper.cpp
+++ b/src/declarative/qml/v8/qv8variantwrapper.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
@@ -159,17 +159,24 @@ QVariant QV8VariantWrapper::toVariant(QV8ObjectResource *r)
return static_cast<QV8VariantResource *>(r)->data;
}
-v8::Handle<v8::Value> QV8VariantWrapper::Getter(v8::Local<v8::String> property,
+QVariant &QV8VariantWrapper::variantValue(v8::Handle<v8::Value> value)
+{
+ Q_ASSERT(isVariant(value));
+ QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(value->ToObject());
+ return static_cast<QV8VariantResource *>(r)->data;
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::Getter(v8::Local<v8::String> property,
const v8::AccessorInfo &info)
{
- return v8::Undefined();
+ return v8::Handle<v8::Value>();
}
v8::Handle<v8::Value> QV8VariantWrapper::Setter(v8::Local<v8::String> property,
v8::Local<v8::Value> value,
const v8::AccessorInfo &info)
{
- return v8::Undefined();
+ return value;
}
v8::Handle<v8::Value> QV8VariantWrapper::PreserveGetter(v8::Local<v8::String> property,
diff --git a/src/declarative/qml/v8/qv8variantwrapper_p.h b/src/declarative/qml/v8/qv8variantwrapper_p.h
index de74bc9e12..7e9924b3c0 100644
--- a/src/declarative/qml/v8/qv8variantwrapper_p.h
+++ b/src/declarative/qml/v8/qv8variantwrapper_p.h
@@ -74,6 +74,7 @@ public:
bool isVariant(v8::Handle<v8::Value>);
QVariant toVariant(v8::Handle<v8::Object>);
QVariant toVariant(QV8ObjectResource *);
+ QVariant &variantValue(v8::Handle<v8::Value>);
private:
static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
diff --git a/src/declarative/qml/v8/qv8worker.cpp b/src/declarative/qml/v8/qv8worker.cpp
index 0d396d3304..d6998849e2 100644
--- a/src/declarative/qml/v8/qv8worker.cpp
+++ b/src/declarative/qml/v8/qv8worker.cpp
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/qv8worker_p.h b/src/declarative/qml/v8/qv8worker_p.h
index 086e18e7e0..20a295a51c 100644
--- a/src/declarative/qml/v8/qv8worker_p.h
+++ b/src/declarative/qml/v8/qv8worker_p.h
@@ -7,29 +7,29 @@
** 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.
**
**
**
diff --git a/src/declarative/qml/v8/script.pri b/src/declarative/qml/v8/script.pri
index 04a23d1f2b..7454d2004c 100644
--- a/src/declarative/qml/v8/script.pri
+++ b/src/declarative/qml/v8/script.pri
@@ -17,4 +17,6 @@ HEADERS += \
$$PWD/qscriptshareddata_p.h \
$$PWD/qscripttools_p.h \
$$PWD/qscript_impl_p.h \
- $$PWD/qscriptoriginalglobalobject_p.h
+ $$PWD/qscriptoriginalglobalobject_p.h \
+ $$PWD/qjsvalueiterator_p.h \
+ $$PWD/qjsvalueiterator_impl_p.h
diff --git a/src/declarative/qml/v8/v8.pri b/src/declarative/qml/v8/v8.pri
index 97b3d679df..9349742c78 100644
--- a/src/declarative/qml/v8/v8.pri
+++ b/src/declarative/qml/v8/v8.pri
@@ -5,6 +5,7 @@ include(script.pri)
HEADERS += \
$$PWD/qv8_p.h \
+ $$PWD/qv8debug_p.h \
$$PWD/qv8stringwrapper_p.h \
$$PWD/qv8engine_p.h \
$$PWD/qhashedstring_p.h \
@@ -18,7 +19,8 @@ HEADERS += \
$$PWD/qv8worker_p.h \
$$PWD/qv8bindings_p.h \
$$PWD/../../../3rdparty/javascriptcore/DateMath.h \
- $$PWD/qv8engine_impl_p.h
+ $$PWD/qv8engine_impl_p.h \
+ $$PWD/qv8domerrors_p.h
SOURCES += \
$$PWD/qv8stringwrapper.cpp \
@@ -34,3 +36,4 @@ SOURCES += \
$$PWD/qv8worker.cpp \
$$PWD/qv8bindings.cpp \
$$PWD/../../../3rdparty/javascriptcore/DateMath.cpp \
+ $$PWD/qv8domerrors.cpp