Kross

qts-interpreter/script.h
1 /***************************************************************************
2  * script.h
3  * This file is part of the KDE project
4  * copyright (C)2007-2008 by Sebastian Sauer ([email protected])
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  * You should have received a copy of the GNU Library General Public License
15  * along with this program; see the file COPYING. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  ***************************************************************************/
19 
20 #ifndef KROSS_QTS_SCRIPT_H
21 #define KROSS_QTS_SCRIPT_H
22 
23 #include <kross/core/krossconfig.h>
24 #include <kross/core/interpreter.h>
25 #include <kross/core/manager.h>
26 #include <kross/core/script.h>
27 #include <kross/core/action.h>
28 #include <kross/core/object.h>
29 
30 namespace Kross
31 {
32 
33 /**
34 * The EcmaScript class implements a \a Kross::Script to handle
35 * a single script. Each script and script file will have its
36 * own \a EcmaScript instance as container for a Ecma QtScript
37 * that is managed by the \a Kross::Action class.
38 */
39 class EcmaScript : public Kross::Script
40 {
41  Q_OBJECT
42 public:
43 
44  /**
45  * Constructor.
46  *
47  * \param interpreter The \a EcmaInterpreter instance this
48  * script belongs to.
49  * \param action The \a Kross::Action instance that contains
50  * details about the script and that decorates this script.
51  */
53 
54  /**
55  * Destructor.
56  */
57  ~EcmaScript() override;
58 
59 public Q_SLOTS:
60 
61  /**
62  * Executes the script.
63  */
64  void execute() override;
65 
66  /**
67  * \return a list of function-names.
68  */
69  QStringList functionNames() override;
70 
71  /**
72  * Execute a function.
73  *
74  * \param name The name of the function that should be called.
75  * \param args The optional arguments for the function.
76  * \return The return value of the function.
77  */
78  QVariant callFunction(const QString &name, const QVariantList &args = QVariantList()) override;
79 
80  /**
81  * Evaluate some scripting code.
82  *
83  * \param code The scripting code to evaluate.
84  * \return The return value of the evaluation.
85  */
86  QVariant evaluate(const QByteArray &code) override;
87 
88  /**
89  * \return the internal used QScriptEngine instance.
90  */
91  QObject *engine() const;
92 
93 private:
94  class Private;
95  Private *const d;
96 };
97 
98 }
99 
100 #endif
Q_OBJECTQ_OBJECT
void execute() override
Executes the script.
Base class for interpreter implementations.
Q_SLOTSQ_SLOTS
Action * action() const
Definition: core/script.cpp:62
~EcmaScript() override
Destructor.
QStringList functionNames() override
The Action class is an abstract container to deal with scripts like a single standalone script file.
Definition: action.h:112
Interpreter * interpreter() const
Definition: core/script.cpp:57
QVariant callFunction(const QString &name, const QVariantList &args=QVariantList()) override
Execute a function.
QVariant evaluate(const QByteArray &code) override
Evaluate some scripting code.
EcmaScript(Kross::Interpreter *interpreter, Kross::Action *action)
Constructor.
Base class for interpreter dependent functionality each script provides.
Definition: core/script.h:61
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 04:00:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.