PageRenderTime 26ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 68 lines | 51 code | 17 blank | 0 comment | 0 complexity | 840edd6254962965116a259b05b48ffd MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module(naturalvar="1") implicittest
  2. %implicitconv;
  3. %inline
  4. {
  5. struct B { };
  6. }
  7. %inline
  8. {
  9. struct A
  10. {
  11. int ii;
  12. A(int i) { ii = 1; }
  13. A(double d) { ii = 2; }
  14. A(const B& b) { ii = 3; }
  15. explicit A(char *s) { ii = 4; }
  16. int get() const { return ii; }
  17. };
  18. int get(const A& a) { return a.ii; }
  19. template <class T>
  20. struct A_T
  21. {
  22. int ii;
  23. A_T(int i) { ii = 1; }
  24. A_T(double d) { ii = 2; }
  25. A_T(const B& b) { ii = 3; }
  26. explicit A_T(char *s) { ii = 4; }
  27. int get() const { return ii; }
  28. };
  29. }
  30. %inline
  31. {
  32. struct Foo
  33. {
  34. int ii;
  35. Foo(){ ii = 0;}
  36. Foo(int){ ii = 1;}
  37. Foo(double){ ii = 2;}
  38. explicit Foo(char *s){ii = 3;}
  39. Foo(const Foo& f){ ii = f.ii;}
  40. };
  41. struct Bar
  42. {
  43. int ii;
  44. Foo f;
  45. Bar() {ii = -1;}
  46. Bar(const Foo& ff){ ii = ff.ii;}
  47. };
  48. int get_b(const Bar&b) { return b.ii; }
  49. Foo foo;
  50. }
  51. %template(A_int) A_T<int>;