summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@theqtcompany.com>2016-07-26 14:43:36 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2016-07-28 08:02:14 +0000
commit1b002a4aa4ef2eaf863e6d036ca92da2305a8bfd (patch)
tree4780450ffc515d1c676cd96be71620fe426a8f3d
parent07eeac08a42f481fb3e599e212d032e1983f4f63 (diff)
Generate unique class names for sub machines
Change-Id: I3a83e12a611a6c4c2ab86a45b44e168b62bb7da3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--tests/auto/compiled/submachineA.scxml2
-rw-r--r--tests/auto/compiled/submachineB.scxml2
-rw-r--r--tools/qscxmlc/qscxmlc.cpp9
3 files changed, 10 insertions, 3 deletions
diff --git a/tests/auto/compiled/submachineA.scxml b/tests/auto/compiled/submachineA.scxml
index b72a048..0924b2e 100644
--- a/tests/auto/compiled/submachineA.scxml
+++ b/tests/auto/compiled/submachineA.scxml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0">
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="SubMachine">
<final id="topState"/>
</scxml>
diff --git a/tests/auto/compiled/submachineB.scxml b/tests/auto/compiled/submachineB.scxml
index b72a048..0924b2e 100644
--- a/tests/auto/compiled/submachineB.scxml
+++ b/tests/auto/compiled/submachineB.scxml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0">
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="SubMachine">
<final id="topState"/>
</scxml>
diff --git a/tools/qscxmlc/qscxmlc.cpp b/tools/qscxmlc/qscxmlc.cpp
index d5217d8..d362b25 100644
--- a/tools/qscxmlc/qscxmlc.cpp
+++ b/tools/qscxmlc/qscxmlc.cpp
@@ -236,9 +236,16 @@ int run(const QStringList &arguments)
tu.outCppFileName = outCppFileName;
for (QMap<DocumentModel::ScxmlDocument *, QString>::const_iterator i = docs.begin(), ei = docs.end(); i != ei; ++i) {
auto name = i.value();
+ auto prefix = name;
if (name.isEmpty()) {
- name = QStringLiteral("%1_StateMachine_%2").arg(mainClassName).arg(tu.classnameForDocument.size() + 1);
+ prefix = QStringLiteral("%1_StateMachine").arg(mainClassName);
+ name = prefix;
}
+
+ int counter = 1;
+ while (tu.classnameForDocument.key(name) != nullptr)
+ name = QStringLiteral("%1_%2").arg(prefix).arg(++counter);
+
tu.classnameForDocument.insert(i.key(), name);
}