1 typedef long unsigned int size_t;
5 } pthread_barrierattr_t;
6 }} typedef long int ptrdiff_t;
7 typedef unsigned int uint32_t;
8 typedef unsigned long int uint64_t;
9 typedef uint32_t JSUint32;
10 typedef uint64_t JSUint64;
13 typedef unsigned int JSUintn;
14 typedef JSIntn JSBool;
15 typedef JSUint64 uint64;
16 typedef JSUint32 uint32;
17 } typedef JSUintn uintN;
20 } _IO_cookie_io_functions_t;
21 typedef struct JSString JSString;
22 typedef struct JSObject JSObject;
23 typedef union jsval_layout {
27 __attribute__ ((always_inline)) inline jsval_layout
28 STRING_TO_JSVAL_IMPL(JSString * str) {
29 } typedef __attribute__ ((aligned(8))) uint64 jsval;
30 typedef ptrdiff_t jsid;
31 typedef JSUint32 jsuint;
33 JSTYPE_VOID, JSTYPE_OBJECT, JSTYPE_FUNCTION, JSTYPE_STRING,
34 JSTYPE_NUMBER, JSTYPE_BOOLEAN, JSTYPE_NULL, JSTYPE_XML,
37 typedef enum JSProtoKey {
38 JSProto_Null = 0, JSProto_Object = 1, JSProto_Function =
39 2, JSProto_Array = 3, JSProto_Boolean = 4, JSProto_JSON =
40 5, JSProto_Date = 6, JSProto_Math = 7, JSProto_Number =
41 8, JSProto_String = 9, JSProto_RegExp = 10, JSProto_XML =
42 11, JSProto_Namespace = 12, JSProto_QName =
43 13, JSProto_Reflect = 14, JSProto_ASTNode =
44 15, JSProto_Error = 16, JSProto_InternalError =
45 17, JSProto_EvalError = 18, JSProto_RangeError =
46 19, JSProto_ReferenceError = 20, JSProto_SyntaxError =
47 21, JSProto_TypeError = 22, JSProto_URIError =
48 23, JSProto_Generator = 24, JSProto_Iterator =
49 25, JSProto_StopIteration = 26, JSProto_ArrayBuffer =
50 27, JSProto_Int8Array = 28, JSProto_Uint8Array =
51 29, JSProto_Int16Array = 30, JSProto_Uint16Array =
52 31, JSProto_Int32Array = 32, JSProto_Uint32Array =
53 33, JSProto_Float32Array = 34, JSProto_Float64Array =
54 35, JSProto_Uint8ClampedArray = 36, JSProto_Proxy =
55 37, JSProto_AnyName = 38, JSProto_LIMIT
57 typedef enum JSAccessMode {
58 JSACC_PROTO = 0, JSACC_PARENT = 1, JSACC_WATCH = 3, JSACC_READ =
59 4, JSACC_WRITE = 8, JSACC_LIMIT
61 typedef struct JSContext JSContext;
62 typedef struct JSTracer JSTracer;
63 typedef struct JSXDRState JSXDRState;
64 typedef JSBool(*JSEnumerateOp) (JSContext * cx, JSObject * obj);
65 typedef JSBool(*JSResolveOp) (JSContext * cx, JSObject * obj, jsid id);
66 typedef void (*JSFinalizeOp) (JSContext * cx, JSObject * obj);
67 typedef JSBool(*JSXDRObjectOp) (JSXDRState * xdr, JSObject ** objp);
68 typedef uint32(*JSMarkOp) (JSContext * cx, JSObject * obj, void *arg);
70 __attribute__ ((always_inline)) inline JSBool JSID_IS_STRING(jsid
74 __attribute__ ((always_inline)) inline JSString *JSID_TO_STRING(jsid
78 typedef void (*JSClassInternal) ();
80 __attribute__ ((visibility("default"))) JSBool
81 JS_PropertyStub(JSContext * cx, JSObject * obj, jsid id,
84 __attribute__ ((visibility("default"))) JSBool
85 JS_StrictPropertyStub(JSContext * cx, JSObject * obj, jsid id,
86 JSBool strict, jsval * vp);
88 __attribute__ ((visibility("default"))) JSBool
89 JS_EnumerateStub(JSContext * cx, JSObject * obj);
91 __attribute__ ((visibility("default"))) JSBool
92 JS_ResolveStub(JSContext * cx, JSObject * obj, jsid id);
94 __attribute__ ((visibility("default"))) JSBool
95 JS_ConvertStub(JSContext * cx, JSObject * obj, JSType type,
98 __attribute__ ((visibility("default"))) void
99 JS_FinalizeStub(JSContext * cx, JSObject * obj);
100 typedef struct JSProperty JSProperty;
101 typedef struct JSLinearString JSLinearString;
102 typedef JSObject *(*JSObjectOp) (JSContext * cx, JSObject * obj);
103 typedef JSObject *(*JSIteratorOp) (JSContext * cx, JSObject * obj,
109 public:__attribute__ ((always_inline)) inline void setNull()
111 } __attribute__ ((always_inline)) inline void setString(JSString
113 data = STRING_TO_JSVAL_IMPL(str);
116 __attribute__ ((aligned(8)));
117 static __attribute__ ((always_inline)) inline Value UndefinedValue() {
120 __attribute__ ((always_inline)) inline 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;
231 static __attribute__ ((always_inline)) inline Value IdToValue(jsid id) {
232 if (JSID_IS_STRING(id))
233 return StringValue(JSID_TO_STRING(id));
234 } static __attribute__ ((always_inline)) inline jsval IdToJsval(jsid id) {
235 return Jsvalify(IdToValue(id));
239 extern const char js_XML_str[];
240 extern const char js_AnyName_str[];
241 inline JSBool js_IdIsIndex(jsid id, jsuint * indexp)
248 js::AutoGCRooter * autoGCRooters;
252 public:AutoGCRooter(JSContext * cx,
253 ptrdiff_t tag):down(cx->autoGCRooters), tag(tag),
255 cx->autoGCRooters = this;
256 } protected:AutoGCRooter * const down;
258 JSContext *const context;
260 class AutoArrayRooter:private AutoGCRooter {
261 public:AutoArrayRooter(JSContext * cx, size_t len,
262 Value * vec):AutoGCRooter(cx, len),
270 struct JSXMLArrayCursor {
272 typedef enum JSXMLClass {
273 JSXML_CLASS_LIST, JSXML_CLASS_ELEMENT, JSXML_CLASS_ATTRIBUTE,
274 JSXML_CLASS_PROCESSING_INSTRUCTION, JSXML_CLASS_TEXT,
275 JSXML_CLASS_COMMENT, JSXML_CLASS_LIMIT
277 struct JSXML:js::gc::Cell {
281 } using namespace js;
282 __attribute__ ((visibility("default")))
283 Class js_AttributeNameClass = {
286 (((JSObject::QNAME_CLASS_RESERVED_SLOTS) & (((JSUint32) 1 << (8)) -
287 1)) << 8) | (1 << ((8 +
290 (1 << ((8 + 8) + 1)), PropertyStub, PropertyStub, PropertyStub,
291 StrictPropertyStub, EnumerateStub, ResolveStub, ConvertStub,
295 static JSObject *NewXMLAttributeName(JSContext * cx, JSLinearString * uri,
296 JSLinearString * prefix,
297 JSLinearString * localName)
301 static JSBool GetXMLSettingFlags(JSContext * cx, uintN * flagsp)
304 for (size_t n = 0; n < 4; ++n)
306 *flagsp |= ((JSUint32) 1 << (n));
309 static JSBool PutProperty(JSContext * cx, JSObject * obj, jsid id,
310 JSBool strict, jsval * vp)
313 OBJ_ROOT, ID_ROOT, VAL_ROOT
315 JSXML *xml, *vxml, *rxml, *kid, *attr, *parent, *copy, *kid2, *match;
316 JSObject *vobj, *nameobj, *attrobj, *parentobj, *kidobj, *copyobj;
317 uint32 index, i, j, k, n, q, matchIndex;
319 roots[ID_ROOT] = IdToJsval(id);
320 roots[VAL_ROOT] = *vp;
321 AutoArrayRooter tvr(cx, (sizeof(roots) / sizeof(roots)[0]),
323 if (js_IdIsIndex(id, &index)) {
324 if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
325 if (nameobj->getClass() != &js_AttributeNameClass) {
327 NewXMLAttributeName(cx,
328 nameobj->getNameURI(),
332 getQNameLocalName());
338 static void xml_finalize(JSContext * cx, JSObject * obj)
342 static JSBool xml_lookupProperty(JSContext * cx, JSObject * obj, jsid id,
343 JSObject ** objp, JSProperty ** propp)
347 static JSBool xml_defineProperty(JSContext * cx, JSObject * obj, jsid id,
348 const Value * v, PropertyOp getter,
349 StrictPropertyOp setter, uintN attrs)
351 jsval tmp = Jsvalify(*v);
352 return PutProperty(cx, obj, id, false, &tmp);
355 static JSBool xml_getProperty(JSContext * cx, JSObject * obj,
356 JSObject * receiver, jsid id, Value * vp)
360 static JSBool xml_setProperty(JSContext * cx, JSObject * obj, jsid id,
361 Value * vp, JSBool strict)
365 static JSBool xml_getAttributes(JSContext * cx, JSObject * obj, jsid id,
370 static JSBool xml_setAttributes(JSContext * cx, JSObject * obj, jsid id,
375 static JSBool xml_deleteProperty(JSContext * cx, JSObject * obj, jsid id,
376 Value * rval, JSBool strict)
380 JSBool xml_convert(JSContext * cx, JSObject * obj, JSType type, Value * rval)
384 static JSBool xml_enumerate(JSContext * cx, JSObject * obj, JSIterateOp enum_op,
385 Value * statep, jsid * idp)
389 static JSType xml_typeOf(JSContext * cx, JSObject * obj)
393 static JSBool xml_hasInstance(JSContext * cx, JSObject * obj, const Value *,
398 static void xml_trace(JSTracer * trc, JSObject * obj)
402 static JSBool xml_fix(JSContext * cx, JSObject * obj, bool * success,
403 AutoIdVector * props)
407 static void xml_clear(JSContext * cx, JSObject * obj)
411 __attribute__ ((visibility("default")))
412 Class js_XMLClass = {
414 (1 << 0) | (1 << ((8 + 8) + 3)) | ((JSProto_XML) << ((8 + 8) + 8)),
415 PropertyStub, PropertyStub, PropertyStub, StrictPropertyStub,
416 EnumerateStub, ResolveStub, xml_convert, xml_finalize, __null,
417 __null, __null, __null, __null, xml_hasInstance,
418 ((JSMarkOp) (xml_trace)), {
419 __null, __null, __null, __null, __null}
421 xml_lookupProperty, xml_defineProperty, xml_getProperty,
422 xml_setProperty, xml_getAttributes, xml_setAttributes,
423 xml_deleteProperty, xml_enumerate, xml_typeOf, __null, xml_fix,