From f27c5e1f0cd2042142392cc39ed65fd42959538f Mon Sep 17 00:00:00 2001 From: slembcke Date: Sat, 19 Nov 2011 01:03:19 -0600 Subject: [PATCH] minor modifications to the headers to make them easier to parse and doxygen crap --- doxygen_generator.rb | 273 +++++++++++------- extract_protos.rb | 37 ++- include/chipmunk/chipmunk.h | 15 +- include/chipmunk/chipmunk_types.h | 2 +- include/chipmunk/constraints/cpConstraint.h | 12 +- .../constraints/cpDampedRotarySpring.h | 7 +- include/chipmunk/constraints/cpDampedSpring.h | 6 +- include/chipmunk/constraints/cpGearJoint.h | 6 +- include/chipmunk/constraints/cpGrooveJoint.h | 6 +- include/chipmunk/constraints/cpPinJoint.h | 6 +- include/chipmunk/constraints/cpPivotJoint.h | 8 +- include/chipmunk/constraints/cpRatchetJoint.h | 6 +- .../chipmunk/constraints/cpRotaryLimitJoint.h | 6 +- include/chipmunk/constraints/cpSimpleMotor.h | 6 +- include/chipmunk/constraints/cpSlideJoint.h | 6 +- include/chipmunk/cpBody.h | 10 +- include/chipmunk/cpPolyShape.h | 14 +- include/chipmunk/cpShape.h | 8 +- include/chipmunk/cpSpace.h | 12 +- include/chipmunk/cpSpatialIndex.h | 18 +- include/chipmunk/cpVect.h | 2 +- 21 files changed, 262 insertions(+), 204 deletions(-) diff --git a/doxygen_generator.rb b/doxygen_generator.rb index 5066074e..4b91ef74 100644 --- a/doxygen_generator.rb +++ b/doxygen_generator.rb @@ -1,125 +1,178 @@ DOC_FILE = open("generated_docs", "w") -def output(str='') - DOC_FILE.puts str -end - -def find_declarations(name) - IO.readlines("|find include -name \"*.h\" | xargs grep -h \"^#{name}.*;\\s*$\"") -end - -def output_getter(struct_base, struct, type, name) - output "/// @fn static inline #{type} #{struct}Get#{name}(const #{struct_base} *#{struct_base[2..-1].downcase});" - output "/// Get the #{name} of a #{struct}." - output -end - -def output_setter(struct_base, struct, type, name) - output "/// @fn static inline void #{struct}Set#{name}(#{struct_base} *#{struct_base[2..-1].downcase}, #{type} value);" - output "/// Set the #{name} of a #{struct}." - output -end - -def struct_parser(decl) - decl.match(/\((.*?), (.*?), (.*?)(, .*)?\)/).captures.values_at(0, 2) -end - -def search_struct(struct) - upname = struct[2..-1].capitalize - find_declarations("CP_Define#{upname}StructProperty").each do|decl| - type, name = *struct_parser(decl) - output_getter(struct, struct, type, name) - output_setter(struct, struct, type, name) - end +FUNCS = {} +IO.readlines("|ruby extract_protos.rb").each{|line| + func = eval(line) + FUNCS[func[:name]] = func +} + +SKIP = Object.new + +GETTER_DOCS = { + "cpArbiterGetBodies" => SKIP, + "cpArbiterGetContactPointSet" => SKIP, + "cpArbiterGetCount" => SKIP, + "cpArbiterGetDepth" => SKIP, + "cpArbiterGetElasticity" => "Get the elasticity for this cpArbiter", + "cpArbiterGetFriction" => "Get the friction for this cpArbiter", + "cpArbiterGetNormal" => SKIP, + "cpArbiterGetPoint" => SKIP, + "cpArbiterGetShapes" => SKIP, + "cpArbiterGetSurfaceVelocity" => "Get the surface velocity used by the contact calculation for this cpArbiter", - find_declarations("CP_Define#{upname}StructGetter").each do|decl| - output_getter(struct, struct, *struct_parser(decl)) - end + "cpBodyGetAngVel" => "Get the angular velocity of this cpBody", + "cpBodyGetAngVelLimit" => "Get the angular velocity limit of this cpBody", + "cpBodyGetAngle" => "Get the angle of this cpBody", + "cpBodyGetForce" => "Get the force applied to this cpBody", + "cpBodyGetMass" => "Get the mass of this cpBody", + "cpBodyGetMoment" => "Get the moment of inertia of this cpBody", + "cpBodyGetPos" => "Get the position of this cpBody", + "cpBodyGetRot" => "Get the rotation vector of this cpBody", + "cpBodyGetTorque" => "Get the torque applied to this cpBody", + "cpBodyGetUserData" => "Get the userdata pointer for this cpBody", + "cpBodyGetVel" => "Get the velocity of this cpBody", + "cpBodyGetVelLimit" => "Get the velocity limit of this cpBody", - find_declarations("CP_Define#{upname}StructSetter").each do|decl| - output_setter(struct, struct, *struct_parser(decl)) - end -end - -search_struct("cpBody") -search_struct("cpShape") -search_struct("cpConstraint") -search_struct("cpSpace") - -def output_getter2(struct_base, struct, type, name) - output "/// @addtogroup #{struct}" - output "/// @{" - output "/// @fn static inline #{type} #{struct}Get#{name}(const #{struct_base} *#{struct_base[2..-1].downcase});" - output "/// @brief Get the #{name} of a #{struct}." - output "static inline #{type} #{struct}Get#{name}(const #{struct_base} *#{struct_base[2..-1].downcase});" - output "/// @}" - output -end - -def output_setter2(struct_base, struct, type, name) - output "/// @addtogroup #{struct}" - output "/// @{" - output "/// @fn static inline void #{struct}Set#{name}(#{struct_base} *#{struct_base[2..-1].downcase}, #{type} value);" - output "/// @brief Set the #{name} of a #{struct}." - output "static inline void #{struct}Set#{name}(#{struct_base} *#{struct_base[2..-1].downcase}, #{type} value);" - output "/// @}" - output -end - -def struct_parser2(decl) - decl.match(/\((.*?), (.*?), (.*?), (.*?)\)/).captures.values_at(0, 1, 3) -end - -def search_struct2(struct_base) - upname = struct_base[2..-1].capitalize - find_declarations("CP_\\(Define\\|Declare\\)#{upname}Property").each do|decl| - struct, type, name = *struct_parser2(decl) - output_getter2(struct_base, struct, type, name) - output_setter2(struct_base, struct, type, name) - end + "cpCircleShapeGetOffset" => "Get the offset of this cpCircleShape", + "cpCircleShapeGetRadius" => "Get the radius of this cpCircleShape", - find_declarations("CP_Define#{upname}Getter").each do|decl| - output_getter2(struct_base, *struct_parser2(decl)) - end + "cpConstraintGetA" => "Get the first of the two bodies this cpConstraint is connected to.", + "cpConstraintGetB" => "Get the second of the two bodies this cpConstraint is connected to.", + "cpConstraintGetErrorBias" => "Get the percentage of constraint error that remains unfixed after each second.", + "cpConstraintGetImpulse" => SKIP, + "cpConstraintGetMaxBias" => "Get the maximum rate this cpConstraint can apply to correct itself at.", + "cpConstraintGetMaxForce" => "Get the maximum force this cpConstraint can apply to correct itself.", + "cpConstraintGetPostSolveFunc" => "Get the function callback that is called each step after the solver runs.", + "cpConstraintGetPreSolveFunc" => "Get the function callback that is called each step before the solver runs.", + "cpConstraintGetUserData" => "Get the user data pointer for this cpConstraint.", + + "cpDampedRotarySpringGetDamping" => "Get the damping of this cpDampedRotarySpring.", + "cpDampedRotarySpringGetRestAngle" => "Get the restangle of this cpDampedRotarySpring.", + "cpDampedRotarySpringGetSpringTorqueFunc" => "Get the springtorquefunc of this cpDampedRotarySpring.", + "cpDampedRotarySpringGetStiffness" => "Get the stiffness of this cpDampedRotarySpring.", + + "cpDampedSpringGetAnchr1" => "Get the anchr1 of this cpDampedSpring.", + "cpDampedSpringGetAnchr2" => "Get the anchr2 of this cpDampedSpring.", + "cpDampedSpringGetDamping" => "Get the damping of this cpDampedSpring.", + "cpDampedSpringGetRestLength" => "Get the rest length of this cpDampedSpring.", + "cpDampedSpringGetSpringForceFunc" => "Get the spring force callback function of this cpDampedSpring.", + "cpDampedSpringGetStiffness" => "Get the stiffness of this cpDampedSpring.", - find_declarations("CP_Define#{upname}Setter").each do|decl| - output_setter2(struct_base, *struct_parser2(decl)) + "cpGearJointGetPhase" => "Get the phase of this cpGearJoint.", + "cpGearJointGetRatio" => "Get the ratio of this cpGearJoint.", + + "cpGrooveJointGetAnchr2" => "Get the anchr2 of this cpGrooveJoint.", + "cpGrooveJointGetGrooveA" => "Get the groovea of this cpGrooveJoint.", + "cpGrooveJointGetGrooveB" => "Get the grooveb of this cpGrooveJoint.", + + "cpPinJointGetAnchr1" => "Get the anchr1 of this cpPinJoint.", + "cpPinJointGetAnchr2" => "Get the anchr2 of this cpPinJoint.", + "cpPinJointGetDist" => "Get the dist between the anchor points of this cpPinJoint.", + + "cpPivotJointGetAnchr1" => "Get the anchr1 of this cpPivotJoint.", + "cpPivotJointGetAnchr2" => "Get the anchr2 of this cpPivotJoint.", + + "cpPolyShapeGetNumVerts" => SKIP, + "cpPolyShapeGetVert" => SKIP, + + "cpRatchetJointGetAngle" => "Get the angle of this cpRatchetJoint.", + "cpRatchetJointGetPhase" => "Get the phase of this cpRatchetJoint.", + "cpRatchetJointGetRatchet" => "Get the ratchet angular distance of this cpRatchetJoint.", + + "cpRotaryLimitJointGetMax" => "Get the max delta angle of this cpRotaryLimitJoint.", + "cpRotaryLimitJointGetMin" => "Get the min delta angle of this cpRotaryLimitJoint.", + + "cpSegmentShapeGetA" => "Get the first endpoint of this cpSegmentShape.", + "cpSegmentShapeGetB" => "Get the second endpoint of this cpSegmentShape.", + "cpSegmentShapeGetNormal" => "Get the normal of this cpSegmentShape.", + "cpSegmentShapeGetRadius" => "Get the radius of this cpSegmentShape.", + + "cpShapeGetBB" => "Get the bounding box of this cpShape.", + "cpShapeGetBody" => "Get the body this cpShape is attached to.", + "cpShapeGetCollisionType" => "Get the collision type of this cpShape.", + "cpShapeGetElasticity" => "Get the elasticity of this cpShape.", + "cpShapeGetFriction" => "Get the friction of this cpShape.", + "cpShapeGetGroup" => "Get the group of this cpShape.", + "cpShapeGetLayers" => "Get the layer bitmask of this cpShape.", + "cpShapeGetSensor" => "Get the sensor flag of this cpShape.", + "cpShapeGetSurfaceVelocity" => "Get the surface velocity of this cpShape.", + "cpShapeGetUserData" => "Get the user data pointer of this cpShape.", + + "cpSimpleMotorGetRate" => "Get the rate of this cpSimpleMotor.", + + "cpSlideJointGetAnchr1" => "Get the anchr1 of this cpSlideJoint.", + "cpSlideJointGetAnchr2" => "Get the anchr2 of this cpSlideJoint.", + "cpSlideJointGetMax" => "Get the max distance between the anchors of this cpSlideJoint.", + "cpSlideJointGetMin" => "Get the min distance between the anchors of this cpSlideJoint.", + + "cpSpaceGetCollisionBias" => "Get the collision bias of this cpSpace.", + "cpSpaceGetCollisionPersistence" => "Get the collision persistence of this cpSpace.", + "cpSpaceGetCollisionSlop" => "Get the collision slop of this cpSpace.", + "cpSpaceGetCurrentTimeStep" => "Get the most recent timestep used with this cpSpace.", + "cpSpaceGetDamping" => "Get the damping of this cpSpace.", + "cpSpaceGetEnableContactGraph" => "Get the enable contact graph flag of this cpSpace.", + "cpSpaceGetGravity" => "Get the gravity of this cpSpace.", + "cpSpaceGetIdleSpeedThreshold" => "Get the idle speed threshold of this cpSpace.", + "cpSpaceGetIterations" => "Get the number of solver iterations of this cpSpace.", + "cpSpaceGetSleepTimeThreshold" => "Get the sleep time threshold of this cpSpace.", + "cpSpaceGetStaticBody" => "Get the static body of this cpSpace.", + "cpSpaceGetUserData" => "Get the user data pointer of this cpSpace.", +} + +def output_getter(func) + name = func[:name] + + doc = GETTER_DOCS[name] + return if doc == SKIP + + struct, property = */(cp\w*)Get(.+)/.match(name).captures + + if doc + prototype = "#{func[:inline] ? "static inline " : ""}#{func[:return]} #{name}(#{func[:args]})" + +DOC_FILE.puts <<-EOF +/// @addtogroup #{struct} +/// @{ +/// @fn #{prototype}; +/// @brief #{doc} +#{prototype}; +/// @} + +EOF + else + puts %{\t"#{name}" => "Get the #{property.downcase} of this #{struct}.",} end end -search_struct2("cpConstraint") - -def output_getter2(struct_base, struct, type, name) - output "/// @fn #{type} #{struct}Get#{name}(const #{struct_base} *#{struct_base[2..-1].downcase});" - output "/// Get the #{name} of a #{struct}." - output -end - -def output_setter2(struct_base, struct, type, name) - output "/// @fn void #{struct}Set#{name}(#{struct_base} *#{struct_base[2..-1].downcase}, #{type} value);" - output "/// Set the #{name} of a #{struct}." - output -end - -def struct_parser3(decl) - decl.match(/\((.*?), (.*?), (.*?)\)/).captures -end -def search_struct3(struct_base) - upname = struct_base[2..-1].capitalize - find_declarations("CP_\\(Define\\|Declare\\)#{upname}Property").each do|decl| - struct, type, name = *struct_parser3(decl) - output_getter2(struct_base, struct, type, name) - output_setter2(struct_base, struct, type, name) - end +def output_setter(func) + name = func[:name] - find_declarations("CP_\\(Define\\|Declare\\)#{upname}Getter").each do|decl| - output_getter2(struct_base, *struct_parser3(decl)) - end + doc = GETTER_DOCS[name.gsub("Set", "Get")] + return if doc == SKIP - find_declarations("CP_\\(Define\\|Declare\\)#{upname}Setter").each do|decl| - output_setter2(struct_base, *struct_parser3(decl)) + struct, property = */(cp\w*)Set(.+)/.match(name).captures + + if doc + prototype = "static inline void #{name}(#{func[:args]})" + +DOC_FILE.puts <<-EOF +/// @addtogroup #{struct} +/// @{ +/// @fn #{prototype}; +/// @brief #{doc.gsub("Get", "Set")} +#{prototype}; +/// @}" + +EOF + else + puts %{\t"#{name}" => "Set the #{property.downcase} of this #{struct}.",} end end -search_struct3("cpShape") + +getters = FUNCS.keys.find_all{|name| /(cp\w*)Get(.+)/.match(name)}.sort +FUNCS.values_at(*getters).each{|func| output_getter(func)} + +setters = FUNCS.keys.find_all{|name| /(cp\w*)Set(.+)/.match(name)}.sort +FUNCS.values_at(*setters).each{|func| output_setter(func)} diff --git a/extract_protos.rb b/extract_protos.rb index e692b504..0c8971f9 100644 --- a/extract_protos.rb +++ b/extract_protos.rb @@ -1,25 +1,22 @@ -# extract function prototypes from the headers for making FFIs, etc. -# use like this: find include/ -name "*.h" | xargs cat | ruby extract_protos.rb - -FORMAT = ARGV[0] - # match 0 is the whole function proto -# match 1 is the return value -# match 2 returns pointer? -# match 3 is the function name -# match 4 is the remainder -REGEX = /.*?((\w+(\s+\*)?)\s*(cp\w*)\(.*?\))(.*)/ +# match 1 is either "static inline " or nil +# match 2 is the return type +# match 3 is the function symbol name +# match 4 is the arguments +PATTERN = /.*?((static inline )?(\w*\*?)\s(cp\w*)\((.*?)\))/ -STDIN.readlines.each do|str| - while match = REGEX.match(str) - captures = match.captures - proto, ret, sym, str = captures.values_at(0, 1, 3, 4) - break if ret == "return" +IO.readlines("|gcc -DNDEBUG -E include/chipmunk/chipmunk.h").each do|line| + str = line + + while match = PATTERN.match(str) + str = match.post_match + + proto, inline, ret, name, args = match.captures.values_at(0, 1, 2, 3, 4) + next if ret == "return" || ret == "" + + inline = !!inline - if FORMAT - puts eval('"' + FORMAT + '"') - else - puts "* #{proto} - #{sym}" - end + p({:inline => inline, :return => ret, :name => name, :args => args}) +# puts "#{sym} - #{inline ? "static inline " : ""}#{ret} #{sym}(#{args})" end end diff --git a/include/chipmunk/chipmunk.h b/include/chipmunk/chipmunk.h index 9b292e69..0ba697e4 100644 --- a/include/chipmunk/chipmunk.h +++ b/include/chipmunk/chipmunk.h @@ -19,9 +19,6 @@ * SOFTWARE. */ -/// @defgroup misc Misc -/// @{ - #ifndef CHIPMUNK_HEADER #define CHIPMUNK_HEADER @@ -58,21 +55,26 @@ void cpMessage(const char *condition, const char *file, int line, int isError, i #include "chipmunk_types.h" -// Allocated size for various Chipmunk buffers +/// @defgroup misc Misc +/// @{ + +/// Allocated size for various Chipmunk buffers #ifndef CP_BUFFER_BYTES #define CP_BUFFER_BYTES (32*1024) #endif -// Chipmunk memory function aliases. #ifndef cpcalloc + /// Chipmunk calloc() alias. #define cpcalloc calloc #endif #ifndef cprealloc + /// Chipmunk realloc() alias. #define cprealloc realloc #endif #ifndef cpfree + /// Chipmunk free() alias. #define cpfree free #endif @@ -146,6 +148,8 @@ cpFloat cpMomentForBox(cpFloat m, cpFloat width, cpFloat height); /// Calculate the moment of inertia for a solid box. cpFloat cpMomentForBox2(cpFloat m, cpBB box); +//@} + #ifdef __cplusplus } @@ -157,4 +161,3 @@ static inline cpVect operator -(const cpVect v){return cpvneg(v);} #endif #endif -//@} diff --git a/include/chipmunk/chipmunk_types.h b/include/chipmunk/chipmunk_types.h index 6552f8ef..da3060ce 100644 --- a/include/chipmunk/chipmunk_types.h +++ b/include/chipmunk/chipmunk_types.h @@ -137,8 +137,8 @@ static inline cpFloat cpflerpconst(cpFloat f1, cpFloat f2, cpFloat d) /// Hash value type. typedef uintptr_t cpHashValue; +// Oh C, how we love to define our own boolean types to get compiler compatibility /// Chipmunk's boolean type. -/// Oh C, how we love to define our own boolean types to get compiler compatibility #ifdef CP_BOOL_TYPE typedef CP_BOOL_TYPE cpBool; #else diff --git a/include/chipmunk/constraints/cpConstraint.h b/include/chipmunk/constraints/cpConstraint.h index c7906b45..1564caef 100644 --- a/include/chipmunk/constraints/cpConstraint.h +++ b/include/chipmunk/constraints/cpConstraint.h @@ -37,8 +37,9 @@ struct cpConstraintClass { cpConstraintGetImpulseImpl getImpulse; }; - +/// Callback function type that gets called before solving a joint. typedef void (*cpConstraintPreSolveFunc)(cpConstraint *constraint, cpSpace *space); +/// Callback function type that gets called after solving a joint. typedef void (*cpConstraintPostSolveFunc)(cpConstraint *constraint, cpSpace *space); @@ -93,21 +94,24 @@ static inline void cpConstraintActivateBodies(cpConstraint *constraint) cpBody *b = constraint->b; if(b) cpBodyActivate(b); } +/// @private #define CP_DefineConstraintStructGetter(type, member, name) \ static inline type cpConstraint##Get##name(const cpConstraint *constraint){return constraint->member;} +/// @private #define CP_DefineConstraintStructSetter(type, member, name) \ static inline void cpConstraint##Set##name(cpConstraint *constraint, type value){ \ cpConstraintActivateBodies(constraint); \ constraint->member = value; \ } +/// @private #define CP_DefineConstraintStructProperty(type, member, name) \ CP_DefineConstraintStructGetter(type, member, name) \ CP_DefineConstraintStructSetter(type, member, name) -CP_DefineConstraintStructGetter(cpBody *, a, A); -CP_DefineConstraintStructGetter(cpBody *, b, B); +CP_DefineConstraintStructGetter(cpBody*, a, A); +CP_DefineConstraintStructGetter(cpBody*, b, B); CP_DefineConstraintStructProperty(cpFloat, maxForce, MaxForce); CP_DefineConstraintStructProperty(cpFloat, errorBias, ErrorBias); CP_DefineConstraintStructProperty(cpFloat, maxBias, MaxBias); @@ -115,7 +119,7 @@ CP_DefineConstraintStructProperty(cpConstraintPreSolveFunc, preSolve, PreSolveFu CP_DefineConstraintStructProperty(cpConstraintPostSolveFunc, postSolve, PostSolveFunc); CP_DefineConstraintStructProperty(cpDataPointer, data, UserData); -/// Get the last impulse applied by this constraint. +// Get the last impulse applied by this constraint. static inline cpFloat cpConstraintGetImpulse(cpConstraint *constraint) { return constraint->CP_PRIVATE(klass)->getImpulse(constraint); diff --git a/include/chipmunk/constraints/cpDampedRotarySpring.h b/include/chipmunk/constraints/cpDampedRotarySpring.h index 9f3775a6..735d28b2 100644 --- a/include/chipmunk/constraints/cpDampedRotarySpring.h +++ b/include/chipmunk/constraints/cpDampedRotarySpring.h @@ -26,6 +26,7 @@ typedef cpFloat (*cpDampedRotarySpringTorqueFunc)(struct cpConstraint *spring, c const cpConstraintClass *cpDampedRotarySpringGetClass(); +/// @private typedef struct cpDampedRotarySpring { cpConstraint constraint; cpFloat restAngle; @@ -40,11 +41,11 @@ typedef struct cpDampedRotarySpring { } cpDampedRotarySpring; /// Allocate a damped rotary spring. -cpDampedRotarySpring *cpDampedRotarySpringAlloc(void); +cpDampedRotarySpring* cpDampedRotarySpringAlloc(void); /// Initialize a damped rotary spring. -cpDampedRotarySpring *cpDampedRotarySpringInit(cpDampedRotarySpring *joint, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); +cpDampedRotarySpring* cpDampedRotarySpringInit(cpDampedRotarySpring *joint, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); /// Allocate and initialize a damped rotary spring. -cpConstraint *cpDampedRotarySpringNew(cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); +cpConstraint* cpDampedRotarySpringNew(cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, restAngle, RestAngle); CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, stiffness, Stiffness); diff --git a/include/chipmunk/constraints/cpDampedSpring.h b/include/chipmunk/constraints/cpDampedSpring.h index b34f6639..7cc9cb91 100644 --- a/include/chipmunk/constraints/cpDampedSpring.h +++ b/include/chipmunk/constraints/cpDampedSpring.h @@ -46,11 +46,11 @@ struct cpDampedSpring { }; /// Allocate a damped spring. -cpDampedSpring *cpDampedSpringAlloc(void); +cpDampedSpring* cpDampedSpringAlloc(void); /// Initialize a damped spring. -cpDampedSpring *cpDampedSpringInit(cpDampedSpring *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping); +cpDampedSpring* cpDampedSpringInit(cpDampedSpring *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping); /// Allocate and initialize a damped spring. -cpConstraint *cpDampedSpringNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping); +cpConstraint* cpDampedSpringNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping); CP_DefineConstraintProperty(cpDampedSpring, cpVect, anchr1, Anchr1); CP_DefineConstraintProperty(cpDampedSpring, cpVect, anchr2, Anchr2); diff --git a/include/chipmunk/constraints/cpGearJoint.h b/include/chipmunk/constraints/cpGearJoint.h index 0b068273..8fd006d0 100644 --- a/include/chipmunk/constraints/cpGearJoint.h +++ b/include/chipmunk/constraints/cpGearJoint.h @@ -37,11 +37,11 @@ typedef struct cpGearJoint { } cpGearJoint; /// Allocate a gear joint. -cpGearJoint *cpGearJointAlloc(void); +cpGearJoint* cpGearJointAlloc(void); /// Initialize a gear joint. -cpGearJoint *cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); +cpGearJoint* cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); /// Allocate and initialize a gear joint. -cpConstraint *cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); +cpConstraint* cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); CP_DefineConstraintProperty(cpGearJoint, cpFloat, phase, Phase); CP_DefineConstraintGetter(cpGearJoint, cpFloat, ratio, Ratio); diff --git a/include/chipmunk/constraints/cpGrooveJoint.h b/include/chipmunk/constraints/cpGrooveJoint.h index bed2c52f..ca03d8d4 100644 --- a/include/chipmunk/constraints/cpGrooveJoint.h +++ b/include/chipmunk/constraints/cpGrooveJoint.h @@ -41,11 +41,11 @@ typedef struct cpGrooveJoint { } cpGrooveJoint; /// Allocate a groove joint. -cpGrooveJoint *cpGrooveJointAlloc(void); +cpGrooveJoint* cpGrooveJointAlloc(void); /// Initialize a groove joint. -cpGrooveJoint *cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2); +cpGrooveJoint* cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2); /// Allocate and initialize a groove joint. -cpConstraint *cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2); +cpConstraint* cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2); CP_DefineConstraintGetter(cpGrooveJoint, cpVect, grv_a, GrooveA); /// Set endpoint a of a groove joint's groove diff --git a/include/chipmunk/constraints/cpPinJoint.h b/include/chipmunk/constraints/cpPinJoint.h index 8b57f266..2b3910ff 100644 --- a/include/chipmunk/constraints/cpPinJoint.h +++ b/include/chipmunk/constraints/cpPinJoint.h @@ -39,11 +39,11 @@ typedef struct cpPinJoint { } cpPinJoint; /// Allocate a pin joint. -cpPinJoint *cpPinJointAlloc(void); +cpPinJoint* cpPinJointAlloc(void); /// Initialize a pin joint. -cpPinJoint *cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); +cpPinJoint* cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); /// Allocate and initialize a pin joint. -cpConstraint *cpPinJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); +cpConstraint* cpPinJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr1, Anchr1); CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr2, Anchr2); diff --git a/include/chipmunk/constraints/cpPivotJoint.h b/include/chipmunk/constraints/cpPivotJoint.h index 13cf4a43..d3c58c2d 100644 --- a/include/chipmunk/constraints/cpPivotJoint.h +++ b/include/chipmunk/constraints/cpPivotJoint.h @@ -38,13 +38,13 @@ typedef struct cpPivotJoint { } cpPivotJoint; /// Allocate a pivot joint -cpPivotJoint *cpPivotJointAlloc(void); +cpPivotJoint* cpPivotJointAlloc(void); /// Initialize a pivot joint. -cpPivotJoint *cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); +cpPivotJoint* cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); /// Allocate and initialize a pivot joint. -cpConstraint *cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot); +cpConstraint* cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot); /// Allocate and initialize a pivot joint with specific anchors. -cpConstraint *cpPivotJointNew2(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); +cpConstraint* cpPivotJointNew2(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr1, Anchr1); CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr2, Anchr2); diff --git a/include/chipmunk/constraints/cpRatchetJoint.h b/include/chipmunk/constraints/cpRatchetJoint.h index a37339c4..35ca30f3 100644 --- a/include/chipmunk/constraints/cpRatchetJoint.h +++ b/include/chipmunk/constraints/cpRatchetJoint.h @@ -36,11 +36,11 @@ typedef struct cpRatchetJoint { } cpRatchetJoint; /// Allocate a ratchet joint. -cpRatchetJoint *cpRatchetJointAlloc(void); +cpRatchetJoint* cpRatchetJointAlloc(void); /// Initialize a ratched joint. -cpRatchetJoint *cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); +cpRatchetJoint* cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); /// Allocate and initialize a ratchet joint. -cpConstraint *cpRatchetJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); +cpConstraint* cpRatchetJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); CP_DefineConstraintProperty(cpRatchetJoint, cpFloat, angle, Angle); CP_DefineConstraintProperty(cpRatchetJoint, cpFloat, phase, Phase); diff --git a/include/chipmunk/constraints/cpRotaryLimitJoint.h b/include/chipmunk/constraints/cpRotaryLimitJoint.h index 5d55e8c3..8bda9c98 100644 --- a/include/chipmunk/constraints/cpRotaryLimitJoint.h +++ b/include/chipmunk/constraints/cpRotaryLimitJoint.h @@ -36,11 +36,11 @@ typedef struct cpRotaryLimitJoint { } cpRotaryLimitJoint; /// Allocate a damped rotary limit joint. -cpRotaryLimitJoint *cpRotaryLimitJointAlloc(void); +cpRotaryLimitJoint* cpRotaryLimitJointAlloc(void); /// Initialize a damped rotary limit joint. -cpRotaryLimitJoint *cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max); +cpRotaryLimitJoint* cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max); /// Allocate and initialize a damped rotary limit joint. -cpConstraint *cpRotaryLimitJointNew(cpBody *a, cpBody *b, cpFloat min, cpFloat max); +cpConstraint* cpRotaryLimitJointNew(cpBody *a, cpBody *b, cpFloat min, cpFloat max); CP_DefineConstraintProperty(cpRotaryLimitJoint, cpFloat, min, Min); CP_DefineConstraintProperty(cpRotaryLimitJoint, cpFloat, max, Max); diff --git a/include/chipmunk/constraints/cpSimpleMotor.h b/include/chipmunk/constraints/cpSimpleMotor.h index acd6ca25..f3bb80d6 100644 --- a/include/chipmunk/constraints/cpSimpleMotor.h +++ b/include/chipmunk/constraints/cpSimpleMotor.h @@ -35,11 +35,11 @@ typedef struct cpSimpleMotor { } cpSimpleMotor; /// Allocate a simple motor. -cpSimpleMotor *cpSimpleMotorAlloc(void); +cpSimpleMotor* cpSimpleMotorAlloc(void); /// initialize a simple motor. -cpSimpleMotor *cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate); +cpSimpleMotor* cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate); /// Allocate and initialize a simple motor. -cpConstraint *cpSimpleMotorNew(cpBody *a, cpBody *b, cpFloat rate); +cpConstraint* cpSimpleMotorNew(cpBody *a, cpBody *b, cpFloat rate); CP_DefineConstraintProperty(cpSimpleMotor, cpFloat, rate, Rate); diff --git a/include/chipmunk/constraints/cpSlideJoint.h b/include/chipmunk/constraints/cpSlideJoint.h index 86689538..d468f0a8 100644 --- a/include/chipmunk/constraints/cpSlideJoint.h +++ b/include/chipmunk/constraints/cpSlideJoint.h @@ -39,11 +39,11 @@ typedef struct cpSlideJoint { } cpSlideJoint; /// Allocate a slide joint. -cpSlideJoint *cpSlideJointAlloc(void); +cpSlideJoint* cpSlideJointAlloc(void); /// Initialize a slide joint. -cpSlideJoint *cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max); +cpSlideJoint* cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max); /// Allocate and initialize a slide joint. -cpConstraint *cpSlideJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max); +cpConstraint* cpSlideJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max); CP_DefineConstraintProperty(cpSlideJoint, cpVect, anchr1, Anchr1); CP_DefineConstraintProperty(cpSlideJoint, cpVect, anchr2, Anchr2); diff --git a/include/chipmunk/cpBody.h b/include/chipmunk/cpBody.h index 2d4764d7..5aeaae77 100644 --- a/include/chipmunk/cpBody.h +++ b/include/chipmunk/cpBody.h @@ -100,16 +100,16 @@ struct cpBody { }; /// Allocate a cpBody. -cpBody *cpBodyAlloc(void); +cpBody* cpBodyAlloc(void); /// Initialize a cpBody. -cpBody *cpBodyInit(cpBody *body, cpFloat m, cpFloat i); +cpBody* cpBodyInit(cpBody *body, cpFloat m, cpFloat i); /// Allocate and initialize a cpBody. -cpBody *cpBodyNew(cpFloat m, cpFloat i); +cpBody* cpBodyNew(cpFloat m, cpFloat i); /// Initialize a static cpBody. -cpBody *cpBodyInitStatic(cpBody *body); +cpBody* cpBodyInitStatic(cpBody *body); /// Allocate and initialize a static cpBody. -cpBody *cpBodyNewStatic(); +cpBody* cpBodyNewStatic(); /// Destroy a cpBody. void cpBodyDestroy(cpBody *body); diff --git a/include/chipmunk/cpPolyShape.h b/include/chipmunk/cpPolyShape.h index a34956ed..174ee046 100644 --- a/include/chipmunk/cpPolyShape.h +++ b/include/chipmunk/cpPolyShape.h @@ -38,22 +38,22 @@ typedef struct cpPolyShape { } cpPolyShape; /// Allocate a polygon shape. -cpPolyShape *cpPolyShapeAlloc(void); +cpPolyShape* cpPolyShapeAlloc(void); /// Initialize a polygon shape. /// The vertexes must be convex and have a clockwise winding. -cpPolyShape *cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int numVerts, cpVect *verts, cpVect offset); +cpPolyShape* cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int numVerts, cpVect *verts, cpVect offset); /// Allocate and initialize a polygon shape. /// The vertexes must be convex and have a clockwise winding. -cpShape *cpPolyShapeNew(cpBody *body, int numVerts, cpVect *verts, cpVect offset); +cpShape* cpPolyShapeNew(cpBody *body, int numVerts, cpVect *verts, cpVect offset); /// Initialize a box shaped polygon shape. -cpPolyShape *cpBoxShapeInit(cpPolyShape *poly, cpBody *body, cpFloat width, cpFloat height); +cpPolyShape* cpBoxShapeInit(cpPolyShape *poly, cpBody *body, cpFloat width, cpFloat height); /// Initialize an offset box shaped polygon shape. -cpPolyShape *cpBoxShapeInit2(cpPolyShape *poly, cpBody *body, cpBB box); +cpPolyShape* cpBoxShapeInit2(cpPolyShape *poly, cpBody *body, cpBB box); /// Allocate and initialize a box shaped polygon shape. -cpShape *cpBoxShapeNew(cpBody *body, cpFloat width, cpFloat height); +cpShape* cpBoxShapeNew(cpBody *body, cpFloat width, cpFloat height); /// Allocate and initialize an offset box shaped polygon shape. -cpShape *cpBoxShapeNew2(cpBody *body, cpBB box); +cpShape* cpBoxShapeNew2(cpBody *body, cpBB box); /// Check that a set of vertexes is convex and has a clockwise winding. cpBool cpPolyValidate(const cpVect *verts, const int numVerts); diff --git a/include/chipmunk/cpShape.h b/include/chipmunk/cpShape.h index f700f203..1b1db781 100644 --- a/include/chipmunk/cpShape.h +++ b/include/chipmunk/cpShape.h @@ -125,7 +125,7 @@ static inline void cpShapeSet##name(cpShape *shape, type value){ \ CP_DefineShapeStructGetter(type, member, name) \ CP_DefineShapeStructSetter(type, member, name, activates) -CP_DefineShapeStructGetter(cpBody *, body, Body); +CP_DefineShapeStructGetter(cpBody*, body, Body); void cpShapeSetBody(cpShape *shape, cpBody *body); CP_DefineShapeStructGetter(cpBB, bb, BB); @@ -172,11 +172,11 @@ typedef struct cpCircleShape { } cpCircleShape; /// Allocate a circle shape. -cpCircleShape *cpCircleShapeAlloc(void); +cpCircleShape* cpCircleShapeAlloc(void); /// Initialize a circle shape. -cpCircleShape *cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset); +cpCircleShape* cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset); /// Allocate and initialize a circle shape. -cpShape *cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset); +cpShape* cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset); CP_DeclareShapeGetter(cpCircleShape, cpVect, Offset); CP_DeclareShapeGetter(cpCircleShape, cpFloat, Radius); diff --git a/include/chipmunk/cpSpace.h b/include/chipmunk/cpSpace.h index 6c8d9fa1..11108d27 100644 --- a/include/chipmunk/cpSpace.h +++ b/include/chipmunk/cpSpace.h @@ -48,7 +48,7 @@ struct cpSpace { /// The default value of INFINITY disables the sleeping algorithm. cpFloat sleepTimeThreshold; - /// Amount of encouraged penetration between colliding shapes.. + /// Amount of encouraged penetration between colliding shapes. /// Used to reduce oscillating contacts and keep the collision cache warm. /// Defaults to 0.1. If you have poor simulation quality, /// increase this number as much as possible without allowing visible amounts of overlap. @@ -137,7 +137,7 @@ CP_DefineSpaceStructProperty(cpFloat, collisionBias, CollisionBias); CP_DefineSpaceStructProperty(cpTimestamp, collisionPersistence, CollisionPersistence); CP_DefineSpaceStructProperty(cpBool, enableContactGraph, EnableContactGraph); CP_DefineSpaceStructProperty(cpDataPointer, data, UserData); -CP_DefineSpaceStructGetter(cpBody *, staticBody, StaticBody); +CP_DefineSpaceStructGetter(cpBody*, staticBody, StaticBody); CP_DefineSpaceStructGetter(cpFloat, CP_PRIVATE(curr_dt), CurrentTimeStep); /// returns true from inside a callback and objects cannot be added/removed. @@ -177,13 +177,13 @@ void cpSpaceRemoveCollisionHandler(cpSpace *space, cpCollisionType a, cpCollisio /// Add a collision shape to the simulation. /// If the shape is attached to a static body, it will be added as a static shape. -cpShape *cpSpaceAddShape(cpSpace *space, cpShape *shape); +cpShape* cpSpaceAddShape(cpSpace *space, cpShape *shape); /// Explicity add a shape as a static shape to the simulation. -cpShape *cpSpaceAddStaticShape(cpSpace *space, cpShape *shape); +cpShape* cpSpaceAddStaticShape(cpSpace *space, cpShape *shape); /// Add a rigid body to the simulation. -cpBody *cpSpaceAddBody(cpSpace *space, cpBody *body); +cpBody* cpSpaceAddBody(cpSpace *space, cpBody *body); /// Add a constraint to the simulation. -cpConstraint *cpSpaceAddConstraint(cpSpace *space, cpConstraint *constraint); +cpConstraint* cpSpaceAddConstraint(cpSpace *space, cpConstraint *constraint); /// Remove a collision shape from the simulation. void cpSpaceRemoveShape(cpSpace *space, cpShape *shape); diff --git a/include/chipmunk/cpSpatialIndex.h b/include/chipmunk/cpSpatialIndex.h index ff0d0597..7e17bd33 100644 --- a/include/chipmunk/cpSpatialIndex.h +++ b/include/chipmunk/cpSpatialIndex.h @@ -69,11 +69,11 @@ struct cpSpatialIndex { typedef struct cpSpaceHash cpSpaceHash; /// Allocate a spatial hash. -cpSpaceHash *cpSpaceHashAlloc(void); +cpSpaceHash* cpSpaceHashAlloc(void); /// Initialize a spatial hash. -cpSpatialIndex *cpSpaceHashInit(cpSpaceHash *hash, cpFloat celldim, int numcells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); +cpSpatialIndex* cpSpaceHashInit(cpSpaceHash *hash, cpFloat celldim, int numcells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); /// Allocate and initialize a spatial hash. -cpSpatialIndex *cpSpaceHashNew(cpFloat celldim, int cells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); +cpSpatialIndex* cpSpaceHashNew(cpFloat celldim, int cells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); /// Change the cell dimensions and table size of the spatial hash to tune it. /// The cell dimensions should roughly match the average size of your objects @@ -86,11 +86,11 @@ void cpSpaceHashResize(cpSpaceHash *hash, cpFloat celldim, int numcells); typedef struct cpBBTree cpBBTree; /// Allocate a bounding box tree. -cpBBTree *cpBBTreeAlloc(void); +cpBBTree* cpBBTreeAlloc(void); /// Initialize a bounding box tree. -cpSpatialIndex *cpBBTreeInit(cpBBTree *tree, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); +cpSpatialIndex* cpBBTreeInit(cpBBTree *tree, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); /// Allocate and initialize a bounding box tree. -cpSpatialIndex *cpBBTreeNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); +cpSpatialIndex* cpBBTreeNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); /// Perform a static top down optimization of the tree. void cpBBTreeOptimize(cpSpatialIndex *index); @@ -106,11 +106,11 @@ void cpBBTreeSetVelocityFunc(cpSpatialIndex *index, cpBBTreeVelocityFunc func); typedef struct cpSweep1D cpSweep1D; /// Allocate a 1D sort and sweep broadphase. -cpSweep1D *cpSweep1DAlloc(void); +cpSweep1D* cpSweep1DAlloc(void); /// Initialize a 1D sort and sweep broadphase. -cpSpatialIndex *cpSweep1DInit(cpSweep1D *sweep, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); +cpSpatialIndex* cpSweep1DInit(cpSweep1D *sweep, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); /// Allocate and initialize a 1D sort and sweep broadphase. -cpSpatialIndex *cpSweep1DNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); +cpSpatialIndex* cpSweep1DNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); #pragma mark Spatial Index Implementation diff --git a/include/chipmunk/cpVect.h b/include/chipmunk/cpVect.h index 23569295..8f866d90 100644 --- a/include/chipmunk/cpVect.h +++ b/include/chipmunk/cpVect.h @@ -51,7 +51,7 @@ cpFloat cpvtoangle(const cpVect v); /// Returns a string representation of v. Intended mostly for debugging purposes and not production use. /// @attention The string points to a static local and is reset every time the function is called. /// If you want to print more than one vector you will have to split up your printing onto separate lines. -char *cpvstr(const cpVect v); +char* cpvstr(const cpVect v); /// Check if two vectors are equal. (Be careful when comparing floating point numbers!) static inline cpBool cpveql(const cpVect v1, const cpVect v2)