fixes for templates and template default args, cosmetics, and other fixes for OSS
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6893 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
41e5cbc33c
commit
0ac8253c3f
20 changed files with 615 additions and 271 deletions
|
|
@ -32,10 +32,10 @@ namespace EnumDirector {
|
|||
virtual Hello say_hello(Hello){ return hello;}
|
||||
virtual Hello say_hi(A *a){ return hi;}
|
||||
virtual Bye say_bye(Bye b){ return b;}
|
||||
virtual const Hello & say_hi_ref(const Hello & h){ return h;}
|
||||
virtual Hello say_hi_ref(const Hello & h){ return h;}
|
||||
|
||||
Hello ping(Hello h){ return say_hi(h);}
|
||||
const Hello & ping_ref(const Hello &h){ return say_hi_ref(h);}
|
||||
Hello ping_ref(const Hello &h){ return say_hi_ref(h);}
|
||||
Bye ping_member_enum(Bye b){ return say_bye(b);}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Massive primitive datatype test.
|
||||
%module(directors="1") primitive_types
|
||||
|
||||
// Using thread unsafe wrapping
|
||||
#pragma SWIG nowarn=470
|
||||
/*
|
||||
|
||||
if your language has problems with MyInt* and/or Hello*,
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@
|
|||
};
|
||||
%}
|
||||
|
||||
%extend std::basic_ostream<char, std::char_traits<char> >{
|
||||
std::basic_ostream<char, std::char_traits<char> >&
|
||||
%extend std::basic_ostream<char>{
|
||||
std::basic_ostream<char>&
|
||||
operator<<(const A& a)
|
||||
{
|
||||
*self << "A class";
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
return f;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int get_y(Bar *b)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,164 @@
|
|||
%module template_default
|
||||
%inline %{
|
||||
template <class T1, class T2 = T1>
|
||||
class A
|
||||
{
|
||||
};
|
||||
%}
|
||||
|
||||
%template(A_ii) A<int, int>;
|
||||
%template(A_d) A<double>;
|
||||
|
||||
|
||||
%warnfilter(801) ns1::Traits::c; /* Ruby, wrong constant name */
|
||||
namespace ns1 {
|
||||
namespace ns2 {
|
||||
|
||||
%feature("hello") A<int>;
|
||||
%feature("hello") A<double,double>;
|
||||
%feature("hi") A<int,int>;
|
||||
%feature("hi") A<double>;
|
||||
|
||||
%extend A<int>
|
||||
{
|
||||
int foo() { return 1; }
|
||||
}
|
||||
|
||||
%extend A<double,double>
|
||||
{
|
||||
int foo() { return 1; }
|
||||
}
|
||||
|
||||
%extend A<int,int>
|
||||
{
|
||||
int bar() { return 1; }
|
||||
}
|
||||
|
||||
%extend A<double>
|
||||
{
|
||||
int bar() { return 1; }
|
||||
}
|
||||
|
||||
%extend N<double>
|
||||
{
|
||||
int bar() { return 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace ns1 {
|
||||
namespace ns2 {
|
||||
|
||||
struct Parm
|
||||
{
|
||||
};
|
||||
|
||||
template <class T1, class T2 = T1>
|
||||
class A
|
||||
{
|
||||
|
||||
#ifdef SWIG
|
||||
%typemap(in) A * { /* in A */ }
|
||||
%typemap(out) A * { /* out A */ }
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef unsigned int category;
|
||||
|
||||
const category one = 1;
|
||||
const category two = 1;
|
||||
|
||||
|
||||
template <class T1, category C = one, class T2 = Parm>
|
||||
class N
|
||||
{
|
||||
|
||||
#ifdef SWIG
|
||||
%typemap(in) N * { /* in N */ }
|
||||
%typemap(out) N * { /* out N */ }
|
||||
#endif
|
||||
};
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
|
||||
|
||||
%template(A_p) ns1::ns2::A<double,ns1::ns2::Parm>;
|
||||
%template(N_1p) ns1::ns2::N<int>;
|
||||
|
||||
|
||||
namespace ns1 {
|
||||
namespace ns2 {
|
||||
%template(A_ii) A<int, int>;
|
||||
%template(A_d) A<double>;
|
||||
%template(N_d) N<double>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%inline %{
|
||||
namespace ns1 {
|
||||
namespace ns2 {
|
||||
namespace ns3 {
|
||||
|
||||
struct B : A<int>
|
||||
{
|
||||
};
|
||||
|
||||
struct C : N<double,ns1::ns2::one>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
A<int> *get_a1(A<int> *a) {
|
||||
return a;
|
||||
}
|
||||
|
||||
A<int,int> *get_a2(A<int,int> *a) {
|
||||
return a;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
namespace ns1 {
|
||||
struct Traits
|
||||
{
|
||||
static const ns2::category c = ns2::one;
|
||||
};
|
||||
namespace ns4 {
|
||||
|
||||
template <class T>
|
||||
struct D : ns2::N<double,T::c>
|
||||
{
|
||||
D()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <class T1, class T2 = D<T1> >
|
||||
struct Base : T2
|
||||
{
|
||||
};
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
%template(Do) ns1::ns4::D<ns1::Traits>;
|
||||
%template(Bo) ns1::ns4::Base<ns1::Traits, ns1::ns4::D<ns1::Traits> >;
|
||||
|
||||
|
||||
|
||||
%inline %{
|
||||
namespace ns1 {
|
||||
namespace ns5 {
|
||||
|
||||
struct Der : ns4::Base<Traits>
|
||||
{
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue