Skip to content

Commit eb2be58

Browse files
Thomas REITMAYRtreitmayr
authored andcommitted
Add test cases for abstract user-defined conversion operators
1 parent 059bb0c commit eb2be58

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Examples/test-suite/common.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ CPP_TEST_CASES += \
184184
director_classes \
185185
director_classic \
186186
director_constructor \
187+
director_conversion_operators \
187188
director_default \
188189
director_detect \
189190
director_enum \
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
%module(directors="1") director_conversion_operators
2+
3+
%feature("director");
4+
5+
%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Bar;
6+
7+
%rename(toFoo) Bar::operator Foo();
8+
%rename(toFooPtr) Bar::operator Foo *();
9+
%rename(toFooRef) Bar::operator Foo &();
10+
%rename(toFooPtrRef) Bar::operator Foo *&();
11+
12+
%rename(toOtherFoo) Bar::operator OtherFoo();
13+
%rename(toOtherFooPtr) Bar::operator OtherFoo *();
14+
%rename(toOtherFooRef) Bar::operator OtherFoo &();
15+
%rename(toOtherFooPtrRef) Bar::operator OtherFoo *&();
16+
17+
%inline %{
18+
struct Foo {
19+
};
20+
struct OtherFoo {
21+
};
22+
struct Bar {
23+
Foo myFoo;
24+
Foo *myFooPtr;
25+
virtual ~Bar() { }
26+
virtual operator Foo () { return Foo(); }
27+
virtual operator Foo *() { return &myFoo; }
28+
virtual operator Foo &() { return myFoo; }
29+
virtual operator Foo *&() { return myFooPtr; }
30+
virtual operator OtherFoo () = 0;
31+
virtual operator OtherFoo *() = 0;
32+
virtual operator OtherFoo &() = 0;
33+
virtual operator OtherFoo *&() = 0;
34+
};
35+
%}

0 commit comments

Comments
 (0)