typedef struct JSFunctionSpec JSFunctionSpec; typedef struct JSObject JSObject; typedef int (* JSNative)(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval); struct JSConstDoubleSpec { }; struct JSFunctionSpec { const char *name; JSNative call; }; extern const char js_toSource_str[]; static int math_abs(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval) { } static 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); } static int math_toSource(void *cx, JSObject *obj, unsigned int argc, long *argv, long *rval) { } static JSFunctionSpec math_static_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_static_methods)) return ((void *)0); }