diff options
Diffstat (limited to 'src/qmlcompiler/qqmljstypedescriptionreader.cpp')
-rw-r--r-- | src/qmlcompiler/qqmljstypedescriptionreader.cpp | 73 |
1 files changed, 55 insertions, 18 deletions
diff --git a/src/qmlcompiler/qqmljstypedescriptionreader.cpp b/src/qmlcompiler/qqmljstypedescriptionreader.cpp index 8528d39f0f..bebc01a8ef 100644 --- a/src/qmlcompiler/qqmljstypedescriptionreader.cpp +++ b/src/qmlcompiler/qqmljstypedescriptionreader.cpp @@ -166,6 +166,7 @@ void QQmlJSTypeDescriptionReader::readDependencies(UiScriptBinding *ast) void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) { + m_currentCtorIndex = 0; QQmlJSScope::Ptr scope = QQmlJSScope::create(); QList<QQmlJSScope::Export> exports; @@ -200,6 +201,8 @@ void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) scope->setOwnParentPropertyName(readStringBinding(script)); } else if (name == QLatin1String("exports")) { exports = readExports(script); + } else if (name == QLatin1String("aliases")) { + readAliases(script, scope); } else if (name == QLatin1String("interfaces")) { readInterfaces(script, scope); } else if (name == QLatin1String("exportMetaObjectRevisions")) { @@ -212,6 +215,8 @@ void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) scope->setIsSingleton(readBoolBinding(script)); } else if (name == QLatin1String("isCreatable")) { scope->setCreatableFlag(readBoolBinding(script)); + } else if (name == QLatin1String("isStructured")) { + scope->setStructuredFlag(readBoolBinding(script)); } else if (name == QLatin1String("isComposite")) { scope->setIsComposite(readBoolBinding(script)); } else if (name == QLatin1String("hasCustomParser")) { @@ -232,6 +237,8 @@ void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) } } else if (name == QLatin1String("extension")) { scope->setExtensionTypeName(readStringBinding(script)); + } else if (name == QLatin1String("extensionIsJavaScript")) { + scope->setExtensionIsJavaScript(readBoolBinding(script)); } else if (name == QLatin1String("extensionIsNamespace")) { scope->setExtensionIsNamespace(readBoolBinding(script)); } else if (name == QLatin1String("deferredNames")) { @@ -242,8 +249,9 @@ void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) addWarning(script->firstSourceLocation(), tr("Expected only name, prototype, defaultProperty, attachedType, " "valueType, exports, interfaces, isSingleton, isCreatable, " - "isComposite, hasCustomParser, exportMetaObjectRevisions, " - "deferredNames, and immediateNames in script bindings, not \"%1\".") + "isStructured, isComposite, hasCustomParser, aliases, " + "exportMetaObjectRevisions, deferredNames, and immediateNames " + "in script bindings, not \"%1\".") .arg(name)); } } else { @@ -262,15 +270,15 @@ void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) m_objects->append({scope, exports}); } -void QQmlJSTypeDescriptionReader::readSignalOrMethod(UiObjectDefinition *ast, bool isMethod, - const QQmlJSScope::Ptr &scope) +void QQmlJSTypeDescriptionReader::readSignalOrMethod( + UiObjectDefinition *ast, bool isMethod, const QQmlJSScope::Ptr &scope) { QQmlJSMetaMethod metaMethod; // ### confusion between Method and Slot. Method should be removed. if (isMethod) - metaMethod.setMethodType(QQmlJSMetaMethod::Slot); + metaMethod.setMethodType(QQmlJSMetaMethodType::Slot); else - metaMethod.setMethodType(QQmlJSMetaMethod::Signal); + metaMethod.setMethodType(QQmlJSMetaMethodType::Signal); for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) { UiObjectMember *member = it->member; @@ -293,22 +301,40 @@ void QQmlJSTypeDescriptionReader::readSignalOrMethod(UiObjectDefinition *ast, bo } else if (name == QLatin1String("revision")) { metaMethod.setRevision(readIntBinding(script)); } else if (name == QLatin1String("isCloned")) { - metaMethod.setIsCloned(true); + metaMethod.setIsCloned(readBoolBinding(script)); } else if (name == QLatin1String("isConstructor")) { - metaMethod.setIsConstructor(true); + // The constructors in the moc json output are ordered the same + // way as the ones in the metaobject. qmltyperegistrar moves them into + // the same list as the other members, but maintains their order. + if (readBoolBinding(script)) { + metaMethod.setIsConstructor(true); + metaMethod.setConstructorIndex( + QQmlJSMetaMethod::RelativeFunctionIndex(m_currentCtorIndex++)); + } } else if (name == QLatin1String("isJavaScriptFunction")) { - metaMethod.setIsJavaScriptFunction(true); + metaMethod.setIsJavaScriptFunction(readBoolBinding(script)); } else if (name == QLatin1String("isList")) { - // TODO: Theoretically this can happen. QQmlJSMetaMethod should store it. + auto metaReturnType = metaMethod.returnValue(); + metaReturnType.setIsList(readBoolBinding(script)); + metaMethod.setReturnValue(metaReturnType); } else if (name == QLatin1String("isPointer")) { // TODO: We don't need this information. We can probably drop all isPointer members // once we make sure that the type information is always complete. The // description of the type being referenced has access semantics after all. + auto metaReturnType = metaMethod.returnValue(); + metaReturnType.setIsPointer(readBoolBinding(script)); + metaMethod.setReturnValue(metaReturnType); + } else if (name == QLatin1String("isConstant")) { + auto metaReturnType = metaMethod.returnValue(); + metaReturnType.setTypeQualifier(readBoolBinding(script) + ? QQmlJSMetaParameter::Const + : QQmlJSMetaParameter::NonConst); + metaMethod.setReturnValue(metaReturnType); } else { addWarning(script->firstSourceLocation(), - tr("Expected only name, type, revision, isPointer, isList, " - "isCloned, isConstructor, and " - "isJavaScriptFunction in script bindings.")); + tr("Expected only name, type, revision, isPointer, isConstant, " + "isList, isCloned, isConstructor, and isJavaScriptFunction " + "in script bindings.")); } } else { addWarning(member->firstSourceLocation(), @@ -412,11 +438,13 @@ void QQmlJSTypeDescriptionReader::readEnum(UiObjectDefinition *ast, const QQmlJS metaEnum.setIsFlag(readBoolBinding(script)); } else if (name == QLatin1String("values")) { readEnumValues(script, &metaEnum); - } else if (name == QLatin1String("scoped")) { - metaEnum.setScoped(readBoolBinding(script)); + } else if (name == QLatin1String("isScoped")) { + metaEnum.setIsScoped(readBoolBinding(script)); + } else if (name == QLatin1String("type")) { + metaEnum.setTypeName(readStringBinding(script)); } else { addWarning(script->firstSourceLocation(), - tr("Expected only name and values script bindings.")); + tr("Expected only name, alias, isFlag, values, isScoped, or type.")); } } @@ -429,6 +457,7 @@ void QQmlJSTypeDescriptionReader::readParameter(UiObjectDefinition *ast, QQmlJSM QString type; bool isConstant = false; bool isPointer = false; + bool isList = false; for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) { UiObjectMember *member = it->member; @@ -450,16 +479,18 @@ void QQmlJSTypeDescriptionReader::readParameter(UiObjectDefinition *ast, QQmlJSM } else if (id == QLatin1String("isReadonly")) { // ### unhandled } else if (id == QLatin1String("isList")) { - // ### unhandled + isList = readBoolBinding(script); } else { addWarning(script->firstSourceLocation(), - tr("Expected only name and type script bindings.")); + tr("Expected only name, type, isPointer, isConstant, isReadonly, " + "or IsList script bindings.")); } } QQmlJSMetaParameter p(name, type); p.setTypeQualifier(isConstant ? QQmlJSMetaParameter::Const : QQmlJSMetaParameter::NonConst); p.setIsPointer(isPointer); + p.setIsList(isList); metaMethod->addParameter(std::move(p)); } @@ -657,6 +688,12 @@ QList<QQmlJSScope::Export> QQmlJSTypeDescriptionReader::readExports(UiScriptBind return exports; } +void QQmlJSTypeDescriptionReader::readAliases( + QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope) +{ + scope->setAliases(readStringList(ast)); +} + void QQmlJSTypeDescriptionReader::readInterfaces(UiScriptBinding *ast, const QQmlJSScope::Ptr &scope) { auto *arrayLit = getArray(ast); |