aboutsummaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-01-14 16:42:38 -0200
committerHugo Lima <hugo.lima@openbossa.org>2010-01-14 16:45:14 -0200
commit0e649b3e3874fb237be0b0ca02a04e7708325e06 (patch)
tree9b8f67048260e347b07ce360d593319f326ea796 /libpyside
parentad2d6b21584e608f39379491eb0acd338899c4c9 (diff)
Adapt to changed in libshiboken API.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/CMakeLists.txt1
-rw-r--r--libpyside/globalreceiver.cpp2
-rw-r--r--libpyside/signalmanager.cpp8
-rw-r--r--libpyside/typeresolver.cpp124
-rw-r--r--libpyside/typeresolver.h111
5 files changed, 5 insertions, 241 deletions
diff --git a/libpyside/CMakeLists.txt b/libpyside/CMakeLists.txt
index 4a5049554..c690b5a87 100644
--- a/libpyside/CMakeLists.txt
+++ b/libpyside/CMakeLists.txt
@@ -4,7 +4,6 @@ set(libpyside_SRC
dynamicqmetaobject.cpp
signalmanager.cpp
globalreceiver.cpp
-typeresolver.cpp
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/libpyside/globalreceiver.cpp b/libpyside/globalreceiver.cpp
index 333268081..a52db7be2 100644
--- a/libpyside/globalreceiver.cpp
+++ b/libpyside/globalreceiver.cpp
@@ -178,7 +178,7 @@ int GlobalReceiver::qt_metacall(QMetaObject::Call call, int id, void** args)
numArgs = paramTypes.count();
Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count()));
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);
}
diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp
index 6ac0cb7c0..5fcb95c54 100644
--- a/libpyside/signalmanager.cpp
+++ b/libpyside/signalmanager.cpp
@@ -40,13 +40,13 @@
#include <autodecref.h>
#include <QDebug>
#include <limits>
+#include <typeresolver.h>
#if QSLOT_CODE != 1 || QSIGNAL_CODE != 2
#error QSLOT_CODE and/or QSIGNAL_CODE changed! change the hardcoded stuff to the correct value!
#endif
#define PYSIDE_SLOT '1'
#define PYSIDE_SIGNAL '2'
-#include "typeresolver.h"
#include "globalreceiver.h"
using namespace PySide;
@@ -199,11 +199,11 @@ static bool emitNormalSignal(QObject* source, int signalIndex, const char* signa
signalArgs[0] = 0;
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);
// FIXME: This will cause troubles with non-direct connections.
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;
}
@@ -248,7 +248,7 @@ int PySide::SignalManager::qt_metacall(QObject* object, QMetaObject::Call call,
Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count()));
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);
}
diff --git a/libpyside/typeresolver.cpp b/libpyside/typeresolver.cpp
deleted file mode 100644
index 49ca19f75..000000000
--- a/libpyside/typeresolver.cpp
+++ /dev/null
@@ -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);
-}
-
diff --git a/libpyside/typeresolver.h b/libpyside/typeresolver.h
deleted file mode 100644
index bb59f83e8..000000000
--- a/libpyside/typeresolver.h
+++ /dev/null
@@ -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