]> git.wh0rd.org - ICEs.git/blob - 571482/jsxml.ii.5
more
[ICEs.git] / 571482 / jsxml.ii.5
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 typedef struct JSProperty JSProperty;
46 typedef struct JSLinearString JSLinearString;
47 typedef JSObject *(*JSObjectOp) (JSContext * cx, JSObject * obj);
48 typedef JSObject *(*JSIteratorOp) (JSContext * cx, JSObject * obj,
49 JSBool keysonly);
50 }
51
52 namespace js {
53 class Value {
54 public:void setNull() {
55 } void setString(JSString * str) {
56 data = STRING_TO_JSVAL_IMPL(str);
57 } jsval_layout data;
58 }
59 __attribute__ ((aligned(8)));
60 static Value StringValue(JSString * str) {
61 Value v;
62 v.setString(str);
63 return v;
64 }
65 static inline const jsval & Jsvalify(const Value & v) {
66 return (const jsval &)v;
67 }
68 static inline Value *Valueify(jsval * v) {
69 return (Value *) v;
70 }
71 typedef JSBool(*Native) (JSContext * cx, uintN argc, Value * vp);
72 typedef JSBool(*PropertyOp) (JSContext * cx, JSObject * obj, jsid id,
73 Value * vp);
74 typedef JSBool(*StrictPropertyOp) (JSContext * cx, JSObject * obj,
75 jsid id, JSBool strict, Value * vp);
76 typedef JSBool(*ConvertOp) (JSContext * cx, JSObject * obj, JSType type,
77 Value * vp);
78 typedef JSBool(*NewEnumerateOp) (JSContext * cx, JSObject * obj,
79 JSIterateOp enum_op, Value * statep,
80 jsid * idp);
81 typedef JSBool(*HasInstanceOp) (JSContext * cx, JSObject * obj,
82 const Value * v, JSBool * bp);
83 typedef JSBool(*CheckAccessOp) (JSContext * cx, JSObject * obj, jsid id,
84 JSAccessMode mode, Value * vp);
85 typedef JSBool(*EqualityOp) (JSContext * cx, JSObject * obj,
86 const Value * v, JSBool * bp);
87 typedef JSBool(*DefinePropOp) (JSContext * cx, JSObject * obj, jsid id,
88 const Value * value, PropertyOp getter,
89 StrictPropertyOp setter, uintN attrs);
90 typedef JSBool(*PropertyIdOp) (JSContext * cx, JSObject * obj,
91 JSObject * receiver, jsid id,
92 Value * vp);
93 typedef JSBool(*StrictPropertyIdOp) (JSContext * cx, JSObject * obj,
94 jsid id, Value * vp,
95 JSBool strict);
96 typedef JSBool(*DeleteIdOp) (JSContext * cx, JSObject * obj, jsid id,
97 Value * vp, JSBool strict);
98 typedef JSBool(*LookupPropOp) (JSContext * cx, JSObject * obj, jsid id,
99 JSObject ** objp, JSProperty ** propp);
100 typedef JSBool(*AttributesOp) (JSContext * cx, JSObject * obj, jsid id,
101 uintN * attrsp);
102 typedef JSType(*TypeOfOp) (JSContext * cx, JSObject * obj);
103 typedef void (*TraceOp) (JSTracer * trc, JSObject * obj);
104 typedef JSObject *(*ObjectOp) (JSContext * cx, JSObject * obj);
105 typedef void (*FinalizeOp) (JSContext * cx, JSObject * obj);
106 class AutoIdVector;
107 typedef JSBool(*FixOp) (JSContext * cx, JSObject * obj, bool * fixed,
108 AutoIdVector * props);
109 struct ClassExtension {
110 EqualityOp equality;
111 JSObjectOp outerObject;
112 JSObjectOp innerObject;
113 JSIteratorOp iteratorObject;
114 void *unused;
115 };
116 struct ObjectOps {
117 js::LookupPropOp lookupProperty;
118 js::DefinePropOp defineProperty;
119 js::PropertyIdOp getProperty;
120 js::StrictPropertyIdOp setProperty;
121 js::AttributesOp getAttributes;
122 js::AttributesOp setAttributes;
123 js::DeleteIdOp deleteProperty;
124 js::NewEnumerateOp enumerate;
125 js::TypeOfOp typeOf;
126 js::TraceOp trace;
127 js::FixOp fix;
128 js::ObjectOp thisObject;
129 js::FinalizeOp clear;
130 };
131 struct Class {
132 const char *name;
133 uint32 flags;
134 PropertyOp addProperty;
135 PropertyOp delProperty;
136 PropertyOp getProperty;
137 StrictPropertyOp setProperty;
138 JSEnumerateOp enumerate;
139 JSResolveOp resolve;
140 ConvertOp convert;
141 JSFinalizeOp finalize;
142 JSClassInternal reserved0;
143 CheckAccessOp checkAccess;
144 Native call;
145 Native construct;
146 JSXDRObjectOp xdrObject;
147 HasInstanceOp hasInstance;
148 JSMarkOp mark;
149 ClassExtension ext;
150 ObjectOps ops;
151 };
152 namespace gc {
153 struct Cell {
154 };
155 }} struct JSObject:js::gc::Cell {
156 js::Class * getClass() const {
157 } inline JSLinearString *getNamePrefix() const;
158 inline JSLinearString *getNameURI() const;
159 inline JSLinearString *getQNameLocalName() const;
160 };
161 namespace js {
162 static Value IdToValue(jsid id) {
163 if (JSID_IS_STRING(id))
164 return StringValue(JSID_TO_STRING(id));
165 } static jsval IdToJsval(jsid id) {
166 return Jsvalify(IdToValue(id));
167 }
168 }
169
170 inline JSBool js_IdIsIndex(jsid id, jsuint * indexp)
171 {
172 }
173
174 namespace js {
175 class AutoGCRooter;
176 } struct JSContext {
177 js::AutoGCRooter * autoGCRooters;
178 };
179 namespace js {
180 class AutoGCRooter {
181 public:AutoGCRooter(JSContext * cx,
182 ptrdiff_t tag):down(cx->autoGCRooters), tag(tag),
183 context(cx) {
184 cx->autoGCRooters = this;
185 } protected:AutoGCRooter * const down;
186 ptrdiff_t tag;
187 JSContext *const context;
188 };
189 class AutoArrayRooter:private AutoGCRooter {
190 public:AutoArrayRooter(JSContext * cx, size_t len,
191 Value * vec):AutoGCRooter(cx, len),
192 array(vec) {
193 } Value *array;
194 private:};
195 }
196
197 typedef enum JSXMLClass {
198 JSXML_CLASS_LIST, JSXML_CLASS_ELEMENT, JSXML_CLASS_ATTRIBUTE,
199 JSXML_CLASS_PROCESSING_INSTRUCTION, JSXML_CLASS_TEXT,
200 JSXML_CLASS_COMMENT, JSXML_CLASS_LIMIT
201 } JSXMLElemVar;
202 struct JSXML:js::gc::Cell {
203 uint32 xml_class;
204 };
205 using namespace js;
206 Class js_AttributeNameClass;
207
208 static JSObject *NewXMLAttributeName(JSContext * cx, JSLinearString * uri,
209 JSLinearString * prefix,
210 JSLinearString * localName)
211 {
212 }
213
214 static JSBool PutProperty(JSContext * cx, JSObject * obj, jsid id,
215 JSBool strict, jsval * vp)
216 {
217 enum {
218 OBJ_ROOT,
219 ID_ROOT, VAL_ROOT
220 };
221 JSXML *xml, *vxml, *rxml, *kid, *attr, *parent, *copy, *kid2, *match;
222 JSObject *vobj, *nameobj, *attrobj, *parentobj, *kidobj, *copyobj;
223 uint32 index, i, j, k, n, q, matchIndex;
224 jsval roots[3];
225 roots[ID_ROOT] = IdToJsval(id);
226 roots[VAL_ROOT] = *vp;
227 AutoArrayRooter tvr(cx, (sizeof(roots) / sizeof(roots)[0]),
228 Valueify(roots));
229 if (js_IdIsIndex(id, &index)) {
230 if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
231 if (nameobj->getClass() != &js_AttributeNameClass) {
232 nameobj =
233 NewXMLAttributeName(cx,
234 nameobj->getNameURI(),
235 nameobj->
236 getNamePrefix(),
237 nameobj->
238 getQNameLocalName());
239 }
240 }
241 }
242 }
243
244 JSBool xml_defineProperty(JSContext * cx, JSObject * obj, jsid id,
245 const Value * v)
246 {
247 jsval tmp = Jsvalify(*v);
248 return PutProperty(cx, obj, id, false, &tmp);
249 }