#include <pythonextension.h>
Inheritance diagram for Kross::Python::PythonExtension:


Definition at line 47 of file pythonextension.h.
Public Member Functions | |
| PythonExtension (Kross::Api::Object::Ptr object) | |
| virtual | ~PythonExtension () |
| virtual Py::Object | str () |
| virtual Py::Object | repr () |
| virtual Py::Object | getattr (const char *name) |
Friends | |
| class | PythonScript |
| class | PythonObject |
| class | PythonModule |
|
|
Constructor.
Definition at line 31 of file pythonextension.cpp. 00032 : Py::PythonExtension<PythonExtension>() 00033 , m_object(object) 00034 { 00035 #ifdef KROSS_PYTHON_EXTENSION_CTOR_DEBUG 00036 kdDebug() << QString("Kross::Python::PythonExtension::Constructor objectname='%1' objectclass='%2'").arg(m_object->getName()).arg(m_object->getClassName()) << endl; 00037 #endif 00038 00039 //TODO determinate and return real dynamic objectname and documentation. 00040 behaviors().name("KrossPythonExtension"); 00041 behaviors().doc( 00042 "The common KrossPythonExtension object enables passing " 00043 "of Kross::Api::Object's from C/C++ to Python and " 00044 "backwards in a transparent way." 00045 ); 00046 behaviors().supportGetattr(); 00047 00048 m_proxymethod = new Py::MethodDefExt<PythonExtension>( 00049 "", // methodname, not needed cause we use the method only internaly. 00050 0, // method that should handle the callback, not needed cause proxyhandler will handle it. 00051 Py::method_varargs_call_handler_t( proxyhandler ), // callback handler 00052 "" // documentation 00053 ); 00054 }
|
|
|
Destructor. Definition at line 56 of file pythonextension.cpp. 00057 { 00058 #ifdef KROSS_PYTHON_EXTENSION_DTOR_DEBUG 00059 kdDebug() << QString("Kross::Python::PythonExtension::Destructor objectname='%1' objectclass='%2'").arg(m_object->getName()).arg(m_object->getClassName()) << endl; 00060 #endif 00061 delete m_proxymethod; 00062 }
|
|
|
Overloaded method to handle attribute calls from within python.
Definition at line 75 of file pythonextension.cpp. References QMap::begin(), and QMap::end(). 00076 { 00077 #ifdef KROSS_PYTHON_EXTENSION_GETATTR_DEBUG 00078 kdDebug() << QString("Kross::Python::PythonExtension::getattr name='%1'").arg(n) << endl; 00079 #endif 00080 00081 if(n[0] == '_') { 00082 if(n == "__methods__") { 00083 Py::List methods; 00084 QStringList calls = m_object->getCalls(); 00085 for(QStringList::Iterator it = calls.begin(); it != calls.end(); ++it) { 00086 #ifdef KROSS_PYTHON_EXTENSION_GETATTR_DEBUG 00087 kdDebug() << QString("Kross::Python::PythonExtension::getattr name='%1' callable='%2'").arg(n).arg(*it) << endl; 00088 #endif 00089 methods.append(Py::String( (*it).latin1() )); 00090 } 00091 return methods; 00092 } 00093 00094 if(n == "__members__") { 00095 Py::List members; 00096 QMap<QString, Kross::Api::Object::Ptr> children = m_object->getChildren(); 00097 QMap<QString, Kross::Api::Object::Ptr>::Iterator it( children.begin() ); 00098 for(; it != children.end(); ++it) { 00099 #ifdef KROSS_PYTHON_EXTENSION_GETATTR_DEBUG 00100 kdDebug() << QString("Kross::Python::PythonExtension::getattr n='%1' child='%2'").arg(n).arg(it.key()) << endl; 00101 #endif 00102 members.append(Py::String( it.key().latin1() )); 00103 } 00104 return members; 00105 } 00106 00107 //if(n == "__dict__") { kdDebug()<<QString("PythonExtension::getattr(%1) __dict__").arg(n)<<endl; return Py::None(); } 00108 //if(n == "__class__") { kdDebug()<<QString("PythonExtension::getattr(%1) __class__").arg(n)<<endl; return Py::None(); } 00109 00110 #ifdef KROSS_PYTHON_EXTENSION_GETATTR_DEBUG 00111 kdDebug() << QString("Kross::Python::PythonExtension::getattr name='%1' is a internal name.").arg(name) << endl; 00112 #endif 00113 return Py::PythonExtension<PythonExtension>::getattr_methods(n); 00114 } 00115 00116 // Redirect the call to our static proxy method which will take care 00117 // of handling the call. 00118 Py::Tuple self(2); 00119 self[0] = Py::Object(this); 00120 self[1] = Py::String(n); 00121 return Py::Object(PyCFunction_New( &m_proxymethod->ext_meth_def, self.ptr() ), true); 00122 }
|
|
|
Overloaded method to return the string-representation of the value this object has.
Definition at line 70 of file pythonextension.cpp.
|
|
|
Overloaded method to return the string-representation of this object.
Definition at line 64 of file pythonextension.cpp. References QString::isEmpty(). 00065 { 00066 QString s = m_object->getName(); 00067 return toPyObject(s.isEmpty() ? m_object->getClassName() : s); 00068 }
|
1.4.6