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 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,
54 public:void setNull() {
55 } void setString(JSString * str) {
56 data = STRING_TO_JSVAL_IMPL(str);
59 __attribute__ ((aligned(8)));
60 static Value StringValue(JSString * str) {
65 static inline const jsval & Jsvalify(const Value & v) {
66 return (const jsval &)v;
68 static inline Value *Valueify(jsval * v) {
71 typedef JSBool(*Native) (JSContext * cx, uintN argc, Value * vp);
72 typedef JSBool(*PropertyOp) (JSContext * cx, JSObject * obj, jsid id,
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,
78 typedef JSBool(*NewEnumerateOp) (JSContext * cx, JSObject * obj,
79 JSIterateOp enum_op, Value * statep,
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,
93 typedef JSBool(*StrictPropertyIdOp) (JSContext * cx, JSObject * obj,
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,
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);
107 typedef JSBool(*FixOp) (JSContext * cx, JSObject * obj, bool * fixed,
108 AutoIdVector * props);
109 struct ClassExtension {
111 JSObjectOp outerObject;
112 JSObjectOp innerObject;
113 JSIteratorOp iteratorObject;
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;
128 js::ObjectOp thisObject;
129 js::FinalizeOp clear;
134 PropertyOp addProperty;
135 PropertyOp delProperty;
136 PropertyOp getProperty;
137 StrictPropertyOp setProperty;
138 JSEnumerateOp enumerate;
141 JSFinalizeOp finalize;
142 JSClassInternal reserved0;
143 CheckAccessOp checkAccess;
146 JSXDRObjectOp xdrObject;
147 HasInstanceOp hasInstance;
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;
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));
170 inline JSBool js_IdIsIndex(jsid id, jsuint * indexp)
177 js::AutoGCRooter * autoGCRooters;
181 public:AutoGCRooter(JSContext * cx,
182 ptrdiff_t tag):down(cx->autoGCRooters), tag(tag),
184 cx->autoGCRooters = this;
185 } protected:AutoGCRooter * const down;
187 JSContext *const context;
189 class AutoArrayRooter:private AutoGCRooter {
190 public:AutoArrayRooter(JSContext * cx, size_t len,
191 Value * vec):AutoGCRooter(cx, len),
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
202 struct JSXML:js::gc::Cell {
206 Class js_AttributeNameClass;
208 static JSObject *NewXMLAttributeName(JSContext * cx, JSLinearString * uri,
209 JSLinearString * prefix,
210 JSLinearString * localName)
214 static JSBool PutProperty(JSContext * cx, JSObject * obj, jsid id,
215 JSBool strict, jsval * vp)
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;
225 roots[ID_ROOT] = IdToJsval(id);
226 roots[VAL_ROOT] = *vp;
227 AutoArrayRooter tvr(cx, (sizeof(roots) / sizeof(roots)[0]),
229 if (js_IdIsIndex(id, &index)) {
230 if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
231 if (nameobj->getClass() != &js_AttributeNameClass) {
233 NewXMLAttributeName(cx,
234 nameobj->getNameURI(),
238 getQNameLocalName());
244 JSBool xml_defineProperty(JSContext * cx, JSObject * obj, jsid id,
247 jsval tmp = Jsvalify(*v);
248 return PutProperty(cx, obj, id, false, &tmp);