summaryrefslogtreecommitdiff
path: root/Examples/test-suite/implicittest.i
blob: e07adc5cc0f7f5181ab46b0b3444cbd68caf950d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
%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; }
    static int sget(const A_T& a) { return a.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>;