Skip to content

Commit b9d5664

Browse files
committed
merged contributions from commontk/PythonQt@svn-mirror...patched
changed polymorphichandler char** to const char**
1 parent 8322b1e commit b9d5664

10 files changed

+245
-9
lines changed

src/PythonQt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class PythonQtQFileImporter;
6868

6969
typedef void PythonQtQObjectWrappedCB(QObject* object);
7070
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);
7272

7373
typedef void PythonQtShellSetInstanceWrapperCB(void* object, PythonQtInstanceWrapper* wrapper);
7474

src/PythonQtClassInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ PythonQtSlotInfo* PythonQtClassInfo::recursiveFindDecoratorSlotsFromDecoratorPro
159159

160160
PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(const char* memberName, PythonQtSlotInfo* tail, bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache, int upcastingOffset) {
161161
QObject* decoratorProvider = decorator();
162-
int memberNameLen = strlen(memberName);
162+
int memberNameLen = static_cast<int>(strlen(memberName));
163163
if (decoratorProvider) {
164164
//qDebug()<< "looking " << decoratorProvider->metaObject()->className() << " " << memberName << " " << upcastingOffset;
165165
const QMetaObject* meta = decoratorProvider->metaObject();
@@ -212,7 +212,7 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(con
212212
bool PythonQtClassInfo::lookForMethodAndCache(const char* memberName)
213213
{
214214
bool found = false;
215-
int memberNameLen = strlen(memberName);
215+
int memberNameLen = static_cast<int>(strlen(memberName));
216216
PythonQtSlotInfo* tail = NULL;
217217
if (_meta) {
218218
int numMethods = _meta->methodCount();
@@ -730,7 +730,7 @@ bool PythonQtClassInfo::hasOwnerMethodButNoOwner(void* object)
730730
}
731731
}
732732

733-
void* PythonQtClassInfo::recursiveCastDownIfPossible(void* ptr, char** resultClassName)
733+
void* PythonQtClassInfo::recursiveCastDownIfPossible(void* ptr, const char** resultClassName)
734734
{
735735
if (!_polymorphicHandlers.isEmpty()) {
736736
foreach(PythonQtPolymorphicHandlerCB* cb, _polymorphicHandlers) {
@@ -753,7 +753,7 @@ void* PythonQtClassInfo::recursiveCastDownIfPossible(void* ptr, char** resultCla
753753

754754
void* PythonQtClassInfo::castDownIfPossible(void* ptr, PythonQtClassInfo** resultClassInfo)
755755
{
756-
char* className;
756+
const char* className;
757757
// this would do downcasting recursively...
758758
// void* resultPtr = recursiveCastDownIfPossible(ptr, &className);
759759

src/PythonQtClassInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class PYTHONQT_EXPORT PythonQtClassInfo {
213213
//! clear all cached members
214214
void clearCachedMembers();
215215

216-
void* recursiveCastDownIfPossible(void* ptr, char** resultClassName);
216+
void* recursiveCastDownIfPossible(void* ptr, const char** resultClassName);
217217

218218
PythonQtSlotInfo* findDecoratorSlotsFromDecoratorProvider(const char* memberName, PythonQtSlotInfo* inputInfo, bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache, int upcastingOffset);
219219
void listDecoratorSlotsFromDecoratorProvider(QStringList& list, bool metaOnly);

src/PythonQtCppWrapperFactory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ class PYTHONQT_EXPORT PythonQtCppWrapperFactory
5959
};
6060

6161
#endif
62+

src/PythonQtImportFileInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ class PythonQtImportFileInterface {
7373
};
7474

7575
#endif
76+

src/PythonQtMethodInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,14 @@ QString PythonQtSlotInfo::fullSignature()
288288

289289
if (_type == ClassDecorator) {
290290
if (sig.startsWith("new_")) {
291-
sig = sig.mid(strlen("new_"));
291+
sig = sig.mid(4);
292292
isConstructor = true;
293293
} else if (sig.startsWith("delete_")) {
294-
sig = sig.mid(strlen("delete_"));
294+
sig = sig.mid(7);
295295
isDestructor = true;
296296
} else if(sig.startsWith("static_")) {
297297
isStatic = true;
298-
sig = sig.mid(strlen("static_"));
298+
sig = sig.mid(7);
299299
int idx = sig.indexOf("_");
300300
if (idx>=0) {
301301
sig = sig.mid(idx+1);

src/PythonQtPythonInclude.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/PythonQtStdIn.cpp

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
};

src/PythonQtStdIn.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/src.pri

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ HEADERS += \
77
$$PWD/PythonQtImporter.h \
88
$$PWD/PythonQtObjectPtr.h \
99
$$PWD/PythonQtSlot.h \
10+
$$PWD/PythonQtStdIn.h \
1011
$$PWD/PythonQtStdOut.h \
1112
$$PWD/PythonQtMisc.h \
1213
$$PWD/PythonQtMethodInfo.h \
@@ -28,6 +29,7 @@ SOURCES += \
2829
$$PWD/PythonQtClassInfo.cpp \
2930
$$PWD/PythonQtImporter.cpp \
3031
$$PWD/PythonQtObjectPtr.cpp \
32+
$$PWD/PythonQtStdIn.cpp \
3133
$$PWD/PythonQtStdOut.cpp \
3234
$$PWD/PythonQtSlot.cpp \
3335
$$PWD/PythonQtMisc.cpp \

0 commit comments

Comments
 (0)