You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
946 lines
22 KiB
946 lines
22 KiB
14 years ago
|
//
|
||
|
// Copyright 2004 Jim Bublitz <jbublitz@nwinternet.com>
|
||
|
// Earlier copyrights 1998 - 2003 Jim Bublitz and/or Phil Thompson
|
||
|
// may also apply
|
||
|
|
||
|
// module kdecore version KDE_3_2_2
|
||
|
|
||
|
|
||
|
// This software is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License as
|
||
|
// published by the Free Software Foundation; either version 2 of
|
||
|
// the License, or (at your option) any later version.
|
||
|
//
|
||
|
// This software 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 General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU General Public
|
||
|
// License along with this library; see the file COPYING.
|
||
|
// If not, write to the Free Software Foundation, Inc.,
|
||
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
|
||
|
%ModuleHeaderCode
|
||
|
#include <qvariant.h>
|
||
|
%End
|
||
|
|
||
|
|
||
|
void dcop_add (QDataStream&, QWidget::FocusPolicy /Constrained/);
|
||
|
void dcop_add (QDataStream&, int /Constrained/, const QCString& = "int");
|
||
|
//void dcop_add (QDataStream&, longlong);
|
||
|
//void dcop_add (QDataStream&, ulonglong);
|
||
|
void dcop_add (QDataStream&, double, const QCString& = "double");
|
||
|
void dcop_add (QDataStream&, QString);
|
||
|
void dcop_add (QDataStream&, QStringList);
|
||
|
void dcop_add (QDataStream&, QCString);
|
||
|
void dcop_add (QDataStream&, KURL);
|
||
|
void dcop_add (QDataStream&, KURL::List);
|
||
|
void dcop_add (QDataStream&, QSize);
|
||
|
void dcop_add (QDataStream&, QRect);
|
||
|
void dcop_add (QDataStream&, QRegion);
|
||
|
void dcop_add (QDataStream&, QPoint);
|
||
|
void dcop_add (QDataStream&, QFont);
|
||
|
void dcop_add (QDataStream&, QCursor);
|
||
|
void dcop_add (QDataStream&, QPixmap);
|
||
|
void dcop_add (QDataStream&, QColor);
|
||
|
void dcop_add (QDataStream&, QColorGroup);
|
||
|
void dcop_add (QDataStream&, QPalette);
|
||
|
void dcop_add (QDataStream&, QBrush);
|
||
|
void dcop_add (QDataStream&, DCOPRef);
|
||
|
void dcop_add (QDataStream&, QVariant);
|
||
|
void dcop_add (QDataStream&, QDate);
|
||
|
void dcop_add (QDataStream&, QTime);
|
||
|
void dcop_add (QDataStream&, QDateTime);
|
||
|
void dcop_add (QDataStream&, QImage);
|
||
|
void dcop_add (QDataStream&, QKeySequence);
|
||
|
void dcop_add (QDataStream&, QPen);
|
||
|
void dcop_add (QDataStream&, QPicture);
|
||
|
void dcop_add (QDataStream&, QPointArray);
|
||
|
void dcop_add (QDataStream&, QByteArray);
|
||
|
|
||
|
void dcop_add (QDataStream&, SIP_PYDICT, QCString);
|
||
|
%MethodCode
|
||
|
const sipTypeDef *map_td = sipFindType(*a2);
|
||
|
|
||
|
if (map_td)
|
||
|
{
|
||
|
int iserr = 0;
|
||
|
void *map_v;
|
||
|
|
||
|
map_v = sipForceConvertToType(a1, map_td, NULL,
|
||
|
SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);
|
||
|
|
||
|
if (iserr)
|
||
|
{
|
||
|
sipIsErr = 1;
|
||
|
}
|
||
|
else if (*a2 == "QMap<QCString,DCOPRef>")
|
||
|
{
|
||
|
QMap<QCString,DCOPRef> *map = (QMap<QCString,DCOPRef> *)map_v;
|
||
|
|
||
|
*a0 << *map;
|
||
|
}
|
||
|
else if (*a2 == "QMap<QString,DCOPRef>")
|
||
|
{
|
||
|
QMap<QString,DCOPRef> *map = (QMap<QString,DCOPRef> *)map_v;
|
||
|
|
||
|
*a0 << *map;
|
||
|
}
|
||
|
else if (*a2 == "QMap<QString,QString>")
|
||
|
{
|
||
|
QMap<QString,QString> *map = (QMap<QString,QString> *)map_v;
|
||
|
|
||
|
*a0 << *map;
|
||
|
}
|
||
|
else if (*a2 == "QMap<QString,QByteArray>")
|
||
|
{
|
||
|
QMap<QString,QByteArray> *map = (QMap<QString,QByteArray> *)map_v;
|
||
|
|
||
|
*a0 << *map;
|
||
|
}
|
||
|
}
|
||
|
%End
|
||
|
|
||
|
|
||
|
void dcop_add (QDataStream&, SIP_PYLIST, QCString);
|
||
|
%MethodCode
|
||
|
const sipTypeDef *list_td = sipFindType(*a2);
|
||
|
|
||
|
if (list_td)
|
||
|
{
|
||
|
int iserr = 0;
|
||
|
void *list_v;
|
||
|
|
||
|
list_v = sipForceConvertToType(a1, list_td, NULL,
|
||
|
SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);
|
||
|
|
||
|
if (iserr)
|
||
|
{
|
||
|
sipIsErr = 1;
|
||
|
}
|
||
|
else if (*a2 == "QValueList<QCString>")
|
||
|
{
|
||
|
QValueList<QCString> *list = (QValueList<QCString> *)list_v;
|
||
|
|
||
|
*a0 << *list;
|
||
|
}
|
||
|
else if (*a2 == "QValueList<DCOPRef>")
|
||
|
{
|
||
|
QValueList<DCOPRef> *list = (QValueList<DCOPRef> *)list_v;
|
||
|
|
||
|
*a0 << *list;
|
||
|
}
|
||
|
}
|
||
|
%End
|
||
|
|
||
|
|
||
|
void dcop_next (QDataStream&, QCString&);
|
||
|
%MethodCode
|
||
|
if (*a1 == "char")
|
||
|
{
|
||
|
Q_INT8 res;
|
||
|
*a0 >> res;
|
||
|
return PyInt_FromLong ((long)res);
|
||
|
}
|
||
|
else if (*a1 == "bool")
|
||
|
{
|
||
|
bool res;
|
||
|
*a0 >> res;
|
||
|
return PyBool_FromLong ((long)res);
|
||
|
}
|
||
|
else if (*a1 == "int")
|
||
|
{
|
||
|
int res;
|
||
|
*a0 >> res;
|
||
|
return PyInt_FromLong ((long)res);
|
||
|
}
|
||
|
else if (*a1 == "long")
|
||
|
{
|
||
|
long res;
|
||
|
*a0 >> res;
|
||
|
return PyLong_FromLong (res);
|
||
|
}
|
||
|
else if (*a1 == "short")
|
||
|
{
|
||
|
short res;
|
||
|
*a0 >> res;
|
||
|
return PyInt_FromLong ((long)res);
|
||
|
}
|
||
|
if (*a1 == "uchar" || *a1 == "unsigned char")
|
||
|
{
|
||
|
Q_UINT8 res;
|
||
|
*a0 >> res;
|
||
|
return PyInt_FromLong ((long)res);
|
||
|
}
|
||
|
else if (*a1 == "uint" || *a1 == "unsigned int")
|
||
|
{
|
||
|
unsigned int res;
|
||
|
*a0 >> res;
|
||
|
return PyInt_FromLong ((long)res);
|
||
|
}
|
||
|
else if (*a1 == "ulong" || *a1 == "unsigned long")
|
||
|
{
|
||
|
unsigned long res;
|
||
|
*a0 >> res;
|
||
|
return PyLong_FromLong (res);
|
||
|
}
|
||
|
else if (*a1 == "Q_INT32")
|
||
|
{
|
||
|
Q_INT32 res;
|
||
|
*a0 >> res;
|
||
|
return PyLong_FromLong ((long)res);
|
||
|
}
|
||
|
else if (*a1 == "pid_t")
|
||
|
{
|
||
|
pid_t res;
|
||
|
*a0 >> res;
|
||
|
return PyLong_FromLong ((long)res);
|
||
|
}
|
||
|
else if (*a1 == "ushort" || *a1 == "unsigned short")
|
||
|
{
|
||
|
unsigned short res;
|
||
|
*a0 >> res;
|
||
|
return PyInt_FromLong ((long)res);
|
||
|
}
|
||
|
else if (*a1 == "float")
|
||
|
{
|
||
|
float res;
|
||
|
*a0 >> res;
|
||
|
return PyFloat_FromDouble ((double)res);
|
||
|
}
|
||
|
else if (*a1 == "double")
|
||
|
{
|
||
|
double res;
|
||
|
*a0 >> res;
|
||
|
return PyFloat_FromDouble (res);
|
||
|
}
|
||
|
else if (*a1 == "QString")
|
||
|
{
|
||
|
QString res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QString(res), sipType_QString, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QStringList")
|
||
|
{
|
||
|
QStringList res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QStringList(res), sipType_QStringList, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QCString")
|
||
|
{
|
||
|
QCString res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QCString(res), sipType_QCString, NULL);
|
||
|
}
|
||
|
else if (*a1 == "KURL")
|
||
|
{
|
||
|
KURL res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new KURL(res), sipType_KURL, NULL);
|
||
|
}
|
||
|
else if (*a1 == "KURL::List")
|
||
|
{
|
||
|
KURL::List res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new KURL::List(res), sipType_KURL_List, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QSize")
|
||
|
{
|
||
|
QSize res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QSize(res), sipType_QSize, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QRect")
|
||
|
{
|
||
|
QRect res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QRect(res), sipType_QRect, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QRegion")
|
||
|
{
|
||
|
QRect res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QRegion(res), sipType_QRegion, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QPoint")
|
||
|
{
|
||
|
QPoint res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QPoint(res), sipType_QPoint, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QFont")
|
||
|
{
|
||
|
QFont res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QFont(res), sipType_QFont, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QCursor")
|
||
|
{
|
||
|
QCursor res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QCursor(res), sipType_QCursor, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QPixmap")
|
||
|
{
|
||
|
QPixmap res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QPixmap(res), sipType_QPixmap, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QColor")
|
||
|
{
|
||
|
QColor res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QColor(res), sipType_QColor, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QColorGroup")
|
||
|
{
|
||
|
QColorGroup res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QColorGroup(res), sipType_QColorGroup, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QPalette")
|
||
|
{
|
||
|
QPalette res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QPalette(res), sipType_QPalette, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QBrush")
|
||
|
{
|
||
|
QBrush res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QBrush(res), sipType_QBrush, NULL);
|
||
|
}
|
||
|
else if (*a1 == "FocusPolicy")
|
||
|
{
|
||
|
unsigned int res;
|
||
|
*a0 >> res;
|
||
|
return PyInt_FromLong ((long)res);
|
||
|
}
|
||
|
else if (*a1 == "DCOPRef")
|
||
|
{
|
||
|
DCOPRef res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new DCOPRef(res), sipType_DCOPRef, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QVariant")
|
||
|
{
|
||
|
QVariant res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QVariant(res), sipType_QVariant, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QDate")
|
||
|
{
|
||
|
QDate res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QDate(res), sipType_QDate, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QTime")
|
||
|
{
|
||
|
QTime res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QTime(res), sipType_QTime, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QDateTime")
|
||
|
{
|
||
|
QDateTime res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QDateTime(res), sipType_QDateTime, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QImage")
|
||
|
{
|
||
|
QImage res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QImage(res), sipType_QImage, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QKeySequence")
|
||
|
{
|
||
|
QKeySequence res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QKeySequence(res), sipType_QKeySequence, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QPen")
|
||
|
{
|
||
|
QPen res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QPen(res), sipType_QPen, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QPicture")
|
||
|
{
|
||
|
QPicture res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QPicture(res), sipType_QPicture, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QPointArray")
|
||
|
{
|
||
|
QPointArray res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QPointArray(res), sipType_QPointArray, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QByteArray")
|
||
|
{
|
||
|
QByteArray res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromNewType(new QByteArray(res), sipType_QByteArray, NULL);
|
||
|
}
|
||
|
else if (*a1 == "QMap<QCString,DCOPRef>")
|
||
|
{
|
||
|
QMap<QCString, DCOPRef> res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
||
|
}
|
||
|
else if (*a1 == "QMap<QString,DCOPRef>")
|
||
|
{
|
||
|
QMap<QString, DCOPRef> res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
||
|
}
|
||
|
else if (*a1 == "QMap<QString,QString>")
|
||
|
{
|
||
|
QMap<QString, QString> res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
||
|
}
|
||
|
else if (*a1 == "QMap<QString,QByteArray>")
|
||
|
{
|
||
|
QMap<QString, QByteArray> res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
||
|
}
|
||
|
else if (*a1 == "QValueList<QCString>")
|
||
|
{
|
||
|
QValueList<QCString> res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
||
|
}
|
||
|
else if (*a1 == "QValueList<DCOPRef>" || *a1 == "QCStringList")
|
||
|
{
|
||
|
QValueList<DCOPRef> res;
|
||
|
*a0 >> res;
|
||
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
||
|
}
|
||
|
|
||
|
%End
|
||
|
|
||
|
%ModuleHeaderCode
|
||
|
#include <qcstring.h>
|
||
|
#include <qdatastream.h>
|
||
|
#include <dcopref.h>
|
||
|
%End
|
||
|
|
||
|
%ModuleCode
|
||
|
|
||
|
void dcop_add (QDataStream& s, int value, const QCString& type_)
|
||
|
{
|
||
|
if (type_ == "char")
|
||
|
s << (Q_INT8)value;
|
||
|
else if (type_ == "bool")
|
||
|
s << (bool)value;
|
||
|
else if (type_ == "short")
|
||
|
s << (short)value;
|
||
|
else if (type_ == "int")
|
||
|
s << (int)value;
|
||
|
else if (type_ == "long")
|
||
|
s << (long)value;
|
||
|
else if (type_== "uchar" || type_ == "unsigned char")
|
||
|
s << (Q_UINT8)value;
|
||
|
else if (type_ == "ushort" || type_ == "unsigned short")
|
||
|
s << (ushort)value;
|
||
|
else if (type_ == "uint" || type_ == "unsigned int")
|
||
|
s << (uint)value;
|
||
|
else if (type_ == "ulong" || type_ == "unsigned long")
|
||
|
s << (long)value;
|
||
|
}
|
||
|
|
||
|
/*void dcop_add (QDataStream& s, longlong value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, ulonglong value)
|
||
|
{
|
||
|
s << value;
|
||
|
}*/
|
||
|
|
||
|
void dcop_add (QDataStream& s, double value, const QCString& type_)
|
||
|
{
|
||
|
if (type_ == "double")
|
||
|
s << value;
|
||
|
else if (type_ == "float")
|
||
|
s << (float)value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QString value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QStringList value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QCString value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, KURL value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, KURL::List value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QSize value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QRect value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QRegion value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QPoint value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QFont value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QCursor value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QPixmap value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QColor value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QColorGroup value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QPalette value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QBrush value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QWidget::FocusPolicy value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, DCOPRef value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QVariant value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QDate value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QTime value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QDateTime value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QImage value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QKeySequence value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QPen value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QPicture value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QPointArray value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
void dcop_add (QDataStream& s, QByteArray value)
|
||
|
{
|
||
|
s << value;
|
||
|
}
|
||
|
|
||
|
%End
|
||
|
|
||
|
|
||
|
%MappedType QMap<QCString,DCOPRef>
|
||
|
//converts a Python dict of QCString:DCOPRef
|
||
|
{
|
||
|
%TypeHeaderCode
|
||
|
#include <qmap.h>
|
||
|
//typedef QMap<QCString,DCOPRef> DCOPRefMap;
|
||
|
%End
|
||
|
|
||
|
%ConvertFromTypeCode
|
||
|
// Convert to a Python dict
|
||
|
|
||
|
if (!sipCpp)
|
||
|
return PyDict_New();
|
||
|
|
||
|
PyObject *dict;
|
||
|
|
||
|
// Create the dictionary.
|
||
|
|
||
|
if ((dict = PyDict_New()) == NULL)
|
||
|
return NULL;
|
||
|
|
||
|
// Get it.
|
||
|
|
||
|
const QMap<QCString,DCOPRef> cppmap = *sipCpp;
|
||
|
QMap<QCString,DCOPRef>::ConstIterator it;
|
||
|
|
||
|
for (it = cppmap.begin (); it != cppmap.end (); ++it)
|
||
|
{
|
||
|
QCString acpp = it.key ();
|
||
|
DCOPRef bcpp = it.data ();
|
||
|
PyObject *ainst;
|
||
|
PyObject *binst = NULL;
|
||
|
if (((ainst = sipConvertFromNewType(new QCString(acpp), sipType_QCString, NULL)) == NULL)
|
||
|
|| ((binst = sipConvertFromNewType(new DCOPRef(bcpp), sipType_DCOPRef, NULL)) == NULL)
|
||
|
|| (PyDict_SetItem (dict, ainst, binst) < 0))
|
||
|
{
|
||
|
Py_XDECREF (ainst);
|
||
|
Py_XDECREF (binst);
|
||
|
Py_DECREF (dict);
|
||
|
return NULL;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return dict;
|
||
|
%End
|
||
|
|
||
|
|
||
|
%ConvertToTypeCode
|
||
|
// Convert a Python dictionary to a QMap on the heap.
|
||
|
|
||
|
if (sipIsErr == NULL)
|
||
|
return PyDict_Check(sipPy);
|
||
|
|
||
|
QMap<QCString,DCOPRef> *cppmap = new QMap<QCString,DCOPRef>;
|
||
|
|
||
|
PyObject *aelem, *belem;
|
||
|
SIP_SSIZE_T pos = 0;
|
||
|
QCString *acpp;
|
||
|
DCOPRef *bcpp;
|
||
|
|
||
|
while (PyDict_Next(sipPy, &pos, &aelem, &belem))
|
||
|
{
|
||
|
int iserr = 0;
|
||
|
|
||
|
acpp = (QCString *)sipForceConvertToType(aelem, sipType_QCString, sipTransferObj, SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);
|
||
|
bcpp = (DCOPRef *)sipForceConvertToType(belem, sipType_DCOPRef, sipTransferObj, SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);
|
||
|
|
||
|
if (iserr)
|
||
|
{
|
||
|
*sipIsErr = 1;
|
||
|
delete cppmap;
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
cppmap->insert (*acpp, *bcpp);
|
||
|
}
|
||
|
|
||
|
*sipCppPtr = cppmap;
|
||
|
|
||
|
return 1;
|
||
|
%End
|
||
|
};
|
||
|
|
||
|
%MappedType QMap<QString,DCOPRef>
|
||
|
//converts a Python dict of QString:DCOPRef
|
||
|
{
|
||
|
%TypeHeaderCode
|
||
|
#include <qmap.h>
|
||
|
//typedef QMap<QString,DCOPRef> DCOPRefMap;
|
||
|
%End
|
||
|
|
||
|
%ConvertFromTypeCode
|
||
|
// Convert to a Python dict
|
||
|
|
||
|
if (!sipCpp)
|
||
|
return PyDict_New();
|
||
|
|
||
|
PyObject *dict;
|
||
|
|
||
|
// Create the dictionary.
|
||
|
|
||
|
if ((dict = PyDict_New()) == NULL)
|
||
|
return NULL;
|
||
|
|
||
|
// Get it.
|
||
|
|
||
|
const QMap<QString,DCOPRef> cppmap = *sipCpp;
|
||
|
QMap<QString,DCOPRef>::ConstIterator it;
|
||
|
|
||
|
for (it = cppmap.begin (); it != cppmap.end (); ++it)
|
||
|
{
|
||
|
QString acpp = it.key ();
|
||
|
DCOPRef bcpp = it.data ();
|
||
|
PyObject *ainst;
|
||
|
PyObject *binst = NULL;
|
||
|
if (((ainst = sipConvertFromNewType(new QString(acpp), sipType_QString, sipTransferObj)) == NULL)
|
||
|
|| ((binst = sipConvertFromNewType(new DCOPRef(bcpp), sipType_DCOPRef, sipTransferObj)) == NULL)
|
||
|
|| (PyDict_SetItem (dict, ainst, binst) < 0))
|
||
|
{
|
||
|
Py_XDECREF (ainst);
|
||
|
Py_XDECREF (binst);
|
||
|
Py_DECREF (dict);
|
||
|
return NULL;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return dict;
|
||
|
%End
|
||
|
|
||
|
|
||
|
%ConvertToTypeCode
|
||
|
// Convert a Python dictionary to a QMap on the heap.
|
||
|
|
||
|
if (sipIsErr == NULL)
|
||
|
return PyDict_Check(sipPy);
|
||
|
|
||
|
QMap<QString,DCOPRef> *cppmap = new QMap<QString,DCOPRef>;
|
||
|
|
||
|
PyObject *aelem, *belem;
|
||
|
SIP_SSIZE_T pos = 0;
|
||
|
QString *acpp;
|
||
|
DCOPRef *bcpp;
|
||
|
|
||
|
while (PyDict_Next(sipPy, &pos, &aelem, &belem))
|
||
|
{
|
||
|
int iserr = 0, acpp_state;
|
||
|
|
||
|
acpp = (QString *)sipForceConvertToType(aelem, sipType_QString, sipTransferObj, SIP_NOT_NONE, &acpp_state, &iserr);
|
||
|
bcpp = (DCOPRef *)sipForceConvertToType(belem, sipType_DCOPRef, sipTransferObj, SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);
|
||
|
|
||
|
if (iserr)
|
||
|
{
|
||
|
if (acpp)
|
||
|
sipReleaseType(acpp, sipType_QString, acpp_state);
|
||
|
|
||
|
*sipIsErr = 1;
|
||
|
delete cppmap;
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
cppmap->insert (*acpp, *bcpp);
|
||
|
|
||
|
sipReleaseType(acpp, sipType_QString, acpp_state);
|
||
|
}
|
||
|
|
||
|
*sipCppPtr = cppmap;
|
||
|
|
||
|
return 1;
|
||
|
%End
|
||
|
};
|
||
|
|
||
|
|
||
|
//%MappedType QMap<QString,QString> is available in kdecore/kconfig.sip
|
||
|
|
||
|
|
||
|
%MappedType QMap<QString,QByteArray>
|
||
|
//converts a Python dict of QString:QByteArray
|
||
|
{
|
||
|
%TypeHeaderCode
|
||
|
#include <qmap.h>
|
||
|
%End
|
||
|
|
||
|
%ConvertFromTypeCode
|
||
|
// Convert to a Python dict
|
||
|
|
||
|
if (!sipCpp)
|
||
|
return PyDict_New();
|
||
|
|
||
|
PyObject *dict;
|
||
|
|
||
|
// Create the dictionary.
|
||
|
|
||
|
if ((dict = PyDict_New()) == NULL)
|
||
|
return NULL;
|
||
|
|
||
|
// Get it.
|
||
|
|
||
|
const QMap<QString,QByteArray> cppmap = *sipCpp;
|
||
|
QMap<QString,QByteArray>::ConstIterator it;
|
||
|
|
||
|
for (it = cppmap.begin (); it != cppmap.end (); ++it)
|
||
|
{
|
||
|
QString acpp = it.key ();
|
||
|
QByteArray bcpp = it.data ();
|
||
|
PyObject *ainst;
|
||
|
PyObject *binst = NULL;
|
||
|
if (((ainst = sipConvertFromNewType(new QString(acpp), sipType_QString, sipTransferObj)) == NULL)
|
||
|
|| ((binst = sipConvertFromNewType(new QByteArray(bcpp), sipType_QByteArray, sipTransferObj)) == NULL)
|
||
|
|| (PyDict_SetItem (dict, ainst, binst) < 0))
|
||
|
{
|
||
|
Py_XDECREF (ainst);
|
||
|
Py_XDECREF (binst);
|
||
|
Py_DECREF (dict);
|
||
|
return NULL;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return dict;
|
||
|
%End
|
||
|
|
||
|
|
||
|
%ConvertToTypeCode
|
||
|
// Convert a Python dictionary to a QMap<QString,QByteArray> on the heap.
|
||
|
|
||
|
if (sipIsErr == NULL)
|
||
|
return PyDict_Check(sipPy);
|
||
|
|
||
|
QMap<QString,QByteArray> *cppmap = new QMap<QString,QByteArray>;
|
||
|
|
||
|
PyObject *aelem, *belem;
|
||
|
SIP_SSIZE_T pos = 0;
|
||
|
QString *acpp;
|
||
|
QByteArray *bcpp;
|
||
|
|
||
|
while (PyDict_Next(sipPy, &pos, &aelem, &belem))
|
||
|
{
|
||
|
int iserr = 0, acpp_state, bcpp_state;
|
||
|
|
||
|
acpp = (QString *)sipForceConvertToType(aelem, sipType_QString, sipTransferObj, SIP_NOT_NONE, &acpp_state, &iserr);
|
||
|
bcpp = (QByteArray *)sipForceConvertToType(belem, sipType_QByteArray, sipTransferObj, SIP_NOT_NONE, &bcpp_state, &iserr);
|
||
|
|
||
|
if (iserr)
|
||
|
{
|
||
|
if (acpp)
|
||
|
sipReleaseType(acpp, sipType_QString, acpp_state);
|
||
|
|
||
|
*sipIsErr = 1;
|
||
|
delete cppmap;
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
cppmap->insert (*acpp, *bcpp);
|
||
|
|
||
|
sipReleaseType(acpp, sipType_QString, acpp_state);
|
||
|
sipReleaseType(bcpp, sipType_QByteArray, bcpp_state);
|
||
|
}
|
||
|
|
||
|
*sipCppPtr = cppmap;
|
||
|
|
||
|
return 1;
|
||
|
%End
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
%MappedType QValueList<DCOPRef>
|
||
|
//converts a Python list of DCOPRef
|
||
|
{
|
||
|
%TypeHeaderCode
|
||
|
#include <qvaluelist.h>
|
||
|
%End
|
||
|
|
||
|
%ConvertFromTypeCode
|
||
|
if (!sipCpp)
|
||
|
return PyList_New(0);
|
||
|
|
||
|
// Create the list
|
||
|
PyObject *pylist;
|
||
|
if ((pylist = PyList_New(0)) == NULL)
|
||
|
return NULL;
|
||
|
|
||
|
QValueList<DCOPRef> *cpplist = (QValueList<DCOPRef> *)sipCpp;
|
||
|
PyObject *inst;
|
||
|
|
||
|
// Get it.
|
||
|
QValueList<DCOPRef>::Iterator it;
|
||
|
for( it = cpplist->begin(); it != cpplist->end(); ++it )
|
||
|
{
|
||
|
if (((inst = sipConvertFromNewType(new DCOPRef(*it), sipType_DCOPRef, NULL)) == NULL)
|
||
|
|| PyList_Append (pylist, inst) < 0)
|
||
|
{
|
||
|
Py_DECREF (pylist);
|
||
|
return NULL;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return pylist;
|
||
|
%End
|
||
|
|
||
|
|
||
|
%ConvertToTypeCode
|
||
|
if (sipIsErr == NULL)
|
||
|
return PyList_Check(sipPy);
|
||
|
|
||
|
QValueList<DCOPRef> *cpplist = new QValueList<DCOPRef>;
|
||
|
|
||
|
PyObject *elem;
|
||
|
DCOPRef *cpp;
|
||
|
int iserr = 0;
|
||
|
|
||
|
for (int i = 0; i < PyList_Size (sipPy); i++)
|
||
|
{
|
||
|
elem = PyList_GET_ITEM (sipPy, i);
|
||
|
cpp = (DCOPRef *)sipForceConvertToType(elem, sipType_DCOPRef, sipTransferObj, SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);
|
||
|
if (iserr)
|
||
|
{
|
||
|
*sipIsErr = 1;
|
||
|
delete cpplist;
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
cpplist->append (*cpp);
|
||
|
}
|
||
|
|
||
|
*sipCppPtr = cpplist;
|
||
|
|
||
|
return 1;
|
||
|
%End
|
||
|
};
|
||
|
|