diff options
Diffstat (limited to 'lib/kross/python/pythonextension.cpp')
-rw-r--r-- | lib/kross/python/pythonextension.cpp | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/lib/kross/python/pythonextension.cpp b/lib/kross/python/pythonextension.cpp index 59d9aaed..aab781ab 100644 --- a/lib/kross/python/pythonextension.cpp +++ b/lib/kross/python/pythonextension.cpp @@ -31,7 +31,7 @@ PythonExtension::PythonExtension(Kross::Api::Object::Ptr object) , m_object(object) { #ifdef KROSS_PYTHON_EXTENSION_CTOR_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::Constructor objectname='%1' objectclass='%2'").arg(m_object->getName()).arg(m_object->getClassName()) ); + krossdebug( TQString("Kross::Python::PythonExtension::Constructor objectname='%1' objectclass='%2'").tqarg(m_object->getName()).tqarg(m_object->getClassName()) ); #endif behaviors().name("KrossPythonExtension"); @@ -55,7 +55,7 @@ PythonExtension::PythonExtension(Kross::Api::Object::Ptr object) PythonExtension::~PythonExtension() { #ifdef KROSS_PYTHON_EXTENSION_DTOR_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::Destructor objectname='%1' objectclass='%2'").arg(m_object->getName()).arg(m_object->getClassName()) ); + krossdebug( TQString("Kross::Python::PythonExtension::Destructor objectname='%1' objectclass='%2'").tqarg(m_object->getName()).tqarg(m_object->getClassName()) ); #endif delete m_proxymethod; } @@ -64,7 +64,7 @@ PythonExtension::~PythonExtension() Py::Object PythonExtension::str() { Kross::Api::Callable* callable = dynamic_cast< Kross::Api::Callable* >(m_object); - QString s = callable ? callable->getName() : m_object->getClassName(); + TQString s = callable ? callable->getName() : m_object->getClassName(); return toPyObject(s.isEmpty() ? : s); } @@ -77,16 +77,16 @@ Py::Object PythonExtension::repr() Py::Object PythonExtension::getattr(const char* n) { #ifdef KROSS_PYTHON_EXTENSION_GETATTR_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::getattr name='%1'").arg(n) ); + krossdebug( TQString("Kross::Python::PythonExtension::getattr name='%1'").tqarg(n) ); #endif if(n[0] == '_') { if(!strcmp(n, "__methods__")) { Py::List methods; - QStringList calls = m_object->getCalls(); - for(QStringList::Iterator it = calls.begin(); it != calls.end(); ++it) { + TQStringList calls = m_object->getCalls(); + for(TQStringList::Iterator it = calls.begin(); it != calls.end(); ++it) { #ifdef KROSS_PYTHON_EXTENSION_GETATTR_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::getattr name='%1' callable='%2'").arg(n).arg(*it) ); + krossdebug( TQString("Kross::Python::PythonExtension::getattr name='%1' callable='%2'").tqarg(n).tqarg(*it) ); #endif methods.append(Py::String( (*it).latin1() )); } @@ -97,11 +97,11 @@ Py::Object PythonExtension::getattr(const char* n) Py::List members; Kross::Api::Callable* callable = dynamic_cast<Kross::Api::Callable*>(m_object.data()); if(callable) { - QMap<QString, Kross::Api::Object::Ptr> children = callable->getChildren(); - QMap<QString, Kross::Api::Object::Ptr>::Iterator it( children.begin() ); - for(; it != children.end(); ++it) { + TQMap<TQString, Kross::Api::Object::Ptr> tqchildren = callable->getChildren(); + TQMap<TQString, Kross::Api::Object::Ptr>::Iterator it( tqchildren.begin() ); + for(; it != tqchildren.end(); ++it) { #ifdef KROSS_PYTHON_EXTENSION_GETATTR_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::getattr n='%1' child='%2'").arg(n).arg(it.key()) ); + krossdebug( TQString("Kross::Python::PythonExtension::getattr n='%1' child='%2'").tqarg(n).tqarg(it.key()) ); #endif members.append(Py::String( it.key().latin1() )); } @@ -109,11 +109,11 @@ Py::Object PythonExtension::getattr(const char* n) return members; } - //if(n == "__dict__") { krosswarning( QString("PythonExtension::getattr(%1) __dict__").arg(n) ); return Py::None(); } - //if(n == "__class__") { krosswarning( QString("PythonExtension::getattr(%1) __class__").arg(n) ); return Py::None(); } + //if(n == "__dict__") { krosswarning( TQString("PythonExtension::getattr(%1) __dict__").tqarg(n) ); return Py::None(); } + //if(n == "__class__") { krosswarning( TQString("PythonExtension::getattr(%1) __class__").tqarg(n) ); return Py::None(); } #ifdef KROSS_PYTHON_EXTENSION_GETATTR_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::getattr name='%1' is a internal name.").arg(n) ); + krossdebug( TQString("Kross::Python::PythonExtension::getattr name='%1' is a internal name.").tqarg(n) ); #endif return Py::PythonExtension<PythonExtension>::getattr_methods(n); } @@ -130,7 +130,7 @@ Py::Object PythonExtension::getattr(const char* n) Py::Object PythonExtension::getattr_methods(const char* n) { #ifdef KROSS_PYTHON_EXTENSION_GETATTRMETHOD_DEBUG - krossdebug( QString("PythonExtension::getattr_methods name=%1").arg(n) ); + krossdebug( TQString("PythonExtension::getattr_methods name=%1").tqarg(n) ); #endif return Py::PythonExtension<PythonExtension>::getattr_methods(n); } @@ -138,7 +138,7 @@ Py::Object PythonExtension::getattr_methods(const char* n) int PythonExtension::setattr(const char* name, const Py::Object& value) { #ifdef KROSS_PYTHON_EXTENSION_SETATTR_DEBUG - krossdebug( QString("PythonExtension::setattr name=%1 value=%2").arg(name).arg(value.as_string().c_str()) ); + krossdebug( TQString("PythonExtension::setattr name=%1 value=%2").tqarg(name).tqarg(value.as_string().c_str()) ); #endif return Py::PythonExtension<PythonExtension>::setattr(name, value); } @@ -147,10 +147,10 @@ int PythonExtension::setattr(const char* name, const Py::Object& value) Kross::Api::List::Ptr PythonExtension::toObject(const Py::Tuple& tuple) { #ifdef KROSS_PYTHON_EXTENSION_TOOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toObject(Py::Tuple)") ); + krossdebug( TQString("Kross::Python::PythonExtension::toObject(Py::Tuple)") ); #endif - QValueList<Kross::Api::Object::Ptr> l; + TQValueList<Kross::Api::Object::Ptr> l; uint size = tuple.size(); for(uint i = 0; i < size; i++) l.append( toObject( tuple[i] ) ); @@ -160,10 +160,10 @@ Kross::Api::List::Ptr PythonExtension::toObject(const Py::Tuple& tuple) Kross::Api::List::Ptr PythonExtension::toObject(const Py::List& list) { #ifdef KROSS_PYTHON_EXTENSION_TOOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toObject(Py::List)") ); + krossdebug( TQString("Kross::Python::PythonExtension::toObject(Py::List)") ); #endif - QValueList<Kross::Api::Object::Ptr> l; + TQValueList<Kross::Api::Object::Ptr> l; uint length = list.length(); for(uint i = 0; i < length; i++) l.append( toObject( list[i] ) ); @@ -172,12 +172,12 @@ Kross::Api::List::Ptr PythonExtension::toObject(const Py::List& list) Kross::Api::Dict::Ptr PythonExtension::toObject(const Py::Dict& dict) { - QMap<QString, Kross::Api::Object::Ptr> map; + TQMap<TQString, Kross::Api::Object::Ptr> map; Py::List l = dict.keys(); uint length = l.length(); for(Py::List::size_type i = 0; i < length; ++i) { const char* n = l[i].str().as_string().c_str(); - map.replace(n, toObject( dict[n] )); + map.tqreplace(n, toObject( dict[n] )); } return new Kross::Api::Dict(map); } @@ -185,20 +185,20 @@ Kross::Api::Dict::Ptr PythonExtension::toObject(const Py::Dict& dict) Kross::Api::Object::Ptr PythonExtension::toObject(const Py::Object& object) { #ifdef KROSS_PYTHON_EXTENSION_TOOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toObject(Py::Object) object='%1'").arg(object.as_string().c_str()) ); + krossdebug( TQString("Kross::Python::PythonExtension::toObject(Py::Object) object='%1'").tqarg(object.as_string().c_str()) ); #endif if(object == Py::None()) return 0; PyTypeObject *type = (PyTypeObject*) object.type().ptr(); #ifdef KROSS_PYTHON_EXTENSION_TOOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toObject(Py::Object) type='%1'").arg(type->tp_name) ); + krossdebug( TQString("Kross::Python::PythonExtension::toObject(Py::Object) type='%1'").tqarg(type->tp_name) ); #endif if(type == &PyInt_Type) return new Kross::Api::Variant(int(Py::Int(object))); if(type == &PyBool_Type) - return new Kross::Api::Variant(QVariant(object.isTrue(),0)); + return new Kross::Api::Variant(TQVariant(object.isTrue(),0)); if(type == &PyLong_Type) - return new Kross::Api::Variant(Q_LLONG(long(Py::Long(object)))); + return new Kross::Api::Variant(TQ_LLONG(long(Py::Long(object)))); if(type == &PyFloat_Type) return new Kross::Api::Variant(double(Py::Float(object))); @@ -206,7 +206,7 @@ Kross::Api::Object::Ptr PythonExtension::toObject(const Py::Object& object) #ifdef Py_USING_UNICODE /* TODO if(type == &PyUnicode_Type) { - Py::unicodestring u = Py::String(object).as_unicodestring(); + Py::tqunicodestring u = Py::String(object).as_tqunicodestring(); std::string s; std::copy(u.begin(), u.end(), std::back_inserter(s)); return new Kross::Api::Variant(s.c_str()); @@ -243,95 +243,95 @@ Kross::Api::Object::Ptr PythonExtension::toObject(const Py::Object& object) return extension->m_object; } -const Py::Object PythonExtension::toPyObject(const QString& s) +const Py::Object PythonExtension::toPyObject(const TQString& s) { #ifdef KROSS_PYTHON_EXTENSION_TOPYOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toPyObject(QString)") ); + krossdebug( TQString("Kross::Python::PythonExtension::toPyObject(TQString)") ); #endif return s.isNull() ? Py::String() : Py::String(s.latin1()); } -const Py::List PythonExtension::toPyObject(const QStringList& list) +const Py::List PythonExtension::toPyObject(const TQStringList& list) { #ifdef KROSS_PYTHON_EXTENSION_TOPYOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toPyObject(QStringList)") ); + krossdebug( TQString("Kross::Python::PythonExtension::toPyObject(TQStringList)") ); #endif Py::List l; - for(QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) + for(TQStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) l.append(toPyObject(*it)); return l; } -const Py::Dict PythonExtension::toPyObject(const QMap<QString, QVariant>& map) +const Py::Dict PythonExtension::toPyObject(const TQMap<TQString, TQVariant>& map) { #ifdef KROSS_PYTHON_EXTENSION_TOPYOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toPyObject(QMap<QString,QVariant>)") ); + krossdebug( TQString("Kross::Python::PythonExtension::toPyObject(TQMap<TQString,TQVariant>)") ); #endif Py::Dict d; - for(QMap<QString, QVariant>::ConstIterator it = map.constBegin(); it != map.constEnd(); ++it) + for(TQMap<TQString, TQVariant>::ConstIterator it = map.constBegin(); it != map.constEnd(); ++it) d.setItem(it.key().latin1(), toPyObject(it.data())); return d; } -const Py::List PythonExtension::toPyObject(const QValueList<QVariant>& list) +const Py::List PythonExtension::toPyObject(const TQValueList<TQVariant>& list) { #ifdef KROSS_PYTHON_EXTENSION_TOPYOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toPyObject(QValueList<QVariant>)") ); + krossdebug( TQString("Kross::Python::PythonExtension::toPyObject(TQValueList<TQVariant>)") ); #endif Py::List l; - for(QValueList<QVariant>::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) + for(TQValueList<TQVariant>::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) l.append(toPyObject(*it)); return l; } -const Py::Object PythonExtension::toPyObject(const QVariant& variant) +const Py::Object PythonExtension::toPyObject(const TQVariant& variant) { #ifdef KROSS_PYTHON_EXTENSION_TOPYOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toPyObject(QVariant) typename='%1'").arg(variant.typeName()) ); + krossdebug( TQString("Kross::Python::PythonExtension::toPyObject(TQVariant) typename='%1'").tqarg(variant.typeName()) ); #endif switch(variant.type()) { - case QVariant::Invalid: + case TQVariant::Invalid: return Py::None(); - case QVariant::Bool: + case TQVariant::Bool: return Py::Int(variant.toBool()); - case QVariant::Int: + case TQVariant::Int: return Py::Int(variant.toInt()); - case QVariant::UInt: + case TQVariant::UInt: return Py::Long((unsigned long)variant.toUInt()); - case QVariant::Double: + case TQVariant::Double: return Py::Float(variant.toDouble()); - case QVariant::Date: - case QVariant::Time: - case QVariant::DateTime: - case QVariant::ByteArray: - case QVariant::BitArray: - case QVariant::CString: - case QVariant::String: + case TQVariant::Date: + case TQVariant::Time: + case TQVariant::DateTime: + case TQVariant::ByteArray: + case TQVariant::BitArray: + case TQVariant::CString: + case TQVariant::String: return toPyObject(variant.toString()); - case QVariant::StringList: + case TQVariant::StringList: return toPyObject(variant.toStringList()); - case QVariant::Map: + case TQVariant::Map: return toPyObject(variant.toMap()); - case QVariant::List: + case TQVariant::List: return toPyObject(variant.toList()); // To handle following both cases is a bit difficult // cause Python doesn't spend an easy possibility // for such large numbers (TODO maybe BigInt?). So, // we risk overflows here, but well... - case QVariant::LongLong: { - Q_LLONG l = variant.toLongLong(); + case TQVariant::LongLong: { + TQ_LLONG l = variant.toLongLong(); //return (l < 0) ? Py::Long((long)l) : Py::Long((unsigned long)l); return Py::Long((long)l); //return Py::Long(PyLong_FromLong( (long)l ), true); } break; - case QVariant::ULongLong: { + case TQVariant::ULongLong: { return Py::Long((unsigned long)variant.toULongLong()); } break; default: { - krosswarning( QString("Kross::Python::PythonExtension::toPyObject(QVariant) Not possible to convert the QVariant type '%1' to a Py::Object.").arg(variant.typeName()) ); + krosswarning( TQString("Kross::Python::PythonExtension::toPyObject(TQVariant) Not possible to convert the TQVariant type '%1' to a Py::Object.").tqarg(variant.typeName()) ); return Py::None(); } } @@ -346,11 +346,11 @@ const Py::Object PythonExtension::toPyObject(Kross::Api::Object::Ptr object) return Py::None(); } - const QString classname = object->getClassName(); + const TQString classname = object->getClassName(); if(classname == "Kross::Api::Variant") { - QVariant v = static_cast<Kross::Api::Variant*>( object.data() )->getValue(); + TQVariant v = static_cast<Kross::Api::Variant*>( object.data() )->getValue(); #ifdef KROSS_PYTHON_EXTENSION_TOPYOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toPyObject(Kross::Api::Object) is Kross::Api::Variant %1").arg(v.toString()) ); + krossdebug( TQString("Kross::Python::PythonExtension::toPyObject(Kross::Api::Object) is Kross::Api::Variant %1").tqarg(v.toString()) ); #endif return toPyObject(v); } @@ -361,8 +361,8 @@ const Py::Object PythonExtension::toPyObject(Kross::Api::Object::Ptr object) #endif Py::List pylist; Kross::Api::List* list = static_cast<Kross::Api::List*>( object.data() ); - QValueList<Kross::Api::Object::Ptr> valuelist = list->getValue(); - for(QValueList<Kross::Api::Object::Ptr>::Iterator it = valuelist.begin(); it != valuelist.end(); ++it) + TQValueList<Kross::Api::Object::Ptr> valuelist = list->getValue(); + for(TQValueList<Kross::Api::Object::Ptr>::Iterator it = valuelist.begin(); it != valuelist.end(); ++it) pylist.append( toPyObject(*it) ); // recursive return pylist; } @@ -373,8 +373,8 @@ const Py::Object PythonExtension::toPyObject(Kross::Api::Object::Ptr object) #endif Py::Dict pydict; Kross::Api::Dict* dict = static_cast<Kross::Api::Dict*>( object.data() ); - QMap<QString, Kross::Api::Object::Ptr> valuedict = dict->getValue(); - for(QMap<QString, Kross::Api::Object::Ptr>::Iterator it = valuedict.begin(); it != valuedict.end(); ++it) { + TQMap<TQString, Kross::Api::Object::Ptr> valuedict = dict->getValue(); + for(TQMap<TQString, Kross::Api::Object::Ptr>::Iterator it = valuedict.begin(); it != valuedict.end(); ++it) { const char* n = it.key().latin1(); pydict[ n ] = toPyObject( it.data() ); // recursive } @@ -382,7 +382,7 @@ const Py::Object PythonExtension::toPyObject(Kross::Api::Object::Ptr object) } #ifdef KROSS_PYTHON_EXTENSION_TOPYOBJECT_DEBUG - krossdebug( QString("Trying to handle PythonExtension::toPyObject(%1) as PythonExtension").arg(object->getClassName()) ); + krossdebug( TQString("Trying to handle PythonExtension::toPyObject(%1) as PythonExtension").tqarg(object->getClassName()) ); #endif return Py::asObject( new PythonExtension(object) ); } @@ -390,7 +390,7 @@ const Py::Object PythonExtension::toPyObject(Kross::Api::Object::Ptr object) const Py::Tuple PythonExtension::toPyTuple(Kross::Api::List::Ptr list) { #ifdef KROSS_PYTHON_EXTENSION_TOPYOBJECT_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::toPyTuple(Kross::Api::List) name='%1'").arg(list ? list->getName() : "NULL") ); + krossdebug( TQString("Kross::Python::PythonExtension::toPyTuple(Kross::Api::List) name='%1'").tqarg(list ? list->getName() : "NULL") ); #endif uint count = list ? list->count() : 0; Py::Tuple tuple(count); @@ -403,39 +403,39 @@ PyObject* PythonExtension::proxyhandler(PyObject *_self_and_name_tuple, PyObject { Py::Tuple tuple(_self_and_name_tuple); PythonExtension *self = static_cast<PythonExtension*>( tuple[0].ptr() ); - QString methodname = Py::String(tuple[1]).as_string().c_str(); + TQString methodname = Py::String(tuple[1]).as_string().c_str(); try { Kross::Api::List::Ptr arguments = toObject( Py::Tuple(args) ); #ifdef KROSS_PYTHON_EXTENSION_CALL_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::proxyhandler methodname='%1' arguments='%2'").arg(methodname).arg(arguments->toString()) ); + krossdebug( TQString("Kross::Python::PythonExtension::proxyhandler methodname='%1' arguments='%2'").tqarg(methodname).tqarg(arguments->toString()) ); #endif Kross::Api::Callable* callable = dynamic_cast<Kross::Api::Callable*>(self->m_object.data()); if(callable && callable->hasChild(methodname)) { #ifdef KROSS_PYTHON_EXTENSION_CALL_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::proxyhandler methodname='%1' is a child object of '%2'.").arg(methodname).arg(self->m_object->getName()) ); + krossdebug( TQString("Kross::Python::PythonExtension::proxyhandler methodname='%1' is a child object of '%2'.").tqarg(methodname).tqarg(self->m_object->getName()) ); #endif - Py::Object result = toPyObject( callable->getChild(methodname)->call(QString::null, arguments) ); + Py::Object result = toPyObject( callable->getChild(methodname)->call(TQString(), arguments) ); result.increment_reference_count(); return result.ptr(); } #ifdef KROSS_PYTHON_EXTENSION_CALL_DEBUG - krossdebug( QString("Kross::Python::PythonExtension::proxyhandler try to call function with methodname '%1' in object '%2'.").arg(methodname).arg(self->m_object->getName()) ); + krossdebug( TQString("Kross::Python::PythonExtension::proxyhandler try to call function with methodname '%1' in object '%2'.").tqarg(methodname).tqarg(self->m_object->getName()) ); #endif Py::Object result = toPyObject( self->m_object->call(methodname, arguments) ); result.increment_reference_count(); return result.ptr(); } catch(Py::Exception& e) { - const QString err = Py::value(e).as_string().c_str(); - krosswarning( QString("Py::Exception in Kross::Python::PythonExtension::proxyhandler %1").arg(err) ); + const TQString err = Py::value(e).as_string().c_str(); + krosswarning( TQString("Py::Exception in Kross::Python::PythonExtension::proxyhandler %1").tqarg(err) ); //throw e; } catch(Kross::Api::Exception::Ptr e) { - const QString err = e->toString(); - krosswarning( QString("Kross::Api::Exception in Kross::Python::PythonExtension::proxyhandler %1").arg(err) ); + const TQString err = e->toString(); + krosswarning( TQString("Kross::Api::Exception in Kross::Python::PythonExtension::proxyhandler %1").tqarg(err) ); // Don't throw here cause it will end in a crash deep in python. The // error is already handled anyway. //throw Py::Exception( (char*) e->toString().latin1() ); |