PageRenderTime 125ms CodeModel.GetById 60ms app.highlight 19ms RepoModel.GetById 29ms app.codeStats 1ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/jsxml.h

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
C++ Header | 298 lines | 176 code | 60 blank | 62 comment | 2 complexity | aa7d2a5f207ff7734cc3cd51c84f47f8 MD5 | raw file
  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 "jsstddef.h"
 43#include "jspubtd.h"
 44
 45JS_BEGIN_EXTERN_C
 46
 47extern const char js_AnyName_str[];
 48extern const char js_AttributeName_str[];
 49extern const char js_isXMLName_str[];
 50extern const char js_XMLList_str[];
 51
 52extern const char js_amp_entity_str[];
 53extern const char js_gt_entity_str[];
 54extern const char js_lt_entity_str[];
 55extern const char js_quot_entity_str[];
 56
 57typedef JSBool
 58(* JSIdentityOp)(const void *a, const void *b);
 59
 60struct JSXMLArray {
 61    uint32              length;
 62    uint32              capacity;
 63    void                **vector;
 64    JSXMLArrayCursor    *cursors;
 65};
 66
 67#define JSXML_PRESET_CAPACITY   JS_BIT(31)
 68#define JSXML_CAPACITY_MASK     JS_BITMASK(31)
 69#define JSXML_CAPACITY(array)   ((array)->capacity & JSXML_CAPACITY_MASK)
 70
 71struct JSXMLArrayCursor {
 72    JSXMLArray          *array;
 73    uint32              index;
 74    JSXMLArrayCursor    *next;
 75    JSXMLArrayCursor    **prevp;
 76    void                *root;
 77};
 78
 79/*
 80 * NB: don't reorder this enum without changing all array initializers that
 81 * depend on it in jsxml.c.
 82 */
 83typedef enum JSXMLClass {
 84    JSXML_CLASS_LIST,
 85    JSXML_CLASS_ELEMENT,
 86    JSXML_CLASS_ATTRIBUTE,
 87    JSXML_CLASS_PROCESSING_INSTRUCTION,
 88    JSXML_CLASS_TEXT,
 89    JSXML_CLASS_COMMENT,
 90    JSXML_CLASS_LIMIT
 91} JSXMLClass;
 92
 93#define JSXML_CLASS_HAS_KIDS(class_)    ((class_) < JSXML_CLASS_ATTRIBUTE)
 94#define JSXML_CLASS_HAS_VALUE(class_)   ((class_) >= JSXML_CLASS_ATTRIBUTE)
 95#define JSXML_CLASS_HAS_NAME(class_)                                          \
 96    ((uintN)((class_) - JSXML_CLASS_ELEMENT) <=                               \
 97     (uintN)(JSXML_CLASS_PROCESSING_INSTRUCTION - JSXML_CLASS_ELEMENT))
 98
 99#ifdef DEBUG_notme
100#include "jsclist.h"
101#endif
102
103typedef struct JSXMLListVar {
104    JSXMLArray          kids;           /* NB: must come first */
105    JSXML               *target;
106    JSObject            *targetprop;
107} JSXMLListVar;
108
109typedef struct JSXMLElemVar {
110    JSXMLArray          kids;           /* NB: must come first */
111    JSXMLArray          namespaces;
112    JSXMLArray          attrs;
113} JSXMLElemVar;
114
115struct JSXML {
116#ifdef DEBUG_notme
117    JSCList             links;
118    uint32              serial;
119#endif
120    JSObject            *object;
121    void                *domnode;       /* DOM node if mapped info item */
122    JSXML               *parent;
123    JSObject            *name;
124    uint16              xml_class;      /* discriminates u, below */
125    uint16              xml_flags;      /* flags, see below */
126    union {
127        JSXMLListVar    list;
128        JSXMLElemVar    elem;
129        JSString        *value;
130    } u;
131
132    /* Don't add anything after u -- see js_NewXML for why. */
133};
134
135/* union member shorthands */
136#define xml_kids        u.list.kids
137#define xml_target      u.list.target
138#define xml_targetprop  u.list.targetprop
139#define xml_namespaces  u.elem.namespaces
140#define xml_attrs       u.elem.attrs
141#define xml_value       u.value
142
143/* xml_flags values */
144#define XMLF_WHITESPACE_TEXT    0x1
145
146/* xml_class-testing macros */
147#define JSXML_HAS_KIDS(xml)     JSXML_CLASS_HAS_KIDS((xml)->xml_class)
148#define JSXML_HAS_VALUE(xml)    JSXML_CLASS_HAS_VALUE((xml)->xml_class)
149#define JSXML_HAS_NAME(xml)     JSXML_CLASS_HAS_NAME((xml)->xml_class)
150#define JSXML_LENGTH(xml)       (JSXML_CLASS_HAS_KIDS((xml)->xml_class)       \
151                                 ? (xml)->xml_kids.length                     \
152                                 : 0)
153
154extern JSXML *
155js_NewXML(JSContext *cx, JSXMLClass xml_class);
156
157extern void
158js_TraceXML(JSTracer *trc, JSXML *xml);
159
160extern void
161js_FinalizeXML(JSContext *cx, JSXML *xml);
162
163extern JSObject *
164js_ParseNodeToXMLObject(JSContext *cx, JSParseContext *pc, JSParseNode *pn);
165
166extern JSObject *
167js_NewXMLObject(JSContext *cx, JSXMLClass xml_class);
168
169extern JSObject *
170js_GetXMLObject(JSContext *cx, JSXML *xml);
171
172extern JS_FRIEND_DATA(JSXMLObjectOps)   js_XMLObjectOps;
173extern JS_FRIEND_DATA(JSClass)          js_XMLClass;
174extern JS_FRIEND_DATA(JSExtendedClass)  js_NamespaceClass;
175extern JS_FRIEND_DATA(JSExtendedClass)  js_QNameClass;
176extern JS_FRIEND_DATA(JSClass)          js_AttributeNameClass;
177extern JS_FRIEND_DATA(JSClass)          js_AnyNameClass;
178extern JSClass                          js_XMLFilterClass;
179
180/*
181 * Macros to test whether an object or a value is of type "xml" (per typeof).
182 * NB: jsobj.h must be included before any call to OBJECT_IS_XML, and jsapi.h
183 * and jsobj.h must be included before any call to VALUE_IS_XML.
184 */
185#define OBJECT_IS_XML(cx,obj)   ((obj)->map->ops == &js_XMLObjectOps.base)
186#define VALUE_IS_XML(cx,v)      (!JSVAL_IS_PRIMITIVE(v) &&                    \
187                                 OBJECT_IS_XML(cx, JSVAL_TO_OBJECT(v)))
188
189extern JSObject *
190js_InitNamespaceClass(JSContext *cx, JSObject *obj);
191
192extern JSObject *
193js_InitQNameClass(JSContext *cx, JSObject *obj);
194
195extern JSObject *
196js_InitAttributeNameClass(JSContext *cx, JSObject *obj);
197
198extern JSObject *
199js_InitAnyNameClass(JSContext *cx, JSObject *obj);
200
201extern JSObject *
202js_InitXMLClass(JSContext *cx, JSObject *obj);
203
204extern JSObject *
205js_InitXMLClasses(JSContext *cx, JSObject *obj);
206
207extern JSBool
208js_GetFunctionNamespace(JSContext *cx, jsval *vp);
209
210/*
211 * If obj is QName corresponding to function::name, set *funidp to name's id,
212 * otherwise set *funidp to 0.
213 */
214JSBool
215js_IsFunctionQName(JSContext *cx, JSObject *obj, jsid *funidp);
216
217extern JSBool
218js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp);
219
220extern JSBool
221js_SetDefaultXMLNamespace(JSContext *cx, jsval v);
222
223/*
224 * Return true if v is a XML QName object, or if it converts to a string that
225 * contains a valid XML qualified name (one containing no :), false otherwise.
226 * NB: This function is an infallible predicate, it hides exceptions.
227 */
228extern JSBool
229js_IsXMLName(JSContext *cx, jsval v);
230
231extern JSBool
232js_ToAttributeName(JSContext *cx, jsval *vp);
233
234extern JSString *
235js_EscapeAttributeValue(JSContext *cx, JSString *str, JSBool quote);
236
237extern JSString *
238js_AddAttributePart(JSContext *cx, JSBool isName, JSString *str,
239                    JSString *str2);
240
241extern JSString *
242js_EscapeElementValue(JSContext *cx, JSString *str);
243
244extern JSString *
245js_ValueToXMLString(JSContext *cx, jsval v);
246
247extern JSObject *
248js_ConstructXMLQNameObject(JSContext *cx, jsval nsval, jsval lnval);
249
250extern JSBool
251js_GetAnyName(JSContext *cx, jsval *vp);
252
253/*
254 * Note: nameval must be either QName, AttributeName, or AnyName.
255 */
256extern JSBool
257js_FindXMLProperty(JSContext *cx, jsval nameval, JSObject **objp, jsid *idp);
258
259extern JSBool
260js_GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
261
262extern JSBool
263js_GetXMLDescendants(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
264
265extern JSBool
266js_DeleteXMLListElements(JSContext *cx, JSObject *listobj);
267
268extern JSObject *
269js_InitXMLFilterClass(JSContext *cx, JSObject* obj);
270
271extern JSBool
272js_StepXMLListFilter(JSContext *cx, JSBool initialized);
273
274extern JSObject *
275js_ValueToXMLObject(JSContext *cx, jsval v);
276
277extern JSObject *
278js_ValueToXMLListObject(JSContext *cx, jsval v);
279
280extern JSObject *
281js_CloneXMLObject(JSContext *cx, JSObject *obj);
282
283extern JSObject *
284js_NewXMLSpecialObject(JSContext *cx, JSXMLClass xml_class, JSString *name,
285                       JSString *value);
286
287extern JSString *
288js_MakeXMLCDATAString(JSContext *cx, JSString *str);
289
290extern JSString *
291js_MakeXMLCommentString(JSContext *cx, JSString *str);
292
293extern JSString *
294js_MakeXMLPIString(JSContext *cx, JSString *name, JSString *str);
295
296JS_END_EXTERN_C
297
298#endif /* jsxml_h___ */