PageRenderTime 226ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 41 lines | 33 code | 8 blank | 0 comment | 0 complexity | b843ca4f0a5c2dc269fdfd2ddb37b04b MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. // Tests typedef through member pointers
  2. %module typedef_mptr
  3. %{
  4. #if defined(__SUNPRO_CC)
  5. #pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
  6. #pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
  7. #endif
  8. %}
  9. #if defined(SWIGPYTHON) || defined(SWIGOCAML)
  10. %inline %{
  11. class Foo {
  12. public:
  13. int add(int x, int y) {
  14. return x+y;
  15. }
  16. int sub(int x, int y) {
  17. return x-y;
  18. }
  19. int do_op(int x, int y, int (Foo::*op)(int, int)) {
  20. return (this->*op)(x,y);
  21. }
  22. };
  23. typedef Foo FooObj;
  24. typedef int Integer;
  25. Integer do_op(Foo *f, Integer x, Integer y, Integer (FooObj::*op)(Integer, Integer)) {
  26. return f->do_op(x,y,op);
  27. }
  28. %}
  29. #endif
  30. #if defined(SWIGPYTHON) || defined(SWIGOCAML)
  31. %constant int (Foo::*add)(int,int) = &Foo::add;
  32. %constant Integer (FooObj::*sub)(Integer,Integer) = &FooObj::sub;
  33. #endif