PageRenderTime 47ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

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

#
Swig | 112 lines | 73 code | 38 blank | 1 comment | 0 complexity | 728c51150751e69bb2106930b5bb9731 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module kwargs_feature
  2. %nocopyctor;
  3. %kwargs;
  4. %rename(myDel) del;
  5. %inline
  6. {
  7. struct s { int del; };
  8. }
  9. // Simple class
  10. %extend Foo
  11. {
  12. int efoo(int a = 1, int b = 0) {return a + b; }
  13. static int sfoo(int a = 1, int b = 0) { return a + b; }
  14. }
  15. %newobject Foo::create;
  16. %inline %{
  17. struct Foo
  18. {
  19. Foo(int a, int b = 0) {}
  20. virtual int foo(int a = 1, int b = 0) {return a + b; }
  21. static int statfoo(int a = 1, int b = 0) {return a + b; }
  22. static Foo *create(int a = 1, int b = 0)
  23. {
  24. return new Foo(a, b);
  25. }
  26. virtual ~Foo() {
  27. }
  28. };
  29. %}
  30. // Templated class
  31. %extend Bar
  32. {
  33. T ebar(T a = 1, T b = 0) {return a + b; }
  34. static T sbar(T a = 1, T b = 0) { return a + b; }
  35. }
  36. %inline %{
  37. template <typename T> struct Bar
  38. {
  39. Bar(T a, T b = 0){}
  40. T bar(T a = 1, T b = 0) {return a + b; }
  41. static T statbar(T a = 1, T b = 0) {return a + b; }
  42. };
  43. %}
  44. %template(BarInt) Bar<int>;
  45. // Functions
  46. %inline %{
  47. int foo(int a = 1, int b = 0) {return a + b; }
  48. template<typename T> T templatedfunction(T a = 1, T b = 0) { return a + b; }
  49. %}
  50. %template(templatedfunction) templatedfunction<int>;
  51. // Deafult args with references
  52. %inline
  53. %{
  54. typedef int size_type;
  55. struct Hello
  56. {
  57. static const size_type hello = 3;
  58. };
  59. int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() )
  60. {
  61. return x;
  62. }
  63. %}
  64. %{
  65. const int Hello::hello;
  66. %}
  67. // Functions with keywords
  68. %warnfilter(SWIGWARN_PARSE_KEYWORD);
  69. %inline %{
  70. /* silently rename the parameter names in python */
  71. int foo_kw(int from = 1, int except = 2) {return from + except; }
  72. int foo_nu(int from = 1, int = 0) {return from; }
  73. int foo_mm(int min = 1, int max = 2) {return min + max; }
  74. %}