1 typedef long unsigned int size_t;
3 } pthread_barrierattr_t;
4 typedef long int ptrdiff_t;
5 typedef unsigned int uint32_t;
6 typedef unsigned long int uint64_t;
7 typedef uint32_t JSUint32;
8 typedef uint64_t JSUint64;
10 typedef unsigned int JSUintn;
11 typedef JSIntn JSBool;
12 typedef JSUint64 uint64;
13 typedef JSUint32 uint32;
14 typedef JSUintn uintN;
17 } _IO_cookie_io_functions_t;
18 typedef struct JSString JSString;
19 typedef struct JSObject JSObject;
20 typedef union jsval_layout {
25 STRING_TO_JSVAL_IMPL(JSString * str) {
26 } typedef __attribute__ ((aligned(8))) uint64 jsval;
27 typedef ptrdiff_t jsid;
28 typedef JSUint32 jsuint;
30 JSTYPE_VOID, JSTYPE_OBJECT, JSTYPE_FUNCTION, JSTYPE_STRING,
31 JSTYPE_NUMBER, JSTYPE_BOOLEAN, JSTYPE_NULL, JSTYPE_XML,
34 typedef enum JSProtoKey {
35 JSProto_Null = 0, JSProto_Object = 1, JSProto_Function =
36 2, JSProto_Array = 3, JSProto_Boolean = 4, JSProto_JSON =
37 5, JSProto_Date = 6, JSProto_Math = 7, JSProto_Number =
38 8, JSProto_String = 9, JSProto_RegExp = 10, JSProto_XML =
39 11, JSProto_Namespace = 12, JSProto_QName =
40 13, JSProto_Reflect = 14, JSProto_ASTNode =
41 15, JSProto_Error = 16, JSProto_InternalError =
42 17, JSProto_EvalError = 18, JSProto_RangeError =
43 19, JSProto_ReferenceError = 20, JSProto_SyntaxError =
44 21, JSProto_TypeError = 22, JSProto_URIError =
45 23, JSProto_Generator = 24, JSProto_Iterator =
46 25, JSProto_StopIteration = 26, JSProto_ArrayBuffer =
47 27, JSProto_Int8Array = 28, JSProto_Uint8Array =
48 29, JSProto_Int16Array = 30, JSProto_Uint16Array =
49 31, JSProto_Int32Array = 32, JSProto_Uint32Array =
50 33, JSProto_Float32Array = 34, JSProto_Float64Array =
51 35, JSProto_Uint8ClampedArray = 36, JSProto_Proxy =
52 37, JSProto_AnyName = 38, JSProto_LIMIT
54 typedef enum JSAccessMode {
55 JSACC_PROTO = 0, JSACC_PARENT = 1, JSACC_WATCH = 3, JSACC_READ =
56 4, JSACC_WRITE = 8, JSACC_LIMIT
58 typedef struct JSContext JSContext;
59 typedef struct JSTracer JSTracer;
60 typedef struct JSXDRState JSXDRState;
61 typedef JSBool(*JSEnumerateOp) (JSContext * cx, JSObject * obj);
62 typedef JSBool(*JSResolveOp) (JSContext * cx, JSObject * obj, jsid id);
63 typedef void (*JSFinalizeOp) (JSContext * cx, JSObject * obj);
64 typedef JSBool(*JSXDRObjectOp) (JSXDRState * xdr, JSObject ** objp);
65 typedef uint32(*JSMarkOp) (JSContext * cx, JSObject * obj, void *arg);
67 JSBool JSID_IS_STRING(jsid
71 JSString *JSID_TO_STRING(jsid
75 typedef void (*JSClassInternal) ();
78 JS_PropertyStub(JSContext * cx, JSObject * obj, jsid id,
82 JS_StrictPropertyStub(JSContext * cx, JSObject * obj, jsid id,
83 JSBool strict, jsval * vp);
86 JS_EnumerateStub(JSContext * cx, JSObject * obj);
89 JS_ResolveStub(JSContext * cx, JSObject * obj, jsid id);
92 JS_ConvertStub(JSContext * cx, JSObject * obj, JSType type,
96 JS_FinalizeStub(JSContext * cx, JSObject * obj);
97 typedef struct JSProperty JSProperty;
98 typedef struct JSLinearString JSLinearString;
99 typedef JSObject *(*JSObjectOp) (JSContext * cx, JSObject * obj);
100 typedef JSObject *(*JSIteratorOp) (JSContext * cx, JSObject * obj,
110 void setString(JSString
112 data = STRING_TO_JSVAL_IMPL(str);
115 __attribute__ ((aligned(8)));
117 Value UndefinedValue() {
120 Value StringValue(JSString *
126 static inline const jsval & Jsvalify(const Value & v) {
127 return (const jsval &)v;
129 static inline Value *Valueify(jsval * v) {
132 typedef JSBool(*Native) (JSContext * cx, uintN argc, Value * vp);
133 typedef JSBool(*PropertyOp) (JSContext * cx, JSObject * obj, jsid id,
135 typedef JSBool(*StrictPropertyOp) (JSContext * cx, JSObject * obj,
136 jsid id, JSBool strict, Value * vp);
137 typedef JSBool(*ConvertOp) (JSContext * cx, JSObject * obj, JSType type,
139 typedef JSBool(*NewEnumerateOp) (JSContext * cx, JSObject * obj,
140 JSIterateOp enum_op, Value * statep,
142 typedef JSBool(*HasInstanceOp) (JSContext * cx, JSObject * obj,
143 const Value * v, JSBool * bp);
144 typedef JSBool(*CheckAccessOp) (JSContext * cx, JSObject * obj, jsid id,
145 JSAccessMode mode, Value * vp);
146 typedef JSBool(*EqualityOp) (JSContext * cx, JSObject * obj,
147 const Value * v, JSBool * bp);
148 typedef JSBool(*DefinePropOp) (JSContext * cx, JSObject * obj, jsid id,
149 const Value * value, PropertyOp getter,
150 StrictPropertyOp setter, uintN attrs);
151 typedef JSBool(*PropertyIdOp) (JSContext * cx, JSObject * obj,
152 JSObject * receiver, jsid id,
154 typedef JSBool(*StrictPropertyIdOp) (JSContext * cx, JSObject * obj,
157 typedef JSBool(*DeleteIdOp) (JSContext * cx, JSObject * obj, jsid id,
158 Value * vp, JSBool strict);
159 typedef JSBool(*LookupPropOp) (JSContext * cx, JSObject * obj, jsid id,
160 JSObject ** objp, JSProperty ** propp);
161 typedef JSBool(*AttributesOp) (JSContext * cx, JSObject * obj, jsid id,
163 typedef JSType(*TypeOfOp) (JSContext * cx, JSObject * obj);
164 typedef void (*TraceOp) (JSTracer * trc, JSObject * obj);
165 typedef JSObject *(*ObjectOp) (JSContext * cx, JSObject * obj);
166 typedef void (*FinalizeOp) (JSContext * cx, JSObject * obj);
168 typedef JSBool(*FixOp) (JSContext * cx, JSObject * obj, bool * fixed,
169 AutoIdVector * props);
170 static const PropertyOp PropertyStub = (PropertyOp) JS_PropertyStub;
171 static const StrictPropertyOp StrictPropertyStub =
172 (StrictPropertyOp) JS_StrictPropertyStub;
173 static const JSEnumerateOp EnumerateStub = JS_EnumerateStub;
174 static const JSResolveOp ResolveStub = JS_ResolveStub;
175 static const ConvertOp ConvertStub = (ConvertOp) JS_ConvertStub;
176 static const JSFinalizeOp FinalizeStub = JS_FinalizeStub;
177 struct ClassExtension {
179 JSObjectOp outerObject;
180 JSObjectOp innerObject;
181 JSIteratorOp iteratorObject;
185 js::LookupPropOp lookupProperty;
186 js::DefinePropOp defineProperty;
187 js::PropertyIdOp getProperty;
188 js::StrictPropertyIdOp setProperty;
189 js::AttributesOp getAttributes;
190 js::AttributesOp setAttributes;
191 js::DeleteIdOp deleteProperty;
192 js::NewEnumerateOp enumerate;
196 js::ObjectOp thisObject;
197 js::FinalizeOp clear;
202 PropertyOp addProperty;
203 PropertyOp delProperty;
204 PropertyOp getProperty;
205 StrictPropertyOp setProperty;
206 JSEnumerateOp enumerate;
209 JSFinalizeOp finalize;
210 JSClassInternal reserved0;
211 CheckAccessOp checkAccess;
214 JSXDRObjectOp xdrObject;
215 HasInstanceOp hasInstance;
223 }} struct JSObject:js::gc::Cell {
224 js::Class * getClass() const {
225 } static const uint32 QNAME_CLASS_RESERVED_SLOTS = 3;
226 inline JSLinearString *getNamePrefix() const;
227 inline JSLinearString *getNameURI() const;
228 inline JSLinearString *getQNameLocalName() const;
232 Value IdToValue(jsid id) {
233 if (JSID_IS_STRING(id))
234 return StringValue(JSID_TO_STRING(id));
236 jsval IdToJsval(jsid id) {
237 return Jsvalify(IdToValue(id));
241 extern const char js_XML_str[];
242 extern const char js_AnyName_str[];
243 inline JSBool js_IdIsIndex(jsid id, jsuint * indexp)
250 js::AutoGCRooter * autoGCRooters;
254 public:AutoGCRooter(JSContext * cx,
255 ptrdiff_t tag):down(cx->autoGCRooters), tag(tag),
257 cx->autoGCRooters = this;
258 } protected:AutoGCRooter * const down;
260 JSContext *const context;
262 class AutoArrayRooter:private AutoGCRooter {
263 public:AutoArrayRooter(JSContext * cx, size_t len,
264 Value * vec):AutoGCRooter(cx, len),
272 struct JSXMLArrayCursor {
274 typedef enum JSXMLClass {
275 JSXML_CLASS_LIST, JSXML_CLASS_ELEMENT, JSXML_CLASS_ATTRIBUTE,
276 JSXML_CLASS_PROCESSING_INSTRUCTION, JSXML_CLASS_TEXT,
277 JSXML_CLASS_COMMENT, JSXML_CLASS_LIMIT
279 struct JSXML:js::gc::Cell {
283 } using namespace js;
284 Class js_AttributeNameClass = {
287 (((JSObject::QNAME_CLASS_RESERVED_SLOTS) & (((JSUint32) 1 << (8)) -
288 1)) << 8) | (1 << ((8 +
291 (1 << ((8 + 8) + 1)), PropertyStub, PropertyStub, PropertyStub,
292 StrictPropertyStub, EnumerateStub, ResolveStub, ConvertStub,
296 static JSObject *NewXMLAttributeName(JSContext * cx, JSLinearString * uri,
297 JSLinearString * prefix,
298 JSLinearString * localName)
302 static JSBool GetXMLSettingFlags(JSContext * cx, uintN * flagsp)
305 for (size_t n = 0; n < 4; ++n)
307 *flagsp |= ((JSUint32) 1 << (n));
310 static JSBool PutProperty(JSContext * cx, JSObject * obj, jsid id,
311 JSBool strict, jsval * vp)
314 OBJ_ROOT, ID_ROOT, VAL_ROOT
316 JSXML *xml, *vxml, *rxml, *kid, *attr, *parent, *copy, *kid2, *match;
317 JSObject *vobj, *nameobj, *attrobj, *parentobj, *kidobj, *copyobj;
318 uint32 index, i, j, k, n, q, matchIndex;
320 roots[ID_ROOT] = IdToJsval(id);
321 roots[VAL_ROOT] = *vp;
322 AutoArrayRooter tvr(cx, (sizeof(roots) / sizeof(roots)[0]),
324 if (js_IdIsIndex(id, &index)) {
325 if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
326 if (nameobj->getClass() != &js_AttributeNameClass) {
328 NewXMLAttributeName(cx,
329 nameobj->getNameURI(),
333 getQNameLocalName());
339 static void xml_finalize(JSContext * cx, JSObject * obj)
343 static JSBool xml_lookupProperty(JSContext * cx, JSObject * obj, jsid id,
344 JSObject ** objp, JSProperty ** propp)
348 static JSBool xml_defineProperty(JSContext * cx, JSObject * obj, jsid id,
349 const Value * v, PropertyOp getter,
350 StrictPropertyOp setter, uintN attrs)
352 jsval tmp = Jsvalify(*v);
353 return PutProperty(cx, obj, id, false, &tmp);
356 static JSBool xml_getProperty(JSContext * cx, JSObject * obj,
357 JSObject * receiver, jsid id, Value * vp)
361 static JSBool xml_setProperty(JSContext * cx, JSObject * obj, jsid id,
362 Value * vp, JSBool strict)
366 static JSBool xml_getAttributes(JSContext * cx, JSObject * obj, jsid id,
371 static JSBool xml_setAttributes(JSContext * cx, JSObject * obj, jsid id,
376 static JSBool xml_deleteProperty(JSContext * cx, JSObject * obj, jsid id,
377 Value * rval, JSBool strict)
381 JSBool xml_convert(JSContext * cx, JSObject * obj, JSType type, Value * rval)
385 static JSBool xml_enumerate(JSContext * cx, JSObject * obj, JSIterateOp enum_op,
386 Value * statep, jsid * idp)
390 static JSType xml_typeOf(JSContext * cx, JSObject * obj)
394 static JSBool xml_hasInstance(JSContext * cx, JSObject * obj, const Value *,
399 static void xml_trace(JSTracer * trc, JSObject * obj)
403 static JSBool xml_fix(JSContext * cx, JSObject * obj, bool * success,
404 AutoIdVector * props)
408 static void xml_clear(JSContext * cx, JSObject * obj)
412 Class js_XMLClass = {
424 __null, __null, __null, __null,
426 ((JSMarkOp) (xml_trace)), {
427 __null, __null, __null, __null, __null}