aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-08-23 11:41:50 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-30 13:18:28 +0200
commitee84bb67a2f90038d1f3462cb9141dffbfa9517b (patch)
tree18d1f857ba6e8e89d670cec1f8218b8d14e1c71d
parentc7a9493730b93f0e19705bdb02729e15b9955117 (diff)
Move all QML file parsing into the QDeclarativeScript namespace
Change-Id: I5969686a796cbfb2eeb3729014df7f01e51b0620 Reviewed-on: http://codereview.qt.nokia.com/3797 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp197
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h180
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h2
-rw-r--r--src/declarative/qml/qdeclarativecustomparser.cpp15
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h10
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p_p.h10
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp14
-rw-r--r--src/declarative/qml/qdeclarativeimport_p.h5
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp450
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h463
-rw-r--r--src/declarative/qml/qdeclarativescript.cpp (renamed from src/declarative/qml/qdeclarativescriptparser.cpp)537
-rw-r--r--src/declarative/qml/qdeclarativescript_p.h526
-rw-r--r--src/declarative/qml/qdeclarativescriptparser_p.h153
-rw-r--r--src/declarative/qml/qdeclarativetypeloader.cpp40
-rw-r--r--src/declarative/qml/qdeclarativetypeloader_p.h18
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp2
-rw-r--r--src/declarative/qml/qml.pri6
-rw-r--r--src/declarative/qml/v4/qdeclarativev4compiler_p.h8
-rw-r--r--src/declarative/qml/v4/qdeclarativev4compiler_p_p.h2
-rw-r--r--src/declarative/qml/v4/qdeclarativev4ir.cpp2
-rw-r--r--src/declarative/qml/v4/qdeclarativev4ir_p.h6
-rw-r--r--src/declarative/qml/v4/qdeclarativev4irbuilder.cpp4
-rw-r--r--src/declarative/qml/v8/qv8include.cpp4
-rw-r--r--src/declarative/util/qdeclarativeconnections.cpp2
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp22
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp14
-rw-r--r--src/imports/gestures/qdeclarativegesturearea.cpp3
-rw-r--r--src/qtquick1/util/qdeclarativeconnections.cpp2
-rw-r--r--src/qtquick1/util/qdeclarativelistmodel.cpp2
-rw-r--r--src/qtquick1/util/qdeclarativepropertychanges.cpp14
-rw-r--r--tests/benchmarks/declarative/compilation/tst_compilation.cpp4
33 files changed, 1284 insertions, 1437 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index bd99a331b8..4198e8cf7b 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -41,8 +41,6 @@
#include "private/qdeclarativecompiler_p.h"
-#include "private/qdeclarativeparser_p.h"
-#include "private/qdeclarativescriptparser_p.h"
#include "qdeclarativepropertyvaluesource.h"
#include "qdeclarativecomponent.h"
#include "private/qmetaobjectbuilder_p.h"
@@ -62,7 +60,6 @@
#include "private/qdeclarativerewrite_p.h"
#include "qdeclarativescriptstring.h"
#include "private/qdeclarativeglobal_p.h"
-#include "private/qdeclarativescriptparser_p.h"
#include "private/qdeclarativebinding_p.h"
#include "private/qdeclarativev4compiler_p.h"
#include "private/qdeclarativeutils_p.h"
@@ -81,7 +78,7 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP);
DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATS);
-using namespace QDeclarativeParser;
+using namespace QDeclarativeScript;
using namespace QDeclarativeCompilerTypes;
static QString id_string(QLatin1String("id"));
@@ -207,10 +204,10 @@ bool QDeclarativeCompiler::isSignalPropertyName(const QHashedStringRef &name)
This test corresponds to action taken by genLiteralAssignment(). Any change
made here, must have a corresponding action in genLiteralAssigment().
*/
-bool QDeclarativeCompiler::testLiteralAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Value *v)
+bool QDeclarativeCompiler::testLiteralAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Value *v)
{
- const QDeclarativeParser::Variant &value = v->value;
+ const QDeclarativeScript::Variant &value = v->value;
if (!prop->core.isWritable())
COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
@@ -226,7 +223,7 @@ bool QDeclarativeCompiler::testLiteralAssignment(QDeclarativeParser::Property *p
if (enumValue == -1)
COMPILE_EXCEPTION(v, tr("Invalid property assignment: unknown enumeration"));
- v->value = QDeclarativeParser::Variant((double)enumValue);
+ v->value = QDeclarativeScript::Variant((double)enumValue);
return true;
}
@@ -362,8 +359,8 @@ bool QDeclarativeCompiler::testLiteralAssignment(QDeclarativeParser::Property *p
Any literal assignment that is approved in testLiteralAssignment() must have
a corresponding action in this method.
*/
-void QDeclarativeCompiler::genLiteralAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Value *v)
+void QDeclarativeCompiler::genLiteralAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Value *v)
{
QDeclarativeInstruction instr;
@@ -636,13 +633,13 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
// Compile types
const QList<QDeclarativeTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes();
- QList<QDeclarativeScriptParser::TypeReference *> referencedTypes = unit->parser().referencedTypes();
+ QList<QDeclarativeScript::TypeReference *> referencedTypes = unit->parser().referencedTypes();
for (int ii = 0; ii < resolvedTypes.count(); ++ii) {
QDeclarativeCompiledData::TypeReference ref;
const QDeclarativeTypeData::TypeReference &tref = resolvedTypes.at(ii);
- QDeclarativeScriptParser::TypeReference *parserRef = referencedTypes.at(ii);
+ QDeclarativeScript::TypeReference *parserRef = referencedTypes.at(ii);
if (tref.type) {
ref.type = tref.type;
@@ -671,7 +668,7 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
out->types << ref;
}
- QDeclarativeParser::Object *root = unit->parser().tree();
+ QDeclarativeScript::Object *root = unit->parser().tree();
Q_ASSERT(root);
this->engine = engine;
@@ -700,7 +697,7 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
return !isError();
}
-void QDeclarativeCompiler::compileTree(QDeclarativeParser::Object *tree)
+void QDeclarativeCompiler::compileTree(QDeclarativeScript::Object *tree)
{
compileState = pool->New<ComponentCompileState>();
@@ -786,7 +783,7 @@ static bool QStringList_contains(const QStringList &list, const QHashedStringRef
return false;
}
-bool QDeclarativeCompiler::buildObject(QDeclarativeParser::Object *obj, const BindingContext &ctxt)
+bool QDeclarativeCompiler::buildObject(QDeclarativeScript::Object *obj, const BindingContext &ctxt)
{
if (componentStats)
componentStats->componentStat.objects++;
@@ -996,7 +993,7 @@ bool QDeclarativeCompiler::buildObject(QDeclarativeParser::Object *obj, const Bi
return true;
}
-void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
+void QDeclarativeCompiler::genObject(QDeclarativeScript::Object *obj)
{
QDeclarativeCompiledData::TypeReference &tr = output->types[obj->type];
if (tr.type && obj->metatype == &QDeclarativeComponent::staticMetaObject) {
@@ -1094,7 +1091,7 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
genObjectBody(obj);
}
-void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
+void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj)
{
for (Property *prop = obj->scriptStringProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
Q_ASSERT(prop->scriptStringScope != -1);
@@ -1149,7 +1146,7 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
for (Property *prop = obj->signalProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
- QDeclarativeParser::Value *v = prop->values.first();
+ QDeclarativeScript::Value *v = prop->values.first();
if (v->type == Value::SignalObject) {
@@ -1232,7 +1229,7 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
}
}
-void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeParser::Object *obj,QDeclarativeParser::Property *prop)
+void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeScript::Object *obj,QDeclarativeScript::Property *prop)
{
QDeclarativeInstruction fetch;
fetch.setType(QDeclarativeInstruction::FetchValueType);
@@ -1265,9 +1262,9 @@ void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeParser::Object *obj,
output->addInstruction(pop);
}
-void QDeclarativeCompiler::genComponent(QDeclarativeParser::Object *obj)
+void QDeclarativeCompiler::genComponent(QDeclarativeScript::Object *obj)
{
- QDeclarativeParser::Object *root = obj->defaultProperty->values.first()->object;
+ QDeclarativeScript::Object *root = obj->defaultProperty->values.first()->object;
Q_ASSERT(root);
QDeclarativeInstruction create;
@@ -1330,7 +1327,7 @@ void QDeclarativeCompiler::genComponent(QDeclarativeParser::Object *obj)
}
}
-bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
+bool QDeclarativeCompiler::buildComponent(QDeclarativeScript::Object *obj,
const BindingContext &ctxt)
{
// The special "Component" element can only have the id property and a
@@ -1372,7 +1369,7 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
if (!obj->dynamicSlots.isEmpty())
COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new functions."));
- QDeclarativeParser::Object *root = 0;
+ QDeclarativeScript::Object *root = 0;
if (obj->defaultProperty && !obj->defaultProperty->values.isEmpty())
root = obj->defaultProperty->values.first()->object;
@@ -1385,7 +1382,7 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
return true;
}
-bool QDeclarativeCompiler::buildComponentFromRoot(QDeclarativeParser::Object *obj,
+bool QDeclarativeCompiler::buildComponentFromRoot(QDeclarativeScript::Object *obj,
const BindingContext &ctxt)
{
ComponentCompileState *oldComponentCompileState = compileState;
@@ -1421,7 +1418,7 @@ bool QDeclarativeCompiler::buildComponentFromRoot(QDeclarativeParser::Object *ob
// Build a sub-object. A sub-object is one that was not created directly by
// QML - such as a grouped property object, or an attached object. Sub-object's
// can't have an id, involve a custom parser, have attached properties etc.
-bool QDeclarativeCompiler::buildSubObject(QDeclarativeParser::Object *obj, const BindingContext &ctxt)
+bool QDeclarativeCompiler::buildSubObject(QDeclarativeScript::Object *obj, const BindingContext &ctxt)
{
Q_ASSERT(obj->metatype);
Q_ASSERT(!obj->defaultProperty);
@@ -1453,7 +1450,7 @@ int QDeclarativeCompiler::componentTypeRef()
return output->types.count() - 1;
}
-bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj,
+bool QDeclarativeCompiler::buildSignal(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj,
const BindingContext &ctxt)
{
Q_ASSERT(obj->metaObject());
@@ -1527,8 +1524,8 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
/*!
Returns true if (value) property \a prop exists on obj, false otherwise.
*/
-bool QDeclarativeCompiler::doesPropertyExist(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj)
+bool QDeclarativeCompiler::doesPropertyExist(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj)
{
if (prop->name().isEmpty())
return false;
@@ -1538,8 +1535,8 @@ bool QDeclarativeCompiler::doesPropertyExist(QDeclarativeParser::Property *prop,
return property(obj, prop->name()) != 0;
}
-bool QDeclarativeCompiler::buildProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+bool QDeclarativeCompiler::buildProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const BindingContext &ctxt)
{
if (prop->isEmpty())
@@ -1667,8 +1664,8 @@ bool QDeclarativeCompiler::buildProperty(QDeclarativeParser::Property *prop,
}
bool QDeclarativeCompiler::buildPropertyInNamespace(QDeclarativeImportedNamespace *ns,
- QDeclarativeParser::Property *nsProp,
- QDeclarativeParser::Object *obj,
+ QDeclarativeScript::Property *nsProp,
+ QDeclarativeScript::Object *obj,
const BindingContext &ctxt)
{
if (!nsProp->value)
@@ -1700,8 +1697,8 @@ bool QDeclarativeCompiler::buildPropertyInNamespace(QDeclarativeImportedNamespac
return true;
}
-void QDeclarativeCompiler::genValueProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj)
+void QDeclarativeCompiler::genValueProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj)
{
if (prop->core.isQList()) {
genListProperty(prop, obj);
@@ -1710,8 +1707,8 @@ void QDeclarativeCompiler::genValueProperty(QDeclarativeParser::Property *prop,
}
}
-void QDeclarativeCompiler::genListProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj)
+void QDeclarativeCompiler::genListProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj)
{
int listType = enginePrivate->listType(prop->type);
@@ -1751,9 +1748,9 @@ void QDeclarativeCompiler::genListProperty(QDeclarativeParser::Property *prop,
output->addInstruction(pop);
}
-void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Property *valueTypeProperty)
+void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Property *valueTypeProperty)
{
for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
@@ -1843,15 +1840,15 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
}
}
-bool QDeclarativeCompiler::buildIdProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj)
+bool QDeclarativeCompiler::buildIdProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj)
{
if (prop->value ||
prop->values.isMany() ||
prop->values.first()->object)
COMPILE_EXCEPTION(prop, tr("Invalid use of id property"));
- QDeclarativeParser::Value *idValue = prop->values.first();
+ QDeclarativeScript::Value *idValue = prop->values.first();
QString val = idValue->primitive();
COMPILE_CHECK(checkValidId(idValue, val));
@@ -1867,7 +1864,7 @@ bool QDeclarativeCompiler::buildIdProperty(QDeclarativeParser::Property *prop,
return true;
}
-void QDeclarativeCompiler::addId(const QString &id, QDeclarativeParser::Object *obj)
+void QDeclarativeCompiler::addId(const QString &id, QDeclarativeScript::Object *obj)
{
Q_ASSERT(!compileState->ids.value(id));
Q_ASSERT(obj->id == id);
@@ -1894,7 +1891,7 @@ void QDeclarativeCompiler::saveComponentState()
}
QDeclarativeCompilerTypes::ComponentCompileState *
-QDeclarativeCompiler::componentState(QDeclarativeParser::Object *obj)
+QDeclarativeCompiler::componentState(QDeclarativeScript::Object *obj)
{
Q_ASSERT(obj->componentCompileState);
return obj->componentCompileState;
@@ -1905,8 +1902,8 @@ QDeclarativeCompiler::componentState(QDeclarativeParser::Object *obj)
// GridView.row: 10
// }
// GridView is an attached property object.
-bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const BindingContext &ctxt)
{
Q_ASSERT(prop->value);
@@ -1926,8 +1923,8 @@ bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeParser::Property *p
// font.family: "Helvetica"
// }
// font is a nested property. pointSize and family are not.
-bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const BindingContext &ctxt)
{
Q_ASSERT(prop->type != 0);
@@ -1980,8 +1977,8 @@ bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *pr
}
bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Object *baseObj,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Object *baseObj,
const BindingContext &ctxt)
{
if (obj->defaultProperty)
@@ -2005,7 +2002,7 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
if (prop->values.isMany()) {
COMPILE_EXCEPTION(prop, tr("Single property assignment expected"));
} else if (!prop->values.isEmpty()) {
- QDeclarativeParser::Value *value = prop->values.first();
+ QDeclarativeScript::Value *value = prop->values.first();
if (value->object) {
COMPILE_EXCEPTION(prop, tr("Unexpected object assignment"));
@@ -2052,8 +2049,8 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
// Build assignments to QML lists. QML lists are properties of type
// QDeclarativeListProperty<T>. List properties can accept a list of
// objects, or a single binding.
-bool QDeclarativeCompiler::buildListProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+bool QDeclarativeCompiler::buildListProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const BindingContext &ctxt)
{
Q_ASSERT(prop->core.isQList());
@@ -2095,8 +2092,8 @@ bool QDeclarativeCompiler::buildListProperty(QDeclarativeParser::Property *prop,
}
// Compiles an assignment to a QDeclarativeScriptString property
-bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const BindingContext &ctxt)
{
if (prop->values.isMany())
@@ -2112,8 +2109,8 @@ bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeParser::Propert
}
// Compile regular property assignments of the form "property: <value>"
-bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const BindingContext &ctxt)
{
obj->addValueProperty(prop);
@@ -2142,9 +2139,9 @@ bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property
}
// Compile assigning a single object instance to a regular property
-bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Value *v,
+bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Value *v,
const BindingContext &ctxt)
{
Q_ASSERT(prop->index != -1);
@@ -2197,13 +2194,13 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro
v->type = Value::CreatedObject;
} else if (propertyMetaObject == &QDeclarativeComponent::staticMetaObject) {
// Automatic "Component" insertion
- QDeclarativeParser::Object *root = v->object;
- QDeclarativeParser::Object *component = pool->New<Object>();
+ QDeclarativeScript::Object *root = v->object;
+ QDeclarativeScript::Object *component = pool->New<Object>();
component->type = componentTypeRef();
component->typeName = "Qt/Component";
component->metatype = &QDeclarativeComponent::staticMetaObject;
component->location = root->location;
- QDeclarativeParser::Value *componentValue = pool->New<Value>();
+ QDeclarativeScript::Value *componentValue = pool->New<Value>();
componentValue->object = root;
component->getDefaultProperty()->addValue(componentValue);
v->object = component;
@@ -2222,10 +2219,10 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro
// Item {
// NumberAnimation on x { }
// }
-bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Object *baseObj,
- QDeclarativeParser::Value *v,
+bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Object *baseObj,
+ QDeclarativeScript::Value *v,
const BindingContext &ctxt)
{
Q_ASSERT(prop->index != -1);
@@ -2266,9 +2263,9 @@ bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeParser::Propert
}
// Compile assigning a literal or binding to a regular property
-bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Value *v,
+bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Value *v,
const BindingContext &ctxt)
{
Q_ASSERT(prop->index != -1);
@@ -2301,8 +2298,8 @@ bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeParser::Pr
}
bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Value *v,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Value *v,
bool *isAssignment)
{
*isAssignment = false;
@@ -2360,7 +2357,7 @@ bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop
return true;
v->type = Value::Literal;
- v->value = QDeclarativeParser::Variant((double)value);
+ v->value = QDeclarativeScript::Variant((double)value);
*isAssignment = true;
return true;
@@ -2417,7 +2414,7 @@ int QDeclarativeCompiler::rewriteBinding(const QString& expression, const QStrin
}
// Ensures that the dynamic meta specification on obj is valid
-bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
+bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeScript::Object *obj)
{
bool seenDefaultProperty = false;
@@ -2430,7 +2427,7 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
// Check properties
int dpCount = obj->dynamicProperties.count();
for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
- const QDeclarativeParser::Object::DynamicProperty &prop = *p;
+ const QDeclarativeScript::Object::DynamicProperty &prop = *p;
if (prop.isDefaultProperty) {
if (seenDefaultProperty)
@@ -2495,7 +2492,7 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
return true;
}
-bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeParser::Object *obj)
+bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeScript::Object *obj)
{
for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
@@ -2521,7 +2518,7 @@ bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeParser::Object
Q_GLOBAL_STATIC(QAtomicInt, classIndexCounter)
-bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, DynamicMetaMode mode)
+bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeScript::Object *obj, DynamicMetaMode mode)
{
Q_ASSERT(obj);
Q_ASSERT(obj->metatype);
@@ -2888,7 +2885,7 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn
return true;
}
-bool QDeclarativeCompiler::checkValidId(QDeclarativeParser::Value *v, const QString &val)
+bool QDeclarativeCompiler::checkValidId(QDeclarativeScript::Value *v, const QString &val)
{
if (val.isEmpty())
COMPILE_EXCEPTION(v, tr( "Invalid empty ID"));
@@ -2935,7 +2932,7 @@ static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node)
bool QDeclarativeCompiler::compileAlias(QFastMetaBuilder &builder,
QByteArray &data,
- QDeclarativeParser::Object *obj,
+ QDeclarativeScript::Object *obj,
int propIndex, int aliasIndex,
Object::DynamicProperty &prop)
{
@@ -2956,7 +2953,7 @@ bool QDeclarativeCompiler::compileAlias(QFastMetaBuilder &builder,
if (alias.count() < 1 || alias.count() > 3)
COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. An alias reference must be specified as <id>, <id>.<property> or <id>.<value property>.<property>"));
- QDeclarativeParser::Object *idObject = compileState->ids.value(alias.at(0));
+ QDeclarativeScript::Object *idObject = compileState->ids.value(alias.at(0));
if (!idObject)
COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0)));
@@ -3043,8 +3040,8 @@ bool QDeclarativeCompiler::compileAlias(QFastMetaBuilder &builder,
return true;
}
-bool QDeclarativeCompiler::buildBinding(QDeclarativeParser::Value *value,
- QDeclarativeParser::Property *prop,
+bool QDeclarativeCompiler::buildBinding(QDeclarativeScript::Value *value,
+ QDeclarativeScript::Property *prop,
const BindingContext &ctxt)
{
Q_ASSERT(prop->index != -1);
@@ -3064,10 +3061,10 @@ bool QDeclarativeCompiler::buildBinding(QDeclarativeParser::Value *value,
return true;
}
-void QDeclarativeCompiler::genBindingAssignment(QDeclarativeParser::Value *binding,
- QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Property *valueTypeProperty)
+void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *binding,
+ QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Property *valueTypeProperty)
{
Q_UNUSED(obj);
Q_ASSERT(binding->bindingReference);
@@ -3140,8 +3137,8 @@ int QDeclarativeCompiler::genContextCache()
return output->contextCaches.count() - 1;
}
-int QDeclarativeCompiler::genValueTypeData(QDeclarativeParser::Property *valueTypeProp,
- QDeclarativeParser::Property *prop)
+int QDeclarativeCompiler::genValueTypeData(QDeclarativeScript::Property *valueTypeProp,
+ QDeclarativeScript::Property *prop)
{
typedef QDeclarativePropertyPrivate QDPP;
QByteArray data = QDPP::saveValueType(prop->parent->metaObject(), prop->index,
@@ -3151,7 +3148,7 @@ int QDeclarativeCompiler::genValueTypeData(QDeclarativeParser::Property *valueTy
return output->indexForByteArray(data);
}
-int QDeclarativeCompiler::genPropertyData(QDeclarativeParser::Property *prop)
+int QDeclarativeCompiler::genPropertyData(QDeclarativeScript::Property *prop)
{
typedef QDeclarativePropertyPrivate QDPP;
QByteArray data = QDPP::saveProperty(prop->parent->metaObject(), prop->index, engine);
@@ -3234,7 +3231,7 @@ bool QDeclarativeCompiler::completeComponentBuild()
QString functionArray(QLatin1String("["));
for (int ii = 0; ii < sharedBindings.count(); ++ii) {
BindingReference *reference = sharedBindings.at(ii);
- QDeclarativeParser::Value *value = reference->value;
+ QDeclarativeScript::Value *value = reference->value;
const QString &expression = reference->rewrittenExpression;
if (ii != 0) functionArray += QLatin1String(",");
@@ -3317,7 +3314,7 @@ void QDeclarativeCompiler::dumpStats()
Returns true if from can be assigned to a (QObject) property of type
to.
*/
-bool QDeclarativeCompiler::canCoerce(int to, QDeclarativeParser::Object *from)
+bool QDeclarativeCompiler::canCoerce(int to, QDeclarativeScript::Object *from)
{
const QMetaObject *toMo =
enginePrivate->rawMetaObjectForType(to);
@@ -3334,7 +3331,7 @@ bool QDeclarativeCompiler::canCoerce(int to, QDeclarativeParser::Object *from)
/*!
Returns the element name, as written in the QML file, for o.
*/
-QString QDeclarativeCompiler::elementName(QDeclarativeParser::Object *o)
+QString QDeclarativeCompiler::elementName(QDeclarativeScript::Object *o)
{
Q_ASSERT(o);
if (o->type != -1) {
@@ -3344,7 +3341,7 @@ QString QDeclarativeCompiler::elementName(QDeclarativeParser::Object *o)
}
}
-QDeclarativeType *QDeclarativeCompiler::toQmlType(QDeclarativeParser::Object *from)
+QDeclarativeType *QDeclarativeCompiler::toQmlType(QDeclarativeScript::Object *from)
{
// ### Optimize
const QMetaObject *mo = from->metatype;
@@ -3356,7 +3353,7 @@ QDeclarativeType *QDeclarativeCompiler::toQmlType(QDeclarativeParser::Object *fr
return type;
}
-QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeParser::Object *obj)
+QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeScript::Object *obj)
{
const QMetaObject *mo = obj->metatype;
@@ -3370,7 +3367,7 @@ QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeParser::Object
}
QDeclarativePropertyCache::Data *
-QDeclarativeCompiler::property(QDeclarativeParser::Object *object, int index)
+QDeclarativeCompiler::property(QDeclarativeScript::Object *object, int index)
{
QDeclarativePropertyCache *cache = 0;
@@ -3385,7 +3382,7 @@ QDeclarativeCompiler::property(QDeclarativeParser::Object *object, int index)
}
QDeclarativePropertyCache::Data *
-QDeclarativeCompiler::property(QDeclarativeParser::Object *object, const QHashedStringRef &name, bool *notInRevision)
+QDeclarativeCompiler::property(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision)
{
if (notInRevision) *notInRevision = false;
@@ -3414,7 +3411,7 @@ QDeclarativeCompiler::property(QDeclarativeParser::Object *object, const QHashed
// This code must match the semantics of QDeclarativePropertyPrivate::findSignalByName
QDeclarativePropertyCache::Data *
-QDeclarativeCompiler::signal(QDeclarativeParser::Object *object, const QHashedStringRef &name, bool *notInRevision)
+QDeclarativeCompiler::signal(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision)
{
if (notInRevision) *notInRevision = false;
@@ -3453,20 +3450,20 @@ QDeclarativeCompiler::signal(QDeclarativeParser::Object *object, const QHashedSt
}
// This code must match the semantics of QDeclarativePropertyPrivate::findSignalByName
-int QDeclarativeCompiler::indexOfSignal(QDeclarativeParser::Object *object, const QString &name,
+int QDeclarativeCompiler::indexOfSignal(QDeclarativeScript::Object *object, const QString &name,
bool *notInRevision)
{
QDeclarativePropertyCache::Data *d = signal(object, QStringRef(&name), notInRevision);
return d?d->coreIndex:-1;
}
-int QDeclarativeCompiler::indexOfProperty(QDeclarativeParser::Object *object, const QString &name,
+int QDeclarativeCompiler::indexOfProperty(QDeclarativeScript::Object *object, const QString &name,
bool *notInRevision)
{
return indexOfProperty(object, QStringRef(&name), notInRevision);
}
-int QDeclarativeCompiler::indexOfProperty(QDeclarativeParser::Object *object, const QHashedStringRef &name,
+int QDeclarativeCompiler::indexOfProperty(QDeclarativeScript::Object *object, const QHashedStringRef &name,
bool *notInRevision)
{
QDeclarativePropertyCache::Data *d = property(object, name, notInRevision);
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 587e401952..0e159a2cdf 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -57,7 +57,7 @@
#include "qdeclarativeerror.h"
#include "private/qv8_p.h"
#include "private/qdeclarativeinstruction_p.h"
-#include "private/qdeclarativeparser_p.h"
+#include "private/qdeclarativescript_p.h"
#include "private/qdeclarativeengine_p.h"
#include "private/qbitfield_p.h"
#include "private/qdeclarativepropertycache_p.h"
@@ -144,7 +144,7 @@ namespace QDeclarativeCompilerTypes {
{
BindingContext()
: stack(0), owner(0), object(0) {}
- BindingContext(QDeclarativeParser::Object *o)
+ BindingContext(QDeclarativeScript::Object *o)
: stack(0), owner(0), object(o) {}
BindingContext incr() const {
BindingContext rv(object);
@@ -154,16 +154,16 @@ namespace QDeclarativeCompilerTypes {
bool isSubContext() const { return stack != 0; }
int stack;
int owner;
- QDeclarativeParser::Object *object;
+ QDeclarativeScript::Object *object;
};
struct BindingReference : public QDeclarativePool::Class
{
BindingReference() : nextReference(0) {}
- QDeclarativeParser::Variant expression;
- QDeclarativeParser::Property *property;
- QDeclarativeParser::Value *value;
+ QDeclarativeScript::Variant expression;
+ QDeclarativeScript::Property *property;
+ QDeclarativeScript::Value *value;
enum DataType { QtScript, V4, V8 };
DataType dataType;
@@ -176,11 +176,11 @@ namespace QDeclarativeCompilerTypes {
BindingReference *nextReference;
};
- struct IdList : public QFieldList<QDeclarativeParser::Object,
- &QDeclarativeParser::Object::nextIdObject>
+ struct IdList : public QFieldList<QDeclarativeScript::Object,
+ &QDeclarativeScript::Object::nextIdObject>
{
- QDeclarativeParser::Object *value(const QString &id) const {
- for (QDeclarativeParser::Object *o = first(); o; o = next(o)) {
+ QDeclarativeScript::Object *value(const QString &id) const {
+ for (QDeclarativeScript::Object *o = first(); o; o = next(o)) {
if (o->id == id)
return o;
}
@@ -209,10 +209,10 @@ namespace QDeclarativeCompilerTypes {
typedef QDeclarativeCompilerTypes::BindingReference B;
typedef QFieldList<B, &B::nextReference> BindingReferenceList;
BindingReferenceList bindings;
- typedef QDeclarativeParser::Object O;
+ typedef QDeclarativeScript::Object O;
typedef QFieldList<O, &O::nextAliasingObject> AliasingObjectsList;
AliasingObjectsList aliasingObjects;
- QDeclarativeParser::Object *root;
+ QDeclarativeScript::Object *root;
};
};
@@ -240,115 +240,115 @@ public:
private:
static void reset(QDeclarativeCompiledData *);
- void compileTree(QDeclarativeParser::Object *tree);
+ void compileTree(QDeclarativeScript::Object *tree);
- bool buildObject(QDeclarativeParser::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
- bool buildComponent(QDeclarativeParser::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
- bool buildSubObject(QDeclarativeParser::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
- bool buildSignal(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj,
+ bool buildObject(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
+ bool buildComponent(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
+ bool buildSubObject(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
+ bool buildSignal(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj,
const QDeclarativeCompilerTypes::BindingContext &);
- bool buildProperty(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj,
+ bool buildProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj,
const QDeclarativeCompilerTypes::BindingContext &);
bool buildPropertyInNamespace(QDeclarativeImportedNamespace *ns,
- QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+ QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const QDeclarativeCompilerTypes::BindingContext &);
- bool buildIdProperty(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj);
- bool buildAttachedProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+ bool buildIdProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj);
+ bool buildAttachedProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildGroupedProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+ bool buildGroupedProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
bool buildValueTypeProperty(QObject *type,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Object *baseObj,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Object *baseObj,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildListProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+ bool buildListProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildScriptStringProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+ bool buildScriptStringProperty(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildPropertyAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
+ bool buildPropertyAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildPropertyObjectAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Value *value,
+ bool buildPropertyObjectAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Value *value,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildPropertyOnAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Object *baseObj,
- QDeclarativeParser::Value *value,
+ bool buildPropertyOnAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Object *baseObj,
+ QDeclarativeScript::Value *value,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildPropertyLiteralAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Value *value,
+ bool buildPropertyLiteralAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Value *value,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool doesPropertyExist(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj);
- bool testLiteralAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Value *value);
+ bool doesPropertyExist(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj);
+ bool testLiteralAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Value *value);
bool testQualifiedEnumAssignment(const QMetaProperty &prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Value *value,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Value *value,
bool *isAssignment);
enum DynamicMetaMode { IgnoreAliases, ResolveAliases, ForceCreation };
- bool mergeDynamicMetaProperties(QDeclarativeParser::Object *obj);
- bool buildDynamicMeta(QDeclarativeParser::Object *obj, DynamicMetaMode mode);
- bool checkDynamicMeta(QDeclarativeParser::Object *obj);
- bool buildBinding(QDeclarativeParser::Value *, QDeclarativeParser::Property *prop,
+ bool mergeDynamicMetaProperties(QDeclarativeScript::Object *obj);
+ bool buildDynamicMeta(QDeclarativeScript::Object *obj, DynamicMetaMode mode);
+ bool checkDynamicMeta(QDeclarativeScript::Object *obj);
+ bool buildBinding(QDeclarativeScript::Value *, QDeclarativeScript::Property *prop,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildComponentFromRoot(QDeclarativeParser::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
+ bool buildComponentFromRoot(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
bool compileAlias(QFastMetaBuilder &,
QByteArray &data,
- QDeclarativeParser::Object *obj,
+ QDeclarativeScript::Object *obj,
int propIndex, int aliasIndex,
- QDeclarativeParser::Object::DynamicProperty &);
+ QDeclarativeScript::Object::DynamicProperty &);
bool completeComponentBuild();
- bool checkValidId(QDeclarativeParser::Value *, const QString &);
-
-
- void genObject(QDeclarativeParser::Object *obj);
- void genObjectBody(QDeclarativeParser::Object *obj);
- void genValueTypeProperty(QDeclarativeParser::Object *obj,QDeclarativeParser::Property *);
- void genComponent(QDeclarativeParser::Object *obj);
- void genValueProperty(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj);
- void genListProperty(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj);
- void genPropertyAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Property *valueTypeProperty = 0);
- void genLiteralAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Value *value);
- void genBindingAssignment(QDeclarativeParser::Value *binding,
- QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Property *valueTypeProperty = 0);
+ bool checkValidId(QDeclarativeScript::Value *, const QString &);
+
+
+ void genObject(QDeclarativeScript::Object *obj);
+ void genObjectBody(QDeclarativeScript::Object *obj);
+ void genValueTypeProperty(QDeclarativeScript::Object *obj,QDeclarativeScript::Property *);
+ void genComponent(QDeclarativeScript::Object *obj);
+ void genValueProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj);
+ void genListProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj);
+ void genPropertyAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Property *valueTypeProperty = 0);
+ void genLiteralAssignment(QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Value *value);
+ void genBindingAssignment(QDeclarativeScript::Value *binding,
+ QDeclarativeScript::Property *prop,
+ QDeclarativeScript::Object *obj,
+ QDeclarativeScript::Property *valueTypeProperty = 0);
int genContextCache();
- int genValueTypeData(QDeclarativeParser::Property *prop, QDeclarativeParser::Property *valueTypeProp);
- int genPropertyData(QDeclarativeParser::Property *prop);
+ int genValueTypeData(QDeclarativeScript::Property *prop, QDeclarativeScript::Property *valueTypeProp);
+ int genPropertyData(QDeclarativeScript::Property *prop);
int componentTypeRef();
- static QDeclarativeType *toQmlType(QDeclarativeParser::Object *from);
- bool canCoerce(int to, QDeclarativeParser::Object *from);
+ static QDeclarativeType *toQmlType(QDeclarativeScript::Object *from);
+ bool canCoerce(int to, QDeclarativeScript::Object *from);
- QString elementName(QDeclarativeParser::Object *);
+ QString elementName(QDeclarativeScript::Object *);
- QStringList deferredProperties(QDeclarativeParser::Object *);
+ QStringList deferredProperties(QDeclarativeScript::Object *);
- QDeclarativePropertyCache::Data *property(QDeclarativeParser::Object *, int);
- QDeclarativePropertyCache::Data *property(QDeclarativeParser::Object *, const QHashedStringRef &,
+ QDeclarativePropertyCache::Data *property(QDeclarativeScript::Object *, int);
+ QDeclarativePropertyCache::Data *property(QDeclarativeScript::Object *, const QHashedStringRef &,
bool *notInRevision = 0);
- QDeclarativePropertyCache::Data *signal(QDeclarativeParser::Object *, const QHashedStringRef &,
+ QDeclarativePropertyCache::Data *signal(QDeclarativeScript::Object *, const QHashedStringRef &,
bool *notInRevision = 0);
- int indexOfProperty(QDeclarativeParser::Object *, const QHashedStringRef &, bool *notInRevision = 0);
- int indexOfProperty(QDeclarativeParser::Object *, const QString &, bool *notInRevision = 0);
- int indexOfSignal(QDeclarativeParser::Object *, const QString &, bool *notInRevision = 0);
+ int indexOfProperty(QDeclarativeScript::Object *, const QHashedStringRef &, bool *notInRevision = 0);
+ int indexOfProperty(QDeclarativeScript::Object *, const QString &, bool *notInRevision = 0);
+ int indexOfSignal(QDeclarativeScript::Object *, const QString &, bool *notInRevision = 0);
- void addId(const QString &, QDeclarativeParser::Object *);
+ void addId(const QString &, QDeclarativeScript::Object *);
void dumpStats();
@@ -358,14 +358,14 @@ private:
QDeclarativePool *pool;
- QDeclarativeCompilerTypes::ComponentCompileState *componentState(QDeclarativeParser::Object *);
+ QDeclarativeCompilerTypes::ComponentCompileState *componentState(QDeclarativeScript::Object *);
void saveComponentState();
QList<QDeclarativeError> exceptions;
QDeclarativeCompiledData *output;
QDeclarativeEngine *engine;
QDeclarativeEnginePrivate *enginePrivate;
- QDeclarativeParser::Object *unitRoot;
+ QDeclarativeScript::Object *unitRoot;
QDeclarativeTypeData *unit;
@@ -377,8 +377,8 @@ private:
int lineNumber;
int ids;
- QList<QDeclarativeParser::LocationSpan> scriptBindings;
- QList<QDeclarativeParser::LocationSpan> optimizedBindings;
+ QList<QDeclarativeScript::LocationSpan> scriptBindings;
+ QList<QDeclarativeScript::LocationSpan> optimizedBindings;
int objects;
};
struct ComponentStats : public QDeclarativePool::Class
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index ca7f3e0f74..eea94cef3e 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -51,7 +51,7 @@
#include "private/qdeclarativebinding_p.h"
#include "private/qdeclarativebinding_p_p.h"
#include "private/qdeclarativeglobal_p.h"
-#include "private/qdeclarativescriptparser_p.h"
+#include "private/qdeclarativescript_p.h"
#include "private/qdeclarativedebugtrace_p.h"
#include "private/qdeclarativeenginedebug_p.h"
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index 5f4072130a..9a068bbf8d 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -60,7 +60,7 @@
#include "private/qdeclarativetypenamecache_p.h"
#include "private/qdeclarativenotifier_p.h"
#include "qdeclarativelist.h"
-#include "private/qdeclarativeparser_p.h"
+#include "private/qdeclarativescript_p.h"
#include <QtCore/qhash.h>
#include <QtDeclarative/qjsvalue.h>
diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp
index 52c4f2d2ae..e806707a06 100644
--- a/src/declarative/qml/qdeclarativecustomparser.cpp
+++ b/src/declarative/qml/qdeclarativecustomparser.cpp
@@ -42,14 +42,13 @@
#include "private/qdeclarativecustomparser_p.h"
#include "private/qdeclarativecustomparser_p_p.h"
-#include "private/qdeclarativeparser_p.h"
#include "private/qdeclarativecompiler_p.h"
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
-using namespace QDeclarativeParser;
+using namespace QDeclarativeScript;
/*!
\class QDeclarativeCustomParser
@@ -95,7 +94,7 @@ using namespace QDeclarativeParser;
*/
QDeclarativeCustomParserNode
-QDeclarativeCustomParserNodePrivate::fromObject(QDeclarativeParser::Object *root)
+QDeclarativeCustomParserNodePrivate::fromObject(QDeclarativeScript::Object *root)
{
QDeclarativeCustomParserNode rootNode;
rootNode.d->name = root->typeName;
@@ -112,7 +111,7 @@ QDeclarativeCustomParserNodePrivate::fromObject(QDeclarativeParser::Object *root
}
QDeclarativeCustomParserProperty
-QDeclarativeCustomParserNodePrivate::fromProperty(QDeclarativeParser::Property *p)
+QDeclarativeCustomParserNodePrivate::fromProperty(QDeclarativeScript::Property *p)
{
QDeclarativeCustomParserProperty prop;
prop.d->name = p->name().toUtf8();
@@ -125,8 +124,8 @@ QDeclarativeCustomParserNodePrivate::fromProperty(QDeclarativeParser::Property *
for (int ii = 0; ii < props.count(); ++ii)
prop.d->values << QVariant::fromValue(props.at(ii));
} else {
- for (QDeclarativeParser::Value *v = p->values.first(); v; v = p->values.next(v)) {
- v->type = QDeclarativeParser::Value::Literal;
+ for (QDeclarativeScript::Value *v = p->values.first(); v; v = p->values.next(v)) {
+ v->type = QDeclarativeScript::Value::Literal;
if(v->object) {
QDeclarativeCustomParserNode node = fromObject(v->object);
@@ -175,7 +174,7 @@ QList<QDeclarativeCustomParserProperty> QDeclarativeCustomParserNode::properties
return d->properties;
}
-QDeclarativeParser::Location QDeclarativeCustomParserNode::location() const
+QDeclarativeScript::Location QDeclarativeCustomParserNode::location() const
{
return d->location;
}
@@ -215,7 +214,7 @@ bool QDeclarativeCustomParserProperty::isList() const
return d->isList;
}
-QDeclarativeParser::Location QDeclarativeCustomParserProperty::location() const
+QDeclarativeScript::Location QDeclarativeCustomParserProperty::location() const
{
return d->location;
}
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
index 31452836bd..47b3ee8f8e 100644
--- a/src/declarative/qml/qdeclarativecustomparser_p.h
+++ b/src/declarative/qml/qdeclarativecustomparser_p.h
@@ -55,7 +55,7 @@
#include "private/qdeclarativemetatype_p.h"
#include "qdeclarativeerror.h"
-#include "private/qdeclarativeparser_p.h"
+#include "private/qdeclarativescript_p.h"
#include "private/qdeclarativebinding_p.h"
#include <QtCore/qbytearray.h>
@@ -79,10 +79,10 @@ public:
~QDeclarativeCustomParserProperty();
QByteArray name() const;
- QDeclarativeParser::Location location() const;
+ QDeclarativeScript::Location location() const;
bool isList() const;
- // Will be one of QDeclarativeParser::Variant, QDeclarativeCustomParserProperty or
+ // Will be one of QDeclarativeScript::Variant, QDeclarativeCustomParserProperty or
// QDeclarativeCustomParserNode
QList<QVariant> assignedValues() const;
@@ -102,7 +102,7 @@ public:
~QDeclarativeCustomParserNode();
QByteArray name() const;
- QDeclarativeParser::Location location() const;
+ QDeclarativeScript::Location location() const;
QList<QDeclarativeCustomParserProperty> properties() const;
@@ -147,7 +147,7 @@ protected:
private:
QList<QDeclarativeError> exceptions;
QDeclarativeCompiler *compiler;
- QDeclarativeParser::Object *object;
+ QDeclarativeScript::Object *object;
Flags m_flags;
friend class QDeclarativeCompiler;
};
diff --git a/src/declarative/qml/qdeclarativecustomparser_p_p.h b/src/declarative/qml/qdeclarativecustomparser_p_p.h
index 386dd96bb4..b11cb3432d 100644
--- a/src/declarative/qml/qdeclarativecustomparser_p_p.h
+++ b/src/declarative/qml/qdeclarativecustomparser_p_p.h
@@ -55,7 +55,7 @@
#include "private/qdeclarativecustomparser_p.h"
-#include "private/qdeclarativeparser_p.h"
+#include "private/qdeclarativescript_p.h"
#include <QtCore/qglobal.h>
@@ -66,10 +66,10 @@ class QDeclarativeCustomParserNodePrivate
public:
QByteArray name;
QList<QDeclarativeCustomParserProperty> properties;
- QDeclarativeParser::Location location;
+ QDeclarativeScript::Location location;
- static QDeclarativeCustomParserNode fromObject(QDeclarativeParser::Object *);
- static QDeclarativeCustomParserProperty fromProperty(QDeclarativeParser::Property *);
+ static QDeclarativeCustomParserNode fromObject(QDeclarativeScript::Object *);
+ static QDeclarativeCustomParserProperty fromProperty(QDeclarativeScript::Property *);
};
class QDeclarativeCustomParserPropertyPrivate
@@ -80,7 +80,7 @@ public:
QByteArray name;
bool isList;
- QDeclarativeParser::Location location;
+ QDeclarativeScript::Location location;
QList<QVariant> values;
};
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index 539f1b8584..3df19a91e1 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -121,7 +121,7 @@ public:
QString resolvedUri(const QString &dir_arg, QDeclarativeImportDatabase *database);
bool add(const QDeclarativeDirComponents &qmldircomponentsnetwork,
const QString& uri_arg, const QString& prefix,
- int vmaj, int vmin, QDeclarativeScriptParser::Import::Type importType,
+ int vmaj, int vmin, QDeclarativeScript::Import::Type importType,
QDeclarativeImportDatabase *database, QList<QDeclarativeError> *errors);
bool find(const QString& type, int *vmajor, int *vminor,
QDeclarativeType** type_return, QString* url_return, QList<QDeclarativeError> *errors);
@@ -463,7 +463,7 @@ QString QDeclarativeImportsPrivate::resolvedUri(const QString &dir_arg, QDeclara
bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomponentsnetwork,
const QString& uri_arg, const QString& prefix, int vmaj, int vmin,
- QDeclarativeScriptParser::Import::Type importType,
+ QDeclarativeScript::Import::Type importType,
QDeclarativeImportDatabase *database, QList<QDeclarativeError> *errors)
{
static QLatin1String Slash_qmldir("/qmldir");
@@ -481,7 +481,7 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
}
QString url = uri;
bool versionFound = false;
- if (importType == QDeclarativeScriptParser::Import::Library) {
+ if (importType == QDeclarativeScript::Import::Library) {
Q_ASSERT(vmaj >= 0 && vmin >= 0); // Versions are always specified for libraries
@@ -561,7 +561,7 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
return false;
}
} else {
- if (importType == QDeclarativeScriptParser::Import::File && qmldircomponents.isEmpty()) {
+ if (importType == QDeclarativeScript::Import::File && qmldircomponents.isEmpty()) {
QString importUrl = resolveLocalUrl(base, uri + Slash_qmldir);
QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl);
if (!localFileOrQrc.isEmpty()) {
@@ -633,7 +633,7 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
data.url = url;
data.majversion = vmaj;
data.minversion = vmin;
- data.isLibrary = importType == QDeclarativeScriptParser::Import::Library;
+ data.isLibrary = importType == QDeclarativeScript::Import::Library;
data.qmlDirComponents = qmldircomponents;
s->imports.prepend(data);
@@ -824,14 +824,14 @@ QDeclarativeImportDatabase::~QDeclarativeImportDatabase()
*/
bool QDeclarativeImports::addImport(QDeclarativeImportDatabase *importDb,
const QString& uri, const QString& prefix, int vmaj, int vmin,
- QDeclarativeScriptParser::Import::Type importType,
+ QDeclarativeScript::Import::Type importType,
const QDeclarativeDirComponents &qmldircomponentsnetwork,
QList<QDeclarativeError> *errors)
{
if (qmlImportTrace())
qDebug().nospace() << "QDeclarativeImports(" << qPrintable(baseUrl().toString()) << ")" << "::addImport: "
<< uri << " " << vmaj << '.' << vmin << " "
- << (importType==QDeclarativeScriptParser::Import::Library? "Library" : "File")
+ << (importType==QDeclarativeScript::Import::Library? "Library" : "File")
<< " as " << prefix;
return d->add(qmldircomponentsnetwork, uri, prefix, vmaj, vmin, importType, importDb, errors);
diff --git a/src/declarative/qml/qdeclarativeimport_p.h b/src/declarative/qml/qdeclarativeimport_p.h
index 4f3b9c2a2d..c695a6b423 100644
--- a/src/declarative/qml/qdeclarativeimport_p.h
+++ b/src/declarative/qml/qdeclarativeimport_p.h
@@ -45,8 +45,9 @@
#include <QtCore/qurl.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qset.h>
+#include <QtCore/qstringlist.h>
#include <private/qdeclarativedirparser_p.h>
-#include <private/qdeclarativescriptparser_p.h>
+#include <private/qdeclarativescript_p.h>
#include <private/qdeclarativemetatype_p.h>
//
@@ -93,7 +94,7 @@ public:
bool addImport(QDeclarativeImportDatabase *,
const QString& uri, const QString& prefix, int vmaj, int vmin,
- QDeclarativeScriptParser::Import::Type importType,
+ QDeclarativeScript::Import::Type importType,
const QDeclarativeDirComponents &qmldircomponentsnetwork,
QList<QDeclarativeError> *errors);
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
deleted file mode 100644
index 6807a7c84a..0000000000
--- a/src/declarative/qml/qdeclarativeparser.cpp
+++ /dev/null
@@ -1,450 +0,0 @@
-/****************************************************************************
-**
-** 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 "private/qdeclarativeparser_p.h"
-
-#include "qdeclarativepropertyvaluesource.h"
-#include "private/qdeclarativevme_p.h"
-#include "qdeclarative.h"
-#include "private/qdeclarativecomponent_p.h"
-#include "qdeclarativecomponent.h"
-#include "private/qmetaobjectbuilder_p.h"
-#include "private/qdeclarativevmemetaobject_p.h"
-#include "private/qdeclarativecompiler_p.h"
-#include "parser/qdeclarativejsast_p.h"
-#include "parser/qdeclarativejsengine_p.h"
-
-#include <QStack>
-#include <QColor>
-#include <QPointF>
-#include <QSizeF>
-#include <QRectF>
-#include <QStringBuilder>
-#include <QtDebug>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QDeclarativeJS;
-using namespace QDeclarativeParser;
-
-QDeclarativeParser::Object::Object()
-: type(-1), idIndex(-1), metatype(0), synthCache(0), defaultProperty(0), parserStatusCast(-1),
- componentCompileState(0), nextAliasingObject(0), nextIdObject(0)
-{
-}
-
-QDeclarativeParser::Object::~Object()
-{
- if (synthCache) synthCache->release();
-}
-
-void Object::setBindingBit(int b)
-{
- while (bindingBitmask.size() < 4 * (1 + b / 32))
- bindingBitmask.append(char(0));
-
- quint32 *bits = (quint32 *)bindingBitmask.data();
- bits[b / 32] |= (1 << (b % 32));
-}
-
-const QMetaObject *Object::metaObject() const
-{
- if (!metadata.isEmpty() && metatype)
- return &extObject;
- else
- return metatype;
-}
-
-QDeclarativeParser::Property *Object::getDefaultProperty()
-{
- if (!defaultProperty) {
- defaultProperty = pool()->New<Property>();
- defaultProperty->parent = this;
- }
- return defaultProperty;
-}
-
-void QDeclarativeParser::Object::addValueProperty(Property *p)
-{
- valueProperties.append(p);
-}
-
-void QDeclarativeParser::Object::addSignalProperty(Property *p)
-{
- signalProperties.append(p);
-}
-
-void QDeclarativeParser::Object::addAttachedProperty(Property *p)
-{
- attachedProperties.append(p);
-}
-
-void QDeclarativeParser::Object::addGroupedProperty(Property *p)
-{
- groupedProperties.append(p);
-}
-
-void QDeclarativeParser::Object::addValueTypeProperty(Property *p)
-{
- valueTypeProperties.append(p);
-}
-
-void QDeclarativeParser::Object::addScriptStringProperty(Property *p)
-{
- scriptStringProperties.append(p);
-}
-
-// This lookup is optimized for missing, and having to create a new property.
-Property *QDeclarativeParser::Object::getProperty(const QHashedStringRef &name, bool create)
-{
- if (create) {
- quint32 h = name.hash();
- if (propertiesHashField.testAndSet(h)) {
- for (Property *p = properties.first(); p; p = properties.next(p)) {
- if (p->name() == name)
- return p;
- }
- }
-
- Property *property = pool()->New<Property>();
- property->parent = this;
- property->_name = name;
- property->isDefault = false;
- properties.prepend(property);
- return property;
- } else {
- for (Property *p = properties.first(); p; p = properties.next(p)) {
- if (p->name() == name)
- return p;
- }
- }
-}
-
-Property *QDeclarativeParser::Object::getProperty(const QStringRef &name, bool create)
-{
- return getProperty(QHashedStringRef(name), create);
-}
-
-Property *QDeclarativeParser::Object::getProperty(const QString &name, bool create)
-{
- for (Property *p = properties.first(); p; p = properties.next(p)) {
- if (p->name() == name)
- return p;
- }
-
- if (create) {
- Property *property = pool()->New<Property>();
- property->parent = this;
- property->_name = QStringRef(pool()->NewString(name));
- propertiesHashField.testAndSet(property->_name.hash());
- property->isDefault = false;
- properties.prepend(property);
- return property;
- } else {
- return 0;
- }
-}
-
-QDeclarativeParser::Object::DynamicProperty::DynamicProperty()
-: isDefaultProperty(false), type(Variant), defaultValue(0), nextProperty(0),
- resolvedCustomTypeName(0)
-{
-}
-
-QDeclarativeParser::Object::DynamicSignal::DynamicSignal()
-: nextSignal(0)
-{
-}
-
-// Returns length in utf8 bytes
-int QDeclarativeParser::Object::DynamicSignal::parameterTypesLength() const
-{
- int rv = 0;
- for (int ii = 0; ii < parameterTypes.count(); ++ii)
- rv += parameterTypes.at(ii).length();
- return rv;
-}
-
-// Returns length in utf8 bytes
-int QDeclarativeParser::Object::DynamicSignal::parameterNamesLength() const
-{
- int rv = 0;
- for (int ii = 0; ii < parameterNames.count(); ++ii)
- rv += parameterNames.at(ii).utf8length();
- return rv;
-}
-
-QDeclarativeParser::Object::DynamicSlot::DynamicSlot()
-: nextSlot(0)
-{
-}
-
-int QDeclarativeParser::Object::DynamicSlot::parameterNamesLength() const
-{
- int rv = 0;
- for (int ii = 0; ii < parameterNames.count(); ++ii)
- rv += parameterNames.at(ii).length();
- return rv;
-}
-
-QDeclarativeParser::Property::Property()
-: parent(0), type(0), index(-1), value(0), isDefault(true), isDeferred(false),
- isValueTypeSubProperty(false), isAlias(false), scriptStringScope(-1), nextMainProperty(0),
- nextProperty(0)
-{
-}
-
-QDeclarativeParser::Object *QDeclarativeParser::Property::getValue(const LocationSpan &l)
-{
- if (!value) { value = pool()->New<Object>(); value->location = l; }
- return value;
-}
-
-void QDeclarativeParser::Property::addValue(Value *v)
-{
- values.append(v);
-}
-
-void QDeclarativeParser::Property::addOnValue(Value *v)
-{
- onValues.append(v);
-}
-
-bool QDeclarativeParser::Property::isEmpty() const
-{
- return !value && values.isEmpty() && onValues.isEmpty();
-}
-
-QDeclarativeParser::Value::Value()
-: type(Unknown), object(0), bindingReference(0), signalExpressionContextStack(0), nextValue(0)
-{
-}
-
-QDeclarativeParser::Variant::Variant()
-: t(Invalid)
-{
-}
-
-QDeclarativeParser::Variant::Variant(const Variant &o)
-: t(o.t), d(o.d), asWritten(o.asWritten)
-{
-}
-
-QDeclarativeParser::Variant::Variant(bool v)
-: t(Boolean), b(v)
-{
-}
-
-QDeclarativeParser::Variant::Variant(double v, const QStringRef &asWritten)
-: t(Number), d(v), asWritten(asWritten)
-{
-}
-
-QDeclarativeParser::Variant::Variant(QDeclarativeJS::AST::StringLiteral *v)
-: t(String), l(v)
-{
-}
-
-QDeclarativeParser::Variant::Variant(const QStringRef &asWritten, QDeclarativeJS::AST::Node *n)
-: t(Script), n(n), asWritten(asWritten)
-{
-}
-
-QDeclarativeParser::Variant &QDeclarativeParser::Variant::operator=(const Variant &o)
-{
- t = o.t;
- d = o.d;
- asWritten = o.asWritten;
- return *this;
-}
-
-QDeclarativeParser::Variant::Type QDeclarativeParser::Variant::type() const
-{
- return t;
-}
-
-bool QDeclarativeParser::Variant::asBoolean() const
-{
- return b;
-}
-
-QString QDeclarativeParser::Variant::asString() const
-{
- if (t == String) {
- // XXX aakenned
- return l->value.toString();
- } else {
- return asWritten.toString();
- }
-}
-
-double QDeclarativeParser::Variant::asNumber() const
-{
- return d;
-}
-
-//reverse of Lexer::singleEscape()
-QString escapedString(const QString &string)
-{
- QString tmp = QLatin1String("\"");
- for (int i = 0; i < string.length(); ++i) {
- const QChar &c = string.at(i);
- switch(c.unicode()) {
- case 0x08:
- tmp += QLatin1String("\\b");
- break;
- case 0x09:
- tmp += QLatin1String("\\t");
- break;
- case 0x0A:
- tmp += QLatin1String("\\n");
- break;
- case 0x0B:
- tmp += QLatin1String("\\v");
- break;
- case 0x0C:
- tmp += QLatin1String("\\f");
- break;
- case 0x0D:
- tmp += QLatin1String("\\r");
- break;
- case 0x22:
- tmp += QLatin1String("\\\"");
- break;
- case 0x27:
- tmp += QLatin1String("\\\'");
- break;
- case 0x5C:
- tmp += QLatin1String("\\\\");
- break;
- default:
- tmp += c;
- break;
- }
- }
- tmp += QLatin1Char('\"');
- return tmp;
-}
-
-QString QDeclarativeParser::Variant::asScript() const
-{
- switch(type()) {
- default:
- case Invalid:
- return QString();
- case Boolean:
- return b?QLatin1String("true"):QLatin1String("false");
- case Number:
- if (asWritten.isEmpty())
- return QString::number(d);
- else
- return asWritten.toString();
- case String:
- return escapedString(asString());
- case Script:
- if (AST::IdentifierExpression *i = AST::cast<AST::IdentifierExpression *>(n)) {
- // XXX aakenned
- return i->name.toString();
- } else
- return asWritten.toString();
- }
-}
-
-QDeclarativeJS::AST::Node *QDeclarativeParser::Variant::asAST() const
-{
- if (type() == Script)
- return n;
- else
- return 0;
-}
-
-bool QDeclarativeParser::Variant::isStringList() const
-{
- if (isString())
- return true;
-
- if (type() != Script || !n)
- return false;
-
- AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
- if (!array)
- return false;
-
- AST::ElementList *elements = array->elements;
-
- while (elements) {
-
- if (!AST::cast<AST::StringLiteral *>(elements->expression))
- return false;
-
- elements = elements->next;
- }
-
- return true;
-}
-
-QStringList QDeclarativeParser::Variant::asStringList() const
-{
- QStringList rv;
- if (isString()) {
- rv << asString();
- return rv;
- }
-
- AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
- if (!array)
- return rv;
-
- AST::ElementList *elements = array->elements;
- while (elements) {
-
- AST::StringLiteral *string = AST::cast<AST::StringLiteral *>(elements->expression);
- if (!string)
- return QStringList();
- rv.append(string->value.toString());
-
- elements = elements->next;
- }
-
- return rv;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
deleted file mode 100644
index ee7927fa76..0000000000
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ /dev/null
@@ -1,463 +0,0 @@
-/****************************************************************************
-**
-** 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 QDECLARATIVEPARSER_P_H
-#define QDECLARATIVEPARSER_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 "qdeclarative.h"
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qstringlist.h>
-
-#include <private/qobject_p.h>
-#include <private/qdeclarativerefcount_p.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativepool_p.h>
-#include <private/qfieldlist_p.h>
-#include <private/qdeclarativepropertycache_p.h>
-#include <private/qfastmetabuilder_p.h>
-#include <private/qhashedstring_p.h>
-#include <private/qhashfield_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativePropertyCache;
-namespace QDeclarativeJS { namespace AST { class Node; class StringLiteral; } }
-namespace QDeclarativeCompilerTypes { class BindingReference; class ComponentCompileState; }
-
-/*
- XXX
-
- These types are created (and owned) by the QDeclarativeScriptParser and consumed by the
- QDeclarativeCompiler. During the compilation phase the compiler will update some of
- the fields for its own use.
-
- The types are part of the generic sounding "QDeclarativeParser" namespace for legacy
- reasons (there used to be more in this namespace) and will be cleaned up and
- migrated into a more appropriate location eventually.
-*/
-namespace QDeclarativeParser
-{
- struct Location
- {
- Location() : line(-1), column(-1) {}
- int line;
- int column;
-
- inline bool operator<(const Location &other) {
- return line < other.line ||
- (line == other.line && column < other.column);
- }
- };
-
- struct LocationRange
- {
- LocationRange() : offset(0), length(0) {}
- quint32 offset;
- quint32 length;
- };
-
- struct LocationSpan
- {
- Location start;
- Location end;
- LocationRange range;
-
- bool operator<(LocationSpan &o) const {
- return (start.line < o.start.line) ||
- (start.line == o.start.line && start.column < o.start.column);
- }
- };
-
- class Object;
- class Property;
- class Q_DECLARATIVE_EXPORT Variant
- {
- public:
- enum Type {
- Invalid,
- Boolean,
- Number,
- String,
- Script
- };
-
- Variant();
- Variant(const Variant &);
- explicit Variant(bool);
- explicit Variant(double, const QStringRef &asWritten = QStringRef());
- explicit Variant(QDeclarativeJS::AST::StringLiteral *);
- explicit Variant(const QStringRef &asWritten, QDeclarativeJS::AST::Node *);
- Variant &operator=(const Variant &);
-
- Type type() const;
-
- bool isBoolean() const { return type() == Boolean; }
- bool isNumber() const { return type() == Number; }
- bool isString() const { return type() == String; }
- bool isScript() const { return type() == Script; }
- bool isStringList() const;
-
- bool asBoolean() const;
- QString asString() const;
- double asNumber() const;
- QString asScript() const;
- QDeclarativeJS::AST::Node *asAST() const;
- QStringList asStringList() const;
-
- private:
- Type t;
- union {
- bool b;
- double d;
- QDeclarativeJS::AST::StringLiteral *l;
- QDeclarativeJS::AST::Node *n;
- };
- QStringRef asWritten;
- };
-
- class Value : public QDeclarativePool::POD
- {
- public:
- Value();
-
- enum Type {
- // The type of this value assignment is not yet known
- Unknown,
- // This is used as a literal property assignment
- Literal,
- // This is used as a property binding assignment
- PropertyBinding,
- // This is used as a QDeclarativePropertyValueSource assignment
- ValueSource,
- // This is used as a QDeclarativePropertyValueInterceptor assignment
- ValueInterceptor,
- // This is used as a property QObject assignment
- CreatedObject,
- // This is used as a signal object assignment
- SignalObject,
- // This is used as a signal expression assignment
- SignalExpression,
- // This is used as an id assignment only
- Id
- };
- Type type;
-
- // ### Temporary (for id only)
- QString primitive() const { return value.isString() ? value.asString() : value.asScript(); }
-
- // Primitive value
- Variant value;
- // Object value
- Object *object;
-
- LocationSpan location;
-
- // Used by compiler
- QDeclarativeCompilerTypes::BindingReference *bindingReference;
- int signalExpressionContextStack;
-
- // Used in Property::ValueList lists
- Value *nextValue;
- };
-
- class Property : public QDeclarativePool::POD
- {
- public:
- Property();
-
- // The Object to which this property is attached
- Object *parent;
-
- Object *getValue(const LocationSpan &);
- void addValue(Value *v);
- void addOnValue(Value *v);
-
- // The QVariant::Type of the property, or 0 (QVariant::Invalid) if
- // unknown.
- int type;
- // The metaobject index of this property, or -1 if unknown.
- int index;
- // The core data in the case of a regular property.
- // XXX This has to be a value now as the synthCache may change during
- // compilation which invalidates pointers. We should fix this.
- QDeclarativePropertyCache::Data core;
-
- // Returns true if this is an empty property - both value and values
- // are unset.
- bool isEmpty() const;
-
- typedef QFieldList<Value, &Value::nextValue> ValueList;
- // The list of values assigned to this property. Content in values
- // and value are mutually exclusive
- ValueList values;
- // The list of values assigned to this property using the "on" syntax
- ValueList onValues;
- // The accessed property. This is used to represent dot properties.
- // Content in value and values are mutually exclusive.
- Object *value;
- // The property name
- const QHashedStringRef &name() const { return _name; }
- void setName(const QString &n) { _name = QHashedStringRef(pool()->NewString(n)); }
- void setName(const QHashedStringRef &n) { _name = n; }
- // True if this property was accessed as the default property.
- bool isDefault;
- // True if the setting of this property will be deferred. Set by the
- // QDeclarativeCompiler
- bool isDeferred;
- // True if this property is a value-type pseudo-property
- bool isValueTypeSubProperty;
- // True if this property is a property alias. Set by the
- // QDeclarativeCompiler
- bool isAlias;
-
- // Used for scriptStringProperties
- int scriptStringScope;
-
- LocationSpan location;
- LocationRange listValueRange;
-
- // Used in Object::MainPropertyList
- Property *nextMainProperty;
-
- // Used in Object::PropertyList lists
- Property *nextProperty;
-
- private:
- friend class Object;
- QHashedStringRef _name;
- };
-
- class Object : public QDeclarativePool::Class
- {
- public:
- Object();
- virtual ~Object();
-
- // Type of the object. The integer is an index into the
- // QDeclarativeCompiledData::types array, or -1 if the object is a property
- // group.
- int type;
-
- // The fully-qualified name of this type
- QByteArray typeName;
- // The id assigned to the object (if any). Set by the QDeclarativeCompiler
- QString id;
- // The id index assigned to the object (if any). Set by the QDeclarativeCompiler
- int idIndex;
- // Custom parsed data
- QByteArray custom;
- // Bit mask of the properties assigned bindings
- QByteArray bindingBitmask;
- void setBindingBit(int);
- // Returns the metaobject for this type, or 0 if not available.
- // Internally selectd between the metatype and extObject variables
- const QMetaObject *metaObject() const;
-
- // The compile time metaobject for this type
- const QMetaObject *metatype;
- // The synthesized metaobject, if QML added signals or properties to
- // this type. Otherwise null
- QAbstractDynamicMetaObject extObject;
- QByteArray metadata; // Generated by compiler
- QByteArray synthdata; // Generated by compiler
- QDeclarativePropertyCache *synthCache; // Generated by compiler
-
- Property *getDefaultProperty();
- // name ptr must be guarenteed to remain valid
- Property *getProperty(const QHashedStringRef &name, bool create=true);
- Property *getProperty(const QStringRef &name, bool create=true);
- Property *getProperty(const QString &name, bool create=true);
-
- Property *defaultProperty;
-
- typedef QFieldList<Property, &Property::nextMainProperty> MainPropertyList;
- MainPropertyList properties;
- QHashField propertiesHashField;
-
- // Output of the compilation phase (these properties continue to exist
- // in either the defaultProperty or properties members too)
- void addValueProperty(Property *);
- void addSignalProperty(Property *);
- void addAttachedProperty(Property *);
- void addGroupedProperty(Property *);
- void addValueTypeProperty(Property *);
- void addScriptStringProperty(Property *);
-
- typedef QFieldList<Property, &Property::nextProperty> PropertyList;
- PropertyList valueProperties;
- PropertyList signalProperties;
- PropertyList attachedProperties;
- PropertyList groupedProperties;
- PropertyList valueTypeProperties;
- PropertyList scriptStringProperties;
-
- // Script blocks that were nested under this object
- struct ScriptBlock {
- enum Pragma {
- None = 0x00000000,
- Shared = 0x00000001
- };
- Q_DECLARE_FLAGS(Pragmas, Pragma)
-
- QString code;
- QString file;
- Pragmas pragmas;
- };
-
- // The bytes to cast instances by to get to the QDeclarativeParserStatus
- // interface. -1 indicates the type doesn't support this interface.
- // Set by the QDeclarativeCompiler.
- int parserStatusCast;
-
- LocationSpan location;
-
- struct DynamicProperty : public QDeclarativePool::POD
- {
- DynamicProperty();
-
- enum Type { Variant, Int, Bool, Real, String, Url, Color, Time,
- Date, DateTime, Alias, Custom, CustomList };
-
- bool isDefaultProperty;
- Type type;
-
- QHashedStringRef customType;
- QHashedStringRef name;
- QDeclarativeParser::Property *defaultValue;
- LocationSpan location;
-
- // Used by Object::DynamicPropertyList
- DynamicProperty *nextProperty;
-
- // Used by the compiler
- QByteArray *resolvedCustomTypeName;
- QFastMetaBuilder::StringRef typeRef;
- QFastMetaBuilder::StringRef nameRef;
- QFastMetaBuilder::StringRef changedSignatureRef;
- };
-
- struct DynamicSignal : public QDeclarativePool::POD
- {
- DynamicSignal();
-
- QHashedStringRef name;
- QDeclarativePool::List<QHashedCStringRef> parameterTypes;
- QDeclarativePool::List<QHashedStringRef> parameterNames;
-
- int parameterTypesLength() const;
- int parameterNamesLength() const;
-
- // Used by Object::DynamicSignalList
- DynamicSignal *nextSignal;
-
- // Used by the compiler
- QFastMetaBuilder::StringRef signatureRef;
- QFastMetaBuilder::StringRef parameterNamesRef;
- };
-
- struct DynamicSlot : public QDeclarativePool::Class
- {
- DynamicSlot();
-
- QHashedStringRef name;
- QString body;
- QList<QByteArray> parameterNames;
- LocationSpan location;
-
- int parameterNamesLength() const;
-
- // Used by Object::DynamicSlotList
- DynamicSlot *nextSlot;
-
- // Used by the compiler
- QFastMetaBuilder::StringRef signatureRef;
- QFastMetaBuilder::StringRef parameterNamesRef;
- };
-
- // The list of dynamic properties
- typedef QFieldList<DynamicProperty, &DynamicProperty::nextProperty> DynamicPropertyList;
- DynamicPropertyList dynamicProperties;
- // The list of dynamic signals
- typedef QFieldList<DynamicSignal, &DynamicSignal::nextSignal> DynamicSignalList;
- DynamicSignalList dynamicSignals;
- // The list of dynamic slots
- typedef QFieldList<DynamicSlot, &DynamicSlot::nextSlot> DynamicSlotList;
- DynamicSlotList dynamicSlots;
-
- // Used by compiler
- QDeclarativeCompilerTypes::ComponentCompileState *componentCompileState;
-
- // Used by ComponentCompileState::AliasingObjectsList
- Object *nextAliasingObject;
- // Used by ComponentComppileState::IdList
- Object *nextIdObject;
- };
-
-}
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeParser::Object::ScriptBlock::Pragmas);
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarativeParser::Variant)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPARSER_P_H
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescript.cpp
index 71b0bd27c2..e83e4026d8 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescript.cpp
@@ -39,9 +39,8 @@
**
****************************************************************************/
-#include "private/qdeclarativescriptparser_p.h"
+#include "private/qdeclarativescript_p.h"
-#include "private/qdeclarativeparser_p.h"
#include "parser/qdeclarativejsengine_p.h"
#include "parser/qdeclarativejsparser_p.h"
#include "parser/qdeclarativejslexer_p.h"
@@ -57,9 +56,399 @@
QT_BEGIN_NAMESPACE
using namespace QDeclarativeJS;
-using namespace QDeclarativeParser;
+using namespace QDeclarativeScript;
+
+//
+// Parser IR classes
+//
+QDeclarativeScript::Object::Object()
+: type(-1), idIndex(-1), metatype(0), synthCache(0), defaultProperty(0), parserStatusCast(-1),
+ componentCompileState(0), nextAliasingObject(0), nextIdObject(0)
+{
+}
+
+QDeclarativeScript::Object::~Object()
+{
+ if (synthCache) synthCache->release();
+}
+
+void Object::setBindingBit(int b)
+{
+ while (bindingBitmask.size() < 4 * (1 + b / 32))
+ bindingBitmask.append(char(0));
+
+ quint32 *bits = (quint32 *)bindingBitmask.data();
+ bits[b / 32] |= (1 << (b % 32));
+}
+
+const QMetaObject *Object::metaObject() const
+{
+ if (!metadata.isEmpty() && metatype)
+ return &extObject;
+ else
+ return metatype;
+}
+
+QDeclarativeScript::Property *Object::getDefaultProperty()
+{
+ if (!defaultProperty) {
+ defaultProperty = pool()->New<Property>();
+ defaultProperty->parent = this;
+ }
+ return defaultProperty;
+}
+
+void QDeclarativeScript::Object::addValueProperty(Property *p)
+{
+ valueProperties.append(p);
+}
+
+void QDeclarativeScript::Object::addSignalProperty(Property *p)
+{
+ signalProperties.append(p);
+}
+
+void QDeclarativeScript::Object::addAttachedProperty(Property *p)
+{
+ attachedProperties.append(p);
+}
+
+void QDeclarativeScript::Object::addGroupedProperty(Property *p)
+{
+ groupedProperties.append(p);
+}
+
+void QDeclarativeScript::Object::addValueTypeProperty(Property *p)
+{
+ valueTypeProperties.append(p);
+}
+
+void QDeclarativeScript::Object::addScriptStringProperty(Property *p)
+{
+ scriptStringProperties.append(p);
+}
+
+// This lookup is optimized for missing, and having to create a new property.
+Property *QDeclarativeScript::Object::getProperty(const QHashedStringRef &name, bool create)
+{
+ if (create) {
+ quint32 h = name.hash();
+ if (propertiesHashField.testAndSet(h)) {
+ for (Property *p = properties.first(); p; p = properties.next(p)) {
+ if (p->name() == name)
+ return p;
+ }
+ }
+
+ Property *property = pool()->New<Property>();
+ property->parent = this;
+ property->_name = name;
+ property->isDefault = false;
+ properties.prepend(property);
+ return property;
+ } else {
+ for (Property *p = properties.first(); p; p = properties.next(p)) {
+ if (p->name() == name)
+ return p;
+ }
+ }
+
+ return 0;
+}
+
+Property *QDeclarativeScript::Object::getProperty(const QStringRef &name, bool create)
+{
+ return getProperty(QHashedStringRef(name), create);
+}
+
+Property *QDeclarativeScript::Object::getProperty(const QString &name, bool create)
+{
+ for (Property *p = properties.first(); p; p = properties.next(p)) {
+ if (p->name() == name)
+ return p;
+ }
+
+ if (create) {
+ Property *property = pool()->New<Property>();
+ property->parent = this;
+ property->_name = QStringRef(pool()->NewString(name));
+ propertiesHashField.testAndSet(property->_name.hash());
+ property->isDefault = false;
+ properties.prepend(property);
+ return property;
+ } else {
+ return 0;
+ }
+}
+
+QDeclarativeScript::Object::DynamicProperty::DynamicProperty()
+: isDefaultProperty(false), type(Variant), defaultValue(0), nextProperty(0),
+ resolvedCustomTypeName(0)
+{
+}
+
+QDeclarativeScript::Object::DynamicSignal::DynamicSignal()
+: nextSignal(0)
+{
+}
+
+// Returns length in utf8 bytes
+int QDeclarativeScript::Object::DynamicSignal::parameterTypesLength() const
+{
+ int rv = 0;
+ for (int ii = 0; ii < parameterTypes.count(); ++ii)
+ rv += parameterTypes.at(ii).length();
+ return rv;
+}
+
+// Returns length in utf8 bytes
+int QDeclarativeScript::Object::DynamicSignal::parameterNamesLength() const
+{
+ int rv = 0;
+ for (int ii = 0; ii < parameterNames.count(); ++ii)
+ rv += parameterNames.at(ii).utf8length();
+ return rv;
+}
+
+QDeclarativeScript::Object::DynamicSlot::DynamicSlot()
+: nextSlot(0)
+{
+}
+
+int QDeclarativeScript::Object::DynamicSlot::parameterNamesLength() const
+{
+ int rv = 0;
+ for (int ii = 0; ii < parameterNames.count(); ++ii)
+ rv += parameterNames.at(ii).length();
+ return rv;
+}
+
+QDeclarativeScript::Property::Property()
+: parent(0), type(0), index(-1), value(0), isDefault(true), isDeferred(false),
+ isValueTypeSubProperty(false), isAlias(false), scriptStringScope(-1),
+ nextMainProperty(0), nextProperty(0)
+{
+}
+
+QDeclarativeScript::Object *QDeclarativeScript::Property::getValue(const LocationSpan &l)
+{
+ if (!value) { value = pool()->New<Object>(); value->location = l; }
+ return value;
+}
+
+void QDeclarativeScript::Property::addValue(Value *v)
+{
+ values.append(v);
+}
+
+void QDeclarativeScript::Property::addOnValue(Value *v)
+{
+ onValues.append(v);
+}
+
+bool QDeclarativeScript::Property::isEmpty() const
+{
+ return !value && values.isEmpty() && onValues.isEmpty();
+}
+
+QDeclarativeScript::Value::Value()
+: type(Unknown), object(0), bindingReference(0), signalExpressionContextStack(0), nextValue(0)
+{
+}
+
+QDeclarativeScript::Variant::Variant()
+: t(Invalid)
+{
+}
+
+QDeclarativeScript::Variant::Variant(const Variant &o)
+: t(o.t), d(o.d), asWritten(o.asWritten)
+{
+}
+
+QDeclarativeScript::Variant::Variant(bool v)
+: t(Boolean), b(v)
+{
+}
+
+QDeclarativeScript::Variant::Variant(double v, const QStringRef &asWritten)
+: t(Number), d(v), asWritten(asWritten)
+{
+}
+
+QDeclarativeScript::Variant::Variant(QDeclarativeJS::AST::StringLiteral *v)
+: t(String), l(v)
+{
+}
+
+QDeclarativeScript::Variant::Variant(const QStringRef &asWritten, QDeclarativeJS::AST::Node *n)
+: t(Script), n(n), asWritten(asWritten)
+{
+}
+
+QDeclarativeScript::Variant &QDeclarativeScript::Variant::operator=(const Variant &o)
+{
+ t = o.t;
+ d = o.d;
+ asWritten = o.asWritten;
+ return *this;
+}
+
+QDeclarativeScript::Variant::Type QDeclarativeScript::Variant::type() const
+{
+ return t;
+}
+
+bool QDeclarativeScript::Variant::asBoolean() const
+{
+ return b;
+}
+
+QString QDeclarativeScript::Variant::asString() const
+{
+ if (t == String) {
+ // XXX aakenned
+ return l->value.toString();
+ } else {
+ return asWritten.toString();
+ }
+}
+
+double QDeclarativeScript::Variant::asNumber() const
+{
+ return d;
+}
+
+//reverse of Lexer::singleEscape()
+QString escapedString(const QString &string)
+{
+ QString tmp = QLatin1String("\"");
+ for (int i = 0; i < string.length(); ++i) {
+ const QChar &c = string.at(i);
+ switch(c.unicode()) {
+ case 0x08:
+ tmp += QLatin1String("\\b");
+ break;
+ case 0x09:
+ tmp += QLatin1String("\\t");
+ break;
+ case 0x0A:
+ tmp += QLatin1String("\\n");
+ break;
+ case 0x0B:
+ tmp += QLatin1String("\\v");
+ break;
+ case 0x0C:
+ tmp += QLatin1String("\\f");
+ break;
+ case 0x0D:
+ tmp += QLatin1String("\\r");
+ break;
+ case 0x22:
+ tmp += QLatin1String("\\\"");
+ break;
+ case 0x27:
+ tmp += QLatin1String("\\\'");
+ break;
+ case 0x5C:
+ tmp += QLatin1String("\\\\");
+ break;
+ default:
+ tmp += c;
+ break;
+ }
+ }
+ tmp += QLatin1Char('\"');
+ return tmp;
+}
+
+QString QDeclarativeScript::Variant::asScript() const
+{
+ switch(type()) {
+ default:
+ case Invalid:
+ return QString();
+ case Boolean:
+ return b?QLatin1String("true"):QLatin1String("false");
+ case Number:
+ if (asWritten.isEmpty())
+ return QString::number(d);
+ else
+ return asWritten.toString();
+ case String:
+ return escapedString(asString());
+ case Script:
+ if (AST::IdentifierExpression *i = AST::cast<AST::IdentifierExpression *>(n)) {
+ // XXX aakenned
+ return i->name.toString();
+ } else
+ return asWritten.toString();
+ }
+}
+
+QDeclarativeJS::AST::Node *QDeclarativeScript::Variant::asAST() const
+{
+ if (type() == Script)
+ return n;
+ else
+ return 0;
+}
+
+bool QDeclarativeScript::Variant::isStringList() const
+{
+ if (isString())
+ return true;
+
+ if (type() != Script || !n)
+ return false;
+
+ AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
+ if (!array)
+ return false;
+
+ AST::ElementList *elements = array->elements;
+
+ while (elements) {
+
+ if (!AST::cast<AST::StringLiteral *>(elements->expression))
+ return false;
+
+ elements = elements->next;
+ }
+
+ return true;
+}
-void QDeclarativeScriptParser::Import::extractVersion(int *maj, int *min) const
+QStringList QDeclarativeScript::Variant::asStringList() const
+{
+ QStringList rv;
+ if (isString()) {
+ rv << asString();
+ return rv;
+ }
+
+ AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
+ if (!array)
+ return rv;
+
+ AST::ElementList *elements = array->elements;
+ while (elements) {
+
+ AST::StringLiteral *string = AST::cast<AST::StringLiteral *>(elements->expression);
+ if (!string)
+ return QStringList();
+ rv.append(string->value.toString());
+
+ elements = elements->next;
+ }
+
+ return rv;
+}
+
+//
+// Actual parser classes
+//
+void QDeclarativeScript::Import::extractVersion(int *maj, int *min) const
{
*maj = -1; *min = -1;
@@ -81,16 +470,16 @@ class ProcessAST: protected AST::Visitor
{
struct State {
State() : object(0), property(0) {}
- State(QDeclarativeParser::Object *o) : object(o), property(0) {}
- State(QDeclarativeParser::Object *o, Property *p) : object(o), property(p) {}
+ State(QDeclarativeScript::Object *o) : object(o), property(0) {}
+ State(QDeclarativeScript::Object *o, Property *p) : object(o), property(p) {}
- QDeclarativeParser::Object *object;
+ QDeclarativeScript::Object *object;
Property *property;
};
struct StateStack : public QStack<State>
{
- void pushObject(QDeclarativeParser::Object *obj)
+ void pushObject(QDeclarativeScript::Object *obj)
{
push(State(obj));
}
@@ -129,21 +518,21 @@ class ProcessAST: protected AST::Visitor
};
public:
- ProcessAST(QDeclarativeScriptParser *parser);
+ ProcessAST(QDeclarativeScript::Parser *parser);
virtual ~ProcessAST();
void operator()(const QString &code, AST::Node *node);
protected:
- QDeclarativeParser::Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment,
+ QDeclarativeScript::Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment,
const QString &objectType,
AST::SourceLocation typeLocation,
LocationSpan location,
AST::UiObjectInitializer *initializer = 0);
- QDeclarativeParser::Variant getVariant(AST::Statement *stmt);
- QDeclarativeParser::Variant getVariant(AST::ExpressionNode *expr);
+ QDeclarativeScript::Variant getVariant(AST::Statement *stmt);
+ QDeclarativeScript::Variant getVariant(AST::ExpressionNode *expr);
LocationSpan location(AST::SourceLocation start, AST::SourceLocation end);
LocationSpan location(AST::UiQualifiedId *);
@@ -166,7 +555,7 @@ protected:
QString asString(AST::UiQualifiedId *node) const;
const State state() const;
- QDeclarativeParser::Object *currentObject() const;
+ QDeclarativeScript::Object *currentObject() const;
Property *currentProperty() const;
QString qualifiedNameId() const;
@@ -220,13 +609,13 @@ protected:
}
private:
- QDeclarativeScriptParser *_parser;
+ QDeclarativeScript::Parser *_parser;
StateStack _stateStack;
QStringList _scope;
const QString *_contents;
};
-ProcessAST::ProcessAST(QDeclarativeScriptParser *parser)
+ProcessAST::ProcessAST(QDeclarativeScript::Parser *parser)
: _parser(parser)
{
}
@@ -254,7 +643,7 @@ const ProcessAST::State ProcessAST::state() const
return _stateStack.back();
}
-QDeclarativeParser::Object *ProcessAST::currentObject() const
+QDeclarativeScript::Object *ProcessAST::currentObject() const
{
return state().object;
}
@@ -283,7 +672,7 @@ QString ProcessAST::asString(AST::UiQualifiedId *node) const
return s;
}
-QDeclarativeParser::Object *
+QDeclarativeScript::Object *
ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
bool onAssignment,
const QString &objectType,
@@ -340,9 +729,9 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
if (lastTypeDot >= 0)
resolvableObjectType.replace(QLatin1Char('.'),QLatin1Char('/'));
- QDeclarativeParser::Object *obj = _parser->_pool.New<QDeclarativeParser::Object>();
+ QDeclarativeScript::Object *obj = _parser->_pool.New<QDeclarativeScript::Object>();
- QDeclarativeScriptParser::TypeReference *typeRef = _parser->findOrCreateType(resolvableObjectType);
+ QDeclarativeScript::TypeReference *typeRef = _parser->findOrCreateType(resolvableObjectType);
obj->type = typeRef->id;
typeRef->refObjects.append(obj);
@@ -356,7 +745,7 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
if (propertyCount) {
Property *prop = currentProperty();
- QDeclarativeParser::Value *v = _parser->_pool.New<QDeclarativeParser::Value>();
+ QDeclarativeScript::Value *v = _parser->_pool.New<QDeclarativeScript::Value>();
v->object = obj;
v->location = obj->location;
if (onAssignment)
@@ -373,7 +762,7 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
_parser->setTree(obj);
} else {
const State state = _stateStack.top();
- QDeclarativeParser::Value *v = _parser->_pool.New<QDeclarativeParser::Value>();
+ QDeclarativeScript::Value *v = _parser->_pool.New<QDeclarativeScript::Value>();
v->object = obj;
v->location = obj->location;
if (state.property) {
@@ -427,18 +816,18 @@ bool ProcessAST::visit(AST::UiProgram *node)
bool ProcessAST::visit(AST::UiImport *node)
{
QString uri;
- QDeclarativeScriptParser::Import import;
+ QDeclarativeScript::Import import;
if (!node->fileName.isNull()) {
uri = node->fileName.toString();
if (uri.endsWith(QLatin1String(".js"))) {
- import.type = QDeclarativeScriptParser::Import::Script;
+ import.type = QDeclarativeScript::Import::Script;
} else {
- import.type = QDeclarativeScriptParser::Import::File;
+ import.type = QDeclarativeScript::Import::File;
}
} else {
- import.type = QDeclarativeScriptParser::Import::Library;
+ import.type = QDeclarativeScript::Import::Library;
uri = asString(node->importUri);
}
@@ -466,10 +855,10 @@ bool ProcessAST::visit(AST::UiImport *node)
}
// Check for script qualifier clashes
- bool isScript = import.type == QDeclarativeScriptParser::Import::Script;
+ bool isScript = import.type == QDeclarativeScript::Import::Script;
for (int ii = 0; ii < _parser->_imports.count(); ++ii) {
- const QDeclarativeScriptParser::Import &other = _parser->_imports.at(ii);
- bool otherIsScript = other.type == QDeclarativeScriptParser::Import::Script;
+ const QDeclarativeScript::Import &other = _parser->_imports.at(ii);
+ bool otherIsScript = other.type == QDeclarativeScript::Import::Script;
if ((isScript || otherIsScript) && import.qualifier == other.qualifier) {
QDeclarativeError error;
@@ -481,7 +870,7 @@ bool ProcessAST::visit(AST::UiImport *node)
}
}
- } else if (import.type == QDeclarativeScriptParser::Import::Script) {
+ } else if (import.type == QDeclarativeScript::Import::Script) {
QDeclarativeError error;
error.setDescription(QCoreApplication::translate("QDeclarativeParser","Script import requires a qualifier"));
error.setLine(node->fileNameToken.startLine);
@@ -492,7 +881,7 @@ bool ProcessAST::visit(AST::UiImport *node)
if (node->versionToken.isValid()) {
import.version = textAt(node->versionToken);
- } else if (import.type == QDeclarativeScriptParser::Import::Library) {
+ } else if (import.type == QDeclarativeScript::Import::Library) {
QDeclarativeError error;
error.setDescription(QCoreApplication::translate("QDeclarativeParser","Library import requires a version"));
error.setLine(node->importIdToken.startLine);
@@ -590,7 +979,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
bool typeFound = false;
Object::DynamicProperty::Type type;
- if (memberType.length() == strlen("alias") &&
+ if ((unsigned)memberType.length() == strlen("alias") &&
QHashedString::compare(memberType.constData(), "alias", strlen("alias"))) {
type = Object::DynamicProperty::Alias;
typeFound = true;
@@ -610,7 +999,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
if (typeModifier.isEmpty()) {
type = Object::DynamicProperty::Custom;
- } else if(typeModifier.length() == strlen("list") &&
+ } else if((unsigned)typeModifier.length() == strlen("list") &&
QHashedString::compare(typeModifier.constData(), "list", strlen("list"))) {
type = Object::DynamicProperty::CustomList;
} else {
@@ -654,7 +1043,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
property->isDefaultProperty = node->isDefaultMember;
property->type = type;
if (type >= Object::DynamicProperty::Custom) {
- QDeclarativeScriptParser::TypeReference *typeRef =
+ QDeclarativeScript::TypeReference *typeRef =
_parser->findOrCreateType(memberType.toString());
typeRef->refObjects.append(_stateStack.top().object);
property->customType = memberType;
@@ -670,7 +1059,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
property->defaultValue->location =
location(node->statement->firstSourceLocation(),
node->statement->lastSourceLocation());
- QDeclarativeParser::Value *value = _parser->_pool.New<QDeclarativeParser::Value>();
+ QDeclarativeScript::Value *value = _parser->_pool.New<QDeclarativeScript::Value>();
value->location = location(node->statement->firstSourceLocation(),
node->statement->lastSourceLocation());
value->value = getVariant(node->statement);
@@ -718,37 +1107,37 @@ bool ProcessAST::visit(AST::UiObjectBinding *node)
return false;
}
-QDeclarativeParser::Variant ProcessAST::getVariant(AST::Statement *stmt)
+QDeclarativeScript::Variant ProcessAST::getVariant(AST::Statement *stmt)
{
if (stmt) {
if (AST::ExpressionStatement *exprStmt = AST::cast<AST::ExpressionStatement *>(stmt))
return getVariant(exprStmt->expression);
- return QDeclarativeParser::Variant(asStringRef(stmt), stmt);
+ return QDeclarativeScript::Variant(asStringRef(stmt), stmt);
}
- return QDeclarativeParser::Variant();
+ return QDeclarativeScript::Variant();
}
-QDeclarativeParser::Variant ProcessAST::getVariant(AST::ExpressionNode *expr)
+QDeclarativeScript::Variant ProcessAST::getVariant(AST::ExpressionNode *expr)
{
if (AST::StringLiteral *lit = AST::cast<AST::StringLiteral *>(expr)) {
- return QDeclarativeParser::Variant(lit);
+ return QDeclarativeScript::Variant(lit);
} else if (expr->kind == AST::Node::Kind_TrueLiteral) {
- return QDeclarativeParser::Variant(true);
+ return QDeclarativeScript::Variant(true);
} else if (expr->kind == AST::Node::Kind_FalseLiteral) {
- return QDeclarativeParser::Variant(false);
+ return QDeclarativeScript::Variant(false);
} else if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(expr)) {
- return QDeclarativeParser::Variant(lit->value, asStringRef(expr));
+ return QDeclarativeScript::Variant(lit->value, asStringRef(expr));
} else {
if (AST::UnaryMinusExpression *unaryMinus = AST::cast<AST::UnaryMinusExpression *>(expr)) {
if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(unaryMinus->expression)) {
- return QDeclarativeParser::Variant(-lit->value, asStringRef(expr));
+ return QDeclarativeScript::Variant(-lit->value, asStringRef(expr));
}
}
- return QDeclarativeParser::Variant(asStringRef(expr), expr);
+ return QDeclarativeScript::Variant(asStringRef(expr), expr);
}
}
@@ -775,17 +1164,17 @@ bool ProcessAST::visit(AST::UiScriptBinding *node)
return 0;
}
- QDeclarativeParser::Variant primitive;
+ QDeclarativeScript::Variant primitive;
if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(node->statement)) {
primitive = getVariant(stmt->expression);
} else { // do binding
- primitive = QDeclarativeParser::Variant(asStringRef(node->statement), node->statement);
+ primitive = QDeclarativeScript::Variant(asStringRef(node->statement), node->statement);
}
prop->location.range.length = prop->location.range.offset + prop->location.range.length - node->qualifiedId->identifierToken.offset;
prop->location.range.offset = node->qualifiedId->identifierToken.offset;
- QDeclarativeParser::Value *v = _parser->_pool.New<QDeclarativeParser::Value>();
+ QDeclarativeScript::Value *v = _parser->_pool.New<QDeclarativeScript::Value>();
v->value = primitive;
v->location = location(node->statement->firstSourceLocation(),
node->statement->lastSourceLocation());
@@ -834,7 +1223,7 @@ bool ProcessAST::visit(AST::UiArrayBinding *node)
bool ProcessAST::visit(AST::UiSourceElement *node)
{
- QDeclarativeParser::Object *obj = currentObject();
+ QDeclarativeScript::Object *obj = currentObject();
if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) {
@@ -868,28 +1257,30 @@ bool ProcessAST::visit(AST::UiSourceElement *node)
} // end of anonymous namespace
-QDeclarativeScriptParser::QDeclarativeScriptParser()
+QDeclarativeScript::Parser::Parser()
: root(0), data(0)
{
}
-QDeclarativeScriptParser::~QDeclarativeScriptParser()
+QDeclarativeScript::Parser::~Parser()
{
clear();
}
-class QDeclarativeScriptParserJsASTData
+namespace QDeclarativeScript {
+class ParserJsASTData
{
public:
- QDeclarativeScriptParserJsASTData(const QString &filename)
- : filename(filename) {}
+ ParserJsASTData(const QString &filename)
+ : filename(filename) {}
QString filename;
Engine engine;
};
+}
-bool QDeclarativeScriptParser::parse(const QByteArray &qmldata, const QUrl &url)
+bool QDeclarativeScript::Parser::parse(const QByteArray &qmldata, const QUrl &url)
{
clear();
@@ -902,12 +1293,12 @@ bool QDeclarativeScriptParser::parse(const QByteArray &qmldata, const QUrl &url)
#endif
QString *code = _pool.NewString(stream.readAll());
- data = new QDeclarativeScriptParserJsASTData(fileName);
+ data = new QDeclarativeScript::ParserJsASTData(fileName);
Lexer lexer(&data->engine);
lexer.setCode(*code, /*line = */ 1);
- Parser parser(&data->engine);
+ QDeclarativeJS::Parser parser(&data->engine);
if (! parser.parse() || !_errors.isEmpty()) {
@@ -939,22 +1330,22 @@ bool QDeclarativeScriptParser::parse(const QByteArray &qmldata, const QUrl &url)
return _errors.isEmpty();
}
-QList<QDeclarativeScriptParser::TypeReference*> QDeclarativeScriptParser::referencedTypes() const
+QList<QDeclarativeScript::TypeReference*> QDeclarativeScript::Parser::referencedTypes() const
{
return _refTypes;
}
-QDeclarativeParser::Object *QDeclarativeScriptParser::tree() const
+QDeclarativeScript::Object *QDeclarativeScript::Parser::tree() const
{
return root;
}
-QList<QDeclarativeScriptParser::Import> QDeclarativeScriptParser::imports() const
+QList<QDeclarativeScript::Import> QDeclarativeScript::Parser::imports() const
{
return _imports;
}
-QList<QDeclarativeError> QDeclarativeScriptParser::errors() const
+QList<QDeclarativeError> QDeclarativeScript::Parser::errors() const
{
return _errors;
}
@@ -967,10 +1358,10 @@ static void replaceWithSpace(QString &str, int idx, int n)
*data++ = space;
}
-static QDeclarativeParser::LocationSpan
+static QDeclarativeScript::LocationSpan
locationFromLexer(const QDeclarativeJS::Lexer &lex, int startLine, int startColumn, int startOffset)
{
- QDeclarativeParser::LocationSpan l;
+ QDeclarativeScript::LocationSpan l;
l.start.line = startLine; l.start.column = startColumn;
l.end.line = lex.tokenEndLine(); l.end.column = lex.tokenEndColumn();
@@ -985,9 +1376,9 @@ Searches for ".pragma <value>" declarations within \a script. Currently support
are:
library
*/
-QDeclarativeParser::Object::ScriptBlock::Pragmas QDeclarativeScriptParser::extractPragmas(QString &script)
+QDeclarativeScript::Object::ScriptBlock::Pragmas QDeclarativeScript::Parser::extractPragmas(QString &script)
{
- QDeclarativeParser::Object::ScriptBlock::Pragmas rv = QDeclarativeParser::Object::ScriptBlock::None;
+ QDeclarativeScript::Object::ScriptBlock::Pragmas rv = QDeclarativeScript::Object::ScriptBlock::None;
const QString pragma(QLatin1String("pragma"));
const QString library(QLatin1String("library"));
@@ -1025,7 +1416,7 @@ QDeclarativeParser::Object::ScriptBlock::Pragmas QDeclarativeScriptParser::extra
return rv;
if (pragmaValue == library) {
- rv |= QDeclarativeParser::Object::ScriptBlock::Shared;
+ rv |= QDeclarativeScript::Object::ScriptBlock::Shared;
replaceWithSpace(script, startOffset, endOffset - startOffset);
} else {
return rv;
@@ -1088,11 +1479,11 @@ static inline bool isUriToken(int token)
return false;
}
-QDeclarativeScriptParser::JavaScriptMetaData QDeclarativeScriptParser::extractMetaData(QString &script)
+QDeclarativeScript::Parser::JavaScriptMetaData QDeclarativeScript::Parser::extractMetaData(QString &script)
{
JavaScriptMetaData rv;
- QDeclarativeParser::Object::ScriptBlock::Pragmas &pragmas = rv.pragmas;
+ QDeclarativeScript::Object::ScriptBlock::Pragmas &pragmas = rv.pragmas;
const QString pragma(QLatin1String("pragma"));
const QString js(QLatin1String(".js"));
@@ -1148,7 +1539,7 @@ QDeclarativeScriptParser::JavaScriptMetaData QDeclarativeScriptParser::extractMe
if (!importId.at(0).isUpper())
return rv;
- QDeclarativeParser::LocationSpan location =
+ QDeclarativeScript::LocationSpan location =
locationFromLexer(l, startLine, startColumn, startOffset);
token = l.lex();
@@ -1206,7 +1597,7 @@ QDeclarativeScriptParser::JavaScriptMetaData QDeclarativeScriptParser::extractMe
if (!importId.at(0).isUpper())
return rv;
- QDeclarativeParser::LocationSpan location =
+ QDeclarativeScript::LocationSpan location =
locationFromLexer(l, startLine, startColumn, startOffset);
token = l.lex();
@@ -1237,7 +1628,7 @@ QDeclarativeScriptParser::JavaScriptMetaData QDeclarativeScriptParser::extractMe
int endOffset = l.tokenLength() + l.tokenOffset();
if (pragmaValue == library) {
- pragmas |= QDeclarativeParser::Object::ScriptBlock::Shared;
+ pragmas |= QDeclarativeScript::Object::ScriptBlock::Shared;
replaceWithSpace(script, startOffset, endOffset - startOffset);
} else {
return rv;
@@ -1254,7 +1645,7 @@ QDeclarativeScriptParser::JavaScriptMetaData QDeclarativeScriptParser::extractMe
return rv;
}
-void QDeclarativeScriptParser::clear()
+void QDeclarativeScript::Parser::clear()
{
_imports.clear();
qDeleteAll(_refTypes);
@@ -1269,7 +1660,7 @@ void QDeclarativeScriptParser::clear()
_pool.clear();
}
-QDeclarativeScriptParser::TypeReference *QDeclarativeScriptParser::findOrCreateType(const QString &name)
+QDeclarativeScript::TypeReference *QDeclarativeScript::Parser::findOrCreateType(const QString &name)
{
TypeReference *type = 0;
int i = 0;
@@ -1287,7 +1678,7 @@ QDeclarativeScriptParser::TypeReference *QDeclarativeScriptParser::findOrCreateT
return type;
}
-void QDeclarativeScriptParser::setTree(QDeclarativeParser::Object *tree)
+void QDeclarativeScript::Parser::setTree(QDeclarativeScript::Object *tree)
{
Q_ASSERT(! root);
diff --git a/src/declarative/qml/qdeclarativescript_p.h b/src/declarative/qml/qdeclarativescript_p.h
new file mode 100644
index 0000000000..3aff31789a
--- /dev/null
+++ b/src/declarative/qml/qdeclarativescript_p.h
@@ -0,0 +1,526 @@
+/****************************************************************************
+**
+** 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 QDECLARATIVESCRIPT_P_H
+#define QDECLARATIVESCRIPT_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 <QtDeclarative/qdeclarativeerror.h>
+
+#include <private/qfieldlist_p.h>
+#include <private/qhashfield_p.h>
+#include <private/qfastmetabuilder_p.h>
+#include <private/qdeclarativepool_p.h>
+#include <private/qdeclarativepropertycache_p.h>
+
+#include <QtCore/QList>
+#include <QtCore/QUrl>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QByteArray;
+class QDeclarativePropertyCache;
+namespace QDeclarativeJS { namespace AST { class Node; class StringLiteral; } }
+namespace QDeclarativeCompilerTypes { class BindingReference; class ComponentCompileState; }
+
+namespace QDeclarativeScript {
+
+struct Location
+{
+ Location() : line(-1), column(-1) {}
+ int line;
+ int column;
+
+ inline bool operator<(const Location &other) {
+ return line < other.line ||
+ (line == other.line && column < other.column);
+ }
+};
+
+struct LocationRange
+{
+ LocationRange() : offset(0), length(0) {}
+ quint32 offset;
+ quint32 length;
+};
+
+struct LocationSpan
+{
+ Location start;
+ Location end;
+ LocationRange range;
+
+ bool operator<(LocationSpan &o) const {
+ return (start.line < o.start.line) ||
+ (start.line == o.start.line && start.column < o.start.column);
+ }
+};
+
+class Import
+{
+public:
+ Import() : type(Library) {}
+
+ enum Type { Library, File, Script };
+ Type type;
+
+ QString uri;
+ QString qualifier;
+ QString version;
+
+ void extractVersion(int *maj, int *min) const;
+
+ QDeclarativeScript::LocationSpan location;
+};
+
+class Object;
+class TypeReference
+{
+public:
+ TypeReference(int typeId, const QString &typeName) : id(typeId), name(typeName) {}
+
+ int id;
+ // type as it has been referenced in Qml
+ QString name;
+ // objects in parse tree referencing the type
+ QList<QDeclarativeScript::Object*> refObjects;
+};
+
+class Object;
+class Property;
+
+class Q_DECLARATIVE_EXPORT Variant
+{
+public:
+ enum Type {
+ Invalid,
+ Boolean,
+ Number,
+ String,
+ Script
+ };
+
+ Variant();
+ Variant(const Variant &);
+ explicit Variant(bool);
+ explicit Variant(double, const QStringRef &asWritten = QStringRef());
+ explicit Variant(QDeclarativeJS::AST::StringLiteral *);
+ explicit Variant(const QStringRef &asWritten, QDeclarativeJS::AST::Node *);
+ Variant &operator=(const Variant &);
+
+ Type type() const;
+
+ bool isBoolean() const { return type() == Boolean; }
+ bool isNumber() const { return type() == Number; }
+ bool isString() const { return type() == String; }
+ bool isScript() const { return type() == Script; }
+ bool isStringList() const;
+
+ bool asBoolean() const;
+ QString asString() const;
+ double asNumber() const;
+ QString asScript() const;
+ QDeclarativeJS::AST::Node *asAST() const;
+ QStringList asStringList() const;
+
+private:
+ Type t;
+ union {
+ bool b;
+ double d;
+ QDeclarativeJS::AST::StringLiteral *l;
+ QDeclarativeJS::AST::Node *n;
+ };
+ QStringRef asWritten;
+};
+
+class Value : public QDeclarativePool::POD
+{
+public:
+ Value();
+
+ enum Type {
+ // The type of this value assignment is not yet known
+ Unknown,
+ // This is used as a literal property assignment
+ Literal,
+ // This is used as a property binding assignment
+ PropertyBinding,
+ // This is used as a QDeclarativePropertyValueSource assignment
+ ValueSource,
+ // This is used as a QDeclarativePropertyValueInterceptor assignment
+ ValueInterceptor,
+ // This is used as a property QObject assignment
+ CreatedObject,
+ // This is used as a signal object assignment
+ SignalObject,
+ // This is used as a signal expression assignment
+ SignalExpression,
+ // This is used as an id assignment only
+ Id
+ };
+ Type type;
+
+ // ### Temporary (for id only)
+ QString primitive() const { return value.isString() ? value.asString() : value.asScript(); }
+
+ // Primitive value
+ Variant value;
+ // Object value
+ Object *object;
+
+ LocationSpan location;
+
+ // Used by compiler
+ QDeclarativeCompilerTypes::BindingReference *bindingReference;
+ int signalExpressionContextStack;
+
+ // Used in Property::ValueList lists
+ Value *nextValue;
+};
+
+class Property : public QDeclarativePool::POD
+{
+public:
+ Property();
+
+ // The Object to which this property is attached
+ Object *parent;
+
+ Object *getValue(const LocationSpan &);
+ void addValue(Value *v);
+ void addOnValue(Value *v);
+
+ // The QVariant::Type of the property, or 0 (QVariant::Invalid) if
+ // unknown.
+ int type;
+ // The metaobject index of this property, or -1 if unknown.
+ int index;
+ // The core data in the case of a regular property.
+ // XXX This has to be a value now as the synthCache may change during
+ // compilation which invalidates pointers. We should fix this.
+ QDeclarativePropertyCache::Data core;
+
+ // Returns true if this is an empty property - both value and values
+ // are unset.
+ bool isEmpty() const;
+
+ typedef QFieldList<Value, &Value::nextValue> ValueList;
+ // The list of values assigned to this property. Content in values
+ // and value are mutually exclusive
+ ValueList values;
+ // The list of values assigned to this property using the "on" syntax
+ ValueList onValues;
+ // The accessed property. This is used to represent dot properties.
+ // Content in value and values are mutually exclusive.
+ Object *value;
+ // The property name
+ const QHashedStringRef &name() const { return _name; }
+ void setName(const QString &n) { _name = QHashedStringRef(pool()->NewString(n)); }
+ void setName(const QHashedStringRef &n) { _name = n; }
+ // True if this property was accessed as the default property.
+ bool isDefault;
+ // True if the setting of this property will be deferred. Set by the
+ // QDeclarativeCompiler
+ bool isDeferred;
+ // True if this property is a value-type pseudo-property
+ bool isValueTypeSubProperty;
+ // True if this property is a property alias. Set by the
+ // QDeclarativeCompiler
+ bool isAlias;
+
+ // Used for scriptStringProperties
+ int scriptStringScope;
+
+ LocationSpan location;
+ LocationRange listValueRange;
+
+ // Used in Object::MainPropertyList
+ Property *nextMainProperty;
+
+ // Used in Object::PropertyList lists
+ Property *nextProperty;
+
+private:
+ friend class Object;
+ QHashedStringRef _name;
+};
+
+class Object : public QDeclarativePool::Class
+{
+public:
+ Object();
+ virtual ~Object();
+
+ // Type of the object. The integer is an index into the
+ // QDeclarativeCompiledData::types array, or -1 if the object is a property
+ // group.
+ int type;
+
+ // The fully-qualified name of this type
+ QByteArray typeName;
+ // The id assigned to the object (if any). Set by the QDeclarativeCompiler
+ QString id;
+ // The id index assigned to the object (if any). Set by the QDeclarativeCompiler
+ int idIndex;
+ // Custom parsed data
+ QByteArray custom;
+ // Bit mask of the properties assigned bindings
+ QByteArray bindingBitmask;
+ void setBindingBit(int);
+ // Returns the metaobject for this type, or 0 if not available.
+ // Internally selectd between the metatype and extObject variables
+ const QMetaObject *metaObject() const;
+
+ // The compile time metaobject for this type
+ const QMetaObject *metatype;
+ // The synthesized metaobject, if QML added signals or properties to
+ // this type. Otherwise null
+ QAbstractDynamicMetaObject extObject;
+ QByteArray metadata; // Generated by compiler
+ QByteArray synthdata; // Generated by compiler
+ QDeclarativePropertyCache *synthCache; // Generated by compiler
+
+ Property *getDefaultProperty();
+ // name ptr must be guarenteed to remain valid
+ Property *getProperty(const QHashedStringRef &name, bool create=true);
+ Property *getProperty(const QStringRef &name, bool create=true);
+ Property *getProperty(const QString &name, bool create=true);
+
+ Property *defaultProperty;
+
+ typedef QFieldList<Property, &Property::nextMainProperty> MainPropertyList;
+ MainPropertyList properties;
+ QHashField propertiesHashField;
+
+ // Output of the compilation phase (these properties continue to exist
+ // in either the defaultProperty or properties members too)
+ void addValueProperty(Property *);
+ void addSignalProperty(Property *);
+ void addAttachedProperty(Property *);
+ void addGroupedProperty(Property *);
+ void addValueTypeProperty(Property *);
+ void addScriptStringProperty(Property *);
+
+ typedef QFieldList<Property, &Property::nextProperty> PropertyList;
+ PropertyList valueProperties;
+ PropertyList signalProperties;
+ PropertyList attachedProperties;
+ PropertyList groupedProperties;
+ PropertyList valueTypeProperties;
+ PropertyList scriptStringProperties;
+
+ // Script blocks that were nested under this object
+ struct ScriptBlock {
+ enum Pragma {
+ None = 0x00000000,
+ Shared = 0x00000001
+ };
+ Q_DECLARE_FLAGS(Pragmas, Pragma)
+
+ QString code;
+ QString file;
+ Pragmas pragmas;
+ };
+
+ // The bytes to cast instances by to get to the QDeclarativeParserStatus
+ // interface. -1 indicates the type doesn't support this interface.
+ // Set by the QDeclarativeCompiler.
+ int parserStatusCast;
+
+ LocationSpan location;
+
+ struct DynamicProperty : public QDeclarativePool::POD
+ {
+ DynamicProperty();
+
+ enum Type { Variant, Int, Bool, Real, String, Url, Color, Time,
+ Date, DateTime, Alias, Custom, CustomList };
+
+ bool isDefaultProperty;
+ Type type;
+
+ QHashedStringRef customType;
+ QHashedStringRef name;
+ QDeclarativeScript::Property *defaultValue;
+ LocationSpan location;
+
+ // Used by Object::DynamicPropertyList
+ DynamicProperty *nextProperty;
+
+ // Used by the compiler
+ QByteArray *resolvedCustomTypeName;
+ QFastMetaBuilder::StringRef typeRef;
+ QFastMetaBuilder::StringRef nameRef;
+ QFastMetaBuilder::StringRef changedSignatureRef;
+ };
+
+ struct DynamicSignal : public QDeclarativePool::POD
+ {
+ DynamicSignal();
+
+ QHashedStringRef name;
+ QDeclarativePool::List<QHashedCStringRef> parameterTypes;
+ QDeclarativePool::List<QHashedStringRef> parameterNames;
+
+ int parameterTypesLength() const;
+ int parameterNamesLength() const;
+
+ // Used by Object::DynamicSignalList
+ DynamicSignal *nextSignal;
+
+ // Used by the compiler
+ QFastMetaBuilder::StringRef signatureRef;
+ QFastMetaBuilder::StringRef parameterNamesRef;
+ LocationSpan location;
+ };
+
+ struct DynamicSlot : public QDeclarativePool::Class
+ {
+ DynamicSlot();
+
+ QHashedStringRef name;
+ QString body;
+ QList<QByteArray> parameterNames;
+ LocationSpan location;
+
+ int parameterNamesLength() const;
+
+ // Used by Object::DynamicSlotList
+ DynamicSlot *nextSlot;
+
+ // Used by the compiler
+ QFastMetaBuilder::StringRef signatureRef;
+ QFastMetaBuilder::StringRef parameterNamesRef;
+ };
+
+ // The list of dynamic properties
+ typedef QFieldList<DynamicProperty, &DynamicProperty::nextProperty> DynamicPropertyList;
+ DynamicPropertyList dynamicProperties;
+ // The list of dynamic signals
+ typedef QFieldList<DynamicSignal, &DynamicSignal::nextSignal> DynamicSignalList;
+ DynamicSignalList dynamicSignals;
+ // The list of dynamic slots
+ typedef QFieldList<DynamicSlot, &DynamicSlot::nextSlot> DynamicSlotList;
+ DynamicSlotList dynamicSlots;
+
+ // Used by compiler
+ QDeclarativeCompilerTypes::ComponentCompileState *componentCompileState;
+
+ // Used by ComponentCompileState::AliasingObjectsList
+ Object *nextAliasingObject;
+ // Used by ComponentComppileState::IdList
+ Object *nextIdObject;
+};
+
+class ParserJsASTData;
+class Q_AUTOTEST_EXPORT Parser
+{
+public:
+ Parser();
+ ~Parser();
+
+ bool parse(const QByteArray &data, const QUrl &url = QUrl());
+
+ QList<TypeReference*> referencedTypes() const;
+
+ QDeclarativeScript::Object *tree() const;
+ QList<Import> imports() const;
+
+ void clear();
+
+ QList<QDeclarativeError> errors() const;
+
+ class JavaScriptMetaData {
+ public:
+ JavaScriptMetaData()
+ : pragmas(QDeclarativeScript::Object::ScriptBlock::None) {}
+
+ QDeclarativeScript::Object::ScriptBlock::Pragmas pragmas;
+ QList<Import> imports;
+ };
+
+ static QDeclarativeScript::Object::ScriptBlock::Pragmas extractPragmas(QString &);
+ static JavaScriptMetaData extractMetaData(QString &);
+
+
+// ### private:
+ TypeReference *findOrCreateType(const QString &name);
+ void setTree(QDeclarativeScript::Object *tree);
+
+ void setScriptFile(const QString &filename) {_scriptFile = filename; }
+ QString scriptFile() const { return _scriptFile; }
+
+// ### private:
+ QList<QDeclarativeError> _errors;
+
+ QDeclarativePool _pool;
+ QDeclarativeScript::Object *root;
+ QList<Import> _imports;
+ QList<TypeReference*> _refTypes;
+ QString _scriptFile;
+ ParserJsASTData *data;
+};
+
+}
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeScript::Object::ScriptBlock::Pragmas);
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeclarativeScript::Variant)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVESCRIPT_P_H
diff --git a/src/declarative/qml/qdeclarativescriptparser_p.h b/src/declarative/qml/qdeclarativescriptparser_p.h
deleted file mode 100644
index 3164d2070b..0000000000
--- a/src/declarative/qml/qdeclarativescriptparser_p.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** 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 QDECLARATIVESCRIPTPARSER_P_H
-#define QDECLARATIVESCRIPTPARSER_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 "qdeclarativeerror.h"
-
-#include <private/qdeclarativeparser_p.h>
-#include <private/qdeclarativepool_p.h>
-
-#include <QtCore/QList>
-#include <QtCore/QUrl>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QByteArray;
-
-class QDeclarativeScriptParserJsASTData;
-class Q_AUTOTEST_EXPORT QDeclarativeScriptParser
-{
-public:
- class Import
- {
- public:
- Import() : type(Library) {}
-
- enum Type { Library, File, Script };
- Type type;
-
- QString uri;
- QString qualifier;
- QString version;
-
- void extractVersion(int *maj, int *min) const;
-
- QDeclarativeParser::LocationSpan location;
- };
-
- class TypeReference
- {
- public:
- TypeReference(int typeId, const QString &typeName) : id(typeId), name(typeName) {}
-
- int id;
- // type as it has been referenced in Qml
- QString name;
- // objects in parse tree referencing the type
- QList<QDeclarativeParser::Object*> refObjects;
- };
-
- QDeclarativeScriptParser();
- ~QDeclarativeScriptParser();
-
- bool parse(const QByteArray &data, const QUrl &url = QUrl());
-
- QList<TypeReference*> referencedTypes() const;
-
- QDeclarativeParser::Object *tree() const;
- QList<Import> imports() const;
-
- void clear();
-
- QList<QDeclarativeError> errors() const;
-
- class JavaScriptMetaData {
- public:
- JavaScriptMetaData()
- : pragmas(QDeclarativeParser::Object::ScriptBlock::None) {}
-
- QDeclarativeParser::Object::ScriptBlock::Pragmas pragmas;
- QList<Import> imports;
- };
-
- static QDeclarativeParser::Object::ScriptBlock::Pragmas extractPragmas(QString &);
- static JavaScriptMetaData extractMetaData(QString &);
-
-
-// ### private:
- TypeReference *findOrCreateType(const QString &name);
- void setTree(QDeclarativeParser::Object *tree);
-
- void setScriptFile(const QString &filename) {_scriptFile = filename; }
- QString scriptFile() const { return _scriptFile; }
-
-// ### private:
- QList<QDeclarativeError> _errors;
-
- QDeclarativePool _pool;
- QDeclarativeParser::Object *root;
- QList<Import> _imports;
- QList<TypeReference*> _refTypes;
- QString _scriptFile;
- QDeclarativeScriptParserJsASTData *data;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESCRIPTPARSER_P_H
diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp
index 36b5f2890b..0b699f4ea3 100644
--- a/src/declarative/qml/qdeclarativetypeloader.cpp
+++ b/src/declarative/qml/qdeclarativetypeloader.cpp
@@ -940,7 +940,7 @@ const QDeclarativeImports &QDeclarativeTypeData::imports() const
return m_imports;
}
-const QDeclarativeScriptParser &QDeclarativeTypeData::parser() const
+const QDeclarativeScript::Parser &QDeclarativeTypeData::parser() const
{
return scriptParser;
}
@@ -1039,15 +1039,15 @@ void QDeclarativeTypeData::dataReceived(const QByteArray &data)
m_imports.setBaseUrl(finalUrl());
- foreach (const QDeclarativeScriptParser::Import &import, scriptParser.imports()) {
- if (import.type == QDeclarativeScriptParser::Import::File && import.qualifier.isEmpty()) {
+ foreach (const QDeclarativeScript::Import &import, scriptParser.imports()) {
+ if (import.type == QDeclarativeScript::Import::File && import.qualifier.isEmpty()) {
QUrl importUrl = finalUrl().resolved(QUrl(import.uri + QLatin1String("/qmldir")));
if (QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl).isEmpty()) {
QDeclarativeQmldirData *data = typeLoader()->getQmldir(importUrl);
addDependency(data);
m_qmldirs << data;
}
- } else if (import.type == QDeclarativeScriptParser::Import::Script) {
+ } else if (import.type == QDeclarativeScript::Import::Script) {
QUrl scriptUrl = finalUrl().resolved(QUrl(import.uri));
QDeclarativeScriptBlob *blob = typeLoader()->getScript(scriptUrl);
addDependency(blob);
@@ -1118,11 +1118,11 @@ void QDeclarativeTypeData::resolveTypes()
QList<QDeclarativeError> errors;
if (QDeclarativeQmldirData *qmldir = qmldirForUrl(finalUrl().resolved(QUrl(QLatin1String("./qmldir"))))) {
m_imports.addImport(importDatabase, QLatin1String("."),
- QString(), -1, -1, QDeclarativeScriptParser::Import::File,
+ QString(), -1, -1, QDeclarativeScript::Import::File,
qmldir->dirComponents(), &errors);
} else {
m_imports.addImport(importDatabase, QLatin1String("."),
- QString(), -1, -1, QDeclarativeScriptParser::Import::File,
+ QString(), -1, -1, QDeclarativeScript::Import::File,
QDeclarativeDirComponents(), &errors);
}
@@ -1142,12 +1142,12 @@ void QDeclarativeTypeData::resolveTypes()
return;
}
- foreach (const QDeclarativeScriptParser::Import &import, scriptParser.imports()) {
+ foreach (const QDeclarativeScript::Import &import, scriptParser.imports()) {
QDeclarativeDirComponents qmldircomponentsnetwork;
- if (import.type == QDeclarativeScriptParser::Import::Script)
+ if (import.type == QDeclarativeScript::Import::Script)
continue;
- if (import.type == QDeclarativeScriptParser::Import::File && import.qualifier.isEmpty()) {
+ if (import.type == QDeclarativeScript::Import::File && import.qualifier.isEmpty()) {
QUrl qmldirUrl = finalUrl().resolved(QUrl(import.uri + QLatin1String("/qmldir")));
if (QDeclarativeQmldirData *qmldir = qmldirForUrl(qmldirUrl))
qmldircomponentsnetwork = qmldir->dirComponents();
@@ -1178,7 +1178,7 @@ void QDeclarativeTypeData::resolveTypes()
}
}
- foreach (QDeclarativeScriptParser::TypeReference *parserRef, scriptParser.referencedTypes()) {
+ foreach (QDeclarativeScript::TypeReference *parserRef, scriptParser.referencedTypes()) {
TypeReference ref;
QString url;
@@ -1210,7 +1210,7 @@ void QDeclarativeTypeData::resolveTypes()
}
if (!parserRef->refObjects.isEmpty()) {
- QDeclarativeParser::Object *obj = parserRef->refObjects.first();
+ QDeclarativeScript::Object *obj = parserRef->refObjects.first();
error.setLine(obj->location.start.line);
error.setColumn(obj->location.start.column);
}
@@ -1245,7 +1245,7 @@ QDeclarativeQmldirData *QDeclarativeTypeData::qmldirForUrl(const QUrl &url)
}
QDeclarativeScriptData::QDeclarativeScriptData(QDeclarativeEngine *engine)
-: QDeclarativeCleanup(engine), importCache(0), pragmas(QDeclarativeParser::Object::ScriptBlock::None),
+: QDeclarativeCleanup(engine), importCache(0), pragmas(QDeclarativeScript::Object::ScriptBlock::None),
m_loaded(false)
{
}
@@ -1271,7 +1271,7 @@ void QDeclarativeScriptData::clear()
}
QDeclarativeScriptBlob::QDeclarativeScriptBlob(const QUrl &url, QDeclarativeTypeLoader *loader)
-: QDeclarativeDataBlob(url, JavaScriptFile), m_pragmas(QDeclarativeParser::Object::ScriptBlock::None),
+: QDeclarativeDataBlob(url, JavaScriptFile), m_pragmas(QDeclarativeScript::Object::ScriptBlock::None),
m_imports(loader), m_scriptData(0), m_typeLoader(loader)
{
}
@@ -1284,7 +1284,7 @@ QDeclarativeScriptBlob::~QDeclarativeScriptBlob()
}
}
-QDeclarativeParser::Object::ScriptBlock::Pragmas QDeclarativeScriptBlob::pragmas() const
+QDeclarativeScript::Object::ScriptBlock::Pragmas QDeclarativeScriptBlob::pragmas() const
{
return m_pragmas;
}
@@ -1316,17 +1316,17 @@ void QDeclarativeScriptBlob::dataReceived(const QByteArray &data)
m_source = QString::fromUtf8(data);
- QDeclarativeScriptParser::JavaScriptMetaData metadata =
- QDeclarativeScriptParser::extractMetaData(m_source);
+ QDeclarativeScript::Parser::JavaScriptMetaData metadata =
+ QDeclarativeScript::Parser::extractMetaData(m_source);
m_imports.setBaseUrl(finalUrl());
m_pragmas = metadata.pragmas;
- foreach (const QDeclarativeScriptParser::Import &import, metadata.imports) {
- Q_ASSERT(import.type != QDeclarativeScriptParser::Import::File);
+ foreach (const QDeclarativeScript::Import &import, metadata.imports) {
+ Q_ASSERT(import.type != QDeclarativeScript::Import::File);
- if (import.type == QDeclarativeScriptParser::Import::Script) {
+ if (import.type == QDeclarativeScript::Import::Script) {
QUrl scriptUrl = finalUrl().resolved(QUrl(import.uri));
QDeclarativeScriptBlob *blob = typeLoader()->getScript(scriptUrl);
addDependency(blob);
@@ -1338,7 +1338,7 @@ void QDeclarativeScriptBlob::dataReceived(const QByteArray &data)
blob->addref();
m_scripts << ref;
} else {
- Q_ASSERT(import.type == QDeclarativeScriptParser::Import::Library);
+ Q_ASSERT(import.type == QDeclarativeScript::Import::Library);
int vmaj = -1;
int vmin = -1;
import.extractVersion(&vmaj, &vmin);
diff --git a/src/declarative/qml/qdeclarativetypeloader_p.h b/src/declarative/qml/qdeclarativetypeloader_p.h
index cfe80aeea5..349a9f8428 100644
--- a/src/declarative/qml/qdeclarativetypeloader_p.h
+++ b/src/declarative/qml/qdeclarativetypeloader_p.h
@@ -59,7 +59,7 @@
#include <QtDeclarative/qdeclarativeerror.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <private/qdeclarativecleanup_p.h>
-#include <private/qdeclarativescriptparser_p.h>
+#include <private/qdeclarativescript_p.h>
#include <private/qdeclarativedirparser_p.h>
#include <private/qdeclarativeimport_p.h>
#include "private/qhashedstring_p.h"
@@ -232,7 +232,7 @@ public:
{
TypeReference() : type(0), majorVersion(0), minorVersion(0), typeData(0) {}
- QDeclarativeParser::Location location;
+ QDeclarativeScript::Location location;
QDeclarativeType *type;
int majorVersion;
int minorVersion;
@@ -243,7 +243,7 @@ public:
{
ScriptReference() : script(0) {}
- QDeclarativeParser::Location location;
+ QDeclarativeScript::Location location;
QString qualifier;
QDeclarativeScriptBlob *script;
};
@@ -254,7 +254,7 @@ public:
QDeclarativeTypeLoader *typeLoader() const;
const QDeclarativeImports &imports() const;
- const QDeclarativeScriptParser &parser() const;
+ const QDeclarativeScript::Parser &parser() const;
const QList<TypeReference> &resolvedTypes() const;
const QList<ScriptReference> &resolvedScripts() const;
@@ -284,7 +284,7 @@ private:
QDeclarativeQmldirData *qmldirForUrl(const QUrl &);
- QDeclarativeScriptParser scriptParser;
+ QDeclarativeScript::Parser scriptParser;
QDeclarativeImports m_imports;
QList<ScriptReference> m_scripts;
@@ -309,7 +309,7 @@ public:
QUrl url;
QDeclarativeTypeNameCache *importCache;
QList<QDeclarativeScriptBlob *> scripts;
- QDeclarativeParser::Object::ScriptBlock::Pragmas pragmas;
+ QDeclarativeScript::Object::ScriptBlock::Pragmas pragmas;
protected:
virtual void clear(); // From QDeclarativeCleanup
@@ -335,12 +335,12 @@ public:
{
ScriptReference() : script(0) {}
- QDeclarativeParser::Location location;
+ QDeclarativeScript::Location location;
QString qualifier;
QDeclarativeScriptBlob *script;
};
- QDeclarativeParser::Object::ScriptBlock::Pragmas pragmas() const;
+ QDeclarativeScript::Object::ScriptBlock::Pragmas pragmas() const;
QString scriptSource() const;
QDeclarativeTypeLoader *typeLoader() const;
@@ -353,7 +353,7 @@ protected:
virtual void done();
private:
- QDeclarativeParser::Object::ScriptBlock::Pragmas m_pragmas;
+ QDeclarativeScript::Object::ScriptBlock::Pragmas m_pragmas;
QString m_source;
QDeclarativeImports m_imports;
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index e631dbbc08..bf290869b4 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -1040,7 +1040,7 @@ v8::Persistent<v8::Object> QDeclarativeVME::run(QDeclarativeContextData *parentC
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(parentCtxt->engine);
QV8Engine *v8engine = ep->v8engine();
- bool shared = script->pragmas & QDeclarativeParser::Object::ScriptBlock::Shared;
+ bool shared = script->pragmas & QDeclarativeScript::Object::ScriptBlock::Shared;
QDeclarativeContextData *effectiveCtxt = parentCtxt;
if (shared)
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index fc9bb887e8..e6af0ba964 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -365,7 +365,7 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
if (f.open(QIODevice::ReadOnly)) {
QByteArray data = f.readAll();
QString sourceCode = QString::fromUtf8(data);
- QDeclarativeScriptParser::extractPragmas(sourceCode);
+ QDeclarativeScript::Parser::extractPragmas(sourceCode);
v8::HandleScope handle_scope;
v8::Context::Scope scope(workerEngine->context());
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index b73c141e5a..7ef28c0231 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -1,6 +1,5 @@
INCLUDEPATH += $$PWD
SOURCES += \
- $$PWD/qdeclarativeparser.cpp \
$$PWD/qdeclarativeinstruction.cpp \
$$PWD/qdeclarativevmemetaobject.cpp \
$$PWD/qdeclarativeengine.cpp \
@@ -23,7 +22,7 @@ SOURCES += \
$$PWD/qdeclarativetypeloader.cpp \
$$PWD/qdeclarativeinfo.cpp \
$$PWD/qdeclarativeerror.cpp \
- $$PWD/qdeclarativescriptparser.cpp \
+ $$PWD/qdeclarativescript.cpp \
$$PWD/qdeclarativeenginedebug.cpp \
$$PWD/qdeclarativerewrite.cpp \
$$PWD/qdeclarativevaluetype.cpp \
@@ -47,7 +46,6 @@ SOURCES += \
$$PWD/qdeclarativelist.cpp \
HEADERS += \
- $$PWD/qdeclarativeparser_p.h \
$$PWD/qdeclarativeglobal_p.h \
$$PWD/qdeclarativeinstruction_p.h \
$$PWD/qdeclarativevmemetaobject_p.h \
@@ -82,7 +80,7 @@ HEADERS += \
$$PWD/qdeclarativelist_p.h \
$$PWD/qdeclarativedata_p.h \
$$PWD/qdeclarativeerror.h \
- $$PWD/qdeclarativescriptparser_p.h \
+ $$PWD/qdeclarativescript_p.h \
$$PWD/qdeclarativeenginedebug_p.h \
$$PWD/qdeclarativerewrite_p.h \
$$PWD/qdeclarativevaluetype_p.h \
diff --git a/src/declarative/qml/v4/qdeclarativev4compiler_p.h b/src/declarative/qml/v4/qdeclarativev4compiler_p.h
index 292519b066..0ed78bfdfc 100644
--- a/src/declarative/qml/v4/qdeclarativev4compiler_p.h
+++ b/src/declarative/qml/v4/qdeclarativev4compiler_p.h
@@ -75,10 +75,10 @@ public:
struct Expression
{
Expression(const QDeclarativeImports &imp) : imports(imp) {}
- QDeclarativeParser::Object *component;
- QDeclarativeParser::Object *context;
- QDeclarativeParser::Property *property;
- QDeclarativeParser::Variant expression;
+ QDeclarativeScript::Object *component;
+ QDeclarativeScript::Object *context;
+ QDeclarativeScript::Property *property;
+ QDeclarativeScript::Variant expression;
QDeclarativeCompilerTypes::IdList *ids;
QDeclarativeTypeNameCache *importCache;
QDeclarativeImports imports;
diff --git a/src/declarative/qml/v4/qdeclarativev4compiler_p_p.h b/src/declarative/qml/v4/qdeclarativev4compiler_p_p.h
index 0aa76f2165..eab609a45d 100644
--- a/src/declarative/qml/v4/qdeclarativev4compiler_p_p.h
+++ b/src/declarative/qml/v4/qdeclarativev4compiler_p_p.h
@@ -55,7 +55,7 @@
#include "qdeclarativev4instruction_p.h"
#include "qdeclarativev4ir_p.h"
-#include <private/qdeclarativeparser_p.h>
+#include <private/qdeclarativescript_p.h>
#include <private/qdeclarativeimport_p.h>
#include <private/qdeclarativeengine_p.h>
diff --git a/src/declarative/qml/v4/qdeclarativev4ir.cpp b/src/declarative/qml/v4/qdeclarativev4ir.cpp
index b7b8eac0fc..7490efe2aa 100644
--- a/src/declarative/qml/v4/qdeclarativev4ir.cpp
+++ b/src/declarative/qml/v4/qdeclarativev4ir.cpp
@@ -496,7 +496,7 @@ Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QMetaOb
return name;
}
-Name *BasicBlock::ID_OBJECT(const QString &id, const QDeclarativeParser::Object *object, quint32 line, quint32 column)
+Name *BasicBlock::ID_OBJECT(const QString &id, const QDeclarativeScript::Object *object, quint32 line, quint32 column)
{
Name *name = function->pool->New<Name>();
name->init(/*base = */ 0, IR::ObjectType,
diff --git a/src/declarative/qml/v4/qdeclarativev4ir_p.h b/src/declarative/qml/v4/qdeclarativev4ir_p.h
index e79a289472..2c8f658378 100644
--- a/src/declarative/qml/v4/qdeclarativev4ir_p.h
+++ b/src/declarative/qml/v4/qdeclarativev4ir_p.h
@@ -55,7 +55,7 @@
#include <private/qdeclarativejsast_p.h>
#include <private/qdeclarativejsengine_p.h>
-#include <private/qdeclarativeparser_p.h>
+#include <private/qdeclarativescript_p.h>
#include <private/qdeclarativeimport_p.h>
#include <private/qdeclarativeengine_p.h>
#include <private/qdeclarativev4compiler_p.h>
@@ -267,7 +267,7 @@ struct Name: Expr {
void *ptr;
const QMetaObject *meta;
const QDeclarativeType *declarativeType;
- const QDeclarativeParser::Object *idObject;
+ const QDeclarativeScript::Object *idObject;
};
int index;
Storage storage;
@@ -534,7 +534,7 @@ struct BasicBlock {
Name *SYMBOL(Type type, const QString &id, const QMetaObject *meta, int index, Name::Storage storage, quint32 line, quint32 column);
Name *SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, int index, quint32 line, quint32 column);
Name *SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, int index, Name::Storage storage, quint32 line, quint32 column);
- Name *ID_OBJECT(const QString &id, const QDeclarativeParser::Object *object, quint32 line, quint32 column);
+ Name *ID_OBJECT(const QString &id, const QDeclarativeScript::Object *object, quint32 line, quint32 column);
Name *ATTACH_TYPE(const QString &id, const QDeclarativeType *attachType, Name::Storage storage, quint32 line, quint32 column);
Expr *UNOP(AluOp op, Expr *expr);
diff --git a/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp b/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp
index 5eb46823c7..9237a3e1e9 100644
--- a/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp
+++ b/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp
@@ -435,7 +435,7 @@ bool QDeclarativeV4IRBuilder::visit(AST::IdentifierExpression *ast)
} else if (m_engine->v8engine()->illegalNames().contains(name) ) {
if (qmlVerboseCompiler()) qWarning() << "*** illegal symbol:" << name;
return false;
- } else if (const QDeclarativeParser::Object *obj = m_expression->ids->value(name)) {
+ } else if (const QDeclarativeScript::Object *obj = m_expression->ids->value(name)) {
IR::Name *code = _block->ID_OBJECT(name, obj, line, column);
if (obj == m_expression->component)
code->storage = IR::Name::RootStorage;
@@ -622,7 +622,7 @@ bool QDeclarativeV4IRBuilder::visit(AST::FieldMemberExpression *ast)
break;
case IR::Name::IdObject: {
- const QDeclarativeParser::Object *idObject = baseName->idObject;
+ const QDeclarativeScript::Object *idObject = baseName->idObject;
QDeclarativePropertyCache *cache =
idObject->synthCache?idObject->synthCache:m_engine->cache(idObject->metaObject());
diff --git a/src/declarative/qml/v8/qv8include.cpp b/src/declarative/qml/v8/qv8include.cpp
index 1d68e8e4be..2e23914f2d 100644
--- a/src/declarative/qml/v8/qv8include.cpp
+++ b/src/declarative/qml/v8/qv8include.cpp
@@ -130,7 +130,7 @@ void QV8Include::finished()
QByteArray data = m_reply->readAll();
QString code = QString::fromUtf8(data);
- QDeclarativeScriptParser::extractPragmas(code);
+ QDeclarativeScript::Parser::extractPragmas(code);
QDeclarativeContextData *importContext = new QDeclarativeContextData;
importContext->isInternal = true;
@@ -203,7 +203,7 @@ v8::Handle<v8::Value> QV8Include::include(const v8::Arguments &args)
if (f.open(QIODevice::ReadOnly)) {
QByteArray data = f.readAll();
QString code = QString::fromUtf8(data);
- QDeclarativeScriptParser::extractPragmas(code);
+ QDeclarativeScript::Parser::extractPragmas(code);
QDeclarativeContextData *importContext = new QDeclarativeContextData;
importContext->isInternal = true;
diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp
index 6559d4bb20..57bb79c302 100644
--- a/src/declarative/util/qdeclarativeconnections.cpp
+++ b/src/declarative/util/qdeclarativeconnections.cpp
@@ -220,7 +220,7 @@ QDeclarativeConnectionsParser::compile(const QList<QDeclarativeCustomParserPrope
error(props.at(ii), QDeclarativeConnections::tr("Connections: syntax error"));
return QByteArray();
} else {
- QDeclarativeParser::Variant v = qvariant_cast<QDeclarativeParser::Variant>(value);
+ QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(value);
if (v.isScript()) {
ds << propName;
ds << v.asScript();
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 531209c3fc..2b113abbec 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -46,7 +46,7 @@
#include "parser/qdeclarativejsengine_p.h"
#include <qdeclarativecustomparser_p.h>
-#include <qdeclarativeparser_p.h>
+#include <qdeclarativescript_p.h>
#include <qdeclarativeengine_p.h>
#include <qdeclarativecontext.h>
#include <qdeclarativeinfo.h>
@@ -822,8 +822,8 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser
} else {
- QDeclarativeParser::Variant variant =
- qvariant_cast<QDeclarativeParser::Variant>(value);
+ QDeclarativeScript::Variant variant =
+ qvariant_cast<QDeclarativeScript::Variant>(value);
int ref = data.count();
@@ -837,7 +837,7 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser
d += char(variant.asBoolean());
} else if (variant.isScript()) {
if (definesEmptyList(variant.asScript())) {
- d[0] = char(QDeclarativeParser::Variant::Invalid); // marks empty list
+ d[0] = char(QDeclarativeScript::Variant::Invalid); // marks empty list
} else {
QByteArray script = variant.asScript().toUtf8();
int v = evaluateEnum(script);
@@ -866,14 +866,14 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser
}
if (literal) {
- d[0] = char(QDeclarativeParser::Variant::String);
+ d[0] = char(QDeclarativeScript::Variant::String);
d += literal->value.toUtf8();
} else {
error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value"));
return false;
}
} else {
- d[0] = char(QDeclarativeParser::Variant::Number);
+ d[0] = char(QDeclarativeScript::Variant::Number);
d += QByteArray::number(v);
}
}
@@ -964,17 +964,17 @@ void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray &
case ListInstruction::Value:
{
ModelNode *n = nodes.top();
- switch (QDeclarativeParser::Variant::Type(data[instr.dataIdx])) {
- case QDeclarativeParser::Variant::Invalid:
+ switch (QDeclarativeScript::Variant::Type(data[instr.dataIdx])) {
+ case QDeclarativeScript::Variant::Invalid:
n->isArray = true;
break;
- case QDeclarativeParser::Variant::Boolean:
+ case QDeclarativeScript::Variant::Boolean:
n->values.append(bool(data[1 + instr.dataIdx]));
break;
- case QDeclarativeParser::Variant::Number:
+ case QDeclarativeScript::Variant::Number:
n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble());
break;
- case QDeclarativeParser::Variant::String:
+ case QDeclarativeScript::Variant::String:
n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx));
break;
default:
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index d03cd3bb1a..039803002c 100644
--- a/src/declarative/util/qdeclarativepropertychanges.cpp
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -48,7 +48,7 @@
#include <qdeclarativeinfo.h>
#include <qdeclarativecustomparser_p.h>
-#include <qdeclarativeparser_p.h>
+#include <qdeclarativescript_p.h>
#include <qdeclarativeexpression.h>
#include <qdeclarativebinding_p.h>
#include <qdeclarativecontext.h>
@@ -279,22 +279,22 @@ QDeclarativePropertyChangesParser::compile(const QList<QDeclarativeCustomParserP
ds << data.count();
for(int ii = 0; ii < data.count(); ++ii) {
- QDeclarativeParser::Variant v = qvariant_cast<QDeclarativeParser::Variant>(data.at(ii).second);
+ QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(data.at(ii).second);
QVariant var;
bool isScript = v.isScript();
QDeclarativeBinding::Identifier id = 0;
switch(v.type()) {
- case QDeclarativeParser::Variant::Boolean:
+ case QDeclarativeScript::Variant::Boolean:
var = QVariant(v.asBoolean());
break;
- case QDeclarativeParser::Variant::Number:
+ case QDeclarativeScript::Variant::Number:
var = QVariant(v.asNumber());
break;
- case QDeclarativeParser::Variant::String:
+ case QDeclarativeScript::Variant::String:
var = QVariant(v.asString());
break;
- case QDeclarativeParser::Variant::Invalid:
- case QDeclarativeParser::Variant::Script:
+ case QDeclarativeScript::Variant::Invalid:
+ case QDeclarativeScript::Variant::Script:
var = QVariant(v.asScript());
{
// Pre-rewrite the expression
diff --git a/src/imports/gestures/qdeclarativegesturearea.cpp b/src/imports/gestures/qdeclarativegesturearea.cpp
index c0d88a3318..1631831c7f 100644
--- a/src/imports/gestures/qdeclarativegesturearea.cpp
+++ b/src/imports/gestures/qdeclarativegesturearea.cpp
@@ -46,6 +46,7 @@
#include <qdeclarativeinfo.h>
#include <private/qdeclarativeproperty_p.h>
+#include <private/qdeclarativescript_p.h>
#include <QtQuick1/private/qdeclarativeitem_p.h>
#include <QtCore/qdebug.h>
@@ -196,7 +197,7 @@ QDeclarativeGestureAreaParser::compile(const QList<QDeclarativeCustomParserPrope
error(props.at(ii), QDeclarativeGestureArea::tr("GestureArea: syntax error"));
return QByteArray();
} else {
- QDeclarativeParser::Variant v = qvariant_cast<QDeclarativeParser::Variant>(value);
+ QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(value);
if (v.isScript()) {
ds << propName;
ds << int(type);
diff --git a/src/qtquick1/util/qdeclarativeconnections.cpp b/src/qtquick1/util/qdeclarativeconnections.cpp
index 5fc019c4c1..54f51acd12 100644
--- a/src/qtquick1/util/qdeclarativeconnections.cpp
+++ b/src/qtquick1/util/qdeclarativeconnections.cpp
@@ -223,7 +223,7 @@ QDeclarative1ConnectionsParser::compile(const QList<QDeclarativeCustomParserProp
error(props.at(ii), QDeclarative1Connections::tr("Connections: syntax error"));
return QByteArray();
} else {
- QDeclarativeParser::Variant v = qvariant_cast<QDeclarativeParser::Variant>(value);
+ QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(value);
if (v.isScript()) {
ds << propName;
ds << v.asScript();
diff --git a/src/qtquick1/util/qdeclarativelistmodel.cpp b/src/qtquick1/util/qdeclarativelistmodel.cpp
index 08e15c52b6..5c31a8bd79 100644
--- a/src/qtquick1/util/qdeclarativelistmodel.cpp
+++ b/src/qtquick1/util/qdeclarativelistmodel.cpp
@@ -44,7 +44,7 @@
#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h"
#include <QtDeclarative/private/qdeclarativecustomparser_p.h>
-#include <QtDeclarative/private/qdeclarativeparser_p.h>
+#include <QtDeclarative/private/qdeclarativescript_p.h>
#include <QtDeclarative/private/qdeclarativeengine_p.h>
#include <QtDeclarative/qdeclarativecontext.h>
#include <QtDeclarative/qdeclarativeinfo.h>
diff --git a/src/qtquick1/util/qdeclarativepropertychanges.cpp b/src/qtquick1/util/qdeclarativepropertychanges.cpp
index 776701e58f..fc063cafb0 100644
--- a/src/qtquick1/util/qdeclarativepropertychanges.cpp
+++ b/src/qtquick1/util/qdeclarativepropertychanges.cpp
@@ -48,7 +48,7 @@
#include <QtDeclarative/qdeclarativeinfo.h>
#include <QtDeclarative/private/qdeclarativecustomparser_p.h>
-#include <QtDeclarative/private/qdeclarativeparser_p.h>
+#include <QtDeclarative/private/qdeclarativescript_p.h>
#include <QtDeclarative/qdeclarativeexpression.h>
#include <QtDeclarative/private/qdeclarativebinding_p.h>
#include <QtDeclarative/qdeclarativecontext.h>
@@ -282,22 +282,22 @@ QDeclarative1PropertyChangesParser::compile(const QList<QDeclarativeCustomParser
ds << data.count();
for(int ii = 0; ii < data.count(); ++ii) {
- QDeclarativeParser::Variant v = qvariant_cast<QDeclarativeParser::Variant>(data.at(ii).second);
+ QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(data.at(ii).second);
QVariant var;
bool isScript = v.isScript();
QDeclarativeBinding::Identifier id = 0;
switch(v.type()) {
- case QDeclarativeParser::Variant::Boolean:
+ case QDeclarativeScript::Variant::Boolean:
var = QVariant(v.asBoolean());
break;
- case QDeclarativeParser::Variant::Number:
+ case QDeclarativeScript::Variant::Number:
var = QVariant(v.asNumber());
break;
- case QDeclarativeParser::Variant::String:
+ case QDeclarativeScript::Variant::String:
var = QVariant(v.asString());
break;
- case QDeclarativeParser::Variant::Invalid:
- case QDeclarativeParser::Variant::Script:
+ case QDeclarativeScript::Variant::Invalid:
+ case QDeclarativeScript::Variant::Script:
var = QVariant(v.asScript());
{
// Pre-rewrite the expression
diff --git a/tests/benchmarks/declarative/compilation/tst_compilation.cpp b/tests/benchmarks/declarative/compilation/tst_compilation.cpp
index cadffe7f0d..9b4f9a70e8 100644
--- a/tests/benchmarks/declarative/compilation/tst_compilation.cpp
+++ b/tests/benchmarks/declarative/compilation/tst_compilation.cpp
@@ -47,7 +47,7 @@
#include <QtDeclarative/private/qdeclarativejsmemorypool_p.h>
#include <QtDeclarative/private/qdeclarativejsparser_p.h>
#include <QtDeclarative/private/qdeclarativejslexer_p.h>
-#include <QtDeclarative/private/qdeclarativescriptparser_p.h>
+#include <QtDeclarative/private/qdeclarativescript_p.h>
#include <QFile>
#include <QDebug>
@@ -154,7 +154,7 @@ void tst_compilation::scriptparser()
QUrl url = QUrl::fromLocalFile(file);
QBENCHMARK {
- QDeclarativeScriptParser parser;
+ QDeclarativeScript::Parser parser;
parser.parse(data, url);
parser.tree();
}