- wrapped instances are now wrapped by class specific subtypes to fac… · MeVisLab/pythonqt@a15f2cd · GitHub
Skip to content

Commit a15f2cd

Browse files
committed
- wrapped instances are now wrapped by class specific subtypes to facilitate future deriving from python
- object creation has changed by using the python type system (calling the type object with PyObject_Call)
1 parent 05e2f30 commit a15f2cd

11 files changed

Lines changed: 322 additions & 248 deletions

src/PythonQt.cpp

Lines changed: 91 additions & 56 deletions

src/PythonQt.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class PythonQtMethodInfo;
6363
class PythonQtSignalReceiver;
6464
class PythonQtImportFileInterface;
6565
class PythonQtCppWrapperFactory;
66-
class PythonQtConstructorHandler;
6766
class PythonQtQFileImporter;
6867

6968
typedef void PythonQtQObjectWrappedCB(QObject* object);
@@ -269,12 +268,6 @@ class PYTHONQT_EXPORT PythonQt : public QObject {
269268
//! add the given factory to PythonQt (ownership stays with caller)
270269
void addWrapperFactory(PythonQtCppWrapperFactory* factory);
271270

272-
//! add the given constructor handler to PythonQt (ownership stays with caller)
273-
void addConstructorHandler(PythonQtConstructorHandler* handler);
274-
275-
//! get list of constructor handlers
276-
const QList<PythonQtConstructorHandler*>& constructorHandlers();
277-
278271
//@}
279272

280273
//@{ Custom importer (to replace internal import implementation of python)
@@ -383,6 +376,8 @@ class PythonQtPrivate : public QObject {
383376
//! returns if the id is the id for PythonQtObjectPtr
384377
bool isPythonQtObjectPtrMetaId(int id) { return _PythonQtObjectPtr_metaId == id; }
385378

379+
//! add the wrapper pointer (for reuse if the same obj appears while wrapper still exists)
380+
void addWrapperPointer(void* obj, PythonQtInstanceWrapper* wrapper);
386381
//! remove the wrapper ptr again
387382
void removeWrapperPointer(void* obj);
388383

@@ -425,7 +420,7 @@ class PythonQtPrivate : public QObject {
425420
bool isEnumType(const QMetaObject* meta, const QByteArray& name);
426421

427422
//! helper method that creates a PythonQtClassWrapper object
428-
PythonQtClassWrapper* createNewPythonQtClassWrapper(PythonQtClassInfo* info);
423+
PythonQtClassWrapper* createNewPythonQtClassWrapper(PythonQtClassInfo* info, const char* package = NULL);
429424

430425
//! helper method that creates a PythonQtInstanceWrapper object and registers it in the object map
431426
PythonQtInstanceWrapper* createNewPythonQtInstanceWrapper(QObject* obj, PythonQtClassInfo* info, void* wrappedPtr = NULL);
@@ -445,7 +440,17 @@ class PythonQtPrivate : public QObject {
445440
//! creates the new module from the given pycode
446441
PythonQtObjectPtr createModule(const QString& name, PyObject* pycode);
447442

443+
//! get the current class info (for the next PythonQtClassWrapper that is created) and reset it to NULL again
444+
PythonQtClassInfo* currentClassInfoForClassWrapperCreation();
445+
446+
//! the dummy tuple (which is empty and may be used to detected that a wrapper is called from internal wrapper creation
447+
static PyObject* dummyTuple();
448+
448449
private:
450+
451+
//! create a new class info and python wrapper type
452+
PythonQtClassInfo* createPythonQtClassInfo(const QMetaObject* meta, const char* cppClassName, const char* package);
453+
449454
//! get/create new package module
450455
PythonQtObjectPtr packageByName(const char* name);
451456

@@ -487,14 +492,13 @@ class PythonQtPrivate : public QObject {
487492
//! the cpp object wrapper factories
488493
QList<PythonQtCppWrapperFactory*> _cppWrapperFactories;
489494

490-
//! the cpp object wrapper factories
491-
QList<PythonQtConstructorHandler*> _constructorHandlers;
492-
493495
QHash<QByteArray , PythonQtSlotInfo *> _constructorSlots;
494496
QHash<QByteArray , PythonQtSlotInfo *> _destructorSlots;
495497

496498
QHash<QByteArray, PythonQtObjectPtr> _packages;
497499

500+
PythonQtClassInfo* _currentClassInfoForClassWrapperCreation;
501+
498502
int _initFlags;
499503
int _PythonQtObjectPtr_metaId;
500504

src/PythonQtClassInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ PythonQtClassInfo::PythonQtClassInfo(const QMetaObject* meta, const QByteArray&
5454
_parentClassInfoResolved = false;
5555
_decoratorProvider = NULL;
5656
_decoratorProviderCB = NULL;
57+
_pythonQtClassWrapper = NULL;
5758
if (wrappedClassName.isEmpty()) {
5859
_metaTypeId = -1;
5960
} else {

src/PythonQtClassInfo.h

Lines changed: 8 additions & 0 deletions

0 commit comments

Comments
 (0)