blob: 8a4b6dca91be62f00c36105c724c5aaa1fb1a2a6 (
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
|
/* Tests the use of %template with namespaces */
%module namespace_template
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<int>; /* Ruby, wrong class name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<short>; /* Ruby, wrong class name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<long>; /* Ruby, wrong class name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<test::Char>; /* Ruby, wrong class name */
%{
#ifdef max
#undef max
#endif
%}
%{
namespace test {
template<typename T> T max(T a, T b) { return (a > b) ? a : b; }
template<typename T> class vector {
public:
vector() { }
~vector() { }
char * blah(T x) {
return (char *) "vector::blah";
}
void vectoruse(vector<T> a, test::vector<T> b) {}
};
}
%}
namespace test {
template<typename T> T max(T a, T b) { return (a > b) ? a : b; }
template<typename T> class vector {
public:
vector() { }
~vector() { }
char * blah(T x) {
return (char *) "vector::blah";
}
void vectoruse(vector<T> a, test::vector<T> b) {}
};
}
using namespace test;
%template(maxint) max<int>;
%template(vectorint) vector<int>;
namespace test {
%template(maxshort) max<short>;
%template(vectorshort) vector<short>;
}
namespace test {
%template(maxlong) max<long>;
%template(vectorlong) vector<long>;
}
%inline %{
namespace test {
typedef char Char;
}
%}
namespace test {
%template(maxchar) max<Char>;
%template(vectorchar) vector<Char>;
}
|