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:
%clear
typemap type before function processed swig.- 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
Post a Comment