aboutsummaryrefslogtreecommitdiffstats
path: root/PySide
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-12-11 23:13:12 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:56:21 -0300
commit7bfbbf3cb784f8e22dde74ebe28ba5e5eda4b7db (patch)
tree0bd9c001bd2d6ff30f34c39aaf1a28c6233ffb43 /PySide
parentaec20b21a5cfc678c8bd1e017d2300542edfbce7 (diff)
No more training wheels. The last occurrences of the old template Converter where removed.
Also related fixes here and there.
Diffstat (limited to 'PySide')
-rw-r--r--PySide/QtCore/glue/hwnd_conversions.h54
-rw-r--r--PySide/QtCore/glue/qbytearray_bufferprotocol.cpp2
-rw-r--r--PySide/QtCore/glue/qeasingcurve_glue.cpp2
-rw-r--r--PySide/QtCore/glue/qobject_connect.cpp8
-rw-r--r--PySide/QtCore/qbool_conversions.h16
-rw-r--r--PySide/QtCore/qbytearray_conversions.h44
-rw-r--r--PySide/QtCore/qchar_conversions.h35
-rw-r--r--PySide/QtCore/qdate_conversions.h53
-rw-r--r--PySide/QtCore/qdatetime_conversions.h56
-rw-r--r--PySide/QtCore/qhash_conversions.h4
-rw-r--r--PySide/QtCore/qlist_conversions.h4
-rw-r--r--PySide/QtCore/qmap_conversions.h5
-rw-r--r--PySide/QtCore/qmultimap_conversions.h5
-rw-r--r--PySide/QtCore/qpair_conversions.h4
-rw-r--r--PySide/QtCore/qset_conversions.h4
-rw-r--r--PySide/QtCore/qstack_conversion.h4
-rw-r--r--PySide/QtCore/qstring_conversions.h49
-rw-r--r--PySide/QtCore/qstringlist_conversions.h5
-rw-r--r--PySide/QtCore/qstringref_conversions.h18
-rw-r--r--PySide/QtCore/qtime_conversions.h45
-rw-r--r--PySide/QtCore/qvariant_conversions.h219
-rw-r--r--PySide/QtCore/qvariant_type_conversions.h87
-rw-r--r--PySide/QtCore/qvector_conversions.h4
-rw-r--r--PySide/QtCore/typesystem_core_common.xml65
-rw-r--r--PySide/QtCore/typesystem_core_win.xml2
-rw-r--r--PySide/QtDeclarative/pysideqmlregistertype.cpp19
-rw-r--r--PySide/QtGui/glue/qlayout_help_functions.cpp (renamed from PySide/QtGui/glue/qlayout_help_functions.h)38
-rw-r--r--PySide/QtGui/glue/qmenu_glue.cpp (renamed from PySide/QtGui/glue/qmenu_glue.h)3
-rw-r--r--PySide/QtGui/glue/qmenubar_glue.cpp (renamed from PySide/QtGui/glue/qmenubar_glue.h)2
-rw-r--r--PySide/QtGui/glue/qtgui_qapp.cpp2
-rw-r--r--PySide/QtGui/glue/qwidget_glue.cpp (renamed from PySide/QtGui/glue/qwidget_glue.h)8
-rw-r--r--PySide/QtGui/glue/wid_conversions.h39
-rw-r--r--PySide/QtGui/qpixmap_conversion.h49
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml41
-rw-r--r--PySide/QtGui/typesystem_gui_win.xml2
-rw-r--r--PySide/QtUiTools/glue/uitools_loadui.cpp (renamed from PySide/QtUiTools/glue/uitools_loadui.h)8
-rw-r--r--PySide/QtUiTools/typesystem_uitools.xml7
-rw-r--r--PySide/QtWebKit/typesystem_webkit.xml4
38 files changed, 99 insertions, 917 deletions
diff --git a/PySide/QtCore/glue/hwnd_conversions.h b/PySide/QtCore/glue/hwnd_conversions.h
deleted file mode 100644
index 6dbaa8f4e..000000000
--- a/PySide/QtCore/glue/hwnd_conversions.h
+++ /dev/null
@@ -1,54 +0,0 @@
-namespace Shiboken {
-template <>
-struct Converter<HWND>
-{
- static bool checkType(PyObject* pyObj)
- {
- return false;
- }
-
- static bool isConvertible(PyObject* pyobj)
- {
- if (pyobj == Py_None)
- return true;
-
-#ifdef IS_PY3K
- return PyCapsule_CheckExact(pyobj);
-#else
- return PyCObject_Check(pyobj);
-#endif
- }
-
- static inline PyObject* toPython(void* cppobj)
- {
- // not supported
- Q_ASSERT(true);
- return 0;
- }
-
- static PyObject* toPython(HWND cppobj)
- {
- if (!cppobj)
- Py_RETURN_NONE;
-
-#ifdef IS_PY3K
- return PyCapsule_New(cppobj, 0, 0);
-#else
- return PyCObject_FromVoidPtr(cppobj, 0);
-#endif
- }
-
- static HWND toCpp(PyObject* pyobj)
- {
- if (pyobj == Py_None)
- return 0;
-
-#ifdef IS_PY3K
- return (HWND)PyCapsule_GetPointer(pyobj, 0);
-#else
- return (HWND)PyCObject_AsVoidPtr(pyobj);
-#endif
- }
-};
-
-}
diff --git a/PySide/QtCore/glue/qbytearray_bufferprotocol.cpp b/PySide/QtCore/glue/qbytearray_bufferprotocol.cpp
index 03ffcb4af..acc7bb93e 100644
--- a/PySide/QtCore/glue/qbytearray_bufferprotocol.cpp
+++ b/PySide/QtCore/glue/qbytearray_bufferprotocol.cpp
@@ -18,7 +18,7 @@ static Py_ssize_t SbkQByteArray_readbufferproc(PyObject* self, Py_ssize_t segmen
if (segment || !Shiboken::Object::isValid(self))
return -1;
- QByteArray* cppSelf = Shiboken::Converter<QByteArray*>::toCpp(self);
+ QByteArray* cppSelf = %CONVERTTOCPP[QByteArray*](self);
*ptrptr = reinterpret_cast<void*>(cppSelf->data());
return cppSelf->size();
}
diff --git a/PySide/QtCore/glue/qeasingcurve_glue.cpp b/PySide/QtCore/glue/qeasingcurve_glue.cpp
index fd2dee092..7f56315b3 100644
--- a/PySide/QtCore/glue/qeasingcurve_glue.cpp
+++ b/PySide/QtCore/glue/qeasingcurve_glue.cpp
@@ -93,7 +93,7 @@ qreal PySideEasingCurveFunctor::operator()(qreal progress)
PyObject* result = PyObject_CallObject(m_func, args);
qreal cppResult = 0.0;
if (result) {
- cppResult = Shiboken::Converter<qreal>::toCpp(result);
+ Shiboken::Conversions::pythonToCppCopy(Shiboken::Conversions::PrimitiveTypeConverter<qreal>(), result, &cppResult);
Py_DECREF(result);
}
Py_DECREF(args);
diff --git a/PySide/QtCore/glue/qobject_connect.cpp b/PySide/QtCore/glue/qobject_connect.cpp
index b46cbcfbc..96bcfb227 100644
--- a/PySide/QtCore/glue/qobject_connect.cpp
+++ b/PySide/QtCore/glue/qobject_connect.cpp
@@ -13,13 +13,13 @@ static bool getReceiver(QObject *source, const char* signal, PyObject* callback,
bool forceGlobalReceiver = false;
if (PyMethod_Check(callback)) {
*self = PyMethod_GET_SELF(callback);
- if (Shiboken::Converter<QObject*>::checkType(*self))
- *receiver = Shiboken::Converter<QObject*>::toCpp(*self);
+ if (%CHECKTYPE[QObject*](*self))
+ *receiver = %CONVERTTOCPP[QObject*](*self);
forceGlobalReceiver = isDecorator(callback, *self);
} else if (PyCFunction_Check(callback)) {
*self = PyCFunction_GET_SELF(callback);
- if (*self && Shiboken::Converter<QObject*>::checkType(*self))
- *receiver = Shiboken::Converter<QObject*>::toCpp(*self);
+ if (*self && %CHECKTYPE[QObject*](*self))
+ *receiver = %CONVERTTOCPP[QObject*](*self);
} else if (PyCallable_Check(callback)) {
// Ok, just a callable object
*receiver = 0;
diff --git a/PySide/QtCore/qbool_conversions.h b/PySide/QtCore/qbool_conversions.h
deleted file mode 100644
index f4fb43fa6..000000000
--- a/PySide/QtCore/qbool_conversions.h
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace Shiboken {
-template <>
-struct Converter<QBool> : public ValueTypeConverter<QBool>
-{
- using ValueTypeConverter<QBool>::toPython;
-
- static PyObject* toPython(const QBool& cppobj)
- {
- return PyBool_FromLong((bool) cppobj);
- }
- static QBool toCpp(PyObject* pyobj)
- {
- return QBool(pyobj == Py_True);
- }
-};
-}
diff --git a/PySide/QtCore/qbytearray_conversions.h b/PySide/QtCore/qbytearray_conversions.h
deleted file mode 100644
index d776d82c4..000000000
--- a/PySide/QtCore/qbytearray_conversions.h
+++ /dev/null
@@ -1,44 +0,0 @@
-namespace Shiboken {
-
-inline bool Converter<QByteArray>::checkType(PyObject* pyObj)
-{
- return ValueTypeConverter<QByteArray>::checkType(pyObj);
-}
-
-inline bool Converter<QByteArray>::isConvertible(PyObject* pyObj)
-{
- if (ValueTypeConverter<QByteArray>::isConvertible(pyObj))
- return true;
- SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType< ::QByteArray >());
- return Shiboken::Converter<const char *>::checkType(pyObj)
- || PyBytes_Check(pyObj)
- || (ObjectType::isExternalConvertible(shiboType, pyObj));
-}
-
-inline QByteArray Converter<QByteArray>::toCpp(PyObject* pyObj)
-{
- if (pyObj == Py_None) {
- return 0;
- } else if (PyObject_TypeCheck(pyObj, SbkType<QByteArray>())) {
- return *Converter<QByteArray*>::toCpp(pyObj);
- } else if (PyBytes_Check(pyObj)) {
- return QByteArray(PyBytes_AS_STRING(pyObj), PyBytes_GET_SIZE(pyObj));
- } else if (PyUnicode_Check(pyObj)) {
- Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(pyObj));
- if (!data.isNull())
- return QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
- else
- return QByteArray();
- } else if (Shiboken::String::check(pyObj)) {
- return QByteArray(Shiboken::String::toCString(pyObj));
- } else {
- return ValueTypeConverter<QByteArray>::toCpp(pyObj);
- }
-}
-
-inline PyObject* Converter<QByteArray>::toPython(const ::QByteArray& cppObj)
-{
- return ValueTypeConverter<QByteArray>::toPython(cppObj);
-}
-
-}
diff --git a/PySide/QtCore/qchar_conversions.h b/PySide/QtCore/qchar_conversions.h
deleted file mode 100644
index f79bac3c7..000000000
--- a/PySide/QtCore/qchar_conversions.h
+++ /dev/null
@@ -1,35 +0,0 @@
-namespace Shiboken {
-
-template<>
-struct Converter<QChar>
-{
- static bool checkType(PyObject* pyObj)
- {
- return Shiboken::String::check(pyObj) && (Shiboken::String::len(pyObj) == 1);
- }
-
- static bool isConvertible(PyObject* pyObj)
- {
- return (Shiboken::String::check(pyObj) && (Shiboken::String::len(pyObj) == 1))
- || pyObj == Py_None
- || PyInt_Check(pyObj);
- }
-
- static QChar toCpp(PyObject* pyObj)
- {
- if (Shiboken::String::check(pyObj) && (Shiboken::String::len(pyObj) == 1))
- return QChar(Shiboken::Converter<char >::toCpp(pyObj));
- else if (PyInt_Check(pyObj))
- return QChar(Shiboken::Converter<int >::toCpp(pyObj));
- return QChar();
- }
-
- static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<QChar*>(cppObj)); }
- static PyObject* toPython(const QChar& cppObj)
- {
- wchar_t c = (wchar_t)cppObj.unicode();
- PyObject* pyObj = PyUnicode_FromWideChar(&c, 1);
- return pyObj;
- }
-};
-}
diff --git a/PySide/QtCore/qdate_conversions.h b/PySide/QtCore/qdate_conversions.h
deleted file mode 100644
index 0d97a057a..000000000
--- a/PySide/QtCore/qdate_conversions.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifdef IS_PY3K
-#define PySideDateTime_IMPORT PyDateTime_IMPORT
-#else
-#define PySideDateTime_IMPORT \
- PyDateTimeAPI = (PyDateTime_CAPI*) PyCObject_Import((char*)"datetime", \
- (char*)"datetime_CAPI")
-#endif
-
-namespace Shiboken {
-
-inline bool Converter<QDate>::checkType(PyObject* pyObj)
-{
- return ValueTypeConverter<QDate>::checkType(pyObj);
-}
-
-inline PyObject* Converter<QDate>::toPython(const ::QDate& cppObj)
-{
- return ValueTypeConverter<QDate>::toPython(cppObj);
-}
-
-inline bool Converter<QDate>::isConvertible(PyObject* pyObj)
-{
- if (ValueTypeConverter<QDate>::isConvertible(pyObj))
- return true;
-
- if (!PyDateTimeAPI)
- PySideDateTime_IMPORT;
-
- SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType< ::QDate >());
- return PyDate_Check(pyObj) || ObjectType::isExternalConvertible(shiboType, pyObj);
-}
-
-inline QDate Converter<QDate>::toCpp(PyObject* pyObj)
-{
- if (!PyDateTimeAPI)
- PySideDateTime_IMPORT;
-
- if (pyObj == Py_None) {
- return QDate();
- } else if (PyObject_TypeCheck(pyObj, SbkType<QDate>())) {
- return *Converter<QDate*>::toCpp(pyObj);
- } else if (PyDate_Check(pyObj)) {
- int day = PyDateTime_GET_DAY(pyObj);
- int month = PyDateTime_GET_MONTH(pyObj);
- int year = PyDateTime_GET_YEAR(pyObj);
- return QDate(year, month, day);
- } else {
- return ValueTypeConverter<QDate>::toCpp(pyObj);
- }
-}
-
-
-}
diff --git a/PySide/QtCore/qdatetime_conversions.h b/PySide/QtCore/qdatetime_conversions.h
deleted file mode 100644
index bcf9ad3fe..000000000
--- a/PySide/QtCore/qdatetime_conversions.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifdef IS_PY3K
-#define PySideDateTime_IMPORT PyDateTime_IMPORT
-#else
-#define PySideDateTime_IMPORT \
- PyDateTimeAPI = (PyDateTime_CAPI*) PyCObject_Import((char*)"datetime", \
- (char*)"datetime_CAPI")
-#endif
-namespace Shiboken {
-
-inline bool Converter<QDateTime>::checkType(PyObject* pyObj)
-{
- return ValueTypeConverter<QDateTime>::checkType(pyObj);
-}
-
-inline PyObject* Converter<QDateTime>::toPython(const ::QDateTime& cppObj)
-{
- return ValueTypeConverter<QDateTime>::toPython(cppObj);
-}
-
-inline bool Converter<QDateTime>::isConvertible(PyObject* pyObj)
-{
- if (ValueTypeConverter<QDateTime>::isConvertible(pyObj))
- return true;
-
- if (!PyDateTimeAPI)
- PySideDateTime_IMPORT;
-
- SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType< ::QDateTime >());
- return PyDateTime_Check(pyObj) || ObjectType::isExternalConvertible(shiboType, pyObj);
-}
-
-
-inline QDateTime Converter<QDateTime>::toCpp(PyObject* pyObj)
-{
- if (!PyDateTimeAPI)
- PySideDateTime_IMPORT;
-
- if (pyObj == Py_None) {
- return QDateTime();
- } else if (PyObject_TypeCheck(pyObj, SbkType<QDateTime>())) {
- return *Converter<QDateTime*>::toCpp(pyObj);
- } else if (PyDateTime_Check(pyObj)) {
- int day = PyDateTime_GET_DAY(pyObj);
- int month = PyDateTime_GET_MONTH(pyObj);
- int year = PyDateTime_GET_YEAR(pyObj);
- int hour = PyDateTime_DATE_GET_HOUR(pyObj);
- int min = PyDateTime_DATE_GET_MINUTE(pyObj);
- int sec = PyDateTime_DATE_GET_SECOND(pyObj);
- int usec = PyDateTime_DATE_GET_MICROSECOND(pyObj);
- return QDateTime(QDate(year, month, day), QTime(hour, min, sec, usec/1000));
- } else {
- return ValueTypeConverter<QDateTime>::toCpp(pyObj);
- }
-}
-
-}
diff --git a/PySide/QtCore/qhash_conversions.h b/PySide/QtCore/qhash_conversions.h
deleted file mode 100644
index f9e2e4217..000000000
--- a/PySide/QtCore/qhash_conversions.h
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace Shiboken {
-template<typename KT, typename VT>
-struct Converter<QHash<KT, VT> > : QtDictConverter<QHash<KT, VT> > {};
-}
diff --git a/PySide/QtCore/qlist_conversions.h b/PySide/QtCore/qlist_conversions.h
deleted file mode 100644
index cb1d26bd5..000000000
--- a/PySide/QtCore/qlist_conversions.h
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace Shiboken {
-template<typename T>
-struct Converter<QList<T> > : StdListConverter<QList<T> > {};
-}
diff --git a/PySide/QtCore/qmap_conversions.h b/PySide/QtCore/qmap_conversions.h
deleted file mode 100644
index 3153fae92..000000000
--- a/PySide/QtCore/qmap_conversions.h
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace Shiboken {
-template<typename KT, typename VT>
-struct Converter<QMap<KT, VT> > : QtDictConverter<QMap<KT, VT> > {
-};
-}
diff --git a/PySide/QtCore/qmultimap_conversions.h b/PySide/QtCore/qmultimap_conversions.h
deleted file mode 100644
index 43abd84df..000000000
--- a/PySide/QtCore/qmultimap_conversions.h
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace Shiboken {
-template<typename KT, typename VT>
-struct Converter<QMultiMap<KT, VT> > : QtMultiMapConverter<QMap<KT, VT> > {
-};
-}
diff --git a/PySide/QtCore/qpair_conversions.h b/PySide/QtCore/qpair_conversions.h
deleted file mode 100644
index 99e9cd8b8..000000000
--- a/PySide/QtCore/qpair_conversions.h
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace Shiboken {
-template<typename FT, typename ST>
-struct Converter<QPair<FT, ST> > : StdPairConverter<QPair<FT, ST> > {};
-}
diff --git a/PySide/QtCore/qset_conversions.h b/PySide/QtCore/qset_conversions.h
deleted file mode 100644
index c46fef00b..000000000
--- a/PySide/QtCore/qset_conversions.h
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace Shiboken {
-template<typename T>
-struct Converter<QSet<T> > : QSequenceConverter<QSet<T> > {};
-}
diff --git a/PySide/QtCore/qstack_conversion.h b/PySide/QtCore/qstack_conversion.h
deleted file mode 100644
index 709a91891..000000000
--- a/PySide/QtCore/qstack_conversion.h
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace Shiboken {
-template<typename T>
-struct Converter<QStack<T> > : StdListConverter<QStack<T> > {};
-}
diff --git a/PySide/QtCore/qstring_conversions.h b/PySide/QtCore/qstring_conversions.h
deleted file mode 100644
index 33c393b1f..000000000
--- a/PySide/QtCore/qstring_conversions.h
+++ /dev/null
@@ -1,49 +0,0 @@
-namespace Shiboken {
-
-template<>
-inline PyTypeObject* SbkType<QString>()
-{
- return &PyUnicode_Type;
-}
-
-template<>
-struct Converter<QString>
-{
- static bool checkType(PyObject* pyObj)
- {
- return Shiboken::String::check(pyObj);
- }
-
- static bool isConvertible(PyObject* pyObj)
- {
- return Shiboken::String::isConvertible(pyObj);
- }
-
- static QString toCpp(PyObject* pyObj)
- {
- if (PyUnicode_Check(pyObj)) {
- Py_UNICODE* unicode = PyUnicode_AS_UNICODE(pyObj);
- #if defined(Py_UNICODE_WIDE) || defined(__CYGWIN__)
- // cast as Py_UNICODE can be a different type
- return QString::fromUcs4(reinterpret_cast<const uint*>(unicode));
- #else
- return QString::fromUtf16(unicode, PyUnicode_GET_SIZE(pyObj));
- #endif
- } else if (Shiboken::String::check(pyObj)) {
- return QString(Shiboken::String::toCString(pyObj));
- }
- return QString();
- }
-
- static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<QString*>(cppObj)); }
- static PyObject* toPython(const QString& cppObj)
- {
- const int N = cppObj.length();
- wchar_t* str = new wchar_t[N];
- cppObj.toWCharArray(str);
- PyObject* pyObj = PyUnicode_FromWideChar(str, N);
- delete[] str;
- return pyObj;
- }
-};
-}
diff --git a/PySide/QtCore/qstringlist_conversions.h b/PySide/QtCore/qstringlist_conversions.h
deleted file mode 100644
index 6075c1672..000000000
--- a/PySide/QtCore/qstringlist_conversions.h
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace Shiboken
-{
-template<>
-struct Converter<QStringList> : StdListConverter<QStringList> {};
-}
diff --git a/PySide/QtCore/qstringref_conversions.h b/PySide/QtCore/qstringref_conversions.h
deleted file mode 100644
index db3eefcae..000000000
--- a/PySide/QtCore/qstringref_conversions.h
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace Shiboken {
-
-template<>
-struct Converter<QStringRef> : public Converter<QString>
-{
- static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<QStringRef*>(cppObj)); }
-
- static PyObject* toPython(const QStringRef& cppObj)
- {
- return Converter<QString>::toPython(cppObj.toString());
- }
-
- static QStringRef toCpp(PyObject* pyObj)
- {
- return QStringRef();
- }
-};
-}
diff --git a/PySide/QtCore/qtime_conversions.h b/PySide/QtCore/qtime_conversions.h
deleted file mode 100644
index 4600ef758..000000000
--- a/PySide/QtCore/qtime_conversions.h
+++ /dev/null
@@ -1,45 +0,0 @@
-namespace Shiboken {
-
-inline bool Converter<QTime>::checkType(PyObject* pyObj)
-{
- return ValueTypeConverter<QTime>::checkType(pyObj);
-}
-
-inline PyObject* Converter<QTime>::toPython(const ::QTime& cppObj)
-{
- return ValueTypeConverter<QTime>::toPython(cppObj);
-}
-
-inline bool Converter<QTime>::isConvertible(PyObject* pyObj)
-{
- if (ValueTypeConverter<QTime>::isConvertible(pyObj))
- return true;
-
- if (!PyDateTimeAPI)
- PyDateTime_IMPORT;
-
- SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType< ::QTime >());
- return PyTime_Check(pyObj) || ObjectType::isExternalConvertible(shiboType, pyObj);
-}
-
-inline QTime Converter<QTime>::toCpp(PyObject* pyObj)
-{
- if (!PyDateTimeAPI)
- PyDateTime_IMPORT;
-
- if (pyObj == Py_None) {
- return QTime();
- } else if (PyObject_TypeCheck(pyObj, SbkType<QTime>())) {
- return *Converter<QTime*>::toCpp(pyObj);
- } else if (PyTime_Check(pyObj)) {
- int hour = PyDateTime_TIME_GET_HOUR(pyObj);
- int min = PyDateTime_TIME_GET_MINUTE(pyObj);
- int sec = PyDateTime_TIME_GET_SECOND(pyObj);
- int usec = PyDateTime_TIME_GET_MICROSECOND(pyObj);
- return QTime(hour, min, sec, usec/1000);
- } else {
- return ValueTypeConverter<QTime>::toCpp(pyObj);
- }
-}
-
-}
diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h
deleted file mode 100644
index eda2acce9..000000000
--- a/PySide/QtCore/qvariant_conversions.h
+++ /dev/null
@@ -1,219 +0,0 @@
-namespace Shiboken {
-
-template<>
-struct Converter<QVariant>
-{
- static bool checkType(PyObject* pyObj)
- {
- return false; // lets avoid the chaos
- }
-
- // all types are convertible to QVariant
- static bool isConvertible(PyObject* pyObj)
- {
- return true;
- }
-
- static const char* resolveMetaType(PyTypeObject* type, int* typeId)
- {
- if (PyObject_TypeCheck(type, &SbkObjectType_Type)) {
- SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(type);
- const char* typeName = Shiboken::ObjectType::getOriginalName(sbkType);
- if (!typeName)
- return 0;
- bool valueType = '*' != typeName[qstrlen(typeName) - 1];
-
- // Do not convert user type of value
- if (valueType && Shiboken::ObjectType::isUserType(type))
- return 0;
-
- int obTypeId = QMetaType::type(typeName);
- if (obTypeId) {
- *typeId = obTypeId;
- return typeName;
- }
-
- // Do not resolve types to value type
- if (valueType)
- return 0;
-
- // find in base types
- if (type->tp_base) {
- return resolveMetaType(type->tp_base, typeId);
- } else if (type->tp_bases) {
- int size = PyTuple_GET_SIZE(type->tp_bases);
- for(int i=0; i < size; i++){
- const char* derivedName = resolveMetaType(reinterpret_cast<PyTypeObject*>(PyTuple_GET_ITEM(type->tp_bases, i)), typeId);
- if (derivedName)
- return derivedName;
- }
- }
- }
- *typeId = 0;
- return 0;
- }
-
- static QVariant toCpp(PyObject* pyObj)
- {
- using namespace Shiboken;
-
- // Primitive types
- if (Converter<bool>::checkType(pyObj)) {
- // QVariant(bool)
- return QVariant(Converter<bool>::toCpp(pyObj));
- } else if (pyObj == Py_None) {
- // QVariant()
- return QVariant();
- } else if (Converter<QString>::checkType(pyObj)) {
- // QVariant(const char*)
- return QVariant(Converter<QString>::toCpp(pyObj));
- } else if (Converter<QByteArray>::checkType(pyObj)) {
- // QVariant(QByteArray)
- return QVariant(Converter<QByteArray>::toCpp(pyObj));
- } else if (PyFloat_CheckExact(pyObj)) {
- // QVariant(double)
- return QVariant(Converter<double>::toCpp(pyObj));
- } else if (PyInt_Check(pyObj)) {
- // QVariant(int)
- return QVariant(Converter<int>::toCpp(pyObj));
- } else if (PyLong_CheckExact(pyObj)) {
- // QVariant(qlonglong)
- return QVariant(Converter<qlonglong>::toCpp(pyObj));
- } else if (Shiboken::isShibokenEnum(pyObj)) {
- // QVariant(enum)
- return QVariant(Converter<int>::toCpp(pyObj));
- } else if (PyNumber_Check(pyObj)) {
- Shiboken::AutoDecRef pyValue(PyNumber_Long(pyObj));
- return QVariant((int)PyLong_AsLong(pyValue.object()));
- } else if (Shiboken::Object::checkType(pyObj)) {
- // a class supported by QVariant?
- int typeCode;
- const char* typeName = resolveMetaType(pyObj->ob_type, &typeCode);
- if (typeCode && typeName) {
- Shiboken::TypeResolver* tr = Shiboken::TypeResolver::get(typeName);
- QVariant var(typeCode, (void*)0);
- void* args[] = { var.data() };
- tr->toCpp(pyObj, args);
- return var;
- }
- }
-
- // Sequence and dictionary
- if (PyDict_Check(pyObj)) {
- QVariant ret = convertToVariantMap(pyObj);
- if (ret.isValid())
- return ret;
- } else if (PySequence_Check(pyObj)) {
- return convertToVariantList(pyObj);
- }
-
- // Is a shiboken type not known by Qt
- return QVariant::fromValue<PySide::PyObjectWrapper>(pyObj);
- }
-
- static PyObject* toPython(void* cppObj)
- {
- return toPython(*reinterpret_cast<QVariant*>(cppObj));
- }
-
- static PyObject* toPython(const QVariant& cppObj)
- {
- if (cppObj.isValid()) {
- if (qstrcmp(cppObj.typeName(), "QVariantList") == 0)
- return Converter<QList<QVariant> >::toPython(cppObj.value<QVariantList>());
-
- if (qstrcmp(cppObj.typeName(), "QStringList") == 0)
- return Converter<QList<QString> >::toPython(cppObj.value<QStringList>());
-
- if (qstrcmp(cppObj.typeName(), "QVariantMap") == 0)
- return Converter<QMap<QString, QVariant> >::toPython(cppObj.value<QVariantMap>());
-
- Shiboken::TypeResolver* tr = Shiboken::TypeResolver::get(cppObj.typeName());
- if (tr)
- return tr->toPython(const_cast<void*>(cppObj.data()));
- }
- Py_RETURN_NONE;
- }
-
- static QVariant convertToValueList(PyObject* list)
- {
- if (PySequence_Size(list) < 1)
- return QVariant();
-
- Shiboken::AutoDecRef element(PySequence_GetItem(list, 0));
- int typeId;
- const char* typeName = resolveMetaType(element.cast<PyTypeObject*>(), &typeId);
- if (typeName) {
- QByteArray listTypeName("QList<");
- listTypeName += typeName;
- listTypeName += '>';
- typeId = QMetaType::type(listTypeName);
- if (typeId > 0) {
- Shiboken::TypeResolver* tr = Shiboken::TypeResolver::get(listTypeName);
- if (!tr) {
- qWarning() << "TypeResolver for :" << listTypeName << "not registered.";
- } else {
- QVariant var(typeId, (void*)0);
- void* args[] = { var.data(), 0 };
- tr->toCpp(list, args);
- return var;
- }
- }
- }
- return QVariant();
- }
-
- static QVariant convertToVariantMap(PyObject* map)
- {
- PyObject *key, *value;
- Py_ssize_t pos = 0;
- AutoDecRef keys(PyDict_Keys(map));
- bool keysIsString = isStringList(keys);
- if (keysIsString) {
- QMap<QString, QVariant> ret;
- while (PyDict_Next(map, &pos, &key, &value))
- ret.insert(Converter<QString>::toCpp(key), toCpp(value));
- return QVariant(ret);
- } else {
- return QVariant();
- }
- }
-
- static bool isStringList(PyObject *list)
- {
- bool allString = true;
- AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList"));
- Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object());
- for(int i=0; i < size; i++) {
- PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i);
- if (!Converter<QString>::checkType(item)) {
- allString = false;
- break;
- }
- }
- return allString;
- }
-
- static QVariant convertToVariantList(PyObject* list)
- {
- bool allString = isStringList(list);
- if (allString) {
- QStringList lst = Converter<QList<QString> >::toCpp(list);
- return QVariant(lst);
- } else {
- QVariant valueList = convertToValueList(list);
- if (valueList.isValid())
- return valueList;
- QList<QVariant> lst;
- AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList"));
- Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object());
- for(int i=0; i < size; i++) {
- PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i);
- lst.append(toCpp(item));
- }
- return QVariant(lst);
- }
- Q_ASSERT(false);
- }
-};
-}
diff --git a/PySide/QtCore/qvariant_type_conversions.h b/PySide/QtCore/qvariant_type_conversions.h
deleted file mode 100644
index 9fad1f183..000000000
--- a/PySide/QtCore/qvariant_type_conversions.h
+++ /dev/null
@@ -1,87 +0,0 @@
-namespace Shiboken {
-
-template<>
-struct Converter<QVariant::Type>
-{
- static bool checkType(PyObject* pyObj)
- {
- return pyObj == Py_None || PyType_Check(pyObj) || Converter<QString>::checkType(pyObj);
- }
-
- static bool isConvertible(PyObject* pyObj)
- {
- return checkType(pyObj);
- }
-
- static QVariant::Type toCpp(PyObject* pyObj)
- {
- const char* typeName = 0;
- if (pyObj == Py_None)
- return QVariant::Invalid;
-
- if (Shiboken::String::checkType(reinterpret_cast<PyTypeObject*>(pyObj)))
- typeName = "QString";
-
-
- else if (pyObj == reinterpret_cast<PyObject*>(&PyFloat_Type))
- typeName = "double"; // float is a UserType in QVariant.
- else if (pyObj == reinterpret_cast<PyObject*>(&PyLong_Type))
- typeName = "int"; // long is a UserType in QVariant.
- else if (PyType_Check(pyObj)) {
- if (pyObj->ob_type == &SbkObjectType_Type)
- typeName = Shiboken::ObjectType::getOriginalName(reinterpret_cast<SbkObjectType*>(pyObj));
- else
- typeName = reinterpret_cast<PyTypeObject*>(pyObj)->tp_name;
- }
- else if (Shiboken::String::check(pyObj))
- typeName = Shiboken::String::toCString(pyObj);
- else if (PyDict_Check(pyObj) && checkAllStringKeys(pyObj))
- typeName = "QVariantMap";
- else if (PySequence_Check(pyObj))
- if (isStringList(pyObj))
- typeName = "QStringList";
- else
- typeName = "QVariantList";
- else
- Q_ASSERT(false);
-
- return QVariant::nameToType(typeName);
- }
-
- static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<QVariant::Type*>(cppObj)); }
- static PyObject* toPython(const QVariant::Type& cppObj)
- {
- const char* typeName = QVariant::typeToName(cppObj);
- PyObject* pyObj;
- if (!typeName) {
- pyObj = Py_None;
- } else {
- Shiboken::TypeResolver* tr = Shiboken::TypeResolver::get(typeName);
- pyObj = tr ? reinterpret_cast<PyObject*>(tr->pythonType()) : Py_None;
- }
- Py_INCREF(pyObj);
- return pyObj;
- }
-
- static bool isStringList(PyObject* list)
- {
- bool allString = true;
- AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList"));
- Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object());
- for(int i=0; i < size; i++) {
- PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i);
- if (!Converter<QString>::checkType(item)) {
- allString = false;
- break;
- }
- }
- return allString;
- }
-
- static bool checkAllStringKeys(PyObject* dict)
- {
- AutoDecRef keys(PyDict_Keys(dict));
- return isStringList(keys);
- }
-};
-}
diff --git a/PySide/QtCore/qvector_conversions.h b/PySide/QtCore/qvector_conversions.h
deleted file mode 100644
index 0857036ae..000000000
--- a/PySide/QtCore/qvector_conversions.h
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace Shiboken {
-template<typename T>
-struct Converter<QVector<T> > : StdListConverter<QVector<T> > {};
-}
diff --git a/PySide/QtCore/typesystem_core_common.xml b/PySide/QtCore/typesystem_core_common.xml
index 965433b8d..aa39e9536 100644
--- a/PySide/QtCore/typesystem_core_common.xml
+++ b/PySide/QtCore/typesystem_core_common.xml
@@ -153,7 +153,7 @@
<include file-name="signalmanager.h" location="global"/>
</primitive-type>
<primitive-type name="QBool" target-lang-api-name="PyBool">
- <conversion-rule file="qbool_conversions.h">
+ <conversion-rule>
<native-to-target>
return PyBool_FromLong((bool)%in);
</native-to-target>
@@ -180,7 +180,7 @@
<primitive-type name="QString" target-lang-api-name="PyUnicode">
<include file-name="QString" location="global"/>
- <conversion-rule file="qstring_conversions.h">
+ <conversion-rule>
<native-to-target>
const int N = %in.length();
wchar_t* str = new wchar_t[N];
@@ -213,8 +213,7 @@
</primitive-type>
<primitive-type name="QStringRef">
- <include file-name="datetime.h" location="global"/>
- <conversion-rule file="qstringref_conversions.h">
+ <conversion-rule>
<native-to-target>
const int N = %in.toString().length();
wchar_t* str = new wchar_t[N];
@@ -231,7 +230,7 @@
</conversion-rule>
</primitive-type>
<primitive-type name="QChar">
- <conversion-rule file="qchar_conversions.h">
+ <conversion-rule>
<native-to-target>
wchar_t c = (wchar_t)%in.unicode();
return PyUnicode_FromWideChar(&amp;c, 1);
@@ -254,7 +253,7 @@
<primitive-type name="QVariant" target-lang-api-name="PyObject">
<include file-name="typeresolver.h" location="global"/>
- <conversion-rule file="qvariant_conversions.h">
+ <conversion-rule>
<native-to-target>
if (!%in.isValid())
Py_RETURN_NONE;
@@ -448,7 +447,7 @@
</inject-code>
<primitive-type name="QVariant::Type" default-constructor="QVariant::Invalid">
- <conversion-rule file="qvariant_type_conversions.h">
+ <conversion-rule>
<native-to-target>
const char* typeName = QVariant::typeToName(%in);
PyObject* %out;
@@ -524,7 +523,7 @@
<primitive-type name="QStringList">
<include file-name="QStringList" location="global"/>
- <conversion-rule file="qstringlist_conversions.h">
+ <conversion-rule>
<native-to-target>
<insert-template name="cpplist_to_pylist_convertion">
<replace from="%INTYPE_0" to="QString" />
@@ -560,7 +559,7 @@
<container-type name="QSet" type="set">
<include file-name="QSet" location="global"/>
- <conversion-rule file="qset_conversions.h">
+ <conversion-rule>
<native-to-target>
<insert-template name="cpplist_to_pylist_convertion"/>
</native-to-target>
@@ -574,7 +573,7 @@
<container-type name="QList" type="list">
<include file-name="QList" location="global"/>
- <conversion-rule file="qlist_conversions.h">
+ <conversion-rule>
<native-to-target>
<insert-template name="cpplist_to_pylist_convertion"/>
</native-to-target>
@@ -588,7 +587,7 @@
<container-type name="QVector" type="vector">
<include file-name="QVector" location="global"/>
- <conversion-rule file="qvector_conversions.h">
+ <conversion-rule>
<native-to-target>
<insert-template name="cpplist_to_pylist_convertion"/>
</native-to-target>
@@ -603,7 +602,7 @@
<container-type name="QStack" type="stack">
<include file-name="QStack" location="global"/>
- <conversion-rule file="qstack_conversion.h">
+ <conversion-rule>
<native-to-target>
<insert-template name="cpplist_to_pylist_convertion"/>
</native-to-target>
@@ -669,7 +668,7 @@
<container-type name="QHash" type="hash">
<include file-name="QHash" location="global"/>
<include file-name="pysideconversions.h" location="global"/>
- <conversion-rule file="qhash_conversions.h">
+ <conversion-rule>
<native-to-target>
<insert-template name="cppmap_to_pymap_convertion"/>
</native-to-target>
@@ -682,7 +681,7 @@
</container-type>
<container-type name="QMap" type="map">
<include file-name="QMap" location="global"/>
- <conversion-rule file="qmap_conversions.h">
+ <conversion-rule>
<native-to-target>
<insert-template name="cppmap_to_pymap_convertion"/>
</native-to-target>
@@ -695,7 +694,7 @@
</container-type>
<container-type name="QMultiMap" type="multi-map">
<include file-name="QMultiMap" location="global"/>
- <conversion-rule file="qmultimap_conversions.h">
+ <conversion-rule>
<native-to-target>
<insert-template name="cppmap_to_pymap_convertion"/>
</native-to-target>
@@ -709,7 +708,7 @@
<container-type name="QPair" type="pair">
<include file-name="QPair" location="global"/>
- <conversion-rule file="qpair_conversions.h">
+ <conversion-rule>
<native-to-target>
PyObject* %out = PyTuple_New(2);
PyTuple_SET_ITEM(%out, 0, %CONVERTTOPYTHON[%INTYPE_0](%in.first));
@@ -1110,9 +1109,15 @@
<value-type name="QByteArrayMatcher"/>
<value-type name="QDate" hash-function="PySide::hash" >
<template name="pydatetime_importandcheck_function">
+ #ifdef IS_PY3K
+ #define PySideDateTime_IMPORT PyDateTime_IMPORT
+ #else
+ #define PySideDateTime_IMPORT \
+ (PyDateTimeAPI = (PyDateTime_CAPI*) PyCObject_Import((char*)"datetime", \
+ (char*)"datetime_CAPI"))
+ #endif
static bool PyDateTime_ImportAndCheck(PyObject* pyIn) {
- if (!PyDateTimeAPI)
- PyDateTime_IMPORT;
+ if (!PyDateTimeAPI) PySideDateTime_IMPORT;
return $DATETIMETYPE_Check(pyIn);
}
</template>
@@ -1121,7 +1126,7 @@
<replace from="$DATETIMETYPE" to="PyDate" />
</insert-template>
</inject-code>
- <conversion-rule file="qdate_conversions.h">
+ <conversion-rule>
<target-to-native>
<add-conversion type="Py_None">
%out = %OUTTYPE();
@@ -1157,8 +1162,8 @@
</add-function>
<add-function signature="toPython()" return-type="PyObject">
<inject-code class="target" position="beginning">
- if (!PyDateTimeAPI) PyDateTime_IMPORT;
- %PYARG_0 = PyDate_FromDate(%CPPSELF.year(), %CPPSELF.month(), %CPPSELF.day());
+ if (!PyDateTimeAPI) PySideDateTime_IMPORT;
+ %PYARG_0 = PyDate_FromDate(%CPPSELF.year(), %CPPSELF.month(), %CPPSELF.day());
</inject-code>
</add-function>
<modify-function signature="getDate(int*,int*,int*)" >
@@ -1211,7 +1216,7 @@
<replace from="$DATETIMETYPE" to="PyDateTime" />
</insert-template>
</inject-code>
- <conversion-rule file="qdatetime_conversions.h">
+ <conversion-rule>
<target-to-native>
<add-conversion type="Py_None">
%out = %OUTTYPE();
@@ -1260,10 +1265,10 @@
</add-function>
<add-function signature="toPython()" return-type="PyObject">
<inject-code class="target" position="beginning">
- QDate date = %CPPSELF.date();
- QTime time = %CPPSELF.time();
- if (!PyDateTimeAPI) PyDateTime_IMPORT;
- %PYARG_0 = PyDateTime_FromDateAndTime(date.year(), date.month(), date.day(), time.hour(), time.minute(), time.second(), time.msec()*1000);
+ QDate date = %CPPSELF.date();
+ QTime time = %CPPSELF.time();
+ if (!PyDateTimeAPI) PySideDateTime_IMPORT;
+ %PYARG_0 = PyDateTime_FromDateAndTime(date.year(), date.month(), date.day(), time.hour(), time.minute(), time.second(), time.msec()*1000);
</inject-code>
</add-function>
</value-type>
@@ -1570,7 +1575,7 @@
<replace from="$DATETIMETYPE" to="PyTime" />
</insert-template>
</inject-code>
- <conversion-rule file="qtime_conversions.h">
+ <conversion-rule>
<target-to-native>
<add-conversion type="Py_None">
%out = %OUTTYPE();
@@ -1607,8 +1612,8 @@
</add-function>
<add-function signature="toPython()" return-type="PyObject">
<inject-code class="target" position="beginning">
- if (!PyDateTimeAPI) PyDateTime_IMPORT;
- %PYARG_0 = PyTime_FromTime(%CPPSELF.hour(), %CPPSELF.minute(), %CPPSELF.second(), %CPPSELF.msec()*1000);
+ if (!PyDateTimeAPI) PySideDateTime_IMPORT;
+ %PYARG_0 = PyTime_FromTime(%CPPSELF.hour(), %CPPSELF.minute(), %CPPSELF.second(), %CPPSELF.msec()*1000);
</inject-code>
</add-function>
</value-type>
@@ -2259,7 +2264,7 @@
</add-function>
</value-type>
<value-type name="QByteArray" hash-function="qHash">
- <conversion-rule file="qbytearray_conversions.h">
+ <conversion-rule>
<target-to-native>
<add-conversion type="Py_None">
%out = %OUTTYPE();
diff --git a/PySide/QtCore/typesystem_core_win.xml b/PySide/QtCore/typesystem_core_win.xml
index f4b8cab24..26c7a82a2 100644
--- a/PySide/QtCore/typesystem_core_win.xml
+++ b/PySide/QtCore/typesystem_core_win.xml
@@ -21,7 +21,7 @@
<typesystem package="PySide.QtCore">
<primitive-type name="Qt::HANDLE" target-lang-api-name="PyObject" />
<primitive-type name="HWND">
- <conversion-rule file="glue/hwnd_conversions.h">
+ <conversion-rule>
<native-to-target>
#ifdef IS_PY3K
return PyCapsule_New(%in, 0, 0);
diff --git a/PySide/QtDeclarative/pysideqmlregistertype.cpp b/PySide/QtDeclarative/pysideqmlregistertype.cpp
index 30844c671..4efc4bf77 100644
--- a/PySide/QtDeclarative/pysideqmlregistertype.cpp
+++ b/PySide/QtDeclarative/pysideqmlregistertype.cpp
@@ -282,12 +282,13 @@ int propListCount(QDeclarativeListProperty<QDeclarativeItem>* propList)
Shiboken::AutoDecRef retVal(PyObject_CallObject(data->count, args));
// Check return type
+ int cppResult = 0;
+ PythonToCppFunc pythonToCpp;
if (PyErr_Occurred())
PyErr_Print();
- else if (Shiboken::Converter<int>::isConvertible(retVal))
- return Shiboken::Converter<int>::toCpp(retVal);
-
- return 0;
+ else if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter<int>(), retVal)))
+ pythonToCpp(retVal, &cppResult);
+ return cppResult;
}
// Implementation of QDeclarativeListProperty<T>::AtFunction callback
@@ -302,12 +303,12 @@ QDeclarativeItem* propListAt(QDeclarativeListProperty<QDeclarativeItem>* propLis
DeclarativeListProperty* data = reinterpret_cast<DeclarativeListProperty*>(propList->data);
Shiboken::AutoDecRef retVal(PyObject_CallObject(data->at, args));
+ QDeclarativeItem* result = 0;
if (PyErr_Occurred())
PyErr_Print();
else if (PyType_IsSubtype(Py_TYPE(retVal), data->type))
- return Shiboken::Converter<QDeclarativeItem*>::toCpp(retVal);
-
- return 0;
+ Shiboken::Conversions::pythonToCppPointer((SbkObjectType*)SbkPySide_QtCoreTypes[SBK_QDECLARATIVEITEM_IDX], retVal, &result);
+ return result;
}
// Implementation of QDeclarativeListProperty<T>::ClearFunction callback
@@ -332,7 +333,9 @@ static void propListMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::Ca
return;
DeclarativeListProperty* data = reinterpret_cast<DeclarativeListProperty*>(PySide::Property::userData(pp));
- QDeclarativeListProperty<QDeclarativeItem> declProp(Shiboken::Converter<QObject*>::toCpp(self), data, &propListAppender);
+ QObject* qobj;
+ Shiboken::Conversions::pythonToCppPointer((SbkObjectType*)SbkPySide_QtCoreTypes[SBK_QOBJECT_IDX], self, &qobj);
+ QDeclarativeListProperty<QDeclarativeItem> declProp(qobj, data, &propListAppender);
if (data->count)
declProp.count = &propListCount;
diff --git a/PySide/QtGui/glue/qlayout_help_functions.h b/PySide/QtGui/glue/qlayout_help_functions.cpp
index 00f0dbde7..b36606136 100644
--- a/PySide/QtGui/glue/qlayout_help_functions.h
+++ b/PySide/QtGui/glue/qlayout_help_functions.cpp
@@ -1,6 +1,3 @@
-#ifndef QLAYOUT_HELP_FUNCTIONS
-#define QLAYOUT_HELP_FUNCTIONS
-
void addLayoutOwnership(QLayout* layout, QLayoutItem* item);
void removeLayoutOwnership(QLayout* layout, QWidget* widget);
@@ -16,21 +13,20 @@ inline void addLayoutOwnership(QLayout* layout, QWidget* widget)
QWidget *lw = layout->parentWidget();
QWidget *pw = widget->parentWidget();
- Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget));
- //Transfer parent to layout widget
+ //Transfer parent to layout widget
if (pw && lw && pw != lw)
Shiboken::Object::setParent(0, pyChild);
if (!lw && !pw) {
//keep the reference while the layout is orphan
- Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(layout));
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](layout));
Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
} else {
if (!lw)
lw = pw;
-
- Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(lw));
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](lw));
Shiboken::Object::setParent(pyParent, pyChild);
}
}
@@ -41,8 +37,8 @@ inline void addLayoutOwnership(QLayout* layout, QLayout* other)
QWidget* parent = layout->parentWidget();
if (!parent) {
//keep the reference while the layout is orphan
- Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout));
- Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(other));
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](other));
Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
return;
}
@@ -51,14 +47,12 @@ inline void addLayoutOwnership(QLayout* layout, QLayout* other)
QLayoutItem* item = other->itemAt(i);
if (PyErr_Occurred() || !item)
return;
-
addLayoutOwnership(layout, item);
}
- Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout));
- Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(other));
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](other));
Shiboken::Object::setParent(pyParent, pyChild);
-
}
inline void addLayoutOwnership(QLayout* layout, QLayoutItem* item)
@@ -75,8 +69,8 @@ inline void addLayoutOwnership(QLayout* layout, QLayoutItem* item)
addLayoutOwnership(layout, l);
}
- Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout));
- Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayoutItem*>::toPython(item));
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayoutItem*](item));
Shiboken::Object::setParent(pyParent, pyChild);
}
@@ -86,13 +80,13 @@ static void removeWidgetFromLayout(QLayout* layout, QWidget* widget)
if (!parent) {
//remove reference on layout
- Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(layout));
- Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget));
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](layout));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget));
Shiboken::Object::removeReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild);
} else {
//give the ownership to parent
- Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent));
- Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget));
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget));
Shiboken::Object::setParent(pyParent, pyChild);
}
}
@@ -108,7 +102,7 @@ inline void removeLayoutOwnership(QLayout* layout, QLayoutItem* item)
removeLayoutOwnership(layout, l);
}
- Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayoutItem*>::toPython(item));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayoutItem*](item));
Shiboken::Object::invalidate(pyChild);
Shiboken::Object::setParent(0, pyChild);
}
@@ -126,5 +120,3 @@ inline void removeLayoutOwnership(QLayout* layout, QWidget* widget)
removeLayoutOwnership(layout, item);
}
}
-
-#endif
diff --git a/PySide/QtGui/glue/qmenu_glue.h b/PySide/QtGui/glue/qmenu_glue.cpp
index 94eab15e0..0636dfab0 100644
--- a/PySide/QtGui/glue/qmenu_glue.h
+++ b/PySide/QtGui/glue/qmenu_glue.cpp
@@ -1,4 +1,3 @@
-
inline PyObject* addActionWithPyObject(QMenu* self, const QIcon& icon, const QString& text, PyObject* callback, const QKeySequence& shortcut)
{
QAction* act = new QAction(text, self);
@@ -11,7 +10,7 @@ inline PyObject* addActionWithPyObject(QMenu* self, const QIcon& icon, const QSt
self->addAction(act);
- PyObject* pyAct = Shiboken::Converter<QAction*>::toPython(act);
+ PyObject* pyAct = %CONVERTTOPYTHON[QAction*](act);
Shiboken::AutoDecRef result(PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback));
if (result.isNull()) {
Py_DECREF(pyAct);
diff --git a/PySide/QtGui/glue/qmenubar_glue.h b/PySide/QtGui/glue/qmenubar_glue.cpp
index 9568fa87c..2326a76cc 100644
--- a/PySide/QtGui/glue/qmenubar_glue.h
+++ b/PySide/QtGui/glue/qmenubar_glue.cpp
@@ -5,7 +5,7 @@ addActionWithPyObject(QMenuBar* self, const QString& text, PyObject* callback)
self->addAction(act);
- PyObject* pyAct = Shiboken::Converter<QAction*>::toPython(act);
+ PyObject* pyAct = %CONVERTTOPYTHON[QAction*](act);
PyObject* result = PyObject_CallMethod(pyAct, "connect", "OsO", pyAct,
SIGNAL(triggered(bool)), callback);
diff --git a/PySide/QtGui/glue/qtgui_qapp.cpp b/PySide/QtGui/glue/qtgui_qapp.cpp
index 4c4508b70..5148b579b 100644
--- a/PySide/QtGui/glue/qtgui_qapp.cpp
+++ b/PySide/QtGui/glue/qtgui_qapp.cpp
@@ -1,6 +1,6 @@
// Init qApp macro to None.
if (qApp) {
- PyObject* pyApp = Shiboken::Converter<QApplication*>::toPython(qApp);
+ PyObject* pyApp = %CONVERTTOPYTHON[QApplication*](qApp);
Py_INCREF(pyApp);
PyModule_AddObject(module, "qApp", pyApp);
} else {
diff --git a/PySide/QtGui/glue/qwidget_glue.h b/PySide/QtGui/glue/qwidget_glue.cpp
index 931a5288e..cfa3f6757 100644
--- a/PySide/QtGui/glue/qwidget_glue.h
+++ b/PySide/QtGui/glue/qwidget_glue.cpp
@@ -10,7 +10,7 @@ static QString retrieveObjectName(PyObject *obj)
**/
static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout)
{
- Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent));
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent));
for (int i=0; i < layout->count(); i++) {
QLayoutItem* item = layout->itemAt(i);
@@ -21,7 +21,7 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout)
if (w) {
QWidget* pw = w->parentWidget();
if (pw != parent) {
- Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(w));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](w));
Shiboken::Object::setParent(pyParent, pyChild);
}
} else {
@@ -31,7 +31,7 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout)
}
}
- Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(layout));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](layout));
Shiboken::Object::setParent(pyParent, pyChild);
//remove previous references
Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None);
@@ -46,7 +46,7 @@ static inline void qwidgetSetLayout(QWidget *self, QLayout *layout)
if (oldParent && oldParent != self) {
if (oldParent->isWidgetType()) {
// remove old parent policy
- Shiboken::AutoDecRef pyLayout(Shiboken::Converter<QLayout*>::toPython(layout));
+ Shiboken::AutoDecRef pyLayout(%CONVERTTOPYTHON[QLayout*](layout));
Shiboken::Object::setParent(Py_None, pyLayout);
} else {
PyErr_Format(PyExc_RuntimeError, "QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent",
diff --git a/PySide/QtGui/glue/wid_conversions.h b/PySide/QtGui/glue/wid_conversions.h
deleted file mode 100644
index 68d752884..000000000
--- a/PySide/QtGui/glue/wid_conversions.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef Q_WS_WIN
-
-namespace Shiboken {
-template <>
-struct Converter<WId>
-{
- static bool checkType(PyObject* pyObj)
- {
- return false;
- }
-
- static bool isConvertible(PyObject* pyobj)
- {
- return pyobj == Py_None || PyNumber_Check(pyobj);
- }
-
- static inline PyObject* toPython(void* cppobj)
- {
- // not supported
- Q_ASSERT(true);
- return 0;
- }
-
- static PyObject* toPython(WId cppobj)
- {
- return PyLong_FromVoidPtr((void*)cppobj);
- }
-
- static WId toCpp(PyObject* pyobj)
- {
- if (pyobj == Py_None)
- return 0;
- return (WId)PyLong_AsVoidPtr(pyobj);
- }
-};
-
-}
-
-#endif
diff --git a/PySide/QtGui/qpixmap_conversion.h b/PySide/QtGui/qpixmap_conversion.h
deleted file mode 100644
index fc49af6be..000000000
--- a/PySide/QtGui/qpixmap_conversion.h
+++ /dev/null
@@ -1,49 +0,0 @@
-namespace Shiboken {
-inline bool Converter<QPixmap>::checkType(PyObject* pyObj)
-{
- return ValueTypeConverter<QPixmap>::checkType(pyObj);
-}
-
-inline bool Converter<QPixmap>::isConvertible(PyObject* pyobj)
-{
- if (ValueTypeConverter<QPixmap>::isConvertible(pyobj))
- return true;
- SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<QPixmap>());
- bool isVariant = Shiboken::Converter<QVariant>::checkType(pyobj);
- if (isVariant) {
- QVariant var(Shiboken::Converter<QVariant>::toCpp(pyobj));
- return var.type() == QVariant::Pixmap;
- } else if (Shiboken::Converter<QSize>::checkType(pyobj) || Shiboken::Converter<QString>::checkType(pyobj)) {
- return true;
- } else {
- return Shiboken::ObjectType::isExternalConvertible(shiboType, pyobj);
- }
- return false;
-
-}
-
-inline QPixmap Converter<QPixmap>::toCpp(PyObject* pyobj)
-{
- SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<QPixmap>());
- bool isVariant = Converter<QVariant>::checkType(pyobj);
- if (isVariant) {
- QVariant var(Converter<QVariant>::toCpp(pyobj));
- return var.value<QPixmap>();
- } else if (Converter<QSize>::checkType(pyobj)) {
- return QPixmap(Shiboken::Converter<QSize >::toCpp(pyobj));
- } else if (Converter<QString>::checkType(pyobj)) {
- return QPixmap(Shiboken::Converter<QString >::toCpp(pyobj));
- } else if (Shiboken::ObjectType::isExternalConvertible(shiboType, pyobj) && Shiboken::ObjectType::hasExternalCppConversions(shiboType)) {
- QPixmap* cptr = reinterpret_cast<QPixmap*>(Shiboken::ObjectType::callExternalCppConversion(shiboType, pyobj));
- std::auto_ptr<QPixmap> cptr_auto_ptr(cptr);
- return *cptr;
- }
-
- return *Converter<QPixmap*>::toCpp(pyobj);
-}
-
-inline PyObject* Converter<QPixmap>::toPython(const QPixmap& cppObj)
-{
- return ValueTypeConverter<QPixmap>::toPython(cppObj);
-}
-}
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 6922bcfa9..e9058b563 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -798,7 +798,14 @@
free(xpm);
</template>
<value-type name="QPixmap" >
- <conversion-rule file="qpixmap_conversion.h" />
+ <!--<conversion-rule>-->
+ <!--<target-to-native replace="no">-->
+ <!--<add-conversion type="QVariant" check="%CHECKTYPE[QVariant](%in)">-->
+ <!--QVariant in = %CONVERTTOCPP[QVariant](%in);-->
+ <!--%out = in.value&lt;%OUTTYPE&gt;();-->
+ <!--</add-conversion>-->
+ <!--</target-to-native>-->
+ <!--</conversion-rule>-->
<add-function signature="QPixmap(const QImage&amp;)">
<modify-argument index="1">
<rename to="image"/>
@@ -2357,9 +2364,7 @@
</modify-function>
</object-type>
<object-type name="QMenu">
- <extra-includes>
- <include file-name="glue/qmenu_glue.h" location="local"/>
- </extra-includes>
+ <inject-code class="native" position="beginning" file="glue/qmenu_glue.cpp"/>
<modify-function signature="exec()" rename="exec_" allow-thread="yes" />
<modify-function signature="exec(const QPoint&amp;, QAction*)" rename="exec_" allow-thread="yes" />
@@ -2453,9 +2458,7 @@
</object-type>
<object-type name="QMenuBar">
- <extra-includes>
- <include file-name="glue/qmenubar_glue.h" location="local"/>
- </extra-includes>
+ <inject-code class="native" position="beginning" file="glue/qmenubar_glue.cpp"/>
<modify-function signature="addAction(const QString&amp;)">
<modify-argument index="return">
<parent index="this" action="add"/>
@@ -3136,10 +3139,7 @@
<modify-function signature="getColor(const QColor&amp;, QWidget*, const QString&amp;, QFlags&lt;QColorDialog::ColorDialogOption>)" allow-thread="yes" />
</object-type>
<object-type name="QLayout">
-
- <extra-includes>
- <include file-name="glue/qlayout_help_functions.h" location="local"/>
- </extra-includes>
+ <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/>
<enum-type name="SizeConstraint"/>
@@ -3239,9 +3239,7 @@
</object-type>
<object-type name="QStackedLayout">
- <extra-includes>
- <include file-name="glue/qlayout_help_functions.h" location="local"/>
- </extra-includes>
+ <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/>
<enum-type name="StackingMode"/>
<modify-function signature="insertWidget(int,QWidget*)">
<inject-code class="target" position="beginning">
@@ -3251,9 +3249,7 @@
</object-type>
<object-type name="QBoxLayout">
- <extra-includes>
- <include file-name="glue/qlayout_help_functions.h" location="local"/>
- </extra-includes>
+ <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/>
<enum-type name="Direction" />
@@ -3297,9 +3293,7 @@
</object-type>
<object-type name="QGridLayout">
- <extra-includes>
- <include file-name="glue/qlayout_help_functions.h" location="local"/>
- </extra-includes>
+ <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/>
<modify-function signature="itemAtPosition (int, int) const">
<modify-argument index="return">
<define-ownership owner="default"/>
@@ -4027,9 +4021,10 @@
<extra-includes>
<include file-name="QIcon" location="global"/>
<include file-name="QMessageBox" location="global"/>
- <include file-name="glue/qwidget_glue.h" location="local"/>
</extra-includes>
+ <inject-code class="native" file="glue/qwidget_glue.cpp" position="beginning" />
+
<enum-type name="RenderFlag" flags="RenderFlags"/>
<modify-function signature="setParent(QWidget*)">
@@ -5687,9 +5682,7 @@
</modify-function>
</object-type>
<object-type name="QFormLayout">
- <extra-includes>
- <include file-name="glue/qlayout_help_functions.h" location="local"/>
- </extra-includes>
+ <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/>
<enum-type name="FieldGrowthPolicy"/>
<enum-type name="ItemRole"/>
diff --git a/PySide/QtGui/typesystem_gui_win.xml b/PySide/QtGui/typesystem_gui_win.xml
index 93d422a22..387964d2b 100644
--- a/PySide/QtGui/typesystem_gui_win.xml
+++ b/PySide/QtGui/typesystem_gui_win.xml
@@ -20,7 +20,7 @@
-->
<typesystem package="PySide.QtGui">
<primitive-type name="WId" target-lang-api-name="PyObject">
- <conversion-rule file="glue/wid_conversions.h">
+ <conversion-rule>
<native-to-target>
#ifdef IS_PY3K
return PyCapsule_New(%in, 0, 0);
diff --git a/PySide/QtUiTools/glue/uitools_loadui.h b/PySide/QtUiTools/glue/uitools_loadui.cpp
index 654ba0aa1..829adf7d0 100644
--- a/PySide/QtUiTools/glue/uitools_loadui.h
+++ b/PySide/QtUiTools/glue/uitools_loadui.cpp
@@ -17,7 +17,7 @@ static void createChildrenNameAttributes(PyObject* root, QObject* object)
if (!name.isEmpty() && !name.startsWith("_") && !name.startsWith("qt_")) {
bool hasAttr = PyObject_HasAttrString(root, name.constData());
if (!hasAttr) {
- Shiboken::AutoDecRef pyChild(Shiboken::Converter<QObject*>::toPython(child));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child));
PyObject_SetAttrString(root, name.constData(), pyChild);
}
createChildrenNameAttributes(root, child);
@@ -31,14 +31,12 @@ static PyObject* QUiLoadedLoadUiFromDevice(QUiLoader* self, QIODevice* dev, QWid
QWidget* wdg = self->load(dev, parent);
if (wdg) {
- PyObject* pyWdg = Shiboken::Converter<QWidget*>::toPython(wdg);
-
+ PyObject* pyWdg = %CONVERTTOPYTHON[QWidget*](wdg);
createChildrenNameAttributes(pyWdg, wdg);
if (parent) {
- Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent));
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent));
Shiboken::Object::setParent(pyParent, pyWdg);
}
-
return pyWdg;
}
diff --git a/PySide/QtUiTools/typesystem_uitools.xml b/PySide/QtUiTools/typesystem_uitools.xml
index d7e405b96..c86ae4499 100644
--- a/PySide/QtUiTools/typesystem_uitools.xml
+++ b/PySide/QtUiTools/typesystem_uitools.xml
@@ -26,6 +26,7 @@
<extra-includes>
<include file-name="glue/plugins.h" location="local"/>
</extra-includes>
+ <inject-code class="native" position="beginning" file="glue/uitools_loadui.cpp"/>
<inject-code>
Q_IMPORT_PLUGIN(uiplugin);
</inject-code>
@@ -94,9 +95,6 @@
</modify-function>
<modify-function signature="load(QIODevice*, QWidget*)">
- <extra-includes>
- <include file-name="glue/uitools_loadui.h" location="local"/>
- </extra-includes>
<modify-argument index="2">
<replace-default-expression with="0" />
<rename to="parentWidget" />
@@ -112,9 +110,6 @@
<!-- Syntax sugar -->
<add-function signature="load(QString, QWidget*)" return-type="QWidget*">
- <extra-includes>
- <include file-name="glue/uitools_loadui.h" location="local"/>
- </extra-includes>
<modify-argument index="2">
<replace-default-expression with="0" />
<rename to="parentWidget" />
diff --git a/PySide/QtWebKit/typesystem_webkit.xml b/PySide/QtWebKit/typesystem_webkit.xml
index ac57dd1f0..86b8431a0 100644
--- a/PySide/QtWebKit/typesystem_webkit.xml
+++ b/PySide/QtWebKit/typesystem_webkit.xml
@@ -98,11 +98,11 @@
// Cast the parameters according to the extension type
if (extension == QWebPage::ChooseMultipleFilesExtension) {
const ChooseMultipleFilesExtension$TYPE_SUFFIX* _in = reinterpret_cast&lt;const ChooseMultipleFilesExtension$TYPE_SUFFIX*>(%in);
- %out = %CONVERTTOPYTHON[const ChooseMultipleFilesExtension$TYPE_SUFFIX*](_in);
+ %out = %CONVERTTOPYTHON[const QWebPage::ChooseMultipleFilesExtension$TYPE_SUFFIX*](_in);
#if QT_VERSION >= 0x040600
} else if (extension == QWebPage::ErrorPageExtension) {
const ErrorPageExtension$TYPE_SUFFIX* _in = reinterpret_cast&lt;const ErrorPageExtension$TYPE_SUFFIX*>(%in);
- %out = %CONVERTTOPYTHON[const ErrorPageExtension$TYPE_SUFFIX*](_in);
+ %out = %CONVERTTOPYTHON[const QWebPage::ErrorPageExtension$TYPE_SUFFIX*](_in);
#endif
}
</template>