import source from 1.3.40
[external/swig.git] / Examples / test-suite / bools.i
1 // bool typemaps check
2 %module bools
3 %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);                   /* memory leak when setting a ptr/ref variable */
4 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) constbool;         /* Ruby, wrong class name */
5
6 // bool constant
7 %constant bool constbool=false;
8
9 %inline %{
10
11 // bool variables
12 bool bool1 = true;
13 bool bool2 = false;
14 bool* pbool = &bool1;
15 bool& rbool = bool2;
16 const bool* const_pbool = pbool;
17 const bool& const_rbool = rbool;
18
19 static int eax()
20 {
21   return 1024;  // NOTE: any number > 255 should do
22 }
23
24 // bool functions
25 bool bo(bool b) {
26   return b;
27 }
28 bool& rbo(bool& b) {
29     return b;
30 }
31 bool* pbo(bool* b) {
32     return b;
33 }
34 const bool& const_rbo(const bool& b) {
35     return b;
36 }
37 const bool* const_pbo(const bool* b) {
38     return b;
39 }
40
41 // helper function
42 bool value(bool* b) {
43     return *b;
44 }
45
46 struct BoolStructure {
47   bool m_bool1;
48   bool m_bool2;
49   bool* m_pbool;
50   bool& m_rbool;
51   const bool* m_const_pbool;
52   const bool& m_const_rbool;
53   BoolStructure() :
54     m_bool1(true),
55     m_bool2(false),
56     m_pbool(&m_bool1),
57     m_rbool(m_bool2),
58     m_const_pbool(m_pbool),
59     m_const_rbool(m_rbool) {}
60 private:
61   BoolStructure& operator=(const BoolStructure &);
62 };
63 %}
64