aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-05-15 13:00:21 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-05-24 12:26:01 +0000
commit9d10897929350417f4c7b2dcf06966ff7c67c5a6 (patch)
tree6f6ffc6d8b8e8e4cf043cdec95111324e76f0166
parent71249b93a5d12a320b44c608c05fb9d220788a18 (diff)
Add QtScxml
Task-number: PYSIDE-487 Change-Id: Ib8eb4a77f04ddbbe2c4b164b95f49e2f53bf44d9 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--sources/pyside2/CMakeLists.txt2
-rw-r--r--sources/pyside2/PySide2/QtScxml/CMakeLists.txt60
-rw-r--r--sources/pyside2/PySide2/QtScxml/typesystem_scxml.xml71
-rw-r--r--sources/pyside2/tests/QtScxml/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtScxml/test_dynamic.py53
-rw-r--r--sources/pyside2/tests/QtScxml/trafficlight.scxml89
6 files changed, 275 insertions, 1 deletions
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt
index d4150c93b..77382480d 100644
--- a/sources/pyside2/CMakeLists.txt
+++ b/sources/pyside2/CMakeLists.txt
@@ -331,7 +331,7 @@ if(APPLE)
endif()
# Collect all optional modules.
-set(ALL_OPTIONAL_MODULES Xml XmlPatterns Help Multimedia MultimediaWidgets OpenGL Positioning Location Qml Quick QuickWidgets Script ScriptTools Sensors TextToSpeech Charts Svg DataVisualization)
+set(ALL_OPTIONAL_MODULES Xml XmlPatterns Help Multimedia MultimediaWidgets OpenGL Positioning Location Qml Quick QuickWidgets Scxml Script ScriptTools Sensors TextToSpeech Charts Svg DataVisualization)
find_package(Qt5UiTools)
if(Qt5UiTools_FOUND)
list(APPEND ALL_OPTIONAL_MODULES UiTools)
diff --git a/sources/pyside2/PySide2/QtScxml/CMakeLists.txt b/sources/pyside2/PySide2/QtScxml/CMakeLists.txt
new file mode 100644
index 000000000..0a75ffce6
--- /dev/null
+++ b/sources/pyside2/PySide2/QtScxml/CMakeLists.txt
@@ -0,0 +1,60 @@
+project(QtScxml)
+
+set(QtScxml_OPTIONAL_SRC )
+set(QtScxml_DROPPED_ENTRIES )
+
+set(QtScxml_SRC
+${QtScxml_GEN_DIR}/qscxmlcompiler_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlcompiler_loader_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlevent_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmldynamicscxmlservicefactory_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlinvokableservice_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlinvokableservicefactory_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlstaticscxmlservicefactory_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlstatemachine_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmltabledata_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlerror_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlexecutablecontent_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlexecutablecontent_assignmentinfo_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlexecutablecontent_evaluatorinfo_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlexecutablecontent_foreachinfo_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlexecutablecontent_invokeinfo_wrapper.cpp
+${QtScxml_GEN_DIR}/qscxmlexecutablecontent_parameterinfo_wrapper.cpp
+# module is always needed
+${QtScxml_GEN_DIR}/qtscxml_module_wrapper.cpp
+)
+
+if (Qt5Scxml_VERSION VERSION_EQUAL 5.12.0 OR Qt5Scxml_VERSION VERSION_GREATER 5.12.0)
+ list(APPEND QtScxml_SRC
+ ${QtScxml_GEN_DIR}/qscxmldatamodel_wrapper.cpp
+ ${QtScxml_GEN_DIR}/qscxmldatamodel_foreachloopbody_wrapper.cpp
+ ${QtScxml_GEN_DIR}/qscxmlecmascriptdatamodel_wrapper.cpp
+ ${QtScxml_GEN_DIR}/qscxmlcppdatamodel_wrapper.cpp
+ ${QtScxml_GEN_DIR}/qscxmlnulldatamodel_wrapper.cpp)
+endif()
+
+set(QtScxml_include_dirs ${QtScxml_SOURCE_DIR}
+ ${QtScxml_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Scxml_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR})
+
+set(QtScxml_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Scxml_LIBRARIES})
+
+set(QtScxml_deps QtCore)
+
+create_pyside_module(QtScxml
+ QtScxml_include_dirs
+ QtScxml_libraries
+ QtScxml_deps
+ QtScxml_SOURCE_DIR
+ QtScxml_SRC
+ ""
+ ""
+ QtScxml_DROPPED_ENTRIES)
diff --git a/sources/pyside2/PySide2/QtScxml/typesystem_scxml.xml b/sources/pyside2/PySide2/QtScxml/typesystem_scxml.xml
new file mode 100644
index 000000000..67a0cc4b7
--- /dev/null
+++ b/sources/pyside2/PySide2/QtScxml/typesystem_scxml.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+-->
+<typesystem package="PySide2.QtScxml">
+ <load-typesystem name="QtCore/typesystem_core.xml" generate="no"/>
+ <object-type name="QScxmlCompiler">
+ <object-type name="Loader"/>
+ </object-type>
+ <object-type name="QScxmlCppDataModel" since="5.12"/>
+ <object-type name="QScxmlEvent">
+ <enum-type name="EventType"/>
+ </object-type>
+ <object-type name="QScxmlDynamicScxmlServiceFactory"/>
+ <object-type name="QScxmlInvokableService"/>
+ <object-type name="QScxmlInvokableServiceFactory"/>
+ <object-type name="QScxmlStaticScxmlServiceFactory"/>
+ <object-type name="QScxmlStateMachine"/>
+ <object-type name="QScxmlTableData"/>
+ <object-type name="QScxmlDataModel" since="5.12">
+ <!-- Needs to have exports fixed -->
+ <interface-type name="ForeachLoopBody" since="5.12"/>
+ </object-type>
+ <object-type name="QScxmlEcmaScriptDataModel" since="5.12"/>
+ <value-type name="QScxmlError"/>
+ <namespace-type name="QScxmlExecutableContent">
+ <value-type name="AssignmentInfo"/>
+ <value-type name="EvaluatorInfo"/>
+ <value-type name="ForeachInfo"/>
+ <value-type name="InvokeInfo"/>
+ <value-type name="ParameterInfo"/>
+ </namespace-type>
+ <object-type name="QScxmlNullDataModel" since="5.12"/>
+</typesystem>
diff --git a/sources/pyside2/tests/QtScxml/CMakeLists.txt b/sources/pyside2/tests/QtScxml/CMakeLists.txt
new file mode 100644
index 000000000..dde186697
--- /dev/null
+++ b/sources/pyside2/tests/QtScxml/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(test_dynamic.py)
diff --git a/sources/pyside2/tests/QtScxml/test_dynamic.py b/sources/pyside2/tests/QtScxml/test_dynamic.py
new file mode 100644
index 000000000..1bae534ac
--- /dev/null
+++ b/sources/pyside2/tests/QtScxml/test_dynamic.py
@@ -0,0 +1,53 @@
+#############################################################################
+##
+## Copyright (C) 2018 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $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$
+##
+#############################################################################
+
+import os
+import unittest
+
+from helper import TimedQApplication
+from PySide2.QtCore import QObject, SIGNAL
+from PySide2.QtScxml import QScxmlStateMachine
+
+class testDynamicStateMachine(TimedQApplication):
+ def setUp(self):
+ super(testDynamicStateMachine, self).setUp()
+ filePath = os.path.join(os.path.dirname(__file__), 'trafficlight.scxml')
+ self.assertTrue(os.path.exists(filePath))
+ self._machine = QScxmlStateMachine.fromFile(filePath)
+ self._machine.reachedStableState.connect(self._reachedStable())
+ self.assertTrue(not self._machine.parseErrors())
+ self.assertTrue(self._machine)
+
+ def _reachedStable(self):
+ self.app.quit()
+
+ def test(self):
+ self._machine.start()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtScxml/trafficlight.scxml b/sources/pyside2/tests/QtScxml/trafficlight.scxml
new file mode 100644
index 000000000..1b0fb6e9a
--- /dev/null
+++ b/sources/pyside2/tests/QtScxml/trafficlight.scxml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of Qt for Python.
+**
+** $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$
+**
+****************************************************************************/
+-->
+<scxml
+ xmlns="http://www.w3.org/2005/07/scxml"
+ xmlns:qt="http://theqtcompany.com/scxml/2015/06/"
+ version="1.0"
+ name="TrafficLightStateMachine"
+ initial="working"
+>
+ <state id="working" initial="yellow">
+ <state id="red">
+ <onentry>
+ <send event="startGoingGreen" delay="3s"/>
+ </onentry>
+ <transition event="startGoingGreen" target="redGoingGreen"/>
+ </state>
+
+ <state id="yellow" initial="greenGoingRed">
+ <state id="redGoingGreen">
+ <onentry>
+ <send event="goGreen" delay="1s"/>
+ </onentry>
+ <transition event="goGreen" target="green"/>
+ </state>
+
+ <state id="greenGoingRed">
+ <onentry>
+ <send event="goRed" delay="1s"/>
+ </onentry>
+ <transition event="goRed" target="red"/>
+ </state>
+ </state>
+
+ <state id="green">
+ <onentry>
+ <send event="startGoingRed" delay="3s"/>
+ </onentry>
+ <transition event="startGoingRed" target="greenGoingRed"/>
+ </state>
+
+ <transition event="smash" target="broken"/>
+ </state>
+
+ <state id="broken" initial="blinking">
+ <state id="blinking">
+ <onentry>
+ <send event="unblink" delay="1s"/>
+ </onentry>
+ <transition event="unblink" target="unblinking"/>
+ </state>
+
+ <state id="unblinking">
+ <onentry>
+ <send event="blink" delay="1s"/>
+ </onentry>
+ <transition event="blink" target="blinking"/>
+ </state>
+
+ <transition event="repair" target="working"/>
+ </state>
+</scxml>