Mercurial > projects > chipmunkd
comparison trunk/chipmunkd/constraints/cpConstraint.d @ 13:c03a41d47b60
- finished all constraints properties
- implemented cpAssertWarn the mixin way
author | Extrawurst |
---|---|
date | Fri, 03 Dec 2010 21:38:01 +0100 |
parents | 707dd4e10c28 |
children | df4ebc8add66 |
comparison
equal
deleted
inserted
replaced
12:8697699b2c5a | 13:c03a41d47b60 |
---|---|
56 { | 56 { |
57 enum cpConstraintCheckCast = | 57 enum cpConstraintCheckCast = |
58 "assert("~constraint~".klass == "~_struct~"GetClass(), \"Constraint is not a "~_struct~"\");"; | 58 "assert("~constraint~".klass == "~_struct~"GetClass(), \"Constraint is not a "~_struct~"\");"; |
59 } | 59 } |
60 | 60 |
61 //#define cpConstraintCheckCast(constraint, struct) \ | |
62 // cpAssert(constraint->klass == struct##GetClass(), "Constraint is not a "#struct); | |
63 | |
64 template CP_DefineConstraintGetter(string _struct,string type,string member,string name) | 61 template CP_DefineConstraintGetter(string _struct,string type,string member,string name) |
65 { | 62 { |
66 enum CP_DefineConstraintGetter = | 63 enum CP_DefineConstraintGetter = |
67 "static "~type~" "~_struct~"Get"~name~"(cpConstraint *constraint){"~ | 64 "static "~type~" "~_struct~"Get"~name~"(cpConstraint *constraint){"~ |
68 cpConstraintCheckCast!("constraint",_struct)~ | 65 cpConstraintCheckCast!("constraint",_struct)~ |
69 "cpConstraintActivateBodies(constraint);"~ | 66 "cpConstraintActivateBodies(constraint);"~ |
70 "return (cast("~_struct~"*)constraint)."~member~";"~ | 67 "return (cast("~_struct~"*)constraint)."~member~";"~ |
71 "}"; | 68 "}"; |
72 } | 69 } |
73 | |
74 //#define CP_DefineConstraintGetter(struct, type, member, name) \ | |
75 //static inline type \ | |
76 //struct##Get##name(const cpConstraint *constraint){ \ | |
77 // cpConstraintCheckCast(constraint, struct); \ | |
78 // return ((struct *)constraint)->member; \ | |
79 //} \ | |
80 | 70 |
81 template CP_DefineConstraintSetter(string _struct,string type,string member,string name) | 71 template CP_DefineConstraintSetter(string _struct,string type,string member,string name) |
82 { | 72 { |
83 enum CP_DefineConstraintSetter = | 73 enum CP_DefineConstraintSetter = |
84 "static void "~_struct~"Set"~name~"(cpConstraint *constraint,"~type~" value){"~ | 74 "static void "~_struct~"Set"~name~"(cpConstraint *constraint,"~type~" value){"~ |
86 "cpConstraintActivateBodies(constraint);"~ | 76 "cpConstraintActivateBodies(constraint);"~ |
87 "(cast("~_struct~"*)constraint)."~member~" = value;"~ | 77 "(cast("~_struct~"*)constraint)."~member~" = value;"~ |
88 "}"; | 78 "}"; |
89 } | 79 } |
90 | 80 |
91 //#define CP_DefineConstraintSetter(struct, type, member, name) \ | |
92 //static inline void \ | |
93 //struct##Set##name(cpConstraint *constraint, type value){ \ | |
94 // cpConstraintCheckCast(constraint, struct); \ | |
95 // cpConstraintActivateBodies(constraint); \ | |
96 // ((struct *)constraint)->member = value; \ | |
97 //} \ | |
98 | |
99 template CP_DefineConstraintProperty(string _struct,string type,string member,string name) | 81 template CP_DefineConstraintProperty(string _struct,string type,string member,string name) |
100 { | 82 { |
101 enum CP_DefineConstraintProperty = | 83 enum CP_DefineConstraintProperty = |
102 CP_DefineConstraintGetter!(_struct,type,member,name)~CP_DefineConstraintSetter!(_struct,type,member,name); | 84 CP_DefineConstraintGetter!(_struct,type,member,name)~CP_DefineConstraintSetter!(_struct,type,member,name); |
103 | 85 |
104 } | 86 } |
105 | 87 |
106 //#define CP_DefineConstraintProperty(struct, type, member, name) \ | |
107 //CP_DefineConstraintGetter(struct, type, member, name) \ | |
108 //CP_DefineConstraintSetter(struct, type, member, name) | |
109 //TODO: | |
110 //// Built in Joint types | 88 //// Built in Joint types |
111 public import chipmunkd.constraints.cpPinJoint; | 89 public import chipmunkd.constraints.cpPinJoint; |
112 public import chipmunkd.constraints.cpSlideJoint; | 90 public import chipmunkd.constraints.cpSlideJoint; |
113 public import chipmunkd.constraints.cpPivotJoint; | 91 public import chipmunkd.constraints.cpPivotJoint; |
114 public import chipmunkd.constraints.cpGrooveJoint; | 92 public import chipmunkd.constraints.cpGrooveJoint; |