1 // This module tests default constructor generation under a
2 // number of different conditions
3
4 %module(ruby_minherit="1") default_constructor
5
6 %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
7 SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
8 SWIGWARN_D_MULTIPLE_INHERITANCE,
9 SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, D, Java, PHP multiple inheritance */
10
11 %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
12 SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
13 SWIGWARN_D_MULTIPLE_INHERITANCE,
14 SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */
15
16 %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
17 SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
18 SWIGWARN_D_MULTIPLE_INHERITANCE,
19 SWIGWARN_PHP_MULTIPLE_INHERITANCE) GGG; /* C#, D, Java, PHP multiple inheritance */
20
21 %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
22 SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
23 SWIGWARN_D_MULTIPLE_INHERITANCE,
24 SWIGWARN_PHP_MULTIPLE_INHERITANCE) HHH; /* C#, D, Java, PHP multiple inheritance */
25
26 %warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
27
28 %delobject F::destroy;
29 %delobject G::destroy;
30
31 %inline %{
32
33 /* A class with a public default constructor */
34 class A {
35 public:
A()36 A() { };
37 };
38
39 /* This class should get default constructor/destructors */
40 class AA : public A {
41 };
42
43 /* A class with a public constructor, but not default */
44
45 class B {
46 private:
B()47 B() { }
48 public:
B(int x,int y)49 B(int x, int y) { }
50 };
51
52 /* This class should get no default constructor, but a destructor */
53 class BB : public B {
54 };
55
56 /* A class with a protected constructor */
57 class C {
58 protected:
C()59 C() { };
60 public:
61 };
62
63 /* This class does get a default constructor/destructor */
64 class CC : public C {
65 };
66
67
68 /* A class with a private constructor */
69 class D {
70 private:
D()71 D() { };
72 public:
foo()73 void foo() { };
74 };
75
76 /* This class does not get a default constructor */
77 class DD: public D {
78
79 };
80
81 /* No default constructor. A is okay, but D is not */
82 class AD: public A, public D {
83
84 };
85
86 /* This class has a default constructor because of optional arguments */
87 class E {
88 public:
89 E(int x = 0, int y = 0) { }
90 };
91
92 /* This should get a default constructor */
93 class EE : public E {
94 };
95
96 /* This class should not get a default constructor. B doesn't have one */
97
98 class EB : public E, public B {
99
100 };
101
102 /* A class with a private destructor */
103
104 class F {
105 private:
~F()106 ~F() { }
107 public:
foo(int,int)108 void foo(int, int) { }
109 friend void bar(F *);
destroy()110 void destroy() { delete this; }
111
112 };
113
bar(F *)114 void bar(F *) { }
115
116 #if defined(_MSC_VER)
117 #pragma warning(disable: 4624) // destructor could not be generated because a base class destructor is inaccessible or deleted
118 #endif
119
120 // Single inheritance, base has private destructor
121 class FFF : public F {
122 };
123
124 // Multiple inheritance, one base has private destructor
125 class GGG : public A, public F {
126 };
127 class HHH : public F, public A {
128 };
129
130 #if defined(_MSC_VER)
131 #pragma warning(default: 4624) // destructor could not be generated because a base class destructor is inaccessible or deleted
132 #endif
133
134 /* A class with a protected destructor */
135 class G {
136 protected:
~G()137 ~G() { }
138
139 public:
destroy(G * g)140 static void destroy(G *g) { delete g; }
141 };
142
143 class GG : public G {
144 };
145
146 template <class T>
147 class HH_T
148 {
149
150
151 public:
152
HH_T(int i,int j)153 HH_T(int i,int j)
154 {
155 }
156
157
158 protected:
159 HH_T();
160
161 };
162
163
164 %}
165
166
167 %template(HH) HH_T<int>;
168
169
170 %{
171 class OSRSpatialReferenceShadow {
172 private:
173 OSRSpatialReferenceShadow();
174 public:
175 };
176 %}
177
178 typedef void OSRSpatialReferenceShadow;
179
180 class OSRSpatialReferenceShadow {
181 private:
182 public:
183 %extend {
184 OSRSpatialReferenceShadow( char const * wkt = "" ) {
185 return 0;
186 }
187 }
188 };
189
190 %inline %{
191 #ifdef SWIGPYTHON_BUILTIN
is_python_builtin()192 bool is_python_builtin() { return true; }
193 #else
194 bool is_python_builtin() { return false; }
195 #endif
196 %}
197
198