/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 3%feature("kwargs"); 4 5// Simple class 6%extend Foo 7{ 8 int efoo(int a = 1, int b = 0) {return a + b; } 9 static int sfoo(int a = 1, int b = 0) { return a + b; } 10} 11 12%inline %{ 13 14 struct Foo 15 { 16 Foo(int a, int b = 0){} 17 18 int foo(int a = 1, int b = 0) {return a + b; } 19 static int statfoo(int a = 1, int b = 0) {return a + b; } 20 }; 21 22%} 23 24 25// Templated class 26%extend Bar 27{ 28 T ebar(T a = 1, T b = 0) {return a + b; } 29 static T sbar(T a = 1, T b = 0) { return a + b; } 30} 31 32%inline %{ 33 template <typename T> struct Bar 34 { 35 Bar(T a, T b = 0){} 36 37 T bar(T a = 1, T b = 0) {return a + b; } 38 static T statbar(T a = 1, T b = 0) {return a + b; } 39 }; 40 41%} 42 43%template(BarInt) Bar<int>; 44 45 46// Functions 47%inline %{ 48 int foo(int a = 1, int b = 0) {return a + b; } 49 50 template<typename T> T templatedfunction(T a = 1, T b = 0) { return a + b; } 51%} 52 53%template(templatedfunction) templatedfunction<int>; 54 55 56// Deafult args with references 57%inline 58%{ 59 60 typedef int size_type; 61 62 struct Hello 63 { 64 static const size_type hello = 3; 65 }; 66 67 68 69 int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() ) 70 { 71 return x; 72 } 73 74%}