Update to new Shiboken API (Renamed SbkObjectType)
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Hugo Parente Lima <hugo.pl@gmail.com>
This commit is contained in:
parent
5e0550446c
commit
c9aef92cab
11 changed files with 30 additions and 32 deletions
|
|
@ -4,7 +4,7 @@ static char** QCoreApplicationArgValues;
|
||||||
|
|
||||||
int Sbk_QCoreApplication_Init(PyObject* self, PyObject* args, PyObject*)
|
int Sbk_QCoreApplication_Init(PyObject* self, PyObject* args, PyObject*)
|
||||||
{
|
{
|
||||||
if (Shiboken::isUserType(self) && !Shiboken::canCallConstructor(self->ob_type, Shiboken::SbkType<QApplication >()))
|
if (Shiboken::Wrapper::isUserType(self) && !Shiboken::BaseType::canCallConstructor(self->ob_type, Shiboken::SbkType<QApplication >()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ struct Converter<QVariant>
|
||||||
|
|
||||||
static QByteArray resolveMetaType(PyTypeObject* type, int &typeId)
|
static QByteArray resolveMetaType(PyTypeObject* type, int &typeId)
|
||||||
{
|
{
|
||||||
if (PyObject_TypeCheck(type, &SbkObjectType_Type)) {
|
if (PyObject_TypeCheck(type, &SbkBaseType_Type)) {
|
||||||
SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(type);
|
SbkBaseType* sbkType = reinterpret_cast<SbkBaseType*>(type);
|
||||||
QByteArray typeName(sbkType->original_name);
|
QByteArray typeName(Shiboken::BaseType::getOriginalName(sbkType));
|
||||||
bool valueType = !typeName.endsWith("*");
|
bool valueType = !typeName.endsWith("*");
|
||||||
|
|
||||||
// Do not convert user type of value
|
// Do not convert user type of value
|
||||||
if (valueType && sbkType->is_user_type)
|
if (valueType && Shiboken::BaseType::isUserType(type))
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
|
|
||||||
int obTypeId = QMetaType::type(typeName);
|
int obTypeId = QMetaType::type(typeName);
|
||||||
|
|
@ -86,8 +86,8 @@ struct Converter<QVariant>
|
||||||
return convertToVariantList(pyObj);
|
return convertToVariantList(pyObj);
|
||||||
} else {
|
} else {
|
||||||
// a class supported by QVariant?
|
// a class supported by QVariant?
|
||||||
if (Shiboken::isShibokenType(pyObj)) {
|
if (Shiboken::Wrapper::checkType(pyObj)) {
|
||||||
SbkObjectType* objType = reinterpret_cast<SbkObjectType*>(pyObj->ob_type);
|
SbkBaseType* objType = reinterpret_cast<SbkBaseType*>(pyObj->ob_type);
|
||||||
int typeCode = 0;
|
int typeCode = 0;
|
||||||
QByteArray typeName = resolveMetaType(reinterpret_cast<PyTypeObject*>(objType), typeCode);
|
QByteArray typeName = resolveMetaType(reinterpret_cast<PyTypeObject*>(objType), typeCode);
|
||||||
if (typeCode) {
|
if (typeCode) {
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ struct Converter<QVariant::Type>
|
||||||
else if (pyObj == reinterpret_cast<PyObject*>(&PyLong_Type))
|
else if (pyObj == reinterpret_cast<PyObject*>(&PyLong_Type))
|
||||||
typeName = "int"; // long is a UserType in QVariant.
|
typeName = "int"; // long is a UserType in QVariant.
|
||||||
else if (PyType_Check(pyObj)) {
|
else if (PyType_Check(pyObj)) {
|
||||||
if (pyObj->ob_type == &SbkObjectType_Type)
|
if (pyObj->ob_type == &SbkBaseType_Type)
|
||||||
typeName = reinterpret_cast<SbkObjectType*>(pyObj)->original_name;
|
typeName = Shiboken::BaseType::getOriginalName(reinterpret_cast<SbkBaseType*>(pyObj));
|
||||||
else
|
else
|
||||||
typeName = reinterpret_cast<PyTypeObject*>(pyObj)->tp_name;
|
typeName = reinterpret_cast<PyTypeObject*>(pyObj)->tp_name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ static const char QAPP_MACRO[] = "qApp";
|
||||||
|
|
||||||
int Sbk_QApplication_Init(PyObject* self, PyObject* args, PyObject*)
|
int Sbk_QApplication_Init(PyObject* self, PyObject* args, PyObject*)
|
||||||
{
|
{
|
||||||
if (Shiboken::isUserType(self) && !Shiboken::canCallConstructor(self->ob_type, Shiboken::SbkType<QApplication>()))
|
if (Shiboken::Wrapper::isUserType(self) && !Shiboken::BaseType::canCallConstructor(self->ob_type, Shiboken::SbkType<QApplication>()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (QApplication::instance()) {
|
if (QApplication::instance()) {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ inline void addLayoutOwnership(QLayout* layout, QWidget* widget)
|
||||||
//keep the reference while the layout is orphan
|
//keep the reference while the layout is orphan
|
||||||
Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(layout));
|
Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(layout));
|
||||||
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget));
|
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget));
|
||||||
Shiboken::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
|
Shiboken::Wrapper::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
|
||||||
} else {
|
} else {
|
||||||
Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent));
|
Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent));
|
||||||
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget));
|
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget));
|
||||||
|
|
@ -34,7 +34,7 @@ inline void addLayoutOwnership(QLayout* layout, QLayout* other)
|
||||||
//keep the reference while the layout is orphan
|
//keep the reference while the layout is orphan
|
||||||
Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout));
|
Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout));
|
||||||
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(other));
|
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(other));
|
||||||
Shiboken::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
|
Shiboken::Wrapper::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout)
|
||||||
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(layout));
|
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(layout));
|
||||||
Shiboken::Wrapper::setParent(pyParent, pyChild);
|
Shiboken::Wrapper::setParent(pyParent, pyChild);
|
||||||
//remove previous references
|
//remove previous references
|
||||||
Shiboken::keepReference(reinterpret_cast<SbkObject*>(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None);
|
Shiboken::Wrapper::keepReference(reinterpret_cast<SbkObject*>(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void qwidgetSetLayout(QWidget *self, QLayout *layout)
|
static inline void qwidgetSetLayout(QWidget *self, QLayout *layout)
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,15 @@ inline bool Converter<QPixmap>::isConvertible(PyObject* pyobj)
|
||||||
{
|
{
|
||||||
if (ValueTypeConverter<QPixmap>::isConvertible(pyobj))
|
if (ValueTypeConverter<QPixmap>::isConvertible(pyobj))
|
||||||
return true;
|
return true;
|
||||||
SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<QPixmap>());
|
SbkBaseType* shiboType = reinterpret_cast<SbkBaseType*>(SbkType<QPixmap>());
|
||||||
bool isVariant = Converter<QVariant>::checkType(pyobj);
|
bool isVariant = Converter<QVariant>::checkType(pyobj);
|
||||||
if (isVariant) {
|
if (isVariant) {
|
||||||
QVariant var(Converter<QVariant>::toCpp(pyobj));
|
QVariant var(Converter<QVariant>::toCpp(pyobj));
|
||||||
return var.type() == QVariant::Pixmap;
|
return var.type() == QVariant::Pixmap;
|
||||||
} else if (Converter<QSize>::checkType(pyobj) || Converter<QString>::checkType(pyobj)) {
|
} else if (Converter<QSize>::checkType(pyobj) || Converter<QString>::checkType(pyobj)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (shiboType->ext_isconvertible) {
|
} else {
|
||||||
return shiboType->ext_isconvertible(pyobj);
|
return Shiboken::BaseType::isExternalConvertible(shiboType, pyobj);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ inline bool Converter<QPixmap>::isConvertible(PyObject* pyobj)
|
||||||
|
|
||||||
inline QPixmap Converter<QPixmap>::toCpp(PyObject* pyobj)
|
inline QPixmap Converter<QPixmap>::toCpp(PyObject* pyobj)
|
||||||
{
|
{
|
||||||
SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<QPixmap>());
|
SbkBaseType* shiboType = reinterpret_cast<SbkBaseType*>(SbkType<QPixmap>());
|
||||||
bool isVariant = Converter<QVariant>::checkType(pyobj);
|
bool isVariant = Converter<QVariant>::checkType(pyobj);
|
||||||
if (isVariant) {
|
if (isVariant) {
|
||||||
QVariant var(Converter<QVariant>::toCpp(pyobj));
|
QVariant var(Converter<QVariant>::toCpp(pyobj));
|
||||||
|
|
@ -33,8 +33,8 @@ inline QPixmap Converter<QPixmap>::toCpp(PyObject* pyobj)
|
||||||
return QPixmap(Shiboken::Converter<QSize >::toCpp(pyobj));
|
return QPixmap(Shiboken::Converter<QSize >::toCpp(pyobj));
|
||||||
} else if (Converter<QString>::checkType(pyobj)) {
|
} else if (Converter<QString>::checkType(pyobj)) {
|
||||||
return QPixmap(Shiboken::Converter<QString >::toCpp(pyobj));
|
return QPixmap(Shiboken::Converter<QString >::toCpp(pyobj));
|
||||||
} else if (shiboType->ext_isconvertible && shiboType->ext_tocpp && shiboType->ext_isconvertible(pyobj)) {
|
} else if (Shiboken::BaseType::isExternalConvertible(shiboType, pyobj) && Shiboken::BaseType::hasExternalCppConversions(shiboType)) {
|
||||||
QPixmap* cptr = reinterpret_cast<QPixmap*>(shiboType->ext_tocpp(pyobj));
|
QPixmap* cptr = reinterpret_cast<QPixmap*>(Shiboken::BaseType::callExternalCppConversion(shiboType, pyobj));
|
||||||
std::auto_ptr<QPixmap> cptr_auto_ptr(cptr);
|
std::auto_ptr<QPixmap> cptr_auto_ptr(cptr);
|
||||||
return *cptr;
|
return *cptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3317,7 +3317,7 @@
|
||||||
|
|
||||||
<modify-function signature="setStyle(QStyle*)">
|
<modify-function signature="setStyle(QStyle*)">
|
||||||
<inject-code class="target" position="end">
|
<inject-code class="target" position="end">
|
||||||
Shiboken::keepReference(reinterpret_cast<SbkObject*>(%PYSELF), "__style__", %PYARG_1);
|
Shiboken::Wrapper::keepReference(reinterpret_cast<SbkObject*>(%PYSELF), "__style__", %PYARG_1);
|
||||||
</inject-code>
|
</inject-code>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
<modify-function signature="style()const">
|
<modify-function signature="style()const">
|
||||||
|
|
@ -3331,7 +3331,7 @@
|
||||||
Shiboken::Wrapper::setParent(pyApp, %PYARG_0);
|
Shiboken::Wrapper::setParent(pyApp, %PYARG_0);
|
||||||
Shiboken::Wrapper::releaseOwnership(%PYARG_0);
|
Shiboken::Wrapper::releaseOwnership(%PYARG_0);
|
||||||
} else {
|
} else {
|
||||||
Shiboken::keepReference(reinterpret_cast<SbkObject*>(%PYSELF), "__style__", %PYARG_0);
|
Shiboken::Wrapper::keepReference(reinterpret_cast<SbkObject*>(%PYSELF), "__style__", %PYARG_0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</inject-code>
|
</inject-code>
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ struct QtDictConverter
|
||||||
if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<QtDict>()))
|
if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<QtDict>()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ((Shiboken::SbkType<QtDict>() && Shiboken::isShibokenType(pyObj)) || !PyDict_Check(pyObj))
|
if ((Shiboken::SbkType<QtDict>() && Shiboken::Wrapper::checkType(pyObj)) || !PyDict_Check(pyObj))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
PyObject* key;
|
PyObject* key;
|
||||||
|
|
@ -100,7 +100,7 @@ struct QtMultiMapConverter
|
||||||
if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<MultiMap>()))
|
if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<MultiMap>()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ((Shiboken::SbkType<MultiMap>() && Shiboken::isShibokenType(pyObj)) || !PyDict_Check(pyObj))
|
if ((Shiboken::SbkType<MultiMap>() && Shiboken::Wrapper::checkType(pyObj)) || !PyDict_Check(pyObj))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
PyObject* key;
|
PyObject* key;
|
||||||
|
|
@ -176,7 +176,7 @@ struct QSequenceConverter
|
||||||
{
|
{
|
||||||
if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>()))
|
if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>()))
|
||||||
return true;
|
return true;
|
||||||
if ((Shiboken::SbkType<T>() && Shiboken::isShibokenType(pyObj)) || !PySequence_Check(pyObj))
|
if ((Shiboken::SbkType<T>() && Shiboken::Wrapper::checkType(pyObj)) || !PySequence_Check(pyObj))
|
||||||
return false;
|
return false;
|
||||||
for (int i = 0, max = PySequence_Length(pyObj); i < max; ++i) {
|
for (int i = 0, max = PySequence_Length(pyObj); i < max; ++i) {
|
||||||
Shiboken::AutoDecRef item(PySequence_GetItem(pyObj, i));
|
Shiboken::AutoDecRef item(PySequence_GetItem(pyObj, i));
|
||||||
|
|
|
||||||
|
|
@ -493,10 +493,9 @@ char* getTypeName(PyObject* type)
|
||||||
{
|
{
|
||||||
if (PyType_Check(type)) {
|
if (PyType_Check(type)) {
|
||||||
char *typeName = NULL;
|
char *typeName = NULL;
|
||||||
if (type->ob_type == &SbkObjectType_Type) {
|
if (type->ob_type == &SbkBaseType_Type) {
|
||||||
SbkObjectType* objType = reinterpret_cast<SbkObjectType*>(type);
|
SbkBaseType* objType = reinterpret_cast<SbkBaseType*>(type);
|
||||||
Q_ASSERT(objType->original_name);
|
typeName = strdup(Shiboken::BaseType::getOriginalName(objType));
|
||||||
typeName = strdup(objType->original_name);
|
|
||||||
} else {
|
} else {
|
||||||
// Translate python types to Qt names
|
// Translate python types to Qt names
|
||||||
PyTypeObject *objType = reinterpret_cast<PyTypeObject*>(type);
|
PyTypeObject *objType = reinterpret_cast<PyTypeObject*>(type);
|
||||||
|
|
@ -670,7 +669,7 @@ PyObject* buildQtCompatible(const char* signature)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal)
|
void addSignalToWrapper(SbkBaseType* wrapperType, const char* signalName, PySideSignal* signal)
|
||||||
{
|
{
|
||||||
PyObject* typeDict = wrapperType->super.ht_type.tp_dict;
|
PyObject* typeDict = wrapperType->super.ht_type.tp_dict;
|
||||||
PyObject* homonymousMethod;
|
PyObject* homonymousMethod;
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,7 @@
|
||||||
|
|
||||||
#include <pysidemacros.h>
|
#include <pysidemacros.h>
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
#include <basewrapper.h>
|
||||||
struct SbkObjectType;
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
@ -108,7 +107,7 @@ PYSIDE_API void updateSourceObject(PyObject* source);
|
||||||
* @param self The Signal object
|
* @param self The Signal object
|
||||||
* @return Return the signal signature
|
* @return Return the signal signature
|
||||||
**/
|
**/
|
||||||
PYSIDE_API void addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal);
|
PYSIDE_API void addSignalToWrapper(SbkBaseType* wrapperType, const char* signalName, PySideSignal* signal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function verify if the signature is a QtSignal base on SIGNAL flag
|
* This function verify if the signature is a QtSignal base on SIGNAL flag
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue