]> git.wh0rd.org Git - ICEs.git/blob - 571482/jsxml.ii.4
more
[ICEs.git] / 571482 / jsxml.ii.4
1 typedef long unsigned int size_t;
2 typedef long int ptrdiff_t;
3 typedef unsigned int uint32_t;
4 typedef unsigned long int uint64_t;
5 typedef uint32_t JSUint32;
6 typedef uint64_t JSUint64;
7 typedef int JSIntn;
8 typedef unsigned int JSUintn;
9 typedef JSIntn JSBool;
10 typedef JSUint64 uint64;
11 typedef JSUint32 uint32;
12 typedef JSUintn uintN;
13 extern "C" {
14         typedef struct JSString JSString;
15         typedef struct JSObject JSObject;
16         typedef union jsval_layout {
17                 uint64 asBits;
18         } jsval_layout;
19         static jsval_layout STRING_TO_JSVAL_IMPL(JSString * str) {
20         } typedef __attribute__ ((aligned(8))) uint64 jsval;
21         typedef ptrdiff_t jsid;
22         typedef JSUint32 jsuint;
23         typedef enum JSType {
24                 JSTYPE_VOID, JSTYPE_OBJECT, JSTYPE_FUNCTION, JSTYPE_STRING,
25                     JSTYPE_NUMBER, JSTYPE_BOOLEAN, JSTYPE_NULL, JSTYPE_XML,
26                     JSTYPE_LIMIT
27         } JSType;
28         typedef enum JSAccessMode {
29                 JSACC_PROTO = 0, JSACC_PARENT = 1, JSACC_WATCH = 3, JSACC_READ =
30                     4, JSACC_WRITE = 8, JSACC_LIMIT
31         } JSIterateOp;
32         typedef struct JSContext JSContext;
33         typedef struct JSTracer JSTracer;
34         typedef struct JSXDRState JSXDRState;
35         typedef JSBool(*JSEnumerateOp) (JSContext * cx, JSObject * obj);
36         typedef JSBool(*JSResolveOp) (JSContext * cx, JSObject * obj, jsid id);
37         typedef void (*JSFinalizeOp) (JSContext * cx, JSObject * obj);
38         typedef JSBool(*JSXDRObjectOp) (JSXDRState * xdr, JSObject ** objp);
39         typedef uint32(*JSMarkOp) (JSContext * cx, JSObject * obj, void *arg);
40         static JSBool JSID_IS_STRING(jsid iden) {
41         }
42         static JSString *JSID_TO_STRING(jsid iden) {
43         }
44         typedef void (*JSClassInternal) ();
45         extern JSBool JS_PropertyStub(JSContext * cx, JSObject * obj, jsid id,
46                                       jsval * vp);
47         extern JSBool JS_StrictPropertyStub(JSContext * cx, JSObject * obj,
48                                             jsid id, JSBool strict, jsval * vp);
49         extern JSBool JS_EnumerateStub(JSContext * cx, JSObject * obj);
50         extern JSBool JS_ResolveStub(JSContext * cx, JSObject * obj, jsid id);
51         extern JSBool JS_ConvertStub(JSContext * cx, JSObject * obj,
52                                      JSType type, jsval * vp);
53         extern void JS_FinalizeStub(JSContext * cx, JSObject * obj);
54         typedef struct JSProperty JSProperty;
55         typedef struct JSLinearString JSLinearString;
56         typedef JSObject *(*JSObjectOp) (JSContext * cx, JSObject * obj);
57         typedef JSObject *(*JSIteratorOp) (JSContext * cx, JSObject * obj,
58                                            JSBool keysonly);
59 }
60
61 namespace js {
62         class Value {
63               public:void setNull() {
64                 } void setString(JSString * str) {
65                         data = STRING_TO_JSVAL_IMPL(str);
66                 } jsval_layout data;
67         }
68         __attribute__ ((aligned(8)));
69         static Value StringValue(JSString * str) {
70                 Value v;
71                 v.setString(str);
72                 return v;
73         }
74         static inline const jsval & Jsvalify(const Value & v) {
75                 return (const jsval &)v;
76         }
77         static inline Value *Valueify(jsval * v) {
78                 return (Value *) v;
79         }
80         typedef JSBool(*Native) (JSContext * cx, uintN argc, Value * vp);
81         typedef JSBool(*PropertyOp) (JSContext * cx, JSObject * obj, jsid id,
82                                      Value * vp);
83         typedef JSBool(*StrictPropertyOp) (JSContext * cx, JSObject * obj,
84                                            jsid id, JSBool strict, Value * vp);
85         typedef JSBool(*ConvertOp) (JSContext * cx, JSObject * obj, JSType type,
86                                     Value * vp);
87         typedef JSBool(*NewEnumerateOp) (JSContext * cx, JSObject * obj,
88                                          JSIterateOp enum_op, Value * statep,
89                                          jsid * idp);
90         typedef JSBool(*HasInstanceOp) (JSContext * cx, JSObject * obj,
91                                         const Value * v, JSBool * bp);
92         typedef JSBool(*CheckAccessOp) (JSContext * cx, JSObject * obj, jsid id,
93                                         JSAccessMode mode, Value * vp);
94         typedef JSBool(*EqualityOp) (JSContext * cx, JSObject * obj,
95                                      const Value * v, JSBool * bp);
96         typedef JSBool(*DefinePropOp) (JSContext * cx, JSObject * obj, jsid id,
97                                        const Value * value, PropertyOp getter,
98                                        StrictPropertyOp setter, uintN attrs);
99         typedef JSBool(*PropertyIdOp) (JSContext * cx, JSObject * obj,
100                                        JSObject * receiver, jsid id,
101                                        Value * vp);
102         typedef JSBool(*StrictPropertyIdOp) (JSContext * cx, JSObject * obj,
103                                              jsid id, Value * vp,
104                                              JSBool strict);
105         typedef JSBool(*DeleteIdOp) (JSContext * cx, JSObject * obj, jsid id,
106                                      Value * vp, JSBool strict);
107         typedef JSBool(*LookupPropOp) (JSContext * cx, JSObject * obj, jsid id,
108                                        JSObject ** objp, JSProperty ** propp);
109         typedef JSBool(*AttributesOp) (JSContext * cx, JSObject * obj, jsid id,
110                                        uintN * attrsp);
111         typedef JSType(*TypeOfOp) (JSContext * cx, JSObject * obj);
112         typedef void (*TraceOp) (JSTracer * trc, JSObject * obj);
113         typedef JSObject *(*ObjectOp) (JSContext * cx, JSObject * obj);
114         typedef void (*FinalizeOp) (JSContext * cx, JSObject * obj);
115         class AutoIdVector;
116         typedef JSBool(*FixOp) (JSContext * cx, JSObject * obj, bool * fixed,
117                                 AutoIdVector * props);
118         static const PropertyOp PropertyStub = (PropertyOp) JS_PropertyStub;
119         static const StrictPropertyOp StrictPropertyStub =
120             (StrictPropertyOp) JS_StrictPropertyStub;
121         static const JSEnumerateOp EnumerateStub = JS_EnumerateStub;
122         static const JSResolveOp ResolveStub = JS_ResolveStub;
123         static const ConvertOp ConvertStub = (ConvertOp) JS_ConvertStub;
124         static const JSFinalizeOp FinalizeStub = JS_FinalizeStub;
125         struct ClassExtension {
126                 EqualityOp equality;
127                 JSObjectOp outerObject;
128                 JSObjectOp innerObject;
129                 JSIteratorOp iteratorObject;
130                 void *unused;
131         };
132         struct ObjectOps {
133                 js::LookupPropOp lookupProperty;
134                 js::DefinePropOp defineProperty;
135                 js::PropertyIdOp getProperty;
136                 js::StrictPropertyIdOp setProperty;
137                 js::AttributesOp getAttributes;
138                 js::AttributesOp setAttributes;
139                 js::DeleteIdOp deleteProperty;
140                 js::NewEnumerateOp enumerate;
141                 js::TypeOfOp typeOf;
142                 js::TraceOp trace;
143                 js::FixOp fix;
144                 js::ObjectOp thisObject;
145                 js::FinalizeOp clear;
146         };
147         struct Class {
148                 const char *name;
149                 uint32 flags;
150                 PropertyOp addProperty;
151                 PropertyOp delProperty;
152                 PropertyOp getProperty;
153                 StrictPropertyOp setProperty;
154                 JSEnumerateOp enumerate;
155                 JSResolveOp resolve;
156                 ConvertOp convert;
157                 JSFinalizeOp finalize;
158                 JSClassInternal reserved0;
159                 CheckAccessOp checkAccess;
160                 Native call;
161                 Native construct;
162                 JSXDRObjectOp xdrObject;
163                 HasInstanceOp hasInstance;
164                 JSMarkOp mark;
165                 ClassExtension ext;
166                 ObjectOps ops;
167         };
168         namespace gc {
169                 struct Cell {
170                 };
171 }} struct JSObject:js::gc::Cell {
172         js::Class * getClass() const {
173         } static const uint32 QNAME_CLASS_RESERVED_SLOTS = 3;
174         inline JSLinearString *getNamePrefix() const;
175         inline JSLinearString *getNameURI() const;
176         inline JSLinearString *getQNameLocalName() const;
177 };
178 namespace js {
179         static Value IdToValue(jsid id) {
180                 if (JSID_IS_STRING(id))
181                         return StringValue(JSID_TO_STRING(id));
182         } static jsval IdToJsval(jsid id) {
183                 return Jsvalify(IdToValue(id));
184         }
185 }
186
187 extern const char js_AnyName_str[];
188 inline JSBool js_IdIsIndex(jsid id, jsuint * indexp)
189 {
190 }
191
192 namespace js {
193         class AutoGCRooter;
194 } struct JSContext {
195         js::AutoGCRooter * autoGCRooters;
196 };
197 namespace js {
198         class AutoGCRooter {
199               public:AutoGCRooter(JSContext * cx,
200                              ptrdiff_t tag):down(cx->autoGCRooters), tag(tag),
201                     context(cx) {
202                         cx->autoGCRooters = this;
203               } protected:AutoGCRooter * const down;
204                 ptrdiff_t tag;
205                 JSContext *const context;
206         };
207         class AutoArrayRooter:private AutoGCRooter {
208               public:AutoArrayRooter(JSContext * cx, size_t len,
209                                 Value * vec):AutoGCRooter(cx, len),
210                     array(vec) {
211                 } Value *array;
212       private:};
213 }
214
215 typedef enum JSXMLClass {
216         JSXML_CLASS_LIST, JSXML_CLASS_ELEMENT, JSXML_CLASS_ATTRIBUTE,
217             JSXML_CLASS_PROCESSING_INSTRUCTION, JSXML_CLASS_TEXT,
218             JSXML_CLASS_COMMENT, JSXML_CLASS_LIMIT
219 } JSXMLElemVar;
220 struct JSXML:js::gc::Cell {
221         uint32 xml_class;
222 };
223 using namespace js;
224 Class js_AttributeNameClass = {
225 __null,
226 0,
227 __null,
228 __null,
229 __null,
230 __null,
231 __null,
232 __null,
233 __null,
234 __null
235 };
236
237 static JSObject *NewXMLAttributeName(JSContext * cx, JSLinearString * uri,
238                                      JSLinearString * prefix,
239                                      JSLinearString * localName)
240 {
241 }
242
243 static JSBool PutProperty(JSContext * cx, JSObject * obj, jsid id,
244                           JSBool strict, jsval * vp)
245 {
246         enum {
247                 OBJ_ROOT, ID_ROOT, VAL_ROOT
248         };
249         JSXML *xml, *vxml, *rxml, *kid, *attr, *parent, *copy, *kid2, *match;
250         JSObject *vobj, *nameobj, *attrobj, *parentobj, *kidobj, *copyobj;
251         uint32 index, i, j, k, n, q, matchIndex;
252         jsval roots[3];
253         roots[ID_ROOT] = IdToJsval(id);
254         roots[VAL_ROOT] = *vp;
255         AutoArrayRooter tvr(cx, (sizeof(roots) / sizeof(roots)[0]),
256                             Valueify(roots));
257         if (js_IdIsIndex(id, &index)) {
258                 if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
259                         if (nameobj->getClass() != &js_AttributeNameClass) {
260                                 nameobj =
261                                     NewXMLAttributeName(cx,
262                                                         nameobj->getNameURI(),
263                                                         nameobj->
264                                                         getNamePrefix(),
265                                                         nameobj->
266                                                         getQNameLocalName());
267                         }
268                 }
269         }
270 }
271
272 static JSBool xml_defineProperty(JSContext * cx, JSObject * obj, jsid id,
273                                  const Value * v, PropertyOp getter,
274                                  StrictPropertyOp setter, uintN attrs)
275 {
276         jsval tmp = Jsvalify(*v);
277         return PutProperty(cx, obj, id, false, &tmp);
278 }
279
280 static void xml_trace(JSTracer * trc, JSObject * obj)
281 {
282 }
283
284 Class js_XMLClass = {
285         __null, 0, __null, __null, __null, __null, __null, __null, __null,
286             __null, __null, __null, __null, __null, __null, __null,
287 __null,
288  {                             __null, __null, __null, __null, __null}
289         , {
290            __null, xml_defineProperty, __null, __null, __null, __null, __null,
291            __null, __null, __null, __null, __null, __null}
292 };