int size = Shiboken::String::len(%PYARG_1);
if (size == 1) {
const char *str = Shiboken::String::toCString(%PYARG_1);
QChar ch(str[0]);
%RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(ch);
%PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
} else {
PyErr_SetString(PyExc_TypeError, "String must have only one character");
}
return PyLong_FromVoidPtr(reinterpret_cast<void *>(%in));
%out = reinterpret_cast<%OUTTYPE>(PyLong_AsVoidPtr(%in));
PyObject *%out = Shiboken::Buffer::newObject(%in, size);
Py_ssize_t bufferLen;
char *%out = reinterpret_cast<char*>(Shiboken::Buffer::getPointer(%PYARG_1, &bufferLen));
uint %out = bufferLen;
Shiboken::AutoDecRef strList(PySequence_Fast(%PYARG_1, "Invalid sequence."));
int lineCount = PySequence_Fast_GET_SIZE(strList.object());
for (int line = 0; line < lineCount; ++line) {
if (!Shiboken::String::check(PySequence_Fast_GET_ITEM(strList.object(), line))) {
PyErr_SetString(PyExc_TypeError, "The argument must be a sequence of strings.");
break;
}
}
const char **xpm = reinterpret_cast<const char**>(malloc(lineCount * sizeof(const char**)));
for (int line = 0; line < lineCount; ++line)
xpm[line] = Shiboken::String::toCString(PySequence_Fast_GET_ITEM(strList.object(), line));
%BEGIN_ALLOW_THREADS
%0 = new %TYPE(xpm);
%END_ALLOW_THREADS
free(xpm);
const uchar *%out = reinterpret_cast<const uchar*>(PyBytes_AS_STRING(%PYARG_1));
uint %out = static_cast<uint>(PyBytes_Size(%PYARG_1));
%ARG1_TYPE a, b;
%CPPSELF.%FUNCTION_NAME(%1, %2, &a, &b);
%PYARG_0 = PyTuple_New(2);
PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%ARG1_TYPE](a));
PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG1_TYPE](b));
uchar *ptr = reinterpret_cast<uchar*>(Shiboken::Buffer::getPointer(%PYARG_1));
%0 = new %TYPE(ptr, %ARGS);
switch(%CPPSELF.spec()) {
case QColor::Rgb:
{
qreal r, g, b, a;
%CPPSELF.getRgbF(&r, &g, &b, &a);
QString repr = QString().sprintf("PySide2.QtGui.QColor.fromRgbF(%.6f, %.6f, %.6f, %.6f)", r, g, b, a);
%PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
break;
}
case QColor::Hsv:
{
qreal h, s, v, a;
%CPPSELF.getHsvF(&h, &s, &v, &a);
QString repr = QString().sprintf("PySide2.QtGui.QColor.fromHsvF(%.6f, %.6f, %.6f, %.6f)", h, s, v, a);
%PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
break;
}
case QColor::Cmyk:
{
qreal c, m, y, k, a;
%CPPSELF.getCmykF(&c, &m, &y, &k, &a);
QString repr = QString().sprintf("PySide2.QtGui.QColor.fromCmykF(%.6f, %.6f, %.6f, %.6f, %.6f)", c, m, y, k, a);
%PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
break;
}
#if QT_VERSION >= 0x040600
case QColor::Hsl:
{
qreal h, s, l, a;
%CPPSELF.getHslF(&h, &s, &l, &a);
QString repr = QString().sprintf("PySide2.QtGui.QColor.fromHslF(%.6f, %.6f, %.6f, %.6f)", h, s, l, a);
%PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
break;
}
#endif
default:
{
%PYARG_0 = Shiboken::String::fromCString("PySide2.QtGui.QColor()");
}
}
QValidator::State %out;
if (PySequence_Check(%PYARG_0)) {
Shiboken::AutoDecRef seq(PySequence_Fast(%PYARG_0, 0));
int size = PySequence_Fast_GET_SIZE(seq.object());
if (size > 1) {
if (%ISCONVERTIBLE[QString](PySequence_Fast_GET_ITEM(seq.object(), 1)))
%1 = %CONVERTTOCPP[QString](PySequence_Fast_GET_ITEM(seq.object(), 1));
else
qWarning("%TYPE::%FUNCTION_NAME: Second tuple element is not convertible to unicode.");
}
if (size > 2) {
if (%ISCONVERTIBLE[int](PySequence_Fast_GET_ITEM(seq.object(), 2)))
%2 = %CONVERTTOCPP[int](PySequence_Fast_GET_ITEM(seq.object(), 2));
else
qWarning("%TYPE::%FUNCTION_NAME: Second tuple element is not convertible to int.");
}
%PYARG_0.reset(PySequence_Fast_GET_ITEM(seq.object(), 0));
Py_INCREF(%PYARG_0); // we need to incref, because "%PYARG_0 = ..." will decref the tuple and the tuple will be decrefed again at the end of this scope.
}
// check retrun value
if (%ISCONVERTIBLE[QValidator::State](%PYARG_0)) {
%out = %CONVERTTOCPP[QValidator::State](%PYARG_0);
} else {
PyErr_Format(PyExc_TypeError, "Invalid return value in function %s, expected %s, got %s.",
"QValidator.validate",
"PySide2.QtGui.QValidator.State, (PySide2.QtGui.QValidator.State,), (PySide2.QtGui.QValidator.State, unicode) or (PySide2.QtGui.QValidator.State, unicode, int)",
Py_TYPE(pyResult)->tp_name);
return QValidator::State();
}
%BEGIN_ALLOW_THREADS
%CPPSELF.%FUNCTION_NAME(%1.data(), %1.size());
%END_ALLOW_THREADS
_______ end of matrix block _______ -->