1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qscxmlecmascriptplatformproperties_p.h"
5#include "qscxmlstatemachine.h"
6
7#include <qjsengine.h>
8
9QT_BEGIN_NAMESPACE
10class QScxmlPlatformProperties::Data
11{
12public:
13 Data()
14 : m_stateMachine(nullptr)
15 {}
16
17 QScxmlStateMachine *m_stateMachine;
18 QJSValue m_jsValue;
19};
20
21QScxmlPlatformProperties::QScxmlPlatformProperties(QObject *parent)
22 : QObject(parent)
23 , data(new Data)
24{}
25
26QScxmlPlatformProperties *QScxmlPlatformProperties::create(QJSEngine *engine, QScxmlStateMachine *stateMachine)
27{
28 QScxmlPlatformProperties *pp = new QScxmlPlatformProperties(engine);
29 pp->data->m_stateMachine = stateMachine;
30 pp->data->m_jsValue = engine->newQObject(object: pp);
31 return pp;
32}
33
34QScxmlPlatformProperties::~QScxmlPlatformProperties()
35{
36 delete data;
37}
38
39QJSEngine *QScxmlPlatformProperties::engine() const
40{
41 return qobject_cast<QJSEngine *>(object: parent());
42}
43
44QScxmlStateMachine *QScxmlPlatformProperties::stateMachine() const
45{
46 return data->m_stateMachine;
47}
48
49QJSValue QScxmlPlatformProperties::jsValue() const
50{
51 return data->m_jsValue;
52}
53
54/// _x.marks === "the spot"
55QString QScxmlPlatformProperties::marks() const
56{
57 return QStringLiteral("the spot");
58}
59
60bool QScxmlPlatformProperties::inState(const QString &stateName)
61{
62 return stateMachine()->isActive(scxmlStateName: stateName);
63}
64
65QT_END_NAMESPACE
66

source code of qtscxml/src/plugins/ecmascriptdatamodel/qscxmlecmascriptplatformproperties.cpp