PageRenderTime 51ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 60 lines | 41 code | 18 blank | 1 comment | 0 complexity | c61fbf68395552e410041d62fdbc8bb0 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* Test the tp_richcompare functions generated with the -builtin option */
  2. %module python_richcompare
  3. %inline {
  4. class BaseClass {
  5. public:
  6. BaseClass (int i_) : i(i_) {}
  7. ~BaseClass () {}
  8. int getValue () const
  9. { return i; }
  10. bool operator< (const BaseClass& x) const
  11. { return this->i < x.i; }
  12. bool operator> (const BaseClass& x) const
  13. { return this->i > x.i; }
  14. bool operator<= (const BaseClass& x) const
  15. { return this->i <= x.i; }
  16. bool operator>= (const BaseClass& x) const
  17. { return this->i >= x.i; }
  18. bool operator== (const BaseClass& x) const
  19. { return this->i == x.i; }
  20. bool operator!= (const BaseClass& x) const
  21. { return this->i != x.i; }
  22. int i;
  23. };
  24. class SubClassA : public BaseClass {
  25. public:
  26. SubClassA (int i_) : BaseClass(i_) {}
  27. ~SubClassA () {}
  28. bool operator== (const SubClassA& x) const
  29. { return true; }
  30. bool operator== (const BaseClass& x) const
  31. { return false; }
  32. };
  33. class SubClassB : public BaseClass {
  34. public:
  35. SubClassB (int i_) : BaseClass(i_) {}
  36. ~SubClassB () {}
  37. bool operator== (const SubClassB& x) const
  38. { return true; }
  39. bool operator== (const SubClassA& x) const
  40. { return false; }
  41. };
  42. }