[PyQt] Problems with wrapping complex types using typedefs
phil at riverbankcomputing.com
Fri Jul 5 10:55:17 BST 2013
On Fri, 5 Jul 2013 17:41:21 +0800, "Casper Ti. Vector"
<caspervector at gmail.com> wrote:
> For example, assuming all example use this header:
>> %Module test
>> #include "test.h"
>> %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:
> 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.
More information about the PyQt