J'essaie de de faire un wrapper de la dernière version de Chipmunk (moteur physique 2D), les headers qui me posent problème sont
cpConstraint.h et
cpPinJoint.h
J'ai essayé de synthétiser le code en C :
Code : Tout sélectionner
typedef struct cpConstraint {
const cpConstraintClass *klass;
cpBody *a, *b;
cpFloat maxForce;
cpFloat biasCoef;
cpFloat maxBias;
cpDataPointer data;
} cpConstraint;
typedef struct cpPinJoint {
cpConstraint constraint;
cpVect anchr1, anchr2;
cpFloat dist;
cpVect r1, r2;
cpVect n;
cpFloat nMass;
cpFloat jnAcc, jnMax;
cpFloat bias;
} cpPinJoint;
#define CP_DefineConstraintGetter(struct, type, member, name) \
static inline type \
struct##Get##name(const cpConstraint *constraint){ \
return ((struct *)constraint)->member; \
} \
CP_DefineConstraintGetter(cpPinJoint, cpVect, anchr1, Anchr1);
Ce qui donnerai en PureBasic :
Code : Tout sélectionner
Structure cpConstraint
*klass.cpConstraintClass
*a.cpBody
*b.cpBody
maxForce.d
biasCoef.d
maxBias.d
*datas
EndStructure
Structure cpPinJoint
constraint.cpConstraint
anchr1.cpVect
anchr2.cpVect
dist.d
r1.cpVect
r2.cpVect
n.cpVect
nMass.d
jnAcc.d
jnMax.d
bias.d
EndStructure
Procedure cpPinJointGetAnchr1(*constraint.cpConstraint)
ProcedureReturn *constraint\anchr1
EndProcedure
Le problème c'est que la structure
cpConstraint n'a pas de membre
anchr1