[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] SWIG Typemap for Two-way Conversion Between Pytho
Re: [Discuss-gnuradio] SWIG Typemap for Two-way Conversion Between Python Stringand (char*, int) in C++
Fri, 05 Jan 2007 08:29:31 -0800
On Fri, 2007-01-05 at 21:48 +0800, Jeremy Chew wrote:
> How do we specify a typemap for a C++ extension that also converts such
> strings from C++ to Python? I want to have C++ calls that receive strings
> from Python code as well as C++ calls that pass strings to Python code.
The good news is that the standard SWIG library has already done most of
the work for you. If you add:
...in your .i file, then SWIG automagically (using typemaps) converts
between the STL std::string type and Python strings.
More documentation is here:
...where you'll see similar examples for converting between std::vector
and Python lists, std::map and Python dictionaries, and more.
Johnathan Corgan, AE6HO
Corgan Enterprises LLC