]>
Commit | Line | Data |
---|---|---|
1 | typedef int JSIntn; | |
2 | typedef unsigned int JSUintn; | |
3 | typedef double JSFloat64; | |
4 | typedef JSIntn JSBool; | |
5 | typedef long JSWord; | |
6 | typedef JSFloat64 float64; | |
7 | typedef JSUintn uintN; | |
8 | typedef JSWord jsword; | |
9 | typedef float64 jsdouble; | |
10 | typedef jsword jsval; | |
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 { | |
16 | }; | |
17 | struct JSFunctionSpec { | |
18 | const char *name; | |
19 | JSNative call; | |
20 | }; | |
21 | extern const char js_toSource_str[]; | |
22 | static JSBool math_abs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { | |
23 | } | |
24 | static JSBool math_round(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { | |
25 | jsdouble x, z; | |
26 | z = copysign(floor(x + 0.5), x); | |
27 | return js_NewNumberValue(cx, z, rval); | |
28 | } | |
29 | static JSBool math_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { | |
30 | } | |
31 | static JSFunctionSpec math_static_methods[] = { | |
32 | { | |
33 | js_toSource_str, math_toSource, 0, 0, 0} | |
34 | , { | |
35 | "round", math_round, 1, 0, 0} | |
36 | }; | |
37 | JSObject * js_InitMathClass(JSContext *cx, JSObject *obj) { | |
38 | JSObject *Math; | |
39 | if (!JS_DefineFunctions(cx, Math, math_static_methods)) return ((void *)0); | |
40 | } |