summaryrefslogtreecommitdiff
path: root/Examples/test-suite/template_ns4.i
blob: 34489c47357fe9baec8df032e89506e7c8c3de84 (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
%module template_ns4


%inline %{
    namespace hello {

    class Double {
    };
   
    template <class ArgType, class ResType>
    struct Function
    {     
	char *test() { return (char *) "test"; }
    };
   
    template <class AF, class RF>
    struct ArithFunction : Function<AF, RF>
    {
    };
   
    template <class ArgType, class ResType>
    struct traits
    {
    }; 

    template <class ArgType>
    struct traits<ArgType, double>
    {
      typedef ArgType arg_type;
      typedef double res_type;
      typedef ArithFunction<ArgType, double> base;
    };   

    template <class ArgType>
    struct traits<ArgType, Double>
    {
      typedef ArgType arg_type;
      typedef Double res_type;
      typedef ArithFunction<ArgType, Double> base;
    };   

    template <class AF, class RF>
    class Class : public ArithFunction< typename traits<AF, RF>::arg_type,
                    typename traits<AF, RF>::res_type >
    {
    };
 
    template <class AF, class RF>
    typename traits<AF, RF>::base
    make_Class()
    {
      return Class<AF, RF>();
    }


  }  
%}

%{  
  namespace hello {
    template struct Function <Double, Double>;
    template struct ArithFunction <Double, Double>;
    template class Class <Double, Double>;   
  }  
%}

 namespace hello {
  //
  // This complains only when using a namespace
  //
  %template() traits<Double,Double>;
  %template(Function_DD) Function <Double, Double>;
  %template(ArithFunction_DD) ArithFunction <Double, Double>;
  %template(Class_DD) Class <Double, Double>;
  %template(make_Class_DD) make_Class <Double, Double>;
 }