PageRenderTime 116ms CodeModel.GetById 22ms RepoModel.GetById 15ms app.codeStats 0ms

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