@@ -0,0 +1,80 | |||||
|
1 | /* | |||
|
2 | * | |||
|
3 | * Copyright (C) 2006 MeVis Research GmbH 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 Research GmbH, Universitaetsallee 29, | |||
|
27 | * 28359 Bremen, Germany or: | |||
|
28 | * | |||
|
29 | * http://www.mevis.de | |||
|
30 | * | |||
|
31 | */ | |||
|
32 | ||||
|
33 | //---------------------------------------------------------------------------------- | |||
|
34 | /*! | |||
|
35 | // \file PythonQtQFileImporter.h | |||
|
36 | // \author Florian Link | |||
|
37 | // \author Last changed by $Author: florian $ | |||
|
38 | // \date 2009-03 | |||
|
39 | */ | |||
|
40 | //---------------------------------------------------------------------------------- | |||
|
41 | ||||
|
42 | #include <QFile> | |||
|
43 | #include <QFileInfo> | |||
|
44 | ||||
|
45 | #include "PythonQtQFileImporter.h" | |||
|
46 | ||||
|
47 | PythonQtQFileImporter::PythonQtQFileImporter() { | |||
|
48 | } | |||
|
49 | ||||
|
50 | PythonQtQFileImporter::~PythonQtQFileImporter() { | |||
|
51 | } | |||
|
52 | ||||
|
53 | QByteArray PythonQtQFileImporter::readFileAsBytes (const QString &filename) { | |||
|
54 | QFile f(filename); | |||
|
55 | if (f.open(QIODevice::ReadOnly)) { | |||
|
56 | return f.readAll(); | |||
|
57 | } else { | |||
|
58 | return QByteArray(); | |||
|
59 | } | |||
|
60 | } | |||
|
61 | ||||
|
62 | QByteArray PythonQtQFileImporter::readSourceFile (const QString &filename, bool &ok) { | |||
|
63 | QFile f(filename); | |||
|
64 | if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { | |||
|
65 | ok = true; | |||
|
66 | return f.readAll(); | |||
|
67 | } else { | |||
|
68 | ok = false; | |||
|
69 | return QByteArray(); | |||
|
70 | } | |||
|
71 | } | |||
|
72 | ||||
|
73 | bool PythonQtQFileImporter::exists (const QString &filename) { | |||
|
74 | return QFile::exists(filename); | |||
|
75 | } | |||
|
76 | ||||
|
77 | QDateTime PythonQtQFileImporter::lastModifiedDate (const QString &filename) { | |||
|
78 | QFileInfo fi(filename); | |||
|
79 | return fi.lastModified(); | |||
|
80 | } |
@@ -0,0 +1,63 | |||||
|
1 | #ifndef _PYTHONQTQFILEIMPORTER_H | |||
|
2 | #define _PYTHONQTQFILEIMPORTER_H | |||
|
3 | ||||
|
4 | /* | |||
|
5 | * | |||
|
6 | * Copyright (C) 2006 MeVis Research GmbH 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 Research GmbH, Universitaetsallee 29, | |||
|
30 | * 28359 Bremen, Germany or: | |||
|
31 | * | |||
|
32 | * http://www.mevis.de | |||
|
33 | * | |||
|
34 | */ | |||
|
35 | ||||
|
36 | //---------------------------------------------------------------------------------- | |||
|
37 | /*! | |||
|
38 | // \file PythonQtQFileImporter.h | |||
|
39 | // \author Florian Link | |||
|
40 | // \author Last changed by $Author: florian $ | |||
|
41 | // \date 2009-03 | |||
|
42 | */ | |||
|
43 | //---------------------------------------------------------------------------------- | |||
|
44 | ||||
|
45 | #include <PythonQtImportFileInterface.h> | |||
|
46 | ||||
|
47 | //! default importer implementation using QFile to load python code | |||
|
48 | class PythonQtQFileImporter : public PythonQtImportFileInterface { | |||
|
49 | public: | |||
|
50 | PythonQtQFileImporter(); | |||
|
51 | ~PythonQtQFileImporter(); | |||
|
52 | ||||
|
53 | QByteArray readFileAsBytes (const QString &filename); | |||
|
54 | ||||
|
55 | QByteArray readSourceFile (const QString &filename, bool &ok); | |||
|
56 | ||||
|
57 | bool exists (const QString &filename); | |||
|
58 | ||||
|
59 | QDateTime lastModifiedDate (const QString &filename); | |||
|
60 | ||||
|
61 | }; | |||
|
62 | ||||
|
63 | #endif |
@@ -1,6 +1,5 | |||||
1 | #include <PythonQt.h> |
|
1 | #include <PythonQt.h> | |
2 | #include <QtGui> |
|
2 | #include <QtGui> | |
3 | #include "QFileImportInterface.h" |
|
|||
4 |
|
3 | |||
5 | int main (int argc, char* argv[]) { |
|
4 | int main (int argc, char* argv[]) { | |
6 | QApplication app(argc, argv); |
|
5 | QApplication app(argc, argv); | |
@@ -19,11 +18,10 int main (int argc, char* argv[]) { | |||||
19 | Q_ASSERT(fn.toString() == QString("t.mp3")); |
|
18 | Q_ASSERT(fn.toString() == QString("t.mp3")); | |
20 | // tag goes out of scope, reference count decremented. |
|
19 | // tag goes out of scope, reference count decremented. | |
21 | } |
|
20 | } | |
22 | qDebug() << "test1"; |
|
|||
23 | /* |
|
|||
24 | { |
|
21 | { | |
25 | // Allow the python system path to recognize QFile paths in the sys.path |
|
22 | // Allow the python system path to recognize QFile paths in the sys.path | |
26 | QFileImportInterface qfii; |
|
23 | //QFileImportInterface qfii; | |
|
24 | PythonQt::self()->setImporter(NULL); | |||
27 | // append the Qt resource root directory to the sys.path |
|
25 | // append the Qt resource root directory to the sys.path | |
28 | mainModule.evalScript("sys.path.append(':')\n"); |
|
26 | mainModule.evalScript("sys.path.append(':')\n"); | |
29 | mainModule.evalScript("import eyed3tagger\n"); |
|
27 | mainModule.evalScript("import eyed3tagger\n"); | |
@@ -33,7 +31,6 int main (int argc, char* argv[]) { | |||||
33 | QVariant fn = tag.call("fileName", QVariantList()); |
|
31 | QVariant fn = tag.call("fileName", QVariantList()); | |
34 | Q_ASSERT(fn.toString() == QString("t.mp3")); |
|
32 | Q_ASSERT(fn.toString() == QString("t.mp3")); | |
35 | } |
|
33 | } | |
36 | qDebug() << "test2"; */ |
|
|||
37 |
|
|
34 | { // alternative using import and loading it as a real module from sys.path | |
38 | // import sys first |
|
35 | // import sys first | |
39 | mainModule.evalScript(QString("sys.path.append('%1')\n").arg(QDir::currentPath())); |
|
36 | mainModule.evalScript(QString("sys.path.append('%1')\n").arg(QDir::currentPath())); |
@@ -2,10 +2,10 CONFIG += debug | |||||
2 | VPATH += |
|
2 | VPATH += | |
3 | INCLUDEPATH += . $$(PYTHONQT_ROOT)/src /usr/include/python2.5 |
|
3 | INCLUDEPATH += . $$(PYTHONQT_ROOT)/src /usr/include/python2.5 | |
4 |
|
4 | |||
5 |
SOURCES += CPPPyWrapperExample.cpp |
|
5 | SOURCES += CPPPyWrapperExample.cpp | |
6 | HEADERS += QFileImportInterface.h |
|
|||
7 |
|
6 | |||
|
7 | mac { CONFIG -= app_bundle } | |||
8 |
|
8 | |||
9 | LIBS += -L$$(PYTHONQT_ROOT)/lib -lPythonQt -lutil |
|
9 | LIBS += -L$$(PYTHONQT_ROOT)/lib -lPythonQt_d -lutil | |
10 |
|
10 | |||
11 | RESOURCES += CPPPyWrapperExample.qrc |
|
11 | RESOURCES += CPPPyWrapperExample.qrc |
@@ -49,6 +49,7 | |||||
49 | #include "PythonQtCppWrapperFactory.h" |
|
49 | #include "PythonQtCppWrapperFactory.h" | |
50 | #include "PythonQtVariants.h" |
|
50 | #include "PythonQtVariants.h" | |
51 | #include "PythonQtStdDecorators.h" |
|
51 | #include "PythonQtStdDecorators.h" | |
|
52 | #include "PythonQtQFileImporter.h" | |||
52 | #include <pydebug.h> |
|
53 | #include <pydebug.h> | |
53 |
|
54 | |||
54 | PythonQt* PythonQt::_self = NULL; |
|
55 | PythonQt* PythonQt::_self = NULL; | |
@@ -163,6 +164,14 PythonQt::~PythonQt() { | |||||
163 | } |
|
164 | } | |
164 |
|
165 | |||
165 | PythonQtPrivate::~PythonQtPrivate() { |
|
166 | PythonQtPrivate::~PythonQtPrivate() { | |
|
167 | delete _defaultImporter; | |||
|
168 | _defaultImporter = NULL; | |||
|
169 | { | |||
|
170 | QHashIterator<QByteArray, PythonQtSlotInfo *> i(_knownQtDecoratorSlots); | |||
|
171 | while (i.hasNext()) { | |||
|
172 | delete i.next().value(); | |||
|
173 | } | |||
|
174 | } | |||
166 | { |
|
175 | { | |
167 | QHashIterator<QByteArray, PythonQtClassInfo *> i(_knownQtClasses); |
|
176 | QHashIterator<QByteArray, PythonQtClassInfo *> i(_knownQtClasses); | |
168 | while (i.hasNext()) { |
|
177 | while (i.hasNext()) { | |
@@ -184,13 +193,25 PythonQtPrivate::~PythonQtPrivate() { | |||||
184 | { |
|
193 | { | |
185 | QHashIterator<QByteArray, PythonQtSlotInfo *> i(_constructorSlots); |
|
194 | QHashIterator<QByteArray, PythonQtSlotInfo *> i(_constructorSlots); | |
186 | while (i.hasNext()) { |
|
195 | while (i.hasNext()) { | |
187 |
|
|
196 | PythonQtSlotInfo* cur = i.next().value(); | |
|
197 | while(cur->nextInfo()) { | |||
|
198 | PythonQtSlotInfo* next = cur->nextInfo(); | |||
|
199 | delete cur; | |||
|
200 | cur = next; | |||
|
201 | } | |||
|
202 | delete cur; | |||
188 | } |
|
203 | } | |
189 | } |
|
204 | } | |
190 | { |
|
205 | { | |
191 | QHashIterator<QByteArray, PythonQtSlotInfo *> i(_destructorSlots); |
|
206 | QHashIterator<QByteArray, PythonQtSlotInfo *> i(_destructorSlots); | |
192 | while (i.hasNext()) { |
|
207 | while (i.hasNext()) { | |
193 |
|
|
208 | PythonQtSlotInfo* cur = i.next().value(); | |
|
209 | while(cur->nextInfo()) { | |||
|
210 | PythonQtSlotInfo* next = cur->nextInfo(); | |||
|
211 | delete cur; | |||
|
212 | cur = next; | |||
|
213 | } | |||
|
214 | delete cur; | |||
194 | } |
|
215 | } | |
195 | } |
|
216 | } | |
196 | PythonQtConv::global_valueStorage.clear(); |
|
217 | PythonQtConv::global_valueStorage.clear(); | |
@@ -204,7 +225,7 PythonQtPrivate::~PythonQtPrivate() { | |||||
204 |
|
225 | |||
205 | PythonQtImportFileInterface* PythonQt::importInterface() |
|
226 | PythonQtImportFileInterface* PythonQt::importInterface() | |
206 | { |
|
227 | { | |
207 | return _self->_p->_importInterface; |
|
228 | return _self->_p->_importInterface?_self->_p->_importInterface:_self->_p->_defaultImporter; | |
208 | } |
|
229 | } | |
209 |
|
230 | |||
210 | void PythonQt::registerClass(const QMetaObject* metaobject) |
|
231 | void PythonQt::registerClass(const QMetaObject* metaobject) | |
@@ -760,12 +781,8 void PythonQt::registerQObjectClassNames(const QStringList& names) | |||||
760 |
|
781 | |||
761 | void PythonQt::setImporter(PythonQtImportFileInterface* importInterface) |
|
782 | void PythonQt::setImporter(PythonQtImportFileInterface* importInterface) | |
762 | { |
|
783 | { | |
763 | static bool first = true; |
|
|||
764 | if (first) { |
|
|||
765 | first = false; |
|
|||
766 | _p->_importInterface = importInterface; |
|
|||
767 |
|
|
784 | PythonQtImport::init(); | |
768 | } |
|
785 | _p->_importInterface = importInterface; | |
769 | } |
|
786 | } | |
770 |
|
787 | |||
771 | void PythonQt::setImporterIgnorePaths(const QStringList& paths) |
|
788 | void PythonQt::setImporterIgnorePaths(const QStringList& paths) | |
@@ -797,6 +814,7 const QList<PythonQtConstructorHandler*>& PythonQt::constructorHandlers() | |||||
797 | PythonQtPrivate::PythonQtPrivate() |
|
814 | PythonQtPrivate::PythonQtPrivate() | |
798 | { |
|
815 | { | |
799 | _importInterface = NULL; |
|
816 | _importInterface = NULL; | |
|
817 | _defaultImporter = new PythonQtQFileImporter; | |||
800 | _noLongerWrappedCB = NULL; |
|
818 | _noLongerWrappedCB = NULL; | |
801 | _wrappedCB = NULL; |
|
819 | _wrappedCB = NULL; | |
802 | } |
|
820 | } |
@@ -65,6 +65,7 class PythonQtSignalReceiver; | |||||
65 | class PythonQtImportFileInterface; |
|
65 | class PythonQtImportFileInterface; | |
66 | class PythonQtCppWrapperFactory; |
|
66 | class PythonQtCppWrapperFactory; | |
67 | class PythonQtConstructorHandler; |
|
67 | class PythonQtConstructorHandler; | |
|
68 | class PythonQtQFileImporter; | |||
68 |
|
69 | |||
69 | typedef void PythonQtQObjectWrappedCB(QObject* object); |
|
70 | typedef void PythonQtQObjectWrappedCB(QObject* object); | |
70 | typedef void PythonQtQObjectNoLongerWrappedCB(QObject* object); |
|
71 | typedef void PythonQtQObjectNoLongerWrappedCB(QObject* object); | |
@@ -278,9 +279,23 public: | |||||
278 |
|
279 | |||
279 | //! replace the internal import implementation and use the supplied interface to load files (both py and pyc files) |
|
280 | //! replace the internal import implementation and use the supplied interface to load files (both py and pyc files) | |
280 | //! (this method should be called directly after initialization of init() and before calling overwriteSysPath(). |
|
281 | //! (this method should be called directly after initialization of init() and before calling overwriteSysPath(). | |
281 | //! It can only be called once, further calls will be ignored silently. (ownership stays with caller) |
|
282 | //! On the first call to this method, it will install a generic PythonQt importer in Pythons "path_hooks". | |
|
283 | //! This is not reversible, so even setting setImporter(NULL) afterwards will | |||
|
284 | //! keep the custom PythonQt importer with a QFile default import interface. | |||
|
285 | //! Subsequent python import calls will make use of the passed importInterface | |||
|
286 | //! which forwards all import calls to the given \c importInterface. | |||
|
287 | //! Passing NULL will install a default QFile importer. | |||
|
288 | //! (\c importInterface ownership stays with caller) | |||
282 | void setImporter(PythonQtImportFileInterface* importInterface); |
|
289 | void setImporter(PythonQtImportFileInterface* importInterface); | |
283 |
|
290 | |||
|
291 | //! this installs the default QFile importer (which effectively does a setImporter(NULL)) | |||
|
292 | //! (without calling setImporter or installDefaultImporter at least once, the default python import | |||
|
293 | //! mechanism is in place) | |||
|
294 | //! the default importer allows to import files from anywhere QFile can read from, | |||
|
295 | //! including the Qt resource system using ":". Keep in mind that you need to extend | |||
|
296 | //! "sys.path" with ":" to be able to import from the Qt resources. | |||
|
297 | void installDefaultImporter() { setImporter(NULL); } | |||
|
298 | ||||
284 | //! set paths that the importer should ignore |
|
299 | //! set paths that the importer should ignore | |
285 | void setImporterIgnorePaths(const QStringList& paths); |
|
300 | void setImporterIgnorePaths(const QStringList& paths); | |
286 |
|
301 | |||
@@ -442,6 +457,9 private: | |||||
442 | //! the importer interface (if set) |
|
457 | //! the importer interface (if set) | |
443 | PythonQtImportFileInterface* _importInterface; |
|
458 | PythonQtImportFileInterface* _importInterface; | |
444 |
|
459 | |||
|
460 | //! the default importer | |||
|
461 | PythonQtQFileImporter* _defaultImporter; | |||
|
462 | ||||
445 |
|
|
463 | PythonQtQObjectNoLongerWrappedCB* _noLongerWrappedCB; | |
446 | PythonQtQObjectWrappedCB* _wrappedCB; |
|
464 | PythonQtQObjectWrappedCB* _wrappedCB; | |
447 |
|
465 |
@@ -588,7 +588,7 QString PythonQtConv::PyObjGetString(PyObject* val, bool strict, bool& ok) { | |||||
588 | return r; |
|
588 | return r; | |
589 | } |
|
589 | } | |
590 |
|
590 | |||
591 | QByteArray PythonQtConv::PyObjGetBytes(PyObject* val, bool strict, bool& ok) { |
|
591 | QByteArray PythonQtConv::PyObjGetBytes(PyObject* val, bool /*strict*/, bool& ok) { | |
592 | QByteArray r; |
|
592 | QByteArray r; | |
593 | ok = true; |
|
593 | ok = true; | |
594 | if (val->ob_type == &PyString_Type) { |
|
594 | if (val->ob_type == &PyString_Type) { | |
@@ -980,7 +980,7 PyObject* PythonQtConv::ConvertQListWithPointersToPython(QList<void*>* list, con | |||||
980 | return result; |
|
980 | return result; | |
981 | } |
|
981 | } | |
982 |
|
982 | |||
983 | bool PythonQtConv::ConvertPythonListToQListOfType(PyObject* obj, QList<void*>* list, const QByteArray& type, bool strict) |
|
983 | bool PythonQtConv::ConvertPythonListToQListOfType(PyObject* obj, QList<void*>* list, const QByteArray& type, bool /*strict*/) | |
984 | { |
|
984 | { | |
985 | bool result = false; |
|
985 | bool result = false; | |
986 | if (PySequence_Check(obj)) { |
|
986 | if (PySequence_Check(obj)) { |
@@ -51,7 +51,7 | |||||
51 |
|
51 | |||
52 | \section Introduction |
|
52 | \section Introduction | |
53 |
|
53 | |||
54 |
\b PythonQt is a dynamic Python (http://www.python.org) binding for Qt (http://www. |
|
54 | \b PythonQt is a dynamic Python (http://www.python.org) binding for Qt (http://www.qtsoftware.com). | |
55 | It offers an easy way to embed the Python scripting language into |
|
55 | It offers an easy way to embed the Python scripting language into | |
56 | your Qt applications. It makes heavy use of the QMetaObject system and thus requires Qt4.x. |
|
56 | your Qt applications. It makes heavy use of the QMetaObject system and thus requires Qt4.x. | |
57 |
|
57 | |||
@@ -339,7 +339,7 yourCpp = None | |||||
339 |
|
339 | |||
340 | \section Building |
|
340 | \section Building | |
341 |
|
341 | |||
342 |
PythonQt requires at least Qt 4.2.2 (or higher) and Python 2.3, 2.4 or 2. |
|
342 | PythonQt requires at least Qt 4.2.2 (or higher) and Python 2.3, 2.4, 2.5 or 2.6 on Windows, Linux and MacOS X. It has not yet been tested with Python 3.x, but it should only require minor changes. | |
343 | To compile PythonQt, you will need a python developer installation which includes Python's header files and |
|
343 | To compile PythonQt, you will need a python developer installation which includes Python's header files and | |
344 | the python2x.[lib | dll | so | dynlib]. |
|
344 | the python2x.[lib | dll | so | dynlib]. | |
345 | The build scripts a currently set to use Python 2.5. |
|
345 | The build scripts a currently set to use Python 2.5. | |
@@ -459,8 +459,4 the python2x.[lib | dll | so | dynlib]. | |||||
459 | \endcode |
|
459 | \endcode | |
460 |
|
460 | |||
461 |
|
461 | |||
462 | \section TODOs |
|
|||
463 |
|
||||
464 | - add more information on how to distribute an application that uses PythonQt, including the Python distribution |
|
|||
465 |
|
||||
466 | */ |
|
462 | */ |
@@ -51,6 +51,9 | |||||
51 | class PythonQtImportFileInterface { |
|
51 | class PythonQtImportFileInterface { | |
52 |
|
52 | |||
53 | public: |
|
53 | public: | |
|
54 | // get rid of warnings | |||
|
55 | virtual ~PythonQtImportFileInterface() {} | |||
|
56 | ||||
54 | //! read the given file as byte array, without doing any linefeed translations |
|
57 | //! read the given file as byte array, without doing any linefeed translations | |
55 | virtual QByteArray readFileAsBytes(const QString& filename) = 0; |
|
58 | virtual QByteArray readFileAsBytes(const QString& filename) = 0; | |
56 |
|
59 |
@@ -112,7 +112,7 PythonQtImport::module_info PythonQtImport::getModuleInfo(PythonQtImporter* self | |||||
112 | /* PythonQtImporter.__init__ |
|
112 | /* PythonQtImporter.__init__ | |
113 | Just store the path argument |
|
113 | Just store the path argument | |
114 | */ |
|
114 | */ | |
115 | int PythonQtImporter_init(PythonQtImporter *self, PyObject *args, PyObject *kwds) |
|
115 | int PythonQtImporter_init(PythonQtImporter *self, PyObject *args, PyObject * /*kwds*/) | |
116 | { |
|
116 | { | |
117 | self->_path = NULL; |
|
117 | self->_path = NULL; | |
118 |
|
118 | |||
@@ -205,8 +205,11 PythonQtImporter_load_module(PyObject *obj, PyObject *args) | |||||
205 | } |
|
205 | } | |
206 | dict = PyModule_GetDict(mod); |
|
206 | dict = PyModule_GetDict(mod); | |
207 |
|
207 | |||
208 | if (PyDict_SetItemString(dict, "__loader__", (PyObject *)self) != 0) |
|
208 | if (PyDict_SetItemString(dict, "__loader__", (PyObject *)self) != 0) { | |
209 | goto error; |
|
209 | Py_DECREF(code); | |
|
210 | Py_DECREF(mod); | |||
|
211 | return NULL; | |||
|
212 | } | |||
210 |
|
213 | |||
211 | if (ispackage) { |
|
214 | if (ispackage) { | |
212 | PyObject *pkgpath, *fullpath; |
|
215 | PyObject *pkgpath, *fullpath; | |
@@ -217,33 +220,38 PythonQtImporter_load_module(PyObject *obj, PyObject *args) | |||||
217 | self->_path->toLatin1().constData(), |
|
220 | self->_path->toLatin1().constData(), | |
218 | SEP, |
|
221 | SEP, | |
219 | subname.toLatin1().constData()); |
|
222 | subname.toLatin1().constData()); | |
220 | if (fullpath == NULL) |
|
223 | if (fullpath == NULL) { | |
221 | goto error; |
|
224 | Py_DECREF(code); | |
|
225 | Py_DECREF(mod); | |||
|
226 | return NULL; | |||
|
227 | } | |||
222 |
|
228 | |||
223 | pkgpath = Py_BuildValue("[O]", fullpath); |
|
229 | pkgpath = Py_BuildValue("[O]", fullpath); | |
224 | Py_DECREF(fullpath); |
|
230 | Py_DECREF(fullpath); | |
225 | if (pkgpath == NULL) |
|
231 | if (pkgpath == NULL) { | |
226 | goto error; |
|
232 | Py_DECREF(code); | |
|
233 | Py_DECREF(mod); | |||
|
234 | return NULL; | |||
|
235 | } | |||
227 | err = PyDict_SetItemString(dict, "__path__", pkgpath); |
|
236 | err = PyDict_SetItemString(dict, "__path__", pkgpath); | |
228 | Py_DECREF(pkgpath); |
|
237 | Py_DECREF(pkgpath); | |
229 | if (err != 0) |
|
238 | if (err != 0) { | |
230 | goto error; |
|
239 | Py_DECREF(code); | |
|
240 | Py_DECREF(mod); | |||
|
241 | return NULL; | |||
|
242 | } | |||
231 | } |
|
243 | } | |
232 | mod = PyImport_ExecCodeModuleEx(fullname, code, (char*)modpath.toLatin1().data()); |
|
244 | mod = PyImport_ExecCodeModuleEx(fullname, code, (char*)modpath.toLatin1().data()); | |
233 | Py_DECREF(code); |
|
245 | Py_DECREF(code); | |
234 | if (Py_VerboseFlag) |
|
246 | if (Py_VerboseFlag) | |
235 | PySys_WriteStderr("import %s # loaded from %s\n", |
|
247 | PySys_WriteStderr("import %s # loaded from %s\n", | |
236 | fullname, modpath); |
|
248 | fullname, modpath.toLatin1().constData()); | |
237 | return mod; |
|
249 | return mod; | |
238 | error: |
|
|||
239 | Py_DECREF(code); |
|
|||
240 | Py_DECREF(mod); |
|
|||
241 | return NULL; |
|
|||
242 | } |
|
250 | } | |
243 |
|
251 | |||
244 |
|
252 | |||
245 | PyObject * |
|
253 | PyObject * | |
246 | PythonQtImporter_get_data(PyObject *obj, PyObject *args) |
|
254 | PythonQtImporter_get_data(PyObject* /*obj*/, PyObject* /*args*/) | |
247 | { |
|
255 | { | |
248 | // EXTRA, NOT YET IMPLEMENTED |
|
256 | // EXTRA, NOT YET IMPLEMENTED | |
249 | return NULL; |
|
257 | return NULL; | |
@@ -263,7 +271,7 PythonQtImporter_get_code(PyObject *obj, PyObject *args) | |||||
263 | } |
|
271 | } | |
264 |
|
272 | |||
265 | PyObject * |
|
273 | PyObject * | |
266 | PythonQtImporter_get_source(PyObject *obj, PyObject *args) |
|
274 | PythonQtImporter_get_source(PyObject * /*obj*/, PyObject * /*args*/) | |
267 | { |
|
275 | { | |
268 | // EXTRA, NOT YET IMPLEMENTED |
|
276 | // EXTRA, NOT YET IMPLEMENTED | |
269 | /* |
|
277 | /* | |
@@ -353,7 +361,7 PyMethodDef PythonQtImporter_methods[] = { | |||||
353 | doc_get_code}, |
|
361 | doc_get_code}, | |
354 | {"get_source", PythonQtImporter_get_source, METH_VARARGS, |
|
362 | {"get_source", PythonQtImporter_get_source, METH_VARARGS, | |
355 | doc_get_source}, |
|
363 | doc_get_source}, | |
356 | {NULL, NULL} /* sentinel */ |
|
364 | {NULL, NULL, 0 , NULL} /* sentinel */ | |
357 | }; |
|
365 | }; | |
358 |
|
366 | |||
359 |
|
367 | |||
@@ -579,24 +587,11 PythonQtImport::compileSource(const QString& path, const QByteArray& data) | |||||
579 | /* Return the code object for the module named by 'fullname' from the |
|
587 | /* Return the code object for the module named by 'fullname' from the | |
580 | Zip archive as a new reference. */ |
|
588 | Zip archive as a new reference. */ | |
581 | PyObject * |
|
589 | PyObject * | |
582 | PythonQtImport::getCodeFromData(const QString& path, int isbytecode,int ispackage, time_t mtime) |
|
590 | PythonQtImport::getCodeFromData(const QString& path, int isbytecode,int /*ispackage*/, time_t mtime) | |
583 | { |
|
591 | { | |
584 | bool hasImporter = PythonQt::importInterface()!=NULL; |
|
|||
585 |
|
||||
586 | PyObject *code; |
|
592 | PyObject *code; | |
587 |
|
593 | |||
588 | QByteArray qdata; |
|
594 | QByteArray qdata; | |
589 | if (!hasImporter) { |
|
|||
590 | QFile file(path); |
|
|||
591 | QIODevice::OpenMode flags = QIODevice::ReadOnly; |
|
|||
592 | if (!isbytecode) { |
|
|||
593 | flags |= QIODevice::Text; |
|
|||
594 | } |
|
|||
595 | if (!file.open(flags)) { |
|
|||
596 | return NULL; |
|
|||
597 | } |
|
|||
598 | qdata = file.readAll(); |
|
|||
599 | } else { |
|
|||
600 | if (!isbytecode) { |
|
595 | if (!isbytecode) { | |
601 | // mlabDebugConst("MLABPython", "reading source " << path); |
|
596 | // mlabDebugConst("MLABPython", "reading source " << path); | |
602 | bool ok; |
|
597 | bool ok; | |
@@ -611,7 +606,6 PythonQtImport::getCodeFromData(const QString& path, int isbytecode,int ispackag | |||||
611 | } else { |
|
606 | } else { | |
612 | qdata = PythonQt::importInterface()->readFileAsBytes(path); |
|
607 | qdata = PythonQt::importInterface()->readFileAsBytes(path); | |
613 | } |
|
608 | } | |
614 | } |
|
|||
615 |
|
609 | |||
616 | if (isbytecode) { |
|
610 | if (isbytecode) { | |
617 | // mlabDebugConst("MLABPython", "reading bytecode " << path); |
|
611 | // mlabDebugConst("MLABPython", "reading bytecode " << path); | |
@@ -623,7 +617,7 PythonQtImport::getCodeFromData(const QString& path, int isbytecode,int ispackag | |||||
623 | if (code) { |
|
617 | if (code) { | |
624 | // save a pyc file if possible |
|
618 | // save a pyc file if possible | |
625 | QDateTime time; |
|
619 | QDateTime time; | |
626 |
time = |
|
620 | time = PythonQt::importInterface()->lastModifiedDate(path); | |
627 | writeCompiledModule((PyCodeObject*)code, path+"c", time.toTime_t()); |
|
621 | writeCompiledModule((PyCodeObject*)code, path+"c", time.toTime_t()); | |
628 | } |
|
622 | } | |
629 | } |
|
623 | } | |
@@ -637,16 +631,10 PythonQtImport::getMTimeOfSource(const QString& path) | |||||
637 | QString path2 = path; |
|
631 | QString path2 = path; | |
638 | path2.truncate(path.length()-1); |
|
632 | path2.truncate(path.length()-1); | |
639 |
|
633 | |||
640 | bool hasImporter = PythonQt::importInterface()!=NULL; |
|
|||
641 | if (hasImporter) { |
|
|||
642 |
|
|
634 | if (PythonQt::importInterface()->exists(path2)) { | |
643 |
|
|
635 | mtime = PythonQt::importInterface()->lastModifiedDate(path2).toTime_t(); | |
644 |
|
|
636 | } | |
645 | } else { |
|
637 | ||
646 | if (QFile::exists(path2)) { |
|
|||
647 | mtime = QFileInfo(path2).lastModified().toTime_t(); |
|
|||
648 | } |
|
|||
649 | } |
|
|||
650 | return mtime; |
|
638 | return mtime; | |
651 | } |
|
639 | } | |
652 |
|
640 | |||
@@ -708,13 +696,10 QString PythonQtImport::replaceExtension(const QString& str, const QString& ext) | |||||
708 |
|
696 | |||
709 | PyObject* PythonQtImport::getCodeFromPyc(const QString& file) |
|
697 | PyObject* PythonQtImport::getCodeFromPyc(const QString& file) | |
710 | { |
|
698 | { | |
711 | bool hasImporter = PythonQt::importInterface()!=NULL; |
|
|||
712 |
|
||||
713 | PyObject* code; |
|
699 | PyObject* code; | |
714 | const static QString pycStr("pyc"); |
|
700 | const static QString pycStr("pyc"); | |
715 | QString pyc = replaceExtension(file, pycStr); |
|
701 | QString pyc = replaceExtension(file, pycStr); | |
716 |
if ( |
|
702 | if (PythonQt::importInterface()->exists(pyc)) { | |
717 | (!hasImporter && QFile::exists(pyc))) { |
|
|||
718 | time_t mtime = 0; |
|
703 | time_t mtime = 0; | |
719 | mtime = getMTimeOfSource(pyc); |
|
704 | mtime = getMTimeOfSource(pyc); | |
720 | code = getCodeFromData(pyc, true, false, mtime); |
|
705 | code = getCodeFromData(pyc, true, false, mtime); | |
@@ -732,10 +717,16 PyObject* PythonQtImport::getCodeFromPyc(const QString& file) | |||||
732 | /* Module init */ |
|
717 | /* Module init */ | |
733 |
|
718 | |||
734 | PyDoc_STRVAR(mlabimport_doc, |
|
719 | PyDoc_STRVAR(mlabimport_doc, | |
735 |
"Imports python files into |
|
720 | "Imports python files into PythonQt, completely replaces internal python import"); | |
736 |
|
721 | |||
737 | void PythonQtImport::init() |
|
722 | void PythonQtImport::init() | |
738 | { |
|
723 | { | |
|
724 | static bool first = true; | |||
|
725 | if (!first) { | |||
|
726 | return; | |||
|
727 | } | |||
|
728 | first = false; | |||
|
729 | ||||
739 | PyObject *mod; |
|
730 | PyObject *mod; | |
740 |
|
731 | |||
741 | if (PyType_Ready(&PythonQtImporter_Type) < 0) |
|
732 | if (PyType_Ready(&PythonQtImporter_Type) < 0) |
@@ -52,7 +52,7 static void PythonQtMetaObjectWrapper_dealloc(PythonQtMetaObjectWrapper* self) | |||||
52 | self->ob_type->tp_free((PyObject*)self); |
|
52 | self->ob_type->tp_free((PyObject*)self); | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | static PyObject* PythonQtMetaObjectWrapper_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
55 | static PyObject* PythonQtMetaObjectWrapper_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) | |
56 | { |
|
56 | { | |
57 | PythonQtMetaObjectWrapper *self; |
|
57 | PythonQtMetaObjectWrapper *self; | |
58 |
|
58 | |||
@@ -63,7 +63,7 static PyObject* PythonQtMetaObjectWrapper_new(PyTypeObject *type, PyObject *arg | |||||
63 | return (PyObject *)self; |
|
63 | return (PyObject *)self; | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | static int PythonQtMetaObjectWrapper_init(PythonQtMetaObjectWrapper *self, PyObject *args, PyObject *kwds) |
|
66 | static int PythonQtMetaObjectWrapper_init(PythonQtMetaObjectWrapper * /*self*/, PyObject * /*args*/, PyObject * /*kwds*/) | |
67 | { |
|
67 | { | |
68 | return 0; |
|
68 | return 0; | |
69 | } |
|
69 | } | |
@@ -123,7 +123,7 static PyMethodDef PythonQtMetaObjectWrapper_methods[] = { | |||||
123 | {"help", (PyCFunction)PythonQtMetaObjectWrapper_help, METH_NOARGS, |
|
123 | {"help", (PyCFunction)PythonQtMetaObjectWrapper_help, METH_NOARGS, | |
124 | "Shows the help of available methods for this class" |
|
124 | "Shows the help of available methods for this class" | |
125 | }, |
|
125 | }, | |
126 | {NULL} /* Sentinel */ |
|
126 | {NULL, NULL, 0 , NULL} /* Sentinel */ | |
127 | }; |
|
127 | }; | |
128 |
|
128 | |||
129 |
|
129 |
@@ -70,6 +70,9 typedef struct { | |||||
70 | // an abstact class for handling construction of objects |
|
70 | // an abstact class for handling construction of objects | |
71 | class PythonQtConstructorHandler { |
|
71 | class PythonQtConstructorHandler { | |
72 | public: |
|
72 | public: | |
|
73 | //! get rid of warnings | |||
|
74 | virtual ~PythonQtConstructorHandler() {} | |||
|
75 | ||||
73 | virtual QObject* create(const QMetaObject* meta, PyObject *args, PyObject *kw, QString& error) = 0; |
|
76 | virtual QObject* create(const QMetaObject* meta, PyObject *args, PyObject *kw, QString& error) = 0; | |
74 | }; |
|
77 | }; | |
75 |
|
78 |
@@ -79,6 +79,7 public: | |||||
79 | foreach(chunk, _chunks) { |
|
79 | foreach(chunk, _chunks) { | |
80 | delete[]chunk; |
|
80 | delete[]chunk; | |
81 | } |
|
81 | } | |
|
82 | _chunks.clear(); | |||
82 | } |
|
83 | } | |
83 |
|
84 | |||
84 | //! reset the storage to 0 (without freeing memory, thus caching old entries for reuse) |
|
85 | //! reset the storage to 0 (without freeing memory, thus caching old entries for reuse) |
@@ -178,7 +178,7 PyObject *PythonQtSlotFunction_Call(PyObject *func, PyObject *args, PyObject *kw | |||||
178 | } |
|
178 | } | |
179 | } |
|
179 | } | |
180 |
|
180 | |||
181 | PyObject *PythonQtSlotFunction_CallImpl(QObject* objectToCall, PythonQtSlotInfo* info, PyObject *args, PyObject *kw, bool isVariantCall, void* firstArg) |
|
181 | PyObject *PythonQtSlotFunction_CallImpl(QObject* objectToCall, PythonQtSlotInfo* info, PyObject *args, PyObject * /*kw*/, bool isVariantCall, void* firstArg) | |
182 | { |
|
182 | { | |
183 | int argc = PyTuple_Size(args); |
|
183 | int argc = PyTuple_Size(args); | |
184 |
|
184 | |||
@@ -298,14 +298,14 meth_dealloc(PythonQtSlotFunctionObject *m) | |||||
298 | } |
|
298 | } | |
299 |
|
299 | |||
300 | static PyObject * |
|
300 | static PyObject * | |
301 | meth_get__doc__(PythonQtSlotFunctionObject *m, void *closure) |
|
301 | meth_get__doc__(PythonQtSlotFunctionObject * /*m*/, void * /*closure*/) | |
302 | { |
|
302 | { | |
303 | Py_INCREF(Py_None); |
|
303 | Py_INCREF(Py_None); | |
304 | return Py_None; |
|
304 | return Py_None; | |
305 | } |
|
305 | } | |
306 |
|
306 | |||
307 | static PyObject * |
|
307 | static PyObject * | |
308 | meth_get__name__(PythonQtSlotFunctionObject *m, void *closure) |
|
308 | meth_get__name__(PythonQtSlotFunctionObject *m, void * /*closure*/) | |
309 | { |
|
309 | { | |
310 | return PyString_FromString(m->m_ml->metaMethod()->signature()); |
|
310 | return PyString_FromString(m->m_ml->metaMethod()->signature()); | |
311 | } |
|
311 | } | |
@@ -328,7 +328,7 meth_traverse(PythonQtSlotFunctionObject *m, visitproc visit, void *arg) | |||||
328 | } |
|
328 | } | |
329 |
|
329 | |||
330 | static PyObject * |
|
330 | static PyObject * | |
331 | meth_get__self__(PythonQtSlotFunctionObject *m, void *closure) |
|
331 | meth_get__self__(PythonQtSlotFunctionObject *m, void * /*closure*/) | |
332 | { |
|
332 | { | |
333 | PyObject *self; |
|
333 | PyObject *self; | |
334 | if (PyEval_GetRestricted()) { |
|
334 | if (PyEval_GetRestricted()) { | |
@@ -347,13 +347,17 static PyGetSetDef meth_getsets [] = { | |||||
347 | {"__doc__", (getter)meth_get__doc__, NULL, NULL}, |
|
347 | {"__doc__", (getter)meth_get__doc__, NULL, NULL}, | |
348 | {"__name__", (getter)meth_get__name__, NULL, NULL}, |
|
348 | {"__name__", (getter)meth_get__name__, NULL, NULL}, | |
349 | {"__self__", (getter)meth_get__self__, NULL, NULL}, |
|
349 | {"__self__", (getter)meth_get__self__, NULL, NULL}, | |
350 | {0} |
|
350 | {NULL, NULL, NULL,NULL}, | |
351 | }; |
|
351 | }; | |
352 |
|
352 | |||
|
353 | #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 6 | |||
|
354 | #define PY_WRITE_RESTRICTED WRITE_RESTRICTED | |||
|
355 | #endif | |||
|
356 | ||||
353 | #define OFF(x) offsetof(PythonQtSlotFunctionObject, x) |
|
357 | #define OFF(x) offsetof(PythonQtSlotFunctionObject, x) | |
354 |
|
358 | |||
355 | static PyMemberDef meth_members[] = { |
|
359 | static PyMemberDef meth_members[] = { | |
356 | {"__module__", T_OBJECT, OFF(m_module), WRITE_RESTRICTED}, |
|
360 | {"__module__", T_OBJECT, OFF(m_module), PY_WRITE_RESTRICTED}, | |
357 | {NULL} |
|
361 | {NULL} | |
358 | }; |
|
362 | }; | |
359 |
|
363 |
@@ -41,7 +41,7 | |||||
41 |
|
41 | |||
42 | #include "PythonQtStdOut.h" |
|
42 | #include "PythonQtStdOut.h" | |
43 |
|
43 | |||
44 | static PyObject *PythonQtStdOutRedirect_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
44 | static PyObject *PythonQtStdOutRedirect_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) | |
45 | { |
|
45 | { | |
46 | PythonQtStdOutRedirect *self; |
|
46 | PythonQtStdOutRedirect *self; | |
47 | self = (PythonQtStdOutRedirect *)type->tp_alloc(type, 0); |
|
47 | self = (PythonQtStdOutRedirect *)type->tp_alloc(type, 0); | |
@@ -70,7 +70,7 static PyObject *PythonQtStdOutRedirect_write(PyObject *self, PyObject *args) | |||||
70 | return Py_BuildValue(""); |
|
70 | return Py_BuildValue(""); | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | static PyObject *PythonQtStdOutRedirect_flush(PyObject *self, PyObject *args) |
|
73 | static PyObject *PythonQtStdOutRedirect_flush(PyObject * /*self*/, PyObject * /*args*/) | |
74 | { |
|
74 | { | |
75 | return Py_BuildValue(""); |
|
75 | return Py_BuildValue(""); | |
76 | } |
|
76 | } | |
@@ -83,7 +83,7 static PyMethodDef PythonQtStdOutRedirect_methods[] = { | |||||
83 | {"flush", (PyCFunction)PythonQtStdOutRedirect_flush, METH_VARARGS, |
|
83 | {"flush", (PyCFunction)PythonQtStdOutRedirect_flush, METH_VARARGS, | |
84 | "flush the output, currently not implemented but needed for logging framework" |
|
84 | "flush the output, currently not implemented but needed for logging framework" | |
85 | }, |
|
85 | }, | |
86 |
{NULL} |
|
86 | {NULL, NULL, 0 , NULL} /* sentinel */ | |
87 | }; |
|
87 | }; | |
88 |
|
88 | |||
89 | static PyMemberDef PythonQtStdOutRedirect_members[] = { |
|
89 | static PyMemberDef PythonQtStdOutRedirect_members[] = { |
@@ -58,7 +58,7 static void PythonQtVariantWrapper_dealloc(PythonQtVariantWrapper* self) | |||||
58 | self->ob_type->tp_free((PyObject*)self); |
|
58 | self->ob_type->tp_free((PyObject*)self); | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | static PyObject* PythonQtVariantWrapper_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
61 | static PyObject* PythonQtVariantWrapper_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) | |
62 | { |
|
62 | { | |
63 | PythonQtVariantWrapper *self; |
|
63 | PythonQtVariantWrapper *self; | |
64 |
|
64 | |||
@@ -70,7 +70,7 static PyObject* PythonQtVariantWrapper_new(PyTypeObject *type, PyObject *args, | |||||
70 | return (PyObject *)self; |
|
70 | return (PyObject *)self; | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | static int PythonQtVariantWrapper_init(PythonQtVariantWrapper *self, PyObject *args, PyObject *kwds) |
|
73 | static int PythonQtVariantWrapper_init(PythonQtVariantWrapper * /*self*/, PyObject * /*args*/, PyObject * /*kwds*/) | |
74 | { |
|
74 | { | |
75 | return 0; |
|
75 | return 0; | |
76 | } |
|
76 | } | |
@@ -93,7 +93,7 static PyMethodDef PythonQtVariantWrapper_methods[] = { | |||||
93 | {"help", (PyCFunction)PythonQtVariantWrapper_help, METH_NOARGS, |
|
93 | {"help", (PyCFunction)PythonQtVariantWrapper_help, METH_NOARGS, | |
94 | "Shows the help of available methods for this class" |
|
94 | "Shows the help of available methods for this class" | |
95 | }, |
|
95 | }, | |
96 | {NULL} /* Sentinel */ |
|
96 | {NULL,NULL,0,NULL} /* Sentinel */ | |
97 | }; |
|
97 | }; | |
98 |
|
98 | |||
99 |
|
99 |
@@ -91,7 +91,7 static void PythonQtWrapper_dealloc(PythonQtWrapper* self) | |||||
91 | self->ob_type->tp_free((PyObject*)self); |
|
91 | self->ob_type->tp_free((PyObject*)self); | |
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 | static PyObject* PythonQtWrapper_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
94 | static PyObject* PythonQtWrapper_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) | |
95 | { |
|
95 | { | |
96 | PythonQtWrapper *self; |
|
96 | PythonQtWrapper *self; | |
97 |
|
97 | |||
@@ -105,7 +105,7 static PyObject* PythonQtWrapper_new(PyTypeObject *type, PyObject *args, PyObjec | |||||
105 | return (PyObject *)self; |
|
105 | return (PyObject *)self; | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | static int PythonQtWrapper_init(PythonQtWrapper *self, PyObject *args, PyObject *kwds) |
|
108 | static int PythonQtWrapper_init(PythonQtWrapper * /*self*/, PyObject * /*args*/, PyObject * /*kwds*/) | |
109 | { |
|
109 | { | |
110 | return 0; |
|
110 | return 0; | |
111 | } |
|
111 | } | |
@@ -128,7 +128,7 static PyMethodDef PythonQtWrapper_methods[] = { | |||||
128 | {"help", (PyCFunction)PythonQtWrapper_help, METH_NOARGS, |
|
128 | {"help", (PyCFunction)PythonQtWrapper_help, METH_NOARGS, | |
129 | "Shows the help of available methods for this class" |
|
129 | "Shows the help of available methods for this class" | |
130 | }, |
|
130 | }, | |
131 | {NULL} /* Sentinel */ |
|
131 | {NULL, NULL, 0, NULL} /* Sentinel */ | |
132 | }; |
|
132 | }; | |
133 |
|
133 | |||
134 |
|
134 | |||
@@ -164,6 +164,9 static PyObject *PythonQtWrapper_getattro(PyObject *obj,PyObject *name) | |||||
164 | case PythonQtMemberInfo::EnumValue: |
|
164 | case PythonQtMemberInfo::EnumValue: | |
165 | return PyInt_FromLong(member._enumValue); |
|
165 | return PyInt_FromLong(member._enumValue); | |
166 | break; |
|
166 | break; | |
|
167 | default: | |||
|
168 | // is an invalid type, go on | |||
|
169 | break; | |||
167 | } |
|
170 | } | |
168 |
|
171 | |||
169 | // look for the interal methods (className(), help()) |
|
172 | // look for the interal methods (className(), help()) |
@@ -18,6 +18,7 HEADERS += \ | |||||
18 | $$PWD/PythonQtCppWrapperFactory.h \ |
|
18 | $$PWD/PythonQtCppWrapperFactory.h \ | |
19 | $$PWD/PythonQtVariants.h \ |
|
19 | $$PWD/PythonQtVariants.h \ | |
20 | $$PWD/PythonQtVariantWrapper.h \ |
|
20 | $$PWD/PythonQtVariantWrapper.h \ | |
|
21 | $$PWD/PythonQtQFileImporter.h \ | |||
21 | $$PWD/wrapper/PythonQtWrappedVariants.h \ |
|
22 | $$PWD/wrapper/PythonQtWrappedVariants.h \ | |
22 | $$PWD/gui/PythonQtScriptingConsole.h \ |
|
23 | $$PWD/gui/PythonQtScriptingConsole.h \ | |
23 | $$PWD/PythonQtSystem.h |
|
24 | $$PWD/PythonQtSystem.h | |
@@ -37,6 +38,7 SOURCES += \ | |||||
37 | $$PWD/PythonQtVariants.cpp \ |
|
38 | $$PWD/PythonQtVariants.cpp \ | |
38 | $$PWD/PythonQtVariantWrapper.cpp \ |
|
39 | $$PWD/PythonQtVariantWrapper.cpp \ | |
39 | $$PWD/PythonQtWrapper.cpp \ |
|
40 | $$PWD/PythonQtWrapper.cpp \ | |
|
41 | $$PWD/PythonQtQFileImporter.cpp \ | |||
40 | $$PWD/PythonQtMetaObjectWrapper.cpp \ |
|
42 | $$PWD/PythonQtMetaObjectWrapper.cpp \ | |
41 | $$PWD/gui/PythonQtScriptingConsole.cpp |
|
43 | $$PWD/gui/PythonQtScriptingConsole.cpp | |
42 |
|
44 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now