Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Enumerations | Functions | Variables
jsxml.c File Reference
#include "jsstddef.h"
#include "jsconfig.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"
#include "jsbit.h"
#include "jsprf.h"
#include "jsutil.h"
#include "jsapi.h"
#include "jsarray.h"
#include "jsatom.h"
#include "jsbool.h"
#include "jscntxt.h"
#include "jsfun.h"
#include "jsgc.h"
#include "jsinterp.h"
#include "jslock.h"
#include "jsnum.h"
#include "jsobj.h"
#include "jsopcode.h"
#include "jsparse.h"
#include "jsscan.h"
#include "jsscope.h"
#include "jsscript.h"
#include "jsstr.h"
#include "jsxml.h"

Go to the source code of this file.

Classes

struct  JSTempRootedNSArray

Defines

#define METER(x)   /* nothing */
#define UNMETER(x)   /* nothing */
#define IS_EMPTY(str)   (JSSTRING_LENGTH(str) == 0)
#define IS_STAR(str)   (JSSTRING_LENGTH(str) == 1 && *JSSTRING_CHARS(str) == '*')
#define NAMESPACE_ATTRS   (JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED)
#define QNAME_ATTRS   (JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED)
#define XML_NOT_FOUND   ((uint32) -1)
#define LINEAR_THRESHOLD   256
#define LINEAR_INCREMENT   32
#define XMLARRAY_FIND_MEMBER(a, e, f)   XMLArrayFindMember(a, (void *)(e), f)
#define XMLARRAY_HAS_MEMBER(a, e, f)
#define XMLARRAY_MEMBER(a, i, t)
#define XMLARRAY_SET_MEMBER(a, i, e)
#define XMLARRAY_ADD_MEMBER(x, a, i, e)   XMLArrayAddMember(x, a, i, (void *)(e))
#define XMLARRAY_INSERT(x, a, i, n)   XMLArrayInsert(x, a, i, n)
#define XMLARRAY_APPEND(x, a, e)   XMLARRAY_ADD_MEMBER(x, a, (a)->length, (e))
#define XMLARRAY_DELETE(x, a, i, c, t)   ((t *) XMLArrayDelete(x, a, i, c))
#define XMLARRAY_TRUNCATE(x, a, n)   XMLArrayTruncate(x, a, n)
#define XSF_IGNORE_COMMENTS   JS_BIT(XML_IGNORE_COMMENTS)
#define XSF_IGNORE_PROCESSING_INSTRUCTIONS   JS_BIT(XML_IGNORE_PROCESSING_INSTRUCTIONS)
#define XSF_IGNORE_WHITESPACE   JS_BIT(XML_IGNORE_WHITESPACE)
#define XSF_PRETTY_PRINTING   JS_BIT(XML_PRETTY_PRINTING)
#define XSF_CACHE_VALID   JS_BIT(XML_PRETTY_INDENT)
#define XSF_PRECOMPILED_ROOT   (XSF_CACHE_VALID << 1)
#define IS_XML(str)   (JSSTRING_LENGTH(str) == 3 && IS_XML_CHARS(JSSTRING_CHARS(str)))
#define IS_XMLNS(str)   (JSSTRING_LENGTH(str) == 5 && IS_XMLNS_CHARS(JSSTRING_CHARS(str)))
#define IS_XML_CHARS(chars)
#define HAS_NS_AFTER_XML(chars)
#define IS_XMLNS_CHARS(chars)   (IS_XML_CHARS(chars) && HAS_NS_AFTER_XML(chars))
#define STARTS_WITH_XML(chars, length)   (length >= 3 && IS_XML_CHARS(chars))
#define PN2X_SKIP_CHILD   ((JSXML *) 1)
#define constrlen(constr)   (sizeof(constr) - 1)
#define CHECK_COPY_ON_WRITE(cx, xml, obj)   (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj))
#define FOUND_XML_PROPERTY   ((JSProperty *) 1)
#define DROP_PROPERTY(cx, pobj, prop)
#define XML_METHOD_PROLOG
#define NON_LIST_XML_METHOD_PROLOG
#define JSXML_LIST_SIZE   (offsetof(JSXML, u) + sizeof(struct JSXMLListVar))
#define JSXML_ELEMENT_SIZE   (offsetof(JSXML, u) + sizeof(struct JSXMLVar))
#define JSXML_LEAF_SIZE   (offsetof(JSXML, u) + sizeof(JSString *))

Typedefs

typedef JSBool(* JSXMLNameMatcher )(JSXMLQName *nameqn, JSXML *xml)
typedef struct JSTempRootedNSArray JSTempRootedNSArray

Enumerations

enum  namespace_tinyid { NAMESPACE_PREFIX = -1, NAMESPACE_URI = -2 }
enum  qname_tinyid { QNAME_URI = -1, QNAME_LOCALNAME = -2 }
enum  xml_static_tinyid {
  XML_IGNORE_COMMENTS, XML_IGNORE_PROCESSING_INSTRUCTIONS, XML_IGNORE_WHITESPACE, XML_PRETTY_PRINTING,
  XML_PRETTY_INDENT
}

Functions

static JSBool xml_isXMLName (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool namespace_getProperty (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
static void namespace_finalize (JSContext *cx, JSObject *obj)
static void namespace_mark_vector (JSContext *cx, JSXMLNamespace **vec, uint32 len)
static uint32 namespace_mark (JSContext *cx, JSObject *obj, void *arg)
static JSBool namespace_equality (JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
 JS_FRIEND_DATA (JSExtendedClass)
static JSBool namespace_toString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSXMLNamespacejs_NewXMLNamespace (JSContext *cx, JSString *prefix, JSString *uri, JSBool declared)
void js_MarkXMLNamespace (JSContext *cx, JSXMLNamespace *ns)
void js_FinalizeXMLNamespace (JSContext *cx, JSXMLNamespace *ns)
JSObjectjs_NewXMLNamespaceObject (JSContext *cx, JSString *prefix, JSString *uri, JSBool declared)
JSObjectjs_GetXMLNamespaceObject (JSContext *cx, JSXMLNamespace *ns)
static JSBool qname_getProperty (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
static void qname_finalize (JSContext *cx, JSObject *obj)
static void anyname_finalize (JSContext *cx, JSObject *obj)
static uint32 qname_mark (JSContext *cx, JSObject *obj, void *arg)
static JSBool qname_identity (JSXMLQName *qna, JSXMLQName *qnb)
static JSBool qname_equality (JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
 JS_FRIEND_DATA (JSClass)
static JSBool qname_toString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSXMLQNamejs_NewXMLQName (JSContext *cx, JSString *uri, JSString *prefix, JSString *localName)
void js_MarkXMLQName (JSContext *cx, JSXMLQName *qn)
void js_FinalizeXMLQName (JSContext *cx, JSXMLQName *qn)
JSObjectjs_NewXMLQNameObject (JSContext *cx, JSString *uri, JSString *prefix, JSString *localName)
JSObjectjs_GetXMLQNameObject (JSContext *cx, JSXMLQName *qn)
JSObjectjs_GetAttributeNameObject (JSContext *cx, JSXMLQName *qn)
JSObjectjs_ConstructXMLQNameObject (JSContext *cx, jsval nsval, jsval lnval)
static JSBool IsXMLName (const jschar *cp, size_t n)
JSBool js_IsXMLName (JSContext *cx, jsval v)
static JSBool NamespaceHelper (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool Namespace (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool QNameHelper (JSContext *cx, JSObject *obj, JSClass *clasp, uintN argc, jsval *argv, jsval *rval)
static JSBool QName (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool AttributeName (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool namespace_identity (const void *a, const void *b)
static JSBool attr_identity (const void *a, const void *b)
static void XMLArrayCursorInit (JSXMLArrayCursor *cursor, JSXMLArray *array)
static void XMLArrayCursorFinish (JSXMLArrayCursor *cursor)
static voidXMLArrayCursorNext (JSXMLArrayCursor *cursor)
static voidXMLArrayCursorItem (JSXMLArrayCursor *cursor)
static void XMLArrayCursorMark (JSContext *cx, JSXMLArrayCursor *cursor)
static JSBool XMLArraySetCapacity (JSContext *cx, JSXMLArray *array, uint32 capacity)
static void XMLArrayTrim (JSXMLArray *array)
static JSBool XMLArrayInit (JSContext *cx, JSXMLArray *array, uint32 capacity)
static void XMLArrayFinish (JSContext *cx, JSXMLArray *array)
static uint32 XMLArrayFindMember (const JSXMLArray *array, void *elt, JSIdentityOp identity)
static JSBool XMLArrayAddMember (JSContext *cx, JSXMLArray *array, uint32 index, void *elt)
static JSBool XMLArrayInsert (JSContext *cx, JSXMLArray *array, uint32 i, uint32 n)
static voidXMLArrayDelete (JSContext *cx, JSXMLArray *array, uint32 index, JSBool compress)
static void XMLArrayTruncate (JSContext *cx, JSXMLArray *array, uint32 length)
static JSBool xml_setting_getter (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
static JSBool xml_setting_setter (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
static JSXMLQNameParseNodeToQName (JSContext *cx, JSParseNode *pn, JSXMLArray *inScopeNSes, JSBool isAttributeName)
static JSStringChompXMLWhitespace (JSContext *cx, JSString *str)
static JSXMLParseNodeToXML (JSContext *cx, JSParseNode *pn, JSXMLArray *inScopeNSes, uintN flags)
static JSBool GetXMLSetting (JSContext *cx, const char *name, jsval *vp)
static JSBool FillSettingsCache (JSContext *cx)
static JSBool GetBooleanXMLSetting (JSContext *cx, const char *name, JSBool *bp)
static JSBool GetUint32XMLSetting (JSContext *cx, const char *name, uint32 *uip)
static JSBool GetXMLSettingFlags (JSContext *cx, uintN *flagsp)
static JSXMLParseXMLSource (JSContext *cx, JSString *src)
static JSXMLOrphanXMLChild (JSContext *cx, JSXML *xml, uint32 i)
static JSObjectToXML (JSContext *cx, jsval v)
static JSBool Append (JSContext *cx, JSXML *list, JSXML *kid)
static JSObjectToXMLList (JSContext *cx, jsval v)
static JSStringMakeXMLSpecialString (JSContext *cx, JSStringBuffer *sb, JSString *str, JSString *str2, const jschar *prefix, size_t prefixlength, const jschar *suffix, size_t suffixlength)
static JSStringMakeXMLCDATAString (JSContext *cx, JSStringBuffer *sb, JSString *str)
static JSStringMakeXMLCommentString (JSContext *cx, JSStringBuffer *sb, JSString *str)
static JSStringMakeXMLPIString (JSContext *cx, JSStringBuffer *sb, JSString *name, JSString *value)
static void AppendAttributeValue (JSContext *cx, JSStringBuffer *sb, JSString *valstr)
static JSStringEscapeElementValue (JSContext *cx, JSStringBuffer *sb, JSString *str)
static JSStringEscapeAttributeValue (JSContext *cx, JSStringBuffer *sb, JSString *str)
static JSXMLNamespaceGetNamespace (JSContext *cx, JSXMLQName *qn, const JSXMLArray *inScopeNSes)
static JSStringGeneratePrefix (JSContext *cx, JSString *uri, JSXMLArray *decls)
static JSBool namespace_match (const void *a, const void *b)
static JSStringXMLToXMLString (JSContext *cx, JSXML *xml, const JSXMLArray *ancestorNSes, uintN indentLevel)
static JSStringToXMLString (JSContext *cx, jsval v)
static JSXMLQNameToAttributeName (JSContext *cx, jsval v)
static JSXMLQNameToXMLName (JSContext *cx, jsval v, jsid *funidp)
static JSBool AddInScopeNamespace (JSContext *cx, JSXML *xml, JSXMLNamespace *ns)
static JSXMLDeepCopyInLRS (JSContext *cx, JSXML *xml, uintN flags)
static JSXMLDeepCopy (JSContext *cx, JSXML *xml, JSObject *obj, uintN flags)
static JSBool DeepCopySetInLRS (JSContext *cx, JSXMLArray *from, JSXMLArray *to, JSXML *parent, uintN flags)
static void ReportBadXMLName (JSContext *cx, jsval id)
static JSBool DeleteByIndex (JSContext *cx, JSXML *xml, jsval id, jsval *vp)
static JSBool MatchAttrName (JSXMLQName *nameqn, JSXML *attr)
static JSBool MatchElemName (JSXMLQName *nameqn, JSXML *elem)
static JSBool DescendantsHelper (JSContext *cx, JSXML *xml, JSXMLQName *nameqn, JSXML *list)
static JSXMLDescendants (JSContext *cx, JSXML *xml, jsval id)
static JSBool xml_equality (JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
static JSBool XMLEquals (JSContext *cx, JSXML *xml, JSXML *vxml, JSBool *bp)
static JSBool Equals (JSContext *cx, JSXML *xml, jsval v, JSBool *bp)
static JSBool CheckCycle (JSContext *cx, JSXML *xml, JSXML *kid)
static JSBool Insert (JSContext *cx, JSXML *xml, uint32 i, jsval v)
static JSBool IndexToIdVal (JSContext *cx, uint32 index, jsval *idvp)
static JSBool Replace (JSContext *cx, JSXML *xml, jsval id, jsval v)
static JSBool ResolveValue (JSContext *cx, JSXML *list, JSXML **result)
static JSBool DeleteProperty (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
static JSBool SyncInScopeNamespaces (JSContext *cx, JSXML *xml)
static JSBool GetNamedProperty (JSContext *cx, JSXML *xml, JSXMLQName *nameqn, JSBool attributes, JSXML *list)
static JSBool GetProperty (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
static JSXMLCopyOnWrite (JSContext *cx, JSXML *xml, JSObject *obj)
static JSStringKidToString (JSContext *cx, JSXML *xml, uint32 index)
static JSBool PutProperty (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
static JSBool HasProperty (JSContext *cx, JSObject *obj, jsval id, JSObject **objp, JSProperty **propp)
static void xml_finalize (JSContext *cx, JSObject *obj)
static void xml_mark_vector (JSContext *cx, JSXML **vec, uint32 len)
static JSBool xml_lookupProperty (JSContext *cx, JSObject *obj, jsid id, JSObject **objp, JSProperty **propp)
static JSBool xml_defineProperty (JSContext *cx, JSObject *obj, jsid id, jsval value, JSPropertyOp getter, JSPropertyOp setter, uintN attrs, JSProperty **propp)
static JSBool xml_getProperty (JSContext *cx, JSObject *obj, jsid id, jsval *vp)
static JSBool xml_setProperty (JSContext *cx, JSObject *obj, jsid id, jsval *vp)
static JSBool FoundProperty (JSContext *cx, JSObject *obj, jsid id, JSProperty *prop, JSBool *foundp)
static JSBool xml_getAttributes (JSContext *cx, JSObject *obj, jsid id, JSProperty *prop, uintN *attrsp)
static JSBool xml_setAttributes (JSContext *cx, JSObject *obj, jsid id, JSProperty *prop, uintN *attrsp)
static JSBool xml_deleteProperty (JSContext *cx, JSObject *obj, jsid id, jsval *rval)
static JSBool xml_defaultValue (JSContext *cx, JSObject *obj, JSType hint, jsval *vp)
static JSBool xml_enumerate (JSContext *cx, JSObject *obj, JSIterateOp enum_op, jsval *statep, jsid *idp)
static JSBool xml_hasInstance (JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
static uint32 xml_mark (JSContext *cx, JSObject *obj, void *arg)
static void xml_clear (JSContext *cx, JSObject *obj)
static JSBool HasSimpleContent (JSXML *xml)
static JSObjectxml_getMethod (JSContext *cx, JSObject *obj, jsid id, jsval *vp)
static JSBool xml_setMethod (JSContext *cx, JSObject *obj, jsid id, jsval *vp)
static JSBool xml_enumerateValues (JSContext *cx, JSObject *obj, JSIterateOp enum_op, jsval *statep, jsid *idp, jsval *vp)
static JSBool xml_concatenate (JSContext *cx, JSObject *obj, jsval v, jsval *vp)
 JS_FRIEND_DATA (JSXMLObjectOps)
static JSObjectOpsxml_getObjectOps (JSContext *cx, JSClass *clasp)
static JSXMLStartNonListXMLMethod (JSContext *cx, JSObject **objp, jsval *argv)
static JSBool xml_addNamespace (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_appendChild (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_attribute (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_attributes (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSXMLxml_list_helper (JSContext *cx, JSXML *xml, jsval *rval)
static JSBool xml_child_helper (JSContext *cx, JSObject *obj, JSXML *xml, jsval name, jsval *rval)
static JSBool xml_child (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_childIndex (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_children (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_comments (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_contains (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_copy (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_descendants (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_elements (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_hasOwnProperty (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_hasComplexContent (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_hasSimpleContent (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 mark_temp_ns_array (JSContext *cx, JSTempValueRooter *tvr)
static void InitTempNSArray (JSContext *cx, JSTempRootedNSArray *tmp)
static void FinishTempNSArray (JSContext *cx, JSTempRootedNSArray *tmp)
static JSBool TempNSArrayToJSArray (JSContext *cx, JSTempRootedNSArray *tmp, jsval *rval)
static JSBool FindInScopeNamespaces (JSContext *cx, JSXML *xml, JSXMLArray *nsarray)
static JSBool xml_inScopeNamespaces (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_insertChildAfter (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_insertChildBefore (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_length (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_localName (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_name (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_namespace (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_namespaceDeclarations (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_nodeKind (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool NormalizingDelete (JSContext *cx, JSObject *obj, JSXML *xml, jsval id)
static JSBool IsXMLSpace (JSString *str)
static JSBool xml_normalize (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_parent (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_processingInstructions (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_prependChild (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_propertyIsEnumerable (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool namespace_full_match (const void *a, const void *b)
static JSBool xml_removeNamespace_helper (JSContext *cx, JSXML *xml, JSXMLNamespace *ns)
static JSBool xml_removeNamespace (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_replace (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_setChildren (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_setLocalName (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_setName (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_setNamespace (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_text (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_toXMLString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSStringxml_toString_helper (JSContext *cx, JSXML *xml)
static JSBool xml_toString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_valueOf (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool CopyXMLSettings (JSContext *cx, JSObject *from, JSObject *to)
static JSBool SetDefaultXMLSettings (JSContext *cx, JSObject *obj)
static JSBool xml_settings (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_setSettings (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool xml_defaultSettings (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool XML (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool XMLList (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSXMLjs_NewXML (JSContext *cx, JSXMLClass xml_class)
void js_MarkXML (JSContext *cx, JSXML *xml)
void js_FinalizeXML (JSContext *cx, JSXML *xml)
JSObjectjs_ParseNodeToXMLObject (JSContext *cx, JSParseNode *pn)
JSObjectjs_NewXMLObject (JSContext *cx, JSXMLClass xml_class)
static JSObjectNewXMLObject (JSContext *cx, JSXML *xml)
JSObjectjs_GetXMLObject (JSContext *cx, JSXML *xml)
JSObjectjs_InitNamespaceClass (JSContext *cx, JSObject *obj)
JSObjectjs_InitQNameClass (JSContext *cx, JSObject *obj)
JSObjectjs_InitAttributeNameClass (JSContext *cx, JSObject *obj)
JSObjectjs_InitAnyNameClass (JSContext *cx, JSObject *obj)
JSObjectjs_InitXMLClass (JSContext *cx, JSObject *obj)
JSObjectjs_InitXMLClasses (JSContext *cx, JSObject *obj)
JSBool js_GetFunctionNamespace (JSContext *cx, jsval *vp)
JSBool js_GetDefaultXMLNamespace (JSContext *cx, jsval *vp)
JSBool js_SetDefaultXMLNamespace (JSContext *cx, jsval v)
JSBool js_ToAttributeName (JSContext *cx, jsval *vp)
JSStringjs_EscapeAttributeValue (JSContext *cx, JSString *str)
JSStringjs_AddAttributePart (JSContext *cx, JSBool isName, JSString *str, JSString *str2)
JSStringjs_EscapeElementValue (JSContext *cx, JSString *str)
JSStringjs_ValueToXMLString (JSContext *cx, jsval v)
static JSBool anyname_toString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSBool js_GetAnyName (JSContext *cx, jsval *vp)
JSBool js_FindXMLProperty (JSContext *cx, jsval name, JSObject **objp, jsval *namep)
JSBool js_GetXMLProperty (JSContext *cx, JSObject *obj, jsval name, jsval *vp)
JSBool js_GetXMLFunction (JSContext *cx, JSObject *obj, jsid id, jsval *vp)
JSBool js_SetXMLProperty (JSContext *cx, JSObject *obj, jsval name, jsval *vp)
static JSXMLGetPrivate (JSContext *cx, JSObject *obj, const char *method)
JSBool js_GetXMLDescendants (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
JSBool js_DeleteXMLListElements (JSContext *cx, JSObject *listobj)
JSBool js_FilterXMLList (JSContext *cx, JSObject *obj, jsbytecode *pc, jsval *vp)
JSObjectjs_ValueToXMLObject (JSContext *cx, jsval v)
JSObjectjs_ValueToXMLListObject (JSContext *cx, jsval v)
JSObjectjs_CloneXMLObject (JSContext *cx, JSObject *obj)
JSObjectjs_NewXMLSpecialObject (JSContext *cx, JSXMLClass xml_class, JSString *name, JSString *value)
JSStringjs_MakeXMLCDATAString (JSContext *cx, JSString *str)
JSStringjs_MakeXMLCommentString (JSContext *cx, JSString *str)
JSStringjs_MakeXMLPIString (JSContext *cx, JSString *name, JSString *str)

Variables

const char js_isXMLName_str [] = "isXMLName"
const char js_XMLList_str [] = "XMLList"
const char js_localName_str [] = "localName"
const char js_xml_parent_str [] = "parent"
const char js_prefix_str [] = "prefix"
const char js_toXMLString_str [] = "toXMLString"
const char js_uri_str [] = "uri"
const char js_amp_entity_str [] = "&amp;"
const char js_gt_entity_str [] = "&gt;"
const char js_lt_entity_str [] = "&lt;"
const char js_quot_entity_str [] = "&quot;"
static JSPropertySpec namespace_props []
static JSFunctionSpec namespace_methods []
static JSPropertySpec qname_props []
static JSFunctionSpec qname_methods []
static const char js_ignoreComments_str [] = "ignoreComments"
static const char js_ignoreProcessingInstructions_str [] = "ignoreProcessingInstructions"
static const char js_ignoreWhitespace_str [] = "ignoreWhitespace"
static const char js_prettyPrinting_str [] = "prettyPrinting"
static const char js_prettyIndent_str [] = "prettyIndent"
static JSPropertySpec xml_static_props []
static const char xml_namespace_str [] = "http://www.w3.org/XML/1998/namespace"
static const char xmlns_namespace_str [] = "http://www.w3.org/2000/xmlns/"
static const char js_attribute_str [] = "attribute"
static const char js_text_str [] = "text"
const char * js_xml_class_str []
static JSFunctionSpec xml_methods []
static JSFunctionSpec xml_static_methods []
static size_t sizeof_JSXML [JSXML_CLASS_LIMIT]

Class Documentation

struct JSTempRootedNSArray

Definition at line 6158 of file jsxml.c.

Class Members
JSXMLArray array
JSTempValueRooter tvr
jsval value

Define Documentation

#define CHECK_COPY_ON_WRITE (   cx,
  xml,
  obj 
)    (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj))

Definition at line 4223 of file jsxml.c.

#define constrlen (   constr)    (sizeof(constr) - 1)
#define DROP_PROPERTY (   cx,
  pobj,
  prop 
)
Value:
(((prop) != FOUND_XML_PROPERTY)       \
                                         ? OBJ_DROP_PROPERTY(cx, pobj, prop)  \
                                         : (void) 0)

Definition at line 4964 of file jsxml.c.

Definition at line 4963 of file jsxml.c.

Value:
(JS_TOLOWER((chars)[3]) == 'n' &&                                         \
     JS_TOLOWER((chars)[4]) == 's')

Definition at line 1392 of file jsxml.c.

#define IS_EMPTY (   str)    (JSSTRING_LENGTH(str) == 0)

Definition at line 132 of file jsxml.c.

#define IS_STAR (   str)    (JSSTRING_LENGTH(str) == 1 && *JSSTRING_CHARS(str) == '*')

Definition at line 133 of file jsxml.c.

Definition at line 1381 of file jsxml.c.

Value:
(JS_TOLOWER((chars)[0]) == 'x' &&                                         \
     JS_TOLOWER((chars)[1]) == 'm' &&                                         \
     JS_TOLOWER((chars)[2]) == 'l')

Definition at line 1387 of file jsxml.c.

Definition at line 1384 of file jsxml.c.

Definition at line 1396 of file jsxml.c.

#define JSXML_ELEMENT_SIZE   (offsetof(JSXML, u) + sizeof(struct JSXMLVar))

Definition at line 7447 of file jsxml.c.

#define JSXML_LEAF_SIZE   (offsetof(JSXML, u) + sizeof(JSString *))

Definition at line 7448 of file jsxml.c.

#define JSXML_LIST_SIZE   (offsetof(JSXML, u) + sizeof(struct JSXMLListVar))

Definition at line 7446 of file jsxml.c.

Definition at line 1160 of file jsxml.c.

Definition at line 1159 of file jsxml.c.

#define METER (   x)    /* nothing */

Definition at line 112 of file jsxml.c.

Definition at line 254 of file jsxml.c.

Value:
JS_BEGIN_MACRO                                                            \
        xml = StartNonListXMLMethod(cx, &obj, argv);                          \
        if (!xml)                                                             \
            return JS_FALSE;                                                  \
        JS_ASSERT(xml->xml_class != JSXML_CLASS_LIST);                        \
    JS_END_MACRO

Definition at line 5647 of file jsxml.c.

#define PN2X_SKIP_CHILD   ((JSXML *) 1)

Definition at line 489 of file jsxml.c.

#define STARTS_WITH_XML (   chars,
  length 
)    (length >= 3 && IS_XML_CHARS(chars))

Definition at line 1399 of file jsxml.c.

#define UNMETER (   x)    /* nothing */

Definition at line 113 of file jsxml.c.

Value:
JS_BEGIN_MACRO                                                            \
        xml = (JSXML *) JS_GetInstancePrivate(cx, obj, &js_XMLClass, argv);   \
        if (!xml)                                                             \
            return JS_FALSE;                                                  \
    JS_END_MACRO

Definition at line 5640 of file jsxml.c.

#define XML_NOT_FOUND   ((uint32) -1)

Definition at line 1130 of file jsxml.c.

#define XMLARRAY_ADD_MEMBER (   x,
  a,
  i,
  e 
)    XMLArrayAddMember(x, a, i, (void *)(e))

Definition at line 1287 of file jsxml.c.

#define XMLARRAY_APPEND (   x,
  a,
  e 
)    XMLARRAY_ADD_MEMBER(x, a, (a)->length, (e))

Definition at line 1289 of file jsxml.c.

#define XMLARRAY_DELETE (   x,
  a,
  i,
  c,
  t 
)    ((t *) XMLArrayDelete(x, a, i, c))

Definition at line 1290 of file jsxml.c.

#define XMLARRAY_FIND_MEMBER (   a,
  e,
  f 
)    XMLArrayFindMember(a, (void *)(e), f)

Definition at line 1276 of file jsxml.c.

#define XMLARRAY_HAS_MEMBER (   a,
  e,
  f 
)
Value:
(XMLArrayFindMember(a, (void *)(e), f) != \
                                     XML_NOT_FOUND)

Definition at line 1277 of file jsxml.c.

#define XMLARRAY_INSERT (   x,
  a,
  i,
  n 
)    XMLArrayInsert(x, a, i, n)

Definition at line 1288 of file jsxml.c.

#define XMLARRAY_MEMBER (   a,
  i,
  t 
)
Value:
(((i) < (a)->length)                      \
                                     ? (t *) (a)->vector[i]                   \
                                     : NULL)

Definition at line 1279 of file jsxml.c.

#define XMLARRAY_SET_MEMBER (   a,
  i,
  e 
)
Value:
JS_BEGIN_MACRO                            \
                                        if ((a)->length <= (i))               \
                                            (a)->length = (i) + 1;            \
                                        ((a)->vector[i] = (void *)(e));       \
                                    JS_END_MACRO

Definition at line 1282 of file jsxml.c.

#define XMLARRAY_TRUNCATE (   x,
  a,
  n 
)    XMLArrayTruncate(x, a, n)

Definition at line 1291 of file jsxml.c.

Definition at line 1363 of file jsxml.c.

Definition at line 1358 of file jsxml.c.

Definition at line 1359 of file jsxml.c.

Definition at line 1361 of file jsxml.c.

Definition at line 1378 of file jsxml.c.

Definition at line 1362 of file jsxml.c.


Typedef Documentation

typedef JSBool(* JSXMLNameMatcher)(JSXMLQName *nameqn, JSXML *xml)

Definition at line 3517 of file jsxml.c.


Enumeration Type Documentation

Enumerator:
NAMESPACE_PREFIX 
NAMESPACE_URI 

Definition at line 146 of file jsxml.c.

Enumerator:
QNAME_URI 
QNAME_LOCALNAME 

Definition at line 358 of file jsxml.c.

                  {
    QNAME_URI = -1,
    QNAME_LOCALNAME = -2
};
Enumerator:
XML_IGNORE_COMMENTS 
XML_IGNORE_PROCESSING_INSTRUCTIONS 
XML_IGNORE_WHITESPACE 
XML_PRETTY_PRINTING 
XML_PRETTY_INDENT 

Definition at line 1310 of file jsxml.c.


Function Documentation

static JSBool AddInScopeNamespace ( JSContext cx,
JSXML xml,
JSXMLNamespace ns 
) [static]

Definition at line 3227 of file jsxml.c.

{
    JSXMLNamespace *match, *ns2;
    uint32 i, n, m;

    if (xml->xml_class != JSXML_CLASS_ELEMENT)
        return JS_TRUE;

    /* NULL means *undefined* here -- see ECMA-357 9.1.1.13 step 2. */
    if (!ns->prefix) {
        match = NULL;
        for (i = 0, n = xml->xml_namespaces.length; i < n; i++) {
            ns2 = XMLARRAY_MEMBER(&xml->xml_namespaces, i, JSXMLNamespace);
            if (ns2 && js_EqualStrings(ns2->uri, ns->uri)) {
                match = ns2;
                break;
            }
        }
        if (!match && !XMLARRAY_ADD_MEMBER(cx, &xml->xml_namespaces, n, ns))
            return JS_FALSE;
    } else {
        if (IS_EMPTY(ns->prefix) && IS_EMPTY(xml->name->uri))
            return JS_TRUE;
        match = NULL;
#ifdef __GNUC__         /* suppress bogus gcc warnings */
        m = XML_NOT_FOUND;
#endif
        for (i = 0, n = xml->xml_namespaces.length; i < n; i++) {
            ns2 = XMLARRAY_MEMBER(&xml->xml_namespaces, i, JSXMLNamespace);
            if (ns2 && ns2->prefix &&
                js_EqualStrings(ns2->prefix, ns->prefix)) {
                match = ns2;
                m = i;
                break;
            }
        }
        if (match && !js_EqualStrings(match->uri, ns->uri)) {
            ns2 = XMLARRAY_DELETE(cx, &xml->xml_namespaces, m, JS_TRUE,
                                  JSXMLNamespace);
            JS_ASSERT(ns2 == match);
            match->prefix = NULL;
            if (!AddInScopeNamespace(cx, xml, match))
                return JS_FALSE;
        }
        if (!XMLARRAY_APPEND(cx, &xml->xml_namespaces, ns))
            return JS_FALSE;
    }

    /* OPTION: enforce that descendants have superset namespaces. */
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void anyname_finalize ( JSContext cx,
JSObject obj 
) [static]

Definition at line 401 of file jsxml.c.

{
    JSRuntime *rt;

    /* Make sure the next call to js_GetAnyName doesn't try to use obj. */
    rt = cx->runtime;
    if (rt->anynameObject == obj)
        rt->anynameObject = NULL;

    qname_finalize(cx, obj);
}

Here is the call graph for this function:

static JSBool anyname_toString ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 7973 of file jsxml.c.

Here is the caller graph for this function:

static JSBool Append ( JSContext cx,
JSXML list,
JSXML kid 
) [static]

Definition at line 3281 of file jsxml.c.

{
    uint32 i, j, k, n;
    JSXML *kid;

    JS_ASSERT(list->xml_class == JSXML_CLASS_LIST);
    i = list->xml_kids.length;
    n = 1;
    if (xml->xml_class == JSXML_CLASS_LIST) {
        list->xml_target = xml->xml_target;
        list->xml_targetprop = xml->xml_targetprop;
        n = JSXML_LENGTH(xml);
        k = i + n;
        if (!XMLArraySetCapacity(cx, &list->xml_kids, k))
            return JS_FALSE;
        for (j = 0; j < n; j++) {
            kid = XMLARRAY_MEMBER(&xml->xml_kids, j, JSXML);
            if (kid)
                XMLARRAY_SET_MEMBER(&list->xml_kids, i + j, kid);
        }
        return JS_TRUE;
    }

    list->xml_target = xml->parent;
    if (xml->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION)
        list->xml_targetprop = NULL;
    else
        list->xml_targetprop = xml->name;
    if (!XMLARRAY_ADD_MEMBER(cx, &list->xml_kids, i, xml))
        return JS_FALSE;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void AppendAttributeValue ( JSContext cx,
JSStringBuffer sb,
JSString valstr 
) [static]

Definition at line 2355 of file jsxml.c.

{
    js_AppendCString(sb, "=\"");
    valstr = js_EscapeAttributeValue(cx, valstr);
    if (!valstr) {
        free(sb->base);
        sb->base = STRING_BUFFER_ERROR_BASE;
        return;
    }
    js_AppendJSString(sb, valstr);
    js_AppendChar(sb, '"');
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool attr_identity ( const void a,
const void b 
) [static]

Definition at line 1004 of file jsxml.c.

{
    const JSXML *xmla = (const JSXML *) a;
    const JSXML *xmlb = (const JSXML *) b;

    return qname_identity(xmla->name, xmlb->name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool AttributeName ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 977 of file jsxml.c.

{
    return QNameHelper(cx, (cx->fp->flags & JSFRAME_CONSTRUCTING) ? obj : NULL,
                       &js_AttributeNameClass, argc, argv, rval);
}

Here is the call graph for this function:

static JSBool CheckCycle ( JSContext cx,
JSXML xml,
JSXML kid 
) [static]

Definition at line 3753 of file jsxml.c.

{
    JS_ASSERT(kid->xml_class != JSXML_CLASS_LIST);

    do {
        if (xml == kid) {
            JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                                 JSMSG_CYCLIC_VALUE, js_XML_str);
            return JS_FALSE;
        }
    } while ((xml = xml->parent) != NULL);

    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSString* ChompXMLWhitespace ( JSContext cx,
JSString str 
) [static]

Definition at line 1498 of file jsxml.c.

{
    size_t length, newlength, offset;
    const jschar *cp, *start, *end;
    jschar c;

    length = JSSTRING_LENGTH(str);
    for (cp = start = JSSTRING_CHARS(str), end = cp + length; cp < end; cp++) {
        c = *cp;
        if (!JS_ISXMLSPACE(c))
            break;
    }
    while (end > cp) {
        c = end[-1];
        if (!JS_ISXMLSPACE(c))
            break;
        --end;
    }
    newlength = PTRDIFF(end, cp, jschar);
    if (newlength == length)
        return str;
    offset = PTRDIFF(cp, start, jschar);
    return js_NewDependentString(cx, str, offset, newlength, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSXML* CopyOnWrite ( JSContext cx,
JSXML xml,
JSObject obj 
) [static]

Definition at line 4211 of file jsxml.c.

{
    JS_ASSERT(xml->object != obj);

    xml = DeepCopy(cx, xml, obj, 0);
    if (!xml)
        return NULL;

    JS_ASSERT(xml->object == obj);
    return xml;
}

Here is the call graph for this function:

static JSBool CopyXMLSettings ( JSContext cx,
JSObject from,
JSObject to 
) [static]

Definition at line 7280 of file jsxml.c.

{
    int i;
    const char *name;
    jsval v;

    for (i = XML_IGNORE_COMMENTS; i < XML_PRETTY_INDENT; i++) {
        name = xml_static_props[i].name;
        if (!JS_GetProperty(cx, from, name, &v))
            return JS_FALSE;
        if (JSVAL_IS_BOOLEAN(v) && !JS_SetProperty(cx, to, name, &v))
            return JS_FALSE;
    }

    name = xml_static_props[i].name;
    if (!JS_GetProperty(cx, from, name, &v))
        return JS_FALSE;
    if (JSVAL_IS_NUMBER(v) && !JS_SetProperty(cx, to, name, &v))
        return JS_FALSE;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSXML* DeepCopy ( JSContext cx,
JSXML xml,
JSObject obj,
uintN  flags 
) [static]

Definition at line 3319 of file jsxml.c.

{
    JSXML *copy;
    JSBool ok;

    /* Our caller may not be protecting newborns with a local root scope. */
    if (!js_EnterLocalRootScope(cx))
        return NULL;
    copy = DeepCopyInLRS(cx, xml, flags);
    if (copy) {
        if (obj) {
            /* Caller provided the object for this copy, hook 'em up. */
            ok = JS_SetPrivate(cx, obj, copy);
            if (ok)
                copy->object = obj;
        } else {
            ok = js_GetXMLObject(cx, copy) != NULL;
        }
        if (!ok)
            copy = NULL;
    }
    js_LeaveLocalRootScopeWithResult(cx, (jsval) copy);
    return copy;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSXML * DeepCopyInLRS ( JSContext cx,
JSXML xml,
uintN  flags 
) [static]

Definition at line 3414 of file jsxml.c.

{
    JSXML *copy;
    JSXMLQName *qn;
    JSBool ok;
    uint32 i, n;
    JSXMLNamespace *ns, *ns2;

    /* Our caller must be protecting newborn objects. */
    JS_ASSERT(cx->localRootStack);

    copy = js_NewXML(cx, xml->xml_class);
    if (!copy)
        return NULL;
    qn = xml->name;
    if (qn) {
        qn = js_NewXMLQName(cx, qn->uri, qn->prefix, qn->localName);
        if (!qn) {
            ok = JS_FALSE;
            goto out;
        }
    }
    copy->name = qn;
    copy->xml_flags = xml->xml_flags;

    if (JSXML_HAS_VALUE(xml)) {
        copy->xml_value = xml->xml_value;
        ok = JS_TRUE;
    } else {
        ok = DeepCopySetInLRS(cx, &xml->xml_kids, &copy->xml_kids, copy, flags);
        if (!ok)
            goto out;

        if (xml->xml_class == JSXML_CLASS_LIST) {
            copy->xml_target = xml->xml_target;
            copy->xml_targetprop = xml->xml_targetprop;
        } else {
            n = xml->xml_namespaces.length;
            ok = XMLArraySetCapacity(cx, &copy->xml_namespaces, n);
            if (!ok)
                goto out;
            for (i = 0; i < n; i++) {
                ns = XMLARRAY_MEMBER(&xml->xml_namespaces, i, JSXMLNamespace);
                if (!ns)
                    continue;
                ns2 = js_NewXMLNamespace(cx, ns->prefix, ns->uri, ns->declared);
                if (!ns2) {
                    copy->xml_namespaces.length = i;
                    ok = JS_FALSE;
                    goto out;
                }
                XMLARRAY_SET_MEMBER(&copy->xml_namespaces, i, ns2);
            }

            ok = DeepCopySetInLRS(cx, &xml->xml_attrs, &copy->xml_attrs, copy,
                                  0);
            if (!ok)
                goto out;
        }
    }

out:
    if (!ok)
        return NULL;
    return copy;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool DeepCopySetInLRS ( JSContext cx,
JSXMLArray from,
JSXMLArray to,
JSXML parent,
uintN  flags 
) [static]

Definition at line 3350 of file jsxml.c.

{
    uint32 j, n;
    JSXMLArrayCursor cursor;
    JSBool ok;
    JSXML *kid, *kid2;
    JSString *str;

    JS_ASSERT(cx->localRootStack);

    n = from->length;
    if (!XMLArraySetCapacity(cx, to, n))
        return JS_FALSE;

    XMLArrayCursorInit(&cursor, from);
    j = 0;
    ok = JS_TRUE;
    while ((kid = (JSXML *) XMLArrayCursorNext(&cursor)) != NULL) {
        if ((flags & XSF_IGNORE_COMMENTS) &&
            kid->xml_class == JSXML_CLASS_COMMENT) {
            continue;
        }
        if ((flags & XSF_IGNORE_PROCESSING_INSTRUCTIONS) &&
            kid->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION) {
            continue;
        }
        if ((flags & XSF_IGNORE_WHITESPACE) &&
            (kid->xml_flags & XMLF_WHITESPACE_TEXT)) {
            continue;
        }
        kid2 = DeepCopyInLRS(cx, kid, flags);
        if (!kid2) {
            to->length = j;
            ok = JS_FALSE;
            break;
        }

        if ((flags & XSF_IGNORE_WHITESPACE) &&
            n > 1 && kid2->xml_class == JSXML_CLASS_TEXT) {
            str = ChompXMLWhitespace(cx, kid2->xml_value);
            if (!str) {
                to->length = j;
                ok = JS_FALSE;
                break;
            }
            kid2->xml_value = str;
        }

        XMLARRAY_SET_MEMBER(to, j, kid2);
        ++j;
        if (parent->xml_class != JSXML_CLASS_LIST)
            kid2->parent = parent;
    }
    XMLArrayCursorFinish(&cursor);
    if (!ok)
        return JS_FALSE;

    if (j < n)
        XMLArrayTrim(to);
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool DeleteByIndex ( JSContext cx,
JSXML xml,
jsval  id,
jsval vp 
) [static]

Definition at line 3496 of file jsxml.c.

{
    uint32 index;
    JSXML *kid;

    if (!js_IdIsIndex(id, &index)) {
        ReportBadXMLName(cx, id);
        return JS_FALSE;
    }

    if (JSXML_HAS_KIDS(xml) && index < xml->xml_kids.length) {
        kid = XMLARRAY_MEMBER(&xml->xml_kids, index, JSXML);
        if (kid)
            kid->parent = NULL;
        XMLArrayDelete(cx, &xml->xml_kids, index, JS_TRUE);
    }

    *vp = JSVAL_TRUE;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool DeleteProperty ( JSContext cx,
JSObject obj,
jsval  id,
jsval vp 
) [static]

Definition at line 3939 of file jsxml.c.

{
    JSXML *xml, *kid, *parent;
    JSBool isIndex;
    JSXMLArray *array;
    uint32 length, index, kidIndex, deleteCount;
    JSXMLQName *nameqn;
    jsid funid;
    JSObject *nameobj, *kidobj;
    JSXMLNameMatcher matcher;

    xml = (JSXML *) JS_GetPrivate(cx, obj);
    isIndex = js_IdIsIndex(id, &index);
    if (JSXML_HAS_KIDS(xml)) {
        array = &xml->xml_kids;
        length = array->length;
    } else {
        array = NULL;
        length = 0;
    }

    if (xml->xml_class == JSXML_CLASS_LIST) {
        /* ECMA-357 9.2.1.3. */
        if (isIndex && index < length) {
            kid = XMLARRAY_MEMBER(array, index, JSXML);
            if (!kid)
                goto out;
            parent = kid->parent;
            if (parent) {
                JS_ASSERT(parent != xml);
                JS_ASSERT(JSXML_HAS_KIDS(parent));

                if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
                    nameqn = kid->name;
                    nameobj = js_GetAttributeNameObject(cx, nameqn);
                    if (!nameobj || !js_GetXMLObject(cx, parent))
                        return JS_FALSE;

                    id = OBJECT_TO_JSVAL(nameobj);
                    if (!DeleteProperty(cx, parent->object, id, vp))
                        return JS_FALSE;
                } else {
                    kidIndex = XMLARRAY_FIND_MEMBER(&parent->xml_kids, kid,
                                                    NULL);
                    JS_ASSERT(kidIndex != XML_NOT_FOUND);
                    if (!IndexToIdVal(cx, kidIndex, &id))
                        return JS_FALSE;
                    if (!DeleteByIndex(cx, parent, id, vp))
                        return JS_FALSE;
                }
            }

            XMLArrayDelete(cx, array, index, JS_TRUE);
        } else {
            for (index = 0; index < length; index++) {
                kid = XMLARRAY_MEMBER(array, index, JSXML);
                if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
                    kidobj = js_GetXMLObject(cx, kid);
                    if (!kidobj || !DeleteProperty(cx, kidobj, id, vp))
                        return JS_FALSE;
                }
            }
        }
    } else {
        /* ECMA-357 9.1.1.3. */
        if (isIndex) {
            /* See NOTE in spec: this variation is reserved for future use. */
            ReportBadXMLName(cx, id);
            return JS_FALSE;
        }

        nameqn = ToXMLName(cx, id, &funid);
        if (!nameqn)
            return JS_FALSE;
        if (funid)
            goto out;
        nameobj = nameqn->object;

        if (OBJ_GET_CLASS(cx, nameobj) == &js_AttributeNameClass) {
            if (xml->xml_class != JSXML_CLASS_ELEMENT)
                goto out;
            array = &xml->xml_attrs;
            length = array->length;
            matcher = MatchAttrName;
        } else {
            matcher = MatchElemName;
        }
        if (length != 0) {
            deleteCount = 0;
            for (index = 0; index < length; index++) {
                kid = XMLARRAY_MEMBER(array, index, JSXML);
                if (kid && matcher(nameqn, kid)) {
                    kid->parent = NULL;
                    XMLArrayDelete(cx, array, index, JS_FALSE);
                    ++deleteCount;
                } else if (deleteCount != 0) {
                    XMLARRAY_SET_MEMBER(array,
                                        index - deleteCount,
                                        array->vector[index]);
                }
            }
            array->length -= deleteCount;
        }
    }

out:
    *vp = JSVAL_TRUE;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSXML* Descendants ( JSContext cx,
JSXML xml,
jsval  id 
) [static]

Definition at line 3575 of file jsxml.c.

{
    jsid funid;
    JSXMLQName *nameqn;
    JSObject *listobj;
    JSXML *list, *kid;
    uint32 i, n;
    JSBool ok;

    nameqn = ToXMLName(cx, id, &funid);
    if (!nameqn)
        return NULL;

    listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
    if (!listobj)
        return NULL;
    list = (JSXML *) JS_GetPrivate(cx, listobj);
    if (funid)
        return list;

    /*
     * Protect nameqn's object and strings from GC by linking list to it
     * temporarily.  The cx->newborn[GCX_OBJECT] GC root protects listobj,
     * which protects list.  Any other object allocations occuring beneath
     * DescendantsHelper use local roots.
     */
    list->name = nameqn;
    if (!js_EnterLocalRootScope(cx))
        return NULL;
    if (xml->xml_class == JSXML_CLASS_LIST) {
        ok = JS_TRUE;
        for (i = 0, n = xml->xml_kids.length; i < n; i++) {
            kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
            if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
                ok = DescendantsHelper(cx, kid, nameqn, list);
                if (!ok)
                    break;
            }
        }
    } else {
        ok = DescendantsHelper(cx, xml, nameqn, list);
    }
    js_LeaveLocalRootScopeWithResult(cx, (jsval) list);
    if (!ok)
        return NULL;
    list->name = NULL;
    return list;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool DescendantsHelper ( JSContext cx,
JSXML xml,
JSXMLQName nameqn,
JSXML list 
) [static]

Definition at line 3543 of file jsxml.c.

{
    uint32 i, n;
    JSXML *attr, *kid;

    if (xml->xml_class == JSXML_CLASS_ELEMENT &&
        OBJ_GET_CLASS(cx, nameqn->object) == &js_AttributeNameClass) {
        for (i = 0, n = xml->xml_attrs.length; i < n; i++) {
            attr = XMLARRAY_MEMBER(&xml->xml_attrs, i, JSXML);
            if (attr && MatchAttrName(nameqn, attr)) {
                if (!Append(cx, list, attr))
                    return JS_FALSE;
            }
        }
    }

    for (i = 0, n = JSXML_LENGTH(xml); i < n; i++) {
        kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
        if (!kid)
            continue;
        if (OBJ_GET_CLASS(cx, nameqn->object) != &js_AttributeNameClass &&
            MatchElemName(nameqn, kid)) {
            if (!Append(cx, list, kid))
                return JS_FALSE;
        }
        if (!DescendantsHelper(cx, kid, nameqn, list))
            return JS_FALSE;
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool Equals ( JSContext cx,
JSXML xml,
jsval  v,
JSBool bp 
) [static]

Definition at line 3719 of file jsxml.c.

{
    JSObject *vobj;
    JSXML *vxml;

    if (JSVAL_IS_PRIMITIVE(v)) {
        *bp = JS_FALSE;
        if (xml->xml_class == JSXML_CLASS_LIST) {
            if (xml->xml_kids.length == 1) {
                vxml = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
                if (!vxml)
                    return JS_TRUE;
                vobj = js_GetXMLObject(cx, vxml);
                if (!vobj)
                    return JS_FALSE;
                return js_XMLObjectOps.equality(cx, vobj, v, bp);
            }
            if (JSVAL_IS_VOID(v) && xml->xml_kids.length == 0)
                *bp = JS_TRUE;
        }
    } else {
        vobj = JSVAL_TO_OBJECT(v);
        if (!OBJECT_IS_XML(cx, vobj)) {
            *bp = JS_FALSE;
        } else {
            vxml = (JSXML *) JS_GetPrivate(cx, vobj);
            if (!XMLEquals(cx, xml, vxml, bp))
                return JS_FALSE;
        }
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSString* EscapeAttributeValue ( JSContext cx,
JSStringBuffer sb,
JSString str 
) [static]

Definition at line 2428 of file jsxml.c.

{
    size_t length, newlength;
    const jschar *cp, *start, *end;
    jschar c;

    length = newlength = JSSTRING_LENGTH(str);
    for (cp = start = JSSTRING_CHARS(str), end = cp + length; cp < end; cp++) {
        c = *cp;
        if (c == '"')
            newlength += 5;
        else if (c == '<')
            newlength += 3;
        else if (c == '&' || c == '\n' || c == '\r' || c == '\t')
            newlength += 4;

        if (newlength < length) {
            JS_ReportOutOfMemory(cx);
            return NULL;
        }
    }
    if ((sb && STRING_BUFFER_OFFSET(sb) != 0) || newlength > length) {
        JSStringBuffer localSB;
        if (!sb) {
            sb = &localSB;
            js_InitStringBuffer(sb);
        }
        if (!sb->grow(sb, newlength)) {
            JS_ReportOutOfMemory(cx);
            return NULL;
        }
        for (cp = start; cp < end; cp++) {
            c = *cp;
            if (c == '"')
                js_AppendCString(sb, js_quot_entity_str);
            else if (c == '<')
                js_AppendCString(sb, js_lt_entity_str);
            else if (c == '&')
                js_AppendCString(sb, js_amp_entity_str);
            else if (c == '\n')
                js_AppendCString(sb, "&#xA;");
            else if (c == '\r')
                js_AppendCString(sb, "&#xD;");
            else if (c == '\t')
                js_AppendCString(sb, "&#x9;");
            else
                js_AppendChar(sb, c);
        }
        JS_ASSERT(STRING_BUFFER_OK(sb));
        str = js_NewString(cx, sb->base, STRING_BUFFER_OFFSET(sb), 0);
        if (!str)
            js_FinishStringBuffer(sb);
    }
    return str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSString* EscapeElementValue ( JSContext cx,
JSStringBuffer sb,
JSString str 
) [static]

Definition at line 2375 of file jsxml.c.

{
    size_t length, newlength;
    const jschar *cp, *start, *end;
    jschar c;

    length = newlength = JSSTRING_LENGTH(str);
    for (cp = start = JSSTRING_CHARS(str), end = cp + length; cp < end; cp++) {
        c = *cp;
        if (c == '<' || c == '>')
            newlength += 3;
        else if (c == '&')
            newlength += 4;

        if (newlength < length) {
            JS_ReportOutOfMemory(cx);
            return NULL;
        }
    }
    if ((sb && STRING_BUFFER_OFFSET(sb) != 0) || newlength > length) {
        JSStringBuffer localSB;
        if (!sb) {
            sb = &localSB;
            js_InitStringBuffer(sb);
        }
        if (!sb->grow(sb, newlength)) {
            JS_ReportOutOfMemory(cx);
            return NULL;
        }
        for (cp = start; cp < end; cp++) {
            c = *cp;
            if (c == '<')
                js_AppendCString(sb, js_lt_entity_str);
            else if (c == '>')
                js_AppendCString(sb, js_gt_entity_str);
            else if (c == '&')
                js_AppendCString(sb, js_amp_entity_str);
            else
                js_AppendChar(sb, c);
        }
        JS_ASSERT(STRING_BUFFER_OK(sb));
        str = js_NewString(cx, sb->base, STRING_BUFFER_OFFSET(sb), 0);
        if (!str)
            js_FinishStringBuffer(sb);
    }
    return str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool FillSettingsCache ( JSContext cx) [static]

Definition at line 1904 of file jsxml.c.

{
    int i;
    const char *name;
    jsval v;
    JSBool isSet;

    /* Note: XML_PRETTY_INDENT is not a boolean setting. */
    for (i = XML_IGNORE_COMMENTS; i < XML_PRETTY_INDENT; i++) {
        name = xml_static_props[i].name;
        if (!GetXMLSetting(cx, name, &v) || !js_ValueToBoolean(cx, v, &isSet))
            return JS_FALSE;
        if (isSet)
            cx->xmlSettingFlags |= JS_BIT(i);
        else
            cx->xmlSettingFlags &= ~JS_BIT(i);
    }

    cx->xmlSettingFlags |= XSF_CACHE_VALID;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool FindInScopeNamespaces ( JSContext cx,
JSXML xml,
JSXMLArray nsarray 
) [static]

Definition at line 6224 of file jsxml.c.

{
    uint32 length, i, j, n;
    JSXMLNamespace *ns, *ns2;

    length = nsarray->length;
    do {
        if (xml->xml_class != JSXML_CLASS_ELEMENT)
            continue;
        for (i = 0, n = xml->xml_namespaces.length; i < n; i++) {
            ns = XMLARRAY_MEMBER(&xml->xml_namespaces, i, JSXMLNamespace);
            if (!ns)
                continue;

            for (j = 0; j < length; j++) {
                ns2 = XMLARRAY_MEMBER(nsarray, j, JSXMLNamespace);
                if (ns2 &&
                    ((ns2->prefix && ns->prefix)
                     ? js_EqualStrings(ns2->prefix, ns->prefix)
                     : js_EqualStrings(ns2->uri, ns->uri))) {
                    break;
                }
            }

            if (j == length) {
                if (!XMLARRAY_APPEND(cx, nsarray, ns))
                    return JS_FALSE;
                ++length;
            }
        }
    } while ((xml = xml->parent) != NULL);
    JS_ASSERT(length == nsarray->length);

    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void FinishTempNSArray ( JSContext cx,
JSTempRootedNSArray tmp 
) [static]

Definition at line 6186 of file jsxml.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool FoundProperty ( JSContext cx,
JSObject obj,
jsid  id,
JSProperty prop,
JSBool foundp 
) [static]

Definition at line 5176 of file jsxml.c.

{
    JSObject *pobj;

    if (prop) {
        *foundp = JS_TRUE;
    } else {
        if (!HasProperty(cx, obj, ID_TO_VALUE(id), &pobj, &prop))
            return JS_FALSE;
        if (prop)
            DROP_PROPERTY(cx, pobj, prop);
        *foundp = (prop != NULL);
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSString* GeneratePrefix ( JSContext cx,
JSString uri,
JSXMLArray decls 
) [static]

Definition at line 2564 of file jsxml.c.

{
    const jschar *cp, *start, *end;
    size_t length, newlength, offset;
    uint32 i, n, m, serial;
    jschar *bp, *dp;
    JSBool done;
    JSXMLNamespace *ns;
    JSString *prefix;

    JS_ASSERT(!IS_EMPTY(uri));

    /*
     * If there are no *declared* namespaces, skip all collision detection and
     * return a short prefix quickly; an example of such a situation:
     *
     *   var x = <f/>;
     *   var n = new Namespace("http://example.com/");
     *   x.@n::att = "val";
     *   x.toXMLString();
     *
     * This is necessary for various log10 uses below to be valid.
     */
    if (decls->length == 0)
        return JS_NewStringCopyZ(cx, "a");

    /*
     * Try peeling off the last filename suffix or pathname component till
     * we have a valid XML name.  This heuristic will prefer "xul" given
     * ".../there.is.only.xul", "xbl" given ".../xbl", and "xbl2" given any
     * likely URI of the form ".../xbl2/2005".
     */
    start = JSSTRING_CHARS(uri);
    cp = end = start + JSSTRING_LENGTH(uri);
    while (--cp > start) {
        if (*cp == '.' || *cp == '/' || *cp == ':') {
            ++cp;
            length = PTRDIFF(end, cp, jschar);
            if (IsXMLName(cp, length) && !STARTS_WITH_XML(cp, length))
                break;
            end = --cp;
        }
    }
    length = PTRDIFF(end, cp, jschar);

    /*
     * If the namespace consisted only of non-XML names or names that begin
     * case-insensitively with "xml", arbitrarily create a prefix consisting
     * of 'a's of size length (allowing dp-calculating code to work with or
     * without this branch executing) plus the space for storing a hyphen and
     * the serial number (avoiding reallocation if a collision happens).
     */
    bp = (jschar *) cp;
    newlength = length;
    if (STARTS_WITH_XML(cp, length) || !IsXMLName(cp, length)) {
        newlength = length + 2 + (size_t) log10(decls->length);
        bp = (jschar *)
             JS_malloc(cx, (newlength + 1) * sizeof(jschar));
        if (!bp)
            return NULL;

        bp[newlength] = 0;
        for (i = 0; i < newlength; i++)
             bp[i] = 'a';
    }

    /*
     * Now search through decls looking for a collision.  If we collide with
     * an existing prefix, start tacking on a hyphen and a serial number.
     */
    serial = 0;
    do {
        done = JS_TRUE;
        for (i = 0, n = decls->length; i < n; i++) {
            ns = XMLARRAY_MEMBER(decls, i, JSXMLNamespace);
            if (ns && ns->prefix &&
                JSSTRING_LENGTH(ns->prefix) == newlength &&
                !memcmp(JSSTRING_CHARS(ns->prefix), bp,
                        newlength * sizeof(jschar))) {
                if (bp == cp) {
                    newlength = length + 2 + (size_t) log10(n);
                    bp = (jschar *)
                         JS_malloc(cx, (newlength + 1) * sizeof(jschar));
                    if (!bp)
                        return NULL;
                    js_strncpy(bp, cp, length);
                }

                ++serial;
                JS_ASSERT(serial <= n);
                dp = bp + length + 2 + (size_t) log10(serial);
                *dp = 0;
                for (m = serial; m != 0; m /= 10)
                    *--dp = (jschar)('0' + m % 10);
                *--dp = '-';
                JS_ASSERT(dp == bp + length);

                done = JS_FALSE;
                break;
            }
        }
    } while (!done);

    if (bp == cp) {
        offset = PTRDIFF(cp, start, jschar);
        prefix = js_NewDependentString(cx, uri, offset, length, 0);
    } else {
        prefix = js_NewString(cx, bp, newlength, 0);
        if (!prefix)
            JS_free(cx, bp);
    }
    return prefix;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool GetBooleanXMLSetting ( JSContext cx,
const char *  name,
JSBool bp 
) [static]

Definition at line 1927 of file jsxml.c.

{
    int i;

    if (!(cx->xmlSettingFlags & XSF_CACHE_VALID) && !FillSettingsCache(cx))
        return JS_FALSE;

    for (i = 0; xml_static_props[i].name; i++) {
        if (!strcmp(xml_static_props[i].name, name)) {
            *bp = (cx->xmlSettingFlags & JS_BIT(i)) != 0;
            return JS_TRUE;
        }
    }
    *bp = JS_FALSE;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool GetNamedProperty ( JSContext cx,
JSXML xml,
JSXMLQName nameqn,
JSBool  attributes,
JSXML list 
) [static]

Definition at line 4070 of file jsxml.c.

{
    JSXMLArray *array;
    JSXMLNameMatcher matcher;
    JSXMLArrayCursor cursor;
    JSXML *kid;
    JSBool ok;

    if (!JSXML_HAS_KIDS(xml))
        return JS_TRUE;

    if (attributes) {
        array = &xml->xml_attrs;
        matcher = MatchAttrName;
    } else {
        array = &xml->xml_kids;
        matcher = MatchElemName;
    }

    XMLArrayCursorInit(&cursor, array);
    while ((kid = (JSXML *) XMLArrayCursorNext(&cursor)) != NULL) {
        if (matcher(nameqn, kid)) {
            if (!attributes && kid->xml_class == JSXML_CLASS_ELEMENT) {
                ok = SyncInScopeNamespaces(cx, kid);
                if (!ok)
                    goto out;
            }
            ok = Append(cx, list, kid);
            if (!ok)
                goto out;
        }
    }
    ok = JS_TRUE;

  out:
    XMLArrayCursorFinish(&cursor);
    return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSXMLNamespace* GetNamespace ( JSContext cx,
JSXMLQName qn,
const JSXMLArray inScopeNSes 
) [static]

Definition at line 2486 of file jsxml.c.

{
    JSXMLNamespace *match, *ns;
    uint32 i, n;
    jsval argv[2];
    JSObject *nsobj;

    JS_ASSERT(qn->uri);
    if (!qn->uri) {
        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                             JSMSG_BAD_XML_NAMESPACE,
                             qn->prefix
                             ? js_ValueToPrintableString(cx,
                                   STRING_TO_JSVAL(qn->prefix))
                             : js_type_strs[JSTYPE_VOID]);
        return NULL;
    }

    /* Look for a matching namespace in inScopeNSes, if provided. */
    match = NULL;
    if (inScopeNSes) {
        for (i = 0, n = inScopeNSes->length; i < n; i++) {
            ns = XMLARRAY_MEMBER(inScopeNSes, i, JSXMLNamespace);
            if (!ns)
                continue;

            /*
             * Erratum, very tricky, and not specified in ECMA-357 13.3.5.4:
             * If we preserve prefixes, we must match null qn->prefix against
             * an empty ns->prefix, in order to avoid generating redundant
             * prefixed and default namespaces for cases such as:
             *
             *   x = <t xmlns="http://foo.com"/>
             *   print(x.toXMLString());
             *
             * Per 10.3.2.1, the namespace attribute in t has an empty string
             * prefix (*not* a null prefix), per 10.3.2.1 Step 6(h)(i)(1):
             *
             *   1. If the [local name] property of a is "xmlns"
             *      a. Map ns.prefix to the empty string
             *
             * But t's name has a null prefix in this implementation, meaning
             * *undefined*, per 10.3.2.1 Step 6(c)'s NOTE (which refers to
             * the http://www.w3.org/TR/xml-infoset/ spec, item 2.2.3, without
             * saying how "no value" maps to an ECMA-357 value -- but it must
             * map to the *undefined* prefix value).
             *
             * Since "" != undefined (or null, in the current implementation)
             * the ECMA-357 spec will fail to match in [[GetNamespace]] called
             * on t with argument {} U {(prefix="", uri="http://foo.com")}.
             * This spec bug leads to ToXMLString results that duplicate the
             * declared namespace.
             */
            if (js_EqualStrings(ns->uri, qn->uri) &&
                (ns->prefix == qn->prefix ||
                 ((ns->prefix && qn->prefix)
                  ? js_EqualStrings(ns->prefix, qn->prefix)
                  : IS_EMPTY(ns->prefix ? ns->prefix : qn->prefix)))) {
                match = ns;
                break;
            }
        }
    }

    /* If we didn't match, make a new namespace from qn. */
    if (!match) {
        argv[0] = qn->prefix ? STRING_TO_JSVAL(qn->prefix) : JSVAL_VOID;
        argv[1] = STRING_TO_JSVAL(qn->uri);
        nsobj = js_ConstructObject(cx, &js_NamespaceClass.base, NULL, NULL,
                                   2, argv);
        if (!nsobj)
            return NULL;
        match = (JSXMLNamespace *) JS_GetPrivate(cx, nsobj);
    }
    return match;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSXML* GetPrivate ( JSContext cx,
JSObject obj,
const char *  method 
) [static]

Definition at line 8160 of file jsxml.c.

{
    JSXML *xml;

    xml = (JSXML *) JS_GetInstancePrivate(cx, obj, &js_XMLClass, NULL);
    if (!xml) {
        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                             JSMSG_INCOMPATIBLE_METHOD,
                             js_XML_str, method, OBJ_GET_CLASS(cx, obj)->name);
    }
    return xml;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool GetProperty ( JSContext cx,
JSObject obj,
jsval  id,
jsval vp 
) [static]

Definition at line 4112 of file jsxml.c.

{
    JSXML *xml, *list, *kid;
    uint32 index;
    JSObject *kidobj, *listobj;
    JSXMLQName *nameqn;
    jsid funid;
    jsval roots[2];
    JSTempValueRooter tvr;
    JSBool attributes;
    JSXMLArrayCursor cursor;

    xml = (JSXML *) JS_GetInstancePrivate(cx, obj, &js_XMLClass, NULL);
    if (!xml)
        return JS_TRUE;

    if (js_IdIsIndex(id, &index)) {
        if (xml->xml_class != JSXML_CLASS_LIST) {
            *vp = (index == 0) ? OBJECT_TO_JSVAL(obj) : JSVAL_VOID;
        } else {
            /*
             * ECMA-357 9.2.1.1 starts here.
             *
             * Erratum: 9.2 is not completely clear that indexed properties
             * correspond to kids, but that's what it seems to say, and it's
             * what any sane user would want.
             */
            if (index < xml->xml_kids.length) {
                kid = XMLARRAY_MEMBER(&xml->xml_kids, index, JSXML);
                if (!kid) {
                    *vp = JSVAL_VOID;
                    return JS_TRUE;
                }
                kidobj = js_GetXMLObject(cx, kid);
                if (!kidobj)
                    return JS_FALSE;

                *vp = OBJECT_TO_JSVAL(kidobj);
            } else {
                *vp = JSVAL_VOID;
            }
        }
        return JS_TRUE;
    }

    /*
     * ECMA-357 9.2.1.1/9.1.1.1 qname case.
     */
    nameqn = ToXMLName(cx, id, &funid);
    if (!nameqn)
        return JS_FALSE;
    if (funid)
        return js_GetXMLFunction(cx, obj, funid, vp);

    roots[0] = OBJECT_TO_JSVAL(nameqn->object);
    JS_PUSH_TEMP_ROOT(cx, 1, roots, &tvr);

    listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
    if (listobj) {
        roots[1] = OBJECT_TO_JSVAL(listobj);
        tvr.count++;

        list = (JSXML *) JS_GetPrivate(cx, listobj);
        attributes = (OBJ_GET_CLASS(cx, nameqn->object) ==
                      &js_AttributeNameClass);

        if (xml->xml_class == JSXML_CLASS_LIST) {
            XMLArrayCursorInit(&cursor, &xml->xml_kids);
            while ((kid = (JSXML *) XMLArrayCursorNext(&cursor)) != NULL) {
                if (kid->xml_class == JSXML_CLASS_ELEMENT &&
                    !GetNamedProperty(cx, kid, nameqn, attributes, list)) {
                    listobj = NULL;
                    break;
                }
            }
            XMLArrayCursorFinish(&cursor);
        } else {
            if (!GetNamedProperty(cx, xml, nameqn, attributes, list))
                listobj = NULL;
        }

        /*
         * Erratum: ECMA-357 9.1.1.1 misses that [[Append]] sets the given
         * list's [[TargetProperty]] to the property that is being appended.
         * This means that any use of the internal [[Get]] property returns
         * a list which, when used by e.g. [[Insert]] duplicates the last
         * element matched by id.
         * See bug 336921.
         */
        list->xml_target = xml;
        list->xml_targetprop = nameqn;
        *vp = OBJECT_TO_JSVAL(listobj);
    }

    JS_POP_TEMP_ROOT(cx, &tvr);
    return listobj != NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool GetUint32XMLSetting ( JSContext cx,
const char *  name,
uint32 uip 
) [static]

Definition at line 1945 of file jsxml.c.

{
    jsval v;

    return GetXMLSetting(cx, name, &v) && js_ValueToECMAUint32(cx, v, uip);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool GetXMLSetting ( JSContext cx,
const char *  name,
jsval vp 
) [static]

Definition at line 1890 of file jsxml.c.

{
    jsval v;

    if (!js_FindClassObject(cx, NULL, INT_TO_JSID(JSProto_XML), &v))
        return JS_FALSE;
    if (!VALUE_IS_FUNCTION(cx, v)) {
        *vp = JSVAL_VOID;
        return JS_TRUE;
    }
    return JS_GetProperty(cx, JSVAL_TO_OBJECT(v), name, vp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool GetXMLSettingFlags ( JSContext cx,
uintN flagsp 
) [static]

Definition at line 1953 of file jsxml.c.

{
    JSBool flag;

    /* Just get the first flag to validate the setting flags cache. */
    if (!GetBooleanXMLSetting(cx, js_ignoreComments_str, &flag))
        return JS_FALSE;
    *flagsp = cx->xmlSettingFlags;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool HasProperty ( JSContext cx,
JSObject obj,
jsval  id,
JSObject **  objp,
JSProperty **  propp 
) [static]

Definition at line 4970 of file jsxml.c.

{
    JSXML *xml, *kid;
    JSXMLArrayCursor cursor;
    JSObject *kidobj;
    JSXMLQName *qn;
    jsid funid;
    JSXMLArray *array;
    JSXMLNameMatcher matcher;
    uint32 i, n;

    *objp = NULL;
    *propp = NULL;

    xml = (JSXML *) JS_GetPrivate(cx, obj);
    if (xml->xml_class == JSXML_CLASS_LIST) {
        n = JSXML_LENGTH(xml);
        if (js_IdIsIndex(id, &i)) {
            if (i < n)
                *propp = FOUND_XML_PROPERTY;
            return JS_TRUE;
        }

        XMLArrayCursorInit(&cursor, &xml->xml_kids);
        while ((kid = (JSXML *) XMLArrayCursorNext(&cursor)) != NULL) {
            if (kid->xml_class == JSXML_CLASS_ELEMENT) {
                kidobj = js_GetXMLObject(cx, kid);
                if (!kidobj || !HasProperty(cx, kidobj, id, objp, propp))
                    break;
                if (*propp)
                    break;
            }
        }
        XMLArrayCursorFinish(&cursor);
        if (kid)
            return *propp != NULL;
    } else {
        if (xml->xml_class == JSXML_CLASS_ELEMENT && js_IdIsIndex(id, &i)) {
            if (i == 0)
                *propp = FOUND_XML_PROPERTY;
            return JS_TRUE;
        }

        qn = ToXMLName(cx, id, &funid);
        if (!qn)
            return JS_FALSE;
        if (funid)
            return js_LookupProperty(cx, obj, funid, objp, propp);

        if (xml->xml_class != JSXML_CLASS_ELEMENT)
            return JS_TRUE;

        if (OBJ_GET_CLASS(cx, qn->object) == &js_AttributeNameClass) {
            array = &xml->xml_attrs;
            matcher = MatchAttrName;
        } else {
            array = &xml->xml_kids;
            matcher = MatchElemName;
        }
        for (i = 0, n = array->length; i < n; i++) {
            kid = XMLARRAY_MEMBER(array, i, JSXML);
            if (kid && matcher(qn, kid)) {
                *propp = FOUND_XML_PROPERTY;
                return JS_TRUE;
            }
        }
    }

    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool HasSimpleContent ( JSXML xml) [static]

Definition at line 5331 of file jsxml.c.

{
    JSXML *kid;
    JSBool simple;
    uint32 i, n;

again:
    switch (xml->xml_class) {
      case JSXML_CLASS_COMMENT:
      case JSXML_CLASS_PROCESSING_INSTRUCTION:
        return JS_FALSE;
      case JSXML_CLASS_LIST:
        if (xml->xml_kids.length == 0)
            return JS_TRUE;
        if (xml->xml_kids.length == 1) {
            kid = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
            if (kid) {
                xml = kid;
                goto again;
            }
        }
        /* FALL THROUGH */
      default:
        simple = JS_TRUE;
        for (i = 0, n = JSXML_LENGTH(xml); i < n; i++) {
            kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
            if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
                simple = JS_FALSE;
                break;
            }
        }
        return simple;
    }
}

Here is the caller graph for this function:

static JSBool IndexToIdVal ( JSContext cx,
uint32  index,
jsval idvp 
) [static]

Definition at line 3839 of file jsxml.c.

{
    JSString *str;

    if (index <= JSVAL_INT_MAX) {
        *idvp = INT_TO_JSVAL(index);
    } else {
        str = js_NumberToString(cx, (jsdouble) index);
        if (!str)
            return JS_FALSE;
        *idvp = STRING_TO_JSVAL(str);
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void InitTempNSArray ( JSContext cx,
JSTempRootedNSArray tmp 
) [static]

Definition at line 6178 of file jsxml.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool Insert ( JSContext cx,
JSXML xml,
uint32  i,
jsval  v 
) [static]

Definition at line 3770 of file jsxml.c.

{
    uint32 j, n;
    JSXML *vxml, *kid;
    JSObject *vobj;
    JSString *str;

    if (!JSXML_HAS_KIDS(xml))
        return JS_TRUE;

    n = 1;
    vxml = NULL;
    if (!JSVAL_IS_PRIMITIVE(v)) {
        vobj = JSVAL_TO_OBJECT(v);
        if (OBJECT_IS_XML(cx, vobj)) {
            vxml = (JSXML *) JS_GetPrivate(cx, vobj);
            if (vxml->xml_class == JSXML_CLASS_LIST) {
                n = vxml->xml_kids.length;
                if (n == 0)
                    return JS_TRUE;
                for (j = 0; j < n; j++) {
                    kid = XMLARRAY_MEMBER(&vxml->xml_kids, j, JSXML);
                    if (!kid)
                        continue;
                    if (!CheckCycle(cx, xml, kid))
                        return JS_FALSE;
                }
            } else if (vxml->xml_class == JSXML_CLASS_ELEMENT) {
                /* OPTION: enforce that descendants have superset namespaces. */
                if (!CheckCycle(cx, xml, vxml))
                    return JS_FALSE;
            }
        }
    }
    if (!vxml) {
        str = js_ValueToString(cx, v);
        if (!str)
            return JS_FALSE;

        vxml = js_NewXML(cx, JSXML_CLASS_TEXT);
        if (!vxml)
            return JS_FALSE;
        vxml->xml_value = str;
    }

    if (i > xml->xml_kids.length)
        i = xml->xml_kids.length;

    if (!XMLArrayInsert(cx, &xml->xml_kids, i, n))
        return JS_FALSE;

    if (vxml->xml_class == JSXML_CLASS_LIST) {
        for (j = 0; j < n; j++) {
            kid = XMLARRAY_MEMBER(&vxml->xml_kids, j, JSXML);
            if (!kid)
                continue;
            kid->parent = xml;
            XMLARRAY_SET_MEMBER(&xml->xml_kids, i + j, kid);

            /* OPTION: enforce that descendants have superset namespaces. */
        }
    } else {
        vxml->parent = xml;
        XMLARRAY_SET_MEMBER(&xml->xml_kids, i, vxml);
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool IsXMLName ( const jschar cp,
size_t  n 
) [static]

Definition at line 676 of file jsxml.c.

{
    JSBool rv;
    jschar c;

    rv = JS_FALSE;
    if (n != 0 && JS_ISXMLNSSTART(*cp)) {
        while (--n != 0) {
            c = *++cp;
            if (!JS_ISXMLNS(c))
                return rv;
        }
        rv = JS_TRUE;
    }
    return rv;
}

Here is the caller graph for this function:

static JSBool IsXMLSpace ( JSString str) [static]

Definition at line 6554 of file jsxml.c.

{
    const jschar *cp, *end;

    cp = JSSTRING_CHARS(str);
    end = cp + JSSTRING_LENGTH(str);
    while (cp < end) {
        if (!JS_ISXMLSPACE(*cp))
            return JS_FALSE;
        ++cp;
    }
    return JS_TRUE;
}

Here is the caller graph for this function:

JSString* js_AddAttributePart ( JSContext cx,
JSBool  isName,
JSString str,
JSString str2 
)

Definition at line 7916 of file jsxml.c.

{
    size_t len, len2, newlen;
    jschar *chars;

    if (JSSTRING_IS_DEPENDENT(str) ||
        !(*js_GetGCThingFlags(str) & GCF_MUTABLE)) {
        str = js_NewStringCopyN(cx, JSSTRING_CHARS(str), JSSTRING_LENGTH(str),
                                0);
        if (!str)
            return NULL;
    }

    len = str->length;
    len2 = JSSTRING_LENGTH(str2);
    newlen = (isName) ? len + 1 + len2 : len + 2 + len2 + 1;
    chars = (jschar *) JS_realloc(cx, str->chars, (newlen+1) * sizeof(jschar));
    if (!chars)
        return NULL;

    /*
     * Reallocating str (because we know it has no other references) requires
     * purging any deflated string cached for it.
     */
    js_PurgeDeflatedStringCache(cx->runtime, str);

    str->chars = chars;
    str->length = newlen;
    chars += len;
    if (isName) {
        *chars++ = ' ';
        js_strncpy(chars, JSSTRING_CHARS(str2), len2);
        chars += len2;
    } else {
        *chars++ = '=';
        *chars++ = '"';
        js_strncpy(chars, JSSTRING_CHARS(str2), len2);
        chars += len2;
        *chars++ = '"';
    }
    *chars = 0;
    return str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* js_CloneXMLObject ( JSContext cx,
JSObject obj 
)

Definition at line 8309 of file jsxml.c.

{
    uintN flags;
    JSXML *xml;

    if (!GetXMLSettingFlags(cx, &flags))
        return NULL;
    xml = (JSXML *) JS_GetPrivate(cx, obj);
    if (flags & (XSF_IGNORE_COMMENTS |
                 XSF_IGNORE_PROCESSING_INSTRUCTIONS |
                 XSF_IGNORE_WHITESPACE)) {
        xml = DeepCopy(cx, xml, NULL, flags);
        if (!xml)
            return NULL;
        return xml->object;
    }
    return NewXMLObject(cx, xml);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* js_ConstructXMLQNameObject ( JSContext cx,
jsval  nsval,
jsval  lnval 
)

Definition at line 656 of file jsxml.c.

{
    jsval argv[2];

    /*
     * ECMA-357 11.1.2,
     * The _QualifiedIdentifier : PropertySelector :: PropertySelector_
     * production, step 2.
     */
    if (!JSVAL_IS_PRIMITIVE(nsval) &&
        OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(nsval)) == &js_AnyNameClass) {
        nsval = JSVAL_NULL;
    }

    argv[0] = nsval;
    argv[1] = lnval;
    return js_ConstructObject(cx, &js_QNameClass.base, NULL, NULL, 2, argv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 8190 of file jsxml.c.

{
    JSXML *list;
    uint32 n;
    jsval junk;

    list = (JSXML *) JS_GetPrivate(cx, listobj);
    for (n = list->xml_kids.length; n != 0; --n) {
        if (!DeleteProperty(cx, listobj, INT_TO_JSID(0), &junk))
            return JS_FALSE;
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7910 of file jsxml.c.

{
    return EscapeAttributeValue(cx, NULL, str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7961 of file jsxml.c.

{
    return EscapeElementValue(cx, NULL, str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_FilterXMLList ( JSContext cx,
JSObject obj,
jsbytecode pc,
jsval vp 
)

Definition at line 8205 of file jsxml.c.

{
    JSBool ok, match;
    JSStackFrame *fp;
    uint32 flags;
    JSObject *scobj, *listobj, *resobj, *withobj, *kidobj, *obj2;
    JSXML *xml, *list, *result, *kid;
    JSXMLArrayCursor cursor;

    ok = js_EnterLocalRootScope(cx);
    if (!ok)
        return JS_FALSE;

    /* All control flow after this point must exit via label out or bad. */
    *vp = JSVAL_NULL;
    fp = cx->fp;
    flags = fp->flags;
    fp->flags = flags | JSFRAME_FILTERING;
    scobj = js_GetScopeChain(cx, fp);
    withobj = NULL;
    if (!scobj)
        goto bad;
    xml = GetPrivate(cx, obj, "filtering predicate operator");
    if (!xml)
        goto bad;

    if (xml->xml_class == JSXML_CLASS_LIST) {
        list = xml;
    } else {
        listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
        if (!listobj)
            goto bad;
        list = (JSXML *) JS_GetPrivate(cx, listobj);
        ok = Append(cx, list, xml);
        if (!ok)
            goto out;
    }

    resobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
    if (!resobj)
        goto bad;
    result = (JSXML *) JS_GetPrivate(cx, resobj);

    /* Hoist the scope chain update out of the loop over kids. */
    withobj = js_NewWithObject(cx, NULL, scobj, -1);
    if (!withobj)
        goto bad;
    fp->scopeChain = withobj;

    XMLArrayCursorInit(&cursor, &list->xml_kids);
    while ((kid = (JSXML *) XMLArrayCursorNext(&cursor)) != NULL) {
        kidobj = js_GetXMLObject(cx, kid);
        if (!kidobj)
            break;
        OBJ_SET_PROTO(cx, withobj, kidobj);
        ok = js_Interpret(cx, pc, vp) && js_ValueToBoolean(cx, *vp, &match);
        for (obj2 = fp->scopeChain;
             obj2 != withobj;
             obj2 = OBJ_GET_PARENT(cx, obj2)) {
            if (OBJ_GET_CLASS(cx, obj2) == &js_BlockClass) {
                if (JS_GetPrivate(cx, obj2) != fp)
                    break;
                ok &= js_PutBlockObject(cx, obj2);
            }
        }
        if (ok && match)
            ok = Append(cx, result, kid);
        if (!ok)
            break;
    }
    XMLArrayCursorFinish(&cursor);
    if (!ok)
        goto out;
    if (kid)
        goto bad;

    *vp = OBJECT_TO_JSVAL(resobj);

out:
    fp->flags = flags | (fp->flags & JSFRAME_POP_BLOCKS);
    if (withobj) {
        fp->scopeChain = scobj;
        JS_SetPrivate(cx, withobj, NULL);
    }
    js_LeaveLocalRootScopeWithResult(cx, *vp);
    return ok;
bad:
    ok = JS_FALSE;
    goto out;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void js_FinalizeXML ( JSContext cx,
JSXML xml 
)

Definition at line 7540 of file jsxml.c.

{
    if (JSXML_HAS_KIDS(xml)) {
        XMLArrayFinish(cx, &xml->xml_kids);
        if (xml->xml_class == JSXML_CLASS_ELEMENT) {
            XMLArrayFinish(cx, &xml->xml_namespaces);
            XMLArrayFinish(cx, &xml->xml_attrs);
        }
    }

#ifdef DEBUG_notme
    JS_REMOVE_LINK(&xml->links);
#endif

    UNMETER(xml_stats.livexml);
}

Here is the call graph for this function:

Definition at line 311 of file jsxml.c.

{
    UNMETER(xml_stats.livenamespace);
}

Definition at line 586 of file jsxml.c.

{
    UNMETER(xml_stats.liveqname);
}
JSBool js_FindXMLProperty ( JSContext cx,
jsval  name,
JSObject **  objp,
jsval namep 
)

Definition at line 8055 of file jsxml.c.

{
    JSXMLQName *qn;
    jsid funid, id;
    JSObject *obj, *pobj, *lastobj;
    JSProperty *prop;
    const char *printable;

    qn = ToXMLName(cx, name, &funid);
    if (!qn)
        return JS_FALSE;
    id = OBJECT_TO_JSID(qn->object);

    obj = cx->fp->scopeChain;
    do {
        if (!OBJ_LOOKUP_PROPERTY(cx, obj, id, &pobj, &prop))
            return JS_FALSE;
        if (prop) {
            OBJ_DROP_PROPERTY(cx, pobj, prop);

            /*
             * Call OBJ_THIS_OBJECT to skip any With object that wraps an XML
             * object to carry scope chain linkage in js_FilterXMLList.
             */
            pobj = OBJ_THIS_OBJECT(cx, obj);
            if (OBJECT_IS_XML(cx, pobj)) {
                *objp = pobj;
                *namep = ID_TO_VALUE(id);
                return JS_TRUE;
            }
        }

        lastobj = obj;
    } while ((obj = OBJ_GET_PARENT(cx, obj)) != NULL);

    printable = js_ValueToPrintableString(cx, name);
    if (printable) {
        JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR,
                                     js_GetErrorMessage, NULL,
                                     JSMSG_UNDEFINED_XML_NAME, printable);
    }
    return JS_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_GetAnyName ( JSContext cx,
jsval vp 
)

Definition at line 7981 of file jsxml.c.

{
    JSRuntime *rt;
    JSObject *obj;
    JSXMLQName *qn;
    JSBool ok;

    /* Optimize by avoiding JS_LOCK_GC(rt) for the common case. */
    rt = cx->runtime;
    obj = rt->anynameObject;
    if (!obj) {
        JS_LOCK_GC(rt);
        obj = rt->anynameObject;
        if (!obj) {
            JS_UNLOCK_GC(rt);

            /*
             * Protect multiple newborns created below, in the do-while(0)
             * loop used to ensure that we leave this local root scope.
             */
            ok = js_EnterLocalRootScope(cx);
            if (!ok)
                return JS_FALSE;

            do {
                qn = js_NewXMLQName(cx, rt->emptyString, rt->emptyString,
                                    ATOM_TO_STRING(rt->atomState.starAtom));
                if (!qn) {
                    ok = JS_FALSE;
                    break;
                }

                obj = js_NewObject(cx, &js_AnyNameClass, NULL, NULL);
                if (!obj || !JS_SetPrivate(cx, obj, qn)) {
                    cx->weakRoots.newborn[GCX_OBJECT] = NULL;
                    ok = JS_FALSE;
                    break;
                }
                qn->object = obj;
                METER(xml_stats.qnameobj);
                METER(xml_stats.liveqnameobj);

                /*
                 * Avoid entraining any Object.prototype found via cx's scope
                 * chain or global object.  This loses the default toString,
                 * but no big deal: we want to customize toString anyway for
                 * clearer diagnostics.
                 */
                if (!JS_DefineFunction(cx, obj, js_toString_str,
                                       anyname_toString, 0, 0)) {
                    ok = JS_FALSE;
                    break;
                }
                OBJ_SET_PROTO(cx, obj, NULL);
                JS_ASSERT(!OBJ_GET_PARENT(cx, obj));
            } while (0);

            js_LeaveLocalRootScopeWithResult(cx, OBJECT_TO_JSVAL(obj));
            if (!ok)
                return JS_FALSE;

            JS_LOCK_GC(rt);
            if (!rt->anynameObject)
                rt->anynameObject = obj;
            else
                obj = rt->anynameObject;
        }
        JS_UNLOCK_GC(rt);
    }
    *vp = OBJECT_TO_JSVAL(obj);
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 630 of file jsxml.c.

{
    JSObject *obj;

    obj = qn->object;
    if (obj) {
        if (OBJ_GET_CLASS(cx, obj) == &js_AttributeNameClass)
            return obj;
        qn = js_NewXMLQName(cx, qn->uri, qn->prefix, qn->localName);
        if (!qn)
            return NULL;
    }

    obj = js_NewObject(cx, &js_AttributeNameClass, NULL, NULL);
    if (!obj || !JS_SetPrivate(cx, obj, qn)) {
        cx->weakRoots.newborn[GCX_OBJECT] = NULL;
        return NULL;
    }

    qn->object = obj;
    METER(xml_stats.qnameobj);
    METER(xml_stats.liveqnameobj);
    return obj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7827 of file jsxml.c.

{
    JSStackFrame *fp;
    JSObject *nsobj, *obj, *tmp;
    jsval v;

    fp = cx->fp;
    nsobj = fp->xmlNamespace;
    if (nsobj) {
        *vp = OBJECT_TO_JSVAL(nsobj);
        return JS_TRUE;
    }

    obj = NULL;
    for (tmp = fp->scopeChain; tmp; tmp = OBJ_GET_PARENT(cx, obj)) {
        obj = tmp;
        if (!OBJ_GET_PROPERTY(cx, obj, JS_DEFAULT_XML_NAMESPACE_ID, &v))
            return JS_FALSE;
        if (!JSVAL_IS_PRIMITIVE(v)) {
            fp->xmlNamespace = JSVAL_TO_OBJECT(v);
            *vp = v;
            return JS_TRUE;
        }
    }

    nsobj = js_ConstructObject(cx, &js_NamespaceClass.base, NULL, obj, 0, NULL);
    if (!nsobj)
        return JS_FALSE;
    v = OBJECT_TO_JSVAL(nsobj);
    if (obj &&
        !OBJ_DEFINE_PROPERTY(cx, obj, JS_DEFAULT_XML_NAMESPACE_ID, v,
                             JS_PropertyStub, JS_PropertyStub,
                             JSPROP_PERMANENT, NULL)) {
        return JS_FALSE;
    }
    fp->xmlNamespace = nsobj;
    *vp = v;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7753 of file jsxml.c.

{
    JSRuntime *rt;
    JSObject *obj;
    JSAtom *atom;
    JSString *prefix, *uri;

    /* An invalid URI, for internal use only, guaranteed not to collide. */
    static const char anti_uri[] = "@mozilla.org/js/function";

    /* Optimize by avoiding JS_LOCK_GC(rt) for the common case. */
    rt = cx->runtime;
    obj = rt->functionNamespaceObject;
    if (!obj) {
        JS_LOCK_GC(rt);
        obj = rt->functionNamespaceObject;
        if (!obj) {
            JS_UNLOCK_GC(rt);

            /*
             * Note that any race to atomize anti_uri here is resolved by
             * the atom table code, such that at most one atom for anti_uri
             * is created.  We store in rt->atomState.lazy unconditionally,
             * since we are guaranteed to overwrite either null or the same
             * atom pointer.
             */
            atom = js_Atomize(cx, anti_uri, sizeof anti_uri - 1, ATOM_PINNED);
            if (!atom)
                return JS_FALSE;
            rt->atomState.lazy.functionNamespaceURIAtom = atom;

            prefix = ATOM_TO_STRING(rt->atomState.typeAtoms[JSTYPE_FUNCTION]);
            uri = ATOM_TO_STRING(atom);
            obj = js_NewXMLNamespaceObject(cx, prefix, uri, JS_FALSE);
            if (!obj)
                return JS_FALSE;

            /*
             * Avoid entraining any in-scope Object.prototype.  The loss of
             * Namespace.prototype is not detectable, as there is no way to
             * refer to this instance in scripts.  When used to qualify method
             * names, its prefix and uri references are copied to the QName.
             */
            OBJ_SET_PROTO(cx, obj, NULL);
            OBJ_SET_PARENT(cx, obj, NULL);

            JS_LOCK_GC(rt);
            if (!rt->functionNamespaceObject)
                rt->functionNamespaceObject = obj;
            else
                obj = rt->functionNamespaceObject;
        }
        JS_UNLOCK_GC(rt);
    }
    *vp = OBJECT_TO_JSVAL(obj);
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_GetXMLDescendants ( JSContext cx,
JSObject obj,
jsval  id,
jsval vp 
)

Definition at line 8174 of file jsxml.c.

{
    JSXML *xml, *list;

    xml = GetPrivate(cx, obj, "descendants internal method");
    if (!xml)
        return JS_FALSE;

    list = Descendants(cx, xml, id);
    if (!list)
        return JS_FALSE;
    *vp = OBJECT_TO_JSVAL(list->object);
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_GetXMLFunction ( JSContext cx,
JSObject obj,
jsid  id,
jsval vp 
)

Definition at line 8106 of file jsxml.c.

{
    JSObject *target;
    JSXML *xml;
    JSTempValueRooter tvr;
    JSBool ok;

    JS_ASSERT(OBJECT_IS_XML(cx, obj));

    /* After this point, control must flow through label out: to exit. */
    JS_PUSH_TEMP_ROOT_OBJECT(cx, NULL, &tvr);

    /*
     * See comments before xml_lookupProperty about the need for the proto
     * chain lookup.
     */
    target = obj;
    for (;;) {
        ok = js_GetProperty(cx, target, id, vp);
        if (!ok)
            goto out;
        if (VALUE_IS_FUNCTION(cx, *vp)) {
            ok = JS_TRUE;
            goto out;
        }
        target = OBJ_GET_PROTO(cx, target);
        if (target == NULL)
            break;
        tvr.u.object = target;
    }

    xml = (JSXML *) JS_GetPrivate(cx, obj);
    if (HasSimpleContent(xml)) {
        /* Search in String.prototype to implement 11.2.2.1 Step 3(f). */
        ok = js_GetClassPrototype(cx, NULL, INT_TO_JSID(JSProto_String),
                                  &tvr.u.object);
        if (!ok)
            goto out;
        JS_ASSERT(tvr.u.object);
        ok = OBJ_GET_PROPERTY(cx, tvr.u.object, id, vp);
    }

  out:
    JS_POP_TEMP_ROOT(cx, &tvr);
    return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 335 of file jsxml.c.

{
    JSObject *obj;

    obj = ns->object;
    if (obj) {
        JS_ASSERT(JS_GetPrivate(cx, obj) == ns);
        return obj;
    }
    obj = js_NewObject(cx, &js_NamespaceClass.base, NULL, NULL);
    if (!obj || !JS_SetPrivate(cx, obj, ns)) {
        cx->weakRoots.newborn[GCX_OBJECT] = NULL;
        return NULL;
    }
    ns->object = obj;
    METER(xml_stats.namespaceobj);
    METER(xml_stats.livenamespaceobj);
    return obj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* js_GetXMLObject ( JSContext cx,
JSXML xml 
)

Definition at line 7614 of file jsxml.c.

{
    JSObject *obj;

    obj = xml->object;
    if (obj) {
        JS_ASSERT(JS_GetPrivate(cx, obj) == xml);
        return obj;
    }

    /*
     * A JSXML cannot be shared among threads unless it has an object.
     * A JSXML cannot be given an object unless:
     * (a) it has no parent; or
     * (b) its parent has no object (therefore is thread-private); or
     * (c) its parent's object is locked.
     *
     * Once given an object, a JSXML is immutable.
     */
    JS_ASSERT(!xml->parent ||
              !xml->parent->object ||
              JS_IS_OBJ_LOCKED(cx, xml->parent->object));

    obj = NewXMLObject(cx, xml);
    if (!obj)
        return NULL;
    xml->object = obj;
    return obj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_GetXMLProperty ( JSContext cx,
JSObject obj,
jsval  name,
jsval vp 
)

Definition at line 8100 of file jsxml.c.

{
    return GetProperty(cx, obj, name, vp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 609 of file jsxml.c.

{
    JSObject *obj;

    obj = qn->object;
    if (obj) {
        JS_ASSERT(JS_GetPrivate(cx, obj) == qn);
        return obj;
    }
    obj = js_NewObject(cx, &js_QNameClass.base, NULL, NULL);
    if (!obj || !JS_SetPrivate(cx, obj, qn)) {
        cx->weakRoots.newborn[GCX_OBJECT] = NULL;
        return NULL;
    }
    qn->object = obj;
    METER(xml_stats.qnameobj);
    METER(xml_stats.liveqnameobj);
    return obj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7666 of file jsxml.c.

{
    jsval v;

    if (!js_GetAnyName(cx, &v))
        return NULL;
    return JSVAL_TO_OBJECT(v);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7659 of file jsxml.c.

{
    return JS_InitClass(cx, obj, NULL, &js_AttributeNameClass, AttributeName, 2,
                        qname_props, qname_methods, NULL, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7645 of file jsxml.c.

{
    return JS_InitClass(cx, obj, NULL, &js_NamespaceClass.base, Namespace, 2,
                        namespace_props, namespace_methods, NULL, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* js_InitQNameClass ( JSContext cx,
JSObject obj 
)

Definition at line 7652 of file jsxml.c.

{
    return JS_InitClass(cx, obj, NULL, &js_QNameClass.base, QName, 2,
                        qname_props, qname_methods, NULL, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* js_InitXMLClass ( JSContext cx,
JSObject obj 
)

Definition at line 7676 of file jsxml.c.

{
    JSObject *proto, *pobj, *ctor;
    JSFunction *fun;
    JSXML *xml;
    JSProperty *prop;
    JSScopeProperty *sprop;
    jsval cval, argv[1], junk;

    /* Define the isXMLName function. */
    if (!JS_DefineFunction(cx, obj, js_isXMLName_str, xml_isXMLName, 1, 0))
        return NULL;

    /* Define the XML class constructor and prototype. */
    proto = JS_InitClass(cx, obj, NULL, &js_XMLClass, XML, 1,
                         NULL, xml_methods,
                         xml_static_props, xml_static_methods);
    if (!proto)
        return NULL;

    xml = js_NewXML(cx, JSXML_CLASS_TEXT);
    if (!xml || !JS_SetPrivate(cx, proto, xml))
        return NULL;
    xml->object = proto;
    METER(xml_stats.xmlobj);
    METER(xml_stats.livexmlobj);

    /*
     * Prepare to set default settings on the XML constructor we just made.
     * NB: We can't use JS_GetConstructor, because it calls OBJ_GET_PROPERTY,
     * which is xml_getProperty, which creates a new XMLList every time!  We
     * must instead call js_LookupProperty directly.
     */
    if (!js_LookupProperty(cx, proto,
                           ATOM_TO_JSID(cx->runtime->atomState.constructorAtom),
                           &pobj, &prop)) {
        return NULL;
    }
    JS_ASSERT(prop);
    sprop = (JSScopeProperty *) prop;
    JS_ASSERT(SPROP_HAS_VALID_SLOT(sprop, OBJ_SCOPE(pobj)));
    cval = OBJ_GET_SLOT(cx, pobj, sprop->slot);
    OBJ_DROP_PROPERTY(cx, pobj, prop);
    JS_ASSERT(VALUE_IS_FUNCTION(cx, cval));

    /* Set default settings. */
    ctor = JSVAL_TO_OBJECT(cval);
    argv[0] = JSVAL_VOID;
    if (!xml_setSettings(cx, ctor, 1, argv, &junk))
        return NULL;

    /* Define the XMLList function and give it the same prototype as XML. */
    fun = JS_DefineFunction(cx, obj, js_XMLList_str, XMLList, 1, 0);
    if (!fun)
        return NULL;
    if (!js_SetClassPrototype(cx, fun->object, proto,
                              JSPROP_READONLY | JSPROP_PERMANENT)) {
        return NULL;
    }
    return proto;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* js_InitXMLClasses ( JSContext cx,
JSObject obj 
)

Definition at line 7739 of file jsxml.c.

{
    if (!js_InitNamespaceClass(cx, obj))
        return NULL;
    if (!js_InitQNameClass(cx, obj))
        return NULL;
    if (!js_InitAttributeNameClass(cx, obj))
        return NULL;
    if (!js_InitAnyNameClass(cx, obj))
        return NULL;
    return js_InitXMLClass(cx, obj);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_IsXMLName ( JSContext cx,
jsval  v 
)

Definition at line 694 of file jsxml.c.

{
    JSClass *clasp;
    JSXMLQName *qn;
    JSString *name;
    JSErrorReporter older;

    /*
     * Inline specialization of the QName constructor called with v passed as
     * the only argument, to compute the localName for the constructed qname,
     * without actually allocating the object or computing its uri and prefix.
     * See ECMA-357 13.1.2.1 step 1 and 13.3.2.
     */
    if (!JSVAL_IS_PRIMITIVE(v) &&
        (clasp = OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(v)),
         clasp == &js_QNameClass.base ||
         clasp == &js_AttributeNameClass ||
         clasp == &js_AnyNameClass)) {
        qn = (JSXMLQName *) JS_GetPrivate(cx, JSVAL_TO_OBJECT(v));
        name = qn->localName;
    } else {
        older = JS_SetErrorReporter(cx, NULL);
        name = js_ValueToString(cx, v);
        JS_SetErrorReporter(cx, older);
        if (!name) {
            JS_ClearPendingException(cx);
            return JS_FALSE;
        }
    }

    return IsXMLName(JSSTRING_CHARS(name), JSSTRING_LENGTH(name));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 8362 of file jsxml.c.

{
    return MakeXMLCDATAString(cx, NULL, str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 8368 of file jsxml.c.

{
    return MakeXMLCommentString(cx, NULL, str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSString* js_MakeXMLPIString ( JSContext cx,
JSString name,
JSString str 
)

Definition at line 8374 of file jsxml.c.

{
    return MakeXMLPIString(cx, NULL, name, str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void js_MarkXML ( JSContext cx,
JSXML xml 
)

Definition at line 7502 of file jsxml.c.

{
    GC_MARK(cx, xml->object, "object");
    GC_MARK(cx, xml->name, "name");
    GC_MARK(cx, xml->parent, "xml_parent");

    if (JSXML_HAS_VALUE(xml)) {
        GC_MARK(cx, xml->xml_value, "value");
        return;
    }

    xml_mark_vector(cx,
                    (JSXML **) xml->xml_kids.vector,
                    xml->xml_kids.length);
    XMLArrayCursorMark(cx, xml->xml_kids.cursors);
    XMLArrayTrim(&xml->xml_kids);

    if (xml->xml_class == JSXML_CLASS_LIST) {
        if (xml->xml_target)
            GC_MARK(cx, xml->xml_target, "target");
        if (xml->xml_targetprop)
            GC_MARK(cx, xml->xml_targetprop, "targetprop");
    } else {
        namespace_mark_vector(cx,
                              (JSXMLNamespace **) xml->xml_namespaces.vector,
                              xml->xml_namespaces.length);
        XMLArrayCursorMark(cx, xml->xml_namespaces.cursors);
        XMLArrayTrim(&xml->xml_namespaces);

        xml_mark_vector(cx,
                        (JSXML **) xml->xml_attrs.vector,
                        xml->xml_attrs.length);
        XMLArrayCursorMark(cx, xml->xml_attrs.cursors);
        XMLArrayTrim(&xml->xml_attrs);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 303 of file jsxml.c.

{
    GC_MARK(cx, ns->object, "object");
    GC_MARK(cx, ns->prefix, "prefix");
    GC_MARK(cx, ns->uri, "uri");
}

Here is the caller graph for this function:

void js_MarkXMLQName ( JSContext cx,
JSXMLQName qn 
)

Definition at line 577 of file jsxml.c.

{
    GC_MARK(cx, qn->object, "object");
    GC_MARK(cx, qn->uri, "uri");
    GC_MARK(cx, qn->prefix, "prefix");
    GC_MARK(cx, qn->localName, "localName");
}

Here is the caller graph for this function:

JSXML* js_NewXML ( JSContext cx,
JSXMLClass  xml_class 
)

Definition at line 7465 of file jsxml.c.

{
    JSXML *xml;

    xml = (JSXML *) js_NewGCThing(cx, GCX_XML, sizeof_JSXML[xml_class]);
    if (!xml)
        return NULL;

    xml->object = NULL;
    xml->domnode = NULL;
    xml->parent = NULL;
    xml->name = NULL;
    xml->xml_class = xml_class;
    xml->xml_flags = 0;
    if (JSXML_CLASS_HAS_VALUE(xml_class)) {
        xml->xml_value = cx->runtime->emptyString;
    } else {
        XMLArrayInit(cx, &xml->xml_kids, 0);
        if (xml_class == JSXML_CLASS_LIST) {
            xml->xml_target = NULL;
            xml->xml_targetprop = NULL;
        } else {
            XMLArrayInit(cx, &xml->xml_namespaces, 0);
            XMLArrayInit(cx, &xml->xml_attrs, 0);
        }
    }

#ifdef DEBUG_notme
    JS_APPEND_LINK(&xml->links, &xml_leaks);
    xml->serial = xml_serial++;
#endif
    METER(xml_stats.xml);
    METER(xml_stats.livexml);
    return xml;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSXMLNamespace* js_NewXMLNamespace ( JSContext cx,
JSString prefix,
JSString uri,
JSBool  declared 
)

Definition at line 284 of file jsxml.c.

{
    JSXMLNamespace *ns;

    ns = (JSXMLNamespace *)
         js_NewGCThing(cx, GCX_NAMESPACE, sizeof(JSXMLNamespace));
    if (!ns)
        return NULL;
    ns->object = NULL;
    ns->prefix = prefix;
    ns->uri = uri;
    ns->declared = declared;
    METER(xml_stats.namespace);
    METER(xml_stats.livenamespace);
    return ns;
}

Here is the call graph for this function:

Here is the caller graph for this function: