summaryrefslogtreecommitdiffstats
path: root/src/scxml
diff options
context:
space:
mode:
Diffstat (limited to 'src/scxml')
-rw-r--r--src/scxml/CMakeLists.txt56
-rw-r--r--src/scxml/Qt5ScxmlConfigExtras.cmake.in48
-rw-r--r--src/scxml/Qt5ScxmlMacros.cmake68
-rw-r--r--src/scxml/Qt6ScxmlMacros.cmake79
-rw-r--r--src/scxml/configure.cmake28
-rw-r--r--src/scxml/configure.json21
-rw-r--r--src/scxml/doc/external-resources.qdoc28
-rw-r--r--src/scxml/doc/qt6-changes.qdoc45
-rw-r--r--src/scxml/doc/qtscxml-cmake-macros.qdoc29
-rw-r--r--src/scxml/doc/qtscxml-examples.qdoc46
-rw-r--r--src/scxml/doc/qtscxml-index.qdoc60
-rw-r--r--src/scxml/doc/qtscxml-instantiating-state-machines.qdoc68
-rw-r--r--src/scxml/doc/qtscxml-module-cpp.qdoc45
-rw-r--r--src/scxml/doc/qtscxml-module-qml.qdoc36
-rw-r--r--src/scxml/doc/qtscxml-module-use.qdocinc30
-rw-r--r--src/scxml/doc/qtscxml-overview.qdoc33
-rw-r--r--src/scxml/doc/qtscxml-scxml-compliance.qdoc28
-rw-r--r--src/scxml/doc/qtscxml.qdocconf30
-rw-r--r--src/scxml/qscxmlcompiler.cpp197
-rw-r--r--src/scxml/qscxmlcompiler.h42
-rw-r--r--src/scxml/qscxmlcompiler_p.h95
-rw-r--r--src/scxml/qscxmlcppdatamodel.cpp48
-rw-r--r--src/scxml/qscxmlcppdatamodel.h40
-rw-r--r--src/scxml/qscxmlcppdatamodel_p.h40
-rw-r--r--src/scxml/qscxmldatamodel.cpp100
-rw-r--r--src/scxml/qscxmldatamodel.h51
-rw-r--r--src/scxml/qscxmldatamodel_p.h59
-rw-r--r--src/scxml/qscxmldatamodelplugin.cpp13
-rw-r--r--src/scxml/qscxmldatamodelplugin_p.h36
-rw-r--r--src/scxml/qscxmlecmascriptdatamodel.cpp576
-rw-r--r--src/scxml/qscxmlecmascriptdatamodel.h80
-rw-r--r--src/scxml/qscxmlecmascriptplatformproperties.cpp101
-rw-r--r--src/scxml/qscxmlecmascriptplatformproperties_p.h93
-rw-r--r--src/scxml/qscxmlerror.cpp40
-rw-r--r--src/scxml/qscxmlerror.h40
-rw-r--r--src/scxml/qscxmlevent.cpp44
-rw-r--r--src/scxml/qscxmlevent.h40
-rw-r--r--src/scxml/qscxmlevent_p.h40
-rw-r--r--src/scxml/qscxmlexecutablecontent.cpp50
-rw-r--r--src/scxml/qscxmlexecutablecontent.h40
-rw-r--r--src/scxml/qscxmlexecutablecontent_p.h50
-rw-r--r--src/scxml/qscxmlglobals.h52
-rw-r--r--src/scxml/qscxmlglobals_p.h41
-rw-r--r--src/scxml/qscxmlinvokableservice.cpp68
-rw-r--r--src/scxml/qscxmlinvokableservice.h60
-rw-r--r--src/scxml/qscxmlinvokableservice_p.h56
-rw-r--r--src/scxml/qscxmlnulldatamodel.cpp42
-rw-r--r--src/scxml/qscxmlnulldatamodel.h40
-rw-r--r--src/scxml/qscxmlstatemachine.cpp342
-rw-r--r--src/scxml/qscxmlstatemachine.h200
-rw-r--r--src/scxml/qscxmlstatemachine_p.h114
-rw-r--r--src/scxml/qscxmlstatemachineinfo.cpp64
-rw-r--r--src/scxml/qscxmlstatemachineinfo_p.h59
-rw-r--r--src/scxml/qscxmltabledata.cpp110
-rw-r--r--src/scxml/qscxmltabledata.h42
-rw-r--r--src/scxml/qscxmltabledata_p.h61
-rw-r--r--src/scxml/qt_cmdline.cmake0
-rw-r--r--src/scxml/scxml.pro73
58 files changed, 1104 insertions, 3013 deletions
diff --git a/src/scxml/CMakeLists.txt b/src/scxml/CMakeLists.txt
new file mode 100644
index 0000000..ee5b743
--- /dev/null
+++ b/src/scxml/CMakeLists.txt
@@ -0,0 +1,56 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+
+#####################################################################
+## Scxml Module:
+#####################################################################
+
+qt_internal_include_in_repo_target_set(qtscxml)
+
+qt_internal_add_module(Scxml
+ QMAKE_MODULE_CONFIG c++11 qscxmlc
+ PLUGIN_TYPES scxmldatamodel
+ SOURCES
+ qscxmlcompiler.cpp qscxmlcompiler.h qscxmlcompiler_p.h
+ qscxmlcppdatamodel.cpp qscxmlcppdatamodel.h qscxmlcppdatamodel_p.h
+ qscxmldatamodel.cpp qscxmldatamodel.h qscxmldatamodel_p.h
+ qscxmlerror.cpp qscxmlerror.h
+ qscxmlevent.cpp qscxmlevent.h qscxmlevent_p.h
+ qscxmlexecutablecontent.cpp qscxmlexecutablecontent.h qscxmlexecutablecontent_p.h
+ qscxmlglobals.h qscxmlglobals_p.h
+ qscxmlinvokableservice.cpp qscxmlinvokableservice.h qscxmlinvokableservice_p.h
+ qscxmlnulldatamodel.cpp qscxmlnulldatamodel.h
+ qscxmlstatemachine.cpp qscxmlstatemachine.h qscxmlstatemachine_p.h
+ qscxmlstatemachineinfo.cpp qscxmlstatemachineinfo_p.h
+ qscxmltabledata.cpp qscxmltabledata.h qscxmltabledata_p.h
+ qscxmldatamodelplugin_p.h qscxmldatamodelplugin.cpp
+ DEFINES
+ QT_NO_CAST_FROM_ASCII
+ QT_NO_CAST_TO_ASCII
+ LIBRARIES
+ Qt::CorePrivate
+ PUBLIC_LIBRARIES
+ Qt::Core
+ PRIVATE_MODULE_INTERFACE
+ Qt::CorePrivate
+)
+
+# Install the public qscxlmc.prf file that is used by the qmake
+set(scxml_mkspecs "${CMAKE_CURRENT_SOURCE_DIR}/../../mkspecs/features/qscxmlc.prf")
+set(mkspecs_install_dir "${INSTALL_MKSPECSDIR}")
+qt_path_join(mkspecs_install_dir "${QT_INSTALL_DIR}" "${mkspecs_install_dir}" "features")
+qt_copy_or_install(FILES "${scxml_mkspecs}" DESTINATION ${mkspecs_install_dir})
+
+#### Keys ignored in scope 3:.:.:scxml.pro:NOT force_independent AND ( NOT debug_and_release OR NOT build_all OR CONFIG(release,debug OR release) ):
+# QMAKE_EXTRA_COMPILERS = "prf2build"
+# prf2build.CONFIG = "no_link" "no_clean" "target_predeps"
+# prf2build.commands = "$$QMAKE_COPY" "${QMAKE_FILE_IN}" "${QMAKE_FILE_OUT}"
+# prf2build.input = "FEATURES"
+# prf2build.name = "COPY" "${QMAKE_FILE_IN}"
+# prf2build.output = "$$[QT_INSTALL_DATA/get]/mkspecs/features/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}"
+qt_internal_add_docs(Scxml
+ doc/qtscxml.qdocconf
+)
+
+include(Qt6ScxmlMacros.cmake)
diff --git a/src/scxml/Qt5ScxmlConfigExtras.cmake.in b/src/scxml/Qt5ScxmlConfigExtras.cmake.in
index edb320a..716c64e 100644
--- a/src/scxml/Qt5ScxmlConfigExtras.cmake.in
+++ b/src/scxml/Qt5ScxmlConfigExtras.cmake.in
@@ -1,40 +1,5 @@
-#
# Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
-# Contact: https://www.qt.io/licensing/
-#
-# This file is part of the QtScxml module of the Qt Toolkit.
-#
-# $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$
-
-if (NOT TARGET Qt5::qscxmlc)
+# SPDX-License-Identifier: BSD-3-Clause
add_executable(Qt5::qscxmlc IMPORTED)
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
@@ -49,3 +14,14 @@ if (NOT TARGET Qt5::qscxmlc)
)
get_target_property(Qt5Scxml_QSCXMLC_EXECUTABLE Qt5::qscxmlc LOCATION)
endif()
+
+# Create versionless tool targets.
+foreach(__qt_tool qscxmlc)
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::${__qt_tool}
+ AND TARGET Qt5::${__qt_tool})
+ add_executable(Qt::${__qt_tool} IMPORTED)
+ get_target_property(__qt_imported_location Qt5::${__qt_tool} IMPORTED_LOCATION)
+ set_target_properties(Qt::${__qt_tool}
+ PROPERTIES IMPORTED_LOCATION \"${__qt_imported_location}\")
+ endif()
+endforeach()
diff --git a/src/scxml/Qt5ScxmlMacros.cmake b/src/scxml/Qt5ScxmlMacros.cmake
deleted file mode 100644
index c4454ec..0000000
--- a/src/scxml/Qt5ScxmlMacros.cmake
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
-# Contact: https://www.qt.io/licensing/
-#
-# This file is part of the QtScxml module of the Qt Toolkit.
-#
-# $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$
-
-if(NOT Qt5Scxml_QSCXMLC_EXECUTABLE)
- message(FATAL_ERROR "qscxmlc executable not found -- Check installation.")
-endif()
-
-# qt5_add_statecharts(outfiles inputfile ... )
-
-function(qt5_add_statecharts outfiles)
- set(options)
- set(oneValueArgs)
- set(multiValueArgs OPTIONS)
-
- cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- set(scxml_files ${ARGS_UNPARSED_ARGUMENTS})
-
- foreach(it ${scxml_files})
- get_filename_component(outfilename ${it} NAME_WE)
- get_filename_component(infile ${it} ABSOLUTE)
- set(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfilename})
- set(outfile_cpp ${CMAKE_CURRENT_BINARY_DIR}/${outfilename}.cpp)
- set(outfile_h ${CMAKE_CURRENT_BINARY_DIR}/${outfilename}.h)
-
- add_custom_command(OUTPUT ${outfile_cpp} ${outfile_h}
- COMMAND ${Qt5Scxml_QSCXMLC_EXECUTABLE}
- ARGS ${ARGS_OPTIONS} --output ${outfile} ${infile}
- MAIN_DEPENDENCY ${infile}
- VERBATIM)
- list(APPEND ${outfiles} ${outfile_cpp})
- endforeach()
- set_source_files_properties(${outfiles} PROPERTIES SKIP_AUTOMOC TRUE)
- set(${outfiles} ${${outfiles}} PARENT_SCOPE)
-endfunction()
diff --git a/src/scxml/Qt6ScxmlMacros.cmake b/src/scxml/Qt6ScxmlMacros.cmake
new file mode 100644
index 0000000..c99d845
--- /dev/null
+++ b/src/scxml/Qt6ScxmlMacros.cmake
@@ -0,0 +1,79 @@
+# Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+function(qt6_add_statecharts target_or_outfiles)
+ set(options)
+ set(oneValueArgs OUTPUT_DIR OUTPUT_DIRECTORY NAMESPACE)
+ set(multiValueArgs QSCXMLC_ARGUMENTS OPTIONS)
+
+ cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ set(scxml_files ${ARGS_UNPARSED_ARGUMENTS})
+ set(outfiles)
+
+ if (ARGS_NAMESPACE)
+ set(namespace "--namespace" ${ARGS_NAMESPACE})
+ endif()
+
+ if (ARGS_OUTPUT_DIR)
+ message(AUTHOR_WARNING
+ "OUTPUT_DIR is deprecated. Please use OUTPUT_DIRECTORY instead.")
+ set(ARGS_OUTPUT_DIRECTORY ${ARGS_OUTPUT_DIR})
+ endif()
+
+ if (ARGS_QSCXMLC_ARGUMENTS)
+ message(AUTHOR_WARNING
+ "QSCXMLC_ARGUMENTS is deprecated. Please use OPTIONS instead.")
+ set(ARGS_OPTIONS ${ARGS_QSCXMLC_ARGUMENTS})
+ endif()
+
+ set(qscxmlcOutputDir ${CMAKE_CURRENT_BINARY_DIR})
+ if (ARGS_OUTPUT_DIRECTORY)
+ set(qscxmlcOutputDir ${ARGS_OUTPUT_DIRECTORY})
+ if (NOT EXISTS "${qscxmlcOutputDir}" OR NOT IS_DIRECTORY "${qscxmlcOutputDir}")
+ message(WARNING
+ "qt6_add_statecharts: output dir does not exist: \"" ${qscxmlcOutputDir} "\". "
+ "Statechart code generation may fail on some platforms." )
+ endif()
+ endif()
+
+ _qt_internal_get_tool_wrapper_script_path(tool_wrapper)
+ set(qscxmlc_bin "${tool_wrapper}" "$<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::qscxmlc>")
+
+ set(outfiles)
+ foreach(it ${scxml_files})
+ get_filename_component(outfilename ${it} NAME_WE)
+ get_filename_component(infile ${it} ABSOLUTE)
+ set(outfile ${qscxmlcOutputDir}/${outfilename})
+ set(outfile_cpp ${outfile}.cpp)
+ set(outfile_h ${outfile}.h)
+
+ add_custom_command(OUTPUT ${outfile_cpp} ${outfile_h}
+ COMMAND
+ ${qscxmlc_bin} ${namespace} ${ARGS_OPTIONS}
+ --output ${outfile} ${infile}
+ DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::qscxmlc
+ MAIN_DEPENDENCY ${infile}
+ VERBATIM)
+ set_source_files_properties(${outfile_cpp} ${outfile_h} PROPERTIES SKIP_AUTOGEN TRUE)
+ list(APPEND outfiles ${outfile_cpp})
+ endforeach()
+ if (TARGET ${target_or_outfiles})
+ target_include_directories(${target_or_outfiles} PRIVATE ${qscxmlcOutputDir})
+ target_sources(${target_or_outfiles} PRIVATE ${outfiles})
+ else()
+ set(${target_or_outfiles} ${outfiles} PARENT_SCOPE)
+ endif()
+endfunction()
+
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_statecharts outfiles)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_statecharts("${outfiles}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_statecharts("${outfiles}" ${ARGN})
+ endif()
+ set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
+ endfunction()
+endif()
diff --git a/src/scxml/configure.cmake b/src/scxml/configure.cmake
new file mode 100644
index 0000000..55fc1d5
--- /dev/null
+++ b/src/scxml/configure.cmake
@@ -0,0 +1,28 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+
+
+#### Inputs
+
+
+
+#### Libraries
+
+
+
+#### Tests
+
+
+
+#### Features
+
+qt_feature("scxml-ecmascriptdatamodel" PUBLIC
+ SECTION "SCXML"
+ LABEL "ECMAScript data model for QtScxml"
+ PURPOSE "Enables the usage of ecmascript data models in SCXML state machines."
+ CONDITION TARGET Qt::Qml # special case
+)
+qt_configure_add_summary_section(NAME "Qt Scxml")
+qt_configure_add_summary_entry(ARGS "scxml-ecmascriptdatamodel")
+qt_configure_end_summary_section() # end of "Qt Scxml" section
diff --git a/src/scxml/configure.json b/src/scxml/configure.json
deleted file mode 100644
index 288373d..0000000
--- a/src/scxml/configure.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "module": "scxml",
-
- "features": {
- "scxml-ecmascriptdatamodel": {
- "label": "ECMAScript data model for QtScxml",
- "purpose": "Enables the usage of ecmascript data models in SCXML state machines.",
- "section": "SCXML",
- "output": [ "publicFeature" ]
- }
- },
-
- "summary": [
- {
- "section": "Qt Scxml",
- "entries": [
- "scxml-ecmascriptdatamodel"
- ]
- }
- ]
-}
diff --git a/src/scxml/doc/external-resources.qdoc b/src/scxml/doc/external-resources.qdoc
index 39a1c3b..10650fa 100644
--- a/src/scxml/doc/external-resources.qdoc
+++ b/src/scxml/doc/external-resources.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\externalpage http://www.w3.org/TR/scxml/
\title SCXML Specification
diff --git a/src/scxml/doc/qt6-changes.qdoc b/src/scxml/doc/qt6-changes.qdoc
new file mode 100644
index 0000000..da14af4
--- /dev/null
+++ b/src/scxml/doc/qt6-changes.qdoc
@@ -0,0 +1,45 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \page qtscxml-changes-qt6.html
+ \title Changes to Qt SCXML
+ \ingroup changes-qt-5-to-6
+ \brief Migrate Qt SCXML to Qt 6.
+
+ Qt 6 is a result of the conscious effort to make the framework more
+ efficient and easy to use.
+
+ We try to maintain binary and source compatibility for all the public
+ APIs in each release. But some changes were inevitable in an effort to
+ make Qt a better framework.
+
+ In this topic we summarize those changes in Qt SCXML module, and provide
+ guidance to handle them.
+
+ \section1 Changes overview
+
+ The Qt SCXML module is largely source compatible with the Qt5
+ version and users of the library should be able to continue with no or
+ minor changes to their project.
+
+ \section1 API changes
+
+ \section2 QScxmlEcmaScriptDataModel API removal
+
+ The ecmascript datamodel, when enabled, introduces a dependency to the Qt QML library.
+ In Qt5 this depedendency is created at build time, whereas in Qt6 the dependency
+ is moved to runtime (internally a plugin). As a consequence the
+ QScxmlEcmaScriptDataModel class is no longer part of the public API.
+
+ \section1 Build system
+
+ As with Qt6 in general, the Qt SCXML module has cmake support in addition
+ to qmake.
+
+ \section1 QML imports
+
+ The QML import versioning is optional unless one has a specific
+ reason for not using the latest. Generally speaking the versioned imports
+ work from version 5.8 to 6.x, where 'x' is the current minor release.
+*/
diff --git a/src/scxml/doc/qtscxml-cmake-macros.qdoc b/src/scxml/doc/qtscxml-cmake-macros.qdoc
new file mode 100644
index 0000000..1a182cb
--- /dev/null
+++ b/src/scxml/doc/qtscxml-cmake-macros.qdoc
@@ -0,0 +1,29 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+\page qtscxml-cmake-qt-add-statecharts.html
+\ingroup cmake-macros-qtscxml
+
+\title qt_add_statecharts
+\target qt6_add_statecharts
+
+\cmakecommandsince 6.1
+
+\section1 Description
+
+The \c qt6_add_statecharts macro instructs CMake to invoke the qscxmlc tool to
+read the provided .scxml files and produce C++ source and header files,
+that contain the classes that implement the state machines as defined in SCXML.
+
+\section1 Synopsis
+
+\badcode
+qt6_add_statecharts(<TARGET> file1.scxml [file2.scxml ...]
+ [OPTIONS ...])
+\endcode
+
+For further instructions, options and examples please refer to
+\l {Using the Qt SCXML Compiler (qscxmlc)}
+
+*/
diff --git a/src/scxml/doc/qtscxml-examples.qdoc b/src/scxml/doc/qtscxml-examples.qdoc
index cc0b6c4..e645bd6 100644
--- a/src/scxml/doc/qtscxml-examples.qdoc
+++ b/src/scxml/doc/qtscxml-examples.qdoc
@@ -1,49 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\group examples-qtscxml
\title Qt SCXML Examples
\brief Examples for the Qt SCXML module.
-\ingroup all-examples
The Qt SCXML example applications demonstrate the functionality provided by the
\l{Qt SCXML} module.
-There are multiple versions of the \e Invoke, \e {Media Player}, and
-\e {Traffic Light} example applications. Each application has some common files
-that are stored in a common folder, in addition to the files stored in the
-example version folder.
+There are multiple versions of the \e {Traffic Light} example application.
+The application has shared common files, and in addition specific files for
+each version of the application, under their respective folders. They demonstrate
+the different options for creating user interfaces (using \l {Qt Widgets}
+or \l {Qt Quick}) and for loading the SCXML dynamically versus first compiling
+it to a C++ class (the \e static versions).
-All versions of an example application have the same appearance and
-fuctionality. They demonstrate the different options for creating user
-interfaces (using \l {Qt Widgets} or \l {Qt Quick}) and for loading the SCXML
-dynamically versus first compiling it to a C++ class (the \e static versions).
-
-In addition, the Media Player example versions demonstrate how to access the C++
-and ECMAScript data models.
*/
diff --git a/src/scxml/doc/qtscxml-index.qdoc b/src/scxml/doc/qtscxml-index.qdoc
index b65a1c2..ca088e0 100644
--- a/src/scxml/doc/qtscxml-index.qdoc
+++ b/src/scxml/doc/qtscxml-index.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtscxml-index.html
@@ -39,24 +15,20 @@
\section1 Getting Started
- To include the definitions of the module's classes, use the following directive:
-
- \code
- #include <QScxmlStateMachine>
- \endcode
-
To import the QML types into your application, use the following import statement
in your .qml file:
- \qml \QtMinorVersion
- import QtScxml 5.\1
+ \qml
+ import QtScxml
\endqml
- To link against the module, add this line to your qmake .pro file:
+ To link against the module:
+
+ Using cmake:
+ \include qtscxml-module-use.qdocinc cmakebuild
- \code
- QT += scxml
- \endcode
+ Using qmake:
+ \include qtscxml-module-use.qdocinc qmakebuild
\section1 Articles and Guides
@@ -79,4 +51,16 @@
\li \l {Qt SCXML C++ Classes} {C++ Classes and Namespaces}
\li \l {Qt SCXML QML Types} {QML Types}
\endlist
+
+ \section1 Module Evolution
+ \l{Changes to Qt SCXML} lists important changes in the module API
+ and functionality that were done for the Qt 6 series of Qt.
+
+ \section1 Licenses and Trademarks
+
+ The Qt SCXML module is available under commercial licenses from
+ \l{The Qt Company}. In addition, it is available under free software licenses:
+ The \l{GNU Lesser General Public License, version 3}, or
+ the \l{GNU General Public License, version 2}.
+ See \l{Qt Licensing} for further details.
*/
diff --git a/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc b/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc
index 37cff10..51c51e2 100644
--- a/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc
+++ b/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtscxml-instantiating-state-machines.html
@@ -43,7 +19,7 @@
Or, in QML:
\qml
- import QtScxml 5.8
+ import QtScxml
Item {
property StateMachine stateMachine: scxmlLoader.stateMachine
@@ -71,7 +47,12 @@
To use a compiled state machine in QML, you can register it as a QML type:
\code
- qmlRegisterType<MyStateMachine>("MyStateMachine", 1, 0, "MyStateMachine");
+ struct MyStateMachineRegistration {
+ Q_GADGET
+ QML_NAMED_ELEMENT(MyStateMachine)
+ QML_FOREIGN(MyStateMachine)
+ QML_ADDED_IN_VERSION(1, 0)
+ };
\endcode
Then you can instantiate it in QML, like this:
@@ -84,19 +65,25 @@
}
\endqml
- To compile a state machine, the following lines have to be added to a
- .pro file:
+ To compile a state machine, the following lines have to be added to the
+ project build file:
- \badcode
- QT += scxml
- STATECHARTS = MyStatemachine.scxml
- \endcode
+ When using cmake:
+
+ \include qtscxml-module-use.qdocinc cmakebuild
+ \include qtscxml-module-use.qdocinc cmakestatecharts
+
+ When using qmake:
+
+ \include qtscxml-module-use.qdocinc qmakebuild
+ \include qtscxml-module-use.qdocinc qmakestatecharts
This will tell qmake to run \e qscxmlc which generates MyStatemachine.h
- and MyStatemachine.cpp, and adds them to \l [QMake] HEADERS and
- \l [QMake] SOURCES variables. By default, the generated files are saved in
- the build directory. The \e QSCXMLC_DIR variable can be set to specify
- another directory. The \e QSCXMLC_NAMESPACE variable can be set to put the
+ and MyStatemachine.cpp, and adds them to appropriately to the project
+ headers and sources. By default, the generated files are saved in
+ the build directory. The qmake \e QSCXMLC_DIR or cmake \e OUTPUT_DIRECTORY
+ variable can be set to specify another directory. The qmake
+ \e QSCXMLC_NAMESPACE or cmake \e NAMESPACE variable can be set to put the
state machine code into a C++ namespace.
After instantiating a state machine, you can connect to any state's
@@ -107,6 +94,7 @@
\code
stateMachine->connectToState("red", [](bool active) {
qDebug() << (active ? "entered" : "exited") << "the red state";
+ });
\endcode
And in QML:
@@ -133,7 +121,7 @@
And in QML:
\qml
- import QtScxml 5.8
+ import QtScxml
EventConnection {
stateMachine: stateMachine
@@ -148,7 +136,7 @@
stateMachine->submitEvent("tap", QVariantMap({
{ "artist", "Fatboy Slim" },
{ "title", "The Rockafeller Skank" }
- });
+ }));
\endcode
This will generate a "tap" event with the map contents available in
diff --git a/src/scxml/doc/qtscxml-module-cpp.qdoc b/src/scxml/doc/qtscxml-module-cpp.qdoc
index 88002ca..2161f08 100644
--- a/src/scxml/doc/qtscxml-module-cpp.qdoc
+++ b/src/scxml/doc/qtscxml-module-cpp.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\module QtScxml
@@ -33,18 +9,15 @@
\ingroup modules
\ingroup technology-apis
\qtvariable scxml
+ \qtcmakepackage Scxml
- To include the definitions of the module's classes, use the following directive:
+ To use the module with cmake, use the \c{find_package()} command to locate the
+ needed module components in the \c{Qt6} package:
+ \include qtscxml-module-use.qdocinc cmakebuild
- \code
- #include <QScxmlStateMachine>
- \endcode
-
- To link against the module, add this line to your qmake .pro file:
-
- \code
- QT += scxml
- \endcode
+ To configure the module for building with qmake, add the module as a value
+ of the \c QT variable in the project's .pro file:
+ \include qtscxml-module-use.qdocinc qmakebuild
For more information, see \l{Instantiating State Machines}.
*/
diff --git a/src/scxml/doc/qtscxml-module-qml.qdoc b/src/scxml/doc/qtscxml-module-qml.qdoc
index 5fdae36..5bddabc 100644
--- a/src/scxml/doc/qtscxml-module-qml.qdoc
+++ b/src/scxml/doc/qtscxml-module-qml.qdoc
@@ -1,32 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \qmlmodule QtScxml 5.\QtMinorVersion
+ \qmlmodule QtScxml 6.\QtMinorVersion
\title Qt SCXML QML Types
\ingroup qmlmodules
\brief Enables the use of SCXML state machines with QML.
@@ -34,9 +10,9 @@
To import the QML types into your application, use the following import statement
in your .qml file:
- \code \QtMinorVersion
- import QtScxml 5.\1
- \endcode
+ \qml
+ import QtScxml
+ \endqml
For more information, see \l{Instantiating State Machines}.
*/
diff --git a/src/scxml/doc/qtscxml-module-use.qdocinc b/src/scxml/doc/qtscxml-module-use.qdocinc
new file mode 100644
index 0000000..ba48db0
--- /dev/null
+++ b/src/scxml/doc/qtscxml-module-use.qdocinc
@@ -0,0 +1,30 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+//! [cmakebuild]
+ \code
+ find_package(Qt6 REQUIRED COMPONENTS Scxml)
+ target_link_libraries(mytarget PRIVATE Qt6::Scxml)
+ \endcode
+//! [cmakebuild]
+
+//! [qmakebuild]
+ \code
+ QT += scxml
+ \endcode
+//! [qmakebuild]
+
+//! [qmakestatecharts]
+ \code
+ STATECHARTS = MyStatemachine.scxml
+ \endcode
+//! [qmakestatecharts]
+
+//! [cmakestatecharts]
+ \code
+ qt6_add_statecharts(mytarget
+ MyStatemachine.scxml
+ )
+ \endcode
+//! [cmakestatecharts]
+
diff --git a/src/scxml/doc/qtscxml-overview.qdoc b/src/scxml/doc/qtscxml-overview.qdoc
index dfecb0a..dfbe0bf 100644
--- a/src/scxml/doc/qtscxml-overview.qdoc
+++ b/src/scxml/doc/qtscxml-overview.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtscxml-overview.html
\title Qt SCXML Overview
\brief Describes the Qt SCXML module.
+ \ingroup explanation
The Qt SCXML module provides classes for embedding state machines created
from State Chart XML (SCXML) files in Qt applications. The SCXML files
@@ -40,8 +17,8 @@
file. This enables creating a clear division between the application logic
and the user interface implementation by using Qt Quick or Qt Widgets.
- The Qt SCXML module differs from the \l {The State Machine Framework}
- {State Machine framework} in the Qt Core module in that Qt SCXML provides a
+ The Qt SCXML module differs from the \l {Qt State Machine Overview}
+ {State Machine framework} in the \l{Qt State Machine} module in that Qt SCXML provides a
\e {conforming processor} that can parse and process \e {conforming SCXML
documents}. In Qt SCXML, state machines are read from separate SCXML files
and integrated to Qt applications by instantiating the QScxmlStateMachine
diff --git a/src/scxml/doc/qtscxml-scxml-compliance.qdoc b/src/scxml/doc/qtscxml-scxml-compliance.qdoc
index ab1d730..6721c38 100644
--- a/src/scxml/doc/qtscxml-scxml-compliance.qdoc
+++ b/src/scxml/doc/qtscxml-scxml-compliance.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtscxml-scxml-compliance.html
diff --git a/src/scxml/doc/qtscxml.qdocconf b/src/scxml/doc/qtscxml.qdocconf
index 6d90bd1..b8211e6 100644
--- a/src/scxml/doc/qtscxml.qdocconf
+++ b/src/scxml/doc/qtscxml.qdocconf
@@ -2,30 +2,27 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
include($QT_INSTALL_DOCS/config/exampleurl-qtscxml.qdocconf)
project = QtScxml
-description = Qt Scxml Reference Documentation
+description = Qt SCXML Reference Documentation
version = $QT_VERSION
-# Install path for the examples. For Qt 5.6, the convention
-# is to use the repository name as the install location
-# under QT_INSTALL_EXAMPLES.
+# Install path for the examples
examplesinstallpath = scxml
exampledirs = ../../../examples/scxml
-imagedirs = ../../../examples/doc/images
examples.fileextensions += "*.scxml"
qhp.QtScxml.subprojects = classes qmltypes examples
qhp.QtScxml.subprojects.classes.title = C++ Classes
qhp.QtScxml.subprojects.classes.indexTitle = Qt SCXML C++ Classes
-qhp.QtScxml.subprojects.classes.selectors = class fake:headerfile
+qhp.QtScxml.subprojects.classes.selectors = class headerfile
qhp.QtScxml.subprojects.classes.sortPages = true
qhp.QtScxml.subprojects.qmltypes.title = QML Types
qhp.QtScxml.subprojects.qmltypes.indexTitle = Qt SCXML QML Types
-qhp.QtScxml.subprojects.qmltypes.selectors = qmlclass
+qhp.QtScxml.subprojects.qmltypes.selectors = qmltype
qhp.QtScxml.subprojects.qmltypes.sortPages = true
qhp.QtScxml.subprojects.examples.title = Examples
qhp.QtScxml.subprojects.examples.indexTitle = Qt SCXML Examples
-qhp.QtScxml.subprojects.examples.selectors = fake:example
+qhp.QtScxml.subprojects.examples.selectors = doc:example
qhp.projects = QtScxml
@@ -35,21 +32,24 @@ qhp.QtScxml.virtualFolder = qtscxml
qhp.QtScxml.indexTitle = Qt SCXML
qhp.QtScxml.indexRoot =
-depends += qtcore qtdoc qmake qtquick qtwidgets
+depends += qtcore qtdoc qmake qtquick qtwidgets qtstatemachine qtcmake
+
+headerdirs = .. \
+ ../../scxmlqml \
+ ../../plugins/ecmascriptdatamodel
-headerdirs = .. ../../imports/scxmlstatemachine
sourcedirs += .. \
- ../../imports/scxmlstatemachine \
+ ../../scxmlqml \
../../../tools/qscxmlc/doc \
- ../../../examples/scxml
+ ../../plugins/ecmascriptdatamodel
excludefiles += "../qscxmlexecutablecontent_p.h"
tagfile = qtscxml.tags
-manifestmeta.highlighted.names = "QtScxml/Qt SCXML Calculator QML Example" \
- "QtScxml/Qt SCXML Traffic Light QML Example (Dynamic)"
-
navigation.landingpage = "Qt SCXML"
navigation.cppclassespage = "Qt SCXML C++ Classes"
navigation.qmltypespage = "Qt SCXML QML Types"
+
+# Highlighted examples in Data Processing & IO category
+manifestmeta.highlighted.names = "QtScxml/SCXML Sudoku"
diff --git a/src/scxml/qscxmlcompiler.cpp b/src/scxml/qscxmlcompiler.cpp
index 36967d1..eaf7171 100644
--- a/src/scxml/qscxmlcompiler.cpp
+++ b/src/scxml/qscxmlcompiler.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmlcompiler_p.h"
#include "qscxmlexecutablecontent_p.h"
@@ -43,7 +7,7 @@
#include <qxmlstream.h>
#include <qloggingcategory.h>
#include <qfile.h>
-#include <qvector.h>
+#include <qlist.h>
#include <qstring.h>
#ifndef BUILD_QSCXMLC
@@ -56,6 +20,8 @@
#include <private/qmetaobjectbuilder_p.h>
#endif // BUILD_QSCXMLC
+#include <QtCore/qmap.h>
+
#include <functional>
namespace {
@@ -87,7 +53,7 @@ public:
doc->isVerified = true;
m_doc = doc;
- for (DocumentModel::AbstractState *state : qAsConst(doc->allStates)) {
+ for (DocumentModel::AbstractState *state : std::as_const(doc->allStates)) {
if (state->id.isEmpty()) {
continue;
#ifndef QT_NO_DEBUG
@@ -117,8 +83,8 @@ private:
scxml->initialTransition = createInitialTransition({firstChild});
}
} else {
- QVector<DocumentModel::AbstractState *> initialStates;
- for (const QString &initial : qAsConst(scxml->initial)) {
+ QList<DocumentModel::AbstractState *> initialStates;
+ for (const QString &initial : std::as_const(scxml->initial)) {
if (DocumentModel::AbstractState *s = m_stateById.value(initial))
initialStates.append(s);
else
@@ -155,8 +121,8 @@ private:
}
} else {
Q_ASSERT(state->type == DocumentModel::State::Normal);
- QVector<DocumentModel::AbstractState *> initialStates;
- for (const QString &initialState : qAsConst(state->initial)) {
+ QList<DocumentModel::AbstractState *> initialStates;
+ for (const QString &initialState : std::as_const(state->initial)) {
if (DocumentModel::AbstractState *s = m_stateById.value(initialState)) {
initialStates.append(s);
} else {
@@ -207,7 +173,7 @@ private:
if (int size = transition->targets.size())
transition->targetStates.reserve(size);
- for (const QString &target : qAsConst(transition->targets)) {
+ for (const QString &target : std::as_const(transition->targets)) {
if (DocumentModel::AbstractState *s = m_stateById.value(target)) {
if (transition->targetStates.contains(s)) {
error(transition->xmlLocation, QStringLiteral("duplicate target '%1'").arg(target));
@@ -218,7 +184,7 @@ private:
error(transition->xmlLocation, QStringLiteral("unknown state '%1' in target").arg(target));
}
}
- for (const QString &event : qAsConst(transition->events))
+ for (const QString &event : std::as_const(transition->events))
checkEvent(event, transition->xmlLocation, AllowWildCards);
m_parentNodes.append(transition);
@@ -233,7 +199,7 @@ private:
bool visit(DocumentModel::HistoryState *state) override
{
bool seenTransition = false;
- for (DocumentModel::StateOrTransition *sot : qAsConst(state->children)) {
+ for (DocumentModel::StateOrTransition *sot : std::as_const(state->children)) {
if (DocumentModel::State *s = sot->asState()) {
error(s->xmlLocation, QStringLiteral("history state cannot have substates"));
} else if (DocumentModel::Transition *t = sot->asTransition()) {
@@ -298,7 +264,7 @@ private:
if (!isLetter(c) && c != QLatin1Char('_'))
return false;
}
- for (int ei = id.length(); i != ei; ++i) {
+ for (int ei = id.size(); i != ei; ++i) {
const QChar c = id.at(i);
if (isLetter(c) || c.isDigit() || c == QLatin1Char('.') || c == QLatin1Char('-')
|| c == QLatin1Char('_') || isNameTail(c))
@@ -370,12 +336,12 @@ private:
if (part.isEmpty())
return false;
- if (wildCardMode == AllowWildCards && part.length() == 1
+ if (wildCardMode == AllowWildCards && part.size() == 1
&& part.at(0) == QLatin1Char('*')) {
continue;
}
- for (int i = 0, ei = part.length(); i != ei; ++i) {
+ for (int i = 0, ei = part.size(); i != ei; ++i) {
const QChar c = part.at(i);
if (!isLetter(c) && !c.isDigit() && c != QLatin1Char('-') && c != QLatin1Char('_')
&& c != QLatin1Char(':')) {
@@ -387,7 +353,7 @@ private:
return true;
}
- static const QVector<DocumentModel::StateOrTransition *> &allChildrenOfContainer(
+ static const QList<DocumentModel::StateOrTransition *> &allChildrenOfContainer(
DocumentModel::StateContainer *container)
{
if (auto state = container->asState())
@@ -402,8 +368,8 @@ private:
{
const auto &allChildren = allChildrenOfContainer(container);
- QVector<DocumentModel::AbstractState *> childStates;
- for (DocumentModel::StateOrTransition *child : qAsConst(allChildren)) {
+ QList<DocumentModel::AbstractState *> childStates;
+ for (DocumentModel::StateOrTransition *child : std::as_const(allChildren)) {
if (DocumentModel::State *s = child->asState())
return s;
else if (DocumentModel::HistoryState *h = child->asHistoryState())
@@ -412,13 +378,13 @@ private:
return nullptr;
}
- static QVector<DocumentModel::AbstractState *> allAbstractStates(
+ static QList<DocumentModel::AbstractState *> allAbstractStates(
DocumentModel::StateContainer *container)
{
const auto &allChildren = allChildrenOfContainer(container);
- QVector<DocumentModel::AbstractState *> childStates;
- for (DocumentModel::StateOrTransition *child : qAsConst(allChildren)) {
+ QList<DocumentModel::AbstractState *> childStates;
+ for (DocumentModel::StateOrTransition *child : std::as_const(allChildren)) {
if (DocumentModel::State *s = child->asState())
childStates.append(s);
else if (DocumentModel::HistoryState *h = child->asHistoryState())
@@ -428,7 +394,7 @@ private:
}
DocumentModel::Transition *createInitialTransition(
- const QVector<DocumentModel::AbstractState *> &states)
+ const QList<DocumentModel::AbstractState *> &states)
{
auto *newTransition = m_doc->newTransition(nullptr, DocumentModel::XmlLocation(-1, -1));
newTransition->type = DocumentModel::Transition::Synthetic;
@@ -460,7 +426,7 @@ private:
DocumentModel::ScxmlDocument *m_doc;
bool m_hasErrors;
QHash<QString, DocumentModel::AbstractState *> m_stateById;
- QVector<DocumentModel::Node *> m_parentNodes;
+ QList<DocumentModel::Node *> m_parentNodes;
};
#ifndef BUILD_QSCXMLC
@@ -469,8 +435,8 @@ class InvokeDynamicScxmlFactory: public QScxmlInvokableServiceFactory
Q_OBJECT
public:
InvokeDynamicScxmlFactory(const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &namelist,
- const QVector<QScxmlExecutableContent::ParameterInfo> &params)
+ const QList<QScxmlExecutableContent::StringId> &namelist,
+ const QList<QScxmlExecutableContent::ParameterInfo> &params)
: QScxmlInvokableServiceFactory(invokeInfo, namelist, params)
{}
@@ -485,9 +451,31 @@ private:
class DynamicStateMachinePrivate : public QScxmlStateMachinePrivate
{
+ struct DynamicMetaObject : public QAbstractDynamicMetaObject
+ {
+ QMetaObject *toDynamicMetaObject(QObject *) override
+ {
+ return this;
+ }
+
+ int metaCall(QObject *o, QMetaObject::Call c, int id, void **a) override
+ {
+ return o->qt_metacall(c, id, a);
+ }
+ };
+
public:
DynamicStateMachinePrivate() :
- QScxmlStateMachinePrivate(&QScxmlStateMachine::staticMetaObject) {}
+ QScxmlStateMachinePrivate(&QScxmlStateMachine::staticMetaObject)
+ {
+ metaObject = new DynamicMetaObject;
+ }
+
+ void setDynamicMetaObject(const QMetaObject *m) {
+ // Prevent the QML engine from creating a property cache for this thing.
+ static_cast<DynamicMetaObject *>(metaObject)->d = m->d;
+ m_metaObject = m;
+ }
};
class DynamicStateMachine: public QScxmlStateMachine, public QScxmlInternal::GeneratedTableData
@@ -544,7 +532,7 @@ private:
b.setClassName("DynamicStateMachine");
b.setSuperClass(&QScxmlStateMachine::staticMetaObject);
b.setStaticMetacallFunction(qt_static_metacall);
- d->m_metaObject = b.toMetaObject();
+ d->setDynamicMetaObject(b.toMetaObject());
}
void initDynamicParts(const MetaDataInfo &info)
@@ -553,7 +541,7 @@ private:
// Release the temporary QMetaObject.
Q_ASSERT(d->m_metaObject != &QScxmlStateMachine::staticMetaObject);
free(const_cast<QMetaObject *>(d->m_metaObject));
- d->m_metaObject = &QScxmlStateMachine::staticMetaObject;
+ d->setDynamicMetaObject(&QScxmlStateMachine::staticMetaObject);
// Build the real one.
QMetaObjectBuilder b;
@@ -579,7 +567,7 @@ private:
}
// And we're done
- d->m_metaObject = b.toMetaObject();
+ d->setDynamicMetaObject(b.toMetaObject());
}
public:
@@ -588,7 +576,7 @@ public:
Q_D(DynamicStateMachine);
if (d->m_metaObject != &QScxmlStateMachine::staticMetaObject) {
free(const_cast<QMetaObject *>(d->m_metaObject));
- d->m_metaObject = &QScxmlStateMachine::staticMetaObject;
+ d->setDynamicMetaObject(&QScxmlStateMachine::staticMetaObject);
}
}
@@ -602,8 +590,8 @@ public:
DataModelInfo dm;
auto factoryIdCreator = [stateMachine](
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &namelist,
- const QVector<QScxmlExecutableContent::ParameterInfo> &params,
+ const QList<QScxmlExecutableContent::StringId> &namelist,
+ const QList<QScxmlExecutableContent::ParameterInfo> &params,
const QSharedPointer<DocumentModel::ScxmlDocument> &content) -> int {
auto factory = new InvokeDynamicScxmlFactory(invokeInfo, namelist, params);
factory->setContent(content);
@@ -629,7 +617,7 @@ private:
}
private:
- QVector<QScxmlInvokableServiceFactory *> m_allFactoriesById;
+ QList<QScxmlInvokableServiceFactory *> m_allFactoriesById;
int m_propertyCount;
};
@@ -840,7 +828,7 @@ QScxmlStateMachine *QScxmlCompilerPrivate::instantiateStateMachine() const
void QScxmlCompilerPrivate::instantiateDataModel(QScxmlStateMachine *stateMachine) const
{
#ifdef BUILD_QSCXMLC
- Q_UNUSED(stateMachine)
+ Q_UNUSED(stateMachine);
#else
if (!m_errors.isEmpty()) {
qWarning() << "SCXML document has errors";
@@ -864,7 +852,7 @@ void QScxmlCompilerPrivate::instantiateDataModel(QScxmlStateMachine *stateMachin
/*!
* Returns the list of parse errors.
*/
-QVector<QScxmlError> QScxmlCompiler::errors() const
+QList<QScxmlError> QScxmlCompiler::errors() const
{
return d->errors();
}
@@ -1008,7 +996,7 @@ bool QScxmlCompilerPrivate::ParserState::isExecutableContent(ParserState::Kind k
return false;
}
-QScxmlCompilerPrivate::ParserState::Kind QScxmlCompilerPrivate::ParserState::nameToParserStateKind(const QStringRef &name)
+QScxmlCompilerPrivate::ParserState::Kind QScxmlCompilerPrivate::ParserState::nameToParserStateKind(QStringView name)
{
static QMap<QString, ParserState::Kind> nameToKind;
if (nameToKind.isEmpty()) {
@@ -1173,7 +1161,7 @@ void DocumentModel::Param::accept(DocumentModel::NodeVisitor *visitor)
void DocumentModel::DoneData::accept(DocumentModel::NodeVisitor *visitor)
{
if (visitor->visit(this)) {
- for (Param *param : qAsConst(params))
+ for (Param *param : std::as_const(params))
param->accept(visitor);
}
visitor->endVisit(this);
@@ -1246,7 +1234,7 @@ void DocumentModel::State::accept(DocumentModel::NodeVisitor *visitor)
visitor->visit(onExit);
if (doneData)
doneData->accept(visitor);
- for (Invoke *invoke : qAsConst(invokes))
+ for (Invoke *invoke : std::as_const(invokes))
invoke->accept(visitor);
}
visitor->endVisit(this);
@@ -1333,7 +1321,7 @@ bool QScxmlCompilerPrivate::verifyDocument()
this->addError(location, msg);
};
- if (ScxmlVerifier(handler).verify(m_doc.data()))
+ if (ScxmlVerifier(handler).verify(m_doc.get()))
return true;
else
return false;
@@ -1341,7 +1329,7 @@ bool QScxmlCompilerPrivate::verifyDocument()
DocumentModel::ScxmlDocument *QScxmlCompilerPrivate::scxmlDocument() const
{
- return m_doc && m_errors.isEmpty() ? m_doc.data() : nullptr;
+ return m_doc && m_errors.isEmpty() ? m_doc.get() : nullptr;
}
QString QScxmlCompilerPrivate::fileName() const
@@ -1372,7 +1360,7 @@ void QScxmlCompilerPrivate::parseSubDocument(DocumentModel::Invoke *parentInvoke
p.setFileName(fileName);
p.setLoader(loader());
p.d->readDocument();
- parentInvoke->content.reset(p.d->m_doc.take());
+ parentInvoke->content.reset(p.d->m_doc.release());
m_doc->allSubDocuments.append(parentInvoke->content.data());
m_errors.append(p.errors());
}
@@ -1386,7 +1374,7 @@ bool QScxmlCompilerPrivate::parseSubElement(DocumentModel::Invoke *parentInvoke,
p.setLoader(loader());
p.d->resetDocument();
bool ok = p.d->readElement();
- parentInvoke->content.reset(p.d->m_doc.take());
+ parentInvoke->content.reset(p.d->m_doc.release());
m_doc->allSubDocuments.append(parentInvoke->content.data());
m_errors.append(p.errors());
return ok;
@@ -1404,10 +1392,10 @@ bool QScxmlCompilerPrivate::preReadElementScxml()
const QXmlStreamAttributes attributes = m_reader->attributes();
if (attributes.hasAttribute(QStringLiteral("initial"))) {
const QString initial = attributes.value(QStringLiteral("initial")).toString();
- scxml->initial += initial.split(QChar::Space, QString::SkipEmptyParts);
+ scxml->initial += initial.split(QChar::Space, Qt::SkipEmptyParts);
}
- const QStringRef datamodel = attributes.value(QLatin1String("datamodel"));
+ const QStringView datamodel = attributes.value(QLatin1String("datamodel"));
if (datamodel.isEmpty() || datamodel == QLatin1String("null")) {
scxml->dataModel = DocumentModel::Scxml::NullDataModel;
} else if (datamodel == QLatin1String("ecmascript")) {
@@ -1421,7 +1409,7 @@ bool QScxmlCompilerPrivate::preReadElementScxml()
} else {
int lastColon = datamodel.lastIndexOf(QLatin1Char(':'));
if (lastColon == -1) {
- lastColon = datamodel.length();
+ lastColon = datamodel.size();
} else {
scxml->cppDataModelHeaderName = datamodel.mid(lastColon + 1).toString();
}
@@ -1431,7 +1419,7 @@ bool QScxmlCompilerPrivate::preReadElementScxml()
addError(QStringLiteral("Unsupported data model '%1' in scxml")
.arg(datamodel.toString()));
}
- const QStringRef binding = attributes.value(QLatin1String("binding"));
+ const QStringView binding = attributes.value(QLatin1String("binding"));
if (binding.isEmpty() || binding == QLatin1String("early")) {
scxml->binding = DocumentModel::Scxml::EarlyBinding;
} else if (binding == QLatin1String("late")) {
@@ -1441,7 +1429,7 @@ bool QScxmlCompilerPrivate::preReadElementScxml()
.arg(binding.toString()));
return false;
}
- const QStringRef name = attributes.value(QLatin1String("name"));
+ const QStringView name = attributes.value(QLatin1String("name"));
if (!name.isEmpty()) {
scxml->name = name.toString();
}
@@ -1460,7 +1448,7 @@ bool QScxmlCompilerPrivate::preReadElementState()
if (attributes.hasAttribute(QStringLiteral("initial"))) {
const QString initial = attributes.value(QStringLiteral("initial")).toString();
- newState->initial += initial.split(QChar::Space, QString::SkipEmptyParts);
+ newState->initial += initial.split(QChar::Space, Qt::SkipEmptyParts);
}
m_currentState = newState;
return true;
@@ -1525,11 +1513,11 @@ bool QScxmlCompilerPrivate::preReadElementTransition()
}
const QXmlStreamAttributes attributes = m_reader->attributes();
- transition->events = attributes.value(QLatin1String("event")).toString().split(QLatin1Char(' '), QString::SkipEmptyParts);
- transition->targets = attributes.value(QLatin1String("target")).toString().split(QLatin1Char(' '), QString::SkipEmptyParts);
+ transition->events = attributes.value(QLatin1String("event")).toString().split(QLatin1Char(' '), Qt::SkipEmptyParts);
+ transition->targets = attributes.value(QLatin1String("target")).toString().split(QLatin1Char(' '), Qt::SkipEmptyParts);
if (attributes.hasAttribute(QStringLiteral("cond")))
transition->condition.reset(new QString(attributes.value(QLatin1String("cond")).toString()));
- QStringRef type = attributes.value(QLatin1String("type"));
+ QStringView type = attributes.value(QLatin1String("type"));
if (type.isEmpty() || type == QLatin1String("external")) {
transition->type = DocumentModel::Transition::External;
} else if (type == QLatin1String("internal")) {
@@ -1565,7 +1553,7 @@ bool QScxmlCompilerPrivate::preReadElementHistory()
if (!maybeId(attributes, &newState->id))
return false;
- const QStringRef type = attributes.value(QLatin1String("type"));
+ const QStringView type = attributes.value(QLatin1String("type"));
if (type.isEmpty() || type == QLatin1String("shallow")) {
newState->type = DocumentModel::HistoryState::Shallow;
} else if (type == QLatin1String("deep")) {
@@ -1813,7 +1801,7 @@ bool QScxmlCompilerPrivate::preReadElementSend()
send->target = attributes.value(QLatin1String("target")).toString();
send->targetexpr = attributes.value(QLatin1String("targetexpr")).toString();
if (attributes.hasAttribute(QLatin1String("namelist")))
- send->namelist = attributes.value(QLatin1String("namelist")).toString().split(QLatin1Char(' '), QString::SkipEmptyParts);
+ send->namelist = attributes.value(QLatin1String("namelist")).toString().split(QLatin1Char(' '), Qt::SkipEmptyParts);
current().instruction = send;
return true;
}
@@ -1845,16 +1833,16 @@ bool QScxmlCompilerPrivate::preReadElementInvoke()
invoke->idLocation = attributes.value(QLatin1String("idlocation")).toString();
invoke->type = attributes.value(QLatin1String("type")).toString();
invoke->typeexpr = attributes.value(QLatin1String("typeexpr")).toString();
- QStringRef autoforwardS = attributes.value(QLatin1String("autoforward"));
- if (QStringRef::compare(autoforwardS, QLatin1String("true"), Qt::CaseInsensitive) == 0
- || QStringRef::compare(autoforwardS, QLatin1String("yes"), Qt::CaseInsensitive) == 0
- || QStringRef::compare(autoforwardS, QLatin1String("t"), Qt::CaseInsensitive) == 0
- || QStringRef::compare(autoforwardS, QLatin1String("y"), Qt::CaseInsensitive) == 0
+ QStringView autoforwardS = attributes.value(QLatin1String("autoforward"));
+ if (autoforwardS.compare(QLatin1String("true"), Qt::CaseInsensitive) == 0
+ || autoforwardS.compare(QLatin1String("yes"), Qt::CaseInsensitive) == 0
+ || autoforwardS.compare(QLatin1String("t"), Qt::CaseInsensitive) == 0
+ || autoforwardS.compare(QLatin1String("y"), Qt::CaseInsensitive) == 0
|| autoforwardS == QLatin1String("1"))
invoke->autoforward = true;
else
invoke->autoforward = false;
- invoke->namelist = attributes.value(QLatin1String("namelist")).toString().split(QLatin1Char(' '), QString::SkipEmptyParts);
+ invoke->namelist = attributes.value(QLatin1String("namelist")).toString().split(QLatin1Char(' '), Qt::SkipEmptyParts);
current().instruction = invoke;
return true;
}
@@ -2060,6 +2048,9 @@ bool QScxmlCompilerPrivate::postReadElementScript()
scriptI->content = QString::fromUtf8(data);
}
}
+ } else {
+ addError(scriptI->xmlLocation,
+ QStringLiteral("neither src nor any content has been given in the script tag"));
}
return flushInstruction();
}
@@ -2113,7 +2104,7 @@ bool QScxmlCompilerPrivate::readDocument()
for (bool finished = false; !finished && !m_reader->hasError();) {
switch (m_reader->readNext()) {
case QXmlStreamReader::StartElement : {
- const QStringRef newTag = m_reader->name();
+ const QStringView newTag = m_reader->name();
const ParserState::Kind newElementKind = ParserState::nameToParserStateKind(newTag);
auto ns = m_reader->namespaceUri();
@@ -2154,7 +2145,7 @@ bool QScxmlCompilerPrivate::readDocument()
bool QScxmlCompilerPrivate::readElement()
{
- const QStringRef currentTag = m_reader->name();
+ const QStringView currentTag = m_reader->name();
const QXmlStreamAttributes attributes = m_reader->attributes();
const ParserState::Kind elementKind = ParserState::nameToParserStateKind(currentTag);
@@ -2177,7 +2168,7 @@ bool QScxmlCompilerPrivate::readElement()
return parseSubElement(i, m_reader, m_fileName);
}
- if (elementKind != ParserState::Scxml && !m_stack.count()) {
+ if (elementKind != ParserState::Scxml && !m_stack.size()) {
addError(QStringLiteral("misplaced %1").arg(currentTag.toString()));
return false;
}
@@ -2219,7 +2210,7 @@ bool QScxmlCompilerPrivate::readElement()
for (bool finished = false; !finished && !m_reader->hasError();) {
switch (m_reader->readNext()) {
case QXmlStreamReader::StartElement : {
- const QStringRef newTag = m_reader->name();
+ const QStringView newTag = m_reader->name();
const ParserState::Kind newElementKind = ParserState::nameToParserStateKind(newTag);
auto ns = m_reader->namespaceUri();
@@ -2327,7 +2318,7 @@ QByteArray QScxmlCompilerPrivate::load(const QString &name, bool *ok)
return result;
}
-QVector<QScxmlError> QScxmlCompilerPrivate::errors() const
+QList<QScxmlError> QScxmlCompilerPrivate::errors() const
{
return m_errors;
}
@@ -2394,12 +2385,12 @@ QScxmlCompilerPrivate::ParserState &QScxmlCompilerPrivate::current()
QScxmlCompilerPrivate::ParserState &QScxmlCompilerPrivate::previous()
{
- return m_stack[m_stack.count() - 2];
+ return m_stack[m_stack.size() - 2];
}
bool QScxmlCompilerPrivate::hasPrevious() const
{
- return m_stack.count() > 1;
+ return m_stack.size() > 1;
}
bool QScxmlCompilerPrivate::checkAttributes(const QXmlStreamAttributes &attributes,
@@ -2416,7 +2407,7 @@ bool QScxmlCompilerPrivate::checkAttributes(const QXmlStreamAttributes &attribut
{
QStringList required = requiredNames;
for (const QXmlStreamAttribute &attribute : attributes) {
- const QStringRef ns = attribute.namespaceUri();
+ const QStringView ns = attribute.namespaceUri();
if (!ns.isEmpty() && ns != scxmlNamespace && ns != qtScxmlNamespace)
continue;
@@ -2451,7 +2442,7 @@ QByteArray QScxmlCompilerPrivate::DefaultLoader::load(const QString &name, const
const QUrl url(name);
if (!url.isLocalFile() && !url.isRelative())
errs << QStringLiteral("src attribute is not a local file (%1)").arg(name);
- QFileInfo fInfo = url.isLocalFile() ? url.toLocalFile() : name;
+ QFileInfo fInfo(url.isLocalFile() ? url.toLocalFile() : name);
#endif // BUILD_QSCXMLC
if (fInfo.isRelative())
fInfo = QFileInfo(QDir(baseDir).filePath(fInfo.filePath()));
diff --git a/src/scxml/qscxmlcompiler.h b/src/scxml/qscxmlcompiler.h
index 411dfde..3eecca5 100644
--- a/src/scxml/qscxmlcompiler.h
+++ b/src/scxml/qscxmlcompiler.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLCOMPILER_H
#define QSCXMLCOMPILER_H
@@ -72,7 +36,7 @@ public:
void setLoader(Loader *newLoader);
QScxmlStateMachine *compile();
- QVector<QScxmlError> errors() const;
+ QList<QScxmlError> errors() const;
private:
friend class QScxmlCompilerPrivate;
diff --git a/src/scxml/qscxmlcompiler_p.h b/src/scxml/qscxmlcompiler_p.h
index 4b270f8..498018c 100644
--- a/src/scxml/qscxmlcompiler_p.h
+++ b/src/scxml/qscxmlcompiler_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLCOMPILER_P_H
#define QSCXMLCOMPILER_P_H
@@ -60,6 +24,9 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qstring.h>
#include <QtCore/qxmlstream.h>
+#include <QtCore/private/qglobal_p.h>
+
+#include <memory>
QT_BEGIN_NAMESPACE
@@ -129,7 +96,7 @@ struct DoneData: public Node
{
QString contents;
QString expr;
- QVector<Param *> params;
+ QList<Param *> params;
DoneData(const XmlLocation &xmlLocation): Node(xmlLocation) {}
void accept(NodeVisitor *visitor) override;
@@ -141,8 +108,8 @@ struct Instruction: public Node
virtual ~Instruction() {}
};
-typedef QVector<Instruction *> InstructionSequence;
-typedef QVector<InstructionSequence *> InstructionSequences;
+typedef QList<Instruction *> InstructionSequence;
+typedef QList<InstructionSequence *> InstructionSequences;
struct Send: public Instruction
{
@@ -157,7 +124,7 @@ struct Send: public Instruction
QString delay;
QString delayexpr;
QStringList namelist;
- QVector<Param *> params;
+ QList<Param *> params;
QString content;
QString contentexpr;
@@ -177,7 +144,7 @@ struct Invoke: public Instruction
QString idLocation;
QStringList namelist;
bool autoforward;
- QVector<Param *> params;
+ QList<Param *> params;
InstructionSequence finalize;
QSharedPointer<ScxmlDocument> content;
@@ -285,12 +252,12 @@ struct State: public AbstractState, public StateOrTransition
enum Type { Normal, Parallel, Final };
QStringList initial;
- QVector<DataElement *> dataElements;
- QVector<StateOrTransition *> children;
+ QList<DataElement *> dataElements;
+ QList<StateOrTransition *> children;
InstructionSequences onEntry;
InstructionSequences onExit;
DoneData *doneData;
- QVector<Invoke *> invokes;
+ QList<Invoke *> invokes;
Type type;
Transition *initialTransition; // when not set, it is filled during verification
@@ -322,7 +289,7 @@ struct Transition: public StateOrTransition
InstructionSequence instructionsOnTransition;
Type type;
- QVector<AbstractState *> targetStates; // when not set, it is filled during verification
+ QList<AbstractState *> targetStates; // when not set, it is filled during verification
Transition(const XmlLocation &xmlLocation)
: StateOrTransition(xmlLocation)
@@ -338,7 +305,7 @@ struct HistoryState: public AbstractState, public StateOrTransition
{
enum Type { Deep, Shallow };
Type type;
- QVector<StateOrTransition *> children;
+ QList<StateOrTransition *> children;
HistoryState(const XmlLocation &xmlLocation)
: StateOrTransition(xmlLocation)
@@ -376,8 +343,8 @@ struct Scxml: public StateContainer, public Node
QString cppDataModelClassName;
QString cppDataModelHeaderName;
BindingMethod binding;
- QVector<StateOrTransition *> children;
- QVector<DataElement *> dataElements;
+ QList<StateOrTransition *> children;
+ QList<DataElement *> dataElements;
QScopedPointer<Script> script;
InstructionSequence initialSetup;
@@ -405,11 +372,11 @@ struct ScxmlDocument
{
const QString fileName;
Scxml *root;
- QVector<AbstractState *> allStates;
- QVector<Transition *> allTransitions;
- QVector<Node *> allNodes;
- QVector<InstructionSequence *> allSequences;
- QVector<ScxmlDocument *> allSubDocuments; // weak pointers
+ QList<AbstractState *> allStates;
+ QList<Transition *> allTransitions;
+ QList<Node *> allNodes;
+ QList<InstructionSequence *> allSequences;
+ QList<ScxmlDocument *> allSubDocuments; // weak pointers
bool isVerified;
ScxmlDocument(const QString &fileName)
@@ -508,13 +475,13 @@ public:
void visit(InstructionSequence *sequence)
{
Q_ASSERT(sequence);
- for (Instruction *instruction : qAsConst(*sequence)) {
+ for (Instruction *instruction : std::as_const(*sequence)) {
Q_ASSERT(instruction);
instruction->accept(this);
}
}
- void visit(const QVector<DataElement *> &dataElements)
+ void visit(const QList<DataElement *> &dataElements)
{
for (DataElement *dataElement : dataElements) {
Q_ASSERT(dataElement);
@@ -522,7 +489,7 @@ public:
}
}
- void visit(const QVector<StateOrTransition *> &children)
+ void visit(const QList<StateOrTransition *> &children)
{
for (StateOrTransition *child : children) {
Q_ASSERT(child);
@@ -538,7 +505,7 @@ public:
}
}
- void visit(const QVector<Param *> &params)
+ void visit(const QList<Param *> &params)
{
for (Param *param : params) {
Q_ASSERT(param);
@@ -574,7 +541,7 @@ public:
const QString &fileName);
QByteArray load(const QString &name, bool *ok);
- QVector<QScxmlError> errors() const;
+ QList<QScxmlError> errors() const;
void addError(const QString &msg);
void addError(const DocumentModel::XmlLocation &location, const QString &msg);
@@ -694,7 +661,7 @@ private:
bool validChild(ParserState::Kind child) const;
static bool validChild(ParserState::Kind parent, ParserState::Kind child);
static bool isExecutableContent(ParserState::Kind kind);
- static Kind nameToParserStateKind(const QStringRef &name);
+ static Kind nameToParserStateKind(QStringView name);
static QStringList requiredAttributes(Kind kind);
static QStringList optionalAttributes(Kind kind);
};
@@ -719,14 +686,14 @@ private:
QString m_fileName;
QSet<QString> m_allIds;
- QScopedPointer<DocumentModel::ScxmlDocument> m_doc;
+ std::unique_ptr<DocumentModel::ScxmlDocument> m_doc;
DocumentModel::StateContainer *m_currentState;
DefaultLoader m_defaultLoader;
QScxmlCompiler::Loader *m_loader;
QXmlStreamReader *m_reader;
- QVector<ParserState> m_stack;
- QVector<QScxmlError> m_errors;
+ QList<ParserState> m_stack;
+ QList<QScxmlError> m_errors;
};
QT_END_NAMESPACE
diff --git a/src/scxml/qscxmlcppdatamodel.cpp b/src/scxml/qscxmlcppdatamodel.cpp
index ba18cc7..f357eae 100644
--- a/src/scxml/qscxmlcppdatamodel.cpp
+++ b/src/scxml/qscxmlcppdatamodel.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmlcppdatamodel_p.h"
#include "qscxmlstatemachine.h"
@@ -64,12 +28,12 @@ using namespace QScxmlExecutableContent;
The format of the \e datamodel attribute is: \c{cplusplus:<class-name>:<classdef-header>}.
So, for the example above, there should be a file \e thedatamodel.h containing a subclass of
QScxmlCppDataModel, containing at least the following:
- \code
+ \badcode
#include "qscxmlcppdatamodel.h"
class TheDataModel: public QScxmlCppDataModel
{
- Q_OBJECT
+ \Q_OBJECT
Q_SCXML_DATAMODEL
};
\endcode
@@ -123,7 +87,7 @@ void TheDataModel::evaluateToVoid(QScxmlExecutableContent::EvaluatorId id, bool
statements, and in \e cond or \e expr attributes you can use any C++ expression that can be
converted to the respective bool or QVariant. And, as the \c this pointer is also captured, you
can call or access the data model (the \e media attribute in the example above). For the full
- example, see \l {Qt SCXML: Media Player QML Example (C++ Data Model)}.
+ example, see \l {SCXML Media Player}.
*/
/*!
@@ -138,6 +102,8 @@ QScxmlCppDataModel::QScxmlCppDataModel(QObject *parent)
* for data model variables specified by their keys, \a initialDataValues. These
* are the values specified by \c <param> tags in an \c <invoke> element.
*
+ * Returns \c true on success.
+ *
* \sa QScxmlStateMachine::init
*/
bool QScxmlCppDataModel::setup(const QVariantMap &initialDataValues)
diff --git a/src/scxml/qscxmlcppdatamodel.h b/src/scxml/qscxmlcppdatamodel.h
index 8f71229..0fd4ba4 100644
--- a/src/scxml/qscxmlcppdatamodel.h
+++ b/src/scxml/qscxmlcppdatamodel.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLCPPDATAMODEL_H
#define QSCXMLCPPDATAMODEL_H
diff --git a/src/scxml/qscxmlcppdatamodel_p.h b/src/scxml/qscxmlcppdatamodel_p.h
index b342e39..2168d02 100644
--- a/src/scxml/qscxmlcppdatamodel_p.h
+++ b/src/scxml/qscxmlcppdatamodel_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLCPPDATAMODEL_P_H
#define QSCXMLCPPDATAMODEL_P_H
diff --git a/src/scxml/qscxmldatamodel.cpp b/src/scxml/qscxmldatamodel.cpp
index ab0ae7c..eaa15e8 100644
--- a/src/scxml/qscxmldatamodel.cpp
+++ b/src/scxml/qscxmldatamodel.cpp
@@ -1,51 +1,19 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmldatamodel_p.h"
#include "qscxmlnulldatamodel.h"
-#if QT_CONFIG(scxml_ecmascriptdatamodel)
-#include "qscxmlecmascriptdatamodel.h"
-#endif
#include "qscxmlstatemachine_p.h"
+#include <QtCore/private/qfactoryloader_p.h>
+#include "qscxmldatamodelplugin_p.h"
+
QT_BEGIN_NAMESPACE
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ ("org.qt-project.qt.scxml.datamodel.plugin",
+ QStringLiteral("/scxmldatamodel")))
+
/*!
\class QScxmlDataModel::ForeachLoopBody
\brief The ForeachLoopBody class represents a function to be executed on
@@ -85,7 +53,7 @@ QScxmlDataModel::ForeachLoopBody::~ForeachLoopBody()
*
* One data model can only belong to one state machine.
*
- * \sa QScxmlStateMachine QScxmlCppDataModel QScxmlEcmaScriptDataModel QScxmlNullDataModel
+ * \sa QScxmlStateMachine QScxmlCppDataModel QScxmlNullDataModel
*/
/*!
@@ -127,11 +95,13 @@ void QScxmlDataModel::setStateMachine(QScxmlStateMachine *stateMachine)
{
Q_D(QScxmlDataModel);
- if (d->m_stateMachine == nullptr && stateMachine != nullptr) {
- d->m_stateMachine = stateMachine;
- if (stateMachine)
- stateMachine->setDataModel(this);
- emit stateMachineChanged(stateMachine);
+ if (d->m_stateMachine.valueBypassingBindings() == nullptr && stateMachine != nullptr) {
+ // the binding is removed only on the first valid set
+ // as the later attempts are ignored
+ d->m_stateMachine.removeBindingUnlessInWrapper();
+ d->m_stateMachine.setValueBypassingBindings(stateMachine);
+ stateMachine->setDataModel(this);
+ d->m_stateMachine.notify();
}
}
@@ -144,6 +114,37 @@ QScxmlStateMachine *QScxmlDataModel::stateMachine() const
return d->m_stateMachine;
}
+QBindable<QScxmlStateMachine*> QScxmlDataModel::bindableStateMachine()
+{
+ Q_D(QScxmlDataModel);
+ return &d->m_stateMachine;
+}
+
+/*!
+ * Creates a data model from a plugin specified by a \a pluginKey.
+ */
+QScxmlDataModel *QScxmlDataModel::createScxmlDataModel(const QString& pluginKey)
+{
+ QScxmlDataModel *model = nullptr;
+
+ int pluginIndex = loader()->indexOf(pluginKey);
+
+ if (QObject *object = loader()->instance(pluginIndex)) {
+ if (auto *plugin = qobject_cast<QScxmlDataModelPlugin *>(object)) {
+ model = plugin->createScxmlDataModel();
+ if (!model)
+ qWarning() << pluginKey << " data model was not instantiated, createScxmlDataModel() returned null.";
+
+ } else {
+ qWarning() << "plugin object for" << pluginKey << "is not a QScxmlDatModelPlugin.";
+ }
+ delete object;
+ } else {
+ qWarning() << pluginKey << " plugin not found." ;
+ }
+ return model;
+}
+
QScxmlDataModel *QScxmlDataModelPrivate::instantiateDataModel(DocumentModel::Scxml::DataModelType type)
{
QScxmlDataModel *dataModel = nullptr;
@@ -152,16 +153,13 @@ QScxmlDataModel *QScxmlDataModelPrivate::instantiateDataModel(DocumentModel::Scx
dataModel = new QScxmlNullDataModel;
break;
case DocumentModel::Scxml::JSDataModel:
-#if QT_CONFIG(scxml_ecmascriptdatamodel)
- dataModel = new QScxmlEcmaScriptDataModel;
-#endif
+ dataModel = QScxmlDataModel::createScxmlDataModel(QStringLiteral("ecmascriptdatamodel"));
break;
case DocumentModel::Scxml::CppDataModel:
break;
default:
Q_UNREACHABLE();
}
-
return dataModel;
}
diff --git a/src/scxml/qscxmldatamodel.h b/src/scxml/qscxmldatamodel.h
index 0c9e666..5c1811d 100644
--- a/src/scxml/qscxmldatamodel.h
+++ b/src/scxml/qscxmldatamodel.h
@@ -1,63 +1,29 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLDATAMODEL_H
#define QSCXMLDATAMODEL_H
#include <QtScxml/qscxmlexecutablecontent.h>
+#include <QtCore/qobject.h>
#include <QtCore/qvariant.h>
-#include <QtCore/qvector.h>
+
+Q_MOC_INCLUDE(qscxmlstatemachine.h)
QT_BEGIN_NAMESPACE
class QScxmlEvent;
class QScxmlStateMachine;
-class QScxmlTableData;
class QScxmlDataModelPrivate;
class Q_SCXML_EXPORT QScxmlDataModel : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QScxmlDataModel)
- Q_PROPERTY(QScxmlStateMachine *stateMachine READ stateMachine WRITE setStateMachine NOTIFY stateMachineChanged)
+ Q_PROPERTY(QScxmlStateMachine *stateMachine READ stateMachine WRITE setStateMachine
+ NOTIFY stateMachineChanged BINDABLE bindableStateMachine)
public:
class Q_SCXML_EXPORT ForeachLoopBody
@@ -72,8 +38,11 @@ public:
public:
explicit QScxmlDataModel(QObject *parent = nullptr);
+ static QScxmlDataModel *createScxmlDataModel(const QString& pluginKey);
+
void setStateMachine(QScxmlStateMachine *stateMachine);
QScxmlStateMachine *stateMachine() const;
+ QBindable<QScxmlStateMachine*> bindableStateMachine();
Q_INVOKABLE virtual bool setup(const QVariantMap &initialDataValues) = 0;
diff --git a/src/scxml/qscxmldatamodel_p.h b/src/scxml/qscxmldatamodel_p.h
index b91c63c..2432959 100644
--- a/src/scxml/qscxmldatamodel_p.h
+++ b/src/scxml/qscxmldatamodel_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLDATAMODEL_P_H
#define QSCXMLDATAMODEL_P_H
@@ -54,18 +18,31 @@
#include "qscxmldatamodel.h"
#include "qscxmlcompiler_p.h"
#include <private/qobject_p.h>
+#include <private/qproperty_p.h>
QT_BEGIN_NAMESPACE
class QScxmlDataModelPrivate : public QObjectPrivate
{
+ Q_DECLARE_PUBLIC(QScxmlDataModel)
public:
- QScxmlDataModelPrivate() : m_stateMachine(nullptr) {}
+ QScxmlDataModelPrivate() = default;
static QScxmlDataModel *instantiateDataModel(DocumentModel::Scxml::DataModelType type);
-public:
- QScxmlStateMachine *m_stateMachine;
+ void setStateMachine(QScxmlStateMachine* stateMachine)
+ {
+ q_func()->setStateMachine(stateMachine);
+ }
+
+ void emitStateMachineChanged(QScxmlStateMachine* newValue)
+ {
+ emit q_func()->stateMachineChanged(newValue);
+ }
+
+ Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QScxmlDataModelPrivate, QScxmlStateMachine*, m_stateMachine,
+ &QScxmlDataModelPrivate::setStateMachine,
+ &QScxmlDataModelPrivate::emitStateMachineChanged, nullptr)
};
QT_END_NAMESPACE
diff --git a/src/scxml/qscxmldatamodelplugin.cpp b/src/scxml/qscxmldatamodelplugin.cpp
new file mode 100644
index 0000000..d60db70
--- /dev/null
+++ b/src/scxml/qscxmldatamodelplugin.cpp
@@ -0,0 +1,13 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qscxmldatamodelplugin_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QScxmlDataModel *QScxmlDataModelPlugin::createScxmlDataModel() const
+{
+ return nullptr;
+}
+
+QT_END_NAMESPACE
diff --git a/src/scxml/qscxmldatamodelplugin_p.h b/src/scxml/qscxmldatamodelplugin_p.h
new file mode 100644
index 0000000..be00ea9
--- /dev/null
+++ b/src/scxml/qscxmldatamodelplugin_p.h
@@ -0,0 +1,36 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QSCXMLDATAMODELPLUGIN_P_H
+#define QSCXMLDATAMODELPLUGIN_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtScxml/private/qscxmlglobals_p.h>
+#include <QtScxml/qscxmldatamodel.h>
+#include <QtCore/qobject.h>
+
+QT_BEGIN_NAMESPACE
+
+#define QScxmlDataModelPluginInterface_iid "org.qt-project.qt.scxml.datamodel.plugin"
+
+class Q_SCXML_EXPORT QScxmlDataModelPlugin : public QObject
+{
+ Q_OBJECT
+public:
+ virtual QScxmlDataModel *createScxmlDataModel() const;
+};
+
+Q_DECLARE_INTERFACE(QScxmlDataModelPlugin, QScxmlDataModelPluginInterface_iid)
+QT_END_NAMESPACE
+
+#endif // QSCXMLDATAMODELPLUGIN_P_H
diff --git a/src/scxml/qscxmlecmascriptdatamodel.cpp b/src/scxml/qscxmlecmascriptdatamodel.cpp
deleted file mode 100644
index da4fe84..0000000
--- a/src/scxml/qscxmlecmascriptdatamodel.cpp
+++ /dev/null
@@ -1,576 +0,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: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$
-**
-****************************************************************************/
-
-#include "qscxmlglobals_p.h"
-#include "qscxmlecmascriptdatamodel.h"
-#include "qscxmlecmascriptplatformproperties_p.h"
-#include "qscxmlexecutablecontent_p.h"
-#include "qscxmlstatemachine_p.h"
-#include "qscxmldatamodel_p.h"
-
-#include <qjsengine.h>
-#include <qjsondocument.h>
-#include <QtQml/private/qjsvalue_p.h>
-#include <QtQml/private/qv4scopedvalue_p.h>
-
-#include <functional>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QScxmlExecutableContent;
-
-typedef std::function<QString (bool *)> ToStringEvaluator;
-typedef std::function<bool (bool *)> ToBoolEvaluator;
-typedef std::function<QVariant (bool *)> ToVariantEvaluator;
-typedef std::function<void (bool *)> ToVoidEvaluator;
-typedef std::function<bool (bool *, std::function<bool ()>)> ForeachEvaluator;
-
-class QScxmlEcmaScriptDataModelPrivate : public QScxmlDataModelPrivate
-{
- Q_DECLARE_PUBLIC(QScxmlEcmaScriptDataModel)
-public:
- QScxmlEcmaScriptDataModelPrivate()
- : jsEngine(nullptr)
- {}
-
- QString evalStr(const QString &expr, const QString &context, bool *ok)
- {
- QString script = QStringLiteral("(%1).toString()").arg(expr);
- QJSValue v = eval(script, context, ok);
- if (*ok)
- return v.toString();
- else
- return QString();
- }
-
- bool evalBool(const QString &expr, const QString &context, bool *ok)
- {
- QString script = QStringLiteral("(function(){return !!(%1); })()").arg(expr);
- QJSValue v = eval(script, context, ok);
- if (*ok)
- return v.toBool();
- else
- return false;
- }
-
- QJSValue evalJSValue(const QString &expr, const QString &context, bool *ok)
- {
- assertEngine();
-
- QString script = QStringLiteral("(function(){'use strict'; return (\n%1\n); })()").arg(expr);
- return eval(script, context, ok);
- }
-
- QJSValue eval(const QString &script, const QString &context, bool *ok)
- {
- Q_ASSERT(ok);
- QJSEngine *engine = assertEngine();
-
- // TODO: copy QJSEngine::evaluate and handle the case of v4->catchException() "our way"
-
- QJSValue v = engine->evaluate(QStringLiteral("'use strict'; ") + script, QStringLiteral("<expr>"), 0);
- if (v.isError()) {
- *ok = false;
- submitError(QStringLiteral("error.execution"),
- QStringLiteral("%1 in %2").arg(v.toString(), context));
- return QJSValue(QJSValue::UndefinedValue);
- } else {
- *ok = true;
- return v;
- }
- }
-
- void setupDataModel()
- {
- QJSEngine *engine = assertEngine();
- dataModel = engine->globalObject();
-
- qCDebug(qscxmlLog) << m_stateMachine << "initializing the datamodel";
- setupSystemVariables();
- }
-
- void setupSystemVariables()
- {
- setReadonlyProperty(&dataModel, QStringLiteral("_sessionid"),
- m_stateMachine->sessionId());
-
- setReadonlyProperty(&dataModel, QStringLiteral("_name"), m_stateMachine->name());
-
- QJSEngine *engine = assertEngine();
- auto scxml = engine->newObject();
- scxml.setProperty(QStringLiteral("location"), QStringLiteral("#_scxml_%1")
- .arg(m_stateMachine->sessionId()));
- auto ioProcs = engine->newObject();
- setReadonlyProperty(&ioProcs, QStringLiteral("scxml"), scxml);
- setReadonlyProperty(&dataModel, QStringLiteral("_ioprocessors"), ioProcs);
-
- auto platformVars = QScxmlPlatformProperties::create(engine, m_stateMachine);
- dataModel.setProperty(QStringLiteral("_x"), platformVars->jsValue());
-
- dataModel.setProperty(QStringLiteral("In"), engine->evaluate(
- QStringLiteral("(function(id){return _x.inState(id);})")));
- }
-
- void assignEvent(const QScxmlEvent &event)
- {
- if (event.name().isEmpty())
- return;
-
- QJSEngine *engine = assertEngine();
- QJSValue _event = engine->newObject();
- QJSValue dataValue = eventDataAsJSValue(event.data());
- _event.setProperty(QStringLiteral("data"), dataValue.isUndefined() ? QJSValue(QJSValue::UndefinedValue)
- : dataValue);
- _event.setProperty(QStringLiteral("invokeid"), event.invokeId().isEmpty() ? QJSValue(QJSValue::UndefinedValue)
- : engine->toScriptValue(event.invokeId()));
- if (!event.originType().isEmpty())
- _event.setProperty(QStringLiteral("origintype"), engine->toScriptValue(event.originType()));
- _event.setProperty(QStringLiteral("origin"), event.origin().isEmpty() ? QJSValue(QJSValue::UndefinedValue)
- : engine->toScriptValue(event.origin()) );
- _event.setProperty(QStringLiteral("sendid"), event.sendId().isEmpty() ? QJSValue(QJSValue::UndefinedValue)
- : engine->toScriptValue(event.sendId()));
- _event.setProperty(QStringLiteral("type"), engine->toScriptValue(event.scxmlType()));
- _event.setProperty(QStringLiteral("name"), engine->toScriptValue(event.name()));
- _event.setProperty(QStringLiteral("raw"), QStringLiteral("unsupported")); // See test178
- if (event.isErrorEvent())
- _event.setProperty(QStringLiteral("errorMessage"), event.errorMessage());
-
- setReadonlyProperty(&dataModel, QStringLiteral("_event"), _event);
- }
-
- QJSValue eventDataAsJSValue(const QVariant &eventData)
- {
- if (!eventData.isValid()) {
- return QJSValue(QJSValue::UndefinedValue);
- }
-
- QJSEngine *engine = assertEngine();
- if (eventData.canConvert<QVariantMap>()) {
- auto keyValues = eventData.value<QVariantMap>();
- auto data = engine->newObject();
-
- for (QVariantMap::const_iterator it = keyValues.begin(), eit = keyValues.end(); it != eit; ++it) {
- data.setProperty(it.key(), engine->toScriptValue(it.value()));
- }
-
- return data;
- }
-
- if (eventData == QVariant(QMetaType::VoidStar, 0)) {
- return QJSValue(QJSValue::NullValue);
- }
-
- QString data = eventData.toString();
- QJsonParseError err;
- QJsonDocument doc = QJsonDocument::fromJson(data.toUtf8(), &err);
- if (err.error == QJsonParseError::NoError)
- return engine->toScriptValue(doc.toVariant());
- else
- return engine->toScriptValue(data);
- }
-
- QJSEngine *assertEngine()
- {
- if (!jsEngine) {
- Q_Q(QScxmlEcmaScriptDataModel);
- setEngine(new QJSEngine(q->stateMachine()));
- }
-
- return jsEngine;
- }
-
- QJSEngine *engine() const
- {
- return jsEngine;
- }
-
- void setEngine(QJSEngine *engine)
- { jsEngine = engine; }
-
- QString string(StringId id) const
- {
- return m_stateMachine->tableData()->string(id);
- }
-
- bool hasProperty(const QString &name) const
- { return dataModel.hasProperty(name); }
-
- QJSValue property(const QString &name) const
- { return dataModel.property(name); }
-
- bool setProperty(const QString &name, const QJSValue &value, const QString &context)
- {
- QString msg;
- switch (setProperty(&dataModel, name, value)) {
- case SetPropertySucceeded:
- return true;
- case SetReadOnlyPropertyFailed:
- msg = QStringLiteral("cannot assign to read-only property %1 in %2");
- break;
- case SetUnknownPropertyFailed:
- msg = QStringLiteral("cannot assign to unknown propety %1 in %2");
- break;
- case SetPropertyFailedForAnotherReason:
- msg = QStringLiteral("assignment to property %1 failed in %2");
- break;
- default:
- Q_UNREACHABLE();
- }
-
- submitError(QStringLiteral("error.execution"), msg.arg(name, context));
- return false;
- }
-
- void submitError(const QString &type, const QString &msg, const QString &sendid = QString())
- {
- QScxmlStateMachinePrivate::get(m_stateMachine)->submitError(type, msg, sendid);
- }
-
-public:
- QStringList initialDataNames;
-
-private: // Uses private API
- static void setReadonlyProperty(QJSValue *object, const QString &name, const QJSValue &value)
- {
- qCDebug(qscxmlLog) << "setting read-only property" << name;
- QV4::ExecutionEngine *engine = QJSValuePrivate::engine(object);
- Q_ASSERT(engine);
- QV4::Scope scope(engine);
-
- QV4::ScopedObject o(scope, QJSValuePrivate::getValue(object));
- if (!o)
- return;
-
- if (!QJSValuePrivate::checkEngine(engine, value)) {
- qCWarning(qscxmlLog, "EcmaScriptDataModel::setReadonlyProperty(%s) failed: cannot set value created in a different engine", name.toUtf8().constData());
- return;
- }
-
- QV4::ScopedString s(scope, engine->newString(name));
- QV4::ScopedPropertyKey key(scope, s->toPropertyKey());
- if (key->isArrayIndex()) {
- Q_UNIMPLEMENTED();
- return;
- }
-
- QV4::ScopedValue v(scope, QJSValuePrivate::convertedToValue(engine, value));
- o->defineReadonlyProperty(s, v);
- if (engine->hasException)
- engine->catchException();
- }
-
- enum SetPropertyResult {
- SetPropertySucceeded,
- SetReadOnlyPropertyFailed,
- SetUnknownPropertyFailed,
- SetPropertyFailedForAnotherReason,
- };
-
- static SetPropertyResult setProperty(QJSValue *object, const QString &name, const QJSValue &value)
- {
- QV4::ExecutionEngine *engine = QJSValuePrivate::engine(object);
- Q_ASSERT(engine);
- if (engine->hasException)
- return SetPropertyFailedForAnotherReason;
-
- QV4::Scope scope(engine);
- QV4::ScopedObject o(scope, QJSValuePrivate::getValue(object));
- if (o == nullptr) {
- return SetPropertyFailedForAnotherReason;
- }
-
- QV4::ScopedString s(scope, engine->newString(name));
- QV4::ScopedPropertyKey key(scope, s->toPropertyKey());
- if (key->isArrayIndex()) {
- Q_UNIMPLEMENTED();
- return SetPropertyFailedForAnotherReason;
- }
-
- QV4::PropertyAttributes attrs = o->getOwnProperty(s->toPropertyKey());
- if (attrs.isWritable() || attrs.isEmpty()) {
- QV4::ScopedValue v(scope, QJSValuePrivate::convertedToValue(engine, value));
- o->insertMember(s, v);
- if (engine->hasException) {
- engine->catchException();
- return SetPropertyFailedForAnotherReason;
- } else {
- return SetPropertySucceeded;
- }
- } else {
- return SetReadOnlyPropertyFailed;
- }
- }
-
-private:
- QJSEngine *jsEngine;
- QJSValue dataModel;
-};
-
-/*!
- * \class QScxmlEcmaScriptDataModel
- * \brief The QScxmlEcmaScriptDataModel class is the ECMAScript data model for
- * a Qt SCXML state machine.
- * \since 5.7
- * \inmodule QtScxml
- *
- * This class implements the ECMAScript data model as described in
- * \l {SCXML Specification - B.2 The ECMAScript Data Model}. It can be
- * subclassed to perform custom initialization.
- *
- * \sa QScxmlStateMachine QScxmlDataModel
- */
-
-/*!
- * Creates a new ECMAScript data model, with the parent object \a parent.
- */
-QScxmlEcmaScriptDataModel::QScxmlEcmaScriptDataModel(QObject *parent)
- : QScxmlDataModel(*(new QScxmlEcmaScriptDataModelPrivate), parent)
-{}
-
-/*!
- \reimp
- */
-bool QScxmlEcmaScriptDataModel::setup(const QVariantMap &initialDataValues)
-{
- Q_D(QScxmlEcmaScriptDataModel);
- d->setupDataModel();
-
- bool ok = true;
- QJSValue undefined(QJSValue::UndefinedValue); // See B.2.1, and test456.
- int count;
- StringId *names = d->m_stateMachine->tableData()->dataNames(&count);
- for (int i = 0; i < count; ++i) {
- auto name = d->string(names[i]);
- QJSValue v = undefined;
- QVariantMap::const_iterator it = initialDataValues.find(name);
- if (it != initialDataValues.end()) {
- QJSEngine *engine = d->assertEngine();
- v = engine->toScriptValue(it.value());
- }
- if (!d->setProperty(name, v, QStringLiteral("<data>"))) {
- ok = false;
- }
- }
- d->initialDataNames = initialDataValues.keys();
-
- return ok;
-}
-
-/*!
- \reimp
- */
-QString QScxmlEcmaScriptDataModel::evaluateToString(QScxmlExecutableContent::EvaluatorId id,
- bool *ok)
-{
- Q_D(QScxmlEcmaScriptDataModel);
- const EvaluatorInfo &info = d->m_stateMachine->tableData()->evaluatorInfo(id);
-
- return d->evalStr(d->string(info.expr), d->string(info.context), ok);
-}
-
-/*!
- \reimp
- */
-bool QScxmlEcmaScriptDataModel::evaluateToBool(QScxmlExecutableContent::EvaluatorId id,
- bool *ok)
-{
- Q_D(QScxmlEcmaScriptDataModel);
- const EvaluatorInfo &info = d->m_stateMachine->tableData()->evaluatorInfo(id);
-
- return d->evalBool(d->string(info.expr), d->string(info.context), ok);
-}
-
-/*!
- \reimp
- */
-QVariant QScxmlEcmaScriptDataModel::evaluateToVariant(QScxmlExecutableContent::EvaluatorId id,
- bool *ok)
-{
- Q_D(QScxmlEcmaScriptDataModel);
- const EvaluatorInfo &info = d->m_stateMachine->tableData()->evaluatorInfo(id);
-
- return d->evalJSValue(d->string(info.expr), d->string(info.context), ok).toVariant();
-}
-
-/*!
- \reimp
- */
-void QScxmlEcmaScriptDataModel::evaluateToVoid(QScxmlExecutableContent::EvaluatorId id,
- bool *ok)
-{
- Q_D(QScxmlEcmaScriptDataModel);
- const EvaluatorInfo &info = d->m_stateMachine->tableData()->evaluatorInfo(id);
-
- d->eval(d->string(info.expr), d->string(info.context), ok);
-}
-
-/*!
- \reimp
- */
-void QScxmlEcmaScriptDataModel::evaluateAssignment(QScxmlExecutableContent::EvaluatorId id,
- bool *ok)
-{
- Q_D(QScxmlEcmaScriptDataModel);
- Q_ASSERT(ok);
-
- const AssignmentInfo &info = d->m_stateMachine->tableData()->assignmentInfo(id);
-
- QString dest = d->string(info.dest);
-
- if (hasScxmlProperty(dest)) {
- QJSValue v = d->evalJSValue(d->string(info.expr), d->string(info.context), ok);
- if (*ok)
- *ok = d->setProperty(dest, v, d->string(info.context));
- } else {
- *ok = false;
- d->submitError(QStringLiteral("error.execution"),
- QStringLiteral("%1 in %2 does not exist").arg(dest, d->string(info.context)));
- }
-}
-
-/*!
- \reimp
- */
-void QScxmlEcmaScriptDataModel::evaluateInitialization(QScxmlExecutableContent::EvaluatorId id,
- bool *ok)
-{
- Q_D(QScxmlEcmaScriptDataModel);
- const AssignmentInfo &info = d->m_stateMachine->tableData()->assignmentInfo(id);
- QString dest = d->string(info.dest);
- if (d->initialDataNames.contains(dest)) {
- *ok = true; // silently ignore the <data> tag
- return;
- }
-
- evaluateAssignment(id, ok);
-}
-
-/*!
- \reimp
- */
-void QScxmlEcmaScriptDataModel::evaluateForeach(QScxmlExecutableContent::EvaluatorId id, bool *ok,
- ForeachLoopBody *body)
-{
- Q_D(QScxmlEcmaScriptDataModel);
- Q_ASSERT(ok);
- Q_ASSERT(body);
- const ForeachInfo &info = d->m_stateMachine->tableData()->foreachInfo(id);
-
- QJSValue jsArray = d->property(d->string(info.array));
- if (!jsArray.isArray()) {
- d->submitError(QStringLiteral("error.execution"), QStringLiteral("invalid array '%1' in %2").arg(d->string(info.array), d->string(info.context)));
- *ok = false;
- return;
- }
-
- QString item = d->string(info.item);
-
- QJSEngine *engine = d->assertEngine();
- if (engine->evaluate(QStringLiteral("(function(){var %1 = 0})()").arg(item)).isError()) {
- d->submitError(QStringLiteral("error.execution"), QStringLiteral("invalid item '%1' in %2")
- .arg(d->string(info.item), d->string(info.context)));
- *ok = false;
- return;
- }
-
- const int length = jsArray.property(QStringLiteral("length")).toInt();
- QString idx = d->string(info.index);
- QString context = d->string(info.context);
- const bool hasIndex = !idx.isEmpty();
-
- for (int currentIndex = 0; currentIndex < length; ++currentIndex) {
- QJSValue currentItem = jsArray.property(static_cast<quint32>(currentIndex));
- *ok = d->setProperty(item, currentItem, context);
- if (!*ok)
- return;
- if (hasIndex) {
- *ok = d->setProperty(idx, currentIndex, context);
- if (!*ok)
- return;
- }
- body->run(ok);
- if (!*ok)
- return;
- }
- *ok = true;
-}
-
-/*!
- * \reimp
- */
-void QScxmlEcmaScriptDataModel::setScxmlEvent(const QScxmlEvent &event)
-{
- Q_D(QScxmlEcmaScriptDataModel);
- d->assignEvent(event);
-}
-
-/*!
- * \reimp
- */
-QVariant QScxmlEcmaScriptDataModel::scxmlProperty(const QString &name) const
-{
- Q_D(const QScxmlEcmaScriptDataModel);
- return d->property(name).toVariant();
-}
-
-/*!
- * \reimp
- */
-bool QScxmlEcmaScriptDataModel::hasScxmlProperty(const QString &name) const
-{
- Q_D(const QScxmlEcmaScriptDataModel);
- return d->hasProperty(name);
-}
-
-/*!
- * \reimp
- */
-bool QScxmlEcmaScriptDataModel::setScxmlProperty(const QString &name, const QVariant &value,
- const QString &context)
-{
- Q_D(QScxmlEcmaScriptDataModel);
- Q_ASSERT(hasScxmlProperty(name));
-
- QJSEngine *engine = d->assertEngine();
- QJSValue v = engine->toScriptValue(
- value.canConvert<QJSValue>() ? value.value<QJSValue>().toVariant() : value);
- return d->setProperty(name, v, context);
-}
-
-QT_END_NAMESPACE
diff --git a/src/scxml/qscxmlecmascriptdatamodel.h b/src/scxml/qscxmlecmascriptdatamodel.h
deleted file mode 100644
index 16f29d4..0000000
--- a/src/scxml/qscxmlecmascriptdatamodel.h
+++ /dev/null
@@ -1,80 +0,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: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$
-**
-****************************************************************************/
-
-#ifndef QSCXMLECMASCRIPTDATAMODEL_H
-#define QSCXMLECMASCRIPTDATAMODEL_H
-
-#include <QtScxml/qscxmlglobals.h>
-#include <QtScxml/qscxmldatamodel.h>
-
-QT_BEGIN_NAMESPACE
-
-// We cannot use QT_REQUIRE_CONFIG here, because the feature name contains a dash.
-#if QT_CONFIG(scxml_ecmascriptdatamodel)
-
-class QScxmlEcmaScriptDataModelPrivate;
-class Q_SCXML_EXPORT QScxmlEcmaScriptDataModel: public QScxmlDataModel
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QScxmlEcmaScriptDataModel)
-public:
- explicit QScxmlEcmaScriptDataModel(QObject *parent = nullptr);
-
- Q_INVOKABLE bool setup(const QVariantMap &initialDataValues) override;
-
- QString evaluateToString(QScxmlExecutableContent::EvaluatorId id, bool *ok) override final;
- bool evaluateToBool(QScxmlExecutableContent::EvaluatorId id, bool *ok) override final;
- QVariant evaluateToVariant(QScxmlExecutableContent::EvaluatorId id, bool *ok) override final;
- void evaluateToVoid(QScxmlExecutableContent::EvaluatorId id, bool *ok) override final;
- void evaluateAssignment(QScxmlExecutableContent::EvaluatorId id, bool *ok) override final;
- void evaluateInitialization(QScxmlExecutableContent::EvaluatorId id, bool *ok) override final;
- void evaluateForeach(QScxmlExecutableContent::EvaluatorId id, bool *ok, ForeachLoopBody *body) override final;
-
- void setScxmlEvent(const QScxmlEvent &event) override;
-
- QVariant scxmlProperty(const QString &name) const override;
- bool hasScxmlProperty(const QString &name) const override;
- bool setScxmlProperty(const QString &name, const QVariant &value, const QString &context) override;
-};
-
-#endif // QT_CONFIG(scxml_ecmascriptdatamodel)
-
-QT_END_NAMESPACE
-
-#endif // QSCXMLECMASCRIPTDATAMODEL_H
diff --git a/src/scxml/qscxmlecmascriptplatformproperties.cpp b/src/scxml/qscxmlecmascriptplatformproperties.cpp
deleted file mode 100644
index 95e3b4f..0000000
--- a/src/scxml/qscxmlecmascriptplatformproperties.cpp
+++ /dev/null
@@ -1,101 +0,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: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$
-**
-****************************************************************************/
-
-#include "qscxmlecmascriptplatformproperties_p.h"
-#include "qscxmlstatemachine.h"
-
-#include <qjsengine.h>
-
-QT_BEGIN_NAMESPACE
-class QScxmlPlatformProperties::Data
-{
-public:
- Data()
- : m_stateMachine(nullptr)
- {}
-
- QScxmlStateMachine *m_stateMachine;
- QJSValue m_jsValue;
-};
-
-QScxmlPlatformProperties::QScxmlPlatformProperties(QObject *parent)
- : QObject(parent)
- , data(new Data)
-{}
-
-QScxmlPlatformProperties *QScxmlPlatformProperties::create(QJSEngine *engine, QScxmlStateMachine *stateMachine)
-{
- QScxmlPlatformProperties *pp = new QScxmlPlatformProperties(engine);
- pp->data->m_stateMachine = stateMachine;
- pp->data->m_jsValue = engine->newQObject(pp);
- return pp;
-}
-
-QScxmlPlatformProperties::~QScxmlPlatformProperties()
-{
- delete data;
-}
-
-QJSEngine *QScxmlPlatformProperties::engine() const
-{
- return qobject_cast<QJSEngine *>(parent());
-}
-
-QScxmlStateMachine *QScxmlPlatformProperties::stateMachine() const
-{
- return data->m_stateMachine;
-}
-
-QJSValue QScxmlPlatformProperties::jsValue() const
-{
- return data->m_jsValue;
-}
-
-/// _x.marks === "the spot"
-QString QScxmlPlatformProperties::marks() const
-{
- return QStringLiteral("the spot");
-}
-
-bool QScxmlPlatformProperties::inState(const QString &stateName)
-{
- return stateMachine()->isActive(stateName);
-}
-
-QT_END_NAMESPACE
diff --git a/src/scxml/qscxmlecmascriptplatformproperties_p.h b/src/scxml/qscxmlecmascriptplatformproperties_p.h
deleted file mode 100644
index e7b8a09..0000000
--- a/src/scxml/qscxmlecmascriptplatformproperties_p.h
+++ /dev/null
@@ -1,93 +0,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: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$
-**
-****************************************************************************/
-
-#ifndef QSCXMLECMASCRIPTPLATFORMPROPERTIES_P_H
-#define QSCXMLECMASCRIPTPLATFORMPROPERTIES_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qscxmlglobals.h"
-
-#include <QtCore/qobject.h>
-
-QT_FORWARD_DECLARE_CLASS(QJSEngine)
-QT_FORWARD_DECLARE_CLASS(QJSValue)
-
-QT_REQUIRE_CONFIG(scxml_ecmascriptdatamodel);
-
-QT_BEGIN_NAMESPACE
-
-class QScxmlStateMachine;
-class QScxmlPlatformProperties: public QObject
-{
- Q_OBJECT
-
- QScxmlPlatformProperties(QObject *parent);
-
- Q_PROPERTY(QString marks READ marks CONSTANT)
-
-public:
- static QScxmlPlatformProperties *create(QJSEngine *engine, QScxmlStateMachine *stateMachine);
- ~QScxmlPlatformProperties();
-
- QJSEngine *engine() const;
- QScxmlStateMachine *stateMachine() const;
- QJSValue jsValue() const;
-
- QString marks() const;
-
- Q_INVOKABLE bool inState(const QString &stateName);
-
-private:
- class Data;
- Data *data;
-};
-
-QT_END_NAMESPACE
-
-#endif // QSCXMLECMASCRIPTPLATFORMPROPERTIES_P_H
diff --git a/src/scxml/qscxmlerror.cpp b/src/scxml/qscxmlerror.cpp
index 3033040..b5b541b 100644
--- a/src/scxml/qscxmlerror.cpp
+++ b/src/scxml/qscxmlerror.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmlerror.h"
diff --git a/src/scxml/qscxmlerror.h b/src/scxml/qscxmlerror.h
index 6e6e459..8b1201b 100644
--- a/src/scxml/qscxmlerror.h
+++ b/src/scxml/qscxmlerror.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLERROR_H
#define QSCXMLERROR_H
diff --git a/src/scxml/qscxmlevent.cpp b/src/scxml/qscxmlevent.cpp
index 2ec7566..3d4795f 100644
--- a/src/scxml/qscxmlevent.cpp
+++ b/src/scxml/qscxmlevent.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmlexecutablecontent_p.h"
#include "qscxmlevent_p.h"
@@ -71,7 +35,7 @@ QScxmlEvent *QScxmlEventBuilder::buildEvent()
}
if (!ok) {
// expr evaluation failure results in the data property of the event being set to null. See e.g. test528.
- data = QVariant(QMetaType::VoidStar, 0);
+ data = QVariant(QMetaType(QMetaType::VoidStar), nullptr);
}
} else {
QVariantMap keyValues;
@@ -86,7 +50,7 @@ QScxmlEvent *QScxmlEventBuilder::buildEvent()
} else {
// If the evaluation of the <param> tags fails, set _event.data to an empty string.
// See test343.
- data = QVariant(QMetaType::VoidStar, 0);
+ data = QVariant(QMetaType(QMetaType::VoidStar), nullptr);
}
}
diff --git a/src/scxml/qscxmlevent.h b/src/scxml/qscxmlevent.h
index e07da7a..566f0c3 100644
--- a/src/scxml/qscxmlevent.h
+++ b/src/scxml/qscxmlevent.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLEVENT_H
#define QSCXMLEVENT_H
diff --git a/src/scxml/qscxmlevent_p.h b/src/scxml/qscxmlevent_p.h
index cf4e26a..b177b30 100644
--- a/src/scxml/qscxmlevent_p.h
+++ b/src/scxml/qscxmlevent_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLEVENT_P_H
#define QSCXMLEVENT_P_H
diff --git a/src/scxml/qscxmlexecutablecontent.cpp b/src/scxml/qscxmlexecutablecontent.cpp
index 45079d7..eae7c4a 100644
--- a/src/scxml/qscxmlexecutablecontent.cpp
+++ b/src/scxml/qscxmlexecutablecontent.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmlglobals_p.h"
#include "qscxmlexecutablecontent_p.h"
@@ -234,7 +198,7 @@ using namespace QScxmlExecutableContent;
#ifndef BUILD_QSCXMLC
-static int parseTime(const QString &t, bool *ok = nullptr)
+static int parseTime(QStringView t, bool *ok = nullptr)
{
if (t.isEmpty()) {
if (ok)
@@ -250,7 +214,7 @@ static int parseTime(const QString &t, bool *ok = nullptr)
++startPos;
}
int pos = startPos;
- for (int endPos = t.length(); pos < endPos; ++pos) {
+ for (int endPos = t.size(); pos < endPos; ++pos) {
auto c = t[pos];
if (c < QLatin1Char('0') || c > QLatin1Char('9'))
break;
@@ -259,11 +223,11 @@ static int parseTime(const QString &t, bool *ok = nullptr)
if (ok) *ok = false;
return -1;
}
- int value = t.midRef(startPos, pos - startPos).toInt(ok);
+ int value = t.mid(startPos, pos - startPos).toInt(ok);
if (ok && !*ok) return -1;
- if (t.length() == pos + 1 && t[pos] == QLatin1Char('s')) {
+ if (t.size() == pos + 1 && t[pos] == QLatin1Char('s')) {
value *= 1000;
- } else if (t.length() != pos + 2 || t[pos] != QLatin1Char('m') || t[pos + 1] != QLatin1Char('s')) {
+ } else if (t.size() != pos + 2 || t[pos] != QLatin1Char('m') || t[pos + 1] != QLatin1Char('s')) {
if (ok) *ok = false;
return -1;
}
diff --git a/src/scxml/qscxmlexecutablecontent.h b/src/scxml/qscxmlexecutablecontent.h
index 8d2ef13..9d456c2 100644
--- a/src/scxml/qscxmlexecutablecontent.h
+++ b/src/scxml/qscxmlexecutablecontent.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLEXECUTABLECONTENT_H
#define QSCXMLEXECUTABLECONTENT_H
diff --git a/src/scxml/qscxmlexecutablecontent_p.h b/src/scxml/qscxmlexecutablecontent_p.h
index 5980330..90f779f 100644
--- a/src/scxml/qscxmlexecutablecontent_p.h
+++ b/src/scxml/qscxmlexecutablecontent_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLEXECUTABLECONTENT_P_H
#define QSCXMLEXECUTABLECONTENT_P_H
@@ -404,11 +368,17 @@ struct StateTable {
return *(start + idx + 1);
}
- struct const_iterator: public std::iterator<std::forward_iterator_tag, int, ptrdiff_t,
- const int *, const int &>
+ struct const_iterator
{
const_iterator(const Array &a, int pos): a(a), pos(pos) {}
+ // std::iterator_traits
+ using value_type = int;
+ using pointer = const int*;
+ using reference = const int&;
+ using difference_type = std::ptrdiff_t;
+ using iterator_category = std::forward_iterator_tag;
+
const_iterator &operator++() {
if (pos < a.size()) ++pos;
return *this;
diff --git a/src/scxml/qscxmlglobals.h b/src/scxml/qscxmlglobals.h
index da45a2b..64169d2 100644
--- a/src/scxml/qscxmlglobals.h
+++ b/src/scxml/qscxmlglobals.h
@@ -1,59 +1,19 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLGLOBALS_H
#define QSCXMLGLOBALS_H
#include <QtCore/qglobal.h>
#include <QtScxml/qtscxml-config.h>
-QT_BEGIN_NAMESPACE
-
-#if defined(QT_STATIC) || defined(BUILD_QSCXMLC)
+#if defined(BUILD_QSCXMLC)
# define Q_SCXML_EXPORT
#else
-# ifdef QT_BUILD_SCXML_LIB
-# define Q_SCXML_EXPORT Q_DECL_EXPORT
-# else
-# define Q_SCXML_EXPORT Q_DECL_IMPORT
-# endif
+# include <QtScxml/qtscxmlexports.h>
#endif
+// Silence syncqt
+QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
#endif // QSCXMLGLOBALS_H
diff --git a/src/scxml/qscxmlglobals_p.h b/src/scxml/qscxmlglobals_p.h
index fac74dc..ba82405 100644
--- a/src/scxml/qscxmlglobals_p.h
+++ b/src/scxml/qscxmlglobals_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLGLOBALS_P_H
#define QSCXMLGLOBALS_P_H
@@ -52,7 +16,6 @@
//
#include "qscxmlglobals.h"
-
#include <QtCore/qloggingcategory.h>
QT_BEGIN_NAMESPACE
diff --git a/src/scxml/qscxmlinvokableservice.cpp b/src/scxml/qscxmlinvokableservice.cpp
index 912be00..0665406 100644
--- a/src/scxml/qscxmlinvokableservice.cpp
+++ b/src/scxml/qscxmlinvokableservice.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmlglobals_p.h"
#include "qscxmlinvokableservice_p.h"
@@ -158,8 +122,8 @@ QScxmlInvokableServicePrivate::QScxmlInvokableServicePrivate(QScxmlStateMachine
QScxmlInvokableServiceFactoryPrivate::QScxmlInvokableServiceFactoryPrivate(
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &namelist,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters)
+ const QList<QScxmlExecutableContent::StringId> &namelist,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters)
: invokeInfo(invokeInfo)
, names(namelist)
, parameters(parameters)
@@ -168,8 +132,8 @@ QScxmlInvokableServiceFactoryPrivate::QScxmlInvokableServiceFactoryPrivate(
QScxmlStaticScxmlServiceFactoryPrivate::QScxmlStaticScxmlServiceFactoryPrivate(
const QMetaObject *metaObject,
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &names,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters)
+ const QList<QScxmlExecutableContent::StringId> &names,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters)
: QScxmlInvokableServiceFactoryPrivate(invokeInfo, names, parameters), metaObject(metaObject)
{
}
@@ -188,8 +152,8 @@ QScxmlStateMachine *QScxmlInvokableService::parentStateMachine() const
QScxmlInvokableServiceFactory::QScxmlInvokableServiceFactory(
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &names,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
+ const QList<QScxmlExecutableContent::StringId> &names,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
QObject *parent)
: QObject(*(new QScxmlInvokableServiceFactoryPrivate(invokeInfo, names, parameters)), parent)
{}
@@ -200,14 +164,14 @@ const QScxmlExecutableContent::InvokeInfo &QScxmlInvokableServiceFactory::invoke
return d->invokeInfo;
}
-const QVector<QScxmlExecutableContent::ParameterInfo> &
+const QList<QScxmlExecutableContent::ParameterInfo> &
QScxmlInvokableServiceFactory::parameters() const
{
Q_D(const QScxmlInvokableServiceFactory);
return d->parameters;
}
-const QVector<QScxmlExecutableContent::StringId> &QScxmlInvokableServiceFactory::names() const
+const QList<QScxmlExecutableContent::StringId> &QScxmlInvokableServiceFactory::names() const
{
Q_D(const QScxmlInvokableServiceFactory);
return d->names;
@@ -259,8 +223,8 @@ QString QScxmlInvokableServicePrivate::calculateId(
QVariantMap QScxmlInvokableServicePrivate::calculateData(
QScxmlStateMachine *parent,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
- const QVector<QScxmlExecutableContent::StringId> &names,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
+ const QList<QScxmlExecutableContent::StringId> &names,
bool *ok) const
{
Q_ASSERT(ok);
@@ -404,8 +368,8 @@ QScxmlStateMachine *QScxmlScxmlService::stateMachine() const
*/
QScxmlDynamicScxmlServiceFactory::QScxmlDynamicScxmlServiceFactory(
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &names,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
+ const QList<QScxmlExecutableContent::StringId> &names,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
QObject *parent)
: QScxmlInvokableServiceFactory(invokeInfo, names, parameters, parent)
{}
@@ -427,8 +391,8 @@ QScxmlInvokableService *QScxmlDynamicScxmlServiceFactory::invoke(
QScxmlStaticScxmlServiceFactory::QScxmlStaticScxmlServiceFactory(
const QMetaObject *metaObject,
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &nameList,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
+ const QList<QScxmlExecutableContent::StringId> &nameList,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
QObject *parent)
: QScxmlInvokableServiceFactory(*(new QScxmlStaticScxmlServiceFactoryPrivate(
metaObject, invokeInfo, nameList, parameters)), parent)
diff --git a/src/scxml/qscxmlinvokableservice.h b/src/scxml/qscxmlinvokableservice.h
index 65ce4fc..fdf7dad 100644
--- a/src/scxml/qscxmlinvokableservice.h
+++ b/src/scxml/qscxmlinvokableservice.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLINVOKABLESERVICE_H
#define QSCXMLINVOKABLESERVICE_H
@@ -76,20 +40,20 @@ class Q_SCXML_EXPORT QScxmlInvokableServiceFactory : public QObject
Q_OBJECT
Q_DECLARE_PRIVATE(QScxmlInvokableServiceFactory)
Q_PROPERTY(QScxmlExecutableContent::InvokeInfo invokeInfo READ invokeInfo CONSTANT)
- Q_PROPERTY(QVector<QScxmlExecutableContent::ParameterInfo> parameters READ parameters CONSTANT)
- Q_PROPERTY(QVector<QScxmlExecutableContent::StringId> names READ names CONSTANT)
+ Q_PROPERTY(QList<QScxmlExecutableContent::ParameterInfo> parameters READ parameters CONSTANT)
+ Q_PROPERTY(QList<QScxmlExecutableContent::StringId> names READ names CONSTANT)
public:
QScxmlInvokableServiceFactory(
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &names,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
+ const QList<QScxmlExecutableContent::StringId> &names,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
QObject *parent = nullptr);
virtual QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) = 0;
const QScxmlExecutableContent::InvokeInfo &invokeInfo() const;
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters() const;
- const QVector<QScxmlExecutableContent::StringId> &names() const;
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters() const;
+ const QList<QScxmlExecutableContent::StringId> &names() const;
protected:
QScxmlInvokableServiceFactory(QScxmlInvokableServiceFactoryPrivate &dd, QObject *parent);
@@ -104,8 +68,8 @@ public:
QScxmlStaticScxmlServiceFactory(
const QMetaObject *metaObject,
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &nameList,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
+ const QList<QScxmlExecutableContent::StringId> &nameList,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
QObject *parent = nullptr);
QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) override;
@@ -117,8 +81,8 @@ class Q_SCXML_EXPORT QScxmlDynamicScxmlServiceFactory: public QScxmlInvokableSer
public:
QScxmlDynamicScxmlServiceFactory(
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &names,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
+ const QList<QScxmlExecutableContent::StringId> &names,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
QObject *parent = nullptr);
QScxmlInvokableService *invoke(QScxmlStateMachine *parentStateMachine) override;
diff --git a/src/scxml/qscxmlinvokableservice_p.h b/src/scxml/qscxmlinvokableservice_p.h
index dce1d64..a334c5a 100644
--- a/src/scxml/qscxmlinvokableservice_p.h
+++ b/src/scxml/qscxmlinvokableservice_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLINVOKABLESERVICE_P_H
#define QSCXMLINVOKABLESERVICE_P_H
@@ -64,8 +28,8 @@ public:
QString calculateId(QScxmlStateMachine *parent,
const QScxmlExecutableContent::InvokeInfo &invokeInfo, bool *ok) const;
QVariantMap calculateData(QScxmlStateMachine *parent,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters,
- const QVector<QScxmlExecutableContent::StringId> &names,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters,
+ const QList<QScxmlExecutableContent::StringId> &names,
bool *ok) const;
QScxmlStateMachine *parentStateMachine;
@@ -76,12 +40,12 @@ class QScxmlInvokableServiceFactoryPrivate : public QObjectPrivate
public:
QScxmlInvokableServiceFactoryPrivate(
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &names,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters);
+ const QList<QScxmlExecutableContent::StringId> &names,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters);
QScxmlExecutableContent::InvokeInfo invokeInfo;
- QVector<QScxmlExecutableContent::StringId> names;
- QVector<QScxmlExecutableContent::ParameterInfo> parameters;
+ QList<QScxmlExecutableContent::StringId> names;
+ QList<QScxmlExecutableContent::ParameterInfo> parameters;
};
class Q_SCXML_EXPORT QScxmlScxmlService: public QScxmlInvokableService
@@ -111,8 +75,8 @@ public:
QScxmlStaticScxmlServiceFactoryPrivate(
const QMetaObject *metaObject,
const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &names,
- const QVector<QScxmlExecutableContent::ParameterInfo> &parameters);
+ const QList<QScxmlExecutableContent::StringId> &names,
+ const QList<QScxmlExecutableContent::ParameterInfo> &parameters);
const QMetaObject *metaObject;
};
diff --git a/src/scxml/qscxmlnulldatamodel.cpp b/src/scxml/qscxmlnulldatamodel.cpp
index 4759d22..c62226f 100644
--- a/src/scxml/qscxmlnulldatamodel.cpp
+++ b/src/scxml/qscxmlnulldatamodel.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmlnulldatamodel.h"
#include "qscxmlevent.h"
@@ -99,7 +63,7 @@ public:
ResolvedEvaluatorInfo resolved;
if (expr.startsWith(QStringLiteral("In(")) && expr.endsWith(QLatin1Char(')'))) {
resolved.error = false;
- resolved.str = expr.mid(3, expr.length() - 4);
+ resolved.str = expr.mid(3, expr.size() - 4);
} else {
resolved.error = true;
resolved.str = QStringLiteral("%1 in %2").arg(expr, td->string(info.context));
diff --git a/src/scxml/qscxmlnulldatamodel.h b/src/scxml/qscxmlnulldatamodel.h
index b34428d..f999cf2 100644
--- a/src/scxml/qscxmlnulldatamodel.h
+++ b/src/scxml/qscxmlnulldatamodel.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLNULLDATAMODEL_H
#define QSCXMLNULLDATAMODEL_H
diff --git a/src/scxml/qscxmlstatemachine.cpp b/src/scxml/qscxmlstatemachine.cpp
index 23f8a71..04d3726 100644
--- a/src/scxml/qscxmlstatemachine.cpp
+++ b/src/scxml/qscxmlstatemachine.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmlstatemachine_p.h"
#include "qscxmlexecutablecontent_p.h"
@@ -94,16 +58,21 @@ Q_LOGGING_CATEGORY(scxmlLog, "scxml.statemachine")
*/
/*!
- \fn template<typename PointerToMemberFunction> QMetaObject::Connection QScxmlStateMachine::connectToEvent(
- const QString &scxmlEventSpec,
- const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
- PointerToMemberFunction method,
- Qt::ConnectionType type)
+ \fn template<typename Functor> QMetaObject::Connection QScxmlStateMachine::connectToEvent(
+ const QString &scxmlEventSpec,
+ const QObject *context,
+ Functor &&functor,
+ Qt::ConnectionType type)
+ \fn template<typename Functor> QMetaObject::Connection QScxmlStateMachine::connectToEvent(
+ const QString &scxmlEventSpec,
+ Functor &&functor,
+ Qt::ConnectionType type)
Creates a connection of the given \a type from the event specified by
- \a scxmlEventSpec to \a method in the \a receiver object.
+ \a scxmlEventSpec to \a functor, which can be a functor or a member function of
+ the optional \a context object.
- The receiver's \a method must take a QScxmlEvent as a parameter.
+ The receiver's \a functor must take a QScxmlEvent as a parameter.
In contrast to event specifications in SCXML documents, spaces are not
allowed in the \a scxmlEventSpec here. In order to connect to multiple
@@ -114,93 +83,28 @@ Q_LOGGING_CATEGORY(scxmlLog, "scxml.statemachine")
*/
/*!
- \fn template<typename Functor> typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction && !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type QScxmlStateMachine::connectToEvent(
- const QString &scxmlEventSpec,
- Functor functor,
- Qt::ConnectionType type)
-
- Creates a connection of the given \a type from the event specified by
- \a scxmlEventSpec to \a functor.
-
- The \a functor must take a QScxmlEvent as a parameter.
-
- In contrast to event specifications in SCXML documents, spaces are not
- allowed in the \a scxmlEventSpec here. In order to connect to multiple
- events with different prefixes, connectToEvent() has to be called multiple
- times.
-
- Returns a handle to the connection, which can be used later to disconnect.
-*/
-
-/*!
- \fn template<typename Functor> typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction && !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type QScxmlStateMachine::connectToEvent(
- const QString &scxmlEventSpec,
- const QObject *context,
- Functor functor,
- Qt::ConnectionType type)
-
- Creates a connection of the given \a type from the event specified by
- \a scxmlEventSpec to \a functor using \a context as context.
-
- The \a functor must take a QScxmlEvent as a parameter.
-
- In contrast to event specifications in SCXML documents, spaces are not
- allowed in the \a scxmlEventSpec here. In order to connect to multiple
- events with different prefixes, connectToEvent() has to be called multiple
- times.
-
- Returns a handle to the connection, which can be used later to disconnect.
-*/
-
-/*!
- \fn template<typename PointerToMemberFunction> QMetaObject::Connection QScxmlStateMachine::connectToState(
- const QString &scxmlStateName,
- const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
- PointerToMemberFunction method,
- Qt::ConnectionType type)
+ \fn template<typename Functor> QMetaObject::Connection QScxmlStateMachine::connectToState(
+ const QString &scxmlStateName,
+ const QObject *context,
+ Functor &&functor,
+ Qt::ConnectionType type)
+ \fn template<typename Functor> QMetaObject::Connection QScxmlStateMachine::connectToState(
+ const QString &scxmlStateName,
+ Functor &&functor,
+ Qt::ConnectionType type)
Creates a connection of the given \a type from the state specified by
- \a scxmlStateName to \a method in the \a receiver object.
+ \a scxmlStateName to \a functor, which can be a functor or a member function of
+ the optional \a context object.
- The receiver's \a method must take a boolean argument that indicates
+ The receiver's \a functor must take a boolean argument that indicates
whether the state connected became active or inactive.
Returns a handle to the connection, which can be used later to disconnect.
*/
/*!
- \fn template<typename Functor> typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction && !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type QScxmlStateMachine::connectToState(
- const QString &scxmlStateName,
- Functor functor,
- Qt::ConnectionType type)
-
- Creates a connection of the given \a type from the state specified by
- \a scxmlStateName to \a functor.
-
- The \a functor must take a boolean argument that indicates whether the
- state connected became active or inactive.
-
- Returns a handle to the connection, which can be used later to disconnect.
-*/
-
-/*!
- \fn template<typename Functor> typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction && !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type QScxmlStateMachine::connectToState(
- const QString &scxmlStateName,
- const QObject *context,
- Functor functor,
- Qt::ConnectionType type)
-
- Creates a connection of the given \a type from the state specified by
- \a scxmlStateName to \a functor using \a context as context.
-
- The \a functor must take a boolean argument that indicates whether the
- state connected became active or inactive.
-
- Returns a handle to the connection, which can be used later to disconnect.
-*/
-
-/*!
- \fn std::function<void(bool)> QScxmlStateMachine::onEntry(
+ \fn [onentry] std::function<void(bool)> QScxmlStateMachine::onEntry(
const QObject *receiver, const char *method)
Returns a functor that accepts a boolean argument and calls the given
@@ -215,7 +119,7 @@ Q_LOGGING_CATEGORY(scxmlLog, "scxml.statemachine")
*/
/*!
- \fn std::function<void(bool)> QScxmlStateMachine::onExit(
+ \fn [onexit] std::function<void(bool)> QScxmlStateMachine::onExit(
const QObject *receiver, const char *method)
Returns a functor that accepts a boolean argument and calls the given
@@ -230,7 +134,7 @@ Q_LOGGING_CATEGORY(scxmlLog, "scxml.statemachine")
*/
/*!
- \fn template<typename Functor> std::function<void(bool)> QScxmlStateMachine::onEntry(
+ \fn [onentry-functor] template<typename Functor> std::function<void(bool)> QScxmlStateMachine::onEntry(
Functor functor)
Returns a functor that accepts a boolean argument and calls the given
@@ -242,7 +146,7 @@ Q_LOGGING_CATEGORY(scxmlLog, "scxml.statemachine")
*/
/*!
- \fn template<typename Functor> std::function<void(bool)> QScxmlStateMachine::onExit(Functor functor)
+ \fn [onexit-functor] template<typename Functor> std::function<void(bool)> QScxmlStateMachine::onExit(Functor functor)
Returns a functor that accepts a boolean argument and calls the given
\a functor if that argument is \c false. The given \a functor must not
@@ -253,7 +157,7 @@ Q_LOGGING_CATEGORY(scxmlLog, "scxml.statemachine")
*/
/*!
- \fn template<typename PointerToMemberFunction> std::function<void(bool)> QScxmlStateMachine::onEntry(
+ \fn [onentry-template] template<typename PointerToMemberFunction> std::function<void(bool)> QScxmlStateMachine::onEntry(
const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
PointerToMemberFunction method)
@@ -267,7 +171,7 @@ Q_LOGGING_CATEGORY(scxmlLog, "scxml.statemachine")
*/
/*!
- \fn template<typename PointerToMemberFunction> std::function<void(bool)> QScxmlStateMachine::onExit(
+ \fn [onexit-template] template<typename PointerToMemberFunction> std::function<void(bool)> QScxmlStateMachine::onExit(
const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
PointerToMemberFunction method)
@@ -429,12 +333,8 @@ QScxmlStateMachinePrivate::QScxmlStateMachinePrivate(const QMetaObject *metaObje
: QObjectPrivate()
, m_sessionId(QScxmlStateMachinePrivate::generateSessionId(QStringLiteral("session-")))
, m_isInvoked(false)
- , m_isInitialized(false)
, m_isProcessingEvents(false)
- , m_dataModel(nullptr)
- , m_loader(&m_defaultLoader)
, m_executionEngine(nullptr)
- , m_tableData(nullptr)
, m_parentStateMachine(nullptr)
, m_eventLoopHook(this)
, m_metaObject(metaObject)
@@ -442,6 +342,7 @@ QScxmlStateMachinePrivate::QScxmlStateMachinePrivate(const QMetaObject *metaObje
{
static int metaType = qRegisterMetaType<QScxmlStateMachine *>();
Q_UNUSED(metaType);
+ m_loader.setValueBypassingBindings(&m_defaultLoader);
}
QScxmlStateMachinePrivate::~QScxmlStateMachinePrivate()
@@ -502,13 +403,13 @@ QScxmlInvokableServiceFactory *QScxmlStateMachinePrivate::serviceFactory(int id)
Q_ASSERT(id <= m_stateTable->maxServiceId && id >= 0);
QScxmlInvokableServiceFactory *& factory = m_cachedFactories[size_t(id)];
if (factory == nullptr)
- factory = m_tableData->serviceFactory(id);
+ factory = m_tableData.value()->serviceFactory(id);
return factory;
}
bool QScxmlStateMachinePrivate::executeInitialSetup()
{
- return m_executionEngine->execute(m_tableData->initialSetup());
+ return m_executionEngine->execute(m_tableData.value()->initialSetup());
}
void QScxmlStateMachinePrivate::routeEvent(QScxmlEvent *event)
@@ -529,7 +430,7 @@ void QScxmlStateMachinePrivate::routeEvent(QScxmlEvent *event)
}
} else if (origin.startsWith(QStringLiteral("#_")) && origin != QStringLiteral("#_internal")) {
// route to children
- auto originId = origin.midRef(2);
+ auto originId = QStringView{origin}.mid(2);
for (const auto &invokedService : m_invokedServices) {
auto service = invokedService.service;
if (service == nullptr)
@@ -727,12 +628,12 @@ void QScxmlStateMachinePrivate::processEvents()
void QScxmlStateMachinePrivate::setEvent(QScxmlEvent *event)
{
Q_ASSERT(event);
- m_dataModel->setScxmlEvent(*event);
+ m_dataModel.value()->setScxmlEvent(*event);
}
void QScxmlStateMachinePrivate::resetEvent()
{
- m_dataModel->setScxmlEvent(QScxmlEvent());
+ m_dataModel.value()->setScxmlEvent(QScxmlEvent());
}
void QScxmlStateMachinePrivate::emitStateActive(int stateIndex, bool active)
@@ -747,6 +648,7 @@ void QScxmlStateMachinePrivate::emitStateActive(int stateIndex, bool active)
void QScxmlStateMachinePrivate::emitInvokedServicesChanged()
{
Q_Q(QScxmlStateMachine);
+ m_invokedServicesComputedProperty.notify();
emit q->invokedServicesChanged(q->invokedServices());
}
@@ -767,10 +669,14 @@ void QScxmlStateMachinePrivate::attach(QScxmlStateMachineInfo *info)
void QScxmlStateMachinePrivate::updateMetaCache()
{
+ // This function creates a mapping from state index/name to their signal indexes.
+ // The state index may differ from its signal index as we don't generate history
+ // and invalid states, effectively skipping them
m_stateIndexToSignalIndex.clear();
m_stateNameToSignalIndex.clear();
- if (!m_tableData)
+ const QScxmlTableData *tableData = m_tableData.valueBypassingBindings();
+ if (!tableData)
return;
if (!m_stateTable)
@@ -782,7 +688,7 @@ void QScxmlStateMachinePrivate::updateMetaCache()
const auto &s = m_stateTable->state(i);
if (!s.isHistoryState() && s.type != StateTable::State::Invalid) {
m_stateIndexToSignalIndex.insert(i, signalIndex);
- m_stateNameToSignalIndex.insert(m_tableData->string(s.name),
+ m_stateNameToSignalIndex.insert(tableData->string(s.name),
signalIndex + methodOffset);
++signalIndex;
@@ -794,7 +700,7 @@ QStringList QScxmlStateMachinePrivate::stateNames(const std::vector<int> &stateI
{
QStringList names;
for (int idx : stateIndexes)
- names.append(m_tableData->string(m_stateTable->state(idx).name));
+ names.append(m_tableData.value()->string(m_stateTable->state(idx).name));
return names;
}
@@ -852,7 +758,7 @@ bool QScxmlStateMachinePrivate::nameMatch(const StateTable::Array &patterns,
const QString eventName = event->name();
bool selected = false;
for (int eventSelectorIter = 0; eventSelectorIter < patterns.size(); ++eventSelectorIter) {
- QString eventStr = m_tableData->string(patterns[eventSelectorIter]);
+ QString eventStr = m_tableData.value()->string(patterns[eventSelectorIter]);
if (eventStr == QStringLiteral("*")) {
selected = true;
break;
@@ -913,7 +819,7 @@ void QScxmlStateMachinePrivate::selectTransitions(OrderedSet &enabledTransitions
enabled = true;
} else {
bool ok = false;
- enabled = m_dataModel->evaluateToBool(t.condition, &ok) && ok;
+ enabled = m_dataModel.value()->evaluateToBool(t.condition, &ok) && ok;
}
}
} else {
@@ -922,7 +828,7 @@ void QScxmlStateMachinePrivate::selectTransitions(OrderedSet &enabledTransitions
enabled = true;
} else {
bool ok = false;
- enabled = m_dataModel->evaluateToBool(t.condition, &ok) && ok;
+ enabled = m_dataModel.value()->evaluateToBool(t.condition, &ok) && ok;
}
}
}
@@ -1037,13 +943,13 @@ void QScxmlStateMachinePrivate::microstep(const OrderedSet &enabledTransitions)
const auto &transition = m_stateTable->transition(t);
QString from = QStringLiteral("(none)");
if (transition.source != StateTable::InvalidIndex)
- from = m_tableData->string(m_stateTable->state(transition.source).name);
+ from = m_tableData.value()->string(m_stateTable->state(transition.source).name);
QStringList to;
if (transition.targets == StateTable::InvalidIndex) {
to.append(QStringLiteral("(none)"));
} else {
for (int t : m_stateTable->array(transition.targets))
- to.append(m_tableData->string(m_stateTable->state(t).name));
+ to.append(m_tableData.value()->string(m_stateTable->state(t).name));
}
qCDebug(qscxmlLog) << q_func() << "\t" << t << ":" << from << "->"
<< to.join(QLatin1Char(','));
@@ -1073,7 +979,7 @@ void QScxmlStateMachinePrivate::exitStates(const OrderedSet &enabledTransitions)
for (int s : statesToExitSorted) {
for (int h : historyStates(s)) {
const auto &hState = m_stateTable->state(h);
- QVector<int> history;
+ QList<int> history;
for (int s0 : m_configuration) {
const auto &s0State = m_stateTable->state(s0);
@@ -1100,7 +1006,7 @@ void QScxmlStateMachinePrivate::exitStates(const OrderedSet &enabledTransitions)
if (m_infoSignalProxy) {
emit m_infoSignalProxy->statesExited(
- QVector<QScxmlStateMachineInfo::StateId>(statesToExitSorted.begin(),
+ QList<QScxmlStateMachineInfo::StateId>(statesToExitSorted.begin(),
statesToExitSorted.end()));
}
}
@@ -1132,7 +1038,7 @@ void QScxmlStateMachinePrivate::executeTransitionContent(const OrderedSet &enabl
if (m_infoSignalProxy) {
emit m_infoSignalProxy->transitionsTriggered(
- QVector<QScxmlStateMachineInfo::TransitionId>(enabledTransitions.list().begin(),
+ QList<QScxmlStateMachineInfo::TransitionId>(enabledTransitions.list().begin(),
enabledTransitions.list().end()));
}
}
@@ -1176,7 +1082,7 @@ void QScxmlStateMachinePrivate::enterStates(const OrderedSet &enabledTransitions
emit q->runningChanged(false);
} else {
const auto &parent = m_stateTable->state(state.parent);
- m_executionEngine->execute(state.doneData, m_tableData->string(parent.name));
+ m_executionEngine->execute(state.doneData, m_tableData.value()->string(parent.name));
if (parent.parent != StateTable::InvalidIndex) {
const auto &grandParent = m_stateTable->state(parent.parent);
if (grandParent.isParallel()) {
@@ -1184,7 +1090,7 @@ void QScxmlStateMachinePrivate::enterStates(const OrderedSet &enabledTransitions
auto e = new QScxmlEvent;
e->setEventType(QScxmlEvent::InternalEvent);
e->setName(QStringLiteral("done.state.")
- + m_tableData->string(grandParent.name));
+ + m_tableData.value()->string(grandParent.name));
q->submitEvent(e);
}
}
@@ -1196,7 +1102,7 @@ void QScxmlStateMachinePrivate::enterStates(const OrderedSet &enabledTransitions
emitStateActive(s, true);
if (m_infoSignalProxy) {
emit m_infoSignalProxy->statesEntered(
- QVector<QScxmlStateMachineInfo::StateId>(sortedStates.begin(),
+ QList<QScxmlStateMachineInfo::StateId>(sortedStates.begin(),
sortedStates.end()));
}
}
@@ -1247,7 +1153,15 @@ void QScxmlStateMachinePrivate::addDescendantStatesToEnter(
addAncestorStatesToEnter(s, state.parent, statesToEnter, statesForDefaultEntry,
defaultHistoryContent);
} else {
- const auto transitionIdx = m_stateTable->array(state.transitions)[0];
+ int transitionIdx = StateTable::InvalidIndex;
+ if (state.transitions == StateTable::InvalidIndex) {
+ int parentInitialTransition = m_stateTable->state(state.parent).initialTransition;
+ if (parentInitialTransition == StateTable::InvalidIndex)
+ return;
+ transitionIdx = parentInitialTransition;
+ } else {
+ transitionIdx = m_stateTable->array(state.transitions)[0];
+ }
const auto &defaultHistoryTransition = m_stateTable->transition(transitionIdx);
defaultHistoryContent->operator[](state.parent) =
defaultHistoryTransition.transitionInstructions;
@@ -1457,7 +1371,7 @@ void QScxmlStateMachinePrivate::getEffectiveTargetStates(OrderedSet *targets,
for (int historyState : historyValueIter.value()) {
targets->add(historyState);
}
- } else {
+ } else if (state.transitions != StateTable::InvalidIndex) {
getEffectiveTargetStates(targets, m_stateTable->array(state.transitions)[0]);
}
} else {
@@ -1507,10 +1421,10 @@ QScxmlStateMachine *QScxmlStateMachine::fromData(QIODevice *data, const QString
return compiler.compile();
}
-QVector<QScxmlError> QScxmlStateMachine::parseErrors() const
+QList<QScxmlError> QScxmlStateMachine::parseErrors() const
{
Q_D(const QScxmlStateMachine);
- return d->m_parserData ? d->m_parserData->m_errors : QVector<QScxmlError>();
+ return d->m_parserData ? d->m_parserData->m_errors : QList<QScxmlError>();
}
QScxmlStateMachine::QScxmlStateMachine(const QMetaObject *metaObject, QObject *parent)
@@ -1553,8 +1467,7 @@ QScxmlStateMachine::QScxmlStateMachine(QScxmlStateMachinePrivate &dd, QObject *p
Changing the data model when the state machine has been \c initialized is
not specified in the SCXML standard and leads to undefined behavior.
- \sa QScxmlDataModel, QScxmlNullDataModel, QScxmlEcmaScriptDataModel,
- QScxmlCppDataModel
+ \sa QScxmlDataModel, QScxmlNullDataModel, QScxmlCppDataModel
*/
/*!
@@ -1569,8 +1482,7 @@ QScxmlStateMachine::QScxmlStateMachine(QScxmlStateMachinePrivate &dd, QObject *p
Changing the data model when the state machine has been \l initialized is
not specified in the SCXML standard and leads to undefined behavior.
- \sa QScxmlDataModel, QScxmlNullDataModel, QScxmlEcmaScriptDataModel,
- QScxmlCppDataModel
+ \sa QScxmlDataModel, QScxmlNullDataModel, QScxmlCppDataModel
*/
/*!
@@ -1723,6 +1635,12 @@ bool QScxmlStateMachine::isInitialized() const
return d->m_isInitialized;
}
+QBindable<bool> QScxmlStateMachine::bindableInitialized() const
+{
+ Q_D(const QScxmlStateMachine);
+ return &d->m_isInitialized;
+}
+
/*!
* Sets the data model for this state machine to \a model. There is a 1:1
* relation between state machines and models. After setting the model once you
@@ -1733,10 +1651,13 @@ void QScxmlStateMachine::setDataModel(QScxmlDataModel *model)
{
Q_D(QScxmlStateMachine);
- if (d->m_dataModel == nullptr && model != nullptr) {
- d->m_dataModel = model;
- if (model)
- model->setStateMachine(this);
+ if (d->m_dataModel.valueBypassingBindings() == nullptr && model != nullptr) {
+ // the binding is removed only on the first valid set
+ // as the later attempts are ignored
+ d->m_dataModel.removeBindingUnlessInWrapper();
+ d->m_dataModel.setValueBypassingBindings(model);
+ model->setStateMachine(this);
+ d->m_dataModel.notify();
emit dataModelChanged(model);
}
}
@@ -1751,14 +1672,16 @@ QScxmlDataModel *QScxmlStateMachine::dataModel() const
return d->m_dataModel;
}
-void QScxmlStateMachine::setLoader(QScxmlCompiler::Loader *loader)
+QBindable<QScxmlDataModel*> QScxmlStateMachine::bindableDataModel()
{
Q_D(QScxmlStateMachine);
+ return &d->m_dataModel;
+}
- if (loader != d->m_loader) {
- d->m_loader = loader;
- emit loaderChanged(loader);
- }
+void QScxmlStateMachine::setLoader(QScxmlCompiler::Loader *loader)
+{
+ Q_D(QScxmlStateMachine);
+ d->m_loader.setValue(loader);
}
QScxmlCompiler::Loader *QScxmlStateMachine::loader() const
@@ -1768,6 +1691,12 @@ QScxmlCompiler::Loader *QScxmlStateMachine::loader() const
return d->m_loader;
}
+QBindable<QScxmlCompiler::Loader*> QScxmlStateMachine::bindableLoader()
+{
+ Q_D(QScxmlStateMachine);
+ return &d->m_loader;
+}
+
QScxmlTableData *QScxmlStateMachine::tableData() const
{
Q_D(const QScxmlStateMachine);
@@ -1779,14 +1708,18 @@ void QScxmlStateMachine::setTableData(QScxmlTableData *tableData)
{
Q_D(QScxmlStateMachine);
- if (d->m_tableData == tableData)
+ d->m_tableData.removeBindingUnlessInWrapper();
+ if (d->m_tableData.valueBypassingBindings() == tableData)
return;
- d->m_tableData = tableData;
+ d->m_tableData.setValueBypassingBindings(tableData);
if (tableData) {
d->m_stateTable = reinterpret_cast<const QScxmlExecutableContent::StateTable *>(
tableData->stateMachineTable());
- if (objectName().isEmpty()) {
+ // cannot use objectName() here, because it creates binding loop
+ const QString currentObjectName = d->extraData
+ ? d->extraData->objectName.valueBypassingBindings() : QString();
+ if (currentObjectName.isEmpty()) {
setObjectName(tableData->name());
}
if (d->m_stateTable->maxServiceId != QScxmlExecutableContent::StateTable::InvalidIndex) {
@@ -1806,9 +1739,16 @@ void QScxmlStateMachine::setTableData(QScxmlTableData *tableData)
d->updateMetaCache();
+ d->m_tableData.notify();
emit tableDataChanged(tableData);
}
+QBindable<QScxmlTableData*> QScxmlStateMachine::bindableTableData()
+{
+ Q_D(QScxmlStateMachine);
+ return &d->m_tableData;
+}
+
/*!
\qmlmethod ScxmlStateMachine::stateNames(bool compress)
@@ -1845,7 +1785,7 @@ QStringList QScxmlStateMachine::stateNames(bool compress) const
for (int i = 0; i < d->m_stateTable->stateCount; ++i) {
const auto &state = d->m_stateTable->state(i);
if (!compress || state.isAtomic())
- names.append(d->m_tableData->string(state.name));
+ names.append(d->m_tableData.value()->string(state.name));
}
return names;
}
@@ -1876,7 +1816,7 @@ QStringList QScxmlStateMachine::activeStateNames(bool compress) const
for (int stateIdx : d->m_configuration) {
const auto &state = d->m_stateTable->state(stateIdx);
if (state.isAtomic() || !compress)
- result.append(d->m_tableData->string(state.name));
+ result.append(d->m_tableData.value()->string(state.name));
}
return result;
}
@@ -1897,7 +1837,7 @@ bool QScxmlStateMachine::isActive(const QString &scxmlStateName) const
for (int stateIndex : d->m_configuration) {
const auto &state = d->m_stateTable->state(stateIndex);
- if (d->m_tableData->string(state.name) == scxmlStateName)
+ if (d->m_tableData.value()->string(state.name) == scxmlStateName)
return true;
}
@@ -1914,7 +1854,7 @@ QMetaObject::Connection QScxmlStateMachine::connectToStateImpl(const QString &sc
types = QtPrivate::ConnectionTypes<QtPrivate::List<bool> >::types();
Q_D(QScxmlStateMachine);
- const int signalIndex = d->m_stateNameToSignalIndex.value(scxmlStateName);
+ const int signalIndex = d->m_stateNameToSignalIndex.value(scxmlStateName, -1);
return signalIndex < 0 ? QMetaObject::Connection()
: QObjectPrivate::connectImpl(this, signalIndex, receiver, slot, slotObj,
type, types, d->m_metaObject);
@@ -2003,20 +1943,19 @@ bool QScxmlStateMachine::init()
{
Q_D(QScxmlStateMachine);
- if (d->m_isInitialized)
+ if (d->m_isInitialized.value())
return false;
if (!parseErrors().isEmpty())
return false;
- if (!dataModel() || !dataModel()->setup(d->m_initialValues))
+ if (!dataModel() || !dataModel()->setup(d->m_initialValues.value()))
return false;
if (!d->executeInitialSetup())
return false;
- d->m_isInitialized = true;
- emit initializedChanged(true);
+ d->m_isInitialized.setValue(true);
return true;
}
@@ -2054,10 +1993,13 @@ QVariantMap QScxmlStateMachine::initialValues()
void QScxmlStateMachine::setInitialValues(const QVariantMap &initialValues)
{
Q_D(QScxmlStateMachine);
- if (initialValues != d->m_initialValues) {
- d->m_initialValues = initialValues;
- emit initialValuesChanged(initialValues);
- }
+ d->m_initialValues.setValue(initialValues);
+}
+
+QBindable<QVariantMap> QScxmlStateMachine::bindableInitialValues()
+{
+ Q_D(QScxmlStateMachine);
+ return &d->m_initialValues;
}
QString QScxmlStateMachine::name() const
@@ -2206,7 +2148,7 @@ bool QScxmlStateMachine::isDispatchableTarget(const QString &target) const
return true; // that's the current state machine
if (target.startsWith(QStringLiteral("#_"))) {
- QStringRef targetId = target.midRef(2);
+ QStringView targetId = QStringView{target}.mid(2);
for (auto invokedService : d->m_invokedServices) {
if (invokedService.service && invokedService.service->id() == targetId)
return true;
@@ -2229,16 +2171,16 @@ bool QScxmlStateMachine::isDispatchableTarget(const QString &target) const
state machine (possibly recursively).
*/
-QVector<QScxmlInvokableService *> QScxmlStateMachine::invokedServices() const
+QList<QScxmlInvokableService *> QScxmlStateMachine::invokedServices() const
{
Q_D(const QScxmlStateMachine);
+ return d->m_invokedServicesComputedProperty;
+}
- QVector<QScxmlInvokableService *> result;
- for (int i = 0, ei = int(d->m_invokedServices.size()); i != ei; ++i) {
- if (auto service = d->m_invokedServices[size_t(i)].service)
- result.append(service);
- }
- return result;
+QBindable<QList<QScxmlInvokableService*>> QScxmlStateMachine::bindableInvokedServices()
+{
+ Q_D(QScxmlStateMachine);
+ return &d->m_invokedServicesComputedProperty;
}
/*!
@@ -2310,20 +2252,28 @@ QVector<QScxmlInvokableService *> QScxmlStateMachine::invokedServices() const
*/
/*!
- Starts this state machine. The machine will reset its configuration and
- transition to the initial state. When a final top-level state
+ Starts this state machine. When a final top-level state
is entered, the machine will emit the finished() signal.
\note A state machine will not run without a running event loop, such as
the main application event loop started with QCoreApplication::exec() or
QApplication::exec().
+ \note Calling start() after stop() will not result in a full reset of its
+ configuration yet, hence it is strongly advised not to do it.
+
+ \note Starting a finished machine yields a warning.
+
\sa runningChanged(), setRunning(), stop(), finished()
*/
void QScxmlStateMachine::start()
{
Q_D(QScxmlStateMachine);
+ if (d->isFinished()) {
+ qCWarning(qscxmlLog) << this << "Can't start finished machine";
+ }
+
if (!parseErrors().isEmpty())
return;
@@ -2366,7 +2316,11 @@ void QScxmlStateMachine::stop()
bool QScxmlStateMachine::isActive(int stateIndex) const
{
Q_D(const QScxmlStateMachine);
- return d->m_configuration.contains(stateIndex);
+ // Here we need to find the actual internal state index that corresponds with the
+ // index of the compiled metaobject (which is same as its mapped signal index).
+ // See updateMetaCache()
+ const int mappedStateIndex = d->m_stateIndexToSignalIndex.key(stateIndex, -1);
+ return d->m_configuration.contains(mappedStateIndex);
}
QT_END_NAMESPACE
diff --git a/src/scxml/qscxmlstatemachine.h b/src/scxml/qscxmlstatemachine.h
index a0a4e8b..a63a602 100644
--- a/src/scxml/qscxmlstatemachine.h
+++ b/src/scxml/qscxmlstatemachine.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLSTATEMACHINE_H
#define QSCXMLSTATEMACHINE_H
@@ -46,18 +10,21 @@
#include <QtScxml/qscxmlcompiler.h>
#include <QtScxml/qscxmlinvokableservice.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qpointer.h>
#include <QtCore/qstring.h>
-#include <QtCore/qvector.h>
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
-#include <QtCore/qpointer.h>
#include <functional>
+Q_MOC_INCLUDE(qscxmltabledata.h)
+
QT_BEGIN_NAMESPACE
class QIODevice;
class QXmlStreamWriter;
class QTextStream;
+class QScxmlTableData;
class QScxmlStateMachinePrivate;
class Q_SCXML_EXPORT QScxmlStateMachine: public QObject
@@ -65,16 +32,22 @@ class Q_SCXML_EXPORT QScxmlStateMachine: public QObject
Q_DECLARE_PRIVATE(QScxmlStateMachine)
Q_OBJECT
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
- Q_PROPERTY(bool initialized READ isInitialized NOTIFY initializedChanged)
- Q_PROPERTY(QScxmlDataModel *dataModel READ dataModel WRITE setDataModel NOTIFY dataModelChanged)
- Q_PROPERTY(QVariantMap initialValues READ initialValues WRITE setInitialValues NOTIFY initialValuesChanged)
- Q_PROPERTY(QVector<QScxmlInvokableService*> invokedServices READ invokedServices NOTIFY invokedServicesChanged)
+ Q_PROPERTY(bool initialized READ isInitialized
+ NOTIFY initializedChanged BINDABLE bindableInitialized)
+ Q_PROPERTY(QScxmlDataModel *dataModel READ dataModel WRITE setDataModel
+ NOTIFY dataModelChanged BINDABLE bindableDataModel)
+ Q_PROPERTY(QVariantMap initialValues READ initialValues WRITE setInitialValues
+ NOTIFY initialValuesChanged BINDABLE bindableInitialValues)
+ Q_PROPERTY(QList<QScxmlInvokableService*> invokedServices READ invokedServices
+ NOTIFY invokedServicesChanged BINDABLE bindableInvokedServices)
Q_PROPERTY(QString sessionId READ sessionId CONSTANT)
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(bool invoked READ isInvoked CONSTANT)
- Q_PROPERTY(QVector<QScxmlError> parseErrors READ parseErrors CONSTANT)
- Q_PROPERTY(QScxmlCompiler::Loader *loader READ loader WRITE setLoader NOTIFY loaderChanged)
- Q_PROPERTY(QScxmlTableData *tableData READ tableData WRITE setTableData NOTIFY tableDataChanged)
+ Q_PROPERTY(QList<QScxmlError> parseErrors READ parseErrors CONSTANT)
+ Q_PROPERTY(QScxmlCompiler::Loader *loader READ loader WRITE setLoader
+ NOTIFY loaderChanged BINDABLE bindableLoader)
+ Q_PROPERTY(QScxmlTableData *tableData READ tableData WRITE setTableData
+ NOTIFY tableDataChanged BINDABLE bindableTableData)
protected:
explicit QScxmlStateMachine(const QMetaObject *metaObject, QObject *parent = nullptr);
@@ -83,24 +56,28 @@ protected:
public:
static QScxmlStateMachine *fromFile(const QString &fileName);
static QScxmlStateMachine *fromData(QIODevice *data, const QString &fileName = QString());
- QVector<QScxmlError> parseErrors() const;
+ QList<QScxmlError> parseErrors() const;
QString sessionId() const;
bool isInvoked() const;
bool isInitialized() const;
+ QBindable<bool> bindableInitialized() const;
void setDataModel(QScxmlDataModel *model);
QScxmlDataModel *dataModel() const;
+ QBindable<QScxmlDataModel*> bindableDataModel();
void setLoader(QScxmlCompiler::Loader *loader);
QScxmlCompiler::Loader *loader() const;
+ QBindable<QScxmlCompiler::Loader*> bindableLoader();
bool isRunning() const;
void setRunning(bool running);
QVariantMap initialValues();
void setInitialValues(const QVariantMap &initialValues);
+ QBindable<QVariantMap> bindableInitialValues();
QString name() const;
Q_INVOKABLE QStringList stateNames(bool compress = true) const;
@@ -111,48 +88,46 @@ public:
const QObject *receiver, const char *method,
Qt::ConnectionType type = Qt::AutoConnection);
- // connect state to a QObject slot
- template <typename PointerToMemberFunction>
- inline QMetaObject::Connection connectToState(
+ // connect state with context
+ template <typename Functor>
+#ifdef Q_QDOC
+ QMetaObject::Connection
+#else
+ inline std::enable_if_t<!std::is_same_v<const char*, Functor>, QMetaObject::Connection>
+#endif
+ connectToState(
const QString &scxmlStateName,
- const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
- PointerToMemberFunction method,
+#ifdef Q_QDOC
+ const QObject *context,
+#else
+ const typename QtPrivate::ContextTypeForFunctor<Functor>::ContextType *context,
+#endif
+ Functor &&functor,
Qt::ConnectionType type = Qt::AutoConnection)
{
- typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SlotType;
+ using Prototype = void(*)(bool);
return connectToStateImpl(
- scxmlStateName, receiver, nullptr,
- new QtPrivate::QSlotObject<PointerToMemberFunction,
- typename SlotType::Arguments, void>(method),
+ scxmlStateName, context, nullptr,
+ QtPrivate::makeCallableObject<Prototype>(std::forward<Functor>(functor)),
type);
}
- // connect state to a functor or function pointer (without context)
- template <typename Functor>
- inline typename QtPrivate::QEnableIf<
- !QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction &&
- !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type
- connectToState(const QString &scxmlStateName, Functor functor,
- Qt::ConnectionType type = Qt::AutoConnection)
- {
- // Use this as context
- return connectToState(scxmlStateName, this, functor, type);
- }
-
- // connectToState to a functor or function pointer (with context)
+ // connect state without context
template <typename Functor>
- inline typename QtPrivate::QEnableIf<
- !QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction &&
- !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type
- connectToState(const QString &scxmlStateName, const QObject *context, Functor functor,
- Qt::ConnectionType type = Qt::AutoConnection)
+#ifdef Q_QDOC
+ QMetaObject::Connection
+#else
+ inline std::enable_if_t<!std::is_same_v<const char*, Functor>, QMetaObject::Connection>
+#endif
+ connectToState(
+ const QString &scxmlStateName,
+ Functor &&functor,
+ Qt::ConnectionType type = Qt::AutoConnection)
{
- QtPrivate::QSlotObjectBase *slotObj = new QtPrivate::QFunctorSlotObject<Functor, 1,
- QtPrivate::List<bool>, void>(functor);
- return connectToStateImpl(scxmlStateName, context, reinterpret_cast<void **>(&functor),
- slotObj, type);
+ return connectToState(scxmlStateName, this, std::forward<Functor>(functor), type);
}
+ //! [onentry]
static std::function<void(bool)> onEntry(const QObject *receiver, const char *method)
{
const QPointer<QObject> receiverPointer(const_cast<QObject *>(receiver));
@@ -162,6 +137,7 @@ public:
};
}
+ //! [onexit]
static std::function<void(bool)> onExit(const QObject *receiver, const char *method)
{
const QPointer<QObject> receiverPointer(const_cast<QObject *>(receiver));
@@ -171,6 +147,7 @@ public:
};
}
+ //! [onentry-functor]
template<typename Functor>
static std::function<void(bool)> onEntry(Functor functor)
{
@@ -180,6 +157,7 @@ public:
};
}
+ //! [onexit-functor]
template<typename Functor>
static std::function<void(bool)> onExit(Functor functor)
{
@@ -189,6 +167,7 @@ public:
};
}
+ //! [onentry-template]
template<typename PointerToMemberFunction>
static std::function<void(bool)> onEntry(
const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
@@ -202,6 +181,7 @@ public:
};
}
+ //! [onexit-template]
template<typename PointerToMemberFunction>
static std::function<void(bool)> onExit(
const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
@@ -219,46 +199,42 @@ public:
const QObject *receiver, const char *method,
Qt::ConnectionType type = Qt::AutoConnection);
- // connect state to a QObject slot
- template <typename PointerToMemberFunction>
- inline QMetaObject::Connection connectToEvent(
+ // connect event with context
+ template <typename Functor>
+#ifdef Q_QDOC
+ QMetaObject::Connection
+#else
+ inline std::enable_if_t<!std::is_same_v<const char*, Functor>, QMetaObject::Connection>
+#endif
+ connectToEvent(
const QString &scxmlEventSpec,
- const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
- PointerToMemberFunction method,
+#ifdef Q_QDOC
+ const QObject *context,
+#else
+ const typename QtPrivate::ContextTypeForFunctor<Functor>::ContextType *context,
+#endif
+ Functor &&functor,
Qt::ConnectionType type = Qt::AutoConnection)
{
- typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SlotType;
+ using Prototype = void(*)(QScxmlEvent);
return connectToEventImpl(
- scxmlEventSpec, receiver, nullptr,
- new QtPrivate::QSlotObject<PointerToMemberFunction,
- typename SlotType::Arguments, void>(method),
+ scxmlEventSpec, context, nullptr,
+ QtPrivate::makeCallableObject<Prototype>(std::forward<Functor>(functor)),
type);
}
- // connect state to a functor or function pointer (without context)
+ // connect event without context
template <typename Functor>
- inline typename QtPrivate::QEnableIf<
- !QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction &&
- !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type
- connectToEvent(const QString &scxmlEventSpec, Functor functor,
+#ifdef Q_QDOC
+ QMetaObject::Connection
+#else
+ inline std::enable_if_t<!std::is_same_v<const char*, Functor>, QMetaObject::Connection>
+#endif
+ connectToEvent(const QString &scxmlEventSpec, Functor &&functor,
Qt::ConnectionType type = Qt::AutoConnection)
{
// Use this as context
- return connectToEvent(scxmlEventSpec, this, functor, type);
- }
-
- // connectToEvent to a functor or function pointer (with context)
- template <typename Functor>
- inline typename QtPrivate::QEnableIf<
- !QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction &&
- !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type
- connectToEvent(const QString &scxmlEventSpec, const QObject *context, Functor functor,
- Qt::ConnectionType type = Qt::AutoConnection)
- {
- QtPrivate::QSlotObjectBase *slotObj = new QtPrivate::QFunctorSlotObject<Functor, 1,
- QtPrivate::List<QScxmlEvent>, void>(functor);
- return connectToEventImpl(scxmlEventSpec, context, reinterpret_cast<void **>(&functor),
- slotObj, type);
+ return connectToEvent(scxmlEventSpec, this, std::forward<Functor>(functor), type);
}
Q_INVOKABLE void submitEvent(QScxmlEvent *event);
@@ -268,14 +244,16 @@ public:
Q_INVOKABLE bool isDispatchableTarget(const QString &target) const;
- QVector<QScxmlInvokableService *> invokedServices() const;
+ QList<QScxmlInvokableService *> invokedServices() const;
+ QBindable<QList<QScxmlInvokableService*>> bindableInvokedServices();
QScxmlTableData *tableData() const;
void setTableData(QScxmlTableData *tableData);
+ QBindable<QScxmlTableData*> bindableTableData();
Q_SIGNALS:
void runningChanged(bool running);
- void invokedServicesChanged(const QVector<QScxmlInvokableService *> &invokedServices);
+ void invokedServicesChanged(const QList<QScxmlInvokableService *> &invokedServices);
void log(const QString &label, const QString &msg);
void reachedStableState();
void finished();
@@ -313,6 +291,6 @@ private:
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QScxmlStateMachine *)
-Q_DECLARE_METATYPE(QVector<QScxmlInvokableService *>)
+Q_DECLARE_METATYPE(QList<QScxmlInvokableService *>)
#endif // QSCXMLSTATEMACHINE_H
diff --git a/src/scxml/qscxmlstatemachine_p.h b/src/scxml/qscxmlstatemachine_p.h
index 1c354fa..3d18ffc 100644
--- a/src/scxml/qscxmlstatemachine_p.h
+++ b/src/scxml/qscxmlstatemachine_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLSTATEMACHINE_P_H
#define QSCXMLSTATEMACHINE_P_H
@@ -56,7 +20,12 @@
#include <QtScxml/private/qscxmlstatemachineinfo_p.h>
#include <QtCore/private/qobject_p.h>
#include <QtCore/private/qmetaobject_p.h>
+#include <QtCore/private/qproperty_p.h>
+#include <QtCore/qhash.h>
+#include <QtCore/qmap.h>
+#include <QtCore/qvariant.h>
#include <QtCore/qmetaobject.h>
+#include "qscxmlglobals_p.h"
QT_BEGIN_NAMESPACE
@@ -113,14 +82,14 @@ public:
{}
Q_SIGNALS:
- void statesEntered(const QVector<QScxmlStateMachineInfo::StateId> &states);
- void statesExited(const QVector<QScxmlStateMachineInfo::StateId> &states);
- void transitionsTriggered(const QVector<QScxmlStateMachineInfo::TransitionId> &transitions);
+ void statesEntered(const QList<QScxmlStateMachineInfo::StateId> &states);
+ void statesExited(const QList<QScxmlStateMachineInfo::StateId> &states);
+ void transitionsTriggered(const QList<QScxmlStateMachineInfo::TransitionId> &transitions);
};
} // QScxmlInternal namespace
class QScxmlInvokableService;
-class QScxmlStateMachinePrivate: public QObjectPrivate
+class Q_SCXML_EXPORT QScxmlStateMachinePrivate: public QObjectPrivate
{
Q_DECLARE_PUBLIC(QScxmlStateMachine)
@@ -152,7 +121,7 @@ public: // types
{
public:
QScopedPointer<QScxmlDataModel> m_ownedDataModel;
- QVector<QScxmlError> m_errors;
+ QList<QScxmlError> m_errors;
};
// The OrderedSet is a set where it elements are in insertion order. See
@@ -216,7 +185,7 @@ public: // types
class Queue
{
- QVector<QScxmlEvent *> storage;
+ QList<QScxmlEvent *> storage;
public:
Queue()
@@ -328,14 +297,46 @@ private:
public: // types & data fields:
QString m_sessionId;
bool m_isInvoked;
- bool m_isInitialized;
+
+ void isInitializedChanged()
+ {
+ emit q_func()->initializedChanged(m_isInitialized.value());
+ }
+ Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QScxmlStateMachinePrivate,
+ bool, m_isInitialized, false,
+ &QScxmlStateMachinePrivate::isInitializedChanged);
+
+ void initialValuesChanged()
+ {
+ emit q_func()->initialValuesChanged(m_initialValues.value());
+ }
+ Q_OBJECT_BINDABLE_PROPERTY(QScxmlStateMachinePrivate, QVariantMap, m_initialValues,
+ &QScxmlStateMachinePrivate::initialValuesChanged);
+
+ void loaderChanged()
+ {
+ emit q_func()->loaderChanged(m_loader.value());
+ }
+ Q_OBJECT_BINDABLE_PROPERTY(QScxmlStateMachinePrivate, QScxmlCompiler::Loader*, m_loader,
+ &QScxmlStateMachinePrivate::loaderChanged);
+
+ void setDataModel(QScxmlDataModel* loader)
+ {
+ q_func()->setDataModel(loader);
+ }
+ Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QScxmlStateMachinePrivate, QScxmlDataModel*, m_dataModel,
+ &QScxmlStateMachinePrivate::setDataModel, nullptr);
+
+ void setTableData(QScxmlTableData* tableData)
+ {
+ q_func()->setTableData(tableData);
+ }
+ Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QScxmlStateMachinePrivate, QScxmlTableData*, m_tableData,
+ &QScxmlStateMachinePrivate::setTableData, nullptr);
+
bool m_isProcessingEvents;
- QVariantMap m_initialValues;
- QScxmlDataModel *m_dataModel;
QScxmlCompilerPrivate::DefaultLoader m_defaultLoader;
- QScxmlCompiler::Loader *m_loader;
QScxmlExecutionEngine *m_executionEngine;
- QScxmlTableData *m_tableData;
const StateTable *m_stateTable;
QScxmlStateMachine *m_parentStateMachine;
QScxmlInternal::EventLoopHook m_eventLoopHook;
@@ -346,7 +347,7 @@ public: // types & data fields:
private:
QScopedPointer<ParserData> m_parserData; // used when created by StateMachine::fromFile.
- typedef QHash<int, QVector<int>> HistoryValues;
+ typedef QHash<int, QList<int>> HistoryValues;
struct InvokedService {
int invokingState;
QScxmlInvokableService *service;
@@ -360,6 +361,18 @@ private:
Queue m_externalQueue;
QSet<int> m_statesToInvoke;
std::vector<InvokedService> m_invokedServices;
+ QList<QScxmlInvokableService*> invokedServicesActualCalculation() const
+ {
+ QList<QScxmlInvokableService *> result;
+ for (size_t i = 0, ei = m_invokedServices.size(); i != ei; ++i) {
+ if (auto service = m_invokedServices[i].service)
+ result.append(service);
+ }
+ return result;
+ }
+ Q_OBJECT_COMPUTED_PROPERTY(QScxmlStateMachinePrivate, QList<QScxmlInvokableService*>,
+ m_invokedServicesComputedProperty,
+ &QScxmlStateMachinePrivate::invokedServicesActualCalculation);
std::vector<bool> m_isFirstStateEntry;
std::vector<QScxmlInvokableServiceFactory *> m_cachedFactories;
enum { Invalid = 0, Starting, Running, Paused, Finished } m_runningState = Invalid;
@@ -378,6 +391,7 @@ private:
}
bool isPaused() const { return m_runningState == Paused; }
+ bool isFinished() const { return m_runningState == Finished; }
QScxmlInternal::StateMachineInfoProxy *m_infoSignalProxy;
diff --git a/src/scxml/qscxmlstatemachineinfo.cpp b/src/scxml/qscxmlstatemachineinfo.cpp
index 4fbbecf..b485f64 100644
--- a/src/scxml/qscxmlstatemachineinfo.cpp
+++ b/src/scxml/qscxmlstatemachineinfo.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmlstatemachineinfo_p.h"
#include "qscxmlstatemachine_p.h"
@@ -71,22 +35,22 @@ QScxmlStateMachine *QScxmlStateMachineInfo::stateMachine() const
return d->stateMachine();
}
-QVector<QScxmlStateMachineInfo::StateId> QScxmlStateMachineInfo::allStates() const
+QList<QScxmlStateMachineInfo::StateId> QScxmlStateMachineInfo::allStates() const
{
Q_D(const QScxmlStateMachineInfo);
- QVector<QScxmlStateMachineInfo::StateId> all;
+ QList<QScxmlStateMachineInfo::StateId> all;
for (int i = 0, ei = d->stateTable()->stateCount; i < ei; ++i) {
all.append(i);
}
return all;
}
-QVector<QScxmlStateMachineInfo::TransitionId> QScxmlStateMachineInfo::allTransitions() const
+QList<QScxmlStateMachineInfo::TransitionId> QScxmlStateMachineInfo::allTransitions() const
{
Q_D(const QScxmlStateMachineInfo);
- QVector<QScxmlStateMachineInfo::TransitionId> all;
+ QList<QScxmlStateMachineInfo::TransitionId> all;
for (int i = 0, ei = d->stateTable()->transitionCount; i < ei; ++i) {
all.append(i);
}
@@ -136,7 +100,7 @@ QScxmlStateMachineInfo::StateType QScxmlStateMachineInfo::stateType(StateId stat
}
}
-QVector<QScxmlStateMachineInfo::StateId> QScxmlStateMachineInfo::stateChildren(StateId stateId) const
+QList<QScxmlStateMachineInfo::StateId> QScxmlStateMachineInfo::stateChildren(StateId stateId) const
{
Q_D(const QScxmlStateMachineInfo);
@@ -146,7 +110,7 @@ QVector<QScxmlStateMachineInfo::StateId> QScxmlStateMachineInfo::stateChildren(S
if (stateId >= 0 && stateId < d->stateTable()->stateCount)
childStates = d->stateTable()->state(stateId).childStates;
- QVector<QScxmlStateMachineInfo::StateId> all;
+ QList<QScxmlStateMachineInfo::StateId> all;
if (childStates == QScxmlExecutableContent::StateTable::InvalidIndex)
return all;
@@ -199,11 +163,11 @@ QScxmlStateMachineInfo::StateId QScxmlStateMachineInfo::transitionSource(Transit
return transition.source;
}
-QVector<QScxmlStateMachineInfo::StateId> QScxmlStateMachineInfo::transitionTargets(TransitionId transitionId) const
+QList<QScxmlStateMachineInfo::StateId> QScxmlStateMachineInfo::transitionTargets(TransitionId transitionId) const
{
Q_D(const QScxmlStateMachineInfo);
- QVector<QScxmlStateMachineInfo::StateId> targets;
+ QList<QScxmlStateMachineInfo::StateId> targets;
if (transitionId < 0 || transitionId >= d->stateTable()->transitionCount)
return targets;
@@ -218,11 +182,11 @@ QVector<QScxmlStateMachineInfo::StateId> QScxmlStateMachineInfo::transitionTarge
return targets;
}
-QVector<QString> QScxmlStateMachineInfo::transitionEvents(TransitionId transitionId) const
+QList<QString> QScxmlStateMachineInfo::transitionEvents(TransitionId transitionId) const
{
Q_D(const QScxmlStateMachineInfo);
- QVector<QString> events;
+ QList<QString> events;
if (transitionId < 0 || transitionId >= d->stateTable()->transitionCount)
return events;
@@ -239,11 +203,11 @@ QVector<QString> QScxmlStateMachineInfo::transitionEvents(TransitionId transitio
return events;
}
-QVector<QScxmlStateMachineInfo::StateId> QScxmlStateMachineInfo::configuration() const
+QList<QScxmlStateMachineInfo::StateId> QScxmlStateMachineInfo::configuration() const
{
Q_D(const QScxmlStateMachineInfo);
const auto &list = d->stateMachinePrivate()->configuration().list();
- return QVector<StateId>(list.cbegin(), list.cend());
+ return QList<StateId>(list.cbegin(), list.cend());
}
QT_END_NAMESPACE
diff --git a/src/scxml/qscxmlstatemachineinfo_p.h b/src/scxml/qscxmlstatemachineinfo_p.h
index 4fa0ca0..8b746a5 100644
--- a/src/scxml/qscxmlstatemachineinfo_p.h
+++ b/src/scxml/qscxmlstatemachineinfo_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLSTATEMACHINEINFO_H
#define QSCXMLSTATEMACHINEINFO_H
@@ -53,6 +17,7 @@
#include <QtScxml/qscxmlglobals.h>
#include <QtCore/qobject.h>
+#include <QtCore/private/qglobal_p.h>
QT_BEGIN_NAMESPACE
@@ -91,23 +56,23 @@ public: // methods
QScxmlStateMachine *stateMachine() const;
- QVector<StateId> allStates() const;
- QVector<TransitionId> allTransitions() const;
+ QList<StateId> allStates() const;
+ QList<TransitionId> allTransitions() const;
QString stateName(int stateId) const;
StateId stateParent(StateId stateId) const;
StateType stateType(int stateId) const;
- QVector<StateId> stateChildren(StateId stateId) const;
+ QList<StateId> stateChildren(StateId stateId) const;
TransitionId initialTransition(StateId stateId) const;
TransitionType transitionType(TransitionId transitionId) const;
StateId transitionSource(TransitionId transitionId) const;
- QVector<StateId> transitionTargets(TransitionId transitionId) const;
- QVector<QString> transitionEvents(TransitionId transitionId) const;
- QVector<StateId> configuration() const;
+ QList<StateId> transitionTargets(TransitionId transitionId) const;
+ QList<QString> transitionEvents(TransitionId transitionId) const;
+ QList<StateId> configuration() const;
Q_SIGNALS:
- void statesEntered(const QVector<QScxmlStateMachineInfo::StateId> &states);
- void statesExited(const QVector<QScxmlStateMachineInfo::StateId> &states);
- void transitionsTriggered(const QVector<QScxmlStateMachineInfo::TransitionId> &transitions);
+ void statesEntered(const QList<QScxmlStateMachineInfo::StateId> &states);
+ void statesExited(const QList<QScxmlStateMachineInfo::StateId> &states);
+ void transitionsTriggered(const QList<QScxmlStateMachineInfo::TransitionId> &transitions);
private:
Q_DECLARE_PRIVATE(QScxmlStateMachineInfo)
diff --git a/src/scxml/qscxmltabledata.cpp b/src/scxml/qscxmltabledata.cpp
index ab63696..81de319 100644
--- a/src/scxml/qscxmltabledata.cpp
+++ b/src/scxml/qscxmltabledata.cpp
@@ -1,46 +1,12 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qscxmltabledata_p.h"
#include "qscxmlcompiler_p.h"
#include "qscxmlexecutablecontent_p.h"
+#include <QtCore/qmap.h>
+
QT_USE_NAMESPACE
/*!
@@ -146,13 +112,13 @@ public:
m_parents.reserve(32);
m_allTransitions.resize(doc->allTransitions.size());
m_docTransitionIndices.reserve(doc->allTransitions.size());
- for (auto *t : qAsConst(doc->allTransitions)) {
+ for (auto *t : std::as_const(doc->allTransitions)) {
m_docTransitionIndices.insert(t, m_docTransitionIndices.size());
}
m_docStatesIndices.reserve(doc->allStates.size());
m_transitionsForState.resize(doc->allStates.size());
m_allStates.resize(doc->allStates.size());
- for (DocumentModel::AbstractState *s : qAsConst(doc->allStates)) {
+ for (DocumentModel::AbstractState *s : std::as_const(doc->allStates)) {
m_docStatesIndices.insert(s, m_docStatesIndices.size());
}
@@ -183,7 +149,7 @@ public:
+ (m_allTransitions.size() * transitionSize)
+ m_arrays.size()
+ 1;
- QVector<qint32> data(dataSize, -1);
+ QList<qint32> data(dataSize, -1);
qint32 *ptr = data.data();
memcpy(ptr, &m_stateTable, sizeof(m_stateTable));
@@ -260,8 +226,8 @@ protected: // visitor
endSequence();
}
- QVector<DocumentModel::AbstractState *> childStates;
- for (DocumentModel::StateOrTransition *sot : qAsConst(node->children)) {
+ QList<DocumentModel::AbstractState *> childStates;
+ for (DocumentModel::StateOrTransition *sot : std::as_const(node->children)) {
if (DocumentModel::AbstractState *s = sot->asAbstractState()) {
childStates.append(s);
}
@@ -317,14 +283,14 @@ protected: // visitor
newState.entryInstructions = generate(state->onEntry);
newState.exitInstructions = generate(state->onExit);
if (!state->invokes.isEmpty()) {
- QVector<int> factoryIds;
- for (DocumentModel::Invoke *invoke : qAsConst(state->invokes)) {
+ QList<int> factoryIds;
+ for (DocumentModel::Invoke *invoke : std::as_const(state->invokes)) {
auto ctxt = createContext(QStringLiteral("invoke"));
- QVector<QScxmlExecutableContent::StringId> namelist;
- for (const QString &name : qAsConst(invoke->namelist))
+ QList<QScxmlExecutableContent::StringId> namelist;
+ for (const QString &name : std::as_const(invoke->namelist))
namelist += addString(name);
- QVector<QScxmlExecutableContent::ParameterInfo> params;
- for (DocumentModel::Param *param : qAsConst(invoke->params)) {
+ QList<QScxmlExecutableContent::ParameterInfo> params;
+ for (DocumentModel::Param *param : std::as_const(invoke->params)) {
QScxmlExecutableContent::ParameterInfo p;
p.name = addString(param->name);
p.expr = createEvaluatorVariant(QStringLiteral("param"), QStringLiteral("expr"),
@@ -361,8 +327,8 @@ protected: // visitor
visit(state->children);
- QVector<DocumentModel::AbstractState *> childStates;
- for (DocumentModel::StateOrTransition *sot : qAsConst(state->children)) {
+ QList<DocumentModel::AbstractState *> childStates;
+ for (DocumentModel::StateOrTransition *sot : std::as_const(state->children)) {
if (auto s = sot->asAbstractState()) {
childStates.append(s);
}
@@ -419,8 +385,8 @@ protected: // visitor
newTransition.targets = addStates(transition->targetStates);
- QVector<int> eventIds;
- for (const QString &event : qAsConst(transition->events))
+ QList<int> eventIds;
+ for (const QString &event : std::as_const(transition->events))
eventIds.push_back(addString(event));
newTransition.events = addArray(eventIds);
@@ -582,7 +548,7 @@ protected:
return addString(createContextString(instrName));
}
- void generate(const QVector<DocumentModel::DataElement *> &dataElements)
+ void generate(const QList<DocumentModel::DataElement *> &dataElements)
{
for (DocumentModel::DataElement *el : dataElements) {
auto ctxt = createContext(QStringLiteral("data"), QStringLiteral("expr"), el->expr);
@@ -605,7 +571,7 @@ protected:
return id;
}
- void generate(Array<ParameterInfo> *out, const QVector<DocumentModel::Param *> &in)
+ void generate(Array<ParameterInfo> *out, const QList<DocumentModel::Param *> &in)
{
out->count = in.size();
ParameterInfo *it = out->data();
@@ -742,7 +708,7 @@ protected:
return NoEvaluator;
}
- GeneratedTableData *tableData(const QVector<int> &stateMachineTable);
+ GeneratedTableData *tableData(const QList<int> &stateMachineTable);
StringId addString(const QString &str)
{ return str.isEmpty() ? NoString : m_stringTable.add(str); }
@@ -756,9 +722,9 @@ protected:
bool isCppDataModel() const
{ return m_isCppDataModel; }
- int addStates(const QVector<DocumentModel::AbstractState *> &states)
+ int addStates(const QList<DocumentModel::AbstractState *> &states)
{
- QVector<int> array;
+ QList<int> array;
for (auto *s : states) {
int si = m_docStatesIndices.value(s, -1);
Q_ASSERT(si != -1);
@@ -768,7 +734,7 @@ protected:
return addArray(array);
}
- int addArray(const QVector<int> &array)
+ int addArray(const QList<int> &array)
{
if (array.isEmpty())
return -1;
@@ -894,7 +860,7 @@ private:
class InstructionStorage {
public:
- InstructionStorage(QVector<qint32> &storage)
+ InstructionStorage(QList<qint32> &storage)
: m_instr(storage)
, m_info(nullptr)
{}
@@ -932,36 +898,36 @@ private:
}
private:
- QVector<qint32> &m_instr;
+ QList<qint32> &m_instr;
SequenceInfo *m_info;
};
- QVector<SequenceInfo> m_activeSequences;
+ QList<SequenceInfo> m_activeSequences;
GeneratedTableData::CreateFactoryId createFactoryId;
GeneratedTableData &m_tableData;
GeneratedTableData::DataModelInfo &m_dataModelInfo;
Table<QStringList, QString, StringId> m_stringTable;
InstructionStorage m_instructions;
- Table<QVector<EvaluatorInfo>, EvaluatorInfo, EvaluatorId> m_evaluators;
- Table<QVector<AssignmentInfo>, AssignmentInfo, EvaluatorId> m_assignments;
- Table<QVector<ForeachInfo>, ForeachInfo, EvaluatorId> m_foreaches;
- QVector<StringId> &m_dataIds;
+ Table<QList<EvaluatorInfo>, EvaluatorInfo, EvaluatorId> m_evaluators;
+ Table<QList<AssignmentInfo>, AssignmentInfo, EvaluatorId> m_assignments;
+ Table<QList<ForeachInfo>, ForeachInfo, EvaluatorId> m_foreaches;
+ QList<StringId> &m_dataIds;
bool m_isCppDataModel = false;
StateTable m_stateTable;
- QVector<int> m_parents;
- QVector<qint32> m_arrays;
+ QList<int> m_parents;
+ QList<qint32> m_arrays;
- QVector<StateTable::Transition> m_allTransitions;
+ QList<StateTable::Transition> m_allTransitions;
QHash<DocumentModel::Transition *, int> m_docTransitionIndices;
- QVector<StateTable::State> m_allStates;
+ QList<StateTable::State> m_allStates;
QHash<DocumentModel::AbstractState *, int> m_docStatesIndices;
- QVector<QVector<int>> m_transitionsForState;
+ QList<QList<int>> m_transitionsForState;
int m_currentTransition = StateTable::InvalidIndex;
bool m_bindLate = false;
- QVector<DocumentModel::DataElement *> m_dataElements;
+ QList<DocumentModel::DataElement *> m_dataElements;
Table<QStringList, QString, int> m_stateNames;
};
diff --git a/src/scxml/qscxmltabledata.h b/src/scxml/qscxmltabledata.h
index 5c0d345..ca56627 100644
--- a/src/scxml/qscxmltabledata.h
+++ b/src/scxml/qscxmltabledata.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLTABLEDATA_H
#define QSCXMLTABLEDATA_H
@@ -44,7 +8,7 @@
#include <QtCore/qstring.h>
#ifndef Q_QSCXMLC_OUTPUT_REVISION
-#define Q_QSCXMLC_OUTPUT_REVISION 1
+#define Q_QSCXMLC_OUTPUT_REVISION 2
#endif
QT_BEGIN_NAMESPACE
diff --git a/src/scxml/qscxmltabledata_p.h b/src/scxml/qscxmltabledata_p.h
index 47d8bac..6f147b7 100644
--- a/src/scxml/qscxmltabledata_p.h
+++ b/src/scxml/qscxmltabledata_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSCXMLTABLEDATA_P_H
#define QSCXMLTABLEDATA_P_H
@@ -52,9 +16,10 @@
//
#include <QtScxml/qscxmltabledata.h>
-#include <QtCore/qsharedpointer.h>
#include <QtCore/qhash.h>
-#include <QtCore/qvector.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qsharedpointer.h>
+#include <QtCore/private/qglobal_p.h>
#include <functional>
@@ -72,8 +37,8 @@ class Q_SCXML_EXPORT GeneratedTableData: public QScxmlTableData
public:
typedef std::function<
int(const QScxmlExecutableContent::InvokeInfo &invokeInfo,
- const QVector<QScxmlExecutableContent::StringId> &namelist,
- const QVector<QScxmlExecutableContent::ParameterInfo> &params,
+ const QList<QScxmlExecutableContent::StringId> &namelist,
+ const QList<QScxmlExecutableContent::ParameterInfo> &params,
QSharedPointer<DocumentModel::ScxmlDocument> content)
> CreateFactoryId;
@@ -110,13 +75,13 @@ public:
QScxmlInvokableServiceFactory *serviceFactory(int id) const override;
public:
- QVector<qint32> theStateMachineTable;
+ QList<qint32> theStateMachineTable;
QStringList theStrings;
- QVector<qint32> theInstructions;
- QVector<QScxmlExecutableContent::EvaluatorInfo> theEvaluators;
- QVector<QScxmlExecutableContent::AssignmentInfo> theAssignments;
- QVector<QScxmlExecutableContent::ForeachInfo> theForeaches;
- QVector<QScxmlExecutableContent::StringId> theDataNameIds;
+ QList<qint32> theInstructions;
+ QList<QScxmlExecutableContent::EvaluatorInfo> theEvaluators;
+ QList<QScxmlExecutableContent::AssignmentInfo> theAssignments;
+ QList<QScxmlExecutableContent::ForeachInfo> theForeaches;
+ QList<QScxmlExecutableContent::StringId> theDataNameIds;
QScxmlExecutableContent::ContainerId theInitialSetup;
int theName;
};
diff --git a/src/scxml/qt_cmdline.cmake b/src/scxml/qt_cmdline.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/scxml/qt_cmdline.cmake
diff --git a/src/scxml/scxml.pro b/src/scxml/scxml.pro
deleted file mode 100644
index fe55769..0000000
--- a/src/scxml/scxml.pro
+++ /dev/null
@@ -1,73 +0,0 @@
-TARGET = QtScxml
-QT = core-private
-MODULE_CONFIG += c++11 qscxmlc
-
-QMAKE_DOCS = $$PWD/doc/qtscxml.qdocconf
-
-CONFIG += $$MODULE_CONFIG
-DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
-
-HEADERS += \
- qscxmlcompiler.h \
- qscxmlcompiler_p.h \
- qscxmlstatemachine.h \
- qscxmlstatemachine_p.h \
- qscxmlglobals.h \
- qscxmlglobals_p.h \
- qscxmlnulldatamodel.h \
- qscxmlexecutablecontent.h \
- qscxmlexecutablecontent_p.h \
- qscxmlevent.h \
- qscxmlevent_p.h \
- qscxmldatamodel.h \
- qscxmldatamodel_p.h \
- qscxmlcppdatamodel_p.h \
- qscxmlcppdatamodel.h \
- qscxmlerror.h \
- qscxmlinvokableservice_p.h \
- qscxmlinvokableservice.h \
- qscxmltabledata.h \
- qscxmltabledata_p.h \
- qscxmlstatemachineinfo_p.h
-
-SOURCES += \
- qscxmlcompiler.cpp \
- qscxmlstatemachine.cpp \
- qscxmlnulldatamodel.cpp \
- qscxmlexecutablecontent.cpp \
- qscxmlevent.cpp \
- qscxmldatamodel.cpp \
- qscxmlcppdatamodel.cpp \
- qscxmlerror.cpp \
- qscxmlinvokableservice.cpp \
- qscxmltabledata.cpp \
- qscxmlstatemachineinfo.cpp
-
-qtConfig(scxml-ecmascriptdatamodel) {
- QT += qml-private
-
- HEADERS += \
- qscxmlecmascriptdatamodel.h \
- qscxmlecmascriptplatformproperties_p.h
-
- SOURCES += \
- qscxmlecmascriptdatamodel.cpp \
- qscxmlecmascriptplatformproperties.cpp
-}
-
-load(qt_module)
-
-FEATURES += ../../mkspecs/features/qscxmlc.prf
-features.files = $$FEATURES
-features.path = $$[QT_HOST_DATA]/mkspecs/features/
-INSTALLS += features
-
-!force_independent:if(!debug_and_release|!build_all|CONFIG(release, debug|release)) {
- # Copy qscxmlc.prf to the qtbase build directory (for non-installed developer builds)
- prf2build.input = FEATURES
- prf2build.output = $$[QT_INSTALL_DATA/get]/mkspecs/features/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
- prf2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
- prf2build.name = COPY ${QMAKE_FILE_IN}
- prf2build.CONFIG = no_link no_clean target_predeps
- QMAKE_EXTRA_COMPILERS += prf2build
-}