adding more cases
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6814 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
749870a799
commit
52fe09a938
10 changed files with 79 additions and 14 deletions
|
|
@ -406,3 +406,5 @@ voidtest_runme.py
|
||||||
wrapmacro.py
|
wrapmacro.py
|
||||||
wrapmacro_runme.py
|
wrapmacro_runme.py
|
||||||
li_std_stream.py
|
li_std_stream.py
|
||||||
|
swigobject.py
|
||||||
|
smart_pointer_member.py
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,8 @@ p = li_std_pair.IntPair(1,10)
|
||||||
p.first = 1
|
p.first = 1
|
||||||
|
|
||||||
p = li_std_pair.paircA1(1,a)
|
p = li_std_pair.paircA1(1,a)
|
||||||
print 'f', p.first
|
p.first
|
||||||
print 's', p.second
|
p.second
|
||||||
|
|
||||||
p = li_std_pair.paircA2(1,a)
|
p = li_std_pair.paircA2(1,a)
|
||||||
pp = li_std_pair.pairiiA(1,p)
|
pp = li_std_pair.pairiiA(1,p)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,26 @@
|
||||||
%module li_std_stream
|
%module li_std_stream
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
struct A;
|
||||||
|
%}
|
||||||
|
|
||||||
%include <std_iostream.i>
|
%include <std_iostream.i>
|
||||||
|
%include <std_sstream.i>
|
||||||
|
|
||||||
|
|
||||||
%pythoncallback(1) A::bar;
|
|
||||||
|
%callback(1) A::bar;
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
struct A
|
struct B {
|
||||||
|
virtual ~B()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct A : B
|
||||||
{
|
{
|
||||||
void __add__(int a)
|
void __add__(int a)
|
||||||
{
|
{
|
||||||
|
|
@ -25,8 +38,22 @@
|
||||||
{
|
{
|
||||||
return pf(a);
|
return pf(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& __rlshift__(std::ostream& out)
|
||||||
|
{
|
||||||
|
out << "A class";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
};
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%extend std::basic_ostream<char, std::char_traits<char> >{
|
||||||
|
std::basic_ostream<char, std::char_traits<char> >&
|
||||||
|
operator<<(const A& a)
|
||||||
|
{
|
||||||
|
*self << "A class";
|
||||||
|
return *self;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
import li_std_stream as std
|
import li_std_stream as std
|
||||||
|
|
||||||
std.cout << 2345 << " " << 1.435 << std.endl
|
|
||||||
std.endl(std.cout)
|
|
||||||
|
|
||||||
|
|
||||||
a = std.A()
|
a = std.A()
|
||||||
|
|
||||||
a.bar(2)
|
o = std.ostringstream()
|
||||||
a.foo(4, a.bar)
|
|
||||||
|
o << a << " " << 2345 << " " << 1.435
|
||||||
|
|
||||||
|
|
||||||
|
if o.str() != "A class 2345 1.435":
|
||||||
|
print "\"%s\"" % (o.str(),)
|
||||||
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
%include <std_basic_string.i>
|
%include <std_basic_string.i>
|
||||||
%include <std_string.i>
|
%include <std_string.i>
|
||||||
|
|
||||||
%template(string) std::basic_string<char>;
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
struct A : std::string
|
struct A : std::string
|
||||||
|
|
@ -72,6 +71,19 @@ void test_throw() throw(std::string){
|
||||||
throw x;
|
throw x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::basic_string<char> test_value_basic1(std::basic_string<char> x) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::basic_string<char,std::char_traits<char> > test_value_basic2(std::basic_string<char,std::char_traits<char> > x) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_basic3(std::basic_string<char,std::char_traits<char>,std::allocator<char> > x) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,9 @@ if li_std_string.test_const_reference(a) != x:
|
||||||
|
|
||||||
b = li_std_string.string(" world")
|
b = li_std_string.string(" world")
|
||||||
|
|
||||||
|
s = a + b
|
||||||
if a + b != "hello world":
|
if a + b != "hello world":
|
||||||
|
print a + b
|
||||||
raise RuntimeError, "bad string mapping"
|
raise RuntimeError, "bad string mapping"
|
||||||
|
|
||||||
if a + " world" != "hello world":
|
if a + " world" != "hello world":
|
||||||
|
|
@ -72,3 +74,12 @@ if b.a != "hello":
|
||||||
raise RuntimeError, "bad string mapping"
|
raise RuntimeError, "bad string mapping"
|
||||||
|
|
||||||
|
|
||||||
|
if li_std_string.test_value_basic1(x) != x:
|
||||||
|
raise RuntimeError, "bad string mapping"
|
||||||
|
|
||||||
|
if li_std_string.test_value_basic2(x) != x:
|
||||||
|
raise RuntimeError, "bad string mapping"
|
||||||
|
|
||||||
|
|
||||||
|
if li_std_string.test_value_basic3(x) != x:
|
||||||
|
raise RuntimeError, "bad string mapping"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
%include <std_wstring.i>
|
%include <std_wstring.i>
|
||||||
|
|
||||||
|
|
||||||
%template(wstring) std::basic_string<wchar_t>;
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
struct A : std::wstring
|
struct A : std::wstring
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,5 @@ import _profiletest
|
||||||
|
|
||||||
a = _profiletest.new_A()
|
a = _profiletest.new_A()
|
||||||
b = _profiletest.new_B()
|
b = _profiletest.new_B()
|
||||||
for i in range(0,1000000):
|
for i in range(0,10000000):
|
||||||
a = _profiletest.B_fn(b, a)
|
a = _profiletest.B_fn(b, a)
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,9 @@
|
||||||
A *a_ptr(A *a){
|
A *a_ptr(A *a){
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void *v_ptr(void *a){
|
||||||
|
return a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,3 +19,8 @@ if xstr1 != xstr2:
|
||||||
|
|
||||||
s = str(a.this)
|
s = str(a.this)
|
||||||
r = repr(a.this)
|
r = repr(a.this)
|
||||||
|
|
||||||
|
v1 = v_ptr(a)
|
||||||
|
v2 = v_ptr(a)
|
||||||
|
if long(v1) != long(v2):
|
||||||
|
raise RuntimeError
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue