If I use
inline_as3("trace(\"obj pointer is: \" + %0);\n" : : "r"(&obj;));
inline_as3("trace(\"obj->m_friction pointer is: \" + %0);\n" : : "r"(&obj;->m_friction));
It throws an error on compiling the swc.. expected ‘)’ before ‘;’
So random guess
void createCollisionObjectInC() __attribute__((used, annotate("as3sig:public function createCollisionObjectInC(as3_shape:uint):uint"), annotate("as3package:AWPC_Run")));
void createCollisionObjectInC(){
btCollisionShape* shape;
AS3_GetScalarFromVar(shape, as3_shape);
btCollisionObject* obj = new btCollisionObject();
inline_as3("trace(\"obj pointer is: \" + %0);\n" :: "r"(&obj;));
inline_as3("trace(\"obj->m_rollingFriction pointer is: \" + %0);\n" : : "r"(&obj;->m_rollingFriction));
obj->setCollisionShape(shape);
AS3_Return(obj);
which compiles but when I run it I get
obj pointer is: 2101228
obj->m_rollingFriction pointer is: 4616760
obj pointer has got to be wrong ?
So another random guess…
added
trace(“pointer = ” + pointer);
after
pointer = createCollisionObjectInC(shape.pointer);
in AWPCollisionObject.as
that traces
pointer = 4616528
so
4616760 - 4616528 = 232
Create get/set in AWPCollisionObject.as
public function get rollingFriction() : Number {
return CModule.readFloat(pointer + 232);
}
public function set rollingFriction(v : Number) : void {
CModule.writeFloat(pointer + 232, v);
}
works, now have rollingFriction.
YAY