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;
8 typedef unsigned int JSUintn;
10 typedef JSUint64 uint64;
11 typedef JSUint32 uint32;
12 typedef JSUintn uintN;
14 typedef struct JSString JSString;
15 typedef struct JSObject JSObject;
16 typedef union 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;
24 JSTYPE_VOID, JSTYPE_OBJECT, JSTYPE_FUNCTION, JSTYPE_STRING,
25 JSTYPE_NUMBER, JSTYPE_BOOLEAN, JSTYPE_NULL, JSTYPE_XML,
28 typedef enum JSAccessMode {
29 JSACC_PROTO = 0, JSACC_PARENT = 1, JSACC_WATCH = 3, JSACC_READ =
30 4, JSACC_WRITE = 8, JSACC_LIMIT
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) {
42 static JSString *JSID_TO_STRING(jsid iden) {
44 typedef void (*JSClassInternal) ();
45 extern JSBool JS_PropertyStub(JSContext * cx, JSObject * obj, jsid id,
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,
63 public:void setNull() {
64 } void setString(JSString * str) {
65 data = STRING_TO_JSVAL_IMPL(str);
68 __attribute__ ((aligned(8)));
69 static Value StringValue(JSString * str) {
74 static inline const jsval & Jsvalify(const Value & v) {
75 return (const jsval &)v;
77 static inline Value *Valueify(jsval * v) {
80 typedef JSBool(*Native) (JSContext * cx, uintN argc, Value * vp);
81 typedef JSBool(*PropertyOp) (JSContext * cx, JSObject * obj, jsid id,
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,
87 typedef JSBool(*NewEnumerateOp) (JSContext * cx, JSObject * obj,
88 JSIterateOp enum_op, Value * statep,
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,
102 typedef JSBool(*StrictPropertyIdOp) (JSContext * cx, JSObject * obj,
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,
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);
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 {
127 JSObjectOp outerObject;
128 JSObjectOp innerObject;
129 JSIteratorOp iteratorObject;
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;
144 js::ObjectOp thisObject;
145 js::FinalizeOp clear;
150 PropertyOp addProperty;
151 PropertyOp delProperty;
152 PropertyOp getProperty;
153 StrictPropertyOp setProperty;
154 JSEnumerateOp enumerate;
157 JSFinalizeOp finalize;
158 JSClassInternal reserved0;
159 CheckAccessOp checkAccess;
162 JSXDRObjectOp xdrObject;
163 HasInstanceOp hasInstance;
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;
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));
187 extern const char js_AnyName_str[];
188 inline JSBool js_IdIsIndex(jsid id, jsuint * indexp)
195 js::AutoGCRooter * autoGCRooters;
199 public:AutoGCRooter(JSContext * cx,
200 ptrdiff_t tag):down(cx->autoGCRooters), tag(tag),
202 cx->autoGCRooters = this;
203 } protected:AutoGCRooter * const down;
205 JSContext *const context;
207 class AutoArrayRooter:private AutoGCRooter {
208 public:AutoArrayRooter(JSContext * cx, size_t len,
209 Value * vec):AutoGCRooter(cx, len),
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
220 struct JSXML:js::gc::Cell {
224 Class js_AttributeNameClass = {
237 static JSObject *NewXMLAttributeName(JSContext * cx, JSLinearString * uri,
238 JSLinearString * prefix,
239 JSLinearString * localName)
243 static JSBool PutProperty(JSContext * cx, JSObject * obj, jsid id,
244 JSBool strict, jsval * vp)
247 OBJ_ROOT, ID_ROOT, VAL_ROOT
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;
253 roots[ID_ROOT] = IdToJsval(id);
254 roots[VAL_ROOT] = *vp;
255 AutoArrayRooter tvr(cx, (sizeof(roots) / sizeof(roots)[0]),
257 if (js_IdIsIndex(id, &index)) {
258 if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
259 if (nameobj->getClass() != &js_AttributeNameClass) {
261 NewXMLAttributeName(cx,
262 nameobj->getNameURI(),
266 getQNameLocalName());
272 static JSBool xml_defineProperty(JSContext * cx, JSObject * obj, jsid id,
273 const Value * v, PropertyOp getter,
274 StrictPropertyOp setter, uintN attrs)
276 jsval tmp = Jsvalify(*v);
277 return PutProperty(cx, obj, id, false, &tmp);
280 static void xml_trace(JSTracer * trc, JSObject * obj)
284 Class js_XMLClass = {
285 __null, 0, __null, __null, __null, __null, __null, __null, __null,
286 __null, __null, __null, __null, __null, __null, __null,
288 { __null, __null, __null, __null, __null}
290 __null, xml_defineProperty, __null, __null, __null, __null, __null,
291 __null, __null, __null, __null, __null, __null}