Changes needed to compile QtCore with libshiboken v1.0

This commit is contained in:
Hugo Parente Lima 2010-11-10 17:22:32 -02:00
commit 92dcb7ae3a
13 changed files with 57 additions and 59 deletions

View file

@ -110,15 +110,15 @@ void destroyQCoreApplication()
return;
Shiboken::BindingManager& bm = Shiboken::BindingManager::instance();
PyObject* pyQApp = bm.retrieveWrapper(app);
SbkObject* pyQApp = bm.retrieveWrapper(app);
PyTypeObject* pyQObjectType = Shiboken::TypeResolver::get("QObject*")->pythonType();
assert(pyQObjectType);
foreach (PyObject* pyObj, bm.getAllPyObjects()) {
foreach (SbkObject* pyObj, bm.getAllPyObjects()) {
if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) {
if (SbkBaseWrapper_hasOwnership(pyObj)) {
if (Shiboken::Wrapper::hasOwnership(pyObj)) {
bm.destroyWrapper(pyObj);
delete static_cast<QObject*>(Shiboken::getCppPointer(pyObj, Shiboken::SbkType<QObject*>()));
delete static_cast<QObject*>(Shiboken::Wrapper::cppPointer(pyObj, Shiboken::SbkType<QObject*>()));
}
}
}

View file

@ -73,7 +73,7 @@ struct QtDictConverter
static inline QtDict toCpp(PyObject* pyobj)
{
if (PyObject_TypeCheck(pyobj, Shiboken::SbkType<QtDict>()))
return *reinterpret_cast<QtDict*>(Shiboken::getCppPointer(pyobj, Shiboken::SbkType<QtDict>()));
return *reinterpret_cast<QtDict*>(Shiboken::Wrapper::cppPointer((SbkObject*)pyobj, Shiboken::SbkType<QtDict>()));
QtDict result;
@ -150,7 +150,7 @@ struct QtMultiMapConverter
static inline MultiMap toCpp(PyObject* pyObj)
{
if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<MultiMap>()))
return *reinterpret_cast<MultiMap*>(Shiboken::getCppPointer(pyObj, Shiboken::SbkType<MultiMap>()));
return *reinterpret_cast<MultiMap*>(Shiboken::Wrapper::cppPointer((SbkObject*)pyObj, Shiboken::SbkType<MultiMap>()));
MultiMap result;
@ -199,7 +199,7 @@ struct QSequenceConverter
static T toCpp(PyObject* pyobj)
{
if (PyObject_TypeCheck(pyobj, Shiboken::SbkType<T>()))
return *reinterpret_cast<T*>(Shiboken::getCppPointer(pyobj, Shiboken::SbkType<T>()));
return *reinterpret_cast<T*>(Shiboken::Wrapper::cppPointer((SbkObject*)pyobj, Shiboken::SbkType<T>()));
Shiboken::AutoDecRef fastSequence(PySequence_Fast(pyobj, "Invalid sequence object"));
T result;
@ -240,7 +240,7 @@ struct QFlagsConverter
static inline T toCpp(PyObject* pyObj)
{
if (Shiboken::isShibokenEnum(pyObj))
return T(QFlag(reinterpret_cast<Shiboken::SbkEnumObject*>(pyObj)->ob_ival));
return T(QFlag(Shiboken::Enum::getValue(pyObj)));
else
return T(QFlag(reinterpret_cast<PyIntObject*>(pyObj)->ob_ival));
}

View file

@ -493,8 +493,8 @@ char* getTypeName(PyObject* type)
{
if (PyType_Check(type)) {
char *typeName = NULL;
if (type->ob_type == &Shiboken::SbkBaseWrapperType_Type) {
Shiboken::SbkBaseWrapperType *objType = reinterpret_cast<Shiboken::SbkBaseWrapperType*>(type);
if (type->ob_type == &SbkObjectType_Type) {
SbkObjectType* objType = reinterpret_cast<SbkObjectType*>(type);
Q_ASSERT(objType->original_name);
typeName = strdup(objType->original_name);
} else {
@ -670,7 +670,7 @@ PyObject* buildQtCompatible(const char* signature)
return ret;
}
void addSignalToWrapper(Shiboken::SbkBaseWrapperType* wrapperType, const char* signalName, PySideSignal* signal)
void addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal)
{
PyObject* typeDict = wrapperType->super.ht_type.tp_dict;
PyObject* homonymousMethod;

View file

@ -30,10 +30,7 @@
#include <pysidemacros.h>
#include <Python.h>
namespace Shiboken
{
struct SbkBaseWrapperType;
}
struct SbkObjectType;
extern "C"
{
@ -60,7 +57,7 @@ namespace PySide { namespace Signal {
* @param signatures a list of signatures supported by this signal, ended with a NULL pointer
* @return Return a new reference to PyObject* of type PySideSignal
**/
PYSIDE_API PySideSignal* newObject(const char* name, ...);
PYSIDE_API PySideSignal* newObject(const char* name, ...);
/**
* This function creates a Signal object which stay attached to QObject class based on a list of QMetaMethod
@ -69,7 +66,7 @@ PYSIDE_API PySideSignal* newObject(const char* name, ...);
* @param methods a list of QMetaMethod wich contains the supported signature
* @return Return a new reference to PyObject* of type PySideSignal
**/
PYSIDE_API PySideSignalInstance* newObjectFromMethod(PyObject* source, const QList<QMetaMethod>& methods);
PYSIDE_API PySideSignalInstance* newObjectFromMethod(PyObject* source, const QList<QMetaMethod>& methods);
/**
* This function initializes the Signal object creating a PySideSignalInstance
@ -79,7 +76,7 @@ PYSIDE_API PySideSignalInstance* newObjectFromMethod(PyObject* source, const
* @param object the PyObject where the signal will be attached
* @return Return a new reference to PySideSignalInstance
**/
PYSIDE_API PySideSignalInstance* initialize(PySideSignal* signal, PyObject* name, PyObject *object);
PYSIDE_API PySideSignalInstance* initialize(PySideSignal* signal, PyObject* name, PyObject *object);
/**
* This function is used to retrieve the object in which the sigal is attached
@ -87,7 +84,7 @@ PYSIDE_API PySideSignalInstance* initialize(PySideSignal* signal, PyObject* n
* @param self The Signal object
* @return Return the internal reference to parent object of the signal
**/
PYSIDE_API PyObject* getObject(PySideSignalInstance* signal);
PYSIDE_API PyObject* getObject(PySideSignalInstance* signal);
/**
* This function is used to retrieve the signal signature
@ -95,7 +92,7 @@ PYSIDE_API PyObject* getObject(PySideSignalInstance* signal);
* @param self The Signal object
* @return Return the signal signature
**/
PYSIDE_API const char* getSignature(PySideSignalInstance* signal);
PYSIDE_API const char* getSignature(PySideSignalInstance* signal);
/**
* This function is used to retrieve the signal signature
@ -103,7 +100,7 @@ PYSIDE_API const char* getSignature(PySideSignalInstance* signal);
* @param self The Signal object
* @return Return the signal signature
**/
PYSIDE_API void updateSourceObject(PyObject* source);
PYSIDE_API void updateSourceObject(PyObject* source);
/**
* This function is used to retrieve the signal signature
@ -111,21 +108,21 @@ PYSIDE_API void updateSourceObject(PyObject* source);
* @param self The Signal object
* @return Return the signal signature
**/
PYSIDE_API void addSignalToWrapper(Shiboken::SbkBaseWrapperType* wrapperType, const char* signalName, PySideSignal* signal);
PYSIDE_API void addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal);
/**
* This function verify if the signature is a QtSignal base on SIGNAL flag
* @param signature The signal signature
* @return Return true if this is a Qt Signal of false if not
**/
PYSIDE_API bool isQtSignal(const char* signature);
PYSIDE_API bool isQtSignal(const char* signature);
/**
* This function is similar as isQtSignal but this reaise a Python error if this faisl
* @param signature The signal signature
* @return Return true if this is a Qt Signal of false if not
**/
PYSIDE_API bool checkQtSignal(const char* signature);
PYSIDE_API bool checkQtSignal(const char* signature);
/**
* This function is used to retrieve the signature base on Signal and receiver callback
@ -135,7 +132,7 @@ PYSIDE_API bool checkQtSignal(const char* signature);
* @param encodeName Used to specify if the returned signature will be encoded with Qt signal/slot style
* @return Return the callback signature
**/
PYSIDE_API QString getCallbackSignature(const char* signal, QObject* receiver, PyObject* callback, bool encodeName);
PYSIDE_API QString getCallbackSignature(const char* signal, QObject* receiver, PyObject* callback, bool encodeName);
/**
* Function to parese the signature and return a list of argument types
@ -143,7 +140,7 @@ PYSIDE_API QString getCallbackSignature(const char* signal, QOb
* @param isShortCircuit If this is a shortCircuit(python<->python) signal
* @return Return true if this is a Qt Signal of false if not
**/
QStringList getArgsFromSignature(const char* signature, bool* isShortCircuit = 0);
QStringList getArgsFromSignature(const char* signature, bool* isShortCircuit = 0);
} //namespace Signal
} //namespace PySide

View file

@ -251,7 +251,7 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id,
return id - metaObject->methodCount();
Shiboken::GilState gil;
pySelf = Shiboken::BindingManager::instance().retrieveWrapper(object);
pySelf = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(object);
Q_ASSERT(pySelf);
pp_name = PyString_FromString(mp.name());
pp = Property::getObject(pySelf, pp_name);
@ -334,7 +334,7 @@ static int PySide::callMethod(QObject* object, int id, void** args)
// call python slot
Shiboken::GilState gil;
QList<QByteArray> paramTypes = method.parameterTypes();
PyObject* self = Shiboken::BindingManager::instance().retrieveWrapper(object);
PyObject* self = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(object);
PyObject* preparedArgs = NULL;
Py_ssize_t args_size = paramTypes.count();
@ -378,8 +378,8 @@ bool SignalManager::registerMetaMethod(QObject* source, const char* signature, Q
int methodIndex = metaObject->indexOfMethod(signature);
// Create the dynamic signal is needed
if (methodIndex == -1) {
Shiboken::SbkBaseWrapper* self = (Shiboken::SbkBaseWrapper*) Shiboken::BindingManager::instance().retrieveWrapper(source);
if (!self->containsCppWrapper) {
SbkObject* self = Shiboken::BindingManager::instance().retrieveWrapper(source);
if (!Shiboken::Wrapper::hasCppWrapper(self)) {
qWarning() << "Invalid Signal signature:" << signature;
return false;
} else {