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 _dir_filter(self):
23         """
24         Using introspection, mimic dir() by adding up all of the __dicts__
25         for the current class and all base classes (type(self).__mro__ returns
26         all of the classes that make it up)
27         Basically filters by:
28             __x__ OK
29             __x bad
30             _classname bad
31         """
32 
33         def check(s):
34             if s.startswith('__'):
35                 if s.endswith('__'):
36                     return True
37                 else:
38                     return False
39             else:
40                 for typename in typenames:
41                     if typename in s:
42                         return False
43                 return True
44 
45         keys = sum([list(c.__dict__.keys()) for c in type(self).__mro__],[])
46         keys += list(self.__dict__.keys())
47         typenames = ["_%s" % c.__name__ for c in type(self).__mro__]
48         ret = [s for s in list(set(keys)) if check(s)]
49         ret.sort()
50         return ret
51 
52 %}
53 
54 
55 %define DIR_EXTEND(classname)
56     %extend classname {
57         %pythoncode %{
58             __dir__ = _dir_filter
59         %}
60     }
61 %enddef
62 
63 DIR_EXTEND(b2AABB);
64 DIR_EXTEND(b2AssertException);
65 DIR_EXTEND(b2Body);
66 DIR_EXTEND(b2BodyDef);
67 DIR_EXTEND(b2BroadPhase);
68 DIR_EXTEND(b2ChainShape);
69 DIR_EXTEND(b2CircleShape);
70 DIR_EXTEND(b2ClipVertex);
71 DIR_EXTEND(b2Color);
72 DIR_EXTEND(b2Contact);
73 DIR_EXTEND(b2ContactEdge);
74 DIR_EXTEND(b2ContactFeature);
75 DIR_EXTEND(b2ContactFilter);
76 DIR_EXTEND(b2ContactID);
77 DIR_EXTEND(b2ContactImpulse);
78 DIR_EXTEND(b2ContactListener);
79 DIR_EXTEND(b2ContactManager);
80 DIR_EXTEND(b2ContactPoint);
81 DIR_EXTEND(b2DestructionListener);
82 DIR_EXTEND(b2DistanceInput);
83 DIR_EXTEND(b2DistanceJoint);
84 DIR_EXTEND(b2DistanceJointDef);
85 DIR_EXTEND(b2DistanceOutput);
86 DIR_EXTEND(b2DistanceProxy);
87 DIR_EXTEND(b2Draw);
88 DIR_EXTEND(b2DrawExtended);
89 DIR_EXTEND(b2EdgeShape);
90 DIR_EXTEND(b2Filter);
91 DIR_EXTEND(b2Fixture);
92 DIR_EXTEND(b2FixtureDef);
93 DIR_EXTEND(b2FixtureProxy);
94 DIR_EXTEND(b2FrictionJoint);
95 DIR_EXTEND(b2FrictionJointDef);
96 DIR_EXTEND(b2GearJoint);
97 DIR_EXTEND(b2GearJointDef);
98 DIR_EXTEND(b2Jacobian);
99 DIR_EXTEND(b2Joint);
100 DIR_EXTEND(b2JointDef);
101 DIR_EXTEND(b2JointEdge);
102 DIR_EXTEND(b2WheelJoint);
103 DIR_EXTEND(b2WheelJointDef);
104 DIR_EXTEND(b2Manifold);
105 DIR_EXTEND(b2ManifoldPoint);
106 DIR_EXTEND(b2MassData);
107 DIR_EXTEND(b2Mat22);
108 DIR_EXTEND(b2Mat33);
109 DIR_EXTEND(b2MouseJoint);
110 DIR_EXTEND(b2MouseJointDef);
111 DIR_EXTEND(b2Pair);
112 DIR_EXTEND(b2PolygonShape);
113 DIR_EXTEND(b2PrismaticJoint);
114 DIR_EXTEND(b2PrismaticJointDef);
115 DIR_EXTEND(b2PulleyJoint);
116 DIR_EXTEND(b2PulleyJointDef);
117 DIR_EXTEND(b2QueryCallback);
118 DIR_EXTEND(b2RayCastCallback);
119 DIR_EXTEND(b2RayCastInput);
120 DIR_EXTEND(b2RayCastOutput);
121 DIR_EXTEND(b2RevoluteJoint);
122 DIR_EXTEND(b2RevoluteJointDef);
123 DIR_EXTEND(b2RopeJoint);
124 DIR_EXTEND(b2RopeJointDef);
125 DIR_EXTEND(b2Shape);
126 DIR_EXTEND(b2Sweep);
127 DIR_EXTEND(b2TOIInput);
128 DIR_EXTEND(b2TOIOutput);
129 DIR_EXTEND(b2Transform);
130 DIR_EXTEND(b2Vec2);
131 DIR_EXTEND(b2Vec3);
132 DIR_EXTEND(b2Version);
133 DIR_EXTEND(b2WeldJoint);
134 DIR_EXTEND(b2WeldJointDef);
135 DIR_EXTEND(b2World);
136 DIR_EXTEND(b2WorldManifold);
137