]>
Commit | Line | Data |
---|---|---|
bd3239d2 MF |
1 | typedef union jsval_layout { |
2 | long int asBits; | |
3 | } jsval_layout; | |
4 | static jsval_layout STRING_TO_JSVAL_IMPL(void *str) | |
5 | {} | |
6 | ||
7 | typedef __attribute__ ((aligned(8))) unsigned long int jsval; | |
8 | class Value { | |
9 | public:void setString() | |
10 | { | |
11 | data = STRING_TO_JSVAL_IMPL(0); | |
12 | } jsval_layout data; | |
13 | } __attribute__ ((aligned(8))); | |
14 | ||
15 | static Value StringValue() { | |
16 | Value v; | |
17 | v.setString(); | |
18 | return v; | |
19 | } | |
20 | static const jsval & Jsvalify(const Value & v) { | |
21 | return (const jsval &)v; | |
22 | } | |
23 | static Value *Valueify(jsval * v) { | |
24 | return (Value *) v; | |
25 | } | |
26 | ||
27 | struct JSObject { | |
28 | void getQNameLocalName(); | |
29 | }; | |
30 | static Value IdToValue(int id) { | |
31 | if (id) | |
32 | return StringValue(); | |
33 | } | |
34 | static jsval IdToJsval(int id) { | |
35 | return Jsvalify(IdToValue(id)); | |
36 | } | |
37 | ||
38 | class AutoGCRooter; | |
39 | struct JSContext { | |
40 | AutoGCRooter *autoGCRooters; | |
41 | }; | |
42 | ||
43 | class AutoGCRooter { | |
44 | public: | |
45 | AutoGCRooter(JSContext * cx | |
46 | ):down(cx->autoGCRooters), | |
47 | context(cx) { | |
48 | cx->autoGCRooters = this; | |
49 | } | |
50 | protected: | |
51 | AutoGCRooter * const down; | |
52 | JSContext *const context; | |
53 | }; | |
54 | class AutoArrayRooter: | |
55 | private AutoGCRooter { | |
56 | public: | |
57 | AutoArrayRooter(JSContext *cx, | |
58 | Value *vec): AutoGCRooter(cx), | |
59 | array(vec) { | |
60 | } Value *array; | |
61 | }; | |
62 | ||
63 | static void PutProperty(JSContext *cx, int id, jsval *vp) | |
64 | { | |
65 | JSObject *nameobj; | |
66 | jsval roots[3]; | |
67 | roots[1] = IdToJsval(id); | |
68 | roots[2] = *vp; | |
69 | AutoArrayRooter tvr(cx, Valueify(roots)); | |
70 | nameobj->getQNameLocalName(); | |
71 | } | |
72 | ||
73 | void xml_defineProperty(JSContext *cx, int id, const Value *v) | |
74 | { | |
75 | jsval tmp = Jsvalify(*v); | |
76 | PutProperty(cx, id, &tmp); | |
77 | } |