1 /* 2 * pybox2d -- http://pybox2d.googlecode.com 3 * 4 * Copyright (c) 2010 Ken Lauer / sirkne at gmail dot com 5 * 6 * This software is provided 'as-is', without any express or implied 7 * warranty. In no event will the authors be held liable for any damages 8 * arising from the use of this software. 9 * Permission is granted to anyone to use this software for any purpose, 10 * including commercial applications, and to alter it and redistribute it 11 * freely, subject to the following restrictions: 12 * 1. The origin of this software must not be misrepresented; you must not 13 * claim that you wrote the original software. If you use this software 14 * in a product, an acknowledgment in the product documentation would be 15 * appreciated but is not required. 16 * 2. Altered source versions must be plainly marked as such, and must not be 17 * misrepresented as being the original software. 18 * 3. This notice may not be removed or altered from any source distribution. 19 */ 20 21 %pythoncode %{ 22 def _init_kwargs(self, **kwargs): 23 cls = self.__class__ 24 for key, value in kwargs.items(): 25 try: 26 getattr(cls, key) 27 except AttributeError: 28 raise AttributeError('Invalid keyword argument "%s" for %s' % (key, cls)) 29 30 try: 31 setattr(self, key, value) 32 except Exception as ex: 33 raise ex.__class__('Failed on kwargs for %s.%s: %s' \ 34 % (self.__class__.__name__, key, ex)) 35 36 def _init_jointdef_kwargs(self, bodyA=None, bodyB=None, **kwargs): 37 if bodyA is not None or bodyB is not None: 38 # Make sure that bodyA and bodyB are defined before the rest 39 _init_kwargs(self, bodyA=bodyA, bodyB=bodyB) 40 41 _init_kwargs(self, **kwargs) 42 %} 43 44 45 // Generic kwarg initialization: 46 47 %feature("shadow") b2ContactFilter::b2ContactFilter() { 48 def __init__(self, **kwargs): 49 if self.__class__ == b2ContactFilter: 50 _self = None 51 else: 52 _self = self 53 _Box2D.b2ContactFilter_swiginit(self,_Box2D.new_b2ContactFilter(_self, )) 54 _init_kwargs(self, **kwargs) 55 } 56 57 58 %feature("shadow") b2ContactListener::b2ContactListener() { 59 def __init__(self, **kwargs): 60 if self.__class__ == b2ContactListener: 61 _self = None 62 else: 63 _self = self 64 _Box2D.b2ContactListener_swiginit(self,_Box2D.new_b2ContactListener(_self, )) 65 _init_kwargs(self, **kwargs) 66 } 67 68 69 %feature("shadow") b2QueryCallback::b2QueryCallback() { 70 def __init__(self, **kwargs): 71 if self.__class__ == b2QueryCallback: 72 _self = None 73 else: 74 _self = self 75 _Box2D.b2QueryCallback_swiginit(self,_Box2D.new_b2QueryCallback(_self, )) 76 _init_kwargs(self, **kwargs) 77 } 78 79 80 %feature("shadow") b2Draw::b2Draw() { 81 def __init__(self, **kwargs): 82 if self.__class__ == b2Draw: 83 _self = None 84 else: 85 _self = self 86 _Box2D.b2Draw_swiginit(self,_Box2D.new_b2Draw(_self, )) 87 _init_kwargs(self, **kwargs) 88 } 89 90 %feature("shadow") b2DrawExtended::b2DrawExtended() { 91 def __init__(self, **kwargs): 92 if self.__class__ == b2DrawExtended: 93 _self = None 94 else: 95 _self = self 96 _Box2D.b2DrawExtended_swiginit(self,_Box2D.new_b2DrawExtended(_self, )) 97 _init_kwargs(self, **kwargs) 98 } 99 100 101 %feature("shadow") b2DestructionListener::b2DestructionListener() { 102 def __init__(self, **kwargs): 103 if self.__class__ == b2DestructionListener: 104 _self = None 105 else: 106 _self = self 107 _Box2D.b2DestructionListener_swiginit(self,_Box2D.new_b2DestructionListener(_self, )) 108 _init_kwargs(self, **kwargs) 109 } 110 111 112 %feature("shadow") b2AABB::b2AABB() { 113 def __init__(self, **kwargs): 114 _Box2D.b2AABB_swiginit(self,_Box2D.new_b2AABB()) 115 _init_kwargs(self, **kwargs) 116 } 117 118 119 %feature("shadow") b2Body::b2Body() { 120 def __init__(self, **kwargs): 121 _Box2D.b2Body_swiginit(self,_Box2D.new_b2Body()) 122 _init_kwargs(self, **kwargs) 123 } 124 125 126 %feature("shadow") b2BodyDef::b2BodyDef() { 127 def __init__(self, **kwargs): 128 _Box2D.b2BodyDef_swiginit(self,_Box2D.new_b2BodyDef()) 129 _init_kwargs(self, **kwargs) 130 } 131 132 133 %feature("shadow") b2CircleShape::b2CircleShape() { 134 def __init__(self, **kwargs): 135 _Box2D.b2CircleShape_swiginit(self,_Box2D.new_b2CircleShape()) 136 _init_kwargs(self, **kwargs) 137 } 138 139 140 %feature("shadow") b2ClipVertex::b2ClipVertex() { 141 def __init__(self, **kwargs): 142 _Box2D.b2ClipVertex_swiginit(self,_Box2D.new_b2ClipVertex()) 143 _init_kwargs(self, **kwargs) 144 } 145 146 147 %feature("shadow") b2Color::b2Color() { 148 def __init__(self, **kwargs): 149 _Box2D.b2Color_swiginit(self,_Box2D.new_b2Color()) 150 _init_kwargs(self, **kwargs) 151 } 152 153 154 %feature("shadow") b2ContactPoint::b2ContactPoint() { 155 def __init__(self, **kwargs): 156 _Box2D.b2ContactPoint_swiginit(self,_Box2D.new_b2ContactPoint()) 157 _init_kwargs(self, **kwargs) 158 } 159 160 161 %feature("shadow") b2ContactEdge::b2ContactEdge() { 162 def __init__(self, **kwargs): 163 _Box2D.b2ContactEdge_swiginit(self,_Box2D.new_b2ContactEdge()) 164 _init_kwargs(self, **kwargs) 165 } 166 167 168 %feature("shadow") b2ContactID::b2ContactID() { 169 def __init__(self, **kwargs): 170 _Box2D.b2ContactID_swiginit(self,_Box2D.new_b2ContactID()) 171 _init_kwargs(self, **kwargs) 172 } 173 174 175 %feature("shadow") b2ContactImpulse::b2ContactImpulse() { 176 def __init__(self, **kwargs): 177 _Box2D.b2ContactImpulse_swiginit(self,_Box2D.new_b2ContactImpulse()) 178 _init_kwargs(self, **kwargs) 179 } 180 181 182 183 %feature("shadow") b2DistanceInput::b2DistanceInput() { 184 def __init__(self, **kwargs): 185 _Box2D.b2DistanceInput_swiginit(self,_Box2D.new_b2DistanceInput()) 186 _init_kwargs(self, **kwargs) 187 } 188 189 190 %feature("shadow") b2DistanceJoint::b2DistanceJoint() { 191 def __init__(self, **kwargs): 192 _Box2D.b2DistanceJoint_swiginit(self,_Box2D.new_b2DistanceJoint()) 193 _init_kwargs(self, **kwargs) 194 } 195 196 197 %feature("shadow") b2DistanceOutput::b2DistanceOutput() { 198 def __init__(self, **kwargs): 199 _Box2D.b2DistanceOutput_swiginit(self,_Box2D.new_b2DistanceOutput()) 200 _init_kwargs(self, **kwargs) 201 } 202 203 %feature("shadow") b2EdgeShape::b2EdgeShape() { 204 def __init__(self, **kwargs): 205 _Box2D.b2EdgeShape_swiginit(self,_Box2D.new_b2EdgeShape()) 206 _init_kwargs(self, **kwargs) 207 } 208 209 %feature("shadow") b2Filter::b2Filter() { 210 def __init__(self, **kwargs): 211 _Box2D.b2Filter_swiginit(self,_Box2D.new_b2Filter()) 212 _init_kwargs(self, **kwargs) 213 } 214 215 216 %feature("shadow") b2Fixture::b2Fixture() { 217 def __init__(self, **kwargs): 218 _Box2D.b2Fixture_swiginit(self,_Box2D.new_b2Fixture()) 219 _init_kwargs(self, **kwargs) 220 } 221 222 %feature("shadow") b2FixtureDef::b2FixtureDef() { 223 def __init__(self, **kwargs): 224 _Box2D.b2FixtureDef_swiginit(self,_Box2D.new_b2FixtureDef()) 225 _init_kwargs(self, **kwargs) 226 } 227 228 229 %feature("shadow") b2FrictionJoint::b2FrictionJoint() { 230 def __init__(self, **kwargs): 231 _Box2D.b2FrictionJoint_swiginit(self,_Box2D.new_b2FrictionJoint()) 232 _init_kwargs(self, **kwargs) 233 } 234 235 236 237 %feature("shadow") b2GearJoint::b2GearJoint() { 238 def __init__(self, **kwargs): 239 _Box2D.b2GearJoint_swiginit(self,_Box2D.new_b2GearJoint()) 240 _init_kwargs(self, **kwargs) 241 } 242 243 244 %feature("shadow") b2GearJointDef::b2GearJointDef() { 245 def __init__(self, **kwargs): 246 _Box2D.b2GearJointDef_swiginit(self,_Box2D.new_b2GearJointDef()) 247 _init_kwargs(self, **kwargs) 248 } 249 250 %feature("shadow") b2RopeJoint::b2RopeJoint() { 251 def __init__(self, **kwargs): 252 _Box2D.b2RopeJoint_swiginit(self,_Box2D.new_b2RopeJoint()) 253 _init_kwargs(self, **kwargs) 254 } 255 256 %feature("shadow") b2RopeJointDef::b2RopeJointDef() { 257 def __init__(self, **kwargs): 258 _Box2D.b2RopeJointDef_swiginit(self,_Box2D.new_b2RopeJointDef()) 259 _init_kwargs(self, **kwargs) 260 } 261 262 263 %feature("shadow") b2Jacobian::b2Jacobian() { 264 def __init__(self, **kwargs): 265 _Box2D.b2Jacobian_swiginit(self,_Box2D.new_b2Jacobian()) 266 _init_kwargs(self, **kwargs) 267 } 268 269 270 %feature("shadow") b2JointDef::b2JointDef() { 271 def __init__(self, **kwargs): 272 _Box2D.b2JointDef_swiginit(self,_Box2D.new_b2JointDef()) 273 _init_kwargs(self, **kwargs) 274 } 275 276 277 %feature("shadow") b2JointEdge::b2JointEdge() { 278 def __init__(self, **kwargs): 279 _Box2D.b2JointEdge_swiginit(self,_Box2D.new_b2JointEdge()) 280 _init_kwargs(self, **kwargs) 281 } 282 283 284 %feature("shadow") b2WheelJoint::b2WheelJoint() { 285 def __init__(self, **kwargs): 286 _Box2D.b2WheelJoint_swiginit(self,_Box2D.new_b2WheelJoint()) 287 _init_kwargs(self, **kwargs) 288 } 289 290 %feature("shadow") b2MotorJoint::b2MotorJoint() { 291 def __init__(self, **kwargs): 292 _Box2D.b2MotorJoint_swiginit(self,_Box2D.new_b2MotorJoint()) 293 _init_kwargs(self, **kwargs) 294 } 295 296 297 %feature("shadow") b2ChainShape::b2ChainShape() { 298 def __init__(self, **kwargs): 299 _Box2D.b2ChainShape_swiginit(self,_Box2D.new_b2ChainShape()) 300 _init_kwargs(self, **kwargs) 301 } 302 303 %feature("shadow") b2Manifold::b2Manifold() { 304 def __init__(self, **kwargs): 305 _Box2D.b2Manifold_swiginit(self,_Box2D.new_b2Manifold()) 306 _init_kwargs(self, **kwargs) 307 } 308 309 310 %feature("shadow") b2ManifoldPoint::b2ManifoldPoint() { 311 def __init__(self, **kwargs): 312 _Box2D.b2ManifoldPoint_swiginit(self,_Box2D.new_b2ManifoldPoint()) 313 _init_kwargs(self, **kwargs) 314 } 315 316 317 %feature("shadow") b2MassData::b2MassData() { 318 def __init__(self, **kwargs): 319 _Box2D.b2MassData_swiginit(self,_Box2D.new_b2MassData()) 320 _init_kwargs(self, **kwargs) 321 } 322 323 324 %feature("shadow") b2MouseJoint::b2MouseJoint() { 325 def __init__(self, **kwargs): 326 _Box2D.b2MouseJoint_swiginit(self,_Box2D.new_b2MouseJoint()) 327 _init_kwargs(self, **kwargs) 328 } 329 330 331 %feature("shadow") b2MouseJointDef::b2MouseJointDef() { 332 def __init__(self, **kwargs): 333 _Box2D.b2MouseJointDef_swiginit(self,_Box2D.new_b2MouseJointDef()) 334 _init_kwargs(self, **kwargs) 335 } 336 337 338 %feature("shadow") b2Pair::b2Pair() { 339 def __init__(self, **kwargs): 340 _Box2D.b2Pair_swiginit(self,_Box2D.new_b2Pair()) 341 _init_kwargs(self, **kwargs) 342 } 343 344 345 %feature("shadow") b2PolygonShape::b2PolygonShape() { 346 def __init__(self, **kwargs): 347 _Box2D.b2PolygonShape_swiginit(self,_Box2D.new_b2PolygonShape()) 348 _init_kwargs(self, **kwargs) 349 } 350 351 352 %feature("shadow") b2PrismaticJoint::b2PrismaticJoint() { 353 def __init__(self, **kwargs): 354 _Box2D.b2PrismaticJoint_swiginit(self,_Box2D.new_b2PrismaticJoint()) 355 _init_kwargs(self, **kwargs) 356 } 357 358 %feature("shadow") b2PulleyJoint::b2PulleyJoint() { 359 def __init__(self, **kwargs): 360 _Box2D.b2PulleyJoint_swiginit(self,_Box2D.new_b2PulleyJoint()) 361 _init_kwargs(self, **kwargs) 362 } 363 364 365 %feature("shadow") b2RayCastInput::b2RayCastInput() { 366 def __init__(self, **kwargs): 367 _Box2D.b2RayCastInput_swiginit(self,_Box2D.new_b2RayCastInput()) 368 _init_kwargs(self, **kwargs) 369 } 370 371 372 %feature("shadow") b2RayCastOutput::b2RayCastOutput() { 373 def __init__(self, **kwargs): 374 _Box2D.b2RayCastOutput_swiginit(self,_Box2D.new_b2RayCastOutput()) 375 _init_kwargs(self, **kwargs) 376 } 377 378 379 %feature("shadow") b2RevoluteJoint::b2RevoluteJoint() { 380 def __init__(self, **kwargs): 381 _Box2D.b2RevoluteJoint_swiginit(self,_Box2D.new_b2RevoluteJoint()) 382 _init_kwargs(self, **kwargs) 383 } 384 385 386 %feature("shadow") b2Segment::b2Segment() { 387 def __init__(self, **kwargs): 388 _Box2D.b2Segment_swiginit(self,_Box2D.new_b2Segment()) 389 _init_kwargs(self, **kwargs) 390 } 391 392 393 %feature("shadow") b2Sweep::b2Sweep() { 394 def __init__(self, **kwargs): 395 _Box2D.b2Sweep_swiginit(self,_Box2D.new_b2Sweep()) 396 _init_kwargs(self, **kwargs) 397 } 398 399 400 %feature("shadow") b2TOIInput::b2TOIInput() { 401 def __init__(self, **kwargs): 402 _Box2D.b2TOIInput_swiginit(self,_Box2D.new_b2TOIInput()) 403 _init_kwargs(self, **kwargs) 404 } 405 406 407 %feature("shadow") b2Transform::b2Transform() { 408 def __init__(self, **kwargs): 409 _Box2D.b2Transform_swiginit(self,_Box2D.new_b2Transform()) 410 _init_kwargs(self, **kwargs) 411 } 412 413 414 %feature("shadow") b2Version::b2Version() { 415 def __init__(self, **kwargs): 416 _Box2D.b2Version_swiginit(self,_Box2D.new_b2Version()) 417 _init_kwargs(self, **kwargs) 418 } 419 420 421 %feature("shadow") b2WeldJoint::b2WeldJoint() { 422 def __init__(self, **kwargs): 423 _Box2D.b2WeldJoint_swiginit(self,_Box2D.new_b2WeldJoint()) 424 _init_kwargs(self, **kwargs) 425 } 426 427 428 %feature("shadow") b2WorldManifold::b2WorldManifold() { 429 def __init__(self, **kwargs): 430 _Box2D.b2WorldManifold_swiginit(self,_Box2D.new_b2WorldManifold()) 431 _init_kwargs(self, **kwargs) 432 } 433 434 %feature("shadow") b2Rot::b2Rot() { 435 def __init__(self, **kwargs): 436 _Box2D.b2Rot_swiginit(self,_Box2D.new_b2Rot()) 437 _init_kwargs(self, **kwargs) 438 } 439