I need to create dll using C. But I saw some problems. OK, first: I need function in dll library to compute angle of the line - tgA = dy/dx. Angle = arctg(dy/dx). And I define this in file framework.c:
JSBool computeAngle(JSContext *cx,
JSObject *obj,
unsigned int argc,
jsval *argv,
jsval *rval ) {
double dx, dy, angle;
if (argc != 2) {
return JS_FALSE;
}
if (JS_ValueToDouble(cx, argv[0], &dy) == JS_FALSE ||
JS_ValueToDouble(cx, argv[1], &dx) == JS_FALSE) {
return JS_FALSE;
}
if( dx == 0 ) {
if( dy < 0 ) angle = -90;
else if( dy > 0 ) angle = 90;
else angle = 0;
}else angle = atan(dy/dx)*180/M_PI;
return JS_DoubleToValue(cx, angle, rval);
}
But this method doesn't work! I thought that something wrong, and downloaded Sample.zip from Adobe site. I chanded function computeSum on my function, but it still not work. I think that something wrong with JS_ValueToDouble() and JS_DoubleToValue methods. How do you think?