##// END OF EJS Templates
florianlink -
r163:349fb638ffe0
parent child
Show More
@@ -0,0 +1,55
1 /*
2 *
3 * Copyright (C) 2011 MeVis Medical Solutions AG All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Medical Solutions AG, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 #ifndef __PythonQtPythonInclude_h
34 #define __PythonQtPythonInclude_h
35
36 // Undefine macros that Python.h defines to avoid redefinition warning.
37 #undef _POSIX_C_SOURCE
38 #undef _POSIX_THREADS
39 #undef _XOPEN_SOURCE
40
41 // If PYTHONQT_USE_RELEASE_PYTHON_FALLBACK is enabled, try to link
42 // release Python DLL if it is available by undefining _DEBUG while
43 // including Python.h
44 #if defined(PYTHONQT_USE_RELEASE_PYTHON_FALLBACK) && defined(_DEBUG)
45 #undef _DEBUG
46 #if defined(_MSC_VER) && _MSC_VER >= 1400
47 #define _CRT_NOFORCE_MANIFEST 1
48 #endif
49 #include <Python.h>
50 #define _DEBUG
51 #else
52 #include <Python.h>
53 #endif
54
55 #endif
@@ -0,0 +1,114
1 /*
2 *
3 * Copyright (C) 2011 MeVis Medical Solutions AG All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Medical Solutions AG, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtStdIn.cpp
36 // \author Jean-Christophe Fillion-Robin
37 // \author Last changed by $Author: jcfr $
38 // \date 2011
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtStdIn.h"
43
44 static PyObject *PythonQtStdInRedirect_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/)
45 {
46 PythonQtStdInRedirect *self;
47 self = (PythonQtStdInRedirect *)type->tp_alloc(type, 0);
48 self->_cb = NULL;
49 self->_callData = NULL;
50
51 return (PyObject *)self;
52 }
53
54 static PyObject *PythonQtStdInRedirect_readline(PyObject * self, PyObject * args)
55 {
56 PythonQtStdInRedirect* s = (PythonQtStdInRedirect*)self;
57 QString string;
58 if (s->_cb) {
59 string = (*s->_cb)(s->_callData);
60 }
61 return Py_BuildValue(const_cast<char*>("s"), const_cast<char*>(string.toAscii().data()));
62 }
63
64 static PyMethodDef PythonQtStdInRedirect_methods[] = {
65 {"readline", (PyCFunction)PythonQtStdInRedirect_readline, METH_VARARGS,
66 "read input line"},
67 {NULL, NULL, 0 , NULL} /* sentinel */
68 };
69
70 static PyMemberDef PythonQtStdInRedirect_members[] = {
71 {NULL} /* Sentinel */
72 };
73
74 PyTypeObject PythonQtStdInRedirectType = {
75 PyObject_HEAD_INIT(NULL)
76 0, /*ob_size*/
77 "PythonQtStdInRedirect", /*tp_name*/
78 sizeof(PythonQtStdInRedirect), /*tp_basicsize*/
79 0, /*tp_itemsize*/
80 0, /*tp_dealloc*/
81 0, /*tp_print*/
82 0, /*tp_getattr*/
83 0, /*tp_setattr*/
84 0, /*tp_compare*/
85 0, /*tp_repr*/
86 0, /*tp_as_number*/
87 0, /*tp_as_sequence*/
88 0, /*tp_as_mapping*/
89 0, /*tp_hash */
90 0, /*tp_call*/
91 0, /*tp_str*/
92 0, /*tp_getattro*/
93 0, /*tp_setattro*/
94 0, /*tp_as_buffer*/
95 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
96 "PythonQtStdInRedirect", /* tp_doc */
97 0, /* tp_traverse */
98 0, /* tp_clear */
99 0, /* tp_richcompare */
100 0, /* tp_weaklistoffset */
101 0, /* tp_iter */
102 0, /* tp_iternext */
103 PythonQtStdInRedirect_methods, /* tp_methods */
104 PythonQtStdInRedirect_members, /* tp_members */
105 0, /* tp_getset */
106 0, /* tp_base */
107 0, /* tp_dict */
108 0, /* tp_descr_get */
109 0, /* tp_descr_set */
110 0, /* tp_dictoffset */
111 0, /* tp_init */
112 0, /* tp_alloc */
113 PythonQtStdInRedirect_new, /* tp_new */
114 };
@@ -0,0 +1,63
1 #ifndef _PYTHONQTSTDIN_H
2 #define _PYTHONQTSTDIN_H
3
4 /*
5 *
6 * Copyright (C) 2011 MeVis Medical Solutions AG All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Medical Solutions AG, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtStdIn.h
39 // \author Jean-Christophe Fillion-Robin
40 // \author Last changed by $Author: jcfr $
41 // \date 2011
42 */
43 //----------------------------------------------------------------------------------
44
45
46 #include "PythonQtPythonInclude.h"
47 #include "structmember.h"
48 #include <QString>
49
50 //! declares the type of the stdout redirection class
51 extern PyTypeObject PythonQtStdInRedirectType;
52
53 //! declares the callback that is called from the write() function
54 typedef QString PythonQtInputChangedCB(void* callData);
55
56 //! declares the stdin redirection class
57 typedef struct {
58 PyObject_HEAD
59 PythonQtInputChangedCB* _cb;
60 void * _callData;
61 } PythonQtStdInRedirect;
62
63 #endif
@@ -68,7 +68,7 class PythonQtQFileImporter;
68 68
69 69 typedef void PythonQtQObjectWrappedCB(QObject* object);
70 70 typedef void PythonQtQObjectNoLongerWrappedCB(QObject* object);
71 typedef void* PythonQtPolymorphicHandlerCB(const void *ptr, char **class_name);
71 typedef void* PythonQtPolymorphicHandlerCB(const void *ptr, const char **class_name);
72 72
73 73 typedef void PythonQtShellSetInstanceWrapperCB(void* object, PythonQtInstanceWrapper* wrapper);
74 74
@@ -159,7 +159,7 PythonQtSlotInfo* PythonQtClassInfo::recursiveFindDecoratorSlotsFromDecoratorPro
159 159
160 160 PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(const char* memberName, PythonQtSlotInfo* tail, bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache, int upcastingOffset) {
161 161 QObject* decoratorProvider = decorator();
162 int memberNameLen = strlen(memberName);
162 int memberNameLen = static_cast<int>(strlen(memberName));
163 163 if (decoratorProvider) {
164 164 //qDebug()<< "looking " << decoratorProvider->metaObject()->className() << " " << memberName << " " << upcastingOffset;
165 165 const QMetaObject* meta = decoratorProvider->metaObject();
@@ -212,7 +212,7 PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(con
212 212 bool PythonQtClassInfo::lookForMethodAndCache(const char* memberName)
213 213 {
214 214 bool found = false;
215 int memberNameLen = strlen(memberName);
215 int memberNameLen = static_cast<int>(strlen(memberName));
216 216 PythonQtSlotInfo* tail = NULL;
217 217 if (_meta) {
218 218 int numMethods = _meta->methodCount();
@@ -730,7 +730,7 bool PythonQtClassInfo::hasOwnerMethodButNoOwner(void* object)
730 730 }
731 731 }
732 732
733 void* PythonQtClassInfo::recursiveCastDownIfPossible(void* ptr, char** resultClassName)
733 void* PythonQtClassInfo::recursiveCastDownIfPossible(void* ptr, const char** resultClassName)
734 734 {
735 735 if (!_polymorphicHandlers.isEmpty()) {
736 736 foreach(PythonQtPolymorphicHandlerCB* cb, _polymorphicHandlers) {
@@ -753,7 +753,7 void* PythonQtClassInfo::recursiveCastDownIfPossible(void* ptr, char** resultCla
753 753
754 754 void* PythonQtClassInfo::castDownIfPossible(void* ptr, PythonQtClassInfo** resultClassInfo)
755 755 {
756 char* className;
756 const char* className;
757 757 // this would do downcasting recursively...
758 758 // void* resultPtr = recursiveCastDownIfPossible(ptr, &className);
759 759
@@ -213,7 +213,7 private:
213 213 //! clear all cached members
214 214 void clearCachedMembers();
215 215
216 void* recursiveCastDownIfPossible(void* ptr, char** resultClassName);
216 void* recursiveCastDownIfPossible(void* ptr, const char** resultClassName);
217 217
218 218 PythonQtSlotInfo* findDecoratorSlotsFromDecoratorProvider(const char* memberName, PythonQtSlotInfo* inputInfo, bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache, int upcastingOffset);
219 219 void listDecoratorSlotsFromDecoratorProvider(QStringList& list, bool metaOnly);
@@ -59,3 +59,4 public:
59 59 };
60 60
61 61 #endif
62
@@ -73,3 +73,4 public:
73 73 };
74 74
75 75 #endif
76
@@ -288,14 +288,14 QString PythonQtSlotInfo::fullSignature()
288 288
289 289 if (_type == ClassDecorator) {
290 290 if (sig.startsWith("new_")) {
291 sig = sig.mid(strlen("new_"));
291 sig = sig.mid(4);
292 292 isConstructor = true;
293 293 } else if (sig.startsWith("delete_")) {
294 sig = sig.mid(strlen("delete_"));
294 sig = sig.mid(7);
295 295 isDestructor = true;
296 296 } else if(sig.startsWith("static_")) {
297 297 isStatic = true;
298 sig = sig.mid(strlen("static_"));
298 sig = sig.mid(7);
299 299 int idx = sig.indexOf("_");
300 300 if (idx>=0) {
301 301 sig = sig.mid(idx+1);
@@ -7,6 +7,7 HEADERS += \
7 7 $$PWD/PythonQtImporter.h \
8 8 $$PWD/PythonQtObjectPtr.h \
9 9 $$PWD/PythonQtSlot.h \
10 $$PWD/PythonQtStdIn.h \
10 11 $$PWD/PythonQtStdOut.h \
11 12 $$PWD/PythonQtMisc.h \
12 13 $$PWD/PythonQtMethodInfo.h \
@@ -28,6 +29,7 SOURCES += \
28 29 $$PWD/PythonQtClassInfo.cpp \
29 30 $$PWD/PythonQtImporter.cpp \
30 31 $$PWD/PythonQtObjectPtr.cpp \
32 $$PWD/PythonQtStdIn.cpp \
31 33 $$PWD/PythonQtStdOut.cpp \
32 34 $$PWD/PythonQtSlot.cpp \
33 35 $$PWD/PythonQtMisc.cpp \
General Comments 0
You need to be logged in to leave comments. Login now