diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2016-11-28 17:13:37 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-11-29 10:06:12 +0000 |
commit | 37747423e5d3bd419fa1d413c7d545a2d4e5552f (patch) | |
tree | 1eb47ce131ca4ece7272a9616f653d1759065079 /tools/qscxmlc/scxmlcppdumper.cpp | |
parent | fd85b14ca803cdda43f8a6437d6d6d7d5560017f (diff) |
Reduce the public API exposed in qscxmlinvokableservice.h
We inline QScxmlInvokableService::finalize into the only place where it
is used.
Furthermore we construct static SCXML state machines through their
metaobjects rather than directly calling the constructor. This way we
can drop the template, make all the service factories QObjects, drop
the intermediate QScxmlScxmlServiceFactory class, and greatly reduce
the API exposed in qscxmlinvokableservice.h.
In addition, as some of the structs in QScxmlExecutableContent are
fairly large, we return them as const references, rather than by value.
Change-Id: Ia9ee61b5668b8af44307787339c08f3c6f23f713
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'tools/qscxmlc/scxmlcppdumper.cpp')
-rw-r--r-- | tools/qscxmlc/scxmlcppdumper.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/qscxmlc/scxmlcppdumper.cpp b/tools/qscxmlc/scxmlcppdumper.cpp index 53988cf..aa207bb 100644 --- a/tools/qscxmlc/scxmlcppdumper.cpp +++ b/tools/qscxmlc/scxmlcppdumper.cpp @@ -387,7 +387,7 @@ int createFactoryId(QStringList &factories, const QString &className, QString line = QStringLiteral("case %1: return new ").arg(QString::number(idx)); if (invokeInfo.expr == QScxmlExecutableContent::NoInstruction) { - line += QStringLiteral("QScxmlStaticScxmlServiceFactory< %1::%2 >(") + line += QStringLiteral("QScxmlStaticScxmlServiceFactory(&%1::%2::staticMetaObject,") .arg(namespacePrefix, className); } else { line += QStringLiteral("QScxmlDynamicScxmlServiceFactory("); @@ -729,6 +729,20 @@ QString CppDumper::generateMetaObject(const QString &className, classDef.qualified = classDef.classname; classDef.superclassList << qMakePair(QByteArray("QScxmlStateMachine"), FunctionDef::Public); classDef.hasQObject = true; + FunctionDef constructor; + constructor.name = className.toUtf8(); + constructor.access = FunctionDef::Public; + constructor.isInvokable = true; + constructor.isConstructor = true; + + ArgumentDef arg; + arg.type.name = "QObject *"; + arg.type.rawName = arg.type.name; + arg.normalizedType = arg.type.name; + arg.name = "parent"; + arg.typeNameForCast = arg.type.name + "*"; + constructor.arguments.append(arg); + classDef.constructorList.append(constructor); // stateNames: int stateIdx = 0; |