import source from 1.3.40
[external/swig.git] / Examples / test-suite / typemap_various.i
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 %{
10 template <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 %{
24 void foo1(Foo<int> f, const Foo<int>& ff) {}
25 void 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