PageRenderTime 12ms CodeModel.GetById 10ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/implicittest.i

#
Swig | 68 lines | 51 code | 17 blank | 0 comment | 0 complexity | 840edd6254962965116a259b05b48ffd MD5 | raw file
 1%module(naturalvar="1") implicittest
 2
 3%implicitconv;
 4
 5%inline 
 6{
 7  struct B { };  
 8}
 9
10%inline 
11{
12  struct A
13  {
14    int ii;
15    A(int i) { ii = 1; }
16    A(double d) { ii = 2; }
17    A(const B& b) { ii = 3; }
18    explicit A(char *s) { ii = 4; }
19
20    int get() const { return ii; }
21    
22  };
23
24  int get(const A& a) { return a.ii; }
25
26  template <class T>
27  struct A_T
28  {
29    int ii;
30    A_T(int i) { ii = 1; }
31    A_T(double d) { ii = 2; }
32    A_T(const B& b) { ii = 3; }
33    explicit A_T(char *s) { ii = 4; }
34
35    int get() const { return ii; }
36    
37  };
38}
39
40%inline 
41{
42  struct Foo 
43  {
44    int ii;
45    Foo(){ ii = 0;}
46    Foo(int){ ii = 1;}
47    Foo(double){ ii = 2;}
48    explicit Foo(char *s){ii = 3;}
49    Foo(const Foo& f){ ii = f.ii;}
50    
51  };
52
53  struct Bar 
54  {
55    int ii;
56    Foo f;
57    Bar() {ii = -1;}
58    Bar(const Foo& ff){ ii = ff.ii;}
59  };
60
61
62  int get_b(const Bar&b) { return b.ii; }
63  
64  Foo foo;
65  
66}
67
68%template(A_int) A_T<int>;