PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Swig | 74 lines | 60 code | 14 blank | 0 comment | 0 complexity | 1c4619cf8eb1671519a39bf5b4fd2400 MD5 | raw file
 1%module typemap_various
 2
 3// %copyctor need to be disables since 'const SWIGTYPE &' is intended to generate errors
 4%nocopyctor;
 5
 6%typemap(in) SWIGTYPE "_this_will_not_compile_SWIGTYPE_"
 7%typemap(in) const SWIGTYPE & "_this_will_not_compile_const_SWIGTYPE_REF_"
 8
 9%inline %{
10template <class T> struct Foo {
11  Foo() {}
12#ifdef SWIG
13  // These typemaps should be used by foo1 and foo2
14  %typemap(in) Foo<T>      "/*in typemap for Foo<T> */"
15  %typemap(in) const Foo & "/*in typemap for const Foo&, with type T*/"
16#endif
17};
18%}
19
20%template(FooInt) Foo<int>;
21%template() Foo<short>; // previously Foo<short> typemaps were being picked up for Python only
22
23%inline %{
24void foo1(Foo<int> f, const Foo<int>& ff) {}
25void foo2(Foo<short> f, const Foo<short>& ff) {}
26%}
27
28#ifdef SWIGUTL
29%typemap(ret) int Bar1::foo() { /* hello1 */ };
30%typemap(ret) int Bar2::foo() { /* hello2 */ };
31%typemap(ret) int foo() {/* hello3 */ };
32#endif
33
34%inline %{
35  struct Bar1 {
36    int foo() { return 1;}    
37  };
38
39  struct Bar2 {
40    int foo() { return 1;}    
41  };
42%}
43
44
45
46%newobject FFoo::Bar(bool) const ;
47%typemap(newfree) char* Bar(bool)  {
48   /* hello */ delete[] result;
49}
50
51%inline {
52  class FFoo {
53  public:
54    char * Bar(bool b) const { return (char *)"x"; }
55  };
56}
57
58
59// Test obscure bug where named typemaps where not being applied when symbol name contained a number
60%typemap(out) double "_typemap_for_double_no_compile_"
61%typemap(out) double ABC::meth "$1 = 0.0;"
62%typemap(out) double ABC::m1   "$1 = 0.0;"
63%typemap(out) double ABC::_x2  "$1 = 0.0;"
64%typemap(out) double ABC::y_   "$1 = 0.0;"
65%typemap(out) double ABC::_3   "$1 = 0.0;"
66%inline %{
67struct ABC {
68  double meth() {}
69  double m1() {}
70  double _x2() {}
71  double y_() {}
72  double _3() {}
73};
74%}