1 /***************************************************************************
3 * This file is part of the KDE project
4 * copyright (C)2005 by Cyrille Berger (cberger@cberger.net)
5 * copyright (C)2006 by Sebastian Sauer (mail@dipe.org)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this program; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 ***************************************************************************/
21 #ifndef KROSS_RUBYRUBYSCRIPT_H
22 #define KROSS_RUBYRUBYSCRIPT_H
24 #include "rubyconfig.h"
25 #include <kross/core/krossconfig.h>
26 #include <kross/core/script.h>
32 class RubyScriptPrivate
;
35 * Handle ruby scripts. This class implements
36 * \a Kross::Script for ruby.
37 * @author Cyrille Berger
39 class RubyScript
: public Kross::Script
41 friend class RubyScriptPrivate
;
47 * @param interpreter The @a RubyInterpreter instance used to
49 * @param action The @a Kross::Action
50 * instance this @a RubyScript does handle the
53 RubyScript(Kross::Interpreter
* interpreter
, Kross::Action
* action
);
61 * \return a \a RubyModule instance defined with the \p modname for
62 * that wraps the QObject \p object . If there exist no such
63 * module yet we create a new one and remember it.
65 RubyModule
* module(QObject
* object
, const QString
& modname
);
68 * \return true if the as argument passed \p value is a
69 * \a RubyScript object else false is returned.
71 static bool isRubyScript(VALUE value
);
76 virtual void execute();
79 * \return the list of functionnames.
81 virtual QStringList
functionNames();
84 * Call a function in the script.
86 * \param name The name of the function which should be called.
87 * \param args The optional list of arguments.
89 virtual QVariant
callFunction(const QString
& name
, const QVariantList
& args
= QVariantList());
92 * Evaluate some scripting code.
94 * \param code The scripting code to evaluate.
95 * \return The return value of the evaluation.
97 virtual QVariant
evaluate(const QByteArray
& code
);
101 * Return a list of class types this script supports.
103 virtual const QStringList
& getClassNames();
106 * Create and return a new class instance.
108 virtual Kross::Object::Ptr
classInstance(const QString
& name
);
112 * Connect a QObject signal with a Ruby method function.
114 * \param sender The QObject instance that sends the signal.
115 * \param signal The signature of the signal the QObject emits.
116 * \param method The callable ruby methods that should
117 * be executed if the QObject emits the signal.
119 RubyFunction
* connectFunction(QObject
* sender
, const QByteArray
& signal
, VALUE method
);
122 /// Private d-pointer.
123 RubyScriptPrivate
* const d
;