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

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

#
Swig | 80 lines | 59 code | 21 blank | 0 comment | 0 complexity | bdec83698e43115377fe37ef250d5c94 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module(directors="1") director_stl
  2. #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
  3. %include "std_string.i"
  4. %include "std_pair.i"
  5. %include "std_vector.i"
  6. #ifndef SWIG_STD_DEFAULT_INSTANTIATION
  7. %template() std::vector<double>;
  8. %template() std::vector<int>;
  9. %template() std::vector<std::string>;
  10. %template() std::pair<std::string, int>;
  11. %template() std::pair<int,double>;
  12. %template() std::pair<double,int>;
  13. #endif
  14. %feature("director") Foo;
  15. %feature("director:except") {
  16. #ifndef SWIGPHP
  17. if ($error != NULL) {
  18. #else
  19. if ($error == FAILURE) {
  20. #endif
  21. throw Swig::DirectorMethodException();
  22. }
  23. }
  24. %exception {
  25. try { $action }
  26. catch (...) { SWIG_fail; }
  27. }
  28. %inline
  29. {
  30. class Foo {
  31. public:
  32. virtual ~Foo() {}
  33. virtual std::string& bar(std::string& s)
  34. {
  35. return s;
  36. }
  37. virtual std::string ping(std::string s) = 0;
  38. virtual std::string pong(const std::string& s)
  39. { return std::string("Foo::pong:") + s + ":" + ping(s); }
  40. std::string tping(std::string s) { return ping(s); }
  41. std::string tpong(const std::string& s) { return pong(s); }
  42. virtual std::pair<double, int>
  43. pident(const std::pair<double, int>& p) { return p; }
  44. virtual std::vector<int>
  45. vident(const std::vector<int>& p) { return p; }
  46. virtual std::vector<int>
  47. vsecond(const std::vector<int>& p, const std::vector<int>& s) { return s; }
  48. std::pair<double, int>
  49. tpident(const std::pair<double, int>& p) { return pident(p); }
  50. std::vector<int>
  51. tvident(const std::vector<int>& p) { return vident(p); }
  52. virtual std::vector<int>
  53. tvsecond(const std::vector<int>& p, const std::vector<int>& s) { return vsecond(p,s); }
  54. virtual std::vector<std::string>
  55. vidents(const std::vector<std::string>& p) { return p; }
  56. std::vector<std::string>
  57. tvidents(const std::vector<std::string>& p) { return vidents(p); }
  58. };
  59. }