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