PythonQt
PythonQtImporter.h
Go to the documentation of this file.
1#ifndef _PYTHONQTIMPORTER_
2#define _PYTHONQTIMPORTER_
3
4/*
5 *
6 * Copyright (C) 2010 MeVis Medical Solutions AG All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Medical Solutions AG, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36//----------------------------------------------------------------------------------
43//----------------------------------------------------------------------------------
44
46
47#include "compile.h"
48#include "marshal.h"
49#include "osdefs.h"
50#include "structmember.h"
51#include <ctime>
52
53#include <qobject.h>
54#include <qstring.h>
55
56
62
63
65
68{
69public:
70
77
86
88 static void init();
89
92
98 static PyObject *unmarshalCode(const QString& path, const QByteArray& data, time_t mtime);
99
102 static PyObject *compileSource(const QString& path, const QByteArray& data);
103
106 static PyObject *getCodeFromData(const QString& path, int isbytecode = 0, int ispackage = 0,
107 time_t mtime = 0);
108
114
115
118
121
124
128 static long getLong(unsigned char *buf);
129
132
135
138
141};
142
143#endif
144
PyObject * PythonQtConvertPairToPython(const void *inPair, int metaTypeId)
struct _object PyObject
implements importing of python files into PythonQt
static PyObject * getModuleCode(PythonQtImporter *self, const char *fullname, QString &modpath, QString &cachemodpath)
static QString getSubName(const QString &str)
get the last name of a dot chain (first.second.last)
static QString getSourceFilename(const QString &cacheFile)
Returns the filename of the source file for the given cache file, e.g. test.py for test....
static QString getCacheFilename(const QString &sourceFile, bool isOptimizedFilename)
Returns the filename of the cache file for the given source file, e.g. test.pyc for test....
static time_t getMTimeOfSource(const QString &path)
get time stamp of file
static ModuleInfo getModuleInfo(PythonQtImporter *self, const QString &fullname)
Return if module exists and is a package or a module.
static QString replaceExtension(const QString &str, const QString &ext)
replace extension of file
static PyObject * compileSource(const QString &path, const QByteArray &data)
static PyObject * getCodeFromPyc(const QString &file)
gets the compiled code for the given *.py file if there is a valid pyc file, otherwise compiles the f...
static PyObject * getCodeFromData(const QString &path, int isbytecode=0, int ispackage=0, time_t mtime=0)
static PyObject * unmarshalCode(const QString &path, const QByteArray &data, time_t mtime)
static void writeCompiledModule(PyCodeObject *co, const QString &filename, long mtime, long sourceSize)
writes the python code to disk, marshalling and writing the time stamp
static void init()
initialize
static long getLong(unsigned char *buf)
QString moduleName
the module name without the package prefix
QString fullPath
the full path to the found file
defines a python object that stores a Qt slot info
PyObject_HEAD QString * _path