how to disable the automatic mapping of std::vector<std::vector<double> > to tuple of tuples in swig python? -


apparently, swig transform automatically std::vector<std::vector<double> > tuple of tuples. want prevent this, , want type kept is. how can achieve it? tried specifying definition type

%template(stdvectorstdvectordouble) std::vector<std::vector<double> >; 

but apparently not work.

two techniques:

  1. %clear typemap type before function processed swig.
  2. declare %template after function processed swig.

example 1

%module x  %begin %{ #pragma warning(disable:4127 4211 4701 4706) %}  %include <std_vector.i> %template(vd) std::vector<double>; %template(vvd) std::vector<std::vector<double> >; %clear std::vector<std::vector<double> >;  %inline %{ #include<vector> std::vector<std::vector<double> > func() {     std::vector<std::vector<double> > temp;     std::vector<double> a;     a.push_back(1.5);     temp.push_back(a);     return temp; } %} 

example 2

%module x  %begin %{ #pragma warning(disable:4127 4211 4701 4706) %}  %include <std_vector.i>  %inline %{ #include<vector> std::vector<std::vector<double> > func() {     std::vector<std::vector<double> > temp;     std::vector<double> a;     a.push_back(1.5);     temp.push_back(a);     return temp; }  %}  %template(vd) std::vector<double>; %template(vvd) std::vector<std::vector<double> >; 

result (of both)

python 3.3.0 (v3.3.0:bd8afb90ebf2, sep 29 2012, 10:57:17) [msc v.1600 64 bit (amd64)] on win32 type "help", "copyright", "credits" or "license" more information. >>> import x >>> x.func() <x.vvd; proxy of <swig object of type 'std::vector< std::vector< double,std::allocator<double > > > *' @ 0x00000000025f6900> > 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -