/[jscoverage]/trunk/js/jsxml.h
ViewVC logotype

Contents of /trunk/js/jsxml.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 507 - (show annotations)
Sun Jan 10 07:23:34 2010 UTC (9 years, 9 months ago) by siliconforks
File MIME type: text/plain
File size: 9411 byte(s)
Update SpiderMonkey from Firefox 3.6rc1.

1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is SpiderMonkey E4X code, released August, 2004.
17 *
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39 #ifndef jsxml_h___
40 #define jsxml_h___
41
42 #include "jspubtd.h"
43
44 JS_BEGIN_EXTERN_C
45
46 extern const char js_AnyName_str[];
47 extern const char js_AttributeName_str[];
48 extern const char js_isXMLName_str[];
49 extern const char js_XMLList_str[];
50
51 extern const char js_amp_entity_str[];
52 extern const char js_gt_entity_str[];
53 extern const char js_lt_entity_str[];
54 extern const char js_quot_entity_str[];
55
56 typedef JSBool
57 (* JSIdentityOp)(const void *a, const void *b);
58
59 struct JSXMLArray {
60 uint32 length;
61 uint32 capacity;
62 void **vector;
63 JSXMLArrayCursor *cursors;
64 };
65
66 #define JSXML_PRESET_CAPACITY JS_BIT(31)
67 #define JSXML_CAPACITY_MASK JS_BITMASK(31)
68 #define JSXML_CAPACITY(array) ((array)->capacity & JSXML_CAPACITY_MASK)
69
70 /*
71 * NB: don't reorder this enum without changing all array initializers that
72 * depend on it in jsxml.c.
73 */
74 typedef enum JSXMLClass {
75 JSXML_CLASS_LIST,
76 JSXML_CLASS_ELEMENT,
77 JSXML_CLASS_ATTRIBUTE,
78 JSXML_CLASS_PROCESSING_INSTRUCTION,
79 JSXML_CLASS_TEXT,
80 JSXML_CLASS_COMMENT,
81 JSXML_CLASS_LIMIT
82 } JSXMLClass;
83
84 #define JSXML_CLASS_HAS_KIDS(class_) ((class_) < JSXML_CLASS_ATTRIBUTE)
85 #define JSXML_CLASS_HAS_VALUE(class_) ((class_) >= JSXML_CLASS_ATTRIBUTE)
86 #define JSXML_CLASS_HAS_NAME(class_) \
87 ((uintN)((class_) - JSXML_CLASS_ELEMENT) <= \
88 (uintN)(JSXML_CLASS_PROCESSING_INSTRUCTION - JSXML_CLASS_ELEMENT))
89
90 #ifdef DEBUG_notme
91 #include "jsclist.h"
92 #endif
93
94 typedef struct JSXMLListVar {
95 JSXMLArray kids; /* NB: must come first */
96 JSXML *target;
97 JSObject *targetprop;
98 } JSXMLListVar;
99
100 typedef struct JSXMLElemVar {
101 JSXMLArray kids; /* NB: must come first */
102 JSXMLArray namespaces;
103 JSXMLArray attrs;
104 } JSXMLElemVar;
105
106 struct JSXML {
107 #ifdef DEBUG_notme
108 JSCList links;
109 uint32 serial;
110 #endif
111 JSObject *object;
112 void *domnode; /* DOM node if mapped info item */
113 JSXML *parent;
114 JSObject *name;
115 uint16 xml_class; /* discriminates u, below */
116 uint16 xml_flags; /* flags, see below */
117 uint32 align;
118 union {
119 JSXMLListVar list;
120 JSXMLElemVar elem;
121 JSString *value;
122 } u;
123 };
124
125 JS_STATIC_ASSERT(JS_ROUNDUP(sizeof(JSXML), sizeof(JSGCThing)) == sizeof(JSXML));
126
127 /* union member shorthands */
128 #define xml_kids u.list.kids
129 #define xml_target u.list.target
130 #define xml_targetprop u.list.targetprop
131 #define xml_namespaces u.elem.namespaces
132 #define xml_attrs u.elem.attrs
133 #define xml_value u.value
134
135 /* xml_flags values */
136 #define XMLF_WHITESPACE_TEXT 0x1
137
138 /* xml_class-testing macros */
139 #define JSXML_HAS_KIDS(xml) JSXML_CLASS_HAS_KIDS((xml)->xml_class)
140 #define JSXML_HAS_VALUE(xml) JSXML_CLASS_HAS_VALUE((xml)->xml_class)
141 #define JSXML_HAS_NAME(xml) JSXML_CLASS_HAS_NAME((xml)->xml_class)
142 #define JSXML_LENGTH(xml) (JSXML_CLASS_HAS_KIDS((xml)->xml_class) \
143 ? (xml)->xml_kids.length \
144 : 0)
145
146 extern JSXML *
147 js_NewXML(JSContext *cx, JSXMLClass xml_class);
148
149 extern void
150 js_TraceXML(JSTracer *trc, JSXML *xml);
151
152 extern void
153 js_FinalizeXML(JSContext *cx, JSXML *xml);
154
155 extern JSObject *
156 js_ParseNodeToXMLObject(JSCompiler *jsc, JSParseNode *pn);
157
158 extern JSObject *
159 js_NewXMLObject(JSContext *cx, JSXMLClass xml_class);
160
161 extern JSObject *
162 js_GetXMLObject(JSContext *cx, JSXML *xml);
163
164 extern JS_FRIEND_DATA(JSObjectOps) js_XMLObjectOps;
165 extern JS_FRIEND_DATA(JSClass) js_XMLClass;
166 extern JS_FRIEND_DATA(JSExtendedClass) js_NamespaceClass;
167 extern JS_FRIEND_DATA(JSExtendedClass) js_QNameClass;
168 extern JS_FRIEND_DATA(JSClass) js_AttributeNameClass;
169 extern JS_FRIEND_DATA(JSClass) js_AnyNameClass;
170 extern JSClass js_XMLFilterClass;
171
172 /*
173 * Macros to test whether an object or a value is of type "xml" (per typeof).
174 * NB: jsobj.h must be included before any call to OBJECT_IS_XML, and jsapi.h
175 * and jsobj.h must be included before any call to VALUE_IS_XML.
176 */
177 #define OBJECT_IS_XML(cx,obj) ((obj)->map->ops == &js_XMLObjectOps)
178 #define VALUE_IS_XML(cx,v) (!JSVAL_IS_PRIMITIVE(v) && \
179 OBJECT_IS_XML(cx, JSVAL_TO_OBJECT(v)))
180
181 extern JSObject *
182 js_InitNamespaceClass(JSContext *cx, JSObject *obj);
183
184 extern JSObject *
185 js_InitQNameClass(JSContext *cx, JSObject *obj);
186
187 extern JSObject *
188 js_InitAttributeNameClass(JSContext *cx, JSObject *obj);
189
190 extern JSObject *
191 js_InitAnyNameClass(JSContext *cx, JSObject *obj);
192
193 extern JSObject *
194 js_InitXMLClass(JSContext *cx, JSObject *obj);
195
196 extern JSObject *
197 js_InitXMLClasses(JSContext *cx, JSObject *obj);
198
199 extern JSBool
200 js_GetFunctionNamespace(JSContext *cx, jsval *vp);
201
202 /*
203 * If obj is QName corresponding to function::name, set *funidp to name's id,
204 * otherwise set *funidp to 0.
205 */
206 JSBool
207 js_IsFunctionQName(JSContext *cx, JSObject *obj, jsid *funidp);
208
209 extern JSBool
210 js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp);
211
212 extern JSBool
213 js_SetDefaultXMLNamespace(JSContext *cx, jsval v);
214
215 /*
216 * Return true if v is a XML QName object, or if it converts to a string that
217 * contains a valid XML qualified name (one containing no :), false otherwise.
218 * NB: This function is an infallible predicate, it hides exceptions.
219 */
220 extern JSBool
221 js_IsXMLName(JSContext *cx, jsval v);
222
223 extern JSBool
224 js_ToAttributeName(JSContext *cx, jsval *vp);
225
226 extern JSString *
227 js_EscapeAttributeValue(JSContext *cx, JSString *str, JSBool quote);
228
229 extern JSString *
230 js_AddAttributePart(JSContext *cx, JSBool isName, JSString *str,
231 JSString *str2);
232
233 extern JSString *
234 js_EscapeElementValue(JSContext *cx, JSString *str);
235
236 extern JSString *
237 js_ValueToXMLString(JSContext *cx, jsval v);
238
239 extern JSObject *
240 js_ConstructXMLQNameObject(JSContext *cx, jsval nsval, jsval lnval);
241
242 extern JSBool
243 js_GetAnyName(JSContext *cx, jsval *vp);
244
245 /*
246 * Note: nameval must be either QName, AttributeName, or AnyName.
247 */
248 extern JSBool
249 js_FindXMLProperty(JSContext *cx, jsval nameval, JSObject **objp, jsid *idp);
250
251 extern JSBool
252 js_GetXMLMethod(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
253
254 extern JSBool
255 js_GetXMLDescendants(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
256
257 extern JSBool
258 js_DeleteXMLListElements(JSContext *cx, JSObject *listobj);
259
260 extern JSBool
261 js_StepXMLListFilter(JSContext *cx, JSBool initialized);
262
263 extern JSObject *
264 js_ValueToXMLObject(JSContext *cx, jsval v);
265
266 extern JSObject *
267 js_ValueToXMLListObject(JSContext *cx, jsval v);
268
269 extern JSObject *
270 js_CloneXMLObject(JSContext *cx, JSObject *obj);
271
272 extern JSObject *
273 js_NewXMLSpecialObject(JSContext *cx, JSXMLClass xml_class, JSString *name,
274 JSString *value);
275
276 extern JSString *
277 js_MakeXMLCDATAString(JSContext *cx, JSString *str);
278
279 extern JSString *
280 js_MakeXMLCommentString(JSContext *cx, JSString *str);
281
282 extern JSString *
283 js_MakeXMLPIString(JSContext *cx, JSString *name, JSString *str);
284
285 extern JSBool
286 js_EnumerateXMLValues(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
287 jsval *statep, jsid *idp, jsval *vp);
288
289 extern JSBool
290 js_TestXMLEquality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
291
292 extern JSBool
293 js_ConcatenateXML(JSContext *cx, JSObject *obj, jsval v, jsval *vp);
294
295 JS_END_EXTERN_C
296
297 #endif /* jsxml_h___ */

  ViewVC Help
Powered by ViewVC 1.1.24