summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/scxml/invoke-common/MainView.qml4
-rw-r--r--examples/scxml/invoke-common/SubView.qml4
-rw-r--r--examples/scxml/invoke-common/statemachine.scxml1
-rw-r--r--examples/scxml/invoke-dynamic/doc/src/invoke-dynamic.qdoc2
-rw-r--r--examples/scxml/invoke-static/doc/src/invoke-static.qdoc2
-rw-r--r--examples/scxml/mediaplayer-common/Mediaplayer.qml31
-rw-r--r--examples/scxml/mediaplayer-common/doc/src/mediaplayer-dynamic.qdocinc15
-rw-r--r--examples/scxml/mediaplayer-common/doc/src/mediaplayer-ecmascript-data-model.qdocinc2
-rw-r--r--examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc16
-rw-r--r--examples/scxml/mediaplayer-common/mainwindow.cpp19
-rw-r--r--examples/scxml/mediaplayer-common/mainwindow.h13
-rw-r--r--examples/scxml/mediaplayer-common/mediaplayer.scxml5
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc2
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml5
-rw-r--r--examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc16
-rw-r--r--examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc19
-rw-r--r--examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp9
-rw-r--r--examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc6
-rw-r--r--examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp9
-rw-r--r--examples/scxml/pinball/pinball.scxml1
-rw-r--r--examples/scxml/trafficlight-common/TrafficLight.qml4
-rw-r--r--examples/scxml/trafficlight-common/statemachine.scxml1
-rw-r--r--src/scxml/doc/qtscxml-instantiating-state-machines.qdoc23
-rw-r--r--src/scxml/doc/qtscxml-overview.qdoc20
-rw-r--r--src/scxml/doc/qtscxml-scxml-compliance.qdoc13
-rw-r--r--src/scxml/qscxmlcppdatamodel.cpp2
-rw-r--r--src/scxml/qscxmlevent.cpp1
-rw-r--r--src/scxml/qscxmlparser.cpp453
-rw-r--r--src/scxml/qscxmlparser.h9
-rw-r--r--src/scxml/qscxmlparser_p.h10
-rw-r--r--src/scxml/qscxmlstatemachine.cpp27
-rw-r--r--src/scxml/qscxmltabledata.cpp23
-rw-r--r--src/scxml/qscxmltabledata.h1
-rw-r--r--src/scxml/qscxmltabledata_p.h3
-rw-r--r--tests/auto/compiled/anonymousstate.scxml1
-rw-r--r--tests/auto/compiled/eventnames2.scxml1
-rw-r--r--tests/auto/compiled/submachineunicodename.scxml1
-rw-r--r--tests/auto/dynamicmetaobject/mediaplayer.scxml5
-rw-r--r--tests/auto/dynamicmetaobject/tst_dynamicmetaobject.cpp46
-rw-r--r--tests/auto/parser/data/ids2.scxml1
-rw-r--r--tests/auto/parser/data/ids2.scxml.errors4
-rw-r--r--tests/auto/parser/data/invalidRoot3.scxml1
-rw-r--r--tests/auto/parser/data/invalidRoot3.scxml.errors5
-rw-r--r--tests/auto/parser/data/qtmode.scxml46
-rw-r--r--tests/auto/parser/data/qtmode.scxml.errors9
-rw-r--r--tests/auto/parser/tst_parser.qrc2
-rw-r--r--tools/qscxmlc/data.t19
-rw-r--r--tools/qscxmlc/decl.t5
-rw-r--r--tools/qscxmlc/qscxmlc.cpp24
-rw-r--r--tools/qscxmlc/scxmlcppdumper.cpp167
-rw-r--r--tools/qscxmlc/scxmlcppdumper.h13
51 files changed, 132 insertions, 989 deletions
diff --git a/examples/scxml/invoke-common/MainView.qml b/examples/scxml/invoke-common/MainView.qml
index 4a75487..d7b8ec8 100644
--- a/examples/scxml/invoke-common/MainView.qml
+++ b/examples/scxml/invoke-common/MainView.qml
@@ -70,7 +70,7 @@ Window {
text: "Go Nowhere"
width: parent.width
height: parent.height / 2
- onClicked: stateMachine.goNowhere()
+ onClicked: stateMachine.submitEvent("goNowhere")
enabled: stateMachine.somewhere
}
@@ -80,7 +80,7 @@ Window {
width: parent.width
height: parent.height / 2
y: parent.height / 2
- onClicked: stateMachine.goSomewhere()
+ onClicked: stateMachine.submitEvent("goSomewhere")
enabled: stateMachine.nowhere
}
}
diff --git a/examples/scxml/invoke-common/SubView.qml b/examples/scxml/invoke-common/SubView.qml
index 61cc723..2c374d5 100644
--- a/examples/scxml/invoke-common/SubView.qml
+++ b/examples/scxml/invoke-common/SubView.qml
@@ -58,7 +58,7 @@ Item {
text: "Go There"
width: parent.width / 2
height: parent.height
- onClicked: anywhere.goThere()
+ onClicked: anywhere.submitEvent("goThere")
}
Button {
@@ -68,6 +68,6 @@ Item {
width: parent.width / 2
height: parent.height
x: width
- onClicked: anywhere.goHere()
+ onClicked: anywhere.submitEvent("goHere")
}
}
diff --git a/examples/scxml/invoke-common/statemachine.scxml b/examples/scxml/invoke-common/statemachine.scxml
index b9defeb..ad04cb3 100644
--- a/examples/scxml/invoke-common/statemachine.scxml
+++ b/examples/scxml/invoke-common/statemachine.scxml
@@ -50,7 +50,6 @@
**
****************************************************************************/
-->
-<!-- enable-qt-mode: yes -->
<scxml
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
diff --git a/examples/scxml/invoke-dynamic/doc/src/invoke-dynamic.qdoc b/examples/scxml/invoke-dynamic/doc/src/invoke-dynamic.qdoc
index 8c0f570..bff773a 100644
--- a/examples/scxml/invoke-dynamic/doc/src/invoke-dynamic.qdoc
+++ b/examples/scxml/invoke-dynamic/doc/src/invoke-dynamic.qdoc
@@ -47,7 +47,7 @@
\e Directions of type \e http://www.w3.org/TR/scxml/ to invoke:
\quotefromfile invoke-common/statemachine.scxml
- \skipto enable-qt-mode
+ \skipto scxml
\printuntil
\section1 Dynamically Loading the State Machine
diff --git a/examples/scxml/invoke-static/doc/src/invoke-static.qdoc b/examples/scxml/invoke-static/doc/src/invoke-static.qdoc
index d58f49c..099b904 100644
--- a/examples/scxml/invoke-static/doc/src/invoke-static.qdoc
+++ b/examples/scxml/invoke-static/doc/src/invoke-static.qdoc
@@ -47,7 +47,7 @@
\e Directions of type \e http://www.w3.org/TR/scxml/ to invoke:
\quotefromfile invoke-common/statemachine.scxml
- \skipto enable-qt-mode
+ \skipto scxml
\printuntil
\section1 Compiling the State Machine
diff --git a/examples/scxml/mediaplayer-common/Mediaplayer.qml b/examples/scxml/mediaplayer-common/Mediaplayer.qml
index 4d793fa..1804b55 100644
--- a/examples/scxml/mediaplayer-common/Mediaplayer.qml
+++ b/examples/scxml/mediaplayer-common/Mediaplayer.qml
@@ -50,7 +50,7 @@
import QtQuick 2.5
import QtQuick.Window 2.2
-import QtScxml 5.7 as Scxml
+import QtScxml 5.7
Window {
id: root
@@ -111,27 +111,30 @@ Window {
color: stateMachine.playing ? "green" : "red"
}
- Scxml.StateMachineLoader {
+ StateMachineLoader {
id: scxmlLoader
}
- Connections {
- target: stateMachine
- onPlaybackStarted: {
- var media = data.media
- theText.text = "Playing '" + media + "'"
- theLog.text = theLog.text + "\nplaybackStarted with data: " + JSON.stringify(data)
- }
- onPlaybackStopped: {
- var media = data.media
- theText.text = "Stopped '" + media + "'"
- theLog.text = theLog.text + "\nplaybackStopped with data: " + JSON.stringify(data)
+ EventConnection {
+ stateMachine: root.stateMachine
+ events: ["playbackStarted", "playbackStopped"]
+ onOccurred: {
+ var media = event.data.media
+ if (event.name === "playbackStarted") {
+ theText.text = "Playing '" + media + "'"
+ theLog.text = theLog.text + "\nplaybackStarted with data: "
+ + JSON.stringify(event.data)
+ } else if (event.name === "playbackStopped") {
+ theText.text = "Stopped '" + media + "'"
+ theLog.text = theLog.text + "\nplaybackStopped with data: "
+ + JSON.stringify(event.data)
+ }
}
}
function tap(idx) {
var media = theModel.get(idx).media
var data = { "media": media }
- stateMachine.tap(data)
+ stateMachine.submitEvent("tap", data)
}
}
diff --git a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-dynamic.qdocinc b/examples/scxml/mediaplayer-common/doc/src/mediaplayer-dynamic.qdocinc
deleted file mode 100644
index 94062ad..0000000
--- a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-dynamic.qdocinc
+++ /dev/null
@@ -1,15 +0,0 @@
- \section1 Dynamically Loading the State Machine
-
- We link against the Qt SCXML module by adding the following line to the
- example \e .pro file:
-
- \quotefromfile mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.pro
- \skipto QT
- \printline scxml
-
- We dynamically create the state machine in
- \e mediaplayer-common\Mediaplayer.qml:
-
- \quotefromfile mediaplayer-common/Mediaplayer.qml
- \skipto import QtScxml
- \printuntil scxmlLoader.filename
diff --git a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-ecmascript-data-model.qdocinc b/examples/scxml/mediaplayer-common/doc/src/mediaplayer-ecmascript-data-model.qdocinc
index 31218ef..98b33c7 100644
--- a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-ecmascript-data-model.qdocinc
+++ b/examples/scxml/mediaplayer-common/doc/src/mediaplayer-ecmascript-data-model.qdocinc
@@ -4,6 +4,6 @@
\c <scxml> element in \e mediaplayer-common/mediaplayer.scxml:
\quotefromfile mediaplayer-common/mediaplayer.scxml
- \skipto enable-qt-mode
+ \skipto scxml
\printuntil </datamodel>
diff --git a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc b/examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc
new file mode 100644
index 0000000..08a152b
--- /dev/null
+++ b/examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc
@@ -0,0 +1,16 @@
+ \section1 Connecting to States
+
+ The media player state machine will send out events when users tap a control
+ and when playback starts or stops, as specified in the SCXML file:
+
+ \quotefromfile mediaplayer-common/mediaplayer.scxml
+ \skipto <state
+ \printuntil !==
+ \printuntil </state
+
+ To be notified when a state machine sends out an event, we connect to the
+ corresponding signals:
+
+ \quotefromfile mediaplayer-common/mainwindow.cpp
+ \skipto connect(ui
+ \printuntil playbackStopped
diff --git a/examples/scxml/mediaplayer-common/mainwindow.cpp b/examples/scxml/mediaplayer-common/mainwindow.cpp
index e9a5767..b4d3760 100644
--- a/examples/scxml/mediaplayer-common/mainwindow.cpp
+++ b/examples/scxml/mediaplayer-common/mainwindow.cpp
@@ -52,10 +52,11 @@
#include "ui_mainwindow.h"
#include <QStringListModel>
+#include <QScxmlStateMachine>
QT_USE_NAMESPACE
-MainWindow::MainWindow(QWidget *parent) :
+MainWindow::MainWindow(QScxmlStateMachine *stateMachine, QWidget *parent) :
QWidget(parent),
ui(new Ui::MainWindow)
{
@@ -66,11 +67,15 @@ MainWindow::MainWindow(QWidget *parent) :
<< QStringLiteral("song 3"), this);
ui->mediaListView->setModel(model);
- connect(ui->mediaListView, &QAbstractItemView::clicked, [model,this](const QModelIndex & index){
+ connect(ui->mediaListView, &QAbstractItemView::clicked,
+ [model, stateMachine](const QModelIndex & index) {
QVariantMap data;
data.insert(QStringLiteral("media"), model->data(index, Qt::EditRole).toString());
- emit tap(data);
+ stateMachine->submitEvent("tap", data);
});
+
+ stateMachine->connectToEvent("playbackStarted", this, &MainWindow::started);
+ stateMachine->connectToEvent("playbackStopped", this, &MainWindow::stopped);
}
MainWindow::~MainWindow()
@@ -78,16 +83,16 @@ MainWindow::~MainWindow()
delete ui;
}
-void MainWindow::started(const QVariant &data)
+void MainWindow::started(const QScxmlEvent &event)
{
- QString media = data.toMap().value("media").toString();
+ const QString media = event.data().toMap().value("media").toString();
ui->logText->appendPlainText(QStringLiteral("call on slot started with media '%1'").arg(media));
ui->statusLabel->setText(QStringLiteral("Playing %1").arg(media));
}
-void MainWindow::stopped(const QVariant &data)
+void MainWindow::stopped(const QScxmlEvent &event)
{
- QString media = data.toMap().value("media").toString();
+ const QString media = event.data().toMap().value("media").toString();
ui->logText->appendPlainText(QStringLiteral("call on slot stopped with media '%1'").arg(media));
ui->statusLabel->setText(QStringLiteral("Stopped"));
}
diff --git a/examples/scxml/mediaplayer-common/mainwindow.h b/examples/scxml/mediaplayer-common/mainwindow.h
index e9ed5fe..38bb39f 100644
--- a/examples/scxml/mediaplayer-common/mainwindow.h
+++ b/examples/scxml/mediaplayer-common/mainwindow.h
@@ -57,6 +57,10 @@ QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
+
+class QScxmlEvent;
+class QScxmlStateMachine;
+
QT_END_NAMESPACE
class MainWindow : public QWidget
@@ -64,15 +68,12 @@ class MainWindow : public QWidget
Q_OBJECT
public:
- explicit MainWindow(QWidget *parent = 0);
+ explicit MainWindow(QScxmlStateMachine *stateMachine, QWidget *parent = 0);
~MainWindow();
-signals:
- void tap(const QVariant &data);
-
public slots:
- void started(const QVariant &data);
- void stopped(const QVariant &data);
+ void started(const QScxmlEvent &event);
+ void stopped(const QScxmlEvent &event);
private:
QT_PREPEND_NAMESPACE(Ui::MainWindow) *ui;
diff --git a/examples/scxml/mediaplayer-common/mediaplayer.scxml b/examples/scxml/mediaplayer-common/mediaplayer.scxml
index 025245a..ca68039 100644
--- a/examples/scxml/mediaplayer-common/mediaplayer.scxml
+++ b/examples/scxml/mediaplayer-common/mediaplayer.scxml
@@ -50,7 +50,6 @@
**
****************************************************************************/
-->
-<!-- enable-qt-mode: yes -->
<scxml
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
@@ -76,13 +75,13 @@
<state id="playing">
<onentry>
<assign location="media" expr="_event.data.media"/>
- <send type="qt:signal" event="playbackStarted">
+ <send event="playbackStarted">
<param name="media" expr="media"/>
</send>
</onentry>
<onexit>
- <send type="qt:signal" event="playbackStopped">
+ <send event="playbackStopped">
<param name="media" expr="media"/>
</send>
</onexit>
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc b/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc
index 633922a..421e72e 100644
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc
+++ b/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc
@@ -50,7 +50,7 @@
\c <scxml> element in the SCXML file:
\quotefromfile mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml
- \skipto enable-qt-mode
+ \skipto scxml
\printuntil datamodel
The format of the \e datamodel attribute is:
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml b/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml
index 3683c19..4ca810e 100644
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml
+++ b/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml
@@ -50,7 +50,6 @@
**
****************************************************************************/
-->
-<!-- enable-qt-mode: yes -->
<scxml
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
@@ -67,13 +66,13 @@
<script>
media = eventData().value(QStringLiteral(&quot;media&quot;)).toString();
</script>
- <send type="qt:signal" event="playbackStarted">
+ <send event="playbackStarted">
<param name="media" expr="media"/>
</send>
</onentry>
<onexit>
- <send type="qt:signal" event="playbackStopped">
+ <send event="playbackStopped">
<param name="media" expr="media"/>
</send>
</onexit>
diff --git a/examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc b/examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc
index 525974a..4f0cb78 100644
--- a/examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc
+++ b/examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc
@@ -44,5 +44,19 @@
\include mediaplayer-ecmascript-data-model.qdocinc
- \include mediaplayer-dynamic.qdocinc
+ \section1 Dynamically Loading the State Machine
+
+ We link against the Qt SCXML module by adding the following line to the
+ example \e .pro file:
+
+ \quotefromfile mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.pro
+ \skipto QT
+ \printline scxml
+
+ We dynamically create the state machine in
+ \e mediaplayer-common\Mediaplayer.qml:
+
+ \quotefromfile mediaplayer-common/Mediaplayer.qml
+ \skipto import QtScxml
+ \printuntil scxmlLoader.filename
*/
diff --git a/examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc b/examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc
index 6cc41df..59ec84f 100644
--- a/examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc
+++ b/examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc
@@ -44,5 +44,22 @@
\include mediaplayer-ecmascript-data-model.qdocinc
- \include mediaplayer-dynamic.qdocinc
+ \section1 Dynamically Loading the State Machine
+
+ We link against the Qt SCXML module by adding the following line to the
+ example \e .pro file:
+
+ \quotefromfile mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.pro
+ \skipto QT
+ \printuntil scxml
+
+ \quotefromfile mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp
+
+ We dynamically create and instantiate the state machine in
+ \e mediaplayer-wigdets-dynamic/mediaplayer-widgets-dynamic.cpp:
+
+ \skipto mainwindow.h
+ \printuntil /^\}/
+
+ \include mediaplayer-widgets-connecting-to-states.qdocinc
*/
diff --git a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp b/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp
index eba0fba..457e4ee 100644
--- a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp
+++ b/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp
@@ -58,16 +58,9 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
auto machine = QScxmlStateMachine::fromFile(QStringLiteral(":mediaplayer.scxml"));
- MainWindow mainWindow;
+ MainWindow mainWindow(machine);
machine->setParent(&mainWindow);
- QObject::connect(&mainWindow, SIGNAL(tap(const QVariant &)),
- machine, SLOT(tap(const QVariant &)));
- QObject::connect(machine, SIGNAL(playbackStarted(const QVariant &)),
- &mainWindow, SLOT(started(const QVariant &)));
- QObject::connect(machine, SIGNAL(playbackStopped(const QVariant &)),
- &mainWindow, SLOT(stopped(const QVariant &)));
-
machine->start();
mainWindow.show();
return app.exec();
diff --git a/examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc b/examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc
index 9d1ae39..dfa1230 100644
--- a/examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc
+++ b/examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc
@@ -55,9 +55,5 @@
\skipto mediaplayer.h
\printuntil MainWindow mainWindow
- To be notified when a state machine sends out an event, we connect to the
- corresponding signals. The media player state machine will send out events
- when users tap a control and when playback starts or stops:
-
- \printuntil MainWindow::stopped
+ \include mediaplayer-widgets-connecting-to-states.qdocinc
*/
diff --git a/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp b/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp
index 1668eac..6a049d9 100644
--- a/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp
+++ b/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp
@@ -58,14 +58,7 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
MediaPlayerStateMachine machine;
- MainWindow mainWindow;
-
- QObject::connect(&mainWindow, &MainWindow::tap,
- &machine, &MediaPlayerStateMachine::tap);
- QObject::connect(&machine, &MediaPlayerStateMachine::playbackStarted,
- &mainWindow, &MainWindow::started);
- QObject::connect(&machine, &MediaPlayerStateMachine::playbackStopped,
- &mainWindow, &MainWindow::stopped);
+ MainWindow mainWindow(&machine);
machine.start();
mainWindow.show();
diff --git a/examples/scxml/pinball/pinball.scxml b/examples/scxml/pinball/pinball.scxml
index 21e3591..022f202 100644
--- a/examples/scxml/pinball/pinball.scxml
+++ b/examples/scxml/pinball/pinball.scxml
@@ -50,7 +50,6 @@
**
****************************************************************************/
-->
-<!-- enable-qt-mode: no -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
name="Pinball" datamodel="ecmascript">
<datamodel>
diff --git a/examples/scxml/trafficlight-common/TrafficLight.qml b/examples/scxml/trafficlight-common/TrafficLight.qml
index 03eac30..87a36ac 100644
--- a/examples/scxml/trafficlight-common/TrafficLight.qml
+++ b/examples/scxml/trafficlight-common/TrafficLight.qml
@@ -106,9 +106,9 @@ Window {
onClicked: {
if (stateMachine.working)
- stateMachine.smash()
+ stateMachine.submitEvent("smash")
else
- stateMachine.repair()
+ stateMachine.submitEvent("repair")
}
}
}
diff --git a/examples/scxml/trafficlight-common/statemachine.scxml b/examples/scxml/trafficlight-common/statemachine.scxml
index 4224e81..3cf023e 100644
--- a/examples/scxml/trafficlight-common/statemachine.scxml
+++ b/examples/scxml/trafficlight-common/statemachine.scxml
@@ -50,7 +50,6 @@
**
****************************************************************************/
-->
-<!-- enable-qt-mode: yes -->
<scxml
xmlns="http://www.w3.org/2005/07/scxml"
xmlns:qt="http://theqtcompany.com/scxml/2015/06/"
diff --git a/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc b/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc
index d361233..239de76 100644
--- a/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc
+++ b/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc
@@ -143,14 +143,10 @@
}
\endqml
- In \e {Qt mode}, events can also be directly mapped to Qt signals by adding
- \e {type="qt:signal"} to the \e {<send>} element in SCXML.
-
- Sending events to a state machine is equally simple. In Qt mode, you can
- call (or connect to) the slot:
+ Sending events to a state machine is equally simple:
\code
- stateMachine->tap(QVariantMap({
+ stateMachine->submitEvent("tap", QVariantMap({
std::make_pair("artist", "Fatboy Slim"),
std::make_pair("title", "The Rockafeller Skank")
});
@@ -160,22 +156,9 @@
_event.data inside the state machine. In QML:
\code
- stateMacine.tap({
+ stateMachine.submitEvent("tap", {
"artist": "Fatboy Slim"
"title": "The Rockafeller Skank"
})
\endcode
-
- You can also use \c submitEvent() to send events with arbitrary
- identifiers. This is also available when not using Qt mode:
-
- \code
- stateMachine->submitEvent("tap", QVariantMap({
- std::make_pair("artist", "Fatboy Slim"),
- std::make_pair("title", "The Rockafeller Skank")
- });
- \endcode
-
- Any invoked state machine with a name property will also show up as a
- property on its parent state machine.
*/
diff --git a/src/scxml/doc/qtscxml-overview.qdoc b/src/scxml/doc/qtscxml-overview.qdoc
index 8b38e39..dfecb0a 100644
--- a/src/scxml/doc/qtscxml-overview.qdoc
+++ b/src/scxml/doc/qtscxml-overview.qdoc
@@ -90,26 +90,6 @@
differ in the way they are instantiated. For more information, see
\l{Instantiating State Machines} and \l{Qt SCXML Examples}.
- \section1 Qt Mode
-
- State machines that are compatible with Qt can be compiled or loaded in the
- \e {Qt mode} to fully benefit from Qt. The Qt mode is unconditionally
- enabled by adding the following line to the beginning of the SCXML file:
- \c {<!-- enable-qt-mode: yes -->}. It is unconditionally disabled by the
- value \c no.
-
- The Qt mode should be disabled for random SCXML files that do not comply to
- the Qt rules. For example, for an SCXML file to be compatible with the Qt
- mode, all IDs and names must be valid Qt identifiers.
-
- In the Qt mode, external signals defined inside an SCXML file that are of
- the \c qt:signal type, are accessible as signals of QScxmlStateMachine. As
- an argument, they take QVariant. It is of QMap<QString, QVariant> type and
- contains the content of all the \c <param> elements specified as children of
- a \c <send> element. The name of each QScxmlStateMachine signal corresponds
- to the value defined in the \e event attribute of one \c <send> tag in the
- SCXML file.
-
\section1 Logging Categories
The Qt SCXML module exports the following logging categories:
diff --git a/src/scxml/doc/qtscxml-scxml-compliance.qdoc b/src/scxml/doc/qtscxml-scxml-compliance.qdoc
index e86feca..ab1d730 100644
--- a/src/scxml/doc/qtscxml-scxml-compliance.qdoc
+++ b/src/scxml/doc/qtscxml-scxml-compliance.qdoc
@@ -72,19 +72,6 @@
The Qt SCXML implementation extends SCXML in the following ways:
\list
- \li For communication purposes, the \c <send> tag supports an extra
- value \c "qt:signal" accepted by the attribute \c type.
- The generated state machine or the state machine that has loaded
- the SCXML file dynamically will contain the corresponding
- signal, the name of which will be equal to the value of the
- \e event attribute inside the \c <send> tag.
- All of the \c <param> children will be placed inside the
- QMap<QString, QVariant> map, and this map will be passed as a
- QVariant argument of the specified signal.
- \li State machines that are compatible with Qt can be compiled or loaded in
- the \e {Qt mode} to fully benefit from Qt. The Qt mode is enabled by
- adding the following line to the beginning of the SCXML file:
- \c {<!-- enable-qt-mode: yes -->}.
\li If the event is an error event, \c _event.errorMessage will contain a
more detailed description of the error.
\endlist
diff --git a/src/scxml/qscxmlcppdatamodel.cpp b/src/scxml/qscxmlcppdatamodel.cpp
index 8a615ed..bc09d65 100644
--- a/src/scxml/qscxmlcppdatamodel.cpp
+++ b/src/scxml/qscxmlcppdatamodel.cpp
@@ -92,7 +92,7 @@ class TheDataModel: public QScxmlCppDataModel
<script>
media = eventData().value(QStringLiteral(&quot;media&quot;)).toString();
</script>
- <send type="qt:signal" event="playbackStarted">
+ <send event="playbackStarted">
<param name="media" expr="media"/>
</send>
</onentry>
diff --git a/src/scxml/qscxmlevent.cpp b/src/scxml/qscxmlevent.cpp
index 77250b0..893c4a5 100644
--- a/src/scxml/qscxmlevent.cpp
+++ b/src/scxml/qscxmlevent.cpp
@@ -137,7 +137,6 @@ QScxmlEvent *QScxmlEventBuilder::buildEvent()
return Q_NULLPTR;
}
if (!origintype.isEmpty()
- && origintype != QStringLiteral("qt:signal")
&& origintype != QStringLiteral("http://www.w3.org/TR/scxml/#SCXMLEventProcessor")) {
// [6.2.5] and test199
submitError(QStringLiteral("error.execution"),
diff --git a/src/scxml/qscxmlparser.cpp b/src/scxml/qscxmlparser.cpp
index 258f96c..c87754d 100644
--- a/src/scxml/qscxmlparser.cpp
+++ b/src/scxml/qscxmlparser.cpp
@@ -151,8 +151,6 @@ private:
{
if (!state->id.isEmpty() && !isValidToken(state->id, XmlNCName)) {
error(state->xmlLocation, QStringLiteral("'%1' is not a valid XML ID").arg(state->id));
- } else {
- validateStateName(state->xmlLocation, state->id);
}
if (state->initialTransition == nullptr) {
@@ -225,10 +223,8 @@ private:
error(transition->xmlLocation, QStringLiteral("unknown state '%1' in target").arg(target));
}
}
- foreach (const QString &event, transition->events) {
+ foreach (const QString &event, transition->events)
checkEvent(event, transition->xmlLocation, AllowWildCards);
- validateEventName(transition->xmlLocation, event);
- }
m_parentNodes.append(transition);
return true;
@@ -263,11 +259,6 @@ private:
bool visit(DocumentModel::Send *node) Q_DECL_OVERRIDE
{
checkEvent(node->event, node->xmlLocation, ForbidWildCards);
-
- if (node->type == QStringLiteral("qt:signal")) {
- validateEventName(node->xmlLocation, node->event);
- }
-
checkExpr(node->xmlLocation, QStringLiteral("send"), QStringLiteral("eventexpr"), node->eventexpr);
return true;
}
@@ -475,275 +466,6 @@ private:
return Q_NULLPTR;
}
- void validateEventName(const DocumentModel::XmlLocation &location, const QString &name)
- {
- if (!m_doc->qtMode)
- return;
-
- if (!isValidCppIdentifier(name))
- error(location, QStringLiteral(
- "event name '%1' is not a valid C++ identifier in Qt mode").arg(name));
-
- if (!isValidQtIdentifier(name))
- error(location, QStringLiteral(
- "event name '%1' is not a valid Qt identifier in Qt mode").arg(name));
-
- if (m_stateById.contains(name))
- error(location, QStringLiteral(
- "event name '%1' collides with a state name '%1' in Qt mode").arg(name));
-
- const QString changedSuffix(QStringLiteral("Changed"));
- if (name.endsWith(changedSuffix)) {
- const QString baseName = name.left(name.count() - changedSuffix.count());
- if (m_stateById.contains(baseName))
- error(location, QStringLiteral(
- "event name '%1' collides with a state name '%2' in Qt mode").arg(name).arg(baseName));
- }
- }
-
- void validateStateName(const DocumentModel::XmlLocation &location, const QString &name)
- {
- if (!m_doc->qtMode)
- return;
-
- if (!isValidCppIdentifier(name))
- error(location, QStringLiteral(
- "state name '%1' is not a valid C++ identifier in Qt mode").arg(name));
-
- if (!isValidQtIdentifier(name))
- error(location, QStringLiteral(
- "state name '%1' is not a valid Qt identifier in Qt mode").arg(name));
-
- const QString changedSuffix(QStringLiteral("Changed"));
- if (name.endsWith(changedSuffix)) {
- const QString baseName = name.left(name.count() - changedSuffix.count());
- if (m_stateById.contains(baseName))
- error(location, QStringLiteral(
- "state name '%1' collides with a state name '%2' in Qt mode").arg(name).arg(baseName));
- }
- }
-
- static bool isValidCppIdentifier(const QString &str)
- {
- static const QStringList keywords = QStringList()
- << QStringLiteral("alignas")
- << QStringLiteral("alignof")
- << QStringLiteral("asm")
- << QStringLiteral("auto")
- << QStringLiteral("bool")
- << QStringLiteral("break")
- << QStringLiteral("case")
- << QStringLiteral("catch")
- << QStringLiteral("char")
- << QStringLiteral("char16_t")
- << QStringLiteral("char32_t")
- << QStringLiteral("class")
- << QStringLiteral("const")
- << QStringLiteral("constexpr")
- << QStringLiteral("const_cast")
- << QStringLiteral("continue")
- << QStringLiteral("decltype")
- << QStringLiteral("default")
- << QStringLiteral("delete")
- << QStringLiteral("double")
- << QStringLiteral("do")
- << QStringLiteral("dynamic_cast")
- << QStringLiteral("else")
- << QStringLiteral("enum")
- << QStringLiteral("explicit")
- << QStringLiteral("export")
- << QStringLiteral("extern")
- << QStringLiteral("false")
- << QStringLiteral("float")
- << QStringLiteral("for")
- << QStringLiteral("friend")
- << QStringLiteral("goto")
- << QStringLiteral("if")
- << QStringLiteral("inline")
- << QStringLiteral("int")
- << QStringLiteral("long")
- << QStringLiteral("mutable")
- << QStringLiteral("namespace")
- << QStringLiteral("new")
- << QStringLiteral("noexcept")
- << QStringLiteral("nullptr")
- << QStringLiteral("operator")
- << QStringLiteral("private")
- << QStringLiteral("protected")
- << QStringLiteral("public")
- << QStringLiteral("register")
- << QStringLiteral("reinterpret_cast")
- << QStringLiteral("return")
- << QStringLiteral("short")
- << QStringLiteral("signed")
- << QStringLiteral("sizeof")
- << QStringLiteral("static")
- << QStringLiteral("static_assert")
- << QStringLiteral("static_cast")
- << QStringLiteral("struct")
- << QStringLiteral("switch")
- << QStringLiteral("template")
- << QStringLiteral("this")
- << QStringLiteral("thread_local")
- << QStringLiteral("throw")
- << QStringLiteral("true")
- << QStringLiteral("try")
- << QStringLiteral("typedef")
- << QStringLiteral("typeid")
- << QStringLiteral("typename")
- << QStringLiteral("union")
- << QStringLiteral("unsigned")
- << QStringLiteral("using")
- << QStringLiteral("virtual")
- << QStringLiteral("void")
- << QStringLiteral("volatile")
- << QStringLiteral("wchar_t")
- << QStringLiteral("while");
-
- if (keywords.contains(str)) {
- return false;
- }
-
- auto isNonDigit = [](QChar ch) -> bool {
- return (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z'))
- || (ch >= QLatin1Char('a') && ch <= QLatin1Char('z'))
- || (ch == QLatin1Char('_'));
- };
-
- QChar ch = str.at(0);
- if (!isNonDigit(ch)) {
- return false;
- }
- for (int i = 1, ei = str.size(); i != ei; ++i) {
- ch = str.at(i);
- if (!isNonDigit(ch) && !ch.isDigit()) {
- return false;
- }
- }
-
- if (str.startsWith(QLatin1Char('_')) && str.size() > 1) {
- QChar ch = str.at(1);
- if (ch == QLatin1Char('_')
- || (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z'))) {
- return false;
- }
- }
-
- return true;
- }
-
- static bool isValidQtIdentifier(const QString &str)
- {
- static const QStringList keywords = QStringList()
-
- // QObject
- << QStringLiteral("blockSignals")
- << QStringLiteral("children")
- << QStringLiteral("childEvent")
- << QStringLiteral("connect")
- << QStringLiteral("connectImpl")
- << QStringLiteral("connectNotify")
- << QStringLiteral("customEvent")
- << QStringLiteral("deleteLater")
- << QStringLiteral("destroyed")
- << QStringLiteral("disconnect")
- << QStringLiteral("disconnectImpl")
- << QStringLiteral("disconnectNotify")
- << QStringLiteral("dumpObjectInfo")
- << QStringLiteral("dumpObjectTree")
- << QStringLiteral("dynamicPropertyNames")
- << QStringLiteral("d_func")
- << QStringLiteral("d_ptr")
- << QStringLiteral("event")
- << QStringLiteral("eventFilter")
- << QStringLiteral("findChild")
- << QStringLiteral("findChildren")
- << QStringLiteral("inherits")
- << QStringLiteral("installEventFilter")
- << QStringLiteral("isSignalConnected")
- << QStringLiteral("isWidgetType")
- << QStringLiteral("isWindowType")
- << QStringLiteral("killTimer")
- << QStringLiteral("metaObject")
- << QStringLiteral("moveToThread")
- << QStringLiteral("objectName")
- << QStringLiteral("objectNameChanged")
- << QStringLiteral("parent")
- << QStringLiteral("property")
- << QStringLiteral("qt_check_for_QOBJECT_macro")
- << QStringLiteral("qt_metacall")
- << QStringLiteral("qt_metacast")
- << QStringLiteral("qt_static_metacall")
- << QStringLiteral("receivers")
- << QStringLiteral("registerUserData")
- << QStringLiteral("removeEventFilter")
- << QStringLiteral("sender")
- << QStringLiteral("senderSignalIndex")
- << QStringLiteral("setObjectName")
- << QStringLiteral("setParent")
- << QStringLiteral("setProperty")
- << QStringLiteral("setUserData")
- << QStringLiteral("signalsBlocked")
- << QStringLiteral("startTimer")
- << QStringLiteral("staticMetaObject")
- << QStringLiteral("staticQtMetaObject")
- << QStringLiteral("thread")
- << QStringLiteral("timerEvent")
- << QStringLiteral("tr")
- << QStringLiteral("trUtf8")
- << QStringLiteral("userData")
- << QStringLiteral("QObject")
-
- // QScxmlStateMachine
- << QStringLiteral("activeStateNames")
- << QStringLiteral("cancelDelayedEvent")
- << QStringLiteral("connectToEvent")
- << QStringLiteral("connectToEventImpl")
- << QStringLiteral("connectToState")
- << QStringLiteral("connectToStateImpl")
- << QStringLiteral("dataModel")
- << QStringLiteral("dataModelChanged")
- << QStringLiteral("finished")
- << QStringLiteral("fromData")
- << QStringLiteral("fromFile")
- << QStringLiteral("init")
- << QStringLiteral("initializedChanged")
- << QStringLiteral("initialValues")
- << QStringLiteral("initialValuesChanged")
- << QStringLiteral("isActive")
- << QStringLiteral("isDispatchableTarget")
- << QStringLiteral("isInitialized")
- << QStringLiteral("isInvoked")
- << QStringLiteral("isRunning")
- << QStringLiteral("loader")
- << QStringLiteral("log")
- << QStringLiteral("name")
- << QStringLiteral("parseErrors")
- << QStringLiteral("reachedStableState")
- << QStringLiteral("runningChanged")
- << QStringLiteral("runningSubStateMachine")
- << QStringLiteral("runningSubStateMachines")
- << QStringLiteral("runningSubStateMachinesChanged")
- << QStringLiteral("sessionId")
- << QStringLiteral("setDataModel")
- << QStringLiteral("setInitialValues")
- << QStringLiteral("setLoader")
- << QStringLiteral("setRunning")
- << QStringLiteral("setTableData")
- << QStringLiteral("start")
- << QStringLiteral("stateNames")
- << QStringLiteral("stop")
- << QStringLiteral("submitEvent")
- << QStringLiteral("tableData")
- << QStringLiteral("QScxmlStateMachine")
- ;
-
- if (keywords.contains(str))
- return false;
-
- return true;
- }
-
private:
std::function<void (const DocumentModel::XmlLocation &, const QString &)> m_errorHandler;
DocumentModel::ScxmlDocument *m_doc;
@@ -818,29 +540,7 @@ private:
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *_o, QMetaObject::Call _c,
int _id, void **_a)
{
- if (_c == QMetaObject::InvokeMetaMethod) {
- DynamicStateMachine *_t = static_cast<DynamicStateMachine *>(_o);
- if (_id < 0) {
- // out of bounds
- return;
- }
- if (_id < _t->m_firstSlot) {
- // these signals are only emitted, not activated by another signal
- return;
- }
- // We have 1 kind of slots: those to submit events.
- if (_id < _t->m_firstSlotWithoutData) {
- const QString &event = _t->m_incomingEvents.at(_id - _t->m_firstSlot);
- QVariant data = *reinterpret_cast< QVariant(*)>(_a[1]);
- if (data.canConvert<QJSValue>()) {
- data = data.value<QJSValue>().toVariant();
- }
- _t->submitEvent(event, data);
- } else {
- const QString &event = _t->m_incomingEvents.at(_id - _t->m_firstSlotWithoutData);
- _t->submitEvent(event, QVariant());
- }
- } else if (_c == QMetaObject::RegisterPropertyMetaType) {
+ if (_c == QMetaObject::RegisterPropertyMetaType) {
*reinterpret_cast<int*>(_a[0]) = qRegisterMetaType<bool>();
} else if (_c == QMetaObject::ReadProperty) {
DynamicStateMachine *_t = static_cast<DynamicStateMachine *>(_o);
@@ -857,8 +557,6 @@ private:
DynamicStateMachine()
: QScxmlStateMachine(*new DynamicStateMachinePrivate)
, m_propertyCount(0)
- , m_firstSlot(0)
- , m_firstSlotWithoutData(0)
{
// Temporarily wire up the QMetaObject
Q_D(DynamicStateMachine);
@@ -877,10 +575,6 @@ private:
free(const_cast<QMetaObject *>(d->m_metaObject));
d->m_metaObject = &QScxmlStateMachine::staticMetaObject;
- m_incomingEvents = info.incomingEvents;
- m_outgoingEvents = info.outgoingEvents;
- std::sort(m_outgoingEvents.begin(), m_outgoingEvents.end());
-
// Build the real one.
QMetaObjectBuilder b;
b.setClassName("DynamicStateMachine");
@@ -895,26 +589,6 @@ private:
signalBuilder.setParameterNames(init("active"));
}
- foreach (const QString &eventName, info.outgoingEvents) {
- const QByteArray signalName = eventName.toUtf8() + "(const QVariant &)";
- QMetaMethodBuilder signalBuilder = b.addSignal(signalName);
- signalBuilder.setParameterNames(init("data"));
- }
-
- // slots
- m_firstSlot = info.stateNames.size() + info.outgoingEvents.size();
- foreach (const QString &eventName, info.incomingEvents) {
- const QByteArray slotName = eventName.toUtf8() + "(const QVariant &)";
- QMetaMethodBuilder slotBuilder = b.addSlot(slotName);
- slotBuilder.setParameterNames(init("data"));
- }
-
- m_firstSlotWithoutData = m_firstSlot + info.incomingEvents.size();
- foreach (const QString &eventName, info.incomingEvents) {
- const QByteArray slotName = eventName.toUtf8() + "()";
- b.addSlot(slotName);
- }
-
// properties
int notifier = 0;
foreach (const QString &stateName, info.stateNames) {
@@ -941,16 +615,6 @@ public:
QScxmlInvokableServiceFactory *serviceFactory(int id) const Q_DECL_OVERRIDE Q_DECL_FINAL
{ return m_allFactoriesById.at(id); }
- int signalIndexForEvent(const QString &event) const Q_DECL_OVERRIDE Q_DECL_FINAL
- {
- auto it = std::lower_bound(m_outgoingEvents.begin(), m_outgoingEvents.end(), event);
- if (it != m_outgoingEvents.end() && *it == event) {
- return int(std::distance(m_outgoingEvents.begin(), it));
- } else {
- return -1;
- }
- }
-
static DynamicStateMachine *build(DocumentModel::ScxmlDocument *doc)
{
auto stateMachine = new DynamicStateMachine;
@@ -999,11 +663,7 @@ private:
private:
QVector<QScxmlInvokableServiceFactory *> m_allFactoriesById;
- QStringList m_incomingEvents;
- QStringList m_outgoingEvents;
int m_propertyCount;
- int m_firstSlot;
- int m_firstSlotWithoutData;
};
inline QScxmlInvokableService *InvokeDynamicScxmlFactory::invoke(QScxmlStateMachine *parent)
@@ -1089,26 +749,6 @@ QScxmlInvokableService *QScxmlInvokableScxmlServiceFactory::loadAndInvokeDynamic
*/
/*!
- \enum QScxmlParser::QtMode
-
- This enum specifies if the document should be parsed in Qt mode. In Qt
- mode, event and state names have to be valid C++ identifiers. If that is
- the case some additional convenience methods are generated. If not, the
- parser will reject the document. Qt mode can be enabled in the document
- itself by adding an XML comment of the form:
-
- \c {<!-- enable-qt-mode: yes -->}
-
- \value QtModeDisabled
- Ignore the XML comment and do not generate additional methods.
- \value QtModeEnabled
- Force parsing in Qt mode and try to generate the additional methods,
- no matter if the XML comment is present.
- \value QtModeFromInputFile
- Enable Qt mode only if the XML comment is present in the document.
- */
-
-/*!
* Creates a new SCXML parser for the specified \a reader.
*/
QScxmlParser::QScxmlParser(QXmlStreamReader *reader)
@@ -1255,31 +895,6 @@ void QScxmlParser::addError(const QString &msg)
d->addError(msg);
}
-/*!
- * Returns how the parser decides if the SCXML document should conform to Qt
- * mode.
- *
- * \sa QtMode
- */
-QScxmlParser::QtMode QScxmlParser::qtMode() const
-{
- return d->qtMode();
-}
-
-/*!
- * Sets the \c qtMode to \a mode. This property overrides the XML comment. You
- * can force Qt mode to be used by setting it to \c QtModeEnabled or force any
- * XML comments to be ignored and Qt mode to be used by setting it to
- * \c QtModeDisabled. The default is \c QtModeFromInputFile, which will switch
- * Qt mode on if the XML comment is present in the source file.
- *
- * \sa QtMode
- */
-void QScxmlParser::setQtMode(QScxmlParser::QtMode mode)
-{
- d->setQtMode(mode);
-}
-
bool QScxmlParserPrivate::ParserState::collectChars() {
switch (kind) {
case Content:
@@ -1686,11 +1301,6 @@ void DocumentModel::Scxml::accept(DocumentModel::NodeVisitor *visitor)
DocumentModel::NodeVisitor::~NodeVisitor()
{}
-bool DocumentModel::isValidQPropertyName(const QString &str)
-{
- return !str.isEmpty() && !str.contains(QLatin1Char('(')) && !str.contains(QLatin1Char(')'));
-}
-
/*!
* \class QScxmlParser::Loader
* \brief The Loader class is a URI resolver and resource loader for an SCXML parser.
@@ -1729,7 +1339,6 @@ QScxmlParserPrivate::QScxmlParserPrivate(QXmlStreamReader *reader)
: m_currentState(Q_NULLPTR)
, m_loader(&m_defaultLoader)
, m_reader(reader)
- , m_qtMode(QScxmlParser::QtModeFromInputFile)
{}
bool QScxmlParserPrivate::verifyDocument()
@@ -1797,20 +1406,9 @@ bool QScxmlParserPrivate::parseSubElement(DocumentModel::Invoke *parentInvoke,
parentInvoke->content.reset(p.d->m_doc.take());
m_doc->allSubDocuments.append(parentInvoke->content.data());
m_errors.append(p.errors());
- parentInvoke->content->qtMode = m_doc->qtMode;
return ok;
}
-static bool isWordEnd(const QStringRef &str, int start)
-{
- if (str.size() <= start) {
- return true;
- }
-
- QChar ch = str.at(start);
- return ch.isSpace();
-}
-
bool QScxmlParserPrivate::preReadElementScxml()
{
if (m_doc->root) {
@@ -2528,10 +2126,6 @@ void QScxmlParserPrivate::resetDocument()
bool QScxmlParserPrivate::readDocument()
{
resetDocument();
- if (m_qtMode == QScxmlParser::QtModeEnabled)
- m_doc->qtMode = true;
- else if (m_qtMode == QScxmlParser::QtModeDisabled)
- m_doc->qtMode = false;
m_currentState = m_doc->root;
for (bool finished = false; !finished && !m_reader->hasError();) {
switch (m_reader->readNext()) {
@@ -2558,9 +2152,6 @@ bool QScxmlParserPrivate::readDocument()
case QXmlStreamReader::EndElement :
finished = true;
break;
- case QXmlStreamReader::Comment:
- parseComment();
- break;
default :
break;
}
@@ -2673,9 +2264,6 @@ bool QScxmlParserPrivate::readElement()
if (current().collectChars())
current().chars.append(m_reader->text());
break;
- case QXmlStreamReader::Comment:
- parseComment();
- break;
default :
break;
}
@@ -2721,33 +2309,6 @@ bool QScxmlParserPrivate::readElement()
return true;
}
-void QScxmlParserPrivate::parseComment()
-{
- static const QString qtModeSwitch = QStringLiteral("enable-qt-mode:");
- const QStringRef commentText = m_reader->text();
- int qtModeIdx = commentText.indexOf(qtModeSwitch);
- if (qtModeIdx != -1) {
- qtModeIdx += qtModeSwitch.size();
- while (qtModeIdx < commentText.size()) {
- if (commentText.at(qtModeIdx).isSpace()) {
- ++qtModeIdx;
- } else {
- break;
- }
- }
- const QStringRef value = commentText.mid(qtModeIdx);
- if (value.startsWith(QStringLiteral("yes")) && isWordEnd(value, 3)) {
- if (m_qtMode == QScxmlParser::QtModeFromInputFile)
- m_doc->qtMode = true;
- } else if (value.startsWith(QStringLiteral("no")) && isWordEnd(value, 2)) {
- if (m_qtMode == QScxmlParser::QtModeFromInputFile)
- m_doc->qtMode = false;
- } else {
- addError(QStringLiteral("expected 'yes' or 'no' after enable-qt-mode in comment"));
- }
- }
-}
-
void QScxmlParserPrivate::currentStateUp()
{
Q_ASSERT(m_currentState->parent);
@@ -2798,16 +2359,6 @@ void QScxmlParserPrivate::addError(const DocumentModel::XmlLocation &location, c
m_errors.append(QScxmlError(m_fileName, location.line, location.column, msg));
}
-QScxmlParser::QtMode QScxmlParserPrivate::qtMode() const
-{
- return m_qtMode;
-}
-
-void QScxmlParserPrivate::setQtMode(QScxmlParser::QtMode mode)
-{
- m_qtMode = mode;
-}
-
DocumentModel::AbstractState *QScxmlParserPrivate::currentParent() const
{
return m_currentState ? m_currentState->asAbstractState() : Q_NULLPTR;
diff --git a/src/scxml/qscxmlparser.h b/src/scxml/qscxmlparser.h
index ac57a0a..9a6b131 100644
--- a/src/scxml/qscxmlparser.h
+++ b/src/scxml/qscxmlparser.h
@@ -63,12 +63,6 @@ public:
QStringList *errors) = 0;
};
- enum QtMode {
- QtModeDisabled,
- QtModeEnabled,
- QtModeFromInputFile
- };
-
public:
QScxmlParser(QXmlStreamReader *xmlReader);
~QScxmlParser();
@@ -86,9 +80,6 @@ public:
QVector<QScxmlError> errors() const;
void addError(const QString &msg);
- QtMode qtMode() const;
- void setQtMode(QtMode mode);
-
private:
friend class QScxmlParserPrivate;
QScxmlParserPrivate *d;
diff --git a/src/scxml/qscxmlparser_p.h b/src/scxml/qscxmlparser_p.h
index 703c864..1d01447 100644
--- a/src/scxml/qscxmlparser_p.h
+++ b/src/scxml/qscxmlparser_p.h
@@ -409,13 +409,11 @@ struct ScxmlDocument
QVector<Node *> allNodes;
QVector<InstructionSequence *> allSequences;
QVector<ScxmlDocument *> allSubDocuments; // weak pointers
- bool qtMode;
bool isVerified;
ScxmlDocument(const QString &fileName)
: fileName(fileName)
, root(Q_NULLPTR)
- , qtMode(false)
, isVerified(false)
{}
@@ -548,9 +546,6 @@ public:
}
};
-Q_SCXML_EXPORT bool isValidCppIdentifier(const QString &str);
-Q_SCXML_EXPORT bool isValidQPropertyName(const QString &str);
-
} // DocumentModel namespace
class Q_SCXML_EXPORT QScxmlParserPrivate
@@ -583,9 +578,6 @@ public:
void addError(const QString &msg);
void addError(const DocumentModel::XmlLocation &location, const QString &msg);
- QScxmlParser::QtMode qtMode() const;
- void setQtMode(QScxmlParser::QtMode mode);
-
private:
DocumentModel::AbstractState *currentParent() const;
DocumentModel::XmlLocation xmlLocation() const;
@@ -652,7 +644,6 @@ private:
bool readElement();
void resetDocument();
- void parseComment();
void currentStateUp();
bool flushInstruction();
@@ -733,7 +724,6 @@ private:
QXmlStreamReader *m_reader;
QVector<ParserState> m_stack;
QVector<QScxmlError> m_errors;
- QScxmlParser::QtMode m_qtMode;
};
QT_END_NAMESPACE
diff --git a/src/scxml/qscxmlstatemachine.cpp b/src/scxml/qscxmlstatemachine.cpp
index 92c6833..7dae1e3 100644
--- a/src/scxml/qscxmlstatemachine.cpp
+++ b/src/scxml/qscxmlstatemachine.cpp
@@ -74,17 +74,6 @@ Q_LOGGING_CATEGORY(scxmlLog, "scxml.statemachine")
* are accessible as properties of QScxmlStateMachine.
* These properties are boolean values and indicate
* whether the state is active or inactive.
- *
- * All external signals defined inside the SCXML file
- * that are of the \c qt:signal type, are accessible
- * as signals of QScxmlStateMachine in the \e {Qt mode}.
- * The only argument of these signals
- * is always QVariant, which is of QMap<QString, QVariant>
- * type containing the content of all the \c <param>
- * elements specified as children of a \c <send> element.
- * The name of each QScxmlStateMachine signal
- * corresponds to the value defined in the
- * \e event attribute of one \c <send> tag in the SCXML file.
*/
/*!
@@ -439,13 +428,6 @@ void QScxmlStateMachinePrivate::postEvent(QScxmlEvent *event)
if (event->eventType() == QScxmlEvent::ExternalEvent)
m_router.route(event->name().split(QLatin1Char('.')), event);
- const int signalIndex = m_tableData->signalIndexForEvent(event->name());
- if (signalIndex != -1) {
- emitSignalForEvent(signalIndex, event->data());
- delete event;
- return;
- }
-
if (event->eventType() == QScxmlEvent::ExternalEvent) {
qCDebug(qscxmlLog) << q << "posting external event" << event->name();
m_externalQueue.enqueue(event);
@@ -600,15 +582,6 @@ void QScxmlStateMachinePrivate::emitRunningSubStateMachinesChanged()
emit q->runningSubStateMachinesChanged(q->runningSubStateMachines());
}
-void QScxmlStateMachinePrivate::emitSignalForEvent(int signalIndex, const QVariant &data)
-{
- Q_Q(QScxmlStateMachine);
- void *args[] = { Q_NULLPTR, const_cast<void*>(reinterpret_cast<const void*>(&data)) };
- QMetaObject::activate(q, m_metaObject,
- signalIndex + m_stateTable->stateCount + m_stateTable->maxServiceId + 1,
- args);
-}
-
QStringList QScxmlStateMachinePrivate::stateNames(const std::vector<int> &stateIndexes) const
{
QStringList names;
diff --git a/src/scxml/qscxmltabledata.cpp b/src/scxml/qscxmltabledata.cpp
index 8bcf086..5e1c628 100644
--- a/src/scxml/qscxmltabledata.cpp
+++ b/src/scxml/qscxmltabledata.cpp
@@ -64,9 +64,7 @@ public:
, m_assignments(tableData.theAssignments)
, m_foreaches(tableData.theForeaches)
, m_dataIds(tableData.theDataNameIds)
- , m_outgoingEvents(metaDataInfo.outgoingEvents)
, m_stateNames(metaDataInfo.stateNames)
- , m_incomingEvents(metaDataInfo.incomingEvents)
{
m_activeSequences.reserve(4);
@@ -75,7 +73,6 @@ public:
void buildTableData(DocumentModel::ScxmlDocument *doc)
{
- m_qtMode = doc->qtMode;
m_isCppDataModel = doc->root->dataModel == DocumentModel::Scxml::CppDataModel;
m_parents.reserve(32);
m_allTransitions.resize(doc->allTransitions.size());
@@ -346,12 +343,9 @@ protected: // visitor
addStates(&newTransition.targets, transition->targetStates);
QVector<int> eventIds;
- foreach (const QString &event, transition->events) {
+ foreach (const QString &event, transition->events)
eventIds.push_back(addString(event));
- if (m_qtMode) {
- m_incomingEvents.add(event);
- }
- }
+
addArray(&newTransition.events, eventIds);
return false;
@@ -385,10 +379,6 @@ protected: // visitor
bool visit(DocumentModel::Send *node) Q_DECL_OVERRIDE Q_DECL_FINAL
{
- if (m_qtMode && node->type == QStringLiteral("qt:signal")) {
- m_outgoingEvents.add(m_stringTable.item(addString(node->event)));
- }
-
auto instr = m_instructions.add<Send>(Send::calculateExtraSize(node->params.size(),
node->namelist.size()));
instr->instructionLocation = createContext(QStringLiteral("send"));
@@ -893,11 +883,8 @@ private:
int m_currentTransition = StateTable::InvalidIndex;
bool m_bindLate = false;
- bool m_qtMode = false;
QVector<DocumentModel::DataElement *> m_dataElements;
- Table<QStringList, QString, int> m_outgoingEvents;
Table<QStringList, QString, int> m_stateNames;
- Table<QStringList, QString, int> m_incomingEvents;
};
} // anonymous namespace
@@ -1043,9 +1030,3 @@ QScxmlInvokableServiceFactory *GeneratedTableData::serviceFactory(int id) const
Q_UNUSED(id);
return nullptr;
}
-
-int GeneratedTableData::signalIndexForEvent(const QString &event) const
-{
- Q_UNUSED(event);
- return -1;
-}
diff --git a/src/scxml/qscxmltabledata.h b/src/scxml/qscxmltabledata.h
index 9f025bf..1b3135f 100644
--- a/src/scxml/qscxmltabledata.h
+++ b/src/scxml/qscxmltabledata.h
@@ -68,7 +68,6 @@ public:
virtual const qint32 *stateMachineTable() const = 0;
virtual QScxmlInvokableServiceFactory *serviceFactory(int id) const = 0;
- virtual int signalIndexForEvent(const QString &event) const = 0;
};
QT_END_NAMESPACE
diff --git a/src/scxml/qscxmltabledata_p.h b/src/scxml/qscxmltabledata_p.h
index aaf53ba..5e73e3a 100644
--- a/src/scxml/qscxmltabledata_p.h
+++ b/src/scxml/qscxmltabledata_p.h
@@ -83,9 +83,7 @@ public:
> CreateFactoryId;
struct MetaDataInfo {
- QStringList outgoingEvents;
QStringList stateNames;
- QStringList incomingEvents;
};
struct DataModelInfo {
@@ -115,7 +113,6 @@ public:
QString name() const Q_DECL_OVERRIDE Q_DECL_FINAL;
const qint32 *stateMachineTable() const Q_DECL_OVERRIDE Q_DECL_FINAL;
QScxmlInvokableServiceFactory *serviceFactory(int id) const Q_DECL_OVERRIDE;
- int signalIndexForEvent(const QString &event) const Q_DECL_OVERRIDE;
public:
QVector<qint32> theStateMachineTable;
diff --git a/tests/auto/compiled/anonymousstate.scxml b/tests/auto/compiled/anonymousstate.scxml
index 016b339..60adfb0 100644
--- a/tests/auto/compiled/anonymousstate.scxml
+++ b/tests/auto/compiled/anonymousstate.scxml
@@ -1,5 +1,4 @@
<?xml version="1.0" ?>
-<!-- enable-qt-mode: no -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
name="Pinball2" datamodel="ecmascript">
<state>
diff --git a/tests/auto/compiled/eventnames2.scxml b/tests/auto/compiled/eventnames2.scxml
index ee5448f..49a5e98 100644
--- a/tests/auto/compiled/eventnames2.scxml
+++ b/tests/auto/compiled/eventnames2.scxml
@@ -28,7 +28,6 @@
**
****************************************************************************/
-->
-<!-- enable-qt-mode: no -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="eventnames2">
<state id="a">
<onentry>
diff --git a/tests/auto/compiled/submachineunicodename.scxml b/tests/auto/compiled/submachineunicodename.scxml
index b62e751..9cee0e3 100644
--- a/tests/auto/compiled/submachineunicodename.scxml
+++ b/tests/auto/compiled/submachineunicodename.scxml
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- enable-qt-mode: yes -->
<scxml
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
diff --git a/tests/auto/dynamicmetaobject/mediaplayer.scxml b/tests/auto/dynamicmetaobject/mediaplayer.scxml
index 025245a..ca68039 100644
--- a/tests/auto/dynamicmetaobject/mediaplayer.scxml
+++ b/tests/auto/dynamicmetaobject/mediaplayer.scxml
@@ -50,7 +50,6 @@
**
****************************************************************************/
-->
-<!-- enable-qt-mode: yes -->
<scxml
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
@@ -76,13 +75,13 @@
<state id="playing">
<onentry>
<assign location="media" expr="_event.data.media"/>
- <send type="qt:signal" event="playbackStarted">
+ <send event="playbackStarted">
<param name="media" expr="media"/>
</send>
</onentry>
<onexit>
- <send type="qt:signal" event="playbackStopped">
+ <send event="playbackStopped">
<param name="media" expr="media"/>
</send>
</onexit>
diff --git a/tests/auto/dynamicmetaobject/tst_dynamicmetaobject.cpp b/tests/auto/dynamicmetaobject/tst_dynamicmetaobject.cpp
index 7610dd7..83fceeb 100644
--- a/tests/auto/dynamicmetaobject/tst_dynamicmetaobject.cpp
+++ b/tests/auto/dynamicmetaobject/tst_dynamicmetaobject.cpp
@@ -44,41 +44,28 @@ void tst_DynamicMetaObject::dynamicPartCheck_data()
{
QTest::addColumn<QString>("scxmlFileName");
QTest::addColumn<QStringList>("expectedProperties");
- QTest::addColumn<QStringList>("expectedMethods");
QTest::addColumn<QStringList>("expectedSignals");
- QTest::addColumn<QStringList>("expectedSlots");
{ // test1.scxml
const QStringList expectedProperties = { QLatin1String("a"), QLatin1String("b") };
- const QStringList expectedMethods = { };
const QStringList expectedSignals = { QLatin1String("aChanged(bool)"),
QLatin1String("bChanged(bool)") };
- const QStringList expectedSlots = { };
QTest::newRow("test1") << QString(":/tst_dynamicmetaobject/test1.scxml")
<< expectedProperties
- << expectedMethods
- << expectedSignals
- << expectedSlots;
+ << expectedSignals;
}
{ // mediaplayer.scxml
const QStringList expectedProperties = { QLatin1String("stopped"), QLatin1String("playing") };
- const QStringList expectedMethods = { };
const QStringList expectedSignals = { QLatin1String("stoppedChanged(bool)"),
- QLatin1String("playingChanged(bool)"),
- QLatin1String("playbackStarted(QVariant)"),
- QLatin1String("playbackStopped(QVariant)") };
- const QStringList expectedSlots = { QLatin1String("tap()"),
- QLatin1String("tap(QVariant)") };
+ QLatin1String("playingChanged(bool)") };
QTest::newRow("mediaplayer") << QString(":/tst_dynamicmetaobject/mediaplayer.scxml")
<< expectedProperties
- << expectedMethods
- << expectedSignals
- << expectedSlots;
+ << expectedSignals;
}
}
@@ -86,9 +73,7 @@ void tst_DynamicMetaObject::dynamicPartCheck()
{
QFETCH(QString, scxmlFileName);
QFETCH(QStringList, expectedProperties);
- QFETCH(QStringList, expectedMethods);
QFETCH(QStringList, expectedSignals);
- QFETCH(QStringList, expectedSlots);
QScopedPointer<QScxmlStateMachine> stateMachine(QScxmlStateMachine::fromFile(scxmlFileName));
QVERIFY(!stateMachine.isNull());
@@ -98,42 +83,25 @@ void tst_DynamicMetaObject::dynamicPartCheck()
QStringList dynamicProperties;
for (int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); i++) {
- QMetaProperty metaProperty = metaObject->property(i);
+ const QMetaProperty metaProperty = metaObject->property(i);
dynamicProperties << metaProperty.name();
}
- QStringList dynamicMethods, dynamicSignals, dynamicSlots;
+ QStringList dynamicSignals;
for (int i = metaObject->methodOffset(); i < metaObject->methodCount(); i++) {
- QMetaMethod metaMethod = metaObject->method(i);
- switch (metaMethod.methodType()) {
- case QMetaMethod::Method:
- dynamicMethods << metaMethod.methodSignature();
- break;
- case QMetaMethod::Signal:
+ const QMetaMethod metaMethod = metaObject->method(i);
+ if (metaMethod.methodType() == QMetaMethod::Signal)
dynamicSignals << metaMethod.methodSignature();
- break;
- case QMetaMethod::Slot:
- dynamicSlots << metaMethod.methodSignature();
- break;
- default:
- break;
- }
}
// TODO: remove sorting when we drop QSet internally
expectedProperties.sort();
- expectedMethods.sort();
expectedSignals.sort();
- expectedSlots.sort();
dynamicProperties.sort();
- dynamicMethods.sort();
dynamicSignals.sort();
- dynamicSlots.sort();
QCOMPARE(dynamicProperties, expectedProperties);
- QCOMPARE(dynamicMethods, expectedMethods);
QCOMPARE(dynamicSignals, expectedSignals);
- QCOMPARE(dynamicSlots, expectedSlots);
}
QTEST_MAIN(tst_DynamicMetaObject)
diff --git a/tests/auto/parser/data/ids2.scxml b/tests/auto/parser/data/ids2.scxml
index 228b487..5378fcb 100644
--- a/tests/auto/parser/data/ids2.scxml
+++ b/tests/auto/parser/data/ids2.scxml
@@ -28,7 +28,6 @@
**
****************************************************************************/
-->
-<!-- enable-qt-mode: yes -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="ids2">
<state id="foo.bar"/>
<state id="foo-bar"/>
diff --git a/tests/auto/parser/data/ids2.scxml.errors b/tests/auto/parser/data/ids2.scxml.errors
index 31d8e7c..3ca729e 100644
--- a/tests/auto/parser/data/ids2.scxml.errors
+++ b/tests/auto/parser/data/ids2.scxml.errors
@@ -1,3 +1 @@
-:/tst_parser/data/ids2.scxml:33:25: error: state name 'foo.bar' is not a valid C++ identifier in Qt mode
-:/tst_parser/data/ids2.scxml:34:25: error: state name 'foo-bar' is not a valid C++ identifier in Qt mode
-:/tst_parser/data/ids2.scxml:36:19: error: '1' is not a valid XML ID
+:/tst_parser/data/ids2.scxml:35:19: error: '1' is not a valid XML ID
diff --git a/tests/auto/parser/data/invalidRoot3.scxml b/tests/auto/parser/data/invalidRoot3.scxml
index e968b20..62dab58 100644
--- a/tests/auto/parser/data/invalidRoot3.scxml
+++ b/tests/auto/parser/data/invalidRoot3.scxml
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- enable-qt-mode: yeq -->
<scxma
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
diff --git a/tests/auto/parser/data/invalidRoot3.scxml.errors b/tests/auto/parser/data/invalidRoot3.scxml.errors
index e61f590..dd1cf6c 100644
--- a/tests/auto/parser/data/invalidRoot3.scxml.errors
+++ b/tests/auto/parser/data/invalidRoot3.scxml.errors
@@ -1,3 +1,2 @@
-:/tst_parser/data/invalidRoot3.scxml:2:28: error: expected 'yes' or 'no' after enable-qt-mode in comment
-:/tst_parser/data/invalidRoot3.scxml:6:1: error: Unknown element scxma
-:/tst_parser/data/invalidRoot3.scxml:9:8: error: Missing root element
+:/tst_parser/data/invalidRoot3.scxml:5:1: error: Unknown element scxma
+:/tst_parser/data/invalidRoot3.scxml:8:8: error: Missing root element
diff --git a/tests/auto/parser/data/qtmode.scxml b/tests/auto/parser/data/qtmode.scxml
deleted file mode 100644
index c5df8b0..0000000
--- a/tests/auto/parser/data/qtmode.scxml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" ?>
-<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
--->
-<!-- enable-qt-mode: yes -->
-<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
- name="test1">
- <state id="a">
- <transition event="a"/>
- <transition event="void"/>
- <transition event="aChanged"/>
- <transition event="finished"/>
- <transition event="done.state.a"/>
- <transition event="done.state.double"/>
- </state>
- <state id="int"/>
- <state id="objectName"/>
- <state id="foo"/>
- <state id="fooChanged"/>
-</scxml>
diff --git a/tests/auto/parser/data/qtmode.scxml.errors b/tests/auto/parser/data/qtmode.scxml.errors
deleted file mode 100644
index ae365b9..0000000
--- a/tests/auto/parser/data/qtmode.scxml.errors
+++ /dev/null
@@ -1,9 +0,0 @@
-:/tst_parser/data/qtmode.scxml:35:31: error: event name 'a' collides with a state name 'a' in Qt mode
-:/tst_parser/data/qtmode.scxml:36:34: error: event name 'void' is not a valid C++ identifier in Qt mode
-:/tst_parser/data/qtmode.scxml:37:38: error: event name 'aChanged' collides with a state name 'a' in Qt mode
-:/tst_parser/data/qtmode.scxml:38:38: error: event name 'finished' is not a valid Qt identifier in Qt mode
-:/tst_parser/data/qtmode.scxml:39:42: error: event name 'done.state.a' is not a valid C++ identifier in Qt mode
-:/tst_parser/data/qtmode.scxml:40:47: error: event name 'done.state.double' is not a valid C++ identifier in Qt mode
-:/tst_parser/data/qtmode.scxml:42:21: error: state name 'int' is not a valid C++ identifier in Qt mode
-:/tst_parser/data/qtmode.scxml:43:28: error: state name 'objectName' is not a valid Qt identifier in Qt mode
-:/tst_parser/data/qtmode.scxml:45:28: error: state name 'fooChanged' collides with a state name 'foo' in Qt mode
diff --git a/tests/auto/parser/tst_parser.qrc b/tests/auto/parser/tst_parser.qrc
index 0c5f56b..8d133d2 100644
--- a/tests/auto/parser/tst_parser.qrc
+++ b/tests/auto/parser/tst_parser.qrc
@@ -48,8 +48,6 @@
<file>data/prematureEndOfDocument1.scxml</file>
<file>data/prematureEndOfDocument2.scxml.errors</file>
<file>data/prematureEndOfDocument2.scxml</file>
- <file>data/qtmode.scxml.errors</file>
- <file>data/qtmode.scxml</file>
<file>data/scxml1.scxml.errors</file>
<file>data/scxml1.scxml</file>
<file>data/scxml2.scxml.errors</file>
diff --git a/tools/qscxmlc/data.t b/tools/qscxmlc/data.t
index b26f451..afb5a64 100644
--- a/tools/qscxmlc/data.t
+++ b/tools/qscxmlc/data.t
@@ -40,7 +40,6 @@ struct ${classname}::Data: private QScxmlTableData {
{ return theStateMachineTable; }
QScxmlInvokableServiceFactory *serviceFactory(int id) const Q_DECL_OVERRIDE Q_DECL_FINAL;
- int signalIndexForEvent(const QString &event) const Q_DECL_OVERRIDE Q_DECL_FINAL;
${classname} &stateMachine;
${dataModelField}
@@ -55,8 +54,6 @@ struct ${classname}::Data: private QScxmlTableData {
QArrayData data[${stringCount}];
qunicodechar stringdata[${stringdataSize}];
} strings;
-
- static std::vector<QString> outgoingEvents;
};
${classname}::${classname}(QObject *parent)
@@ -72,20 +69,6 @@ QScxmlInvokableServiceFactory *${classname}::Data::serviceFactory(int id) const
${serviceFactories}
}
-std::vector<QString> ${classname}::Data::outgoingEvents = {
-${outgoingEvents}
-};
-
-int ${classname}::Data::signalIndexForEvent(const QString &event) const
-{
- auto it = std::lower_bound(outgoingEvents.begin(), outgoingEvents.end(), event);
- if (it != outgoingEvents.end() && *it == event) {
- return int(std::distance(outgoingEvents.begin(), it));
- } else {
- return -1;
- }
-}
-
qint32 ${classname}::Data::theInstructions[] = {
${theInstructions}
};
@@ -119,5 +102,3 @@ ${uniLits}
const qint32 ${classname}::Data::theStateMachineTable[] = ${theStateMachineTable};
${metaObject}
-${getters}
-${slots}
diff --git a/tools/qscxmlc/decl.t b/tools/qscxmlc/decl.t
index b0963e4..7c27f1d 100644
--- a/tools/qscxmlc/decl.t
+++ b/tools/qscxmlc/decl.t
@@ -9,11 +9,6 @@ public:
${classname}(QObject *parent = 0);
~${classname}();
-${getters}
-signals:
-${signals}
-public slots:
-${slots}
private:
struct Data;
friend struct Data;
diff --git a/tools/qscxmlc/qscxmlc.cpp b/tools/qscxmlc/qscxmlc.cpp
index 2198592..47db6fb 100644
--- a/tools/qscxmlc/qscxmlc.cpp
+++ b/tools/qscxmlc/qscxmlc.cpp
@@ -124,13 +124,6 @@ int run(const QStringList &arguments)
QCommandLineOption optionClassName(QLatin1String("classname"),
QCoreApplication::translate("main", "Generate <name> for state machine class name."),
QCoreApplication::translate("main", "name"));
- QCommandLineOption optionQtMode(QLatin1String("qt-mode"),
- QCoreApplication::translate("main", "Enables or disables Qt mode. "
- "In order to unconditionally enable qt-mode, specify \"yes\". "
- "To unconditionally disable qt-mode, specify \"no\". "
- "To read the setting from the input file, specify \"from-input\". "
- "The default is \"from-input\"."),
- QCoreApplication::translate("main", "mode"), QLatin1String("from-input"));
cmdParser.addPositionalArgument(QLatin1String("input"),
QCoreApplication::translate("main", "Input SCXML file."));
@@ -140,7 +133,6 @@ int run(const QStringList &arguments)
cmdParser.addOption(optionOutputHeaderName);
cmdParser.addOption(optionOutputSourceName);
cmdParser.addOption(optionClassName);
- cmdParser.addOption(optionQtMode);
cmdParser.process(arguments);
@@ -167,21 +159,6 @@ int run(const QStringList &arguments)
QString outHFileName = cmdParser.value(optionOutputHeaderName);
QString outCppFileName = cmdParser.value(optionOutputSourceName);
QString mainClassName = cmdParser.value(optionClassName);
- QString qtModeName = cmdParser.value(optionQtMode);
-
- QScxmlParser::QtMode qtMode = QScxmlParser::QtModeFromInputFile;
-
- if (qtModeName == QLatin1String("yes")) {
- qtMode = QScxmlParser::QtModeEnabled;
- } else if (qtModeName == QLatin1String("no")) {
- qtMode = QScxmlParser::QtModeDisabled;
- } else if (qtModeName == QLatin1String("from-input")) {
- qtMode = QScxmlParser::QtModeFromInputFile;
- } else {
- errs << QCoreApplication::translate("main", "Error: unexpected value for qt-mode option: %1")
- .arg(qtModeName) << endl;
- cmdParser.showHelp(CommandLineArgumentsError);
- }
if (outFileName.isEmpty())
outFileName = QFileInfo(scxmlFileName).baseName();
@@ -199,7 +176,6 @@ int run(const QStringList &arguments)
QXmlStreamReader reader(&file);
QScxmlParser parser(&reader);
parser.setFileName(file.fileName());
- parser.setQtMode(qtMode);
parser.parse();
if (!parser.errors().isEmpty()) {
foreach (const QScxmlError &error, parser.errors()) {
diff --git a/tools/qscxmlc/scxmlcppdumper.cpp b/tools/qscxmlc/scxmlcppdumper.cpp
index d13b18e..4d0e795 100644
--- a/tools/qscxmlc/scxmlcppdumper.cpp
+++ b/tools/qscxmlc/scxmlcppdumper.cpp
@@ -188,8 +188,7 @@ static void generateList(QString &out, std::function<QString(int)> next)
out += line;
}
-void generateTables(const GeneratedTableData &td, const QStringList &outgoingEvents,
- Replacements &replacements, bool useCxx11)
+void generateTables(const GeneratedTableData &td, Replacements &replacements)
{
{ // instructions
auto instr = td.theInstructions;
@@ -307,16 +306,6 @@ void generateTables(const GeneratedTableData &td, const QStringList &outgoingEve
replacements[QStringLiteral("uniLits")] = out;
replacements[QStringLiteral("stringdataSize")] = QString::number(ucharCount + 1);
}
-
- {
- QStringList items;
- foreach (const QString &event, outgoingEvents) {
- items += QStringLiteral("QString({static_cast<QStringData*>(strings.data + %1)})")
- .arg(td.theStrings.indexOf(event));
- }
- replacements[QStringLiteral("outgoingEvents")] = createContainer(
- QStringLiteral("std::vector"), QStringLiteral("QString"), items, useCxx11);
- }
}
void generateCppDataModelEvaluators(const GeneratedTableData::DataModelInfo &info,
@@ -470,7 +459,6 @@ void CppDumper::dump(TranslationUnit *unit)
finalize, m_translationUnit->useCxx11);
});
classNames.append(mangleIdentifier(classnameForDocument.value(doc)));
- std::sort(metaDataInfo->outgoingEvents.begin(), metaDataInfo->outgoingEvents.end());
}
const QString headerName = QFileInfo(m_translationUnit->outHFileName).fileName();
@@ -522,13 +510,9 @@ void CppDumper::writeHeaderStart(const QString &headerGuard, const QStringList &
void CppDumper::writeClass(const QString &className, const GeneratedTableData::MetaDataInfo &info)
{
- const bool qtMode = m_translationUnit->mainDocument->qtMode;
Replacements r;
r[QStringLiteral("classname")] = className;
- r[QStringLiteral("properties")] = generatePropertyDecls(info, qtMode);
- r[QStringLiteral("signals")] = qtMode ? generateSignalDecls(info) : QString();
- r[QStringLiteral("slots")] = qtMode ? generateSlotDecls(info) : QString();
- r[QStringLiteral("getters")] = qtMode ? generateGetterDecls(info) : QString();
+ r[QStringLiteral("properties")] = generatePropertyDecls(info);
genTemplate(h, QStringLiteral(":/decl.t"), r);
}
@@ -597,8 +581,6 @@ void CppDumper::writeImplBody(const GeneratedTableData &table,
const QStringList &factory,
const GeneratedTableData::MetaDataInfo &info)
{
- const bool qtMode = m_translationUnit->mainDocument->qtMode;
-
QString dataModelField, dataModelInitialization;
switch (doc->root->dataModel) {
case DocumentModel::Scxml::NullDataModel:
@@ -637,15 +619,13 @@ void CppDumper::writeImplBody(const GeneratedTableData &table,
r[QStringLiteral("classname")] = className;
r[QStringLiteral("name")] = name;
r[QStringLiteral("initialSetup")] = QString::number(table.initialSetup());
- generateTables(table, info.outgoingEvents, r, m_translationUnit->useCxx11);
+ generateTables(table, r);
r[QStringLiteral("dataModelField")] = dataModelField;
r[QStringLiteral("dataModelInitialization")] = dataModelInitialization;
r[QStringLiteral("theStateMachineTable")] =
GeneratedTableData::toString(table.stateMachineTable());
- r[QStringLiteral("metaObject")] = generateMetaObject(className, info, qtMode);
+ r[QStringLiteral("metaObject")] = generateMetaObject(className, info);
r[QStringLiteral("serviceFactories")] = serviceFactories;
- r[QStringLiteral("slots")] = qtMode ? generateSlotDefs(className, info) : QString();
- r[QStringLiteral("getters")] = qtMode ? generateGetterDefs(className, info) : QString();
genTemplate(cpp, QStringLiteral(":/data.t"), r);
}
@@ -721,99 +701,23 @@ QString CppDumper::mangleIdentifier(const QString &str)
return mangled;
}
-QString CppDumper::generatePropertyDecls(const GeneratedTableData::MetaDataInfo &info, bool qtMode)
+QString CppDumper::generatePropertyDecls(const GeneratedTableData::MetaDataInfo &info)
{
QString decls;
foreach (const QString &stateName, info.stateNames) {
if (!stateName.isEmpty()) {
const QString decl = QString::fromLatin1(
- qtMode ? " Q_PROPERTY(bool %1 READ %2 NOTIFY %2Changed)\n" :
" Q_PROPERTY(bool %1 NOTIFY %2Changed)\n");
decls += decl.arg(stateName, mangleIdentifier(stateName));
}
}
- QString namespacePrefix;
- if (!m_translationUnit->namespaceName.isEmpty()) {
- namespacePrefix = QStringLiteral("::%1").arg(m_translationUnit->namespaceName);
- }
-
- return decls;
-}
-
-QString CppDumper::generateSignalDecls(const GeneratedTableData::MetaDataInfo &info)
-{
- QString decls;
-
- foreach (const QString &stateName, info.stateNames) {
- decls += QStringLiteral(" void %1Changed(bool active);\n")
- .arg(mangleIdentifier(stateName));
- }
-
- foreach (const QString &eventName, info.outgoingEvents) {
- decls += QStringLiteral(" void %1(const QVariant &data);\n")
- .arg(mangleIdentifier(eventName));
- }
-
- return decls;
-}
-
-QString CppDumper::generateSlotDecls(const GeneratedTableData::MetaDataInfo &info)
-{
- QString decls;
-
- foreach (const QString &eventName, info.incomingEvents) {
- decls += QStringLiteral(" void %1(const QVariant &data = QVariant());\n")
- .arg(mangleIdentifier(eventName));
- }
-
- return decls;
-}
-
-QString CppDumper::generateSlotDefs(const QString &className,
- const GeneratedTableData::MetaDataInfo &info)
-{
- QString defs;
-
- foreach (const QString &eventName, info.incomingEvents) {
- const auto mangledName = mangleIdentifier(eventName);
- defs += QStringLiteral("void %1::%2(const QVariant &data)\n").arg(className, mangledName);
- defs += QStringLiteral("{ submitEvent(QStringLiteral(\"%1\"), data); }\n\n").arg(eventName);
- }
-
- return defs;
-}
-
-QString CppDumper::generateGetterDecls(const GeneratedTableData::MetaDataInfo &info)
-{
- QString decls;
-
- foreach (const QString &stateName, info.stateNames) {
- decls += QStringLiteral(" bool %1() const;\n").arg(mangleIdentifier(stateName));
- }
-
return decls;
}
-QString CppDumper::generateGetterDefs(const QString &className,
- const GeneratedTableData::MetaDataInfo &info)
-{
- QString defs;
-
- int stateIndex = 0;
- foreach (const QString &stateName, info.stateNames) {
- defs += QStringLiteral("bool %1::%2() const\n").arg(className, mangleIdentifier(stateName));
- defs += QStringLiteral("{ return isActive(%1); }\n\n").arg(stateIndex);
- ++stateIndex;
- }
-
- return defs;
-}
-
QString CppDumper::generateMetaObject(const QString &className,
- const GeneratedTableData::MetaDataInfo &info,
- bool m_qtMode)
+ const GeneratedTableData::MetaDataInfo &info)
{
ClassDef classDef;
classDef.classname = className.toUtf8();
@@ -836,9 +740,8 @@ QString CppDumper::generateMetaObject(const QString &className,
signal.name = mangledStateName + "Changed";
signal.access = FunctionDef::Public;
signal.isSignal = true;
- if (!m_qtMode) {
- signal.implementation = "QMetaObject::activate(_o, &staticMetaObject, %d, _a);";
- }
+ signal.implementation = "QMetaObject::activate(_o, &staticMetaObject, %d, _a);";
+
ArgumentDef arg;
arg.type.name = "bool";
arg.type.rawName = arg.type.name;
@@ -864,60 +767,6 @@ QString CppDumper::generateMetaObject(const QString &className,
QHash<QByteArray, QByteArray> knownQObjectClasses;
knownQObjectClasses.insert(QByteArray("QScxmlStateMachine"), QByteArray());
- // Event signals:
- foreach (const QString &signalName, info.outgoingEvents) {
- FunctionDef signal;
- signal.type.name = "void";
- signal.type.rawName = signal.type.name;
- signal.normalizedType = signal.type.name;
- signal.name = signalName.toUtf8();
- signal.access = FunctionDef::Public;
- signal.isSignal = true;
-
- ArgumentDef arg;
- arg.type.name = "const QVariant &";
- arg.type.rawName = arg.type.name;
- arg.normalizedType = "QVariant";
- arg.name = "data";
- arg.typeNameForCast = arg.normalizedType + "*";
- signal.arguments << arg;
-
- classDef.signalList << signal;
- }
-
- // event slots:
- foreach (const QString &eventName, info.incomingEvents) {
- FunctionDef slot;
- slot.type.name = "void";
- slot.type.rawName = slot.type.name;
- slot.normalizedType = slot.type.name;
- slot.name = eventName.toUtf8();
- slot.access = FunctionDef::Public;
- slot.isSlot = true;
-
- ArgumentDef arg;
- arg.type.name = "const QVariant &";
- arg.type.rawName = arg.type.name;
- arg.normalizedType = "QVariant";
- arg.name = "data";
- arg.typeNameForCast = arg.normalizedType + "*";
- slot.arguments << arg;
-
- classDef.slotList << slot;
- }
-
- foreach (const QString &eventName, info.incomingEvents) {
- FunctionDef slot;
- slot.type.name = "void";
- slot.type.rawName = slot.type.name;
- slot.normalizedType = slot.type.name;
- slot.name = eventName.toUtf8();
- slot.access = FunctionDef::Public;
- slot.isSlot = true;
-
- classDef.slotList << slot;
- }
-
QBuffer buf;
buf.open(QIODevice::WriteOnly);
Generator(&classDef, QList<QByteArray>(), knownQObjectClasses,
diff --git a/tools/qscxmlc/scxmlcppdumper.h b/tools/qscxmlc/scxmlcppdumper.h
index 981499f..e1abfc2 100644
--- a/tools/qscxmlc/scxmlcppdumper.h
+++ b/tools/qscxmlc/scxmlcppdumper.h
@@ -80,18 +80,9 @@ private:
QString mangleIdentifier(const QString &str);
private:
- QString generatePropertyDecls(const QScxmlInternal::GeneratedTableData::MetaDataInfo &info,
- bool qtMode);
- QString generateSignalDecls(const QScxmlInternal::GeneratedTableData::MetaDataInfo &info);
- QString generateSlotDecls(const QScxmlInternal::GeneratedTableData::MetaDataInfo &info);
- QString generateSlotDefs(const QString &className,
- const QScxmlInternal::GeneratedTableData::MetaDataInfo &info);
- QString generateGetterDecls(const QScxmlInternal::GeneratedTableData::MetaDataInfo &info);
- QString generateGetterDefs(const QString &className,
- const QScxmlInternal::GeneratedTableData::MetaDataInfo &info);
+ QString generatePropertyDecls(const QScxmlInternal::GeneratedTableData::MetaDataInfo &info);
QString generateMetaObject(const QString &className,
- const QScxmlInternal::GeneratedTableData::MetaDataInfo &info,
- bool m_qtMode);
+ const QScxmlInternal::GeneratedTableData::MetaDataInfo &info);
QTextStream &h;
QTextStream &cpp;