PageRenderTime 6ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Swig | 77 lines | 62 code | 15 blank | 0 comment | 0 complexity | 4910b28eec9b9ceb0fb70e256f48aefd MD5 | raw file
 1%module template_ns4
 2
 3
 4%inline %{
 5    namespace hello {
 6
 7    class Double {
 8    };
 9   
10    template <class ArgType, class ResType>
11    struct Function_
12    {     
13	char *test() { return (char *) "test"; }
14    };
15   
16    template <class AF, class RF>
17    struct ArithFunction : Function_<AF, RF>
18    {
19    };
20   
21    template <class ArgType, class ResType>
22    struct traits
23    {
24    }; 
25
26    template <class ArgType>
27    struct traits<ArgType, double>
28    {
29      typedef ArgType arg_type;
30      typedef double res_type;
31      typedef ArithFunction<ArgType, double> base;
32    };   
33
34    template <class ArgType>
35    struct traits<ArgType, Double>
36    {
37      typedef ArgType arg_type;
38      typedef Double res_type;
39      typedef ArithFunction<ArgType, Double> base;
40    };   
41
42    template <class AF, class RF>
43    class Class_ : public ArithFunction< typename traits<AF, RF>::arg_type,
44                    typename traits<AF, RF>::res_type >
45    {
46    };
47 
48    template <class AF, class RF>
49    typename traits<AF, RF>::base
50    make_Class()
51    {
52      return Class_<AF, RF>();
53    }
54
55
56  }  
57%}
58
59%{  
60  namespace hello {
61    template struct Function_ <Double, Double>;
62    template struct ArithFunction <Double, Double>;
63    template class Class_ <Double, Double>;   
64  }  
65%}
66
67 namespace hello {
68  //
69  // This complains only when using a namespace
70  //
71  %template() traits<Double,Double>;
72  %template(Function_DD) Function_ <Double, Double>;
73  %template(ArithFunction_DD) ArithFunction <Double, Double>;
74  %template(Class_DD) Class_ <Double, Double>;
75  %template(make_Class_DD) make_Class <Double, Double>;
76 }
77