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
//
|
|
// Copyright 2004 Jim Bublitz <jbublitz@nwinternet.com>
|
|
// Earlier copyrights 1998 - 2003 Jim Bublitz and/or Phil Thompson
|
|
// may also apply
|
|
|
|
// module tdecore 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 (TQDataStream&, TQWidget::FocusPolicy /Constrained/);
|
|
void dcop_add (TQDataStream&, int /Constrained/, const TQCString& = "int");
|
|
//void dcop_add (TQDataStream&, longlong);
|
|
//void dcop_add (TQDataStream&, ulonglong);
|
|
void dcop_add (TQDataStream&, double, const TQCString& = "double");
|
|
void dcop_add (TQDataStream&, TQString);
|
|
void dcop_add (TQDataStream&, TQStringList);
|
|
void dcop_add (TQDataStream&, TQCString);
|
|
void dcop_add (TQDataStream&, KURL);
|
|
void dcop_add (TQDataStream&, KURL::List);
|
|
void dcop_add (TQDataStream&, TQSize);
|
|
void dcop_add (TQDataStream&, TQRect);
|
|
void dcop_add (TQDataStream&, TQRegion);
|
|
void dcop_add (TQDataStream&, TQPoint);
|
|
void dcop_add (TQDataStream&, TQFont);
|
|
void dcop_add (TQDataStream&, TQCursor);
|
|
void dcop_add (TQDataStream&, TQPixmap);
|
|
void dcop_add (TQDataStream&, TQColor);
|
|
void dcop_add (TQDataStream&, TQColorGroup);
|
|
void dcop_add (TQDataStream&, TQPalette);
|
|
void dcop_add (TQDataStream&, TQBrush);
|
|
void dcop_add (TQDataStream&, DCOPRef);
|
|
void dcop_add (TQDataStream&, TQVariant);
|
|
void dcop_add (TQDataStream&, TQDate);
|
|
void dcop_add (TQDataStream&, TQTime);
|
|
void dcop_add (TQDataStream&, TQDateTime);
|
|
void dcop_add (TQDataStream&, TQImage);
|
|
void dcop_add (TQDataStream&, TQKeySequence);
|
|
void dcop_add (TQDataStream&, TQPen);
|
|
void dcop_add (TQDataStream&, TQPicture);
|
|
void dcop_add (TQDataStream&, TQPointArray);
|
|
void dcop_add (TQDataStream&, TQByteArray);
|
|
|
|
void dcop_add (TQDataStream&, SIP_PYDICT, TQCString);
|
|
%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 == "TQMap<TQCString,DCOPRef>")
|
|
{
|
|
TQMap<TQCString,DCOPRef> *map = (TQMap<TQCString,DCOPRef> *)map_v;
|
|
|
|
*a0 << *map;
|
|
}
|
|
else if (*a2 == "TQMap<TQString,DCOPRef>")
|
|
{
|
|
TQMap<TQString,DCOPRef> *map = (TQMap<TQString,DCOPRef> *)map_v;
|
|
|
|
*a0 << *map;
|
|
}
|
|
else if (*a2 == "TQMap<TQString,TQString>")
|
|
{
|
|
TQMap<TQString,TQString> *map = (TQMap<TQString,TQString> *)map_v;
|
|
|
|
*a0 << *map;
|
|
}
|
|
else if (*a2 == "TQMap<TQString,TQByteArray>")
|
|
{
|
|
TQMap<TQString,TQByteArray> *map = (TQMap<TQString,TQByteArray> *)map_v;
|
|
|
|
*a0 << *map;
|
|
}
|
|
}
|
|
%End
|
|
|
|
|
|
void dcop_add (TQDataStream&, SIP_PYLIST, TQCString);
|
|
%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 == "TQValueList<TQCString>")
|
|
{
|
|
TQValueList<TQCString> *list = (TQValueList<TQCString> *)list_v;
|
|
|
|
*a0 << *list;
|
|
}
|
|
else if (*a2 == "TQValueList<DCOPRef>")
|
|
{
|
|
TQValueList<DCOPRef> *list = (TQValueList<DCOPRef> *)list_v;
|
|
|
|
*a0 << *list;
|
|
}
|
|
}
|
|
%End
|
|
|
|
|
|
void dcop_next (TQDataStream&, TQCString&);
|
|
%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 == "TQString")
|
|
{
|
|
TQString res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQString(res), sipType_QString, NULL);
|
|
}
|
|
else if (*a1 == "TQStringList")
|
|
{
|
|
TQStringList res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQStringList(res), sipType_QStringList, NULL);
|
|
}
|
|
else if (*a1 == "TQCString")
|
|
{
|
|
TQCString res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQCString(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 == "TQSize")
|
|
{
|
|
TQSize res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQSize(res), sipType_QSize, NULL);
|
|
}
|
|
else if (*a1 == "TQRect")
|
|
{
|
|
TQRect res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQRect(res), sipType_QRect, NULL);
|
|
}
|
|
else if (*a1 == "TQRegion")
|
|
{
|
|
TQRect res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQRegion(res), sipType_QRegion, NULL);
|
|
}
|
|
else if (*a1 == "TQPoint")
|
|
{
|
|
TQPoint res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQPoint(res), sipType_QPoint, NULL);
|
|
}
|
|
else if (*a1 == "TQFont")
|
|
{
|
|
TQFont res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQFont(res), sipType_QFont, NULL);
|
|
}
|
|
else if (*a1 == "TQCursor")
|
|
{
|
|
TQCursor res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQCursor(res), sipType_QCursor, NULL);
|
|
}
|
|
else if (*a1 == "TQPixmap")
|
|
{
|
|
TQPixmap res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQPixmap(res), sipType_QPixmap, NULL);
|
|
}
|
|
else if (*a1 == "TQColor")
|
|
{
|
|
TQColor res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQColor(res), sipType_QColor, NULL);
|
|
}
|
|
else if (*a1 == "TQColorGroup")
|
|
{
|
|
TQColorGroup res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQColorGroup(res), sipType_QColorGroup, NULL);
|
|
}
|
|
else if (*a1 == "TQPalette")
|
|
{
|
|
TQPalette res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQPalette(res), sipType_QPalette, NULL);
|
|
}
|
|
else if (*a1 == "TQBrush")
|
|
{
|
|
TQBrush res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQBrush(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 == "TQVariant")
|
|
{
|
|
TQVariant res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQVariant(res), sipType_QVariant, NULL);
|
|
}
|
|
else if (*a1 == "TQDate")
|
|
{
|
|
TQDate res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQDate(res), sipType_QDate, NULL);
|
|
}
|
|
else if (*a1 == "TQTime")
|
|
{
|
|
TQTime res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQTime(res), sipType_QTime, NULL);
|
|
}
|
|
else if (*a1 == "TQDateTime")
|
|
{
|
|
TQDateTime res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQDateTime(res), sipType_QDateTime, NULL);
|
|
}
|
|
else if (*a1 == "TQImage")
|
|
{
|
|
TQImage res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQImage(res), sipType_QImage, NULL);
|
|
}
|
|
else if (*a1 == "TQKeySequence")
|
|
{
|
|
TQKeySequence res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQKeySequence(res), sipType_QKeySequence, NULL);
|
|
}
|
|
else if (*a1 == "TQPen")
|
|
{
|
|
TQPen res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQPen(res), sipType_QPen, NULL);
|
|
}
|
|
else if (*a1 == "TQPicture")
|
|
{
|
|
TQPicture res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQPicture(res), sipType_QPicture, NULL);
|
|
}
|
|
else if (*a1 == "TQPointArray")
|
|
{
|
|
TQPointArray res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQPointArray(res), sipType_QPointArray, NULL);
|
|
}
|
|
else if (*a1 == "TQByteArray")
|
|
{
|
|
TQByteArray res;
|
|
*a0 >> res;
|
|
return sipConvertFromNewType(new TQByteArray(res), sipType_QByteArray, NULL);
|
|
}
|
|
else if (*a1 == "TQMap<TQCString,DCOPRef>")
|
|
{
|
|
TQMap<TQCString, DCOPRef> res;
|
|
*a0 >> res;
|
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
|
}
|
|
else if (*a1 == "TQMap<TQString,DCOPRef>")
|
|
{
|
|
TQMap<TQString, DCOPRef> res;
|
|
*a0 >> res;
|
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
|
}
|
|
else if (*a1 == "TQMap<TQString,TQString>")
|
|
{
|
|
TQMap<TQString, TQString> res;
|
|
*a0 >> res;
|
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
|
}
|
|
else if (*a1 == "TQMap<TQString,TQByteArray>")
|
|
{
|
|
TQMap<TQString, TQByteArray> res;
|
|
*a0 >> res;
|
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
|
}
|
|
else if (*a1 == "TQValueList<TQCString>")
|
|
{
|
|
TQValueList<TQCString> res;
|
|
*a0 >> res;
|
|
return sipConvertFromType(&res, sipFindType(*a1), NULL);
|
|
}
|
|
else if (*a1 == "TQValueList<DCOPRef>" || *a1 == "QCStringList")
|
|
{
|
|
TQValueList<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 (TQDataStream& s, int value, const TQCString& 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 (TQDataStream& s, longlong value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, ulonglong value)
|
|
{
|
|
s << value;
|
|
}*/
|
|
|
|
void dcop_add (TQDataStream& s, double value, const TQCString& type_)
|
|
{
|
|
if (type_ == "double")
|
|
s << value;
|
|
else if (type_ == "float")
|
|
s << (float)value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQString value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQStringList value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQCString value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, KURL value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, KURL::List value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQSize value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQRect value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQRegion value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQPoint value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQFont value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQCursor value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQPixmap value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQColor value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQColorGroup value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQPalette value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQBrush value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQWidget::FocusPolicy value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, DCOPRef value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQVariant value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQDate value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQTime value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQDateTime value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQImage value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQKeySequence value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQPen value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQPicture value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQPointArray value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
void dcop_add (TQDataStream& s, TQByteArray value)
|
|
{
|
|
s << value;
|
|
}
|
|
|
|
%End
|
|
|
|
|
|
%MappedType TQMap<TQCString,DCOPRef>
|
|
//converts a Python dict of TQCString:DCOPRef
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qmap.h>
|
|
//typedef TQMap<TQCString,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 TQMap<TQCString,DCOPRef> cppmap = *sipCpp;
|
|
TQMap<TQCString,DCOPRef>::ConstIterator it;
|
|
|
|
for (it = cppmap.begin (); it != cppmap.end (); ++it)
|
|
{
|
|
TQCString acpp = it.key ();
|
|
DCOPRef bcpp = it.data ();
|
|
PyObject *ainst;
|
|
PyObject *binst = NULL;
|
|
if (((ainst = sipConvertFromNewType(new TQCString(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 TQMap on the heap.
|
|
|
|
if (sipIsErr == NULL)
|
|
return PyDict_Check(sipPy);
|
|
|
|
TQMap<TQCString,DCOPRef> *cppmap = new TQMap<TQCString,DCOPRef>;
|
|
|
|
PyObject *aelem, *belem;
|
|
SIP_SSIZE_T pos = 0;
|
|
TQCString *acpp;
|
|
DCOPRef *bcpp;
|
|
|
|
while (PyDict_Next(sipPy, &pos, &aelem, &belem))
|
|
{
|
|
int iserr = 0;
|
|
|
|
acpp = (TQCString *)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 TQMap<TQString,DCOPRef>
|
|
//converts a Python dict of TQString:DCOPRef
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qmap.h>
|
|
//typedef TQMap<TQString,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 TQMap<TQString,DCOPRef> cppmap = *sipCpp;
|
|
TQMap<TQString,DCOPRef>::ConstIterator it;
|
|
|
|
for (it = cppmap.begin (); it != cppmap.end (); ++it)
|
|
{
|
|
TQString acpp = it.key ();
|
|
DCOPRef bcpp = it.data ();
|
|
PyObject *ainst;
|
|
PyObject *binst = NULL;
|
|
if (((ainst = sipConvertFromNewType(new TQString(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 TQMap on the heap.
|
|
|
|
if (sipIsErr == NULL)
|
|
return PyDict_Check(sipPy);
|
|
|
|
TQMap<TQString,DCOPRef> *cppmap = new TQMap<TQString,DCOPRef>;
|
|
|
|
PyObject *aelem, *belem;
|
|
SIP_SSIZE_T pos = 0;
|
|
TQString *acpp;
|
|
DCOPRef *bcpp;
|
|
|
|
while (PyDict_Next(sipPy, &pos, &aelem, &belem))
|
|
{
|
|
int iserr = 0, acpp_state;
|
|
|
|
acpp = (TQString *)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 TQMap<TQString,TQString> is available in tdecore/kconfig.sip
|
|
|
|
|
|
%MappedType TQMap<TQString,TQByteArray>
|
|
//converts a Python dict of TQString:TQByteArray
|
|
{
|
|
%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 TQMap<TQString,TQByteArray> cppmap = *sipCpp;
|
|
TQMap<TQString,TQByteArray>::ConstIterator it;
|
|
|
|
for (it = cppmap.begin (); it != cppmap.end (); ++it)
|
|
{
|
|
TQString acpp = it.key ();
|
|
TQByteArray bcpp = it.data ();
|
|
PyObject *ainst;
|
|
PyObject *binst = NULL;
|
|
if (((ainst = sipConvertFromNewType(new TQString(acpp), sipType_QString, sipTransferObj)) == NULL)
|
|
|| ((binst = sipConvertFromNewType(new TQByteArray(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 TQMap<TQString,TQByteArray> on the heap.
|
|
|
|
if (sipIsErr == NULL)
|
|
return PyDict_Check(sipPy);
|
|
|
|
TQMap<TQString,TQByteArray> *cppmap = new TQMap<TQString,TQByteArray>;
|
|
|
|
PyObject *aelem, *belem;
|
|
SIP_SSIZE_T pos = 0;
|
|
TQString *acpp;
|
|
TQByteArray *bcpp;
|
|
|
|
while (PyDict_Next(sipPy, &pos, &aelem, &belem))
|
|
{
|
|
int iserr = 0, acpp_state, bcpp_state;
|
|
|
|
acpp = (TQString *)sipForceConvertToType(aelem, sipType_QString, sipTransferObj, SIP_NOT_NONE, &acpp_state, &iserr);
|
|
bcpp = (TQByteArray *)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 TQValueList<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;
|
|
|
|
TQValueList<DCOPRef> *cpplist = (TQValueList<DCOPRef> *)sipCpp;
|
|
PyObject *inst;
|
|
|
|
// Get it.
|
|
TQValueList<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);
|
|
|
|
TQValueList<DCOPRef> *cpplist = new TQValueList<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
|
|
};
|
|
|