Debian Codegraph @

doc-src/doxygen_generator.rb

raw symbols SCIP
1 OUTPUT_NAME = "generated_docs"
2 exit if File.exists?(OUTPUT_NAME)
3
4 DOC_FILE = open(OUTPUT_NAME, "w")
5
6 FUNCS = {}
7 IO.readlines("|ruby extract_protos.rb").each{|line|
8 func = eval(line)
9 FUNCS[func[:name]] = func
10 }
11
12 SKIP = Object.new
13
14 GETTER_DOCS = {
15 "cpArbiterGetBodies" => SKIP,
16 "cpArbiterGetContactPointSet" => SKIP,
17 "cpArbiterGetCount" => SKIP,
18 "cpArbiterGetDepth" => SKIP,
19 "cpArbiterGetElasticity" => "Get the elasticity for this cpArbiter",
20 "cpArbiterGetFriction" => "Get the friction for this cpArbiter",
21 "cpArbiterGetNormal" => SKIP,
22 "cpArbiterGetPoint" => SKIP,
23 "cpArbiterGetShapes" => SKIP,
24 "cpArbiterGetSurfaceVelocity" => "Get the surface velocity used by the contact calculation for this cpArbiter",
25
26 "cpBodyGetAngVel" => "Get the angular velocity of this cpBody",
27 "cpBodyGetAngVelLimit" => "Get the angular velocity limit of this cpBody",
28 "cpBodyGetAngle" => "Get the angle of this cpBody",
29 "cpBodyGetForce" => "Get the force applied to this cpBody",
30 "cpBodyGetMass" => "Get the mass of this cpBody",
31 "cpBodyGetMoment" => "Get the moment of inertia of this cpBody",
32 "cpBodyGetPos" => "Get the position of this cpBody",
33 "cpBodyGetRot" => "Get the rotation vector of this cpBody",
34 "cpBodyGetTorque" => "Get the torque applied to this cpBody",
35 "cpBodyGetUserData" => "Get the userdata pointer for this cpBody",
36 "cpBodyGetVel" => "Get the velocity of this cpBody",
37 "cpBodyGetVelLimit" => "Get the velocity limit of this cpBody",
38
39 "cpCircleShapeGetOffset" => "Get the offset of this cpCircleShape",
40 "cpCircleShapeGetRadius" => "Get the radius of this cpCircleShape",
41
42 "cpConstraintGetA" => "Get the first of the two bodies this cpConstraint is connected to.",
43 "cpConstraintGetB" => "Get the second of the two bodies this cpConstraint is connected to.",
44 "cpConstraintGetErrorBias" => "Get the percentage of constraint error that remains unfixed after each second.",
45 "cpConstraintGetImpulse" => SKIP,
46 "cpConstraintGetMaxBias" => "Get the maximum rate this cpConstraint can apply to correct itself at.",
47 "cpConstraintGetMaxForce" => "Get the maximum force this cpConstraint can apply to correct itself.",
48 "cpConstraintGetPostSolveFunc" => "Get the function callback that is called each step after the solver runs.",
49 "cpConstraintGetPreSolveFunc" => "Get the function callback that is called each step before the solver runs.",
50 "cpConstraintGetUserData" => "Get the user data pointer for this cpConstraint.",
51
52 "cpDampedRotarySpringGetDamping" => "Get the damping of this cpDampedRotarySpring.",
53 "cpDampedRotarySpringGetRestAngle" => "Get the restangle of this cpDampedRotarySpring.",
54 "cpDampedRotarySpringGetSpringTorqueFunc" => "Get the springtorquefunc of this cpDampedRotarySpring.",
55 "cpDampedRotarySpringGetStiffness" => "Get the stiffness of this cpDampedRotarySpring.",
56
57 "cpDampedSpringGetAnchr1" => "Get the anchr1 of this cpDampedSpring.",
58 "cpDampedSpringGetAnchr2" => "Get the anchr2 of this cpDampedSpring.",
59 "cpDampedSpringGetDamping" => "Get the damping of this cpDampedSpring.",
60 "cpDampedSpringGetRestLength" => "Get the rest length of this cpDampedSpring.",
61 "cpDampedSpringGetSpringForceFunc" => "Get the spring force callback function of this cpDampedSpring.",
62 "cpDampedSpringGetStiffness" => "Get the stiffness of this cpDampedSpring.",
63
64 "cpGearJointGetPhase" => "Get the phase of this cpGearJoint.",
65 "cpGearJointGetRatio" => "Get the ratio of this cpGearJoint.",
66
67 "cpGrooveJointGetAnchr2" => "Get the anchr2 of this cpGrooveJoint.",
68 "cpGrooveJointGetGrooveA" => "Get the groovea of this cpGrooveJoint.",
69 "cpGrooveJointGetGrooveB" => "Get the grooveb of this cpGrooveJoint.",
70
71 "cpPinJointGetAnchr1" => "Get the anchr1 of this cpPinJoint.",
72 "cpPinJointGetAnchr2" => "Get the anchr2 of this cpPinJoint.",
73 "cpPinJointGetDist" => "Get the dist between the anchor points of this cpPinJoint.",
74
75 "cpPivotJointGetAnchr1" => "Get the anchr1 of this cpPivotJoint.",
76 "cpPivotJointGetAnchr2" => "Get the anchr2 of this cpPivotJoint.",
77
78 "cpPolyShapeGetNumVerts" => SKIP,
79 "cpPolyShapeGetVert" => SKIP,
80
81 "cpRatchetJointGetAngle" => "Get the angle of this cpRatchetJoint.",
82 "cpRatchetJointGetPhase" => "Get the phase of this cpRatchetJoint.",
83 "cpRatchetJointGetRatchet" => "Get the ratchet angular distance of this cpRatchetJoint.",
84
85 "cpRotaryLimitJointGetMax" => "Get the max delta angle of this cpRotaryLimitJoint.",
86 "cpRotaryLimitJointGetMin" => "Get the min delta angle of this cpRotaryLimitJoint.",
87
88 "cpSegmentShapeGetA" => "Get the first endpoint of this cpSegmentShape.",
89 "cpSegmentShapeGetB" => "Get the second endpoint of this cpSegmentShape.",
90 "cpSegmentShapeGetNormal" => "Get the normal of this cpSegmentShape.",
91 "cpSegmentShapeGetRadius" => "Get the radius of this cpSegmentShape.",
92
93 "cpShapeGetBB" => "Get the bounding box of this cpShape.",
94 "cpShapeGetBody" => "Get the body this cpShape is attached to.",
95 "cpShapeGetCollisionType" => "Get the collision type of this cpShape.",
96 "cpShapeGetElasticity" => "Get the elasticity of this cpShape.",
97 "cpShapeGetFriction" => "Get the friction of this cpShape.",
98 "cpShapeGetGroup" => "Get the group of this cpShape.",
99 "cpShapeGetLayers" => "Get the layer bitmask of this cpShape.",
100 "cpShapeGetSensor" => "Get the sensor flag of this cpShape.",
101 "cpShapeGetSurfaceVelocity" => "Get the surface velocity of this cpShape.",
102 "cpShapeGetUserData" => "Get the user data pointer of this cpShape.",
103
104 "cpSimpleMotorGetRate" => "Get the rate of this cpSimpleMotor.",
105
106 "cpSlideJointGetAnchr1" => "Get the anchr1 of this cpSlideJoint.",
107 "cpSlideJointGetAnchr2" => "Get the anchr2 of this cpSlideJoint.",
108 "cpSlideJointGetMax" => "Get the max distance between the anchors of this cpSlideJoint.",
109 "cpSlideJointGetMin" => "Get the min distance between the anchors of this cpSlideJoint.",
110
111 "cpSpaceGetCollisionBias" => "Get the collision bias of this cpSpace.",
112 "cpSpaceGetCollisionPersistence" => "Get the collision persistence of this cpSpace.",
113 "cpSpaceGetCollisionSlop" => "Get the collision slop of this cpSpace.",
114 "cpSpaceGetCurrentTimeStep" => "Get the most recent timestep used with this cpSpace.",
115 "cpSpaceGetDamping" => "Get the damping of this cpSpace.",
116 "cpSpaceGetEnableContactGraph" => "Get the enable contact graph flag of this cpSpace.",
117 "cpSpaceGetGravity" => "Get the gravity of this cpSpace.",
118 "cpSpaceGetIdleSpeedThreshold" => "Get the idle speed threshold of this cpSpace.",
119 "cpSpaceGetIterations" => "Get the number of solver iterations of this cpSpace.",
120 "cpSpaceGetSleepTimeThreshold" => "Get the sleep time threshold of this cpSpace.",
121 "cpSpaceGetStaticBody" => "Get the static body of this cpSpace.",
122 "cpSpaceGetUserData" => "Get the user data pointer of this cpSpace.",
123 }
124
125 def output_getter(func)
126 name = func[:name]
127
128 doc = GETTER_DOCS[name]
129 return if doc == SKIP
130
131 struct, property = */(cp\w*)Get(.+)/.match(name).captures
132
133 if doc
134 prototype = "#{func[:inline] ? "static inline " : ""}#{func[:return]} #{name}(#{func[:args]})"
135
136 DOC_FILE.puts <<-EOF
137 /// @addtogroup #{struct}
138 /// @{
139 /// @fn #{prototype};
140 /// @brief #{doc}
141 #{prototype};
142 /// @}
143
144 EOF
145 else
146 puts %{\t"#{name}" => "Get the #{property.downcase} of this #{struct}.",}
147 end
148 end
149
150
151 def output_setter(func)
152 name = func[:name]
153
154 doc = GETTER_DOCS[name.gsub("Set", "Get")]
155 return if doc == SKIP
156
157 struct, property = */(cp\w*)Set(.+)/.match(name).captures
158
159 if doc
160 prototype = "static inline void #{name}(#{func[:args]})"
161
162 DOC_FILE.puts <<-EOF
163 /// @addtogroup #{struct}
164 /// @{
165 /// @fn #{prototype};
166 /// @brief #{doc.gsub("Get", "Set")}
167 #{prototype};
168 /// @}"
169
170 EOF
171 else
172 puts %{\t"#{name}" => "Set the #{property.downcase} of this #{struct}.",}
173 end
174 end
175
176
177 getters = FUNCS.keys.find_all{|name| /(cp\w*)Get(.+)/.match(name)}.sort
178 FUNCS.values_at(*getters).each{|func| output_getter(func)}
179
180 setters = FUNCS.keys.find_all{|name| /(cp\w*)Set(.+)/.match(name)}.sort
181 FUNCS.values_at(*setters).each{|func| output_setter(func)}