aboutsummaryrefslogtreecommitdiffstats
path: root/headergenerator.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-12-14 10:24:41 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-12-14 14:14:29 -0300
commitcdcb5567c77b3f703541839101cad564605b7f61 (patch)
treeea3ad5751a0ab5f3a3b14bc6b85da82c019463d5 /headergenerator.cpp
parent0f31a28bcb0d802f461fd2012dd2a239decb81b0 (diff)
All wrapped classes now inherit from the SbkBaseWrapper of the metatype SbkBaseWrapperType.
The wrapped classes are described with a SbkBaseWrapperType structure which extends the PyTypeObject with information about multiple inheritance and parenting ownership. This works well for the classes produced by the generator but inheriting classes written in Python continues using the PyTypeObject to describe themselves. To fix this the SbkBaseWrapperType is now a metatype for all the wrapped classes and anyone inheriting from them. In addition all the wrapped classes now inherit from SbkBaseWrapper, since Python's PyType_Ready method need that multiple inheriting classes have a common base class with the same size of the classes involved in the multiple inheritance, which disqualifies Python's base "object" class. The metatype and the base wrapper type are initialized by calling the new Shiboken::init_shiboken() function. This is done by all the imported binding modules, but it is really run only in the first call. Another noteworthy change is the replacement of PyTypeObject as a basis for SbkBaseWrapperType by the PyHeapTypeObject, since the latter is the proper choice for types created on the heap, e.g. user defined classes extending the generated wrapper classes. Reviewed by Hugo Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'headergenerator.cpp')
-rw-r--r--headergenerator.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/headergenerator.cpp b/headergenerator.cpp
index b13fb2bf1..e19bbc277 100644
--- a/headergenerator.cpp
+++ b/headergenerator.cpp
@@ -227,14 +227,14 @@ void HeaderGenerator::finishGeneration()
if (shouldGenerate(innerClass)) {
s_cin << innerClass->typeEntry()->include().toString() << endl;
s_pts << getApiExportMacro() << " PyAPI_FUNC(PyObject*) " << cpythonBaseName(innerClass->typeEntry());
- s_pts << "_New(PyTypeObject* type, PyObject* args, PyObject* kwds);" << endl;
+ s_pts << "_New(Shiboken::SbkBaseWrapperType* type, PyObject* args, PyObject* kwds);" << endl;
writeTypeCheckMacro(s_pts, innerClass->typeEntry());
writeTypeConverterDecl(convDecl, innerClass->typeEntry());
convDecl << endl;
}
}
s_pts << getApiExportMacro() << " PyAPI_FUNC(PyObject*) " << cpythonBaseName(metaClass->typeEntry());
- s_pts << "_New(PyTypeObject* type, PyObject* args, PyObject* kwds);" << endl;
+ s_pts << "_New(Shiboken::SbkBaseWrapperType* type, PyObject* args, PyObject* kwds);" << endl;
writeTypeCheckMacro(s_pts, classType);
s_pts << "#define Sbk" << metaClass->name() << "_cptr(pyobj) ((";
s_pts << metaClass->name() << "*)SbkBaseWrapper_cptr(pyobj))" << endl << endl;