[PySide] container conversion native type ignored?

Matthew Woehlke matthew.woehlke at kitware.com
Wed Jun 19 18:54:50 CEST 2013


On 2013-06-19 12:33, John Ehresman wrote:
> On 6/18/13 5:19 PM, Matthew Woehlke wrote:
>> I am trying to define a conversion from PySet to std::set, but it
>> doesn't work. It seems that container conversion (at least of
>> 'type="set') ignores both the 'type' and 'check' parameters, using
>> Shiboken::Converions::convertibleSequenceTypes unconditionally. (It's
>> sheer luck that my conversion from PySet actually works on PySequence.)
>> Also, additional conversions do not seem to be processed.
>>
>> Can anyone shed some light?
>
> Do you have a test case?  It sounds like it may be a bug, but I'm not
> familiar enough with this part of shiboken to say.

   <container-type name="std::set" type="set">
     <include file-name="set" location="global"/>
     <conversion-rule>

       <native-to-target>...</native-to-target>

       <target-to-native>
         <add-conversion type="NonExistingClass"
                         check="NonExistingFunction">
         // This code will be called with a PySequence. The 'type' does
         // not matter; it is ignored. The 'check' is also ignored.
         </add-conversion>

         <add-conversion type="AnotherNonExistingClass">
         // This second conversion rule is not used at all.
         #error This error doesn't matter...
         // ...because it will never appear in generated code.
         </add-conversion>
       </target-to-native>

     </conversion-rule>
   </container-type>

...?

 From what I can tell (from the source code as well as observed 
behavior), this is simply how container conversions are handled; there 
does not appear to be anything looking at either the 'type' or 'check' 
parameters (of the add-conversion) for container conversions; they only 
depend on the 'type' parameter of the container-type.

Note that the above example will actually generate code that 
successfully compiles, despite the several intentional errors, thus 
demonstrating that the information is not used.

-- 
Matthew




More information about the PySide mailing list