mirror of https://github.com/swig/swig
Add test cases for abstract user-defined conversion operators
This commit is contained in:
parent
059bb0c0a0
commit
eb2be58a12
|
@ -184,6 +184,7 @@ CPP_TEST_CASES += \
|
|||
director_classes \
|
||||
director_classic \
|
||||
director_constructor \
|
||||
director_conversion_operators \
|
||||
director_default \
|
||||
director_detect \
|
||||
director_enum \
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
%module(directors="1") director_conversion_operators
|
||||
|
||||
%feature("director");
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Bar;
|
||||
|
||||
%rename(toFoo) Bar::operator Foo();
|
||||
%rename(toFooPtr) Bar::operator Foo *();
|
||||
%rename(toFooRef) Bar::operator Foo &();
|
||||
%rename(toFooPtrRef) Bar::operator Foo *&();
|
||||
|
||||
%rename(toOtherFoo) Bar::operator OtherFoo();
|
||||
%rename(toOtherFooPtr) Bar::operator OtherFoo *();
|
||||
%rename(toOtherFooRef) Bar::operator OtherFoo &();
|
||||
%rename(toOtherFooPtrRef) Bar::operator OtherFoo *&();
|
||||
|
||||
%inline %{
|
||||
struct Foo {
|
||||
};
|
||||
struct OtherFoo {
|
||||
};
|
||||
struct Bar {
|
||||
Foo myFoo;
|
||||
Foo *myFooPtr;
|
||||
virtual ~Bar() { }
|
||||
virtual operator Foo () { return Foo(); }
|
||||
virtual operator Foo *() { return &myFoo; }
|
||||
virtual operator Foo &() { return myFoo; }
|
||||
virtual operator Foo *&() { return myFooPtr; }
|
||||
virtual operator OtherFoo () = 0;
|
||||
virtual operator OtherFoo *() = 0;
|
||||
virtual operator OtherFoo &() = 0;
|
||||
virtual operator OtherFoo *&() = 0;
|
||||
};
|
||||
%}
|
Loading…
Reference in New Issue