summaryrefslogtreecommitdiff
path: root/Examples/test-suite/template_methods.i
blob: 9be60701f2b31958799f28c9fa5f6f120b98a5bc (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Test %ignore and %rename for templated methods

%module template_methods

%warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve1<float>();
%warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve3<float>();

%include <std_string.i>

///////////////////
%ignore convolve1<float>(float a);

%inline %{
template <typename ImageT> int convolve1() { return 0; }
template <typename ImageT> void convolve1(ImageT a) { ImageT t = a; (void)t; }
%}

%template() convolve1<float>;
%template(convolve1Bool) convolve1<bool>;


///////////////////
%ignore convolve2<float>(float a);

%inline %{
template <typename ImageT> int convolve2() { return 0; }
template <typename ImageT> void convolve2(ImageT a) { ImageT t = a; (void)t; }
%}

%template(convolve2Float) convolve2<float>;

///////////////////
%rename(convolve3FloatRenamed) convolve3<float>(float a);

%inline %{
template <typename ImageT> int convolve3() { return 0; }
template <typename ImageT> void convolve3(ImageT a) { ImageT t = a; (void)t; }
%}

%template() convolve3<float>;

///////////////////
%rename(convolve4FloatRenamed) convolve4<float>(float a);

%inline %{
template <typename ImageT> int convolve4() { return 0; }
template <typename ImageT> void convolve4(ImageT a) { ImageT t = a; (void)t; }
%}

%template(convolve4Float) convolve4<float>;


///////////////////
%rename(convolve5FloatRenamed) convolve5<float>;
%ignore convolve5<bool>;

%inline %{
template <typename ImageT> int convolve5() { return 0; }
template <typename ImageT> void convolve5(ImageT a) { ImageT t = a; (void)t; }
%}

%template() convolve5<float>;
%template() convolve5<bool>;


////////////////////////////////////////////////////////////////////////////
%rename(KlassTMethodBoolRenamed) Klass::tmethod(bool);
%rename(KlassStaticTMethodBoolRenamed) Klass::statictmethod(bool);

%inline %{
struct Klass {
  template<typename X> X tmethod(X x) { return x; }
  template<typename X> void tmethod() {}
  template<typename X> static X statictmethod(X x) { return x; }
  template<typename X> static void statictmethod() {}
};
%}
%template(KlassTMethodBool) Klass::tmethod<bool>;
%template(KlassStaticTMethodBool) Klass::statictmethod<bool>;

////////////////////////////////////////////////////////////////////////////

%inline %{
  class ComponentProperties{
  public:
    ComponentProperties() {}
    ~ComponentProperties() {}

    template <typename T1> void adda(std::string key, T1 val) {}
    template <typename T1, typename T2> void adda(std::string key1, T1 val1, std::string key2, T2 val2) {}
    template <typename T1, typename T2, typename T3> void adda(std::string key1, T1 val1, std::string key2, T2 val2, std::string key3, T3 val3) {}
  };
%}

%extend ComponentProperties {
  %template(adda) adda<std::string, double>;
  %template(adda) adda<std::string, std::string, std::string>; // ERROR OCCURS HERE
  %template(adda) adda<int, int, int>;
}