* Added command line tool example similar to 'sopranocmd'
[kdebindings.git] / ruby / krossruby / rubycallcache.h
blob828c4f8fa807f3abfbbe7ac96152bd21fc7766fd
1 /***************************************************************************
2 * rubycallcache.h
3 * This file is part of the KDE project
4 * copyright (C)2006 by Cyrille Berger (cberger@cberger.net)
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 ***************************************************************************/
20 #ifndef KROSS_RUBYCALLCACHE_H
21 #define KROSS_RUBYCALLCACHE_H
23 #include "rubyconfig.h"
25 #include <QVarLengthArray>
26 class QObject;
27 class QVariant;
29 namespace Kross {
31 struct RubyCallCachePrivate;
33 /**
34 * The RubyCallCache class implements a cache for calling functions
35 * within the RubyExtension::callMetaMethod() method.
37 class RubyCallCache
39 public:
41 /**
42 * Constructor.
44 * \param object The QObject that provides the method that
45 * should be called.
46 * \param methodindex The method-index. The methods are
47 * accessible by there index cause of performance reasons.
48 * \param hasreturnvalue If true then the method does
49 * provide a return-value else the method doesn't provide
50 * anything back (void).
51 * \param ntypes Array of QVariant::Type numbers for the
52 * return-value (index 0) and the arguments (index >=1).
53 * \param nmetatypes Array of QMetaType::Type numbers for the
54 * return-value (index 0) and the arguments (index >=1).
56 RubyCallCache(QObject* object, int methodindex, bool hasreturnvalue, QVarLengthArray<int> ntypes, QVarLengthArray<int> nmetatypes);
58 /**
59 * Destructor.
61 ~RubyCallCache();
63 /**
64 * Execute the method and pass \p argc numbers of
65 * arguments as \p argv array to the method.
67 VALUE execfunction( int argc, VALUE *argv );
69 /**
70 * Executes the method using the call-cache.
72 VALUE toValue();
74 /**
75 * Static function that executes the method using the call-cache.
77 static VALUE method_cacheexec(int argc, VALUE *argv, VALUE self);
79 /**
80 * Called by Ruby if an call-cache object got destructed.
82 static void delete_object(void* object);
84 private:
85 RubyCallCachePrivate * const d;
86 VALUE m_self;
91 #endif