From c1fa7c426fe24fb9ae8581989dfb567e66adee84 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Sun, 3 Apr 2005 03:15:16 +0000 Subject: [PATCH] add wstream case git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7140 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Examples/test-suite/python/Makefile.in | 1 + .../test-suite/python/li_std_wstream.i | 59 +++++++++++++++++++ .../test-suite/python/li_std_wstream_runme.py | 14 +++++ 3 files changed, 74 insertions(+) create mode 100644 SWIG/Examples/test-suite/python/li_std_wstream.i create mode 100644 SWIG/Examples/test-suite/python/li_std_wstream_runme.py diff --git a/SWIG/Examples/test-suite/python/Makefile.in b/SWIG/Examples/test-suite/python/Makefile.in index 090ba914b..26717f352 100644 --- a/SWIG/Examples/test-suite/python/Makefile.in +++ b/SWIG/Examples/test-suite/python/Makefile.in @@ -27,6 +27,7 @@ CPP_TEST_CASES += \ li_std_vectora \ li_std_map \ li_std_stream \ + li_std_wstream \ li_std_wstring \ nondynamic \ primitive_types \ diff --git a/SWIG/Examples/test-suite/python/li_std_wstream.i b/SWIG/Examples/test-suite/python/li_std_wstream.i new file mode 100644 index 000000000..e4d725f10 --- /dev/null +++ b/SWIG/Examples/test-suite/python/li_std_wstream.i @@ -0,0 +1,59 @@ +%module li_std_wstream + +%inline %{ + struct A; +%} + +%include +%include + + + +%callback(1) A::bar; + +%inline %{ + + struct B { + virtual ~B() + { + } + + }; + + struct A : B + { + void __add__(int a) + { + } + + void __add__(double a) + { + } + + static int bar(int a){ + return a; + } + + static int foo(int a, int (*pf)(int a)) + { + return pf(a); + } + + + std::wostream& __rlshift__(std::wostream& out) + { + out << "A class"; + return out; + } + }; +%} + +%extend std::basic_ostream{ + std::basic_ostream& + operator<<(const A& a) + { + *self << "A class"; + return *self; + } +} + diff --git a/SWIG/Examples/test-suite/python/li_std_wstream_runme.py b/SWIG/Examples/test-suite/python/li_std_wstream_runme.py new file mode 100644 index 000000000..74c3c4d4b --- /dev/null +++ b/SWIG/Examples/test-suite/python/li_std_wstream_runme.py @@ -0,0 +1,14 @@ +import li_std_wstream as std + + + +a = std.A() + +o = std.wostringstream() + +o << a << u" " << 2345 << u" " << 1.435 + + +if o.str() != "A class 2345 1.435": + print "\"%s\"" % (o.str(),) + raise RuntimeError