PageRenderTime 93ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-25/SWIG/Examples/test-suite/python/kwargs.i

#
Swig | 74 lines | 50 code | 24 blank | 0 comment | 0 complexity | c0bd4e0ebc0eeec736f6f091197e4c51 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module kwargs
  2. %feature("kwargs");
  3. // Simple class
  4. %extend Foo
  5. {
  6. int efoo(int a = 1, int b = 0) {return a + b; }
  7. static int sfoo(int a = 1, int b = 0) { return a + b; }
  8. }
  9. %inline %{
  10. struct Foo
  11. {
  12. Foo(int a, int b = 0){}
  13. int foo(int a = 1, int b = 0) {return a + b; }
  14. static int statfoo(int a = 1, int b = 0) {return a + b; }
  15. };
  16. %}
  17. // Templated class
  18. %extend Bar
  19. {
  20. T ebar(T a = 1, T b = 0) {return a + b; }
  21. static T sbar(T a = 1, T b = 0) { return a + b; }
  22. }
  23. %inline %{
  24. template <typename T> struct Bar
  25. {
  26. Bar(T a, T b = 0){}
  27. T bar(T a = 1, T b = 0) {return a + b; }
  28. static T statbar(T a = 1, T b = 0) {return a + b; }
  29. };
  30. %}
  31. %template(BarInt) Bar<int>;
  32. // Functions
  33. %inline %{
  34. int foo(int a = 1, int b = 0) {return a + b; }
  35. template<typename T> T templatedfunction(T a = 1, T b = 0) { return a + b; }
  36. %}
  37. %template(templatedfunction) templatedfunction<int>;
  38. // Deafult args with references
  39. %inline
  40. %{
  41. typedef int size_type;
  42. struct Hello
  43. {
  44. static const size_type hello = 3;
  45. };
  46. int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() )
  47. {
  48. return x;
  49. }
  50. %}