diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qscxmlc/decl.t | 1 | ||||
-rw-r--r-- | tools/qscxmlc/doc/qscxmlc.qdoc | 14 | ||||
-rw-r--r-- | tools/qscxmlc/qscxmlc.cpp | 4 | ||||
-rw-r--r-- | tools/qscxmlc/scxmlcppdumper.cpp | 31 | ||||
-rw-r--r-- | tools/qscxmlc/scxmlcppdumper.h | 4 |
5 files changed, 15 insertions, 39 deletions
diff --git a/tools/qscxmlc/decl.t b/tools/qscxmlc/decl.t index 09d6f72..648476d 100644 --- a/tools/qscxmlc/decl.t +++ b/tools/qscxmlc/decl.t @@ -1,6 +1,5 @@ class ${classname}: public QScxmlStateMachine { -public: /* qmake ignore Q_OBJECT */ Q_OBJECT ${properties} diff --git a/tools/qscxmlc/doc/qscxmlc.qdoc b/tools/qscxmlc/doc/qscxmlc.qdoc index f0d6726..07b5c8d 100644 --- a/tools/qscxmlc/doc/qscxmlc.qdoc +++ b/tools/qscxmlc/doc/qscxmlc.qdoc @@ -65,23 +65,21 @@ \li Option \li Description \row - \li \c -no-c++11 - \li Use no C++11 features in the generated code. - \row - \li \c {-namespace <namespace>} - \li Put the generated class(es) in the specified namespace. + \li \c {--namespace <namespace>} + \li Put the generated class(es) in the specified namespace. You can use the + \c QSCXMLC_NAMESPACE variable to specify this in your project file. \row \li \c {-o <base/out/name>} \li The base name of the output files. This can include a path. If none is specified, the basename of the input file is used. \row - \li \c {-oh <header/out>} + \li \c {--header <header/out>} \li The name of the output header file. If none is specified, .h is added to the base name. \row - \li \c {-ocpp <cpp/out>} + \li \c {--impl <cpp/out>} \li The name of the output header file. If none is specified, .cpp is added to the base name. \row - \li \c {-classname <StateMachineClassName>} + \li \c {--classname <StateMachineClassName>} \li The class name of the generated state machine. If none is specified, the value of the name attribute of the <scxml> tag is taken. If that attribute is not specified either, the basename (excluding path) is taken from the input file name. diff --git a/tools/qscxmlc/qscxmlc.cpp b/tools/qscxmlc/qscxmlc.cpp index de97a18..89abdaa 100644 --- a/tools/qscxmlc/qscxmlc.cpp +++ b/tools/qscxmlc/qscxmlc.cpp @@ -107,8 +107,6 @@ int run(const QStringList &arguments) cmdParser.setApplicationDescription(QCoreApplication::translate("main", "Compiles the given input.scxml file to a header and a cpp file.")); - QCommandLineOption optionNoCxx11(QLatin1String("no-c++11"), - QCoreApplication::translate("main", "Don't use C++11 in generated code.")); QCommandLineOption optionNamespace(QLatin1String("namespace"), QCoreApplication::translate("main", "Put generated code into <namespace>."), QCoreApplication::translate("main", "namespace")); @@ -127,7 +125,6 @@ int run(const QStringList &arguments) cmdParser.addPositionalArgument(QLatin1String("input"), QCoreApplication::translate("main", "Input SCXML file.")); - cmdParser.addOption(optionNoCxx11); cmdParser.addOption(optionNamespace); cmdParser.addOption(optionOutputBaseName); cmdParser.addOption(optionOutputHeaderName); @@ -152,7 +149,6 @@ int run(const QStringList &arguments) const QString scxmlFileName = inputFiles.at(0); TranslationUnit options; - options.useCxx11 = !cmdParser.isSet(optionNoCxx11); if (cmdParser.isSet(optionNamespace)) options.namespaceName = cmdParser.value(optionNamespace); QString outFileName = cmdParser.value(optionOutputBaseName); diff --git a/tools/qscxmlc/scxmlcppdumper.cpp b/tools/qscxmlc/scxmlcppdumper.cpp index aa207bb..f5e9b2e 100644 --- a/tools/qscxmlc/scxmlcppdumper.cpp +++ b/tools/qscxmlc/scxmlcppdumper.cpp @@ -143,28 +143,17 @@ static const char *headerStart = using namespace DocumentModel; -QString createContainer(const QString &baseType, const QString &elementType, - const QStringList &elements, bool useCxx11) +QString createContainer(const QStringList &elements) { QString result; - if (useCxx11) { - if (elements.isEmpty()) { - result += QStringLiteral("{}"); - } else { - result += QStringLiteral("{ ") + elements.join(QStringLiteral(", ")) + QStringLiteral(" }"); - } + if (elements.isEmpty()) { + result += QStringLiteral("{}"); } else { - result += QStringLiteral("%1< %2 >()").arg(baseType, elementType); - if (!elements.isEmpty()) { - result += QStringLiteral(" << ") + elements.join(QStringLiteral(" << ")); - } + result += QStringLiteral("{ ") + elements.join(QStringLiteral(", ")) + QStringLiteral(" }"); } return result; } -QString createVector(const QString &elementType, const QStringList &elements, bool useCxx11) -{ return createContainer(QStringLiteral("QVector"), elementType, elements, useCxx11); } - static void generateList(QString &out, std::function<QString(int)> next) { const int maxLineLength = 80; @@ -380,8 +369,7 @@ int createFactoryId(QStringList &factories, const QString &className, const QString &namespacePrefix, const QScxmlExecutableContent::InvokeInfo &invokeInfo, const QVector<QScxmlExecutableContent::StringId> &namelist, - const QVector<QScxmlExecutableContent::ParameterInfo> ¶meters, - bool useCxx11) + const QVector<QScxmlExecutableContent::ParameterInfo> ¶meters) { const int idx = factories.size(); @@ -405,8 +393,7 @@ int createFactoryId(QStringList &factories, const QString &className, for (auto name : namelist) { l.append(QString::number(name)); } - line += QStringLiteral("%1, ").arg( - createVector(QStringLiteral("QScxmlExecutableContent::StringId"), l, useCxx11)); + line += QStringLiteral("%1, ").arg(createContainer(l)); } { QStringList l; @@ -416,9 +403,7 @@ int createFactoryId(QStringList &factories, const QString &className, QString::number(parameter.expr), QString::number(parameter.location)); } - line += QStringLiteral("%1);").arg( - createVector(QStringLiteral("QScxmlExecutableContent::ParameterInfo"), l, - useCxx11)); + line += QStringLiteral("%1);").arg(createContainer(l)); } factories.append(line); @@ -464,7 +449,7 @@ void CppDumper::dump(TranslationUnit *unit) className = mangleIdentifier(classnameForDocument.value(content.data())); } return createFactoryId(factories[i], className, namespacePrefix, - invokeInfo, names, parameters, m_translationUnit->useCxx11); + invokeInfo, names, parameters); }); classNames.append(mangleIdentifier(classnameForDocument.value(doc))); } diff --git a/tools/qscxmlc/scxmlcppdumper.h b/tools/qscxmlc/scxmlcppdumper.h index 2d6b12c..95fa48a 100644 --- a/tools/qscxmlc/scxmlcppdumper.h +++ b/tools/qscxmlc/scxmlcppdumper.h @@ -41,14 +41,12 @@ QT_BEGIN_NAMESPACE struct TranslationUnit { TranslationUnit() - : useCxx11(true) - , mainDocument(Q_NULLPTR) + : mainDocument(Q_NULLPTR) {} QString scxmlFileName; QString outHFileName, outCppFileName; QString namespaceName; - bool useCxx11; DocumentModel::ScxmlDocument *mainDocument; QList<DocumentModel::ScxmlDocument *> allDocuments; QHash<DocumentModel::ScxmlDocument *, QString> classnameForDocument; |