2 typedef unsigned int JSUintn;
3 typedef double JSFloat64;
6 typedef JSFloat64 float64;
9 typedef float64 jsdouble;
11 typedef struct JSContext JSContext;
12 typedef struct JSFunctionSpec JSFunctionSpec;
13 typedef struct JSObject JSObject;
14 typedef JSBool (* JSNative)(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
15 struct JSConstDoubleSpec {
17 struct JSFunctionSpec {
21 extern const char js_toSource_str[];
22 static JSBool math_abs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
24 static JSBool math_round(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
26 z = copysign(floor(x + 0.5), x);
27 return js_NewNumberValue(cx, z, rval);
29 static JSBool math_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
31 static JSFunctionSpec math_static_methods[] = {
33 js_toSource_str, math_toSource, 0, 0, 0}
35 "round", math_round, 1, 0, 0}
37 JSObject * js_InitMathClass(JSContext *cx, JSObject *obj) {
39 if (!JS_DefineFunctions(cx, Math, math_static_methods)) return ((void *)0);