[PyQt] Problems with wrapping complex types using typedefs

Casper Ti. Vector caspervector at gmail.com
Fri Jul 5 10:41:21 BST 2013


For example, assuming all example use this header:
> %Module test
> %ModuleHeaderCode
> #include "test.h"
> %End
> %Include types.sip // Where map, pair and vector are wrapped.

This code:
> std::map<std::pair<int, int>, std::vector<unsigned long> > Test;
fails because sip complains:
> sip: Test has an unsupported type - provide %GetCode and %SetCode

while this code:
> typedef std::pair<int, int> cell;
> typedef std::vector<unsigned long> idxx;
> std::map<cell, idxx> Test;
fails because the compiler complains like:
> error: 'sipType_cell' was not declared in this scope
> error: 'sipType_idxx' was not declared in this scope

I searched Google for `python sip typedef' and found this message:
<http://www.riverbankcomputing.com/pipermail/pyqt/2011-January/029111.html>
It seems that adding something like:
> #define sipType_cell sipType_std_pair_1800_1800
> #define sipType_idxx sipType_std_vector_2100
to the `%ModuleHeaderCode' section make everything runs well.

However, this trick seems quite unreliable because these magic numbers
(1800, 2100, etc.) might vary from version to version.  So is there any
elegant way to wrap these types?

In addition, I personally think it is favourable to generate `sipType's
for typedefs, because this can greatly simplify efforts on wrapping
complex template types, such as those in my examples.

-- 
My current OpenPGP key:
4096R/0xE18262B5D9BF213A (expires: 2017.1.1)
D69C 1828 2BF2 755D C383 D7B2 E182 62B5 D9BF 213A



More information about the PyQt mailing list