Controlling string representation of proxy classes

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Controlling string representation of proxy classes

Is there a general way to control the string representation of the proxy classes?  For example, in Python let's say I'm using:

%module foo
%include "std_vector.i"
%inline %{
#include <vector>

struct Foo {

std::vector<Foo> twoFoos() {
  std::vector<Foo> foos;
  return foos;

%template(FooList) std::vector<Foo>;

Then in Python, I get something like:

>> import foo
>> foo.Foo()
<foo.Foo: proxy of <Swig Object of type 'Foo *' at 0x00000000039B6900>
>> foos = foo.twoFoos(); foos
<foo.FooList; proxy of <Swig Object of type 'std::vector< Foo > *' at 0x00000000039A21B0>
>> foos[0]
<foo.Foo; proxy of <Swig Object of type 'std::vector< Foo >::value_type *' at 0x00000000039A2180> >

From a user's perspective, everything after the semi-colon is basically line noise.  I suppose for Python I could manually override the __str__ with %extend or similar, but I'm wondering if there's a language-agnostic way to get ride of the internal C++ stuff in the string representation without per-language and per-class overrides.

-Jake Cobb

Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
Swig-user mailing list
[hidden email]