Go to the documentation of this file.00001 #ifndef _PYTHONQTIMPORTER_
00002 #define _PYTHONQTIMPORTER_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00043
00044
00045 #include "Python.h"
00046 #include "structmember.h"
00047 #include "osdefs.h"
00048 #include "marshal.h"
00049 #include "compile.h"
00050 #include <time.h>
00051
00052 #include <qobject.h>
00053 #include <qstring.h>
00054
00055
00057 typedef struct _PythonQtImporter {
00058 PyObject_HEAD
00059 QString* _path;
00060 } PythonQtImporter;
00061
00062
00064
00066 class PythonQtImport
00067 {
00068 public:
00069
00070 enum ModuleType {
00071 MI_NOT_FOUND,
00072 MI_MODULE,
00073 MI_PACKAGE,
00074 MI_SHAREDLIBRARY
00075 };
00076
00077 struct ModuleInfo {
00078 ModuleInfo() {
00079 type = MI_NOT_FOUND;
00080 }
00081 QString fullPath;
00082 QString moduleName;
00083 ModuleType type;
00084 };
00085
00087 static void init();
00088
00090 static void writeCompiledModule(PyCodeObject *co, const QString& filename, long mtime);
00091
00097 static PyObject *unmarshalCode(const QString& path, const QByteArray& data, time_t mtime);
00098
00101 static PyObject *compileSource(const QString& path, const QByteArray& data);
00102
00105 static PyObject *getCodeFromData(const QString& path, int isbytecode = 0, int ispackage = 0,
00106 time_t mtime = 0);
00107
00110 static PyObject * getModuleCode(PythonQtImporter *self,
00111 const char* fullname, QString& modpath);
00112
00113
00115 static PyObject* getCodeFromPyc(const QString& file);
00116
00118 static ModuleInfo getModuleInfo(PythonQtImporter* self, const QString& fullname);
00119
00121 static QString getSubName(const QString& str);
00122
00126 static long getLong(unsigned char *buf);
00127
00129 static time_t getMTimeOfSource(const QString& path);
00130
00132 static QString replaceExtension(const QString& str, const QString& ext);
00133
00134 };
00135
00136 #endif
00137