lib

pythonextension.h
1/***************************************************************************
2 * pythonextension.h
3 * This file is part of the KDE project
4 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
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_PYTHON_EXTENSION_H
21#define KROSS_PYTHON_EXTENSION_H
22
23#include "pythonconfig.h"
24
25#include "../api/object.h"
26#include "../api/list.h"
27#include "../api/dict.h"
28#include "../api/class.h"
29
30#include <tqstring.h>
31#include <tqstringlist.h>
32#include <tqvaluelist.h>
33#include <tqvaluevector.h>
34#include <tqmap.h>
35#include <tqvariant.h>
36
37namespace Kross { namespace Python {
38
39 // Forward declaration.
40 class PythonScript;
41
48 class PythonExtension : public Py::PythonExtension<PythonExtension>
49 {
50 friend class PythonScript;
51 friend class PythonObject;
52 friend class PythonModule;
53
54 public:
55
63
67 virtual ~PythonExtension();
68
69#if 0
76 virtual Py::Object str();
77
84 virtual Py::Object repr();
85#endif
86
98 virtual Py::Object getattr(const char* name);
99
100 //virtual Py::Object getattr_methods(const char* name);
101 //virtual int setattr(const char* name, const Py::Object& value);
102
103 private:
104
111 static Kross::Api::List::Ptr toObject(const Py::Tuple& tuple);
112
119 static Kross::Api::List::Ptr toObject(const Py::List& list);
120
127 static Kross::Api::Dict::Ptr toObject(const Py::Dict& dict);
128
135 static Kross::Api::Object::Ptr toObject(const Py::Object& object);
136
145 static const Py::Object toPyObject(const TQString& s);
146
153 static const Py::List toPyObject(const TQStringList& list);
154
161 static const Py::Dict toPyObject(const TQStringVariantMap& map);
162
169 static const Py::List toPyObject(const TQValueList<TQVariant>& list);
170
177 static const Py::Object toPyObject(const TQVariant& variant);
178
185 static const Py::Object toPyObject(Kross::Api::Object::Ptr object);
186
193 static const Py::Tuple toPyTuple(Kross::Api::List::Ptr list);
194
197
202 Py::MethodDefExt<PythonExtension>* m_proxymethod;
203
216 static PyObject* proxyhandler(PyObject* _self_and_name_tuple, PyObject* _args);
217 };
218
219}}
220
221#endif
TDESharedPtr< List > Ptr
Shared pointer to implement reference-counting.
Definition list.h:46
TDESharedPtr< Object > Ptr
Shared pointer to implement reference-counting.
Definition object.h:56
virtual ~PythonExtension()
Destructor.
virtual Py::Object getattr(const char *name)
Overloaded method to handle attribute calls from within python.
PythonExtension(Kross::Api::Object::Ptr object)
Constructor.
Handle python scripts.
The Python plugin for the Kross scripting framework.
The Kross scripting bridge to embed scripting functionality into an application.
Definition callable.h:33