[PySide] manipulating >10 args?

Matthew Woehlke matthew.woehlke at kitware.com
Tue Jul 23 01:32:10 CEST 2013


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




More information about the PySide mailing list