1 typedef struct JSFunctionSpec JSFunctionSpec;
2 typedef struct JSObject JSObject;
3 typedef int (* JSNative)(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval);
4 struct JSConstDoubleSpec {
6 struct JSFunctionSpec {
10 extern const char js_toSource_str[];
11 static int math_abs(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval) {
13 static int math_round(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval) {
15 return js_NewNumberValue(cx,
16 copysign(floor(x + 0.5), x),
19 static int math_toSource(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval) {
21 static JSFunctionSpec math_static_methods[] = {
23 js_toSource_str, math_toSource, 0, 0, 0}
25 "round", math_round, 1, 0, 0}
27 JSObject * js_InitMathClass(void *cx, JSObject *obj) {
29 if (!JS_DefineFunctions(cx, Math, math_static_methods)) return ((void *)0);