// // Copyright 2004 Jim Bublitz // 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 %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") { TQMap *map = (TQMap *)map_v; *a0 << *map; } else if (*a2 == "TQMap") { TQMap *map = (TQMap *)map_v; *a0 << *map; } else if (*a2 == "TQMap") { TQMap *map = (TQMap *)map_v; *a0 << *map; } else if (*a2 == "TQMap") { TQMap *map = (TQMap *)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") { TQValueList *list = (TQValueList *)list_v; *a0 << *list; } else if (*a2 == "TQValueList") { TQValueList *list = (TQValueList *)list_v; *a0 << *list; } } %End void dcop_next (TQDataStream&, TQCString&); %MethodCode if (*a1 == "char") { TQ_INT8 res; *a0 >> res; return PyLong_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 PyLong_FromLong ((long)res); } else if (*a1 == "long") { long res; *a0 >> res; return PyLong_FromLong (res); } else if (*a1 == "short") { short res; *a0 >> res; return PyLong_FromLong ((long)res); } if (*a1 == "uchar" || *a1 == "unsigned char") { TQ_UINT8 res; *a0 >> res; return PyLong_FromLong ((long)res); } else if (*a1 == "uint" || *a1 == "unsigned int") { unsigned int res; *a0 >> res; return PyLong_FromLong ((long)res); } else if (*a1 == "ulong" || *a1 == "unsigned long") { unsigned long res; *a0 >> res; return PyLong_FromLong (res); } else if (*a1 == "TQ_INT32") { TQ_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 PyLong_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_TQString, NULL); } else if (*a1 == "TQStringList") { TQStringList res; *a0 >> res; return sipConvertFromNewType(new TQStringList(res), sipType_TQStringList, NULL); } else if (*a1 == "TQCString") { TQCString res; *a0 >> res; return sipConvertFromNewType(new TQCString(res), sipType_TQCString, 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_TQSize, NULL); } else if (*a1 == "TQRect") { TQRect res; *a0 >> res; return sipConvertFromNewType(new TQRect(res), sipType_TQRect, NULL); } else if (*a1 == "TQRegion") { TQRect res; *a0 >> res; return sipConvertFromNewType(new TQRegion(res), sipType_TQRegion, NULL); } else if (*a1 == "TQPoint") { TQPoint res; *a0 >> res; return sipConvertFromNewType(new TQPoint(res), sipType_TQPoint, NULL); } else if (*a1 == "TQFont") { TQFont res; *a0 >> res; return sipConvertFromNewType(new TQFont(res), sipType_TQFont, NULL); } else if (*a1 == "TQCursor") { TQCursor res; *a0 >> res; return sipConvertFromNewType(new TQCursor(res), sipType_TQCursor, NULL); } else if (*a1 == "TQPixmap") { TQPixmap res; *a0 >> res; return sipConvertFromNewType(new TQPixmap(res), sipType_TQPixmap, NULL); } else if (*a1 == "TQColor") { TQColor res; *a0 >> res; return sipConvertFromNewType(new TQColor(res), sipType_TQColor, NULL); } else if (*a1 == "TQColorGroup") { TQColorGroup res; *a0 >> res; return sipConvertFromNewType(new TQColorGroup(res), sipType_TQColorGroup, NULL); } else if (*a1 == "TQPalette") { TQPalette res; *a0 >> res; return sipConvertFromNewType(new TQPalette(res), sipType_TQPalette, NULL); } else if (*a1 == "TQBrush") { TQBrush res; *a0 >> res; return sipConvertFromNewType(new TQBrush(res), sipType_TQBrush, NULL); } else if (*a1 == "FocusPolicy") { unsigned int res; *a0 >> res; return PyLong_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_TQVariant, NULL); } else if (*a1 == "TQDate") { TQDate res; *a0 >> res; return sipConvertFromNewType(new TQDate(res), sipType_TQDate, NULL); } else if (*a1 == "TQTime") { TQTime res; *a0 >> res; return sipConvertFromNewType(new TQTime(res), sipType_TQTime, NULL); } else if (*a1 == "TQDateTime") { TQDateTime res; *a0 >> res; return sipConvertFromNewType(new TQDateTime(res), sipType_TQDateTime, NULL); } else if (*a1 == "TQImage") { TQImage res; *a0 >> res; return sipConvertFromNewType(new TQImage(res), sipType_TQImage, NULL); } else if (*a1 == "TQKeySequence") { TQKeySequence res; *a0 >> res; return sipConvertFromNewType(new TQKeySequence(res), sipType_TQKeySequence, NULL); } else if (*a1 == "TQPen") { TQPen res; *a0 >> res; return sipConvertFromNewType(new TQPen(res), sipType_TQPen, NULL); } else if (*a1 == "TQPicture") { TQPicture res; *a0 >> res; return sipConvertFromNewType(new TQPicture(res), sipType_TQPicture, NULL); } else if (*a1 == "TQPointArray") { TQPointArray res; *a0 >> res; return sipConvertFromNewType(new TQPointArray(res), sipType_TQPointArray, NULL); } else if (*a1 == "TQByteArray") { TQByteArray res; *a0 >> res; return sipConvertFromNewType(new TQByteArray(res), sipType_TQByteArray, NULL); } else if (*a1 == "TQMap") { TQMap res; *a0 >> res; return sipConvertFromType(&res, sipFindType(*a1), NULL); } else if (*a1 == "TQMap") { TQMap res; *a0 >> res; return sipConvertFromType(&res, sipFindType(*a1), NULL); } else if (*a1 == "TQMap") { TQMap res; *a0 >> res; return sipConvertFromType(&res, sipFindType(*a1), NULL); } else if (*a1 == "TQMap") { TQMap res; *a0 >> res; return sipConvertFromType(&res, sipFindType(*a1), NULL); } else if (*a1 == "TQValueList") { TQValueList res; *a0 >> res; return sipConvertFromType(&res, sipFindType(*a1), NULL); } else if (*a1 == "TQValueList" || *a1 == "QCStringList") { TQValueList res; *a0 >> res; return sipConvertFromType(&res, sipFindType(*a1), NULL); } %End %ModuleHeaderCode #include #include #include %End %ModuleCode void dcop_add (TQDataStream& s, int value, const TQCString& type_) { if (type_ == "char") s << (TQ_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 << (TQ_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 //converts a Python dict of TQCString:DCOPRef { %TypeHeaderCode #include //typedef TQMap 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 cppmap = *sipCpp; TQMap::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_TQCString, 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 *cppmap = new TQMap; 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_TQCString, 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 //converts a Python dict of TQString:DCOPRef { %TypeHeaderCode #include //typedef TQMap 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 cppmap = *sipCpp; TQMap::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_TQString, 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 *cppmap = new TQMap; 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_TQString, 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_TQString, acpp_state); *sipIsErr = 1; delete cppmap; return 0; } cppmap->insert (*acpp, *bcpp); sipReleaseType(acpp, sipType_TQString, acpp_state); } *sipCppPtr = cppmap; return 1; %End }; //%MappedType TQMap is available in tdecore/tdeconfig.sip %MappedType TQMap //converts a Python dict of TQString:TQByteArray { %TypeHeaderCode #include %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 cppmap = *sipCpp; TQMap::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_TQString, sipTransferObj)) == NULL) || ((binst = sipConvertFromNewType(new TQByteArray(bcpp), sipType_TQByteArray, 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 *cppmap = new TQMap; 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_TQString, sipTransferObj, SIP_NOT_NONE, &acpp_state, &iserr); bcpp = (TQByteArray *)sipForceConvertToType(belem, sipType_TQByteArray, sipTransferObj, SIP_NOT_NONE, &bcpp_state, &iserr); if (iserr) { if (acpp) sipReleaseType(acpp, sipType_TQString, acpp_state); *sipIsErr = 1; delete cppmap; return 0; } cppmap->insert (*acpp, *bcpp); sipReleaseType(acpp, sipType_TQString, acpp_state); sipReleaseType(bcpp, sipType_TQByteArray, bcpp_state); } *sipCppPtr = cppmap; return 1; %End }; %MappedType TQValueList //converts a Python list of DCOPRef { %TypeHeaderCode #include %End %ConvertFromTypeCode if (!sipCpp) return PyList_New(0); // Create the list PyObject *pylist; if ((pylist = PyList_New(0)) == NULL) return NULL; TQValueList *cpplist = (TQValueList *)sipCpp; PyObject *inst; // Get it. TQValueList::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 *cpplist = new TQValueList; 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 };