typedef struct JSObject JSObject; typedef int (* JSNative)(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval); extern const char js_toSource_str[]; int math_abs(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval) { } int math_round(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval) { double x; return js_NewNumberValue(cx, copysign(floor(x + 0.5), x), rval); } int math_toSource(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval) { } void *math__methods[] = { { js_toSource_str, math_toSource, 0, 0, 0} , { "round", math_round, 1, 0, 0} }; JSObject * js_InitMathClass(void *cx, JSObject *obj) { JSObject *Math; if (!JS_DefineFunctions(cx, Math, math__methods)) return ((void *)0); }