From 65af4461ce48b859c8cc902ccb354e319354e39d 2012-11-07 12:56:13 From: florianlink Date: 2012-11-07 12:56:13 Subject: [PATCH] adapted to new generator files git-svn-id: svn://svn.code.sf.net/p/pythonqt/code/trunk@234 ea8d5007-eb21-0410-b261-ccb3ea6e24a9 --- diff --git a/src/PythonQt.cpp b/src/PythonQt.cpp index 2981da9..54a7a54 100644 --- a/src/PythonQt.cpp +++ b/src/PythonQt.cpp @@ -1216,7 +1216,7 @@ void PythonQtPrivate::addDecorators(QObject* o, int decoTypes) } else if (qstrncmp(m.signature(), "static_", 7)==0) { if ((decoTypes & StaticDecorator) == 0) continue; QByteArray signature = m.signature(); - QByteArray nameOfClass = signature.mid(signature.indexOf('_')+1); + QByteArray nameOfClass = signature.mid(7); nameOfClass = nameOfClass.mid(0, nameOfClass.indexOf('_')); PythonQtClassInfo* classInfo = lookupClassInfoAndCreateIfNotPresent(nameOfClass); PythonQtSlotInfo* newSlot = new PythonQtSlotInfo(NULL, m, i, o, PythonQtSlotInfo::ClassDecorator); @@ -1778,4 +1778,16 @@ void PythonQtPrivate::shellClassDeleted( void* shellClass ) // if the wrapper is a QObject, we do not handle this here, // it will be handled by the QPointer<> to the QObject, which becomes NULL // via the QObject destructor. +} + +PyObject* PythonQtPrivate::wrapMemoryAsBuffer( const void* data, Py_ssize_t size ) +{ + // P3K port needed later on! + return PyBuffer_FromMemory((void*)data, size); +} + +PyObject* PythonQtPrivate::wrapMemoryAsBuffer( void* data, Py_ssize_t size ) +{ + // P3K port needed later on! + return PyBuffer_FromReadWriteMemory(data, size); } \ No newline at end of file diff --git a/src/PythonQt.h b/src/PythonQt.h index 278ee81..60372c0 100644 --- a/src/PythonQt.h +++ b/src/PythonQt.h @@ -587,6 +587,12 @@ public: //! wrap the given ptr into a Python object (or return existing wrapper!) if there is a known QObject of that name or a known wrapper in the factory PyObject* wrapPtr(void* ptr, const QByteArray& name); + //! create a read-only buffer object from the given memory + static PyObject* wrapMemoryAsBuffer(const void* data, Py_ssize_t size); + + //! create a read-write buffer object from the given memory + static PyObject* wrapMemoryAsBuffer(void* data, Py_ssize_t size); + //! registers a QObject derived class to PythonQt (this is implicitly called by addObject as well) /* Since Qt4 does not offer a way to detect if a given classname is derived from QObject and thus has a QMetaObject, you MUST register all your QObject derived classes here when you want them to be detected in signal and slot calls */ diff --git a/src/PythonQtDoc.h b/src/PythonQtDoc.h index 75f1186..991fdc7 100644 --- a/src/PythonQtDoc.h +++ b/src/PythonQtDoc.h @@ -165,7 +165,7 @@ Qt framework. The PythonQt wrappers generated by the generator located in the "generated_cpp" directory are free to be used without any licensing restrictions. - The generated wrappers are pre-generated and checked-in for Qt 4.8, so you only need to build and run the + The generated wrappers are pre-generated and checked-in for Qt 4.6.1, so you only need to build and run the generator when you want to build additional wrappers or you want to upgrade/downgrade to another Qt version. You may use the generator to generate C++ bindings for your own C++ classes (e.g., to make them inheritable in Python), but this is currently not documented and involves creating your own typesystem files (although the Qt Jambi examples might help you). @@ -420,10 +420,7 @@ the python2x.[lib | dll | so | dynlib]. The build scripts a currently set to use Python 2.6. You may need to tweak the \b build/python.prf file to set the correct Python includes and libs on your system. - \note In addition to the qmake profiles, PythonQt now offers building via Cmake. Just use the provided - CMakeLists.txt in the root directory of the project. This build option has not been well tested yet. - - \section Windows + \subsection Windows On Windows, the (non-source) Python Windows installer can be used. Make sure that you use the same compiler, the current Python distribution is built @@ -462,7 +459,7 @@ the python2x.[lib | dll | so | dynlib]. The tests and examples are located in PythonQt/lib. - \section Linux + \subsection Linux On Linux, you need to install a Python-dev package. If Python can not be linked or include files can not be found, @@ -480,7 +477,7 @@ the python2x.[lib | dll | so | dynlib]. You should add PythonQt/lib to your LD_LIBRARY_PATH so that the runtime linker can find the *.so files. - \section MacOSX + \subsection MacOsX On Mac, Python is installed as a Framework, so you should not need to install it. To build PythonQt, just do a: