more examples, and fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6432 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f9974297d6
commit
50b87f398b
17 changed files with 123 additions and 28 deletions
|
|
@ -46,13 +46,10 @@ LIBPREFIX = lib
|
||||||
# Broken C++ test cases. (Can be run individually using make testcase.cpptest.)
|
# Broken C++ test cases. (Can be run individually using make testcase.cpptest.)
|
||||||
CPP_TEST_BROKEN += \
|
CPP_TEST_BROKEN += \
|
||||||
derived_nested \
|
derived_nested \
|
||||||
derived_byvalue \
|
|
||||||
multiple_inheritance \
|
multiple_inheritance \
|
||||||
namespace_union \
|
namespace_union \
|
||||||
overload_complicated \
|
overload_complicated \
|
||||||
smart_pointer_namespace2 \
|
smart_pointer_namespace2 \
|
||||||
template_specialization_defarg \
|
|
||||||
template_typedef_ptr \
|
|
||||||
using_namespace
|
using_namespace
|
||||||
|
|
||||||
# Broken C test cases. (Can be run individually using make testcase.ctest.)
|
# Broken C test cases. (Can be run individually using make testcase.ctest.)
|
||||||
|
|
@ -114,6 +111,7 @@ CPP_TEST_CASES += \
|
||||||
default_args \
|
default_args \
|
||||||
default_ref \
|
default_ref \
|
||||||
defvalue_constructor \
|
defvalue_constructor \
|
||||||
|
derived_byvalue \
|
||||||
destructor_reprotected \
|
destructor_reprotected \
|
||||||
director_abstract \
|
director_abstract \
|
||||||
director_basic \
|
director_basic \
|
||||||
|
|
@ -165,6 +163,7 @@ CPP_TEST_CASES += \
|
||||||
long_long_apply \
|
long_long_apply \
|
||||||
member_template \
|
member_template \
|
||||||
minherit \
|
minherit \
|
||||||
|
mixed_types \
|
||||||
name_cxx \
|
name_cxx \
|
||||||
name_inherit \
|
name_inherit \
|
||||||
name_warnings \
|
name_warnings \
|
||||||
|
|
@ -253,6 +252,7 @@ CPP_TEST_CASES += \
|
||||||
template_rename \
|
template_rename \
|
||||||
template_retvalue \
|
template_retvalue \
|
||||||
template_specialization \
|
template_specialization \
|
||||||
|
template_specialization_defarg \
|
||||||
template_specialization_enum \
|
template_specialization_enum \
|
||||||
template_static \
|
template_static \
|
||||||
template_tbase_template \
|
template_tbase_template \
|
||||||
|
|
@ -263,6 +263,7 @@ CPP_TEST_CASES += \
|
||||||
template_typedef_cplx3 \
|
template_typedef_cplx3 \
|
||||||
template_typedef_cplx4 \
|
template_typedef_cplx4 \
|
||||||
template_typedef_cplx5 \
|
template_typedef_cplx5 \
|
||||||
|
template_typedef_ptr \
|
||||||
template_virtual \
|
template_virtual \
|
||||||
template_whitespace \
|
template_whitespace \
|
||||||
throw_exception \
|
throw_exception \
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ public:
|
||||||
|
|
||||||
%feature("director") Foo;
|
%feature("director") Foo;
|
||||||
|
|
||||||
|
|
||||||
class Foo {
|
class Foo {
|
||||||
public:
|
public:
|
||||||
virtual ~Foo() {}
|
virtual ~Foo() {}
|
||||||
|
|
@ -25,7 +26,12 @@ public:
|
||||||
%{
|
%{
|
||||||
#include <complex>
|
#include <complex>
|
||||||
%}
|
%}
|
||||||
%feature("director") A;
|
%feature("director");
|
||||||
|
|
||||||
|
// basic renaming
|
||||||
|
%rename(rg) A::gg;
|
||||||
|
%feature("nodirector") hi::A1::gg;
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
struct A{
|
struct A{
|
||||||
|
|
@ -34,11 +40,18 @@ struct A{
|
||||||
virtual ~A() {}
|
virtual ~A() {}
|
||||||
|
|
||||||
virtual int f(int i=0) {return i;}
|
virtual int f(int i=0) {return i;}
|
||||||
|
virtual int gg(int i=0) {return i;}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct A1 : public A{
|
namespace hi {
|
||||||
|
|
||||||
|
struct A1 : public A{
|
||||||
A1(std::complex<int> i, double d=0.0) : A(i, d) {}
|
A1(std::complex<int> i, double d=0.0) : A(i, d) {}
|
||||||
A1(int i, bool j=false) : A(i, j) {}
|
A1(int i, bool j=false) : A(i, j) {}
|
||||||
};
|
|
||||||
|
virtual int ff(int i = 0) {return i;}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%feature("director");
|
%feature("director");
|
||||||
%feature("nodirector") Bravo::abs_method(); // ok
|
%feature("nodirector") Bravo::abs_method(); // ok
|
||||||
%feature("director") Charlie::abs_method(); // ok
|
%feature("director") Charlie::abs_method(); // ok
|
||||||
%feature("nodirector") Delta::abs_method(); // doesn't work
|
%feature("nodirector") Delta::abs_method(); // ok
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
%module extend_default
|
%module extend_default
|
||||||
|
|
||||||
|
%warnfilter(302) Override::over;
|
||||||
|
%warnfilter(302) Override::overload;
|
||||||
|
%warnfilter(302) Override::ride;
|
||||||
|
|
||||||
// %extend before the class definition
|
// %extend before the class definition
|
||||||
%extend Before {
|
%extend Before {
|
||||||
Before(int i = -1, double d = -1.0) {
|
Before(int i = -1, double d = -1.0) {
|
||||||
|
|
@ -86,9 +90,6 @@ struct OverAfter {
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
#pragma SWIG nowarn=-302
|
|
||||||
//%warnfilter(302) over; // why doesn't this work?
|
|
||||||
|
|
||||||
// %extend overrides the class definition
|
// %extend overrides the class definition
|
||||||
%extend Override {
|
%extend Override {
|
||||||
int over(int a) { return a*a; } // SWIG should give a warning then choose this one over the real one
|
int over(int a) { return a*a; } // SWIG should give a warning then choose this one over the real one
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,13 @@
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
namespace hello
|
namespace hello
|
||||||
{
|
{
|
||||||
%template(Hi_hi0) Hi<hi::hi0>;
|
%template(Hi_hi0) Hi<hi::hi0>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
namespace hello
|
namespace hello
|
||||||
|
|
@ -48,7 +49,9 @@ namespace hello
|
||||||
template <class T1>
|
template <class T1>
|
||||||
struct hi1 : T1
|
struct hi1 : T1
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef hello::Hi<hello::hi::hi0> h0;
|
||||||
}
|
}
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,10 @@
|
||||||
%typemap(default) double y "$1=1000;";
|
%typemap(default) double y "$1=1000;";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma SWIG nowarn=-302
|
%warnfilter(302) Foo::test;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%extend Foo {
|
%extend Foo {
|
||||||
int test() { return 0; }
|
int test() { return 0; }
|
||||||
int test(int x) { x = 0; return 1; }
|
int test(int x) { x = 0; return 1; }
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@
|
||||||
//
|
//
|
||||||
// These applies shouldn't be needed ....!!
|
// These applies shouldn't be needed ....!!
|
||||||
//
|
//
|
||||||
%apply const int& { const Hello& };
|
//%apply const int& { const Hello& };
|
||||||
|
|
||||||
%apply void* { pint };
|
%apply void* { pint };
|
||||||
%apply const void*& { const pint& };
|
%apply const void*& { const pint& };
|
||||||
|
|
@ -154,6 +154,10 @@
|
||||||
|
|
||||||
//
|
//
|
||||||
// Some simple types
|
// Some simple types
|
||||||
|
%apply char FIXSIZE[ANY] {char fixsize[8]};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
enum Hello {
|
enum Hello {
|
||||||
Hi, Hola
|
Hi, Hola
|
||||||
|
|
@ -170,7 +174,8 @@
|
||||||
const namet def_namet = {'h','o',0, 'l','a'};
|
const namet def_namet = {'h','o',0, 'l','a'};
|
||||||
|
|
||||||
extern namet gbl_namet;
|
extern namet gbl_namet;
|
||||||
|
|
||||||
|
char fixsize[8] = {'h','o',0, 'l','a', 0, 0, 0};
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -383,6 +388,16 @@ macro(size_t, pfx, sizet)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef Foo* foo_ptr;
|
||||||
|
|
||||||
|
foo_ptr fptr_val(foo_ptr a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
const foo_ptr& fptr_ref(const foo_ptr& a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Test
|
struct Test
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
%module lib_std_except
|
%module lib_std_except
|
||||||
|
|
||||||
%include "std_except.i"
|
%include <std_except.i>
|
||||||
|
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
%module lib_std_string
|
%module lib_std_string
|
||||||
%include "std_string.i"
|
%include <std_basic_string.i>
|
||||||
|
%include <std_string.i>
|
||||||
|
|
||||||
%template(string) std::basic_string<char>;
|
%template(string) std::basic_string<char>;
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
%module lib_std_wstring
|
%module lib_std_wstring
|
||||||
|
%include <std_basic_string.i>
|
||||||
%include "std_wstring.i"
|
%include <std_wstring.i>
|
||||||
|
|
||||||
|
|
||||||
%template(wstring) std::basic_string<wchar_t>;
|
%template(wstring) std::basic_string<wchar_t>;
|
||||||
|
|
|
||||||
|
|
@ -329,3 +329,18 @@ t2 = p.vtest(t)
|
||||||
if t.var_namet != t2.var_namet:
|
if t.var_namet != t2.var_namet:
|
||||||
raise RuntimeError, "bad SWIGTYPE* typemap"
|
raise RuntimeError, "bad SWIGTYPE* typemap"
|
||||||
|
|
||||||
|
|
||||||
|
if cvar.fixsize != 'ho\0la\0\0\0':
|
||||||
|
raise RuntimeError, "bad FIXSIZE typemap"
|
||||||
|
|
||||||
|
cvar.fixsize = 'ho'
|
||||||
|
if cvar.fixsize != 'ho\0\0\0\0\0\0':
|
||||||
|
raise RuntimeError, "bad FIXSIZE typemap"
|
||||||
|
|
||||||
|
|
||||||
|
f = Foo(3)
|
||||||
|
f1 = fptr_val(f)
|
||||||
|
f2 = fptr_ref(f)
|
||||||
|
if f1._a != f2._a:
|
||||||
|
raise RuntimeError, "bad const ptr& typemap"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import template_default_arg
|
||||||
|
|
||||||
|
|
||||||
helloInt = template_default_arg.Hello_int()
|
helloInt = template_default_arg.Hello_int()
|
||||||
helloInt.foo(Hello_int.Hi.hi)
|
helloInt.foo(template_default_arg.Hello_int.hi)
|
||||||
|
|
||||||
|
|
||||||
x = template_default_arg.X_int()
|
x = template_default_arg.X_int()
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ except:
|
||||||
|
|
||||||
|
|
||||||
# the old large format
|
# the old large format
|
||||||
if not SWIG_TypeQuery("vfncs::ArithUnaryFunction<vfncs::arith_traits<float,real>::argument_type,vfncs::arith_traits<float,real >::result_type > *"):
|
if not SWIG_TypeQuery("vfncs::ArithUnaryFunction<vfncs::arith_traits<float,double>::argument_type,vfncs::arith_traits<float,double >::result_type > *"):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@
|
||||||
%warnfilter(801) vector<double>; /* Ruby, wrong class name */
|
%warnfilter(801) vector<double>; /* Ruby, wrong class name */
|
||||||
%warnfilter(801) vector<int (*)[10]>; /* Ruby, wrong class name */
|
%warnfilter(801) vector<int (*)[10]>; /* Ruby, wrong class name */
|
||||||
|
|
||||||
// This warnfilter doesn't work
|
// #pragma is used for warnings that are not associated to
|
||||||
// %warnfilter(320);
|
// specific nodes.
|
||||||
// back to pragma
|
|
||||||
#pragma SWIG nowarn=-320
|
#pragma SWIG nowarn=-320
|
||||||
|
|
||||||
|
|
||||||
/* Let's just grab the original header file here */
|
/* Let's just grab the original header file here */
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
%inline {
|
%inline {
|
||||||
namespace A {
|
namespace A {
|
||||||
struct OpaqueStruct;
|
struct OpaqueStruct;
|
||||||
typedef struct OpaqueStruct OpaqueType;
|
typedef OpaqueStruct OpaqueType;
|
||||||
typedef std::vector<OpaqueType> OpaqueVectorType;
|
typedef std::vector<OpaqueType> OpaqueVectorType;
|
||||||
|
|
||||||
void FillVector(OpaqueVectorType& v)
|
void FillVector(OpaqueVectorType& v)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,42 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct Alloc
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class T, class A = double >
|
||||||
|
struct D
|
||||||
|
{
|
||||||
|
D(int){}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct D<double>
|
||||||
|
{
|
||||||
|
D(){}
|
||||||
|
int foo() { return 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class T, class A = Alloc<T> >
|
||||||
|
struct Vector
|
||||||
|
{
|
||||||
|
Vector(int){}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Vector<double>
|
||||||
|
{
|
||||||
|
Vector(){}
|
||||||
|
int foo() { return 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
@ -49,4 +85,11 @@
|
||||||
//
|
//
|
||||||
// This one fails
|
// This one fails
|
||||||
//
|
//
|
||||||
|
%template(C_dd) C<double,double>;
|
||||||
%template(C_d) C<double>;
|
%template(C_d) C<double>;
|
||||||
|
|
||||||
|
%template(D_i) D<int>;
|
||||||
|
%template(D_d) D<double>;
|
||||||
|
|
||||||
|
%template(Vector_i) Vector<int>;
|
||||||
|
%template(Vector_d) Vector<double, Alloc<double> >;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
template <class A, class B>
|
template <class A, class B>
|
||||||
struct Test<A, B*>
|
struct Test<A, B*>
|
||||||
{
|
{
|
||||||
Test (A a, B* b)
|
Test (B* a)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue