QmlJS: Rename QmlObjectValue -> CppComponentValue.

Reviewed-by: Fawzi Mohamed
Reviewed-by: Thomas Hartmann
Change-Id: Ib89388d5a5678403e4637eec5829f3520637ee27
Reviewed-on: http://codereview.qt-project.org/6310
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
Sanity-Review: Christian Kamm <christian.d.kamm@nokia.com>
This commit is contained in:
Christian Kamm
2011-10-10 10:32:33 +02:00
parent 8c94325a03
commit 90925c69f6
10 changed files with 125 additions and 125 deletions

View File

@@ -138,7 +138,7 @@ QString Context::defaultPropertyName(const ObjectValue *object) const
QString defaultProperty = astObjValue->defaultPropertyName(); QString defaultProperty = astObjValue->defaultPropertyName();
if (!defaultProperty.isEmpty()) if (!defaultProperty.isEmpty())
return defaultProperty; return defaultProperty;
} else if (const QmlObjectValue *qmlValue = dynamic_cast<const QmlObjectValue *>(o)) { } else if (const CppComponentValue *qmlValue = dynamic_cast<const CppComponentValue *>(o)) {
return qmlValue->defaultPropertyName(); return qmlValue->defaultPropertyName();
} }
} }

View File

@@ -159,7 +159,7 @@ public:
} // end of anonymous namespace } // end of anonymous namespace
QmlObjectValue::QmlObjectValue(FakeMetaObject::ConstPtr metaObject, const QString &className, CppComponentValue::CppComponentValue(FakeMetaObject::ConstPtr metaObject, const QString &className,
const QString &packageName, const ComponentVersion &componentVersion, const QString &packageName, const ComponentVersion &componentVersion,
const ComponentVersion &importVersion, int metaObjectRevision, const ComponentVersion &importVersion, int metaObjectRevision,
ValueOwner *valueOwner) ValueOwner *valueOwner)
@@ -179,7 +179,7 @@ QmlObjectValue::QmlObjectValue(FakeMetaObject::ConstPtr metaObject, const QStrin
} }
} }
QmlObjectValue::~QmlObjectValue() CppComponentValue::~CppComponentValue()
{ {
delete _metaSignatures; delete _metaSignatures;
delete _signalScopes; delete _signalScopes;
@@ -193,7 +193,7 @@ static QString generatedSlotName(const QString &base)
return slotName; return slotName;
} }
void QmlObjectValue::processMembers(MemberProcessor *processor) const void CppComponentValue::processMembers(MemberProcessor *processor) const
{ {
// process the meta enums // process the meta enums
for (int index = _metaObject->enumeratorOffset(); index < _metaObject->enumeratorCount(); ++index) { for (int index = _metaObject->enumeratorOffset(); index < _metaObject->enumeratorCount(); ++index) {
@@ -269,12 +269,12 @@ void QmlObjectValue::processMembers(MemberProcessor *processor) const
ObjectValue::processMembers(processor); ObjectValue::processMembers(processor);
} }
const Value *QmlObjectValue::valueForCppName(const QString &typeName) const const Value *CppComponentValue::valueForCppName(const QString &typeName) const
{ {
const CppQmlTypes &cppTypes = valueOwner()->cppQmlTypes(); const CppQmlTypes &cppTypes = valueOwner()->cppQmlTypes();
// check in the same package/version first // check in the same package/version first
const QmlObjectValue *objectValue = cppTypes.objectByQualifiedName( const CppComponentValue *objectValue = cppTypes.objectByQualifiedName(
_moduleName, typeName, _importVersion); _moduleName, typeName, _importVersion);
if (objectValue) if (objectValue)
return objectValue; return objectValue;
@@ -322,7 +322,7 @@ const Value *QmlObjectValue::valueForCppName(const QString &typeName) const
} }
// might be an enum // might be an enum
const QmlObjectValue *base = this; const CppComponentValue *base = this;
const QStringList components = typeName.split(QLatin1String("::")); const QStringList components = typeName.split(QLatin1String("::"));
if (components.size() == 2) { if (components.size() == 2) {
base = valueOwner()->cppQmlTypes().objectByCppName(components.first()); base = valueOwner()->cppQmlTypes().objectByCppName(components.first());
@@ -335,42 +335,42 @@ const Value *QmlObjectValue::valueForCppName(const QString &typeName) const
return valueOwner()->undefinedValue(); return valueOwner()->undefinedValue();
} }
const QmlObjectValue *QmlObjectValue::prototype() const const CppComponentValue *CppComponentValue::prototype() const
{ {
Q_ASSERT(!_prototype || dynamic_cast<const QmlObjectValue *>(_prototype)); Q_ASSERT(!_prototype || dynamic_cast<const CppComponentValue *>(_prototype));
return static_cast<const QmlObjectValue *>(_prototype); return static_cast<const CppComponentValue *>(_prototype);
} }
const QmlObjectValue *QmlObjectValue::attachedType() const const CppComponentValue *CppComponentValue::attachedType() const
{ {
return _attachedType; return _attachedType;
} }
void QmlObjectValue::setAttachedType(QmlObjectValue *value) void CppComponentValue::setAttachedType(CppComponentValue *value)
{ {
_attachedType = value; _attachedType = value;
} }
FakeMetaObject::ConstPtr QmlObjectValue::metaObject() const FakeMetaObject::ConstPtr CppComponentValue::metaObject() const
{ {
return _metaObject; return _metaObject;
} }
QString QmlObjectValue::moduleName() const QString CppComponentValue::moduleName() const
{ return _moduleName; } { return _moduleName; }
ComponentVersion QmlObjectValue::componentVersion() const ComponentVersion CppComponentValue::componentVersion() const
{ return _componentVersion; } { return _componentVersion; }
ComponentVersion QmlObjectValue::importVersion() const ComponentVersion CppComponentValue::importVersion() const
{ return _importVersion; } { return _importVersion; }
QString QmlObjectValue::defaultPropertyName() const QString CppComponentValue::defaultPropertyName() const
{ return _metaObject->defaultPropertyName(); } { return _metaObject->defaultPropertyName(); }
QString QmlObjectValue::propertyType(const QString &propertyName) const QString CppComponentValue::propertyType(const QString &propertyName) const
{ {
for (const QmlObjectValue *it = this; it; it = it->prototype()) { for (const CppComponentValue *it = this; it; it = it->prototype()) {
FakeMetaObject::ConstPtr iter = it->_metaObject; FakeMetaObject::ConstPtr iter = it->_metaObject;
int propIdx = iter->propertyIndex(propertyName); int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1) { if (propIdx != -1) {
@@ -380,9 +380,9 @@ QString QmlObjectValue::propertyType(const QString &propertyName) const
return QString(); return QString();
} }
bool QmlObjectValue::isListProperty(const QString &propertyName) const bool CppComponentValue::isListProperty(const QString &propertyName) const
{ {
for (const QmlObjectValue *it = this; it; it = it->prototype()) { for (const CppComponentValue *it = this; it; it = it->prototype()) {
FakeMetaObject::ConstPtr iter = it->_metaObject; FakeMetaObject::ConstPtr iter = it->_metaObject;
int propIdx = iter->propertyIndex(propertyName); int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1) { if (propIdx != -1) {
@@ -392,9 +392,9 @@ bool QmlObjectValue::isListProperty(const QString &propertyName) const
return false; return false;
} }
FakeMetaEnum QmlObjectValue::getEnum(const QString &typeName, const QmlObjectValue **foundInScope) const FakeMetaEnum CppComponentValue::getEnum(const QString &typeName, const CppComponentValue **foundInScope) const
{ {
for (const QmlObjectValue *it = this; it; it = it->prototype()) { for (const CppComponentValue *it = this; it; it = it->prototype()) {
FakeMetaObject::ConstPtr iter = it->_metaObject; FakeMetaObject::ConstPtr iter = it->_metaObject;
const int index = iter->enumeratorIndex(typeName); const int index = iter->enumeratorIndex(typeName);
if (index != -1) { if (index != -1) {
@@ -408,9 +408,9 @@ FakeMetaEnum QmlObjectValue::getEnum(const QString &typeName, const QmlObjectVal
return FakeMetaEnum(); return FakeMetaEnum();
} }
const QmlEnumValue *QmlObjectValue::getEnumValue(const QString &typeName, const QmlObjectValue **foundInScope) const const QmlEnumValue *CppComponentValue::getEnumValue(const QString &typeName, const CppComponentValue **foundInScope) const
{ {
for (const QmlObjectValue *it = this; it; it = it->prototype()) { for (const CppComponentValue *it = this; it; it = it->prototype()) {
if (const QmlEnumValue *e = it->_enums.value(typeName)) { if (const QmlEnumValue *e = it->_enums.value(typeName)) {
if (foundInScope) if (foundInScope)
*foundInScope = it; *foundInScope = it;
@@ -422,7 +422,7 @@ const QmlEnumValue *QmlObjectValue::getEnumValue(const QString &typeName, const
return 0; return 0;
} }
const ObjectValue *QmlObjectValue::signalScope(const QString &signalName) const const ObjectValue *CppComponentValue::signalScope(const QString &signalName) const
{ {
QHash<QString, const ObjectValue *> *scopes = _signalScopes; QHash<QString, const ObjectValue *> *scopes = _signalScopes;
if (!scopes) { if (!scopes) {
@@ -457,9 +457,9 @@ const ObjectValue *QmlObjectValue::signalScope(const QString &signalName) const
return scopes->value(signalName); return scopes->value(signalName);
} }
bool QmlObjectValue::isWritable(const QString &propertyName) const bool CppComponentValue::isWritable(const QString &propertyName) const
{ {
for (const QmlObjectValue *it = this; it; it = it->prototype()) { for (const CppComponentValue *it = this; it; it = it->prototype()) {
FakeMetaObject::ConstPtr iter = it->_metaObject; FakeMetaObject::ConstPtr iter = it->_metaObject;
int propIdx = iter->propertyIndex(propertyName); int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1) { if (propIdx != -1) {
@@ -469,9 +469,9 @@ bool QmlObjectValue::isWritable(const QString &propertyName) const
return false; return false;
} }
bool QmlObjectValue::isPointer(const QString &propertyName) const bool CppComponentValue::isPointer(const QString &propertyName) const
{ {
for (const QmlObjectValue *it = this; it; it = it->prototype()) { for (const CppComponentValue *it = this; it; it = it->prototype()) {
FakeMetaObject::ConstPtr iter = it->_metaObject; FakeMetaObject::ConstPtr iter = it->_metaObject;
int propIdx = iter->propertyIndex(propertyName); int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1) { if (propIdx != -1) {
@@ -481,7 +481,7 @@ bool QmlObjectValue::isPointer(const QString &propertyName) const
return false; return false;
} }
bool QmlObjectValue::hasLocalProperty(const QString &typeName) const bool CppComponentValue::hasLocalProperty(const QString &typeName) const
{ {
int idx = _metaObject->propertyIndex(typeName); int idx = _metaObject->propertyIndex(typeName);
if (idx == -1) if (idx == -1)
@@ -489,9 +489,9 @@ bool QmlObjectValue::hasLocalProperty(const QString &typeName) const
return true; return true;
} }
bool QmlObjectValue::hasProperty(const QString &propertyName) const bool CppComponentValue::hasProperty(const QString &propertyName) const
{ {
for (const QmlObjectValue *it = this; it; it = it->prototype()) { for (const CppComponentValue *it = this; it; it = it->prototype()) {
FakeMetaObject::ConstPtr iter = it->_metaObject; FakeMetaObject::ConstPtr iter = it->_metaObject;
int propIdx = iter->propertyIndex(propertyName); int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1) { if (propIdx != -1) {
@@ -501,9 +501,9 @@ bool QmlObjectValue::hasProperty(const QString &propertyName) const
return false; return false;
} }
bool QmlObjectValue::isDerivedFrom(FakeMetaObject::ConstPtr base) const bool CppComponentValue::isDerivedFrom(FakeMetaObject::ConstPtr base) const
{ {
for (const QmlObjectValue *it = this; it; it = it->prototype()) { for (const CppComponentValue *it = this; it; it = it->prototype()) {
FakeMetaObject::ConstPtr iter = it->_metaObject; FakeMetaObject::ConstPtr iter = it->_metaObject;
if (iter == base) if (iter == base)
return true; return true;
@@ -511,7 +511,7 @@ bool QmlObjectValue::isDerivedFrom(FakeMetaObject::ConstPtr base) const
return false; return false;
} }
QmlEnumValue::QmlEnumValue(const QmlObjectValue *owner, int enumIndex) QmlEnumValue::QmlEnumValue(const CppComponentValue *owner, int enumIndex)
: _owner(owner) : _owner(owner)
, _enumIndex(enumIndex) , _enumIndex(enumIndex)
{ {
@@ -532,7 +532,7 @@ QStringList QmlEnumValue::keys() const
return _owner->metaObject()->enumerator(_enumIndex).keys(); return _owner->metaObject()->enumerator(_enumIndex).keys();
} }
const QmlObjectValue *QmlEnumValue::owner() const const CppComponentValue *QmlEnumValue::owner() const
{ {
return _owner; return _owner;
} }
@@ -1290,7 +1290,7 @@ const QLatin1String CppQmlTypes::cppPackage("<cpp>");
template <typename T> template <typename T>
void CppQmlTypes::load(const T &fakeMetaObjects, const QString &overridePackage) void CppQmlTypes::load(const T &fakeMetaObjects, const QString &overridePackage)
{ {
QList<QmlObjectValue *> newCppTypes; QList<CppComponentValue *> newCppTypes;
foreach (const FakeMetaObject::ConstPtr &fmo, fakeMetaObjects) { foreach (const FakeMetaObject::ConstPtr &fmo, fakeMetaObjects) {
foreach (const FakeMetaObject::Export &exp, fmo->exports()) { foreach (const FakeMetaObject::Export &exp, fmo->exports()) {
QString package = exp.package; QString package = exp.package;
@@ -1303,7 +1303,7 @@ void CppQmlTypes::load(const T &fakeMetaObjects, const QString &overridePackage)
if (exp.package == cppPackage) { if (exp.package == cppPackage) {
QTC_ASSERT(exp.version == ComponentVersion(), continue); QTC_ASSERT(exp.version == ComponentVersion(), continue);
QTC_ASSERT(exp.type == fmo->className(), continue); QTC_ASSERT(exp.type == fmo->className(), continue);
QmlObjectValue *cppValue = new QmlObjectValue( CppComponentValue *cppValue = new CppComponentValue(
fmo, fmo->className(), cppPackage, ComponentVersion(), ComponentVersion(), fmo, fmo->className(), cppPackage, ComponentVersion(), ComponentVersion(),
ComponentVersion::MaxVersion, _valueOwner); ComponentVersion::MaxVersion, _valueOwner);
_objectsByQualifiedName[qualifiedName(cppPackage, fmo->className(), ComponentVersion())] = cppValue; _objectsByQualifiedName[qualifiedName(cppPackage, fmo->className(), ComponentVersion())] = cppValue;
@@ -1313,9 +1313,9 @@ void CppQmlTypes::load(const T &fakeMetaObjects, const QString &overridePackage)
} }
// set prototypes of cpp types // set prototypes of cpp types
foreach (QmlObjectValue *object, newCppTypes) { foreach (CppComponentValue *object, newCppTypes) {
const QString &protoCppName = object->metaObject()->superclassName(); const QString &protoCppName = object->metaObject()->superclassName();
const QmlObjectValue *proto = objectByCppName(protoCppName); const CppComponentValue *proto = objectByCppName(protoCppName);
if (proto) if (proto)
object->setPrototype(proto); object->setPrototype(proto);
} }
@@ -1324,10 +1324,10 @@ void CppQmlTypes::load(const T &fakeMetaObjects, const QString &overridePackage)
template void CppQmlTypes::load< QList<FakeMetaObject::ConstPtr> >(const QList<FakeMetaObject::ConstPtr> &, const QString &); template void CppQmlTypes::load< QList<FakeMetaObject::ConstPtr> >(const QList<FakeMetaObject::ConstPtr> &, const QString &);
template void CppQmlTypes::load< QHash<QString, FakeMetaObject::ConstPtr> >(const QHash<QString, FakeMetaObject::ConstPtr> &, const QString &); template void CppQmlTypes::load< QHash<QString, FakeMetaObject::ConstPtr> >(const QHash<QString, FakeMetaObject::ConstPtr> &, const QString &);
QList<const QmlObjectValue *> CppQmlTypes::createObjectsForImport(const QString &package, ComponentVersion version) QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QString &package, ComponentVersion version)
{ {
QList<const QmlObjectValue *> exportedObjects; QList<const CppComponentValue *> exportedObjects;
QList<const QmlObjectValue *> newObjects; QList<const CppComponentValue *> newObjects;
// make new exported objects // make new exported objects
foreach (const FakeMetaObject::ConstPtr &fmo, _fakeMetaObjectsByPackage.value(package)) { foreach (const FakeMetaObject::ConstPtr &fmo, _fakeMetaObjectsByPackage.value(package)) {
@@ -1354,7 +1354,7 @@ QList<const QmlObjectValue *> CppQmlTypes::createObjectsForImport(const QString
name = fmo->className(); name = fmo->className();
} }
QmlObjectValue *newObject = new QmlObjectValue( CppComponentValue *newObject = new CppComponentValue(
fmo, name, package, bestExport.version, version, fmo, name, package, bestExport.version, version,
bestExport.metaObjectRevision, _valueOwner); bestExport.metaObjectRevision, _valueOwner);
@@ -1366,8 +1366,8 @@ QList<const QmlObjectValue *> CppQmlTypes::createObjectsForImport(const QString
} }
// set their prototypes, creating them if necessary // set their prototypes, creating them if necessary
foreach (const QmlObjectValue *cobject, newObjects) { foreach (const CppComponentValue *cobject, newObjects) {
QmlObjectValue *object = const_cast<QmlObjectValue *>(cobject); CppComponentValue *object = const_cast<CppComponentValue *>(cobject);
while (!object->prototype()) { while (!object->prototype()) {
const QString &protoCppName = object->metaObject()->superclassName(); const QString &protoCppName = object->metaObject()->superclassName();
if (protoCppName.isEmpty()) if (protoCppName.isEmpty())
@@ -1375,19 +1375,19 @@ QList<const QmlObjectValue *> CppQmlTypes::createObjectsForImport(const QString
// if the prototype already exists, done // if the prototype already exists, done
const QString key = qualifiedName(object->moduleName(), protoCppName, version); const QString key = qualifiedName(object->moduleName(), protoCppName, version);
if (const QmlObjectValue *proto = _objectsByQualifiedName.value(key)) { if (const CppComponentValue *proto = _objectsByQualifiedName.value(key)) {
object->setPrototype(proto); object->setPrototype(proto);
break; break;
} }
// get the fmo via the cpp name // get the fmo via the cpp name
const QmlObjectValue *cppProto = objectByCppName(protoCppName); const CppComponentValue *cppProto = objectByCppName(protoCppName);
if (!cppProto) if (!cppProto)
break; break;
FakeMetaObject::ConstPtr protoFmo = cppProto->metaObject(); FakeMetaObject::ConstPtr protoFmo = cppProto->metaObject();
// make a new object // make a new object
QmlObjectValue *proto = new QmlObjectValue( CppComponentValue *proto = new CppComponentValue(
protoFmo, protoCppName, object->moduleName(), ComponentVersion(), protoFmo, protoCppName, object->moduleName(), ComponentVersion(),
object->importVersion(), ComponentVersion::MaxVersion, _valueOwner); object->importVersion(), ComponentVersion::MaxVersion, _valueOwner);
_objectsByQualifiedName.insert(key, proto); _objectsByQualifiedName.insert(key, proto);
@@ -1414,18 +1414,18 @@ QString CppQmlTypes::qualifiedName(const QString &module, const QString &type, C
} }
const QmlObjectValue *CppQmlTypes::objectByQualifiedName(const QString &name) const const CppComponentValue *CppQmlTypes::objectByQualifiedName(const QString &name) const
{ {
return _objectsByQualifiedName.value(name); return _objectsByQualifiedName.value(name);
} }
const QmlObjectValue *CppQmlTypes::objectByQualifiedName(const QString &package, const QString &type, const CppComponentValue *CppQmlTypes::objectByQualifiedName(const QString &package, const QString &type,
ComponentVersion version) const ComponentVersion version) const
{ {
return objectByQualifiedName(qualifiedName(package, type, version)); return objectByQualifiedName(qualifiedName(package, type, version));
} }
const QmlObjectValue *CppQmlTypes::objectByCppName(const QString &cppName) const const CppComponentValue *CppQmlTypes::objectByCppName(const QString &cppName) const
{ {
return objectByQualifiedName(qualifiedName(cppPackage, cppName, ComponentVersion())); return objectByQualifiedName(qualifiedName(cppPackage, cppName, ComponentVersion()));
} }

View File

@@ -394,43 +394,43 @@ private:
Error m_error; Error m_error;
}; };
class QmlObjectValue; class CppComponentValue;
class QMLJS_EXPORT QmlEnumValue: public NumberValue class QMLJS_EXPORT QmlEnumValue: public NumberValue
{ {
public: public:
QmlEnumValue(const QmlObjectValue *owner, int index); QmlEnumValue(const CppComponentValue *owner, int index);
virtual ~QmlEnumValue(); virtual ~QmlEnumValue();
QString name() const; QString name() const;
QStringList keys() const; QStringList keys() const;
const QmlObjectValue *owner() const; const CppComponentValue *owner() const;
private: private:
const QmlObjectValue *_owner; const CppComponentValue *_owner;
int _enumIndex; int _enumIndex;
}; };
// A ObjectValue based on a FakeMetaObject. // A ObjectValue based on a FakeMetaObject.
// May only have other QmlObjectValues as ancestors. // May only have other CppComponentValue as ancestors.
class QMLJS_EXPORT QmlObjectValue: public ObjectValue class QMLJS_EXPORT CppComponentValue: public ObjectValue
{ {
public: public:
QmlObjectValue(LanguageUtils::FakeMetaObject::ConstPtr metaObject, const QString &className, CppComponentValue(LanguageUtils::FakeMetaObject::ConstPtr metaObject, const QString &className,
const QString &moduleName, const LanguageUtils::ComponentVersion &componentVersion, const QString &moduleName, const LanguageUtils::ComponentVersion &componentVersion,
const LanguageUtils::ComponentVersion &importVersion, int metaObjectRevision, const LanguageUtils::ComponentVersion &importVersion, int metaObjectRevision,
ValueOwner *valueOwner); ValueOwner *valueOwner);
virtual ~QmlObjectValue(); virtual ~CppComponentValue();
virtual void processMembers(MemberProcessor *processor) const; virtual void processMembers(MemberProcessor *processor) const;
const Value *valueForCppName(const QString &typeName) const; const Value *valueForCppName(const QString &typeName) const;
using ObjectValue::prototype; using ObjectValue::prototype;
const QmlObjectValue *prototype() const; const CppComponentValue *prototype() const;
const QmlObjectValue *attachedType() const; const CppComponentValue *attachedType() const;
void setAttachedType(QmlObjectValue *value); void setAttachedType(CppComponentValue *value);
LanguageUtils::FakeMetaObject::ConstPtr metaObject() const; LanguageUtils::FakeMetaObject::ConstPtr metaObject() const;
@@ -446,15 +446,15 @@ public:
bool hasLocalProperty(const QString &typeName) const; bool hasLocalProperty(const QString &typeName) const;
bool hasProperty(const QString &typeName) const; bool hasProperty(const QString &typeName) const;
LanguageUtils::FakeMetaEnum getEnum(const QString &typeName, const QmlObjectValue **foundInScope = 0) const; LanguageUtils::FakeMetaEnum getEnum(const QString &typeName, const CppComponentValue **foundInScope = 0) const;
const QmlEnumValue *getEnumValue(const QString &typeName, const QmlObjectValue **foundInScope = 0) const; const QmlEnumValue *getEnumValue(const QString &typeName, const CppComponentValue **foundInScope = 0) const;
const ObjectValue *signalScope(const QString &signalName) const; const ObjectValue *signalScope(const QString &signalName) const;
protected: protected:
bool isDerivedFrom(LanguageUtils::FakeMetaObject::ConstPtr base) const; bool isDerivedFrom(LanguageUtils::FakeMetaObject::ConstPtr base) const;
private: private:
QmlObjectValue *_attachedType; CppComponentValue *_attachedType;
LanguageUtils::FakeMetaObject::ConstPtr _metaObject; LanguageUtils::FakeMetaObject::ConstPtr _metaObject;
const QString _moduleName; const QString _moduleName;
// _componentVersion is the version of the export // _componentVersion is the version of the export
@@ -588,20 +588,20 @@ public:
template <typename T> template <typename T>
void load(const T &fakeMetaObjects, const QString &overridePackage = QString()); void load(const T &fakeMetaObjects, const QString &overridePackage = QString());
QList<const QmlObjectValue *> createObjectsForImport(const QString &package, LanguageUtils::ComponentVersion version); QList<const CppComponentValue *> createObjectsForImport(const QString &package, LanguageUtils::ComponentVersion version);
bool hasModule(const QString &module) const; bool hasModule(const QString &module) const;
static QString qualifiedName(const QString &module, const QString &type, static QString qualifiedName(const QString &module, const QString &type,
LanguageUtils::ComponentVersion version); LanguageUtils::ComponentVersion version);
const QmlObjectValue *objectByQualifiedName(const QString &fullyQualifiedName) const; const CppComponentValue *objectByQualifiedName(const QString &fullyQualifiedName) const;
const QmlObjectValue *objectByQualifiedName( const CppComponentValue *objectByQualifiedName(
const QString &package, const QString &type, const QString &package, const QString &type,
LanguageUtils::ComponentVersion version) const; LanguageUtils::ComponentVersion version) const;
const QmlObjectValue *objectByCppName(const QString &cppName) const; const CppComponentValue *objectByCppName(const QString &cppName) const;
private: private:
// "Package.CppName ImportVersion" -> QmlObjectValue // "Package.CppName ImportVersion" -> CppComponentValue
QHash<QString, const QmlObjectValue *> _objectsByQualifiedName; QHash<QString, const CppComponentValue *> _objectsByQualifiedName;
QHash<QString, QSet<LanguageUtils::FakeMetaObject::ConstPtr> > _fakeMetaObjectsByPackage; QHash<QString, QSet<LanguageUtils::FakeMetaObject::ConstPtr> > _fakeMetaObjectsByPackage;
ValueOwner *_valueOwner; ValueOwner *_valueOwner;
}; };

View File

@@ -366,7 +366,7 @@ Import LinkPrivate::importNonFile(Document::Ptr doc, const ImportInfo &importInf
// if there are cpp-based types for this package, use them too // if there are cpp-based types for this package, use them too
if (valueOwner->cppQmlTypes().hasModule(packageName)) { if (valueOwner->cppQmlTypes().hasModule(packageName)) {
importFound = true; importFound = true;
foreach (const QmlObjectValue *object, foreach (const CppComponentValue *object,
valueOwner->cppQmlTypes().createObjectsForImport(packageName, version)) { valueOwner->cppQmlTypes().createObjectsForImport(packageName, version)) {
import.object->setMember(object->className(), object); import.object->setMember(object->className(), object);
} }
@@ -439,7 +439,7 @@ bool LinkPrivate::importLibrary(Document::Ptr doc,
} else { } else {
const QString packageName = importInfo.name(); const QString packageName = importInfo.name();
valueOwner->cppQmlTypes().load(libraryInfo.metaObjects(), packageName); valueOwner->cppQmlTypes().load(libraryInfo.metaObjects(), packageName);
foreach (const QmlObjectValue *object, valueOwner->cppQmlTypes().createObjectsForImport(packageName, version)) { foreach (const CppComponentValue *object, valueOwner->cppQmlTypes().createObjectsForImport(packageName, version)) {
import->object->setMember(object->className(), object); import->object->setMember(object->className(), object);
} }
} }
@@ -522,7 +522,7 @@ void LinkPrivate::loadImplicitDefaultImports(Imports *imports)
import.valid = true; import.valid = true;
import.info = info; import.info = info;
import.object = new ObjectValue(valueOwner); import.object = new ObjectValue(valueOwner);
foreach (const QmlObjectValue *object, foreach (const CppComponentValue *object,
valueOwner->cppQmlTypes().createObjectsForImport( valueOwner->cppQmlTypes().createObjectsForImport(
defaultPackage, maxVersion)) { defaultPackage, maxVersion)) {
import.object->setMember(object->className(), object); import.object->setMember(object->className(), object);

View File

@@ -185,7 +185,7 @@ void ScopeBuilder::setQmlScopeObject(Node *node)
iter.next(); iter.next();
while (iter.hasNext()) { while (iter.hasNext()) {
const ObjectValue *prototype = iter.next(); const ObjectValue *prototype = iter.next();
if (const QmlObjectValue *qmlMetaObject = dynamic_cast<const QmlObjectValue *>(prototype)) { if (const CppComponentValue *qmlMetaObject = dynamic_cast<const CppComponentValue *>(prototype)) {
if ((qmlMetaObject->className() == QLatin1String("ListElement") if ((qmlMetaObject->className() == QLatin1String("ListElement")
|| qmlMetaObject->className() == QLatin1String("Connections") || qmlMetaObject->className() == QLatin1String("Connections")
) && (qmlMetaObject->moduleName() == QLatin1String("Qt") ) && (qmlMetaObject->moduleName() == QLatin1String("Qt")
@@ -259,7 +259,7 @@ const ObjectValue *ScopeBuilder::isPropertyChangesObject(const ContextPtr &conte
PrototypeIterator iter(object, context); PrototypeIterator iter(object, context);
while (iter.hasNext()) { while (iter.hasNext()) {
const ObjectValue *prototype = iter.next(); const ObjectValue *prototype = iter.next();
if (const QmlObjectValue *qmlMetaObject = dynamic_cast<const QmlObjectValue *>(prototype)) { if (const CppComponentValue *qmlMetaObject = dynamic_cast<const CppComponentValue *>(prototype)) {
if (qmlMetaObject->className() == QLatin1String("PropertyChanges") if (qmlMetaObject->className() == QLatin1String("PropertyChanges")
&& (qmlMetaObject->moduleName() == QLatin1String("Qt") && (qmlMetaObject->moduleName() == QLatin1String("Qt")
|| qmlMetaObject->moduleName() == QLatin1String("QtQuick"))) || qmlMetaObject->moduleName() == QLatin1String("QtQuick")))

View File

@@ -103,7 +103,7 @@ public:
type = ref->ast()->memberType.toString(); type = ref->ast()->memberType.toString();
m_properties.append(qMakePair(name, type)); m_properties.append(qMakePair(name, type));
} else { } else {
if (const QmlObjectValue * ov = dynamic_cast<const QmlObjectValue *>(value)) { if (const CppComponentValue * ov = dynamic_cast<const CppComponentValue *>(value)) {
QString qualifiedTypeName = ov->moduleName().isEmpty() ? ov->className() : ov->moduleName() + '.' + ov->className(); QString qualifiedTypeName = ov->moduleName().isEmpty() ? ov->className() : ov->moduleName() + '.' + ov->className();
m_properties.append(qMakePair(name, qualifiedTypeName)); m_properties.append(qMakePair(name, qualifiedTypeName));
} else { } else {
@@ -135,12 +135,12 @@ static inline bool isValueType(const QString &type)
return objectValuesList.contains(type); return objectValuesList.contains(type);
} }
const QmlObjectValue *findQmlPrototype(const ObjectValue *ov, const ContextPtr &context) const CppComponentValue *findQmlPrototype(const ObjectValue *ov, const ContextPtr &context)
{ {
if (!ov) if (!ov)
return 0; return 0;
const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(ov); const CppComponentValue * qmlValue = dynamic_cast<const CppComponentValue *>(ov);
if (qmlValue) if (qmlValue)
return qmlValue; return qmlValue;
@@ -154,7 +154,7 @@ QStringList prototypes(const ObjectValue *ov, const ContextPtr &context, bool ve
return list; return list;
ov = ov->prototype(context); ov = ov->prototype(context);
while (ov) { while (ov) {
const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(ov); const CppComponentValue * qmlValue = dynamic_cast<const CppComponentValue *>(ov);
if (qmlValue) { if (qmlValue) {
if (versions) { if (versions) {
list << qmlValue->moduleName() + '.' + qmlValue->className() + list << qmlValue->moduleName() + '.' + qmlValue->className() +
@@ -177,7 +177,7 @@ QStringList prototypes(const ObjectValue *ov, const ContextPtr &context, bool ve
QList<PropertyInfo> getObjectTypes(const ObjectValue *ov, const ContextPtr &context, bool local = false); QList<PropertyInfo> getObjectTypes(const ObjectValue *ov, const ContextPtr &context, bool local = false);
QList<PropertyInfo> getQmlTypes(const QmlObjectValue *ov, const ContextPtr &context, bool local = false) QList<PropertyInfo> getQmlTypes(const CppComponentValue *ov, const ContextPtr &context, bool local = false)
{ {
QList<PropertyInfo> list; QList<PropertyInfo> list;
if (!ov) if (!ov)
@@ -192,7 +192,7 @@ QList<PropertyInfo> getQmlTypes(const QmlObjectValue *ov, const ContextPtr &cont
QString name = property.first; QString name = property.first;
if (!ov->isWritable(name) && ov->isPointer(name)) { if (!ov->isWritable(name) && ov->isPointer(name)) {
//dot property //dot property
const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(ov->lookupMember(name, context)); const CppComponentValue * qmlValue = dynamic_cast<const CppComponentValue *>(ov->lookupMember(name, context));
if (qmlValue) { if (qmlValue) {
QList<PropertyInfo> dotProperties = getQmlTypes(qmlValue, context); QList<PropertyInfo> dotProperties = getQmlTypes(qmlValue, context);
foreach (const PropertyInfo &propertyInfo, dotProperties) { foreach (const PropertyInfo &propertyInfo, dotProperties) {
@@ -224,7 +224,7 @@ QList<PropertyInfo> getQmlTypes(const QmlObjectValue *ov, const ContextPtr &cont
if (!local) { if (!local) {
const ObjectValue* prototype = ov->prototype(context); const ObjectValue* prototype = ov->prototype(context);
const QmlObjectValue * qmlObjectValue = dynamic_cast<const QmlObjectValue *>(prototype); const CppComponentValue * qmlObjectValue = dynamic_cast<const CppComponentValue *>(prototype);
if (qmlObjectValue) { if (qmlObjectValue) {
list << getQmlTypes(qmlObjectValue, context); list << getQmlTypes(qmlObjectValue, context);
@@ -240,7 +240,7 @@ QList<PropertyInfo> getTypes(const ObjectValue *ov, const ContextPtr &context, b
{ {
QList<PropertyInfo> list; QList<PropertyInfo> list;
const QmlObjectValue * qmlObjectValue = dynamic_cast<const QmlObjectValue *>(ov); const CppComponentValue * qmlObjectValue = dynamic_cast<const CppComponentValue *>(ov);
if (qmlObjectValue) { if (qmlObjectValue) {
list << getQmlTypes(qmlObjectValue, context, local); list << getQmlTypes(qmlObjectValue, context, local);
@@ -264,7 +264,7 @@ QList<PropertyInfo> getObjectTypes(const ObjectValue *ov, const ContextPtr &cont
if (!local) { if (!local) {
const ObjectValue* prototype = ov->prototype(context); const ObjectValue* prototype = ov->prototype(context);
const QmlObjectValue * qmlObjectValue = dynamic_cast<const QmlObjectValue *>(prototype); const CppComponentValue * qmlObjectValue = dynamic_cast<const CppComponentValue *>(prototype);
if (qmlObjectValue) { if (qmlObjectValue) {
list << getQmlTypes(qmlObjectValue, context); list << getQmlTypes(qmlObjectValue, context);
@@ -358,13 +358,13 @@ public:
private: private:
NodeMetaInfoPrivate(Model *model, QString type, int maj = -1, int min = -1); NodeMetaInfoPrivate(Model *model, QString type, int maj = -1, int min = -1);
const QmlJS::QmlObjectValue *getQmlObjectValue() const; const QmlJS::CppComponentValue *getCppComponentValue() const;
const QmlJS::ObjectValue *getObjectValue() const; const QmlJS::ObjectValue *getObjectValue() const;
void setupPropertyInfo(QList<PropertyInfo> propertyInfos); void setupPropertyInfo(QList<PropertyInfo> propertyInfos);
void setupLocalPropertyInfo(QList<PropertyInfo> propertyInfos); void setupLocalPropertyInfo(QList<PropertyInfo> propertyInfos);
QString lookupName() const; QString lookupName() const;
QStringList lookupNameComponent() const; QStringList lookupNameComponent() const;
const QmlJS::QmlObjectValue *getNearestQmlObjectValue() const; const QmlJS::CppComponentValue *getNearestCppComponentValue() const;
QString fullQualifiedImportAliasType() const; QString fullQualifiedImportAliasType() const;
QString m_qualfiedTypeName; QString m_qualfiedTypeName;
@@ -424,7 +424,7 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, QString type, int maj, in
m_model(model) m_model(model)
{ {
if (context()) { if (context()) {
const QmlObjectValue *objectValue = getQmlObjectValue(); const CppComponentValue *objectValue = getCppComponentValue();
if (objectValue) { if (objectValue) {
setupPropertyInfo(getTypes(objectValue, context())); setupPropertyInfo(getTypes(objectValue, context()));
setupLocalPropertyInfo(getTypes(objectValue, context(), true)); setupLocalPropertyInfo(getTypes(objectValue, context(), true));
@@ -434,7 +434,7 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, QString type, int maj, in
} else { } else {
const ObjectValue *objectValue = getObjectValue(); const ObjectValue *objectValue = getObjectValue();
if (objectValue) { if (objectValue) {
const QmlObjectValue *qmlValue = dynamic_cast<const QmlObjectValue *>(objectValue); const CppComponentValue *qmlValue = dynamic_cast<const CppComponentValue *>(objectValue);
if (qmlValue) { if (qmlValue) {
m_majorVersion = qmlValue->componentVersion().majorVersion(); m_majorVersion = qmlValue->componentVersion().majorVersion();
m_minorVersion = qmlValue->componentVersion().minorVersion(); m_minorVersion = qmlValue->componentVersion().minorVersion();
@@ -452,7 +452,7 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, QString type, int maj, in
} }
} }
const QmlJS::QmlObjectValue *NodeMetaInfoPrivate::getQmlObjectValue() const const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() const
{ {
const QStringList nameComponents = m_qualfiedTypeName.split('.'); const QStringList nameComponents = m_qualfiedTypeName.split('.');
if (nameComponents.size() < 2) if (nameComponents.size() < 2)
@@ -460,7 +460,7 @@ const QmlJS::QmlObjectValue *NodeMetaInfoPrivate::getQmlObjectValue() const
const QString type = nameComponents.last(); const QString type = nameComponents.last();
// maybe 'type' is a cpp name // maybe 'type' is a cpp name
const QmlJS::QmlObjectValue *value = context()->valueOwner()->cppQmlTypes().objectByCppName(type); const QmlJS::CppComponentValue *value = context()->valueOwner()->cppQmlTypes().objectByCppName(type);
if (value) if (value)
return value; return value;
@@ -476,7 +476,7 @@ const QmlJS::QmlObjectValue *NodeMetaInfoPrivate::getQmlObjectValue() const
if (import.info.path() != module) if (import.info.path() != module)
continue; continue;
const Value *lookupResult = import.object->lookupMember(type, context()); const Value *lookupResult = import.object->lookupMember(type, context());
if ((value = dynamic_cast<const QmlObjectValue *>(lookupResult))) if ((value = dynamic_cast<const CppComponentValue *>(lookupResult)))
return value; return value;
} }
@@ -541,7 +541,7 @@ bool NodeMetaInfoPrivate::isPropertyWritable(const QString &propertyName) const
return true; return true;
} }
const QmlJS::QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); const QmlJS::CppComponentValue *qmlObjectValue = getNearestCppComponentValue();
if (!qmlObjectValue) if (!qmlObjectValue)
return true; return true;
if (qmlObjectValue->hasProperty(propertyName)) if (qmlObjectValue->hasProperty(propertyName))
@@ -573,7 +573,7 @@ bool NodeMetaInfoPrivate::isPropertyList(const QString &propertyName) const
return true; return true;
} }
const QmlJS::QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); const QmlJS::CppComponentValue *qmlObjectValue = getNearestCppComponentValue();
if (!qmlObjectValue) if (!qmlObjectValue)
return false; return false;
return qmlObjectValue->isListProperty(propertyName); return qmlObjectValue->isListProperty(propertyName);
@@ -601,7 +601,7 @@ bool NodeMetaInfoPrivate::isPropertyPointer(const QString &propertyName) const
return true; return true;
} }
const QmlJS::QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); const QmlJS::CppComponentValue *qmlObjectValue = getNearestCppComponentValue();
if (!qmlObjectValue) if (!qmlObjectValue)
return false; return false;
return qmlObjectValue->isPointer(propertyName); return qmlObjectValue->isPointer(propertyName);
@@ -629,7 +629,7 @@ bool NodeMetaInfoPrivate::isPropertyEnum(const QString &propertyName) const
return false; return false;
} }
const QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); const CppComponentValue *qmlObjectValue = getNearestCppComponentValue();
if (!qmlObjectValue) if (!qmlObjectValue)
return false; return false;
return qmlObjectValue->getEnum(propertyType(propertyName)).isValid(); return qmlObjectValue->getEnum(propertyType(propertyName)).isValid();
@@ -657,10 +657,10 @@ QString NodeMetaInfoPrivate::propertyEnumScope(const QString &propertyName) cons
return QString(); return QString();
} }
const QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); const CppComponentValue *qmlObjectValue = getNearestCppComponentValue();
if (!qmlObjectValue) if (!qmlObjectValue)
return QString(); return QString();
const QmlObjectValue *definedIn = 0; const CppComponentValue *definedIn = 0;
qmlObjectValue->getEnum(propertyType(propertyName), &definedIn); qmlObjectValue->getEnum(propertyType(propertyName), &definedIn);
if (definedIn) if (definedIn)
return definedIn->className(); return definedIn->className();
@@ -686,7 +686,7 @@ bool NodeMetaInfoPrivate::cleverCheckType(const QString &otherType) const
if (packageName() == package) if (packageName() == package)
return QString(package + '.' + typeName) == qualfiedTypeName(); return QString(package + '.' + typeName) == qualfiedTypeName();
const QmlObjectValue *qmlObjectValue = getQmlObjectValue(); const CppComponentValue *qmlObjectValue = getCppComponentValue();
if (!qmlObjectValue) if (!qmlObjectValue)
return false; return false;
@@ -741,7 +741,7 @@ QStringList NodeMetaInfoPrivate::keysForEnum(const QString &enumName) const
if (!isValid()) if (!isValid())
return QStringList(); return QStringList();
const QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); const CppComponentValue *qmlObjectValue = getNearestCppComponentValue();
if (!qmlObjectValue) if (!qmlObjectValue)
return QStringList(); return QStringList();
return qmlObjectValue->getEnum(enumName).keys(); return qmlObjectValue->getEnum(enumName).keys();
@@ -750,7 +750,7 @@ QStringList NodeMetaInfoPrivate::keysForEnum(const QString &enumName) const
QString NodeMetaInfoPrivate::packageName() const QString NodeMetaInfoPrivate::packageName() const
{ {
if (!isComponent()) { if (!isComponent()) {
if (const QmlObjectValue *qmlObject = getQmlObjectValue()) if (const CppComponentValue *qmlObject = getCppComponentValue())
return qmlObject->moduleName(); return qmlObject->moduleName();
} }
return QString(); return QString();
@@ -825,13 +825,13 @@ void NodeMetaInfoPrivate::setupPrototypes()
if (m_isComponent) if (m_isComponent)
objects = PrototypeIterator(getObjectValue(), context()).all(); objects = PrototypeIterator(getObjectValue(), context()).all();
else else
objects = PrototypeIterator(getQmlObjectValue(), context()).all(); objects = PrototypeIterator(getCppComponentValue(), context()).all();
foreach (const ObjectValue *ov, objects) { foreach (const ObjectValue *ov, objects) {
TypeDescription description; TypeDescription description;
description.className = ov->className(); description.className = ov->className();
description.minorVersion = -1; description.minorVersion = -1;
description.majorVersion = -1; description.majorVersion = -1;
if (const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(ov)) { if (const CppComponentValue * qmlValue = dynamic_cast<const CppComponentValue *>(ov)) {
description.minorVersion = qmlValue->componentVersion().minorVersion(); description.minorVersion = qmlValue->componentVersion().minorVersion();
description.majorVersion = qmlValue->componentVersion().majorVersion(); description.majorVersion = qmlValue->componentVersion().majorVersion();
if (!qmlValue->moduleName().isEmpty()) if (!qmlValue->moduleName().isEmpty())
@@ -850,11 +850,11 @@ QList<TypeDescription> NodeMetaInfoPrivate::prototypes() const
return m_prototypes; return m_prototypes;
} }
const QmlJS::QmlObjectValue *NodeMetaInfoPrivate::getNearestQmlObjectValue() const const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getNearestCppComponentValue() const
{ {
if (m_isComponent) if (m_isComponent)
return findQmlPrototype(getObjectValue(), context()); return findQmlPrototype(getObjectValue(), context());
return getQmlObjectValue(); return getCppComponentValue();
} }
QString NodeMetaInfoPrivate::fullQualifiedImportAliasType() const QString NodeMetaInfoPrivate::fullQualifiedImportAliasType() const

View File

@@ -344,7 +344,7 @@ public:
const ObjectValue *value = m_context->lookupType(m_doc.data(), astTypeNode); const ObjectValue *value = m_context->lookupType(m_doc.data(), astTypeNode);
defaultPropertyName = m_context->defaultPropertyName(value); defaultPropertyName = m_context->defaultPropertyName(value);
const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(value); const CppComponentValue * qmlValue = dynamic_cast<const CppComponentValue *>(value);
if (qmlValue) { if (qmlValue) {
typeName = fixUpPackeNameForQt(qmlValue->moduleName()) + QLatin1String(".") + qmlValue->className(); typeName = fixUpPackeNameForQt(qmlValue->moduleName()) + QLatin1String(".") + qmlValue->className();
@@ -500,7 +500,7 @@ public:
const ObjectValue *proto = iter.next(); const ObjectValue *proto = iter.next();
if (proto->lookupMember(name, m_context) == m_context->valueOwner()->arrayPrototype()) if (proto->lookupMember(name, m_context) == m_context->valueOwner()->arrayPrototype())
return true; return true;
if (const QmlObjectValue *qmlIter = dynamic_cast<const QmlObjectValue *>(proto)) { if (const CppComponentValue *qmlIter = dynamic_cast<const CppComponentValue *>(proto)) {
if (qmlIter->isListProperty(name)) if (qmlIter->isListProperty(name))
return true; return true;
} }
@@ -525,7 +525,7 @@ public:
if (containingObject) if (containingObject)
containingObject->lookupMember(name, m_context, &containingObject); containingObject->lookupMember(name, m_context, &containingObject);
if (const QmlObjectValue * qmlObject = dynamic_cast<const QmlObjectValue *>(containingObject)) { if (const CppComponentValue * qmlObject = dynamic_cast<const CppComponentValue *>(containingObject)) {
const QString typeName = qmlObject->propertyType(name); const QString typeName = qmlObject->propertyType(name);
if (qmlObject->getEnum(typeName).isValid()) { if (qmlObject->getEnum(typeName).isValid()) {
return QVariant(cleanedValue); return QVariant(cleanedValue);
@@ -569,10 +569,10 @@ public:
if (containingObject) if (containingObject)
containingObject->lookupMember(name, m_context, &containingObject); containingObject->lookupMember(name, m_context, &containingObject);
const QmlObjectValue * lhsQmlObject = dynamic_cast<const QmlObjectValue *>(containingObject); const CppComponentValue * lhsCppComponent = dynamic_cast<const CppComponentValue *>(containingObject);
if (!lhsQmlObject) if (!lhsCppComponent)
return QVariant(); return QVariant();
const QString lhsPropertyTypeName = lhsQmlObject->propertyType(name); const QString lhsPropertyTypeName = lhsCppComponent->propertyType(name);
const ObjectValue *rhsValueObject = 0; const ObjectValue *rhsValueObject = 0;
QString rhsValueName; QString rhsValueName;
@@ -593,11 +593,11 @@ public:
if (rhsValueObject) if (rhsValueObject)
rhsValueObject->lookupMember(rhsValueName, m_context, &rhsValueObject); rhsValueObject->lookupMember(rhsValueName, m_context, &rhsValueObject);
const QmlObjectValue *rhsQmlObjectValue = dynamic_cast<const QmlObjectValue *>(rhsValueObject); const CppComponentValue *rhsCppComponentValue = dynamic_cast<const CppComponentValue *>(rhsValueObject);
if (!rhsQmlObjectValue) if (!rhsCppComponentValue)
return QVariant(); return QVariant();
if (rhsQmlObjectValue->getEnum(lhsPropertyTypeName).hasKey(rhsValueName)) if (rhsCppComponentValue->getEnum(lhsPropertyTypeName).hasKey(rhsValueName))
return QVariant(rhsValueName); return QVariant(rhsValueName);
else else
return QVariant(); return QVariant();

View File

@@ -148,7 +148,7 @@ public:
virtual void operator ()(const Value *base, const QString &name, const Value *) virtual void operator ()(const Value *base, const QString &name, const Value *)
{ {
const QmlObjectValue *qmlBase = dynamic_cast<const QmlObjectValue *>(base); const CppComponentValue *qmlBase = dynamic_cast<const CppComponentValue *>(base);
QString itemText = name; QString itemText = name;
QString postfix; QString postfix;

View File

@@ -94,7 +94,7 @@ class CollectStateNames : protected Visitor
QStringList m_stateNames; QStringList m_stateNames;
bool m_inStateType; bool m_inStateType;
ScopeChain m_scopeChain; ScopeChain m_scopeChain;
const QmlObjectValue *m_statePrototype; const CppComponentValue *m_statePrototype;
public: public:
CollectStateNames(const ScopeChain &scopeChain) CollectStateNames(const ScopeChain &scopeChain)
@@ -138,7 +138,7 @@ protected:
PrototypeIterator it(v, m_scopeChain.context()); PrototypeIterator it(v, m_scopeChain.context());
while (it.hasNext()) { while (it.hasNext()) {
const ObjectValue *proto = it.next(); const ObjectValue *proto = it.next();
const QmlObjectValue *qmlProto = dynamic_cast<const QmlObjectValue *>(proto); const CppComponentValue *qmlProto = dynamic_cast<const CppComponentValue *>(proto);
if (!qmlProto) if (!qmlProto)
continue; continue;
if (qmlProto->metaObject() == m_statePrototype->metaObject()) if (qmlProto->metaObject() == m_statePrototype->metaObject())

View File

@@ -124,8 +124,8 @@ void tst_Basic::basicObjectTests()
ContextPtr context = Link(snapshot, QStringList(), LibraryInfo())(); ContextPtr context = Link(snapshot, QStringList(), LibraryInfo())();
QVERIFY(context); QVERIFY(context);
QmlObjectValue *rectangleValue = context->valueOwner()->cppQmlTypes().typeByQualifiedName( const CppComponentValue *rectangleValue = context->valueOwner()->cppQmlTypes().objectByQualifiedName(
"Qt", "Rectangle", LanguageUtils::ComponentVersion(4, 7)); "QtQuick", "QDeclarative1Rectangle", LanguageUtils::ComponentVersion(1, 0));
QVERIFY(rectangleValue); QVERIFY(rectangleValue);
QVERIFY(!rectangleValue->isWritable("border")); QVERIFY(!rectangleValue->isWritable("border"));
QVERIFY(rectangleValue->hasProperty("border")); QVERIFY(rectangleValue->hasProperty("border"));
@@ -135,7 +135,7 @@ void tst_Basic::basicObjectTests()
const ObjectValue *ovItem = context->lookupType(doc.data(), QStringList() << "Item"); const ObjectValue *ovItem = context->lookupType(doc.data(), QStringList() << "Item");
QCOMPARE(ovItem->className(), QString("Item")); QCOMPARE(ovItem->className(), QString("Item"));
QCOMPARE(context->imports(doc.data())->info("Item", context.data()).name(), QString("Qt")); QCOMPARE(context->imports(doc.data())->info("Item", context.data()).name(), QString("QtQuick"));
const ObjectValue *ovButton = context->lookupType(doc.data(), QStringList() << "MyButton"); const ObjectValue *ovButton = context->lookupType(doc.data(), QStringList() << "MyButton");
QCOMPARE(ovButton->className(), QString("MyButton")); QCOMPARE(ovButton->className(), QString("MyButton"));
QCOMPARE(ovButton->prototype(context)->className(), QString("Rectangle")); QCOMPARE(ovButton->prototype(context)->className(), QString("Rectangle"));
@@ -144,17 +144,17 @@ void tst_Basic::basicObjectTests()
QVERIFY(ovProperty); QVERIFY(ovProperty);
QCOMPARE(ovProperty->className(), QString("State")); QCOMPARE(ovProperty->className(), QString("State"));
const QmlObjectValue * qmlItemValue = dynamic_cast<const QmlObjectValue *>(ovItem); const CppComponentValue * qmlItemValue = dynamic_cast<const CppComponentValue *>(ovItem);
QVERIFY(qmlItemValue); QVERIFY(qmlItemValue);
QCOMPARE(qmlItemValue->defaultPropertyName(), QString("data")); QCOMPARE(qmlItemValue->defaultPropertyName(), QString("data"));
QCOMPARE(qmlItemValue->propertyType("state"), QString("string")); QCOMPARE(qmlItemValue->propertyType("state"), QString("string"));
const ObjectValue *ovState = context->lookupType(doc.data(), QStringList() << "State"); const ObjectValue *ovState = context->lookupType(doc.data(), QStringList() << "State");
const QmlObjectValue * qmlState2Value = dynamic_cast<const QmlObjectValue *>(ovState); const CppComponentValue * qmlState2Value = dynamic_cast<const CppComponentValue *>(ovState);
QCOMPARE(qmlState2Value->className(), QString("State")); QCOMPARE(qmlState2Value->className(), QString("State"));
const ObjectValue *ovImage = context->lookupType(doc.data(), QStringList() << "Image"); const ObjectValue *ovImage = context->lookupType(doc.data(), QStringList() << "Image");
const QmlObjectValue * qmlImageValue = dynamic_cast<const QmlObjectValue *>(ovImage); const CppComponentValue * qmlImageValue = dynamic_cast<const CppComponentValue *>(ovImage);
QCOMPARE(qmlImageValue->className(), QString("Image")); QCOMPARE(qmlImageValue->className(), QString("Image"));
QCOMPARE(qmlImageValue->propertyType("source"), QString("QUrl")); QCOMPARE(qmlImageValue->propertyType("source"), QString("QUrl"));
} }