/trunk/Examples/test-suite/implicittest.i
Swig | 68 lines | 51 code | 17 blank | 0 comment | 0 complexity | 840edd6254962965116a259b05b48ffd MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
- %module(naturalvar="1") implicittest
- %implicitconv;
- %inline
- {
- struct B { };
- }
- %inline
- {
- struct A
- {
- int ii;
- A(int i) { ii = 1; }
- A(double d) { ii = 2; }
- A(const B& b) { ii = 3; }
- explicit A(char *s) { ii = 4; }
- int get() const { return ii; }
-
- };
- int get(const A& a) { return a.ii; }
- template <class T>
- struct A_T
- {
- int ii;
- A_T(int i) { ii = 1; }
- A_T(double d) { ii = 2; }
- A_T(const B& b) { ii = 3; }
- explicit A_T(char *s) { ii = 4; }
- int get() const { return ii; }
-
- };
- }
- %inline
- {
- struct Foo
- {
- int ii;
- Foo(){ ii = 0;}
- Foo(int){ ii = 1;}
- Foo(double){ ii = 2;}
- explicit Foo(char *s){ii = 3;}
- Foo(const Foo& f){ ii = f.ii;}
-
- };
- struct Bar
- {
- int ii;
- Foo f;
- Bar() {ii = -1;}
- Bar(const Foo& ff){ ii = ff.ii;}
- };
- int get_b(const Bar&b) { return b.ii; }
-
- Foo foo;
-
- }
- %template(A_int) A_T<int>;