lib

rubyextension.h

00001 /***************************************************************************
00002  * rubyinterpreter.cpp
00003  * This file is part of the KDE project
00004  * copyright (C)2005 by Cyrille Berger (cberger@cberger.net)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this program; see the file COPYING.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  ***************************************************************************/
00019 #ifndef KROSS_RUBYRUBYEXTENSION_H
00020 #define KROSS_RUBYRUBYEXTENSION_H
00021 
00022 #include <ruby.h>
00023 
00024 #include <api/class.h>
00025 #include <api/dict.h>
00026 #include <api/list.h>
00027 #include <api/object.h>
00028 
00029 namespace Kross {
00030 
00031 namespace Ruby {
00032 
00033 class RubyExtensionPrivate;
00034 
00039 class RubyExtension{
00040         friend class RubyInterpreter;
00041         friend class RubyModule;
00042         friend class RubyScript;
00043     public:
00050         RubyExtension(Kross::Api::Object::Ptr object);
00054         ~RubyExtension();
00055     private:
00059         static VALUE method_missing(int argc, VALUE *argv, VALUE self);
00066         static VALUE call_method( Kross::Api::Object::Ptr obj, int argc, VALUE *argv);
00070         static void delete_object(void* object);
00074         static void delete_exception(void* object);
00075     private: // Tests
00079         static bool isOfExceptionType(VALUE obj);
00083         static bool isOfObjectType(VALUE obj);
00084     private: //Converting functions
00089         static Kross::Api::Exception::Ptr convertToException(VALUE obj);
00093         static VALUE convertFromException(Kross::Api::Exception::Ptr exc);
00097         static int convertHash_i(VALUE key, VALUE value, VALUE vmap);
00103         static Kross::Api::Object::Ptr toObject(VALUE value);
00111         static VALUE toVALUE(const QString& s);
00112 
00118         static VALUE toVALUE(QStringList list);
00119 
00125         static VALUE toVALUE(QMap<QString, QVariant> map);
00126 
00132         static VALUE toVALUE(QValueList<QVariant> list);
00138         static VALUE toVALUE(const QVariant& variant);
00139 
00145         static VALUE toVALUE(Kross::Api::Object::Ptr object);
00146 
00152         static VALUE toVALUE(Kross::Api::List::Ptr list);
00153     private:
00155         RubyExtensionPrivate* d;
00156  };
00157 
00158 }
00159 
00160 }
00161 
00162 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys