More covariant tests and polymorphic methods tests to test C# override keyword.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7197 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
79ee75daf4
commit
377c757a06
2 changed files with 53 additions and 2 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
%module class_ignore
|
%module class_ignore
|
||||||
|
|
||||||
%ignore Foo;
|
%ignore Foo;
|
||||||
|
|
||||||
%ignore *::Bar::foo;
|
%ignore *::Bar::foo;
|
||||||
|
%ignore Far::away() const;
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
class Foo {
|
class Foo {
|
||||||
|
|
@ -21,11 +21,21 @@
|
||||||
|
|
||||||
virtual char *blah() { return (char *) "Bar::blah"; }
|
virtual char *blah() { return (char *) "Bar::blah"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Boo {
|
||||||
|
virtual ~Boo() {}
|
||||||
|
virtual void away() const {}
|
||||||
|
};
|
||||||
|
struct Far : Boo {
|
||||||
|
virtual void away() const {}
|
||||||
|
};
|
||||||
|
struct Hoo : Far {
|
||||||
|
virtual void away() const {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
char *do_blah(Foo *f) {
|
char *do_blah(Foo *f) {
|
||||||
return f->blah();
|
return f->blah();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
%warnfilter(822, 842) copy; /* Java, C# covariant return types */
|
%warnfilter(822, 842) copy; /* Java, C# covariant return types */
|
||||||
%warnfilter(822, 842) ref_this; /* Java, C# covariant return types */
|
%warnfilter(822, 842) ref_this; /* Java, C# covariant return types */
|
||||||
|
%warnfilter(822, 842) covariant; /* Java, C# covariant return types */
|
||||||
|
%warnfilter(822, 842) covariant2; /* Java, C# covariant return types */
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check this example with directors wherever possible.
|
// Check this example with directors wherever possible.
|
||||||
|
|
@ -133,3 +135,42 @@
|
||||||
return dynamic_cast<NDouble*>(n);
|
return dynamic_cast<NDouble*>(n);
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
|
||||||
|
// These two classes test covariant return types and whether swig accurately match
|
||||||
|
// polymorphic methods (mainly for C# override keyword)
|
||||||
|
|
||||||
|
typedef int* IntegerPtr;
|
||||||
|
typedef double Double;
|
||||||
|
|
||||||
|
template<typename T> struct Base {
|
||||||
|
T t;
|
||||||
|
virtual IntegerPtr method() const = 0;
|
||||||
|
virtual IntegerPtr foxy() const = 0;
|
||||||
|
virtual IntegerPtr foxy(int a) const = 0;
|
||||||
|
virtual int * foxy(int*& a) { return 0; }
|
||||||
|
virtual double function() = 0;
|
||||||
|
virtual IntegerPtr defaultargs(double d, int * a = 0) = 0;
|
||||||
|
virtual Base * covariant(int a = 0, int * i = 0) { return 0; }
|
||||||
|
typedef Base * BasePtr;
|
||||||
|
virtual BasePtr covariant2() { return 0; }
|
||||||
|
virtual ~Base() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T> struct Derived : Base<T> {
|
||||||
|
int * method() const { return 0; }
|
||||||
|
int * foxy(int a) const {}
|
||||||
|
virtual int * foxy(int*& a) { return 0; }
|
||||||
|
Double function() { return 0; }
|
||||||
|
int * defaultargs(Double d, IntegerPtr a = 0) { return 0; }
|
||||||
|
typedef Derived * DerivedPtr;
|
||||||
|
DerivedPtr covariant(int a = 0, IntegerPtr i = 0) { return 0; }
|
||||||
|
DerivedPtr covariant2() { return 0; }
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
%template(BaseInt) Base<int>;
|
||||||
|
%template(DerivedInt) Derived<int>;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue