PageRenderTime 60ms CodeModel.GetById 54ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

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

#
Swig | 84 lines | 67 code | 16 blank | 1 comment | 0 complexity | 6c0b478f4a5aa0d3e05aa1f651dbafdb MD5 | raw file
 1/* Tests the use of %template with namespaces */
 2
 3%module namespace_template
 4
 5%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<int>;            /* Ruby, wrong class name */
 6%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test2::vector<short>;   /* Ruby, wrong class name */
 7%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test3::vector<long>;    /* Ruby, wrong class name */
 8%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<test4::Integer>; /* Ruby, wrong class name */
 9
10%{
11#ifdef max
12#undef max
13#endif
14%}
15
16%{
17namespace test {
18   template<typename T> T max(T a, T b) { return (a > b) ? a : b; }
19   template<typename T> class vector { 
20	public:
21	   vector() { }
22          ~vector() { }
23           char * blah(T x) {
24              return (char *) "vector::blah";
25           }
26   }; 
27}
28
29namespace test2 {
30   using namespace test;
31}
32
33namespace test3 {
34   using test::max;
35   using test::vector;
36}
37
38using namespace test2;
39namespace T4 = test;
40%}
41
42namespace test {
43   template<typename T> T max(T a, T b) { return (a > b) ? a : b; }
44   template<typename T> class vector { 
45	public:
46	   vector() { }
47          ~vector() { }
48           char * blah(T x) {
49              return (char *) "vector::blah";
50           }
51   }; 
52}
53
54using namespace test;
55%template(maxint) max<int>;
56%template(vectorint) vector<int>;
57
58namespace test2 {
59   using namespace test;
60   %template(maxshort) max<short>;
61   %template(vectorshort) vector<short>;
62}
63
64namespace test3 {
65   using test::max;
66   using test::vector;
67   %template(maxlong) max<long>;
68   %template(vectorlong) vector<long>;
69}
70
71%inline %{
72
73namespace test4 {
74   using namespace test;
75   typedef int Integer;
76}
77
78%}
79
80namespace test4 {
81   %template(maxInteger) max<Integer>;
82   %template(vectorInteger) vector<Integer>;
83}
84