diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-05-25 16:23:22 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:15:24 -0300 |
commit | 0e6d4cc1d151724f56c6ccf8c431077e2c778b26 (patch) | |
tree | 3717e96dfd1e22bc75ce409cdca20c136d056c96 /generator | |
parent | 22bed1fb96a37bdf9d032a801f5577f81832fe76 (diff) |
Added Shiboken buffer interface.
This interface is just a wrapper to the differents API's provided by Python
to deal with memory buffers in various versions of Python, so is recommended
to use this API to deal with Python memory buffers instead of the CPython API.
If you want to have a Python buffer as argument of any function just change
the argument type to "PyBuffer" and the generator will handle it right regarding
to type checking.
Reviewer: Renato Araújo <renato.filho@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'generator')
-rw-r--r-- | generator/overloaddata.cpp | 11 | ||||
-rw-r--r-- | generator/shibokengenerator.cpp | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/generator/overloaddata.cpp b/generator/overloaddata.cpp index 6bb06fe57..7ec8cf07f 100644 --- a/generator/overloaddata.cpp +++ b/generator/overloaddata.cpp @@ -163,6 +163,8 @@ void OverloadData::sortNextOverloads() int qstringIndex = 0; bool checkQVariant = false; int qvariantIndex = 0; + bool checkPyBuffer = false; + int pyBufferIndex = 0; // Primitive types that are not int, long, short, // char and their respective unsigned counterparts. @@ -194,6 +196,9 @@ void OverloadData::sortNextOverloads() } else if (!checkPySequence && typeName == "PySequence") { checkPySequence = true; pySeqIndex = sortData.lastProcessedItemId(); + } else if (!checkPyBuffer && typeName == "PyBuffer") { + checkPyBuffer = true; + pyBufferIndex = sortData.lastProcessedItemId(); } else if (!checkQVariant && typeName == "QVariant") { checkQVariant = true; qvariantIndex = sortData.lastProcessedItemId(); @@ -315,12 +320,16 @@ void OverloadData::sortNextOverloads() } - if ((checkPySequence || checkPyObject) + if ((checkPySequence || checkPyObject || checkPyBuffer) && !targetTypeEntryName.contains("PyObject") + && !targetTypeEntryName.contains("PyBuffer") && !targetTypeEntryName.contains("PySequence")) { if (checkPySequence) { // PySequence will be checked after all more specific types, but before PyObject. graph.addEdge(targetTypeId, pySeqIndex); + } else if (checkPyBuffer) { + // PySequence will be checked after all more specific types, but before PyObject. + graph.addEdge(targetTypeId, pyBufferIndex); } else { // Add dependency on PyObject, so its check is the last one (too generic). graph.addEdge(targetTypeId, pyobjectIndex); diff --git a/generator/shibokengenerator.cpp b/generator/shibokengenerator.cpp index de96d03ac..8d98869d7 100644 --- a/generator/shibokengenerator.cpp +++ b/generator/shibokengenerator.cpp @@ -865,6 +865,8 @@ QString ShibokenGenerator::guessCPythonCheckFunction(const QString& type) metaType = 0; } else if (type == "PyTypeObject") { retval = "PyType_Check"; + } else if (type == "PyBuffer") { + retval = "Shiboken::Buffer::checkType"; } else { retval = QString("%1_Check").arg(type); } |