| 1158 | } |
| 1159 | |
| 1160 | JSBool jsval_to_ccrect(JSContext *cx, jsval v, CADipRect* ret) { |
| 1161 | JSObject *tmp; |
| 1162 | jsval jsx, jsy, jswidth, jsheight; |
| 1163 | double x, y, width, height; |
| 1164 | JSBool ok = v.isObject() && |
| 1165 | JS_ValueToObject(cx, v, &tmp) && |
| 1166 | JS_GetProperty(cx, tmp, "x", &jsx) && |
| 1167 | JS_GetProperty(cx, tmp, "y", &jsy) && |
| 1168 | JS_GetProperty(cx, tmp, "width", &jswidth) && |
| 1169 | JS_GetProperty(cx, tmp, "height", &jsheight) && |
| 1170 | JS_ValueToNumber(cx, jsx, &x) && |
| 1171 | JS_ValueToNumber(cx, jsy, &y) && |
| 1172 | JS_ValueToNumber(cx, jswidth, &width) && |
| 1173 | JS_ValueToNumber(cx, jsheight, &height); |
| 1174 | |
| 1175 | JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); |
| 1176 | |
| 1177 | ret->origin.x = x; |
| 1178 | ret->origin.y = y; |
| 1179 | ret->size.width = width; |
| 1180 | ret->size.height = height; |
| 1181 | return JS_TRUE; |
| 1182 | } |
| 1183 | |
| 1184 | JSBool jsval_to_ccsize(JSContext *cx, jsval v, CADipSize* ret) { |
| 1185 | JSObject *tmp; |
no test coverage detected