@@ -171,16 +171,16 PythonQt::PythonQt(int flags) | |||||
171 | Py_INCREF(&PythonQtSlotFunction_Type); |
|
171 | Py_INCREF(&PythonQtSlotFunction_Type); | |
172 |
|
172 | |||
173 | // add our own python object types for qt objects |
|
173 | // add our own python object types for qt objects | |
174 | if (PyType_Ready(&PythonQtWrapper_Type) < 0) { |
|
174 | if (PyType_Ready(&PythonQtInstanceWrapper_Type) < 0) { | |
175 | std::cerr << "could not initialize PythonQtWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; |
|
175 | std::cerr << "could not initialize PythonQtInstanceWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; | |
176 | } |
|
176 | } | |
177 | Py_INCREF(&PythonQtWrapper_Type); |
|
177 | Py_INCREF(&PythonQtInstanceWrapper_Type); | |
178 |
|
178 | |||
179 | // add our own python object types for qt objects |
|
179 | // add our own python object types for qt objects | |
180 |
if (PyType_Ready(&PythonQt |
|
180 | if (PyType_Ready(&PythonQtClassWrapper_Type) < 0) { | |
181 |
std::cerr << "could not initialize PythonQt |
|
181 | std::cerr << "could not initialize PythonQtClassWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; | |
182 | } |
|
182 | } | |
183 |
Py_INCREF(&PythonQt |
|
183 | Py_INCREF(&PythonQtClassWrapper_Type); | |
184 |
|
184 | |||
185 | // add our own python object types for redirection of stdout |
|
185 | // add our own python object types for redirection of stdout | |
186 | if (PyType_Ready(&PythonQtStdOutRedirectType) < 0) { |
|
186 | if (PyType_Ready(&PythonQtStdOutRedirectType) < 0) { | |
@@ -277,7 +277,7 void PythonQtPrivate::registerClass(const QMetaObject* metaobject, const char* p | |||||
277 | info = new PythonQtClassInfo(m); |
|
277 | info = new PythonQtClassInfo(m); | |
278 | _knownQtClasses.insert(m->className(), info); |
|
278 | _knownQtClasses.insert(m->className(), info); | |
279 | PythonQtObjectPtr pack = packageByName(package); |
|
279 | PythonQtObjectPtr pack = packageByName(package); | |
280 |
PyObject* pyobj = (PyObject*)createNewPythonQt |
|
280 | PyObject* pyobj = (PyObject*)createNewPythonQtClassWrapper(info); | |
281 | PyModule_AddObject(pack, m->className(), pyobj); |
|
281 | PyModule_AddObject(pack, m->className(), pyobj); | |
282 | if (package && strncmp(package,"Qt",2)==0) { |
|
282 | if (package && strncmp(package,"Qt",2)==0) { | |
283 | // put all qt objects into Qt as well |
|
283 | // put all qt objects into Qt as well | |
@@ -328,7 +328,7 PyObject* PythonQtPrivate::wrapQObject(QObject* obj) | |||||
328 | Py_INCREF(Py_None); |
|
328 | Py_INCREF(Py_None); | |
329 | return Py_None; |
|
329 | return Py_None; | |
330 | } |
|
330 | } | |
331 | PythonQtWrapper* wrap = findWrapperAndRemoveUnused(obj); |
|
331 | PythonQtInstanceWrapper* wrap = findWrapperAndRemoveUnused(obj); | |
332 | if (!wrap) { |
|
332 | if (!wrap) { | |
333 | // smuggling it in... |
|
333 | // smuggling it in... | |
334 | PythonQtClassInfo* classInfo = _knownQtClasses.value(obj->metaObject()->className()); |
|
334 | PythonQtClassInfo* classInfo = _knownQtClasses.value(obj->metaObject()->className()); | |
@@ -336,7 +336,7 PyObject* PythonQtPrivate::wrapQObject(QObject* obj) | |||||
336 | registerClass(obj->metaObject()); |
|
336 | registerClass(obj->metaObject()); | |
337 | classInfo = _knownQtClasses.value(obj->metaObject()->className()); |
|
337 | classInfo = _knownQtClasses.value(obj->metaObject()->className()); | |
338 | } |
|
338 | } | |
339 | wrap = createNewPythonQtWrapper(obj, classInfo); |
|
339 | wrap = createNewPythonQtInstanceWrapper(obj, classInfo); | |
340 | // mlabDebugConst("MLABPython","new qobject wrapper added " << " " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1()); |
|
340 | // mlabDebugConst("MLABPython","new qobject wrapper added " << " " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1()); | |
341 | } else { |
|
341 | } else { | |
342 | Py_INCREF(wrap); |
|
342 | Py_INCREF(wrap); | |
@@ -351,7 +351,7 PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name) | |||||
351 | Py_INCREF(Py_None); |
|
351 | Py_INCREF(Py_None); | |
352 | return Py_None; |
|
352 | return Py_None; | |
353 | } |
|
353 | } | |
354 | PythonQtWrapper* wrap = findWrapperAndRemoveUnused(ptr); |
|
354 | PythonQtInstanceWrapper* wrap = findWrapperAndRemoveUnused(ptr); | |
355 | if (!wrap) { |
|
355 | if (!wrap) { | |
356 | PythonQtClassInfo* info = _knownQtClasses.value(name); |
|
356 | PythonQtClassInfo* info = _knownQtClasses.value(name); | |
357 | if (!info) { |
|
357 | if (!info) { | |
@@ -370,7 +370,7 PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name) | |||||
370 | registerClass(qptr->metaObject()); |
|
370 | registerClass(qptr->metaObject()); | |
371 | info = _knownQtClasses.value(qptr->metaObject()->className()); |
|
371 | info = _knownQtClasses.value(qptr->metaObject()->className()); | |
372 | } |
|
372 | } | |
373 | wrap = createNewPythonQtWrapper(qptr, info); |
|
373 | wrap = createNewPythonQtInstanceWrapper(qptr, info); | |
374 | // mlabDebugConst("MLABPython","new qobject wrapper added " << " " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1()); |
|
374 | // mlabDebugConst("MLABPython","new qobject wrapper added " << " " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1()); | |
375 | } else { |
|
375 | } else { | |
376 | // maybe it is a PyObject, which we can return directly |
|
376 | // maybe it is a PyObject, which we can return directly | |
@@ -391,13 +391,13 PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name) | |||||
391 | if (!info) { |
|
391 | if (!info) { | |
392 | info = new PythonQtClassInfo(wrapper?wrapper->metaObject():NULL, name); |
|
392 | info = new PythonQtClassInfo(wrapper?wrapper->metaObject():NULL, name); | |
393 | _knownQtWrapperClasses.insert(name, info); |
|
393 | _knownQtWrapperClasses.insert(name, info); | |
394 |
PyModule_AddObject(_pythonQtModule, name, (PyObject*)createNewPythonQt |
|
394 | PyModule_AddObject(_pythonQtModule, name, (PyObject*)createNewPythonQtClassWrapper(info)); | |
395 | } else { |
|
395 | } else { | |
396 | if (wrapper && (info->metaObject() != wrapper->metaObject())) { |
|
396 | if (wrapper && (info->metaObject() != wrapper->metaObject())) { | |
397 | info->setMetaObject(wrapper->metaObject()); |
|
397 | info->setMetaObject(wrapper->metaObject()); | |
398 | } |
|
398 | } | |
399 | } |
|
399 | } | |
400 | wrap = createNewPythonQtWrapper(wrapper, info, ptr); |
|
400 | wrap = createNewPythonQtInstanceWrapper(wrapper, info, ptr); | |
401 | // mlabDebugConst("MLABPython","new c++ wrapper added " << wrap->_wrappedPtr << " " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1()); |
|
401 | // mlabDebugConst("MLABPython","new c++ wrapper added " << wrap->_wrappedPtr << " " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1()); | |
402 | } |
|
402 | } | |
403 | } else { |
|
403 | } else { | |
@@ -408,9 +408,9 PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name) | |||||
408 | } |
|
408 | } | |
409 |
|
409 | |||
410 |
|
410 | |||
411 | PythonQtWrapper* PythonQtPrivate::createNewPythonQtWrapper(QObject* obj, PythonQtClassInfo* info, void* wrappedPtr) { |
|
411 | PythonQtInstanceWrapper* PythonQtPrivate::createNewPythonQtInstanceWrapper(QObject* obj, PythonQtClassInfo* info, void* wrappedPtr) { | |
412 | PythonQtWrapper* result; |
|
412 | PythonQtInstanceWrapper* result; | |
413 | result = (PythonQtWrapper *)PythonQtWrapper_Type.tp_new(&PythonQtWrapper_Type, |
|
413 | result = (PythonQtInstanceWrapper *)PythonQtInstanceWrapper_Type.tp_new(&PythonQtInstanceWrapper_Type, | |
414 | NULL, NULL); |
|
414 | NULL, NULL); | |
415 |
|
415 | |||
416 | result->setQObject(obj); |
|
416 | result->setQObject(obj); | |
@@ -431,9 +431,9 PythonQtWrapper* PythonQtPrivate::createNewPythonQtWrapper(QObject* obj, PythonQ | |||||
431 | return result; |
|
431 | return result; | |
432 | } |
|
432 | } | |
433 |
|
433 | |||
434 |
PythonQt |
|
434 | PythonQtClassWrapper* PythonQtPrivate::createNewPythonQtClassWrapper(PythonQtClassInfo* info) { | |
435 |
PythonQt |
|
435 | PythonQtClassWrapper* result; | |
436 |
result = (PythonQt |
|
436 | result = (PythonQtClassWrapper *)PythonQtClassWrapper_Type.tp_new(&PythonQtClassWrapper_Type, | |
437 | NULL, NULL); |
|
437 | NULL, NULL); | |
438 | result->_info = info; |
|
438 | result->_info = info; | |
439 | return result; |
|
439 | return result; | |
@@ -664,8 +664,8 QStringList PythonQt::introspection(PyObject* module, const QString& objectname, | |||||
664 | results << info->fullSignature(info->isInstanceDecorator()); |
|
664 | results << info->fullSignature(info->isInstanceDecorator()); | |
665 | info = info->nextInfo(); |
|
665 | info = info->nextInfo(); | |
666 | } |
|
666 | } | |
667 |
} else if (object->ob_type == &PythonQt |
|
667 | } else if (object->ob_type == &PythonQtClassWrapper_Type) { | |
668 |
PythonQt |
|
668 | PythonQtClassWrapper* o = (PythonQtClassWrapper*)object.object(); | |
669 | PythonQtSlotInfo* info = o->_info->constructors(); |
|
669 | PythonQtSlotInfo* info = o->_info->constructors(); | |
670 |
|
670 | |||
671 | while (info) { |
|
671 | while (info) { | |
@@ -1009,7 +1009,7 void PythonQtPrivate::registerCPPClass(const char* typeName, const char* parentT | |||||
1009 | info = new PythonQtClassInfo(NULL, typeName); |
|
1009 | info = new PythonQtClassInfo(NULL, typeName); | |
1010 | _knownQtWrapperClasses.insert(typeName, info); |
|
1010 | _knownQtWrapperClasses.insert(typeName, info); | |
1011 | PythonQtObjectPtr pack = packageByName(package); |
|
1011 | PythonQtObjectPtr pack = packageByName(package); | |
1012 |
PyObject* pyobj = (PyObject*)createNewPythonQt |
|
1012 | PyObject* pyobj = (PyObject*)createNewPythonQtClassWrapper(info); | |
1013 | PyModule_AddObject(pack, typeName, pyobj); |
|
1013 | PyModule_AddObject(pack, typeName, pyobj); | |
1014 | if (package && strncmp(package,"Qt",2)==0) { |
|
1014 | if (package && strncmp(package,"Qt",2)==0) { | |
1015 | // put all qt objects into Qt as well |
|
1015 | // put all qt objects into Qt as well | |
@@ -1055,9 +1055,9 void PythonQtPrivate::removeWrapperPointer(void* obj) | |||||
1055 | _wrappedObjects.remove(obj); |
|
1055 | _wrappedObjects.remove(obj); | |
1056 | } |
|
1056 | } | |
1057 |
|
1057 | |||
1058 | PythonQtWrapper* PythonQtPrivate::findWrapperAndRemoveUnused(void* obj) |
|
1058 | PythonQtInstanceWrapper* PythonQtPrivate::findWrapperAndRemoveUnused(void* obj) | |
1059 | { |
|
1059 | { | |
1060 | PythonQtWrapper* wrap = _wrappedObjects.value(obj); |
|
1060 | PythonQtInstanceWrapper* wrap = _wrappedObjects.value(obj); | |
1061 | if (wrap && !wrap->_wrappedPtr && wrap->_obj == NULL) { |
|
1061 | if (wrap && !wrap->_wrappedPtr && wrap->_obj == NULL) { | |
1062 | // this is a wrapper whose QObject was already removed due to destruction |
|
1062 | // this is a wrapper whose QObject was already removed due to destruction | |
1063 | // so the obj pointer has to be a new QObject with the same address... |
|
1063 | // so the obj pointer has to be a new QObject with the same address... |
@@ -43,8 +43,8 | |||||
43 | //---------------------------------------------------------------------------------- |
|
43 | //---------------------------------------------------------------------------------- | |
44 |
|
44 | |||
45 | #include "PythonQtSystem.h" |
|
45 | #include "PythonQtSystem.h" | |
46 | #include "PythonQtWrapper.h" |
|
46 | #include "PythonQtInstanceWrapper.h" | |
47 |
#include "PythonQt |
|
47 | #include "PythonQtClassWrapper.h" | |
48 | #include "PythonQtSlot.h" |
|
48 | #include "PythonQtSlot.h" | |
49 | #include "PythonQtObjectPtr.h" |
|
49 | #include "PythonQtObjectPtr.h" | |
50 | #include <QObject> |
|
50 | #include <QObject> | |
@@ -424,11 +424,11 public: | |||||
424 | //! an enum of another known metaobject (and as last resort, of the Qt namespace) |
|
424 | //! an enum of another known metaobject (and as last resort, of the Qt namespace) | |
425 | bool isEnumType(const QMetaObject* meta, const QByteArray& name); |
|
425 | bool isEnumType(const QMetaObject* meta, const QByteArray& name); | |
426 |
|
426 | |||
427 |
//! helper method that creates a PythonQt |
|
427 | //! helper method that creates a PythonQtClassWrapper object | |
428 |
PythonQt |
|
428 | PythonQtClassWrapper* createNewPythonQtClassWrapper(PythonQtClassInfo* info); | |
429 |
|
429 | |||
430 | //! helper method that creates a PythonQtWrapper object and registers it in the object map |
|
430 | //! helper method that creates a PythonQtInstanceWrapper object and registers it in the object map | |
431 | PythonQtWrapper* createNewPythonQtWrapper(QObject* obj, PythonQtClassInfo* info, void* wrappedPtr = NULL); |
|
431 | PythonQtInstanceWrapper* createNewPythonQtInstanceWrapper(QObject* obj, PythonQtClassInfo* info, void* wrappedPtr = NULL); | |
432 |
|
432 | |||
433 | //! get the class info for a meta object (if available) |
|
433 | //! get the class info for a meta object (if available) | |
434 | PythonQtClassInfo* getClassInfo(const QMetaObject* meta) { return _knownQtClasses.value(meta->className()); } |
|
434 | PythonQtClassInfo* getClassInfo(const QMetaObject* meta) { return _knownQtClasses.value(meta->className()); } | |
@@ -450,10 +450,10 private: | |||||
450 | PythonQtObjectPtr packageByName(const char* name); |
|
450 | PythonQtObjectPtr packageByName(const char* name); | |
451 |
|
451 | |||
452 | //! get the wrapper for a given pointer (and remove a wrapper of an already destroyed qobject) |
|
452 | //! get the wrapper for a given pointer (and remove a wrapper of an already destroyed qobject) | |
453 | PythonQtWrapper* findWrapperAndRemoveUnused(void* obj); |
|
453 | PythonQtInstanceWrapper* findWrapperAndRemoveUnused(void* obj); | |
454 |
|
454 | |||
455 | //! stores pointer to PyObject mapping of wrapped QObjects AND C++ objects |
|
455 | //! stores pointer to PyObject mapping of wrapped QObjects AND C++ objects | |
456 | QHash<void* , PythonQtWrapper *> _wrappedObjects; |
|
456 | QHash<void* , PythonQtInstanceWrapper *> _wrappedObjects; | |
457 |
|
457 | |||
458 | //! stores the meta info of known Qt classes |
|
458 | //! stores the meta info of known Qt classes | |
459 | QHash<QByteArray, PythonQtClassInfo *> _knownQtClasses; |
|
459 | QHash<QByteArray, PythonQtClassInfo *> _knownQtClasses; |
@@ -350,11 +350,9 void PythonQtClassInfo::listDecoratorSlotsFromDecoratorProvider(QStringList& lis | |||||
350 | sigStart += 7 + 1 + strlen(className()); |
|
350 | sigStart += 7 + 1 + strlen(className()); | |
351 | isClassDeco = true; |
|
351 | isClassDeco = true; | |
352 | } else if (qstrncmp(sigStart, "new_", 4)==0) { |
|
352 | } else if (qstrncmp(sigStart, "new_", 4)==0) { | |
353 | sigStart += 4 + 1 + strlen(className()); |
|
353 | continue; | |
354 | isClassDeco = true; |
|
|||
355 | } else if (qstrncmp(sigStart, "delete_", 7)==0) { |
|
354 | } else if (qstrncmp(sigStart, "delete_", 7)==0) { | |
356 | sigStart += 7 + 1 + strlen(className()); |
|
355 | continue; | |
357 | isClassDeco = true; |
|
|||
358 | } |
|
356 | } | |
359 | // find the first '(' |
|
357 | // find the first '(' | |
360 | int offset = findCharOffset(sigStart, '('); |
|
358 | int offset = findCharOffset(sigStart, '('); | |
@@ -375,7 +373,7 QStringList PythonQtClassInfo::memberList(bool metaOnly) | |||||
375 |
|
373 | |||
376 | QStringList l; |
|
374 | QStringList l; | |
377 | QString h; |
|
375 | QString h; | |
378 | if (_wrappedClassName.isEmpty() && _meta) { |
|
376 | if (_wrappedClassName.isEmpty() && _meta && !metaOnly) { | |
379 | int i; |
|
377 | int i; | |
380 | int numProperties = _meta->propertyCount(); |
|
378 | int numProperties = _meta->propertyCount(); | |
381 | for (i = 0; i < numProperties; i++) { |
|
379 | for (i = 0; i < numProperties; i++) { |
@@ -32,14 +32,14 | |||||
32 |
|
32 | |||
33 | //---------------------------------------------------------------------------------- |
|
33 | //---------------------------------------------------------------------------------- | |
34 | /*! |
|
34 | /*! | |
35 |
// \file PythonQt |
|
35 | // \file PythonQtClassWrapper.cpp | |
36 | // \author Florian Link |
|
36 | // \author Florian Link | |
37 | // \author Last changed by $Author: florian $ |
|
37 | // \author Last changed by $Author: florian $ | |
38 | // \date 2006-05 |
|
38 | // \date 2006-05 | |
39 | */ |
|
39 | */ | |
40 | //---------------------------------------------------------------------------------- |
|
40 | //---------------------------------------------------------------------------------- | |
41 |
|
41 | |||
42 |
#include "PythonQt |
|
42 | #include "PythonQtClassWrapper.h" | |
43 | #include <QObject> |
|
43 | #include <QObject> | |
44 |
|
44 | |||
45 | #include "PythonQt.h" |
|
45 | #include "PythonQt.h" | |
@@ -47,29 +47,29 | |||||
47 | #include "PythonQtClassInfo.h" |
|
47 | #include "PythonQtClassInfo.h" | |
48 | #include "PythonQtConversion.h" |
|
48 | #include "PythonQtConversion.h" | |
49 |
|
49 | |||
50 |
static void PythonQt |
|
50 | static void PythonQtClassWrapper_dealloc(PythonQtClassWrapper* self) | |
51 | { |
|
51 | { | |
52 | self->ob_type->tp_free((PyObject*)self); |
|
52 | self->ob_type->tp_free((PyObject*)self); | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 |
static PyObject* PythonQt |
|
55 | static PyObject* PythonQtClassWrapper_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) | |
56 | { |
|
56 | { | |
57 |
PythonQt |
|
57 | PythonQtClassWrapper *self; | |
58 |
|
58 | |||
59 |
self = (PythonQt |
|
59 | self = (PythonQtClassWrapper *)type->tp_alloc(type, 0); | |
60 | if (self != NULL) { |
|
60 | if (self != NULL) { | |
61 | self->_info = NULL; |
|
61 | self->_info = NULL; | |
62 | } |
|
62 | } | |
63 | return (PyObject *)self; |
|
63 | return (PyObject *)self; | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 |
static int PythonQt |
|
66 | static int PythonQtClassWrapper_init(PythonQtClassWrapper * /*self*/, PyObject * /*args*/, PyObject * /*kwds*/) | |
67 | { |
|
67 | { | |
68 | return 0; |
|
68 | return 0; | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 |
PyObject *PythonQt |
|
71 | PyObject *PythonQtClassWrapper_call(PyObject *func, PyObject *args, PyObject *kw) { | |
72 |
PythonQt |
|
72 | PythonQtClassWrapper* wrapper = (PythonQtClassWrapper*)func; | |
73 | PyObject* result = NULL; |
|
73 | PyObject* result = NULL; | |
74 | QString error; |
|
74 | QString error; | |
75 | PyObject* err = NULL; |
|
75 | PyObject* err = NULL; | |
@@ -89,8 +89,8 PyObject *PythonQtMetaObjectWrapper_call(PyObject *func, PyObject *args, PyObjec | |||||
89 | } |
|
89 | } | |
90 | if (result) { |
|
90 | if (result) { | |
91 | // change ownershipflag to be owned by PythonQt |
|
91 | // change ownershipflag to be owned by PythonQt | |
92 | if (result->ob_type == &PythonQtWrapper_Type) { |
|
92 | if (result->ob_type == &PythonQtInstanceWrapper_Type) { | |
93 | ((PythonQtWrapper*)result)->_ownedByPythonQt = true; |
|
93 | ((PythonQtInstanceWrapper*)result)->_ownedByPythonQt = true; | |
94 | } |
|
94 | } | |
95 | } else { |
|
95 | } else { | |
96 | if (!wrapper->_info->constructors()) { |
|
96 | if (!wrapper->_info->constructors()) { | |
@@ -105,38 +105,38 PyObject *PythonQtMetaObjectWrapper_call(PyObject *func, PyObject *args, PyObjec | |||||
105 | return result; |
|
105 | return result; | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 |
static PyObject *PythonQt |
|
108 | static PyObject *PythonQtClassWrapper_classname(PythonQtClassWrapper* type) | |
109 | { |
|
109 | { | |
110 | return PyString_FromString((QString("Meta_") + type->_info->className()).toLatin1().data()); |
|
110 | return PyString_FromString((QString("Meta_") + type->_info->className()).toLatin1().data()); | |
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 |
static PyObject *PythonQt |
|
113 | static PyObject *PythonQtClassWrapper_help(PythonQtClassWrapper* type) | |
114 | { |
|
114 | { | |
115 | return PythonQt::self()->helpCalled(type->_info); |
|
115 | return PythonQt::self()->helpCalled(type->_info); | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 |
|
118 | |||
119 |
static PyMethodDef PythonQt |
|
119 | static PyMethodDef PythonQtClassWrapper_methods[] = { | |
120 |
{"className", (PyCFunction)PythonQt |
|
120 | {"className", (PyCFunction)PythonQtClassWrapper_classname, METH_NOARGS, | |
121 | "Return the classname of the object" |
|
121 | "Return the classname of the object" | |
122 | }, |
|
122 | }, | |
123 |
{"help", (PyCFunction)PythonQt |
|
123 | {"help", (PyCFunction)PythonQtClassWrapper_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, NULL, 0 , NULL} /* Sentinel */ |
|
126 | {NULL, NULL, 0 , NULL} /* Sentinel */ | |
127 | }; |
|
127 | }; | |
128 |
|
128 | |||
129 |
|
129 | |||
130 |
static PyObject *PythonQt |
|
130 | static PyObject *PythonQtClassWrapper_getattro(PyObject *obj,PyObject *name) | |
131 | { |
|
131 | { | |
132 | const char *attributeName; |
|
132 | const char *attributeName; | |
133 |
PythonQt |
|
133 | PythonQtClassWrapper *wrapper = (PythonQtClassWrapper *)obj; | |
134 |
|
134 | |||
135 | if ((attributeName = PyString_AsString(name)) == NULL) { |
|
135 | if ((attributeName = PyString_AsString(name)) == NULL) { | |
136 | return NULL; |
|
136 | return NULL; | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 |
PythonQtMemberInfo member = w |
|
139 | PythonQtMemberInfo member = wrapper->_info->member(attributeName); | |
140 | if (member._type == PythonQtMemberInfo::EnumValue) { |
|
140 | if (member._type == PythonQtMemberInfo::EnumValue) { | |
141 | return PyInt_FromLong(member._enumValue); |
|
141 | return PyInt_FromLong(member._enumValue); | |
142 | } |
|
142 | } | |
@@ -145,14 +145,14 static PyObject *PythonQtMetaObjectWrapper_getattro(PyObject *obj,PyObject *name | |||||
145 | } |
|
145 | } | |
146 |
|
146 | |||
147 | // look for the interal methods (className(), help()) |
|
147 | // look for the interal methods (className(), help()) | |
148 |
PyObject* internalMethod = Py_FindMethod( PythonQt |
|
148 | PyObject* internalMethod = Py_FindMethod( PythonQtClassWrapper_methods, obj, (char*)attributeName); | |
149 | if (internalMethod) { |
|
149 | if (internalMethod) { | |
150 | return internalMethod; |
|
150 | return internalMethod; | |
151 | } |
|
151 | } | |
152 | PyErr_Clear(); |
|
152 | PyErr_Clear(); | |
153 |
|
153 | |||
154 | if (qstrcmp(attributeName, "__dict__")==0) { |
|
154 | if (qstrcmp(attributeName, "__dict__")==0) { | |
155 |
QStringList l = w |
|
155 | QStringList l = wrapper->_info->memberList(true); | |
156 | PyObject* dict = PyDict_New(); |
|
156 | PyObject* dict = PyDict_New(); | |
157 | foreach (QString name, l) { |
|
157 | foreach (QString name, l) { | |
158 | //PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data()); |
|
158 | //PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data()); | |
@@ -162,39 +162,39 static PyObject *PythonQtMetaObjectWrapper_getattro(PyObject *obj,PyObject *name | |||||
162 | return dict; |
|
162 | return dict; | |
163 | } |
|
163 | } | |
164 |
|
164 | |||
165 |
QString error = QString(w |
|
165 | QString error = QString(wrapper->_info->className()) + " has no attribute named '" + QString(attributeName) + "'"; | |
166 | PyErr_SetString(PyExc_AttributeError, error.toLatin1().data()); |
|
166 | PyErr_SetString(PyExc_AttributeError, error.toLatin1().data()); | |
167 | return NULL; |
|
167 | return NULL; | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 |
static PyObject * PythonQt |
|
170 | static PyObject * PythonQtClassWrapper_repr(PyObject * obj) | |
171 | { |
|
171 | { | |
172 |
PythonQt |
|
172 | PythonQtClassWrapper* wrapper = (PythonQtClassWrapper*)obj; | |
173 |
if (w |
|
173 | if (wrapper->_info->isCPPWrapper()) { | |
174 |
const QMetaObject* meta = w |
|
174 | const QMetaObject* meta = wrapper->_info->metaObject(); | |
175 | if (!meta) { |
|
175 | if (!meta) { | |
176 |
QObject* decorator = w |
|
176 | QObject* decorator = wrapper->_info->decorator(); | |
177 | if (decorator) { |
|
177 | if (decorator) { | |
178 | meta = decorator->metaObject(); |
|
178 | meta = decorator->metaObject(); | |
179 | } |
|
179 | } | |
180 | } |
|
180 | } | |
181 | if (meta) { |
|
181 | if (meta) { | |
182 |
return PyString_FromFormat("%s Class (C++ wrapped by %s)", w |
|
182 | return PyString_FromFormat("%s Class (C++ wrapped by %s)", wrapper->_info->className(), meta->className()); | |
183 | } else { |
|
183 | } else { | |
184 |
return PyString_FromFormat("%s Class (C++ unwrapped)", w |
|
184 | return PyString_FromFormat("%s Class (C++ unwrapped)", wrapper->_info->className()); | |
185 | } |
|
185 | } | |
186 | } else { |
|
186 | } else { | |
187 |
return PyString_FromFormat("%s Class", w |
|
187 | return PyString_FromFormat("%s Class", wrapper->_info->className()); | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 |
static int PythonQt |
|
191 | static int PythonQtClassWrapper_compare(PyObject * obj1, PyObject * obj2) | |
192 | { |
|
192 | { | |
193 |
if (obj1->ob_type == &PythonQt |
|
193 | if (obj1->ob_type == &PythonQtClassWrapper_Type && | |
194 |
obj2->ob_type == &PythonQt |
|
194 | obj2->ob_type == &PythonQtClassWrapper_Type) { | |
195 |
|
195 | |||
196 |
PythonQt |
|
196 | PythonQtClassWrapper* w1 = (PythonQtClassWrapper*)obj1; | |
197 |
PythonQt |
|
197 | PythonQtClassWrapper* w2 = (PythonQtClassWrapper*)obj2; | |
198 | if (w1->_info == w2->_info) { |
|
198 | if (w1->_info == w2->_info) { | |
199 | return 0; |
|
199 | return 0; | |
200 | } else { |
|
200 | } else { | |
@@ -205,34 +205,34 static int PythonQtMetaObjectWrapper_compare(PyObject * obj1, PyObject * obj2) | |||||
205 | } |
|
205 | } | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 |
static long PythonQt |
|
208 | static long PythonQtClassWrapper_hash(PythonQtClassWrapper *obj) | |
209 | { |
|
209 | { | |
210 | return reinterpret_cast<long>(obj->_info); |
|
210 | return reinterpret_cast<long>(obj->_info); | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 |
PyTypeObject PythonQt |
|
213 | PyTypeObject PythonQtClassWrapper_Type = { | |
214 | PyObject_HEAD_INIT(NULL) |
|
214 | PyObject_HEAD_INIT(NULL) | |
215 | 0, /*ob_size*/ |
|
215 | 0, /*ob_size*/ | |
216 |
"PythonQt.PythonQt |
|
216 | "PythonQt.PythonQtClassWrapper", /*tp_name*/ | |
217 |
sizeof(PythonQt |
|
217 | sizeof(PythonQtClassWrapper), /*tp_basicsize*/ | |
218 | 0, /*tp_itemsize*/ |
|
218 | 0, /*tp_itemsize*/ | |
219 |
(destructor)PythonQt |
|
219 | (destructor)PythonQtClassWrapper_dealloc, /*tp_dealloc*/ | |
220 | 0, /*tp_print*/ |
|
220 | 0, /*tp_print*/ | |
221 | 0, /*tp_getattr*/ |
|
221 | 0, /*tp_getattr*/ | |
222 | 0, /*tp_setattr*/ |
|
222 | 0, /*tp_setattr*/ | |
223 |
PythonQt |
|
223 | PythonQtClassWrapper_compare, /*tp_compare*/ | |
224 |
PythonQt |
|
224 | PythonQtClassWrapper_repr, /*tp_repr*/ | |
225 | 0, /*tp_as_number*/ |
|
225 | 0, /*tp_as_number*/ | |
226 | 0, /*tp_as_sequence*/ |
|
226 | 0, /*tp_as_sequence*/ | |
227 | 0, /*tp_as_mapping*/ |
|
227 | 0, /*tp_as_mapping*/ | |
228 |
(hashfunc)PythonQt |
|
228 | (hashfunc)PythonQtClassWrapper_hash, /*tp_hash */ | |
229 |
PythonQt |
|
229 | PythonQtClassWrapper_call, /*tp_call*/ | |
230 | 0, /*tp_str*/ |
|
230 | 0, /*tp_str*/ | |
231 |
PythonQt |
|
231 | PythonQtClassWrapper_getattro, /*tp_getattro*/ | |
232 | 0, /*tp_setattro*/ |
|
232 | 0, /*tp_setattro*/ | |
233 | 0, /*tp_as_buffer*/ |
|
233 | 0, /*tp_as_buffer*/ | |
234 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ |
|
234 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ | |
235 |
"PythonQt |
|
235 | "PythonQtClassWrapper object", /* tp_doc */ | |
236 | 0, /* tp_traverse */ |
|
236 | 0, /* tp_traverse */ | |
237 | 0, /* tp_clear */ |
|
237 | 0, /* tp_clear */ | |
238 | 0, /* tp_richcompare */ |
|
238 | 0, /* tp_richcompare */ | |
@@ -247,9 +247,9 PyTypeObject PythonQtMetaObjectWrapper_Type = { | |||||
247 | 0, /* tp_descr_get */ |
|
247 | 0, /* tp_descr_get */ | |
248 | 0, /* tp_descr_set */ |
|
248 | 0, /* tp_descr_set */ | |
249 | 0, /* tp_dictoffset */ |
|
249 | 0, /* tp_dictoffset */ | |
250 |
(initproc)PythonQt |
|
250 | (initproc)PythonQtClassWrapper_init, /* tp_init */ | |
251 | 0, /* tp_alloc */ |
|
251 | 0, /* tp_alloc */ | |
252 |
PythonQt |
|
252 | PythonQtClassWrapper_new, /* tp_new */ | |
253 | }; |
|
253 | }; | |
254 |
|
254 | |||
255 | //------------------------------------------------------- |
|
255 | //------------------------------------------------------- |
@@ -35,7 +35,7 | |||||
35 |
|
35 | |||
36 | //---------------------------------------------------------------------------------- |
|
36 | //---------------------------------------------------------------------------------- | |
37 | /*! |
|
37 | /*! | |
38 |
// \file PythonQt |
|
38 | // \file PythonQtClassWrapper.h | |
39 | // \author Florian Link |
|
39 | // \author Florian Link | |
40 | // \author Last changed by $Author: florian $ |
|
40 | // \author Last changed by $Author: florian $ | |
41 | // \date 2006-05 |
|
41 | // \date 2006-05 | |
@@ -54,7 +54,7 class PythonQtClassInfo; | |||||
54 | class QObject; |
|
54 | class QObject; | |
55 | struct QMetaObject; |
|
55 | struct QMetaObject; | |
56 |
|
56 | |||
57 |
extern PyTypeObject PythonQt |
|
57 | extern PyTypeObject PythonQtClassWrapper_Type; | |
58 |
|
58 | |||
59 | //--------------------------------------------------------------- |
|
59 | //--------------------------------------------------------------- | |
60 | //! a Python wrapper object for Qt meta objects |
|
60 | //! a Python wrapper object for Qt meta objects | |
@@ -64,7 +64,7 typedef struct { | |||||
64 | //! the class information (which contains the meta object as well) |
|
64 | //! the class information (which contains the meta object as well) | |
65 | PythonQtClassInfo* _info; |
|
65 | PythonQtClassInfo* _info; | |
66 |
|
66 | |||
67 |
} PythonQt |
|
67 | } PythonQtClassWrapper; | |
68 |
|
68 | |||
69 | //--------------------------------------------------------------- |
|
69 | //--------------------------------------------------------------- | |
70 | // an abstact class for handling construction of objects |
|
70 | // an abstact class for handling construction of objects |
@@ -159,7 +159,7 PyObject* PythonQtConv::ConvertQtValueToPythonInternal(int type, const void* dat | |||||
159 | // if the type is known, we can construct it via QMetaType::construct |
|
159 | // if the type is known, we can construct it via QMetaType::construct | |
160 | void* newCPPObject = QMetaType::construct(type, data); |
|
160 | void* newCPPObject = QMetaType::construct(type, data); | |
161 | // XXX this could be optimized by using metatypeid directly |
|
161 | // XXX this could be optimized by using metatypeid directly | |
162 | PythonQtWrapper* wrap = (PythonQtWrapper*)PythonQt::priv()->wrapPtr(newCPPObject, QMetaType::typeName(type)); |
|
162 | PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(newCPPObject, QMetaType::typeName(type)); | |
163 | wrap->_ownedByPythonQt = true; |
|
163 | wrap->_ownedByPythonQt = true; | |
164 | wrap->_useQMetaTypeDestroy = true; |
|
164 | wrap->_useQMetaTypeDestroy = true; | |
165 | return (PyObject*)wrap; |
|
165 | return (PyObject*)wrap; | |
@@ -224,12 +224,12 return Py_None; | |||||
224 | { |
|
224 | { | |
225 | bool ok; |
|
225 | bool ok; | |
226 | void* ptr = NULL; |
|
226 | void* ptr = NULL; | |
227 | if (obj->ob_type == &PythonQtWrapper_Type && info.typeId != PythonQtMethodInfo::Variant) { |
|
227 | if (obj->ob_type == &PythonQtInstanceWrapper_Type && info.typeId != PythonQtMethodInfo::Variant) { | |
228 | // if we have a Qt wrapper object and if we do not need a QVariant, we do the following: |
|
228 | // if we have a Qt wrapper object and if we do not need a QVariant, we do the following: | |
229 | // (the Variant case is handled below in a switch) |
|
229 | // (the Variant case is handled below in a switch) | |
230 |
|
230 | |||
231 | // a C++ wrapper (can be passed as pointer or reference) |
|
231 | // a C++ wrapper (can be passed as pointer or reference) | |
232 | PythonQtWrapper* wrap = (PythonQtWrapper*)obj; |
|
232 | PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)obj; | |
233 | if (wrap->_info->inherits(info.name)) { |
|
233 | if (wrap->_info->inherits(info.name)) { | |
234 | void* object; |
|
234 | void* object; | |
235 | if (wrap->_info->isCPPWrapper()) { |
|
235 | if (wrap->_info->isCPPWrapper()) { | |
@@ -690,8 +690,8 QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) | |||||
690 | type = QVariant::Double; |
|
690 | type = QVariant::Double; | |
691 | } else if (val == Py_False || val == Py_True) { |
|
691 | } else if (val == Py_False || val == Py_True) { | |
692 | type = QVariant::Bool; |
|
692 | type = QVariant::Bool; | |
693 | } else if (val->ob_type == &PythonQtWrapper_Type) { |
|
693 | } else if (val->ob_type == &PythonQtInstanceWrapper_Type) { | |
694 | PythonQtWrapper* wrap = (PythonQtWrapper*)val; |
|
694 | PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)val; | |
695 | // c++ wrapper, check if the class names of the c++ objects match |
|
695 | // c++ wrapper, check if the class names of the c++ objects match | |
696 | if (wrap->_info->isCPPWrapper()) { |
|
696 | if (wrap->_info->isCPPWrapper()) { | |
697 | if (wrap->_info->metaTypeId()>0) { |
|
697 | if (wrap->_info->metaTypeId()>0) { | |
@@ -849,8 +849,8 QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) | |||||
849 | break; |
|
849 | break; | |
850 |
|
850 | |||
851 | default: |
|
851 | default: | |
852 | if (val->ob_type == &PythonQtWrapper_Type) { |
|
852 | if (val->ob_type == &PythonQtInstanceWrapper_Type) { | |
853 | PythonQtWrapper* wrap = (PythonQtWrapper*)val; |
|
853 | PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)val; | |
854 | if (wrap->_info->isCPPWrapper() && wrap->_info->metaTypeId() == type) { |
|
854 | if (wrap->_info->isCPPWrapper() && wrap->_info->metaTypeId() == type) { | |
855 | // construct a new variant from the C++ object if it has the same meta type |
|
855 | // construct a new variant from the C++ object if it has the same meta type | |
856 | v = QVariant(type, wrap->_wrappedPtr); |
|
856 | v = QVariant(type, wrap->_wrappedPtr); | |
@@ -956,8 +956,8 bool PythonQtConv::ConvertPythonListToQListOfPointerType(PyObject* obj, QList<vo | |||||
956 | PyObject* value; |
|
956 | PyObject* value; | |
957 | for (int i = 0;i<count;i++) { |
|
957 | for (int i = 0;i<count;i++) { | |
958 | value = PySequence_GetItem(obj,i); |
|
958 | value = PySequence_GetItem(obj,i); | |
959 | if (value->ob_type == &PythonQtWrapper_Type) { |
|
959 | if (value->ob_type == &PythonQtInstanceWrapper_Type) { | |
960 | PythonQtWrapper* wrap = (PythonQtWrapper*)value; |
|
960 | PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)value; | |
961 | // both QObjects and CPP wrappers support inherits, so we use that to check of we match |
|
961 | // both QObjects and CPP wrappers support inherits, so we use that to check of we match | |
962 | if (wrap->_info->inherits(type)) { |
|
962 | if (wrap->_info->inherits(type)) { | |
963 | if (wrap->_info->isCPPWrapper()) { |
|
963 | if (wrap->_info->isCPPWrapper()) { |
@@ -32,21 +32,21 | |||||
32 |
|
32 | |||
33 | //---------------------------------------------------------------------------------- |
|
33 | //---------------------------------------------------------------------------------- | |
34 | /*! |
|
34 | /*! | |
35 | // \file PythonQtWrapper.cpp |
|
35 | // \file PythonQtInstanceWrapper.cpp | |
36 | // \author Florian Link |
|
36 | // \author Florian Link | |
37 | // \author Last changed by $Author: florian $ |
|
37 | // \author Last changed by $Author: florian $ | |
38 | // \date 2006-05 |
|
38 | // \date 2006-05 | |
39 | */ |
|
39 | */ | |
40 | //---------------------------------------------------------------------------------- |
|
40 | //---------------------------------------------------------------------------------- | |
41 |
|
41 | |||
42 | #include "PythonQtWrapper.h" |
|
42 | #include "PythonQtInstanceWrapper.h" | |
43 | #include <QObject> |
|
43 | #include <QObject> | |
44 | #include "PythonQt.h" |
|
44 | #include "PythonQt.h" | |
45 | #include "PythonQtSlot.h" |
|
45 | #include "PythonQtSlot.h" | |
46 | #include "PythonQtClassInfo.h" |
|
46 | #include "PythonQtClassInfo.h" | |
47 | #include "PythonQtConversion.h" |
|
47 | #include "PythonQtConversion.h" | |
48 |
|
48 | |||
49 | static void PythonQtWrapper_deleteObject(PythonQtWrapper* self, bool force = false) { |
|
49 | static void PythonQtInstanceWrapper_deleteObject(PythonQtInstanceWrapper* self, bool force = false) { | |
50 |
|
50 | |||
51 | // is this a C++ wrapper? |
|
51 | // is this a C++ wrapper? | |
52 | if (self->_wrappedPtr) { |
|
52 | if (self->_wrappedPtr) { | |
@@ -100,18 +100,18 static void PythonQtWrapper_deleteObject(PythonQtWrapper* self, bool force = fal | |||||
100 | self->_obj = NULL; |
|
100 | self->_obj = NULL; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | static void PythonQtWrapper_dealloc(PythonQtWrapper* self) |
|
103 | static void PythonQtInstanceWrapper_dealloc(PythonQtInstanceWrapper* self) | |
104 | { |
|
104 | { | |
105 | PythonQtWrapper_deleteObject(self); |
|
105 | PythonQtInstanceWrapper_deleteObject(self); | |
106 | self->_obj.~QPointer<QObject>(); |
|
106 | self->_obj.~QPointer<QObject>(); | |
107 | self->ob_type->tp_free((PyObject*)self); |
|
107 | self->ob_type->tp_free((PyObject*)self); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | static PyObject* PythonQtWrapper_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) |
|
110 | static PyObject* PythonQtInstanceWrapper_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) | |
111 | { |
|
111 | { | |
112 | PythonQtWrapper *self; |
|
112 | PythonQtInstanceWrapper *self; | |
113 |
|
113 | |||
114 | self = (PythonQtWrapper *)type->tp_alloc(type, 0); |
|
114 | self = (PythonQtInstanceWrapper *)type->tp_alloc(type, 0); | |
115 | if (self != NULL) { |
|
115 | if (self != NULL) { | |
116 | self->_info = NULL; |
|
116 | self->_info = NULL; | |
117 | new (&self->_obj) QPointer<QObject>(); |
|
117 | new (&self->_obj) QPointer<QObject>(); | |
@@ -122,54 +122,54 static PyObject* PythonQtWrapper_new(PyTypeObject *type, PyObject * /*args*/, Py | |||||
122 | return (PyObject *)self; |
|
122 | return (PyObject *)self; | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | static int PythonQtWrapper_init(PythonQtWrapper * /*self*/, PyObject * /*args*/, PyObject * /*kwds*/) |
|
125 | static int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper * /*self*/, PyObject * /*args*/, PyObject * /*kwds*/) | |
126 | { |
|
126 | { | |
127 | return 0; |
|
127 | return 0; | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | static PyObject *PythonQtWrapper_classname(PythonQtWrapper* type) |
|
130 | static PyObject *PythonQtInstanceWrapper_classname(PythonQtInstanceWrapper* type) | |
131 | { |
|
131 | { | |
132 | return PyString_FromString(type->_info->className()); |
|
132 | return PyString_FromString(type->_info->className()); | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | static PyObject *PythonQtWrapper_help(PythonQtWrapper* type) |
|
135 | static PyObject *PythonQtInstanceWrapper_help(PythonQtInstanceWrapper* type) | |
136 | { |
|
136 | { | |
137 | return PythonQt::self()->helpCalled(type->_info); |
|
137 | return PythonQt::self()->helpCalled(type->_info); | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | static PyObject *PythonQtWrapper_delete(PythonQtWrapper * self) |
|
140 | static PyObject *PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper * self) | |
141 | { |
|
141 | { | |
142 | PythonQtWrapper_deleteObject(self, true); |
|
142 | PythonQtInstanceWrapper_deleteObject(self, true); | |
143 | Py_INCREF(Py_None); |
|
143 | Py_INCREF(Py_None); | |
144 | return Py_None; |
|
144 | return Py_None; | |
145 | } |
|
145 | } | |
146 |
|
146 | |||
147 |
|
147 | |||
148 | static PyMethodDef PythonQtWrapper_methods[] = { |
|
148 | static PyMethodDef PythonQtInstanceWrapper_methods[] = { | |
149 | {"className", (PyCFunction)PythonQtWrapper_classname, METH_NOARGS, |
|
149 | {"className", (PyCFunction)PythonQtInstanceWrapper_classname, METH_NOARGS, | |
150 | "Return the classname of the object" |
|
150 | "Return the classname of the object" | |
151 | }, |
|
151 | }, | |
152 | {"help", (PyCFunction)PythonQtWrapper_help, METH_NOARGS, |
|
152 | {"help", (PyCFunction)PythonQtInstanceWrapper_help, METH_NOARGS, | |
153 | "Shows the help of available methods for this class" |
|
153 | "Shows the help of available methods for this class" | |
154 | }, |
|
154 | }, | |
155 | {"delete", (PyCFunction)PythonQtWrapper_delete, METH_NOARGS, |
|
155 | {"delete", (PyCFunction)PythonQtInstanceWrapper_delete, METH_NOARGS, | |
156 | "Deletes the C++ object (at your own risk, my friend!)" |
|
156 | "Deletes the C++ object (at your own risk, my friend!)" | |
157 | }, |
|
157 | }, | |
158 | {NULL, NULL, 0, NULL} /* Sentinel */ |
|
158 | {NULL, NULL, 0, NULL} /* Sentinel */ | |
159 | }; |
|
159 | }; | |
160 |
|
160 | |||
161 |
|
161 | |||
162 | static PyObject *PythonQtWrapper_getattro(PyObject *obj,PyObject *name) |
|
162 | static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) | |
163 | { |
|
163 | { | |
164 | const char *attributeName; |
|
164 | const char *attributeName; | |
165 |
PythonQtWrapper *w |
|
165 | PythonQtInstanceWrapper *wrapper = (PythonQtInstanceWrapper *)obj; | |
166 |
|
166 | |||
167 | if ((attributeName = PyString_AsString(name)) == NULL) { |
|
167 | if ((attributeName = PyString_AsString(name)) == NULL) { | |
168 | return NULL; |
|
168 | return NULL; | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 |
if (!w |
|
171 | if (!wrapper->_obj && !wrapper->_wrappedPtr) { | |
172 |
QString error = QString("Trying to read attribute '") + attributeName + "' from a destroyed " + w |
|
172 | QString error = QString("Trying to read attribute '") + attributeName + "' from a destroyed " + wrapper->_info->className() + " object"; | |
173 | PyErr_SetString(PyExc_ValueError, error.toLatin1().data()); |
|
173 | PyErr_SetString(PyExc_ValueError, error.toLatin1().data()); | |
174 | return NULL; |
|
174 | return NULL; | |
175 | } |
|
175 | } | |
@@ -178,11 +178,11 static PyObject *PythonQtWrapper_getattro(PyObject *obj,PyObject *name) | |||||
178 |
|
178 | |||
179 | // TODO: dynamic properties are missing |
|
179 | // TODO: dynamic properties are missing | |
180 |
|
180 | |||
181 |
PythonQtMemberInfo member = w |
|
181 | PythonQtMemberInfo member = wrapper->_info->member(attributeName); | |
182 | switch (member._type) { |
|
182 | switch (member._type) { | |
183 | case PythonQtMemberInfo::Property: |
|
183 | case PythonQtMemberInfo::Property: | |
184 |
if (w |
|
184 | if (wrapper->_obj) { | |
185 |
return PythonQtConv::QVariantToPyObject(member._property.read(w |
|
185 | return PythonQtConv::QVariantToPyObject(member._property.read(wrapper->_obj)); | |
186 | } |
|
186 | } | |
187 | break; |
|
187 | break; | |
188 | case PythonQtMemberInfo::Slot: |
|
188 | case PythonQtMemberInfo::Slot: | |
@@ -197,15 +197,15 static PyObject *PythonQtWrapper_getattro(PyObject *obj,PyObject *name) | |||||
197 | } |
|
197 | } | |
198 |
|
198 | |||
199 | // look for the interal methods (className(), help()) |
|
199 | // look for the interal methods (className(), help()) | |
200 | PyObject* internalMethod = Py_FindMethod( PythonQtWrapper_methods, obj, (char*)attributeName); |
|
200 | PyObject* internalMethod = Py_FindMethod( PythonQtInstanceWrapper_methods, obj, (char*)attributeName); | |
201 | if (internalMethod) { |
|
201 | if (internalMethod) { | |
202 | return internalMethod; |
|
202 | return internalMethod; | |
203 | } |
|
203 | } | |
204 | PyErr_Clear(); |
|
204 | PyErr_Clear(); | |
205 |
|
205 | |||
206 |
if (w |
|
206 | if (wrapper->_obj) { | |
207 | // look for a child |
|
207 | // look for a child | |
208 |
QObjectList children = w |
|
208 | QObjectList children = wrapper->_obj->children(); | |
209 | for (int i = 0; i < children.count(); i++) { |
|
209 | for (int i = 0; i < children.count(); i++) { | |
210 | QObject *child = children.at(i); |
|
210 | QObject *child = children.at(i); | |
211 | if (child->objectName() == attributeName) { |
|
211 | if (child->objectName() == attributeName) { | |
@@ -215,7 +215,7 static PyObject *PythonQtWrapper_getattro(PyObject *obj,PyObject *name) | |||||
215 | } |
|
215 | } | |
216 |
|
216 | |||
217 | if (qstrcmp(attributeName, "__dict__")==0) { |
|
217 | if (qstrcmp(attributeName, "__dict__")==0) { | |
218 |
QStringList l = w |
|
218 | QStringList l = wrapper->_info->memberList(false); | |
219 | PyObject* dict = PyDict_New(); |
|
219 | PyObject* dict = PyDict_New(); | |
220 | foreach (QString name, l) { |
|
220 | foreach (QString name, l) { | |
221 | //PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data()); |
|
221 | //PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data()); | |
@@ -227,27 +227,27 static PyObject *PythonQtWrapper_getattro(PyObject *obj,PyObject *name) | |||||
227 | } |
|
227 | } | |
228 |
|
228 | |||
229 |
|
229 | |||
230 |
QString error = QString(w |
|
230 | QString error = QString(wrapper->_info->className()) + " has no attribute named '" + QString(attributeName) + "'"; | |
231 | PyErr_SetString(PyExc_AttributeError, error.toLatin1().data()); |
|
231 | PyErr_SetString(PyExc_AttributeError, error.toLatin1().data()); | |
232 | return NULL; |
|
232 | return NULL; | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | static int PythonQtWrapper_setattro(PyObject *obj,PyObject *name,PyObject *value) |
|
235 | static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObject *value) | |
236 | { |
|
236 | { | |
237 | QString error; |
|
237 | QString error; | |
238 | char *attributeName; |
|
238 | char *attributeName; | |
239 |
PythonQtWrapper *w |
|
239 | PythonQtInstanceWrapper *wrapper = (PythonQtInstanceWrapper *)obj; | |
240 |
|
240 | |||
241 | if ((attributeName = PyString_AsString(name)) == NULL) |
|
241 | if ((attributeName = PyString_AsString(name)) == NULL) | |
242 | return -1; |
|
242 | return -1; | |
243 |
|
243 | |||
244 |
if (!w |
|
244 | if (!wrapper->_obj) { | |
245 |
error = QString("Trying to set attribute '") + attributeName + "' on a destroyed " + w |
|
245 | error = QString("Trying to set attribute '") + attributeName + "' on a destroyed " + wrapper->_info->className() + " object"; | |
246 | PyErr_SetString(PyExc_AttributeError, error.toLatin1().data()); |
|
246 | PyErr_SetString(PyExc_AttributeError, error.toLatin1().data()); | |
247 | return -1; |
|
247 | return -1; | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 |
PythonQtMemberInfo member = w |
|
250 | PythonQtMemberInfo member = wrapper->_info->member(attributeName); | |
251 | if (member._type == PythonQtMemberInfo::Property) { |
|
251 | if (member._type == PythonQtMemberInfo::Property) { | |
252 | QMetaProperty prop = member._property; |
|
252 | QMetaProperty prop = member._property; | |
253 | if (prop.isWritable()) { |
|
253 | if (prop.isWritable()) { | |
@@ -261,7 +261,7 static int PythonQtWrapper_setattro(PyObject *obj,PyObject *name,PyObject *value | |||||
261 | } |
|
261 | } | |
262 | bool success = false; |
|
262 | bool success = false; | |
263 | if (v.isValid()) { |
|
263 | if (v.isValid()) { | |
264 |
success = prop.write(w |
|
264 | success = prop.write(wrapper->_obj, v); | |
265 | } |
|
265 | } | |
266 | if (success) { |
|
266 | if (success) { | |
267 | return 0; |
|
267 | return 0; | |
@@ -271,13 +271,13 static int PythonQtWrapper_setattro(PyObject *obj,PyObject *name,PyObject *value | |||||
271 | + QString(value->ob_type->tp_name) + " (" + PythonQtConv::PyObjGetRepresentation(value) + ")"; |
|
271 | + QString(value->ob_type->tp_name) + " (" + PythonQtConv::PyObjGetRepresentation(value) + ")"; | |
272 | } |
|
272 | } | |
273 | } else { |
|
273 | } else { | |
274 |
error = QString("Property '") + attributeName + "' of " + w |
|
274 | error = QString("Property '") + attributeName + "' of " + wrapper->_info->className() + " object is not writable"; | |
275 | } |
|
275 | } | |
276 | } else { |
|
276 | } else { | |
277 | if (member._type == PythonQtMemberInfo::Slot) { |
|
277 | if (member._type == PythonQtMemberInfo::Slot) { | |
278 |
error = QString("Slot '") + attributeName + "' can not be overwritten on " + w |
|
278 | error = QString("Slot '") + attributeName + "' can not be overwritten on " + wrapper->_info->className() + " object"; | |
279 | } else if (member._type == PythonQtMemberInfo::EnumValue) { |
|
279 | } else if (member._type == PythonQtMemberInfo::EnumValue) { | |
280 |
error = QString("EnumValue '") + attributeName + "' can not be overwritten on " + w |
|
280 | error = QString("EnumValue '") + attributeName + "' can not be overwritten on " + wrapper->_info->className() + " object"; | |
281 | } |
|
281 | } | |
282 | } |
|
282 | } | |
283 |
|
283 | |||
@@ -285,51 +285,51 static int PythonQtWrapper_setattro(PyObject *obj,PyObject *name,PyObject *value | |||||
285 | return -1; |
|
285 | return -1; | |
286 | } |
|
286 | } | |
287 |
|
287 | |||
288 | static PyObject * PythonQtWrapper_str(PyObject * obj) |
|
288 | static PyObject * PythonQtInstanceWrapper_str(PyObject * obj) | |
289 | { |
|
289 | { | |
290 |
PythonQtWrapper* w |
|
290 | PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)obj; | |
291 |
QObject *qobj = w |
|
291 | QObject *qobj = wrapper->_obj; | |
292 |
if (w |
|
292 | if (wrapper->_wrappedPtr) { | |
293 |
QString str = PythonQtConv::CPPObjectToString(w |
|
293 | QString str = PythonQtConv::CPPObjectToString(wrapper->_info->metaTypeId(), wrapper->_wrappedPtr); | |
294 | if (!str.isEmpty()) { |
|
294 | if (!str.isEmpty()) { | |
295 | return PyString_FromFormat("%s", str.toLatin1().constData()); |
|
295 | return PyString_FromFormat("%s", str.toLatin1().constData()); | |
296 | } else |
|
296 | } else | |
297 |
if (w |
|
297 | if (wrapper->_obj) { | |
298 |
return PyString_FromFormat("%s (C++ Object %p wrapped by %s %p))", w |
|
298 | return PyString_FromFormat("%s (C++ Object %p wrapped by %s %p))", wrapper->_info->className(), wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj); | |
299 | } else { |
|
299 | } else { | |
300 |
return PyString_FromFormat("%s (C++ Object %p)", w |
|
300 | return PyString_FromFormat("%s (C++ Object %p)", wrapper->_info->className(), wrapper->_wrappedPtr); | |
301 | } |
|
301 | } | |
302 | } else { |
|
302 | } else { | |
303 |
return PyString_FromFormat("%s (QObject %p)", w |
|
303 | return PyString_FromFormat("%s (QObject %p)", wrapper->_info->className(), qobj); | |
304 | } |
|
304 | } | |
305 | } |
|
305 | } | |
306 |
|
306 | |||
307 | static PyObject * PythonQtWrapper_repr(PyObject * obj) |
|
307 | static PyObject * PythonQtInstanceWrapper_repr(PyObject * obj) | |
308 | { |
|
308 | { | |
309 |
PythonQtWrapper* w |
|
309 | PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)obj; | |
310 |
QObject *qobj = w |
|
310 | QObject *qobj = wrapper->_obj; | |
311 |
if (w |
|
311 | if (wrapper->_wrappedPtr) { | |
312 |
QString str = PythonQtConv::CPPObjectToString(w |
|
312 | QString str = PythonQtConv::CPPObjectToString(wrapper->_info->metaTypeId(), wrapper->_wrappedPtr); | |
313 | if (!str.isEmpty()) { |
|
313 | if (!str.isEmpty()) { | |
314 |
return PyString_FromFormat("%s(%s, %p)", QMetaType::typeName(w |
|
314 | return PyString_FromFormat("%s(%s, %p)", QMetaType::typeName(wrapper->_info->metaTypeId()), str.toLatin1().constData(), wrapper->_wrappedPtr); | |
315 | } else |
|
315 | } else | |
316 |
if (w |
|
316 | if (wrapper->_obj) { | |
317 |
return PyString_FromFormat("%s (C++ Object %p wrapped by %s %p))", w |
|
317 | return PyString_FromFormat("%s (C++ Object %p wrapped by %s %p))", wrapper->_info->className(), wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj); | |
318 | } else { |
|
318 | } else { | |
319 |
return PyString_FromFormat("%s (C++ Object %p)", w |
|
319 | return PyString_FromFormat("%s (C++ Object %p)", wrapper->_info->className(), wrapper->_wrappedPtr); | |
320 | } |
|
320 | } | |
321 | } else { |
|
321 | } else { | |
322 |
return PyString_FromFormat("%s (QObject %p)", w |
|
322 | return PyString_FromFormat("%s (QObject %p)", wrapper->_info->className(), qobj); | |
323 | } |
|
323 | } | |
324 | } |
|
324 | } | |
325 |
|
325 | |||
326 | static int PythonQtWrapper_compare(PyObject * obj1, PyObject * obj2) |
|
326 | static int PythonQtInstanceWrapper_compare(PyObject * obj1, PyObject * obj2) | |
327 | { |
|
327 | { | |
328 | if (obj1->ob_type == &PythonQtWrapper_Type && |
|
328 | if (obj1->ob_type == &PythonQtInstanceWrapper_Type && | |
329 | obj2->ob_type == &PythonQtWrapper_Type) { |
|
329 | obj2->ob_type == &PythonQtInstanceWrapper_Type) { | |
330 |
|
330 | |||
331 | PythonQtWrapper* w1 = (PythonQtWrapper*)obj1; |
|
331 | PythonQtInstanceWrapper* w1 = (PythonQtInstanceWrapper*)obj1; | |
332 | PythonQtWrapper* w2 = (PythonQtWrapper*)obj2; |
|
332 | PythonQtInstanceWrapper* w2 = (PythonQtInstanceWrapper*)obj2; | |
333 | // check pointers directly first: |
|
333 | // check pointers directly first: | |
334 | if (w1->_wrappedPtr != NULL) { |
|
334 | if (w1->_wrappedPtr != NULL) { | |
335 | if (w1->_wrappedPtr == w2->_wrappedPtr) { |
|
335 | if (w1->_wrappedPtr == w2->_wrappedPtr) { | |
@@ -378,14 +378,14 static int PythonQtWrapper_compare(PyObject * obj1, PyObject * obj2) | |||||
378 | return -1; |
|
378 | return -1; | |
379 | } |
|
379 | } | |
380 |
|
380 | |||
381 | static int PythonQtWrapper_nonzero(PyObject *obj) |
|
381 | static int PythonQtInstanceWrapper_nonzero(PyObject *obj) | |
382 | { |
|
382 | { | |
383 |
PythonQtWrapper* w |
|
383 | PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)obj; | |
384 |
return (w |
|
384 | return (wrapper->_wrappedPtr == NULL && wrapper->_obj == NULL)?0:1; | |
385 | } |
|
385 | } | |
386 |
|
386 | |||
387 |
|
387 | |||
388 | static long PythonQtWrapper_hash(PythonQtWrapper *obj) |
|
388 | static long PythonQtInstanceWrapper_hash(PythonQtInstanceWrapper *obj) | |
389 | { |
|
389 | { | |
390 | if (obj->_wrappedPtr != NULL) { |
|
390 | if (obj->_wrappedPtr != NULL) { | |
391 | return reinterpret_cast<long>(obj->_wrappedPtr); |
|
391 | return reinterpret_cast<long>(obj->_wrappedPtr); | |
@@ -398,7 +398,7 static long PythonQtWrapper_hash(PythonQtWrapper *obj) | |||||
398 |
|
398 | |||
399 |
|
399 | |||
400 | // we override nb_nonzero, so that one can do 'if' expressions to test for a NULL ptr |
|
400 | // we override nb_nonzero, so that one can do 'if' expressions to test for a NULL ptr | |
401 | static PyNumberMethods PythonQtWrapper_as_number = { |
|
401 | static PyNumberMethods PythonQtInstanceWrapper_as_number = { | |
402 | 0, /* nb_add */ |
|
402 | 0, /* nb_add */ | |
403 | 0, /* nb_subtract */ |
|
403 | 0, /* nb_subtract */ | |
404 | 0, /* nb_multiply */ |
|
404 | 0, /* nb_multiply */ | |
@@ -409,7 +409,7 static PyNumberMethods PythonQtWrapper_as_number = { | |||||
409 | 0, /* nb_negative */ |
|
409 | 0, /* nb_negative */ | |
410 | 0, /* nb_positive */ |
|
410 | 0, /* nb_positive */ | |
411 | 0, /* nb_absolute */ |
|
411 | 0, /* nb_absolute */ | |
412 | PythonQtWrapper_nonzero, /* nb_nonzero */ |
|
412 | PythonQtInstanceWrapper_nonzero, /* nb_nonzero */ | |
413 | 0, /* nb_invert */ |
|
413 | 0, /* nb_invert */ | |
414 | 0, /* nb_lshift */ |
|
414 | 0, /* nb_lshift */ | |
415 | 0, /* nb_rshift */ |
|
415 | 0, /* nb_rshift */ | |
@@ -439,29 +439,29 static PyNumberMethods PythonQtWrapper_as_number = { | |||||
439 | 0, /* nb_inplace_true_divide */ |
|
439 | 0, /* nb_inplace_true_divide */ | |
440 | }; |
|
440 | }; | |
441 |
|
441 | |||
442 | PyTypeObject PythonQtWrapper_Type = { |
|
442 | PyTypeObject PythonQtInstanceWrapper_Type = { | |
443 | PyObject_HEAD_INIT(NULL) |
|
443 | PyObject_HEAD_INIT(NULL) | |
444 | 0, /*ob_size*/ |
|
444 | 0, /*ob_size*/ | |
445 | "PythonQt.PythonQtWrapper", /*tp_name*/ |
|
445 | "PythonQt.PythonQtInstanceWrapper", /*tp_name*/ | |
446 | sizeof(PythonQtWrapper), /*tp_basicsize*/ |
|
446 | sizeof(PythonQtInstanceWrapper), /*tp_basicsize*/ | |
447 | 0, /*tp_itemsize*/ |
|
447 | 0, /*tp_itemsize*/ | |
448 | (destructor)PythonQtWrapper_dealloc, /*tp_dealloc*/ |
|
448 | (destructor)PythonQtInstanceWrapper_dealloc, /*tp_dealloc*/ | |
449 | 0, /*tp_print*/ |
|
449 | 0, /*tp_print*/ | |
450 | 0, /*tp_getattr*/ |
|
450 | 0, /*tp_getattr*/ | |
451 | 0, /*tp_setattr*/ |
|
451 | 0, /*tp_setattr*/ | |
452 | PythonQtWrapper_compare, /*tp_compare*/ |
|
452 | PythonQtInstanceWrapper_compare, /*tp_compare*/ | |
453 | PythonQtWrapper_repr, /*tp_repr*/ |
|
453 | PythonQtInstanceWrapper_repr, /*tp_repr*/ | |
454 | &PythonQtWrapper_as_number, /*tp_as_number*/ |
|
454 | &PythonQtInstanceWrapper_as_number, /*tp_as_number*/ | |
455 | 0, /*tp_as_sequence*/ |
|
455 | 0, /*tp_as_sequence*/ | |
456 | 0, /*tp_as_mapping*/ |
|
456 | 0, /*tp_as_mapping*/ | |
457 | (hashfunc)PythonQtWrapper_hash, /*tp_hash */ |
|
457 | (hashfunc)PythonQtInstanceWrapper_hash, /*tp_hash */ | |
458 | 0, /*tp_call*/ |
|
458 | 0, /*tp_call*/ | |
459 | PythonQtWrapper_str, /*tp_str*/ |
|
459 | PythonQtInstanceWrapper_str, /*tp_str*/ | |
460 | PythonQtWrapper_getattro, /*tp_getattro*/ |
|
460 | PythonQtInstanceWrapper_getattro, /*tp_getattro*/ | |
461 | PythonQtWrapper_setattro, /*tp_setattro*/ |
|
461 | PythonQtInstanceWrapper_setattro, /*tp_setattro*/ | |
462 | 0, /*tp_as_buffer*/ |
|
462 | 0, /*tp_as_buffer*/ | |
463 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ |
|
463 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ | |
464 | "PythonQtWrapper object", /* tp_doc */ |
|
464 | "PythonQtInstanceWrapper object", /* tp_doc */ | |
465 | 0, /* tp_traverse */ |
|
465 | 0, /* tp_traverse */ | |
466 | 0, /* tp_clear */ |
|
466 | 0, /* tp_clear */ | |
467 | 0, /* tp_richcompare */ |
|
467 | 0, /* tp_richcompare */ | |
@@ -476,9 +476,9 PyTypeObject PythonQtWrapper_Type = { | |||||
476 | 0, /* tp_descr_get */ |
|
476 | 0, /* tp_descr_get */ | |
477 | 0, /* tp_descr_set */ |
|
477 | 0, /* tp_descr_set */ | |
478 | 0, /* tp_dictoffset */ |
|
478 | 0, /* tp_dictoffset */ | |
479 | (initproc)PythonQtWrapper_init, /* tp_init */ |
|
479 | (initproc)PythonQtInstanceWrapper_init, /* tp_init */ | |
480 | 0, /* tp_alloc */ |
|
480 | 0, /* tp_alloc */ | |
481 | PythonQtWrapper_new, /* tp_new */ |
|
481 | PythonQtInstanceWrapper_new, /* tp_new */ | |
482 | }; |
|
482 | }; | |
483 |
|
483 | |||
484 | //------------------------------------------------------- |
|
484 | //------------------------------------------------------- |
@@ -35,7 +35,7 | |||||
35 |
|
35 | |||
36 | //---------------------------------------------------------------------------------- |
|
36 | //---------------------------------------------------------------------------------- | |
37 | /*! |
|
37 | /*! | |
38 | // \file PythonQtWrapper.h |
|
38 | // \file PythonQtInstanceWrapper.h | |
39 | // \author Florian Link |
|
39 | // \author Florian Link | |
40 | // \author Last changed by $Author: florian $ |
|
40 | // \author Last changed by $Author: florian $ | |
41 | // \date 2006-05 |
|
41 | // \date 2006-05 | |
@@ -55,7 +55,7 | |||||
55 | class PythonQtClassInfo; |
|
55 | class PythonQtClassInfo; | |
56 | class QObject; |
|
56 | class QObject; | |
57 |
|
57 | |||
58 | extern PYTHONQT_EXPORT PyTypeObject PythonQtWrapper_Type; |
|
58 | extern PYTHONQT_EXPORT PyTypeObject PythonQtInstanceWrapper_Type; | |
59 |
|
59 | |||
60 | //--------------------------------------------------------------- |
|
60 | //--------------------------------------------------------------- | |
61 | //! a Python wrapper object for Qt objects and C++ objects (that are themselves wrapped by wrapper QObjects) |
|
61 | //! a Python wrapper object for Qt objects and C++ objects (that are themselves wrapped by wrapper QObjects) | |
@@ -86,7 +86,7 typedef struct { | |||||
86 | //! stores that the owned object should be destroyed using QMetaType::destroy() |
|
86 | //! stores that the owned object should be destroyed using QMetaType::destroy() | |
87 | bool _useQMetaTypeDestroy; |
|
87 | bool _useQMetaTypeDestroy; | |
88 |
|
88 | |||
89 | } PythonQtWrapper; |
|
89 | } PythonQtInstanceWrapper; | |
90 |
|
90 | |||
91 |
|
91 | |||
92 | #endif No newline at end of file |
|
92 | #endif |
@@ -41,7 +41,7 | |||||
41 |
|
41 | |||
42 | #include "PythonQt.h" |
|
42 | #include "PythonQt.h" | |
43 | #include "PythonQtSlot.h" |
|
43 | #include "PythonQtSlot.h" | |
44 | #include "PythonQtWrapper.h" |
|
44 | #include "PythonQtInstanceWrapper.h" | |
45 | #include "PythonQtClassInfo.h" |
|
45 | #include "PythonQtClassInfo.h" | |
46 | #include "PythonQtMisc.h" |
|
46 | #include "PythonQtMisc.h" | |
47 | #include "PythonQtConversion.h" |
|
47 | #include "PythonQtConversion.h" | |
@@ -159,10 +159,10 PyObject *PythonQtSlotFunction_Call(PyObject *func, PyObject *args, PyObject *kw | |||||
159 | { |
|
159 | { | |
160 | PythonQtSlotFunctionObject* f = (PythonQtSlotFunctionObject*)func; |
|
160 | PythonQtSlotFunctionObject* f = (PythonQtSlotFunctionObject*)func; | |
161 | PythonQtSlotInfo* info = f->m_ml; |
|
161 | PythonQtSlotInfo* info = f->m_ml; | |
162 | if (f->m_self->ob_type == &PythonQtWrapper_Type) { |
|
162 | if (f->m_self->ob_type == &PythonQtInstanceWrapper_Type) { | |
163 | PythonQtWrapper* self = (PythonQtWrapper*) f->m_self; |
|
163 | PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*) f->m_self; | |
164 | return PythonQtSlotFunction_CallImpl(self->_obj, info, args, kw, self->_wrappedPtr); |
|
164 | return PythonQtSlotFunction_CallImpl(self->_obj, info, args, kw, self->_wrappedPtr); | |
165 |
} else if (f->m_self->ob_type == &PythonQt |
|
165 | } else if (f->m_self->ob_type == &PythonQtClassWrapper_Type) { | |
166 | return PythonQtSlotFunction_CallImpl(NULL, info, args, kw); |
|
166 | return PythonQtSlotFunction_CallImpl(NULL, info, args, kw); | |
167 | } else { |
|
167 | } else { | |
168 | return NULL; |
|
168 | return NULL; |
@@ -13,8 +13,8 HEADERS += \ | |||||
13 | $$PWD/PythonQtImportFileInterface.h \ |
|
13 | $$PWD/PythonQtImportFileInterface.h \ | |
14 | $$PWD/PythonQtConversion.h \ |
|
14 | $$PWD/PythonQtConversion.h \ | |
15 | $$PWD/PythonQtSignalReceiver.h \ |
|
15 | $$PWD/PythonQtSignalReceiver.h \ | |
16 |
$$PWD/PythonQtWrapper.h |
|
16 | $$PWD/PythonQtInstanceWrapper.h \ | |
17 |
$$PWD/PythonQt |
|
17 | $$PWD/PythonQtClassWrapper.h \ | |
18 | $$PWD/PythonQtCppWrapperFactory.h \ |
|
18 | $$PWD/PythonQtCppWrapperFactory.h \ | |
19 | $$PWD/PythonQtVariants.h \ |
|
19 | $$PWD/PythonQtVariants.h \ | |
20 | $$PWD/PythonQtQFileImporter.h \ |
|
20 | $$PWD/PythonQtQFileImporter.h \ | |
@@ -71,9 +71,9 SOURCES += \ | |||||
71 | $$PWD/PythonQtConversion.cpp \ |
|
71 | $$PWD/PythonQtConversion.cpp \ | |
72 | $$PWD/PythonQtSignalReceiver.cpp \ |
|
72 | $$PWD/PythonQtSignalReceiver.cpp \ | |
73 | $$PWD/PythonQtVariants.cpp \ |
|
73 | $$PWD/PythonQtVariants.cpp \ | |
74 |
$$PWD/PythonQtWrapper.cpp |
|
74 | $$PWD/PythonQtInstanceWrapper.cpp \ | |
75 |
$$PWD/PythonQtQFileImporter.cpp |
|
75 | $$PWD/PythonQtQFileImporter.cpp \ | |
76 |
$$PWD/PythonQt |
|
76 | $$PWD/PythonQtClassWrapper.cpp \ | |
77 | $$PWD/gui/PythonQtScriptingConsole.cpp \ |
|
77 | $$PWD/gui/PythonQtScriptingConsole.cpp \ | |
78 | \ |
|
78 | \ | |
79 | $$PWD/../generated_cpp/com_trolltech_qt_core/PythonQtWrapper_Qt.cpp \ |
|
79 | $$PWD/../generated_cpp/com_trolltech_qt_core/PythonQtWrapper_Qt.cpp \ |
General Comments 0
You need to be logged in to leave comments.
Login now