aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmltc
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2022-02-07 13:57:22 +0100
committerAndrei Golubev <andrei.golubev@qt.io>2022-02-14 18:05:06 +0100
commit116ba6f3846569359450424b66f8786ec00ed7cd (patch)
tree0c4a8e5109351f8b500843a87ff565a49617bf14 /tools/qmltc
parent4728efae2c6b7f2f0beae5773472af1817649aaa (diff)
qmltc: Explicitly unsupport singleton types
Change-Id: I05525f884f239c954527f24ad8842b108b32aff1 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> (cherry picked from commit 121457933dfa40de188063fefe86fa78881e18cd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tools/qmltc')
-rw-r--r--tools/qmltc/prototype/codegenerator.cpp31
1 files changed, 6 insertions, 25 deletions
diff --git a/tools/qmltc/prototype/codegenerator.cpp b/tools/qmltc/prototype/codegenerator.cpp
index ff71db989b..dab45a22b8 100644
--- a/tools/qmltc/prototype/codegenerator.cpp
+++ b/tools/qmltc/prototype/codegenerator.cpp
@@ -391,6 +391,11 @@ void CodeGenerator::compileObject(
QQmlJSAotObject &compiled, const CodeGenObject &object,
std::function<void(QQmlJSAotObject &, const CodeGenObject &)> compileElements)
{
+ if (object.type->isSingleton()) {
+ recordError(object.type->sourceLocation(), u"Singleton types are not supported"_qs);
+ return;
+ }
+
compiled.cppType = object.type->internalName();
const QString baseClass = object.type->baseType()->internalName();
@@ -684,18 +689,6 @@ void CodeGenerator::compileObject(
void CodeGenerator::compileObjectElements(QQmlJSAotObject &compiled, const CodeGenObject &object)
{
- if (object.type->isSingleton()) {
- if (m_isAnonymous) {
- recordError(object.type->sourceLocation(),
- QStringLiteral(u"This singleton type won't be accessible from the outside. "
- "Consider changing the file name so that it starts with a "
- "capital letter."));
- return;
- }
- compiled.mocCode << u"QML_SINGLETON"_qs;
- compiled.externalCtor.access = QQmlJSMetaMethod::Private;
- }
-
// compile enums
const auto enums = object.type->ownEnumerations();
compiled.enums.reserve(enums.size());
@@ -790,12 +783,7 @@ void CodeGenerator::compileObjectElements(QQmlJSAotObject &compiled, const CodeG
void CodeGenerator::compileQQmlComponentElements(QQmlJSAotObject &compiled,
const CodeGenObject &object)
{
- if (object.type->isSingleton()) {
- // it is unclear what to do with singletons in general, so just reject
- recordError(object.type->sourceLocation(),
- QStringLiteral(u"Singleton Component-based types are not supported"));
- return;
- }
+ Q_UNUSED(object);
// since we create a document root as QQmlComponent, we only need to fake
// QQmlComponent construction in init:
@@ -1734,13 +1722,6 @@ void CodeGenerator::compileScriptBinding(QQmlJSAotObject &current, const QmlIR::
Q_ASSERT(!objectClassName_slot.isEmpty());
const QString slotName = makeGensym(signalName + u"_slot");
- if (objectType->isSingleton()) { // TODO: support
- recordError(binding.location,
- u"Binding on singleton type '" + objectClassName_signal
- + u"' is not supported");
- return;
- }
-
// SignalHander specific:
QQmlJSAotMethod slotMethod {};
slotMethod.returnType = signalReturnType;