Adapt to changed in libshiboken API.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
ad2d6b2158
commit
0e649b3e38
6 changed files with 9 additions and 245 deletions
|
|
@ -1048,7 +1048,7 @@
|
||||||
<add-function signature="__setitem__">
|
<add-function signature="__setitem__">
|
||||||
<inject-code class="target" position="beginning">
|
<inject-code class="target" position="beginning">
|
||||||
PyObject* args = Py_BuildValue("(nO)", _i, _value);
|
PyObject* args = Py_BuildValue("(nO)", _i, _value);
|
||||||
PyObject* result = SbkQString_replace(self, args);
|
PyObject* result = SbkQStringFunc_replace(self, args);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
return !result ? -1 : 0;
|
return !result ? -1 : 0;
|
||||||
|
|
@ -1236,7 +1236,7 @@
|
||||||
<add-function signature="__setitem__">
|
<add-function signature="__setitem__">
|
||||||
<inject-code class="target" position="beginning">
|
<inject-code class="target" position="beginning">
|
||||||
PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value);
|
PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value);
|
||||||
PyObject* result = SbkQBitArray_setBit(self, args);
|
PyObject* result = SbkQBitArrayFunc_setBit(self, args);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
return !result ? -1 : 0;
|
return !result ? -1 : 0;
|
||||||
|
|
@ -1636,7 +1636,7 @@
|
||||||
<add-function signature="__setitem__">
|
<add-function signature="__setitem__">
|
||||||
<inject-code class="target" position="beginning">
|
<inject-code class="target" position="beginning">
|
||||||
PyObject* args = Py_BuildValue("(nO)", _i, _value);
|
PyObject* args = Py_BuildValue("(nO)", _i, _value);
|
||||||
PyObject* result = SbkQStringList_replace(self, args);
|
PyObject* result = SbkQStringListFunc_replace(self, args);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
return !result ? -1 : 0;
|
return !result ? -1 : 0;
|
||||||
|
|
@ -1980,7 +1980,7 @@
|
||||||
<add-function signature="__setitem__">
|
<add-function signature="__setitem__">
|
||||||
<inject-code class="target" position="beginning">
|
<inject-code class="target" position="beginning">
|
||||||
PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value);
|
PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value);
|
||||||
PyObject* result = SbkQByteArray_replace(self, args);
|
PyObject* result = SbkQByteArrayFunc_replace(self, args);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
return !result ? -1 : 0;
|
return !result ? -1 : 0;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ set(libpyside_SRC
|
||||||
dynamicqmetaobject.cpp
|
dynamicqmetaobject.cpp
|
||||||
signalmanager.cpp
|
signalmanager.cpp
|
||||||
globalreceiver.cpp
|
globalreceiver.cpp
|
||||||
typeresolver.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ int GlobalReceiver::qt_metacall(QMetaObject::Call call, int id, void** args)
|
||||||
numArgs = paramTypes.count();
|
numArgs = paramTypes.count();
|
||||||
Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count()));
|
Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count()));
|
||||||
for (int i = 0, max = paramTypes.count(); i < max; ++i) {
|
for (int i = 0, max = paramTypes.count(); i < max; ++i) {
|
||||||
PyObject* arg = TypeResolver::get(paramTypes[i].constData())->toPython(args[i+1]);
|
PyObject* arg = Shiboken::TypeResolver::get(paramTypes[i].constData())->toPython(args[i+1]);
|
||||||
PyTuple_SET_ITEM(preparedArgs.object(), i, arg);
|
PyTuple_SET_ITEM(preparedArgs.object(), i, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,13 @@
|
||||||
#include <autodecref.h>
|
#include <autodecref.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <typeresolver.h>
|
||||||
|
|
||||||
#if QSLOT_CODE != 1 || QSIGNAL_CODE != 2
|
#if QSLOT_CODE != 1 || QSIGNAL_CODE != 2
|
||||||
#error QSLOT_CODE and/or QSIGNAL_CODE changed! change the hardcoded stuff to the correct value!
|
#error QSLOT_CODE and/or QSIGNAL_CODE changed! change the hardcoded stuff to the correct value!
|
||||||
#endif
|
#endif
|
||||||
#define PYSIDE_SLOT '1'
|
#define PYSIDE_SLOT '1'
|
||||||
#define PYSIDE_SIGNAL '2'
|
#define PYSIDE_SIGNAL '2'
|
||||||
#include "typeresolver.h"
|
|
||||||
#include "globalreceiver.h"
|
#include "globalreceiver.h"
|
||||||
|
|
||||||
using namespace PySide;
|
using namespace PySide;
|
||||||
|
|
@ -199,11 +199,11 @@ static bool emitNormalSignal(QObject* source, int signalIndex, const char* signa
|
||||||
signalArgs[0] = 0;
|
signalArgs[0] = 0;
|
||||||
|
|
||||||
for (int i = 0; i < argsGiven; ++i)
|
for (int i = 0; i < argsGiven; ++i)
|
||||||
signalArgs[i+1] = TypeResolver::get(argTypes[i])->toCpp(PySequence_GetItem(args, i));
|
signalArgs[i+1] = Shiboken::TypeResolver::get(qPrintable(argTypes[i]))->toCpp(PySequence_GetItem(args, i));
|
||||||
QMetaObject::activate(source, signalIndex, signalArgs);
|
QMetaObject::activate(source, signalIndex, signalArgs);
|
||||||
// FIXME: This will cause troubles with non-direct connections.
|
// FIXME: This will cause troubles with non-direct connections.
|
||||||
for (int i = 0; i < argsGiven; ++i)
|
for (int i = 0; i < argsGiven; ++i)
|
||||||
TypeResolver::get(argTypes[i])->deleteObject(signalArgs[i+1]);
|
Shiboken::TypeResolver::get(qPrintable(argTypes[i]))->deleteObject(signalArgs[i+1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,7 +248,7 @@ int PySide::SignalManager::qt_metacall(QObject* object, QMetaObject::Call call,
|
||||||
Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count()));
|
Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count()));
|
||||||
|
|
||||||
for (int i = 0, max = paramTypes.count(); i < max; ++i) {
|
for (int i = 0, max = paramTypes.count(); i < max; ++i) {
|
||||||
PyObject* arg = TypeResolver::get(paramTypes[i].constData())->toPython(args[i+1]);
|
PyObject* arg = Shiboken::TypeResolver::get(paramTypes[i].constData())->toPython(args[i+1]);
|
||||||
PyTuple_SET_ITEM(preparedArgs.object(), i, arg);
|
PyTuple_SET_ITEM(preparedArgs.object(), i, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,124 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the Shiboken Python Bindings Generator project.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
*
|
|
||||||
* Contact: PySide team <contact@pyside.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
|
||||||
* version 2.1 as published by the Free Software Foundation. Please
|
|
||||||
* review the following information to ensure the GNU Lesser General
|
|
||||||
* Public License version 2.1 requirements will be met:
|
|
||||||
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
*
|
|
||||||
* As a special exception to the GNU Lesser General Public License
|
|
||||||
* version 2.1, the object code form of a "work that uses the Library"
|
|
||||||
* may incorporate material from a header file that is part of the
|
|
||||||
* Library. You may distribute such object code under terms of your
|
|
||||||
* choice, provided that the incorporated material (i) does not exceed
|
|
||||||
* more than 5% of the total size of the Library; and (ii) is limited to
|
|
||||||
* numerical parameters, data structure layouts, accessors, macros,
|
|
||||||
* inline functions and templates.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
||||||
* 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "typeresolver.h"
|
|
||||||
#include <QHash>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
using namespace PySide;
|
|
||||||
|
|
||||||
static QHash<QLatin1String, TypeResolver*> typeResolverMap;
|
|
||||||
|
|
||||||
struct TypeResolver::TypeResolverPrivate
|
|
||||||
{
|
|
||||||
const char* typeName; // maybe this is not needed anymore
|
|
||||||
CppToPythonFunc cppToPython;
|
|
||||||
PythonToCppFunc pythonToCpp;
|
|
||||||
DeleteObjectFunc deleteObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void deinitTypeResolver()
|
|
||||||
{
|
|
||||||
qDeleteAll(typeResolverMap);
|
|
||||||
typeResolverMap.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void registerTypeResolver(TypeResolver* resolver)
|
|
||||||
{
|
|
||||||
static bool initied = false;
|
|
||||||
if (!initied) {
|
|
||||||
Q_ASSERT(typeResolverMap.isEmpty());
|
|
||||||
initied = true;
|
|
||||||
std::atexit(deinitTypeResolver);
|
|
||||||
TypeResolver::createValueTypeResolver<double>("double");
|
|
||||||
TypeResolver::createValueTypeResolver<float>("float");
|
|
||||||
TypeResolver::createValueTypeResolver<qreal>("qreal");
|
|
||||||
TypeResolver::createValueTypeResolver<bool>("bool");
|
|
||||||
TypeResolver::createValueTypeResolver<int>("int");
|
|
||||||
TypeResolver::createValueTypeResolver<qint64>("qint64");
|
|
||||||
}
|
|
||||||
Q_ASSERT(!typeResolverMap.contains(QLatin1String(resolver->typeName())));
|
|
||||||
typeResolverMap[QLatin1String(resolver->typeName())] = resolver;
|
|
||||||
}
|
|
||||||
|
|
||||||
TypeResolver::TypeResolver(const char* typeName, TypeResolver::CppToPythonFunc cppToPy, TypeResolver::PythonToCppFunc pyToCpp, TypeResolver::DeleteObjectFunc deleter)
|
|
||||||
{
|
|
||||||
m_d = new TypeResolverPrivate;
|
|
||||||
m_d->typeName = typeName;
|
|
||||||
m_d->cppToPython = cppToPy;
|
|
||||||
m_d->pythonToCpp = pyToCpp;
|
|
||||||
m_d->deleteObject = deleter;
|
|
||||||
|
|
||||||
registerTypeResolver(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
TypeResolver::~TypeResolver()
|
|
||||||
{
|
|
||||||
delete m_d;
|
|
||||||
}
|
|
||||||
|
|
||||||
PySide::TypeResolver* TypeResolver::get(const QString& typeName)
|
|
||||||
{
|
|
||||||
QByteArray data = typeName.toAscii();
|
|
||||||
return get(data.constData());
|
|
||||||
}
|
|
||||||
|
|
||||||
PySide::TypeResolver* TypeResolver::get(const char* typeName)
|
|
||||||
{
|
|
||||||
Q_ASSERT(typeResolverMap.contains(QLatin1String(typeName)));
|
|
||||||
return typeResolverMap.value(QLatin1String(typeName));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* TypeResolver::typeName() const
|
|
||||||
{
|
|
||||||
return m_d->typeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* TypeResolver::toCpp(PyObject* pyObj)
|
|
||||||
{
|
|
||||||
return m_d->pythonToCpp(pyObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject* TypeResolver::toPython(void* cppObj)
|
|
||||||
{
|
|
||||||
return m_d->cppToPython(cppObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TypeResolver::deleteObject(void* object)
|
|
||||||
{
|
|
||||||
if (m_d->deleteObject)
|
|
||||||
m_d->deleteObject(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,111 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the Shiboken Python Bindings Generator project.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
*
|
|
||||||
* Contact: PySide team <contact@pyside.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
|
||||||
* version 2.1 as published by the Free Software Foundation. Please
|
|
||||||
* review the following information to ensure the GNU Lesser General
|
|
||||||
* Public License version 2.1 requirements will be met:
|
|
||||||
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
*
|
|
||||||
* As a special exception to the GNU Lesser General Public License
|
|
||||||
* version 2.1, the object code form of a "work that uses the Library"
|
|
||||||
* may incorporate material from a header file that is part of the
|
|
||||||
* Library. You may distribute such object code under terms of your
|
|
||||||
* choice, provided that the incorporated material (i) does not exceed
|
|
||||||
* more than 5% of the total size of the Library; and (ii) is limited to
|
|
||||||
* numerical parameters, data structure layouts, accessors, macros,
|
|
||||||
* inline functions and templates.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
||||||
* 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TYPERESOLVER_H
|
|
||||||
#define TYPERESOLVER_H
|
|
||||||
|
|
||||||
#include "pysidemacros.h"
|
|
||||||
#include "conversions.h"
|
|
||||||
#include <Python.h>
|
|
||||||
#include <QGenericArgument>
|
|
||||||
|
|
||||||
namespace PySide
|
|
||||||
{
|
|
||||||
|
|
||||||
/* To C++ convertion functions. */
|
|
||||||
template <class T>
|
|
||||||
inline void* pythonToValueType(PyObject* pyobj)
|
|
||||||
{
|
|
||||||
return Shiboken::CppObjectCopier<T>::copy(Shiboken::Converter<T>::toCpp(pyobj));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
inline void* pythonToObjectType(PyObject* pyobj)
|
|
||||||
{
|
|
||||||
return Shiboken::Converter<T>::toCpp(pyobj);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
inline void objectDeleter(void* data)
|
|
||||||
{
|
|
||||||
delete reinterpret_cast<T*>(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline PyObject* objectTypeToPython(void* cptr)
|
|
||||||
{
|
|
||||||
return Shiboken::Converter<T>::toPython(*(T*)cptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
class PYSIDE_API TypeResolver
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef PyObject* (*CppToPythonFunc)(void*);
|
|
||||||
typedef void* (*PythonToCppFunc)(PyObject*);
|
|
||||||
typedef void (*DeleteObjectFunc)(void*);
|
|
||||||
|
|
||||||
~TypeResolver();
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static TypeResolver* createValueTypeResolver(const char* typeName)
|
|
||||||
{
|
|
||||||
return new TypeResolver(typeName, &Shiboken::Converter<T>::toPython, &pythonToValueType<T>, &objectDeleter<T>);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static TypeResolver* createObjectTypeResolver(const char* typeName)
|
|
||||||
{
|
|
||||||
return new TypeResolver(typeName, &objectTypeToPython<T>, &pythonToObjectType<T>);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TypeResolver* get(const char* typeName);
|
|
||||||
static TypeResolver* get(const QString& typeName);
|
|
||||||
|
|
||||||
const char* typeName() const;
|
|
||||||
PyObject* toPython(void* cppObj);
|
|
||||||
void* toCpp(PyObject* pyObj);
|
|
||||||
void deleteObject(void* object);
|
|
||||||
private:
|
|
||||||
struct TypeResolverPrivate;
|
|
||||||
TypeResolverPrivate* m_d;
|
|
||||||
|
|
||||||
// disable object copy
|
|
||||||
TypeResolver(const TypeResolver&);
|
|
||||||
TypeResolver& operator=(const TypeResolver&);
|
|
||||||
|
|
||||||
TypeResolver(const char* typeName, CppToPythonFunc cppToPy, PythonToCppFunc pyToCpp, DeleteObjectFunc deleter = 0);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue