PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms 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
 1/* Test the tp_richcompare functions generated with the -builtin option */
 2
 3%module python_richcompare
 4
 5%inline {
 6
 7class BaseClass {
 8public:
 9    BaseClass (int i_) : i(i_) {}
10    ~BaseClass () {}
11
12    int getValue () const
13    { return i; }
14    
15    bool operator< (const BaseClass& x) const
16    { return this->i < x.i; }
17
18    bool operator> (const BaseClass& x) const
19    { return this->i > x.i; }
20
21    bool operator<= (const BaseClass& x) const
22    { return this->i <= x.i; }
23
24    bool operator>= (const BaseClass& x) const
25    { return this->i >= x.i; }
26
27    bool operator== (const BaseClass& x) const
28    { return this->i == x.i; }
29
30    bool operator!= (const BaseClass& x) const
31    { return this->i != x.i; }
32
33    int i;
34};
35
36class SubClassA : public BaseClass {
37public:
38    SubClassA (int i_) : BaseClass(i_) {}
39    ~SubClassA () {}
40
41    bool operator== (const SubClassA& x) const
42    { return true; }
43
44    bool operator== (const BaseClass& x) const
45    { return false; }
46};
47
48class SubClassB : public BaseClass {
49public:
50    SubClassB (int i_) : BaseClass(i_) {}
51    ~SubClassB () {}
52
53    bool operator== (const SubClassB& x) const
54    { return true; }
55
56    bool operator== (const SubClassA& x) const
57    { return false; }
58};
59
60}