[PySide] manipulating >10 args?

Dennis Victorovich dennis.victorovich at gmail.com
Tue Jul 23 13:01:54 CEST 2013


I'm not sure if its possible to pass more than 10 arguments into call.
10 arguments constraints may come from QMetaObject::Invoke() limitations (
http://qt-project.org/doc/qt-4.8/qmetaobject.html#invokeMethod)
Take a look at cpp bindings code generated from your template. Shiboken may
use QMetaObject::Invoke()



2013/7/23 Matthew Woehlke <matthew.woehlke at kitware.com>

> I'm trying to wrap the following method:
>
> MyDoubleInputDialog::getDouble(QWidget*, QString, QString, double,
>                                 double, double, QString, int, double,
>                                 bool*, QFlags<Qt::WindowType>)
>
> ...and I'm running into problems. Essentially I need to twist this a la
> (e.g.) QString::toInt, which seems like it should be straight-forward:
>
>    <modify-argument index="10">
>      <remove-argument/>
>    </modify-argument>
>    <modify-argument index="return">
>      <replace-type modified-type="(int, bool ok)"/>
>    </modify-argument>
>    <inject-code class="target" position="beginning">
>      bool ok_;
>      %BEGIN_ALLOW_THREADS
>      %RETURN_TYPE retval_ =
>        %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6,
>                                %7, %8, %9, &ok_, %11);
>      %END_ALLOW_THREADS
>      <insert-template name="tuple_retval_ok"/>
>    </inject-code>
>
>
> ...however I'm getting a build error regarding "cppArg01". AFAICT what
> is happening is in "%11", the "%1" is being replaced, leaving a stray
> '1' and causing the eleventh argument to not be converted at all.
>
> Is there a technique I am missing for how this is supposed to work, or
> is handling of '%#' not working for # >= 10?
>
>
> I was able to work around this by patching shiboken:
>
> diff --git a/generator/shiboken/shibokengenerator.cpp
> b/generator/shiboken/shibokengenerator.cpp
> index 7de0d3a..30be324 100644
> --- a/generator/shiboken/shibokengenerator.cpp
> +++ b/generator/shiboken/shibokengenerator.cpp
> @@ -1659,7 +1659,7 @@ void ShibokenGenerator::writeCodeSnips(QTextStream&
> s,
>               if (type->isReference() || isPointer(type))
>                   code.replace(QString("%%1.").arg(idx),
> QString("%1->").arg(replacement));
>           }
> -        code.replace(QString("%%1").arg(idx), pair.second);
> +        code.replace(QRegExp(QString("%%1\\b").arg(idx)), pair.second);
>       }
>
>       if (language == TypeSystem::NativeCode) {
>
>
> ...but I'd appreciate feedback if I am missing something, or if the
> above looks like a reasonable fix, or if there is a better way.
>
> --
> Matthew
>
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20130723/76f81684/attachment.html>


More information about the PySide mailing list