1 // This is a copy of the multiple_inheritance_abstract test 2 %module multiple_inheritance_nspace 3 4 %warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE, 5 SWIGWARN_D_MULTIPLE_INHERITANCE, 6 SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */ 7 8 // nspace feature only supported by these languages 9 #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT) 10 %nspace; 11 #endif 12 13 #if defined(SWIGJAVA) || defined(SWIGCSHARP) 14 %include "swiginterface.i" 15 %interface(Space::ABase1) 16 %interface(Space::CBase1) 17 %interface(Space::CBase2) 18 #endif 19 20 #if defined(SWIGD) 21 // Missing multiple inheritance support results in incorrect use of override 22 %ignore CBase1; 23 %ignore CBase2; 24 #endif 25 26 #if defined(SWIGJAVA) 27 SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) 28 #endif 29 30 %inline %{ 31 namespace Space { 32 struct CBase1 { cbase1xCBase133 virtual void cbase1x() { 34 return; 35 } cbase1yCBase136 virtual int cbase1y() { 37 return 1; 38 } cbase1zCBase139 int cbase1z() { 40 return 10; 41 } ~CBase1CBase142 virtual ~CBase1() { 43 } 44 }; 45 46 struct CBase2 { cbase2CBase247 virtual int cbase2() { 48 return 2; 49 } ~CBase2CBase250 virtual ~CBase2() { 51 } 52 }; 53 54 struct ABase1 { 55 virtual int abase1() = 0; ~ABase1ABase156 virtual ~ABase1() { 57 } 58 }; 59 60 struct Derived1 : CBase2, CBase1 { cbase1xDerived161 virtual void cbase1x() { 62 return; 63 } cbase1yDerived164 virtual int cbase1y() { 65 return 3; 66 } cbase2Derived167 virtual int cbase2() { 68 return 4; 69 } cloneitDerived170 virtual CBase2 *cloneit() { 71 return new Derived1(*this); 72 } derived1Derived173 void derived1() { 74 } 75 }; 76 77 struct Derived2 : CBase1, ABase1 { cbase1xDerived278 virtual void cbase1x() { 79 return; 80 } cbase1yDerived281 virtual int cbase1y() { 82 return 6; 83 } abase1Derived284 virtual int abase1() { 85 return 5; 86 } cloneitDerived287 virtual CBase1 *cloneit() { 88 return new Derived2(*this); 89 } derived2Derived290 void derived2() { 91 } 92 }; 93 94 struct Derived3 : ABase1, CBase1, CBase2 { cbase1yDerived395 virtual int cbase1y() { 96 return 7; 97 } cbase2Derived398 virtual int cbase2() { 99 return 8; 100 } abase1Derived3101 virtual int abase1() { 102 return 9; 103 } cbase1xDerived3104 virtual void cbase1x() { 105 } cloneitDerived3106 virtual ABase1 *cloneit() { 107 return new Derived3(*this); 108 } derived3Derived3109 void derived3() { 110 } 111 }; 112 113 struct Bottom1 : Derived1 { cbase1xBottom1114 virtual void cbase1x() { 115 return; 116 } cbase1yBottom1117 virtual int cbase1y() { 118 return 103; 119 } cbase2Bottom1120 virtual int cbase2() { 121 return 104; 122 } 123 }; 124 125 struct Bottom2 : Derived2 { cbase1yBottom2126 virtual int cbase1y() { 127 return 206; 128 } abase1Bottom2129 virtual int abase1() { 130 return 205; 131 } 132 }; 133 134 struct Bottom3 : Derived3 { cbase1yBottom3135 virtual int cbase1y() { 136 return 307; 137 } cbase2Bottom3138 virtual int cbase2() { 139 return 308; 140 } abase1Bottom3141 virtual int abase1() { 142 return 309; 143 } 144 }; 145 146 // Base classes as input InputValCBase1(CBase1 cb1)147 int InputValCBase1(CBase1 cb1) { 148 return cb1.cbase1y(); 149 } InputValCBase2(CBase2 cb2)150 int InputValCBase2(CBase2 cb2) { 151 return cb2.cbase2(); 152 } 153 InputPtrABase1(ABase1 * pab1)154 int InputPtrABase1(ABase1 *pab1) { 155 return pab1->abase1(); 156 } InputPtrCBase1(CBase1 * pcb1)157 int InputPtrCBase1(CBase1 *pcb1) { 158 return pcb1->cbase1y(); 159 } InputPtrCBase2(CBase2 * pcb2)160 int InputPtrCBase2(CBase2 *pcb2) { 161 return pcb2->cbase2(); 162 } 163 InputRefABase1(ABase1 & rab1)164 int InputRefABase1(ABase1 &rab1) { 165 return rab1.abase1(); 166 } InputRefCBase1(CBase1 & rcb1)167 int InputRefCBase1(CBase1 &rcb1) { 168 return rcb1.cbase1y(); 169 } InputRefCBase2(CBase2 & rcb2)170 int InputRefCBase2(CBase2 &rcb2) { 171 return rcb2.cbase2(); 172 } 173 InputCPtrRefABase1(ABase1 * const & pab1)174 int InputCPtrRefABase1(ABase1 *const& pab1) { 175 return pab1->abase1(); 176 } InputCPtrRefCBase1(CBase1 * const & pcb1)177 int InputCPtrRefCBase1(CBase1 *const& pcb1) { 178 return pcb1->cbase1y(); 179 } InputCPtrRefCBase2(CBase2 * const & pcb2)180 int InputCPtrRefCBase2(CBase2 *const& pcb2) { 181 return pcb2->cbase2(); 182 } 183 184 // Derived classes as input InputValDerived1(Derived1 d)185 int InputValDerived1(Derived1 d) { 186 return d.cbase1y() + d.cbase2(); 187 } InputValDerived2(Derived2 d)188 int InputValDerived2(Derived2 d) { 189 return d.cbase1y() + d.abase1(); 190 } InputValDerived3(Derived3 d)191 int InputValDerived3(Derived3 d) { 192 return d.cbase1y() + d.cbase2() + d.abase1(); 193 } 194 InputRefDerived1(Derived1 & d)195 int InputRefDerived1(Derived1 &d) { 196 return d.cbase1y() + d.cbase2(); 197 } InputRefDerived2(Derived2 & d)198 int InputRefDerived2(Derived2 &d) { 199 return d.cbase1y() + d.abase1(); 200 } InputRefDerived3(Derived3 & d)201 int InputRefDerived3(Derived3 &d) { 202 return d.cbase1y() + d.cbase2() + d.abase1(); 203 } 204 InputPtrDerived1(Derived1 * d)205 int InputPtrDerived1(Derived1 *d) { 206 return d->cbase1y() + d->cbase2(); 207 } InputPtrDerived2(Derived2 * d)208 int InputPtrDerived2(Derived2 *d) { 209 return d->cbase1y() + d->abase1(); 210 } InputPtrDerived3(Derived3 * d)211 int InputPtrDerived3(Derived3 *d) { 212 return d->cbase1y() + d->cbase2() + d->abase1(); 213 } 214 InputCPtrRefDerived1(Derived1 * const & d)215 int InputCPtrRefDerived1(Derived1 *const& d) { 216 return d->cbase1y() + d->cbase2(); 217 } InputCPtrRefDerived2(Derived2 * const & d)218 int InputCPtrRefDerived2(Derived2 *const& d) { 219 return d->cbase1y() + d->abase1(); 220 } InputCPtrRefDerived3(Derived3 * const & d)221 int InputCPtrRefDerived3(Derived3 *const& d) { 222 return d->cbase1y() + d->cbase2() + d->abase1(); 223 } 224 225 // Bottom classes as input InputValBottom1(Bottom1 d)226 int InputValBottom1(Bottom1 d) { 227 return d.cbase1y() + d.cbase2(); 228 } InputValBottom2(Bottom2 d)229 int InputValBottom2(Bottom2 d) { 230 return d.cbase1y() + d.abase1(); 231 } InputValBottom3(Bottom3 d)232 int InputValBottom3(Bottom3 d) { 233 return d.cbase1y() + d.cbase2() + d.abase1(); 234 } 235 InputRefBottom1(Bottom1 & d)236 int InputRefBottom1(Bottom1 &d) { 237 return d.cbase1y() + d.cbase2(); 238 } InputRefBottom2(Bottom2 & d)239 int InputRefBottom2(Bottom2 &d) { 240 return d.cbase1y() + d.abase1(); 241 } InputRefBottom3(Bottom3 & d)242 int InputRefBottom3(Bottom3 &d) { 243 return d.cbase1y() + d.cbase2() + d.abase1(); 244 } 245 InputPtrBottom1(Bottom1 * d)246 int InputPtrBottom1(Bottom1 *d) { 247 return d->cbase1y() + d->cbase2(); 248 } InputPtrBottom2(Bottom2 * d)249 int InputPtrBottom2(Bottom2 *d) { 250 return d->cbase1y() + d->abase1(); 251 } InputPtrBottom3(Bottom3 * d)252 int InputPtrBottom3(Bottom3 *d) { 253 return d->cbase1y() + d->cbase2() + d->abase1(); 254 } 255 InputCPtrRefBottom1(Bottom1 * const & d)256 int InputCPtrRefBottom1(Bottom1 *const& d) { 257 return d->cbase1y() + d->cbase2(); 258 } InputCPtrRefBottom2(Bottom2 * const & d)259 int InputCPtrRefBottom2(Bottom2 *const& d) { 260 return d->cbase1y() + d->abase1(); 261 } InputCPtrRefBottom3(Bottom3 * const & d)262 int InputCPtrRefBottom3(Bottom3 *const& d) { 263 return d->cbase1y() + d->cbase2() + d->abase1(); 264 } 265 266 // Return pointers MakePtrDerived1_CBase1()267 CBase1 *MakePtrDerived1_CBase1() { 268 return new Derived1(); 269 } MakePtrDerived1_CBase2()270 CBase2 *MakePtrDerived1_CBase2() { 271 return new Derived1(); 272 } MakePtrDerived2_CBase1()273 CBase1 *MakePtrDerived2_CBase1() { 274 return new Derived2(); 275 } MakePtrDerived2_ABase1()276 ABase1 *MakePtrDerived2_ABase1() { 277 return new Derived2(); 278 } MakePtrDerived3_ABase1()279 ABase1 *MakePtrDerived3_ABase1() { 280 return new Derived3(); 281 } MakePtrDerived3_CBase1()282 CBase1 *MakePtrDerived3_CBase1() { 283 return new Derived3(); 284 } MakePtrDerived3_CBase2()285 CBase2 *MakePtrDerived3_CBase2() { 286 return new Derived3(); 287 } 288 289 // Return references MakeRefDerived1_CBase1()290 CBase1 &MakeRefDerived1_CBase1() { 291 static Derived1 d; 292 return d; 293 } MakeRefDerived1_CBase2()294 CBase2 &MakeRefDerived1_CBase2() { 295 static Derived1 d; 296 return d; 297 } MakeRefDerived2_CBase1()298 CBase1 &MakeRefDerived2_CBase1() { 299 static Derived2 d; 300 return d; 301 } MakeRefDerived2_ABase1()302 ABase1 &MakeRefDerived2_ABase1() { 303 static Derived2 d; 304 return d; 305 } MakeRefDerived3_ABase1()306 ABase1 &MakeRefDerived3_ABase1() { 307 static Derived3 d; 308 return d; 309 } MakeRefDerived3_CBase1()310 CBase1 &MakeRefDerived3_CBase1() { 311 static Derived3 d; 312 return d; 313 } MakeRefDerived3_CBase2()314 CBase2 &MakeRefDerived3_CBase2() { 315 static Derived3 d; 316 return d; 317 } 318 319 // Return by value (sliced objects) MakeValDerived1_CBase1()320 CBase1 MakeValDerived1_CBase1() { 321 return Derived1(); 322 } MakeValDerived1_CBase2()323 CBase2 MakeValDerived1_CBase2() { 324 return Derived1(); 325 } MakeValDerived2_CBase1()326 CBase1 MakeValDerived2_CBase1() { 327 return Derived2(); 328 } MakeValDerived3_CBase1()329 CBase1 MakeValDerived3_CBase1() { 330 return Derived3(); 331 } MakeValDerived3_CBase2()332 CBase2 MakeValDerived3_CBase2() { 333 return Derived3(); 334 } 335 } 336 337 %} 338 339