From: ishmal Date: Tue, 5 Sep 2006 16:00:09 +0000 (+0000) Subject: Massive update for smart pointers. Rework js dom binding to be smarter. Placeholder... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e6eb9f8b3d61894279128d0666e1e600b86278f9;p=inkscape.git Massive update for smart pointers. Rework js dom binding to be smarter. Placeholder for dom binding, finish later. --- diff --git a/src/dom/Makefile.mingw b/src/dom/Makefile.mingw index 2c2dd1c98..33b6aed9e 100644 --- a/src/dom/Makefile.mingw +++ b/src/dom/Makefile.mingw @@ -142,9 +142,10 @@ DOMOBJ = \ charclass.o \ cssparser.o \ domimpl.o \ +domptr.o \ domstring.o \ jsengine.o \ -jsbind.o \ +jsdombind.o \ lsimpl.o \ smilimpl.o \ uri.o \ diff --git a/src/dom/dom.h b/src/dom/dom.h index de3532074..138e735e3 100644 --- a/src/dom/dom.h +++ b/src/dom/dom.h @@ -82,40 +82,320 @@ typedef unsigned long long DOMTimeStamp; */ typedef void DOMUserData; +/*######################################################################### +## NodePtr +#########################################################################*/ + +/** + * A simple Smart Pointer class that handles Nodes and all of its + * descendants + */ +template class Ptr +{ +public: + + /** + * Simple constructor + */ + Ptr() + { _ref = 0; } + + /** + * Constructor upon a reference + */ + template Ptr(const Ptr &other) + { + _ref = other._ref; + incrementRefCount(_ref); + } + + /** + * Constructor upon a reference + */ + Ptr(T * refArg, bool addRef = true) + { + _ref = refArg; + if(addRef) + incrementRefCount(_ref); + } + + + /** + * Copy constructor + */ + Ptr(const Ptr &other) + { + _ref = other._ref; + incrementRefCount(_ref); + } + + /** + * Destructor + */ + ~Ptr() + { + decrementRefCount(_ref); + } + + + /** + * Assignment operator + */ + template Ptr &operator=(const Ptr &other) + { + decrementRefCount(_ref); + _ref = other._ref; + incrementRefCount(_ref); + return *this; + } + + /** + * Assignment operator + */ + Ptr &operator=(const Ptr &other) + { + decrementRefCount(_ref); + _ref = other._ref; + incrementRefCount(_ref); + return *this; + } + + /** + * Assignment operator + */ + template Ptr &operator=(Y * ref) + { + decrementRefCount(_ref); + _ref = ref; + incrementRefCount(_ref); + return *this; + } + + /** + * Assignment operator + */ + template Ptr &operator=(const Y * ref) + { + decrementRefCount(_ref); + _ref = (Y *) ref; + incrementRefCount(_ref); + return *this; + } + + /** + * Return the reference + */ + T * get() const + { + return _ref; + } + + /** + * Dereference operator + */ + T &operator*() const + { + return *_ref; + } + + /** + * Point-to operator + */ + T *operator->() const + { + return _ref; + } + + /** + * NOT bool operator. How to check if we are null without a comparison + */ + bool operator! () const + { + return (_ref == 0); + } + + /** + * Swap what I reference with the other guy + */ + void swap(Ptr &other) + { + T *tmp = _ref; + _ref = other._ref; + other._ref = tmp; + } + + //The referenced item + T *_ref; +}; + + +/** + * Global definitions. Many of these are used to mimic behaviour of + * a real pointer + */ + +/** + * Equality + */ +template inline bool + operator==(const Ptr &a, const Ptr &b) +{ + return a.get() == b.get(); +} + +/** + * Inequality + */ +template inline bool + operator!=(const Ptr &a, const Ptr &b) +{ + return a.get() != b.get(); +} + +/** + * Equality + */ +template inline bool + operator==(const Ptr &a, T * b) +{ + return a.get() == b; +} + +/** + * Inequality + */ +template inline bool + operator!=(const Ptr &a, T * b) +{ + return a.get() != b; +} + +/** + * Equality + */ +template inline bool + operator==(T * a, const Ptr &b) +{ + return a == b.get(); +} + +/** + * Inequality + */ +template inline bool + operator!=(T * a, const Ptr &b) +{ + return a != b.get(); +} + + +/** + * Less than + */ +template inline bool + operator<(const Ptr &a, const Ptr &b) +{ + return std::less()(a.get(), b.get()); +} + +/** + * Swap + */ +template void + swap(Ptr &a, Ptr &b) +{ + a.swap(b); +} + + +/** + * Get the pointer globally, for + */ +template T * + get_pointer(const Ptr &p) +{ + return p.get(); +} + +/** + * Static cast + */ +template Ptr + static_pointer_cast(const Ptr &p) +{ + return static_cast(p.get()); +} + +/** + * Const cast + */ +template Ptr + const_pointer_cast(const Ptr &p) +{ + return const_cast(p.get()); +} + +/** + * Dynamic cast + */ +template Ptr + dynamic_pointer_cast(const Ptr &p) +{ + return dynamic_cast(p.get()); +} + + /** * */ typedef void DOMObject; +class NodeList; +class NamedNodeMap; class DOMException; class DOMStringList; class NameList; class DOMImplementationList; class DOMImplementationSource; class DOMImplementation; -class Node; -class NodeList; -class NamedNodeMap; -class CharacterData; -class Attr; -class Element; -class Text; -class Comment; class TypeInfo; class UserDataHandler; class DOMError; class DOMErrorHandler; class DOMLocator; class DOMConfiguration; -class CDATASection; + +class Node; +typedef Ptr NodePtr; +class CharacterData; +typedef Ptr CharacterDataPtr; +class Attr; +typedef Ptr AttrPtr; +class Element; +typedef Ptr ElementPtr; +class Text; +typedef Ptr TextPtr; +class Comment; +typedef Ptr CommentPtr; class DocumentType; +typedef Ptr DocumentTypePtr; +class CDATASection; +typedef Ptr CDATASectionPtr; class Notation; +typedef Ptr NotationPtr; class Entity; +typedef Ptr EntityPtr; class EntityReference; +typedef Ptr EntityReferencePtr; class ProcessingInstruction; +typedef Ptr ProcessingInstructionPtr; class DocumentFragment; +typedef Ptr DocumentFragmentPtr; class Document; +typedef Ptr DocumentPtr; + + /** @@ -543,17 +823,18 @@ public: /** * */ - virtual DocumentType *createDocumentType(const DOMString& qualifiedName, - const DOMString& publicId, - const DOMString& systemId) - throw(DOMException) = 0; + virtual DocumentTypePtr createDocumentType( + const DOMString& qualifiedName, + const DOMString& publicId, + const DOMString& systemId) + throw(DOMException) = 0; /** * */ - virtual Document *createDocument(const DOMString& namespaceURI, + virtual DocumentPtr createDocument(const DOMString& namespaceURI, const DOMString& qualifiedName, - DocumentType *doctype) + DocumentTypePtr doctype) throw(DOMException) = 0; /** * @@ -576,12 +857,14 @@ public: + /*######################################################################### ## Node #########################################################################*/ /** - * + * The basic Node class, which is the root of most other + * classes in DOM. */ class Node { @@ -626,7 +909,7 @@ public: /** * */ - virtual Node *getParentNode() = 0; + virtual NodePtr getParentNode() = 0; /** * @@ -636,22 +919,22 @@ public: /** * */ - virtual Node *getFirstChild() = 0; + virtual NodePtr getFirstChild() = 0; /** * */ - virtual Node *getLastChild() = 0; + virtual NodePtr getLastChild() = 0; /** * */ - virtual Node *getPreviousSibling() = 0; + virtual NodePtr getPreviousSibling() = 0; /** * */ - virtual Node *getNextSibling() = 0; + virtual NodePtr getNextSibling() = 0; /** * @@ -662,32 +945,32 @@ public: /** * */ - virtual Document *getOwnerDocument() = 0; + virtual DocumentPtr getOwnerDocument() = 0; /** * */ - virtual Node *insertBefore(const Node *newChild, - const Node *refChild) + virtual NodePtr insertBefore(const NodePtr newChild, + const NodePtr refChild) throw(DOMException) = 0; /** * */ - virtual Node *replaceChild(const Node *newChild, - const Node *oldChild) + virtual NodePtr replaceChild(const NodePtr newChild, + const NodePtr oldChild) throw(DOMException) = 0; /** * */ - virtual Node *removeChild(const Node *oldChild) + virtual NodePtr removeChild(const NodePtr oldChild) throw(DOMException) = 0; /** * */ - virtual Node *appendChild(const Node *newChild) + virtual NodePtr appendChild(const NodePtr newChild) throw(DOMException) = 0; /** @@ -698,7 +981,7 @@ public: /** * */ - virtual Node *cloneNode(bool deep) = 0; + virtual NodePtr cloneNode(bool deep) = 0; /** * @@ -755,7 +1038,8 @@ public: /** * */ - virtual unsigned short compareDocumentPosition(const Node *other) = 0; + virtual unsigned short compareDocumentPosition( + const NodePtr other) = 0; /** * @@ -790,7 +1074,7 @@ public: /** * */ - virtual bool isEqualNode(const Node *node) =0; + virtual bool isEqualNode(const NodePtr node) =0; @@ -817,19 +1101,32 @@ public: //# Non-API methods //################## + /** + * + */ + Node() : _refCnt(0) + {} /** * */ virtual ~Node() {} +protected: - + friend void incrementRefCount(Node *p); + friend void decrementRefCount(Node *p); + + /** + * For the Ptr smart pointer + */ + int _refCnt; }; + /*######################################################################### ## NodeList #########################################################################*/ @@ -843,7 +1140,7 @@ public: /** * */ - virtual Node *item(unsigned long index) + virtual NodePtr item(unsigned long index) { if (index>=nodes.size()) return NULL; @@ -906,14 +1203,14 @@ friend class ElementImpl; /* * */ - virtual void add(const Node *node) + virtual void add(const NodePtr node) { - nodes.push_back((Node *)node); + nodes.push_back(node); } protected: - std::vector nodes; + std::vector nodes; }; @@ -929,11 +1226,11 @@ class NamedNodeMapEntry public: NamedNodeMapEntry(const DOMString &theNamespaceURI, const DOMString &theName, - const Node *theNode) + const NodePtr theNode) { namespaceURI = theNamespaceURI; name = theName; - node = (Node *)theNode; + node = theNode; } NamedNodeMapEntry(const NamedNodeMapEntry &other) { @@ -955,7 +1252,7 @@ public: } DOMString namespaceURI; DOMString name; - Node *node; + NodePtr node; }; /** @@ -968,14 +1265,14 @@ public: /** * */ - virtual Node *getNamedItem(const DOMString& name) + virtual NodePtr getNamedItem(const DOMString& name) { std::vector::iterator iter; for (iter = entries.begin() ; iter!=entries.end() ; iter++) { if (iter->name == name) { - Node *node = iter->node; + NodePtr node = iter->node; return node; } } @@ -985,7 +1282,7 @@ public: /** * */ - virtual Node *setNamedItem(Node *arg) throw(DOMException) + virtual NodePtr setNamedItem(NodePtr arg) throw(DOMException) { if (!arg) return NULL; @@ -996,7 +1293,7 @@ public: { if (iter->name == name) { - Node *node = iter->node; + NodePtr node = iter->node; iter->node = arg; return node; } @@ -1010,14 +1307,14 @@ public: /** * */ - virtual Node *removeNamedItem(const DOMString& name) throw(DOMException) + virtual NodePtr removeNamedItem(const DOMString& name) throw(DOMException) { std::vector::iterator iter; for (iter = entries.begin() ; iter!=entries.end() ; iter++) { if (iter->name == name) { - Node *node = iter->node; + NodePtr node = iter->node; entries.erase(iter); return node; } @@ -1028,7 +1325,7 @@ public: /** * */ - virtual Node *item(unsigned long index) + virtual NodePtr item(unsigned long index) { if (index>=entries.size()) return NULL; @@ -1046,7 +1343,7 @@ public: /** * */ - virtual Node *getNamedItemNS(const DOMString& namespaceURI, + virtual NodePtr getNamedItemNS(const DOMString& namespaceURI, const DOMString& localName) { std::vector::iterator iter; @@ -1054,7 +1351,7 @@ public: { if (iter->namespaceURI == namespaceURI && iter->name == localName) { - Node *node = iter->node; + NodePtr node = iter->node; return node; } } @@ -1064,7 +1361,7 @@ public: /** * */ - virtual Node *setNamedItemNS(Node *arg) throw(DOMException) + virtual NodePtr setNamedItemNS(NodePtr arg) throw(DOMException) { if (!arg) return NULL; @@ -1075,7 +1372,7 @@ public: { if (iter->namespaceURI == namespaceURI && iter->name == name) { - Node *node = iter->node; + NodePtr node = iter->node; iter->node = arg; return node; } @@ -1088,7 +1385,7 @@ public: /** * */ - virtual Node *removeNamedItemNS(const DOMString& namespaceURI, + virtual NodePtr removeNamedItemNS(const DOMString& namespaceURI, const DOMString& localName) throw(DOMException) { @@ -1097,7 +1394,7 @@ public: { if (iter->namespaceURI == namespaceURI && iter->name == localName) { - Node *node = iter->node; + NodePtr node = iter->node; entries.erase(iter); return node; } @@ -1221,6 +1518,8 @@ public: }; +typedef Ptr CharacterDataPtr; + @@ -1258,13 +1557,13 @@ public: /** * */ - virtual Element *getOwnerElement() = 0; + virtual ElementPtr getOwnerElement() = 0; /** * */ - virtual TypeInfo *getSchemaTypeInfo() = 0; + virtual TypeInfo &getSchemaTypeInfo() = 0; /** @@ -1326,18 +1625,18 @@ public: /** * */ - virtual Attr *getAttributeNode(const DOMString& name) = 0; + virtual AttrPtr getAttributeNode(const DOMString& name) = 0; /** * */ - virtual Attr *setAttributeNode(Attr *newAttr) + virtual AttrPtr setAttributeNode(AttrPtr newAttr) throw(DOMException) = 0; /** * */ - virtual Attr *removeAttributeNode(Attr *oldAttr) + virtual AttrPtr removeAttributeNode(AttrPtr oldAttr) throw(DOMException) = 0; /** @@ -1369,13 +1668,13 @@ public: /** * */ - virtual Attr *getAttributeNodeNS(const DOMString& namespaceURI, + virtual AttrPtr getAttributeNodeNS(const DOMString& namespaceURI, const DOMString& localName) = 0; /** * */ - virtual Attr *setAttributeNodeNS(Attr *newAttr) + virtual AttrPtr setAttributeNodeNS(AttrPtr newAttr) throw(DOMException) = 0; /** @@ -1398,7 +1697,7 @@ public: /** * */ - virtual TypeInfo *getSchemaTypeInto() = 0; + virtual TypeInfo &getSchemaTypeInfo() = 0; /** @@ -1417,7 +1716,7 @@ public: /** * */ - virtual void setIdAttributeNode(const Attr *idAttr, + virtual void setIdAttributeNode(const AttrPtr idAttr, bool isId) throw (DOMException) = 0; //################## @@ -1449,7 +1748,7 @@ public: /** * */ - virtual Text *splitText(unsigned long offset) + virtual TextPtr splitText(unsigned long offset) throw(DOMException) = 0; /** @@ -1466,7 +1765,7 @@ public: /** * */ - virtual Text *replaceWholeText(const DOMString &content) + virtual TextPtr replaceWholeText(const DOMString &content) throw(DOMException) = 0; //################## @@ -1523,12 +1822,14 @@ public: /** * */ - virtual DOMString getTypeName() =0; + virtual DOMString getTypeName() + { return typeName; } /** * */ - virtual DOMString getTypeNamespace() =0; + virtual DOMString getTypeNamespace() + { return typeNameSpace; } typedef enum { @@ -1544,18 +1845,47 @@ public: */ virtual bool isDerivedFrom(const DOMString &typeNamespaceArg, const DOMString &typeNameArg, - DerivationMethod derivationMethod) =0; + DerivationMethod derivationMethod) + { return false; } //################## //# Non-API methods //################## + /** + * + */ + TypeInfo() + {} + + /** + * + */ + TypeInfo(const TypeInfo &other) + { assign(other); } + + /** + * + */ + TypeInfo &operator=(const TypeInfo &other) + { assign(other); return *this; } + /** * */ virtual ~TypeInfo() {} + +private: + + void assign(const TypeInfo &other) + { + typeName = other.typeName; + typeNameSpace = other.typeNameSpace; + } + DOMString typeName; + DOMString typeNameSpace; }; @@ -1588,8 +1918,8 @@ public: virtual void handle(unsigned short operation, const DOMString &key, const DOMUserData *data, - const Node *src, - const Node *dst) =0; + const NodePtr src, + const NodePtr dst) =0; //################## //# Non-API methods @@ -1731,7 +2061,7 @@ public: /** * */ - virtual Node *getRelatedNode() =0; + virtual NodePtr getRelatedNode() =0; /** @@ -1765,7 +2095,8 @@ public: * */ virtual void setParameter(const DOMString &name, - const DOMUserData *value) throw (DOMException) =0; + const DOMUserData *value) + throw (DOMException) =0; /** * @@ -2082,7 +2413,7 @@ public: /** * */ - virtual DocumentType *getDoctype() = 0; + virtual DocumentTypePtr getDoctype() = 0; /** * @@ -2092,52 +2423,53 @@ public: /** * */ - virtual Element *getDocumentElement() = 0; + virtual ElementPtr getDocumentElement() = 0; /** * */ - virtual Element *createElement(const DOMString& tagName) + virtual ElementPtr createElement(const DOMString& tagName) throw(DOMException) = 0; /** * */ - virtual DocumentFragment *createDocumentFragment() = 0; + virtual DocumentFragmentPtr createDocumentFragment() = 0; /** * */ - virtual Text *createTextNode(const DOMString& data) = 0; + virtual TextPtr createTextNode(const DOMString& data) = 0; /** * */ - virtual Comment *createComment(const DOMString& data) = 0; + virtual CommentPtr createComment(const DOMString& data) = 0; /** * */ - virtual CDATASection *createCDATASection(const DOMString& data) + virtual CDATASectionPtr createCDATASection(const DOMString& data) throw(DOMException) = 0; /** * */ - virtual ProcessingInstruction *createProcessingInstruction(const DOMString& target, - const DOMString& data) - throw(DOMException) = 0; + virtual ProcessingInstructionPtr + createProcessingInstruction(const DOMString& target, + const DOMString& data) + throw(DOMException) = 0; /** * */ - virtual Attr *createAttribute(const DOMString& name) + virtual AttrPtr createAttribute(const DOMString& name) throw(DOMException) = 0; /** * */ - virtual EntityReference *createEntityReference(const DOMString& name) + virtual EntityReferencePtr createEntityReference(const DOMString& name) throw(DOMException) = 0; /** @@ -2149,21 +2481,21 @@ public: /** * */ - virtual Node *importNode(const Node *importedNode, + virtual NodePtr importNode(const NodePtr importedNode, bool deep) throw(DOMException) = 0; /** * */ - virtual Element *createElementNS(const DOMString& namespaceURI, + virtual ElementPtr createElementNS(const DOMString& namespaceURI, const DOMString& qualifiedName) throw(DOMException) = 0; /** * */ - virtual Attr *createAttributeNS(const DOMString& namespaceURI, + virtual AttrPtr createAttributeNS(const DOMString& namespaceURI, const DOMString& qualifiedName) throw(DOMException) = 0; @@ -2176,7 +2508,7 @@ public: /** * */ - virtual Element *getElementById(const DOMString& elementId) = 0; + virtual ElementPtr getElementById(const DOMString& elementId) = 0; /** @@ -2208,7 +2540,8 @@ public: /** * */ - virtual void setXmlVersion(const DOMString &version) throw (DOMException) = 0; + virtual void setXmlVersion(const DOMString &version) + throw (DOMException) = 0; /** * @@ -2234,7 +2567,7 @@ public: /** * */ - virtual Node *adoptNode(const Node *source) throw (DOMException) = 0; + virtual NodePtr adoptNode(const NodePtr source) throw (DOMException) = 0; /** * @@ -2249,10 +2582,10 @@ public: /** * */ - virtual Node *renameNode(const Node *n, - const DOMString &namespaceURI, - const DOMString &qualifiedName) - throw (DOMException) = 0; + virtual NodePtr renameNode(const NodePtr n, + const DOMString &namespaceURI, + const DOMString &qualifiedName) + throw (DOMException) = 0; //################## @@ -2273,9 +2606,6 @@ public: - - - } //namespace dom } //namespace w3c } //namespace org diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp index 510751895..663a8febc 100644 --- a/src/dom/domimpl.cpp +++ b/src/dom/domimpl.cpp @@ -134,12 +134,12 @@ bool DOMImplementationImpl::hasFeature(const DOMString& feature, /** * */ -DocumentType *DOMImplementationImpl::createDocumentType(const DOMString& qualifiedName, +DocumentTypePtr DOMImplementationImpl::createDocumentType(const DOMString& qualifiedName, const DOMString& publicId, const DOMString& systemId) throw(DOMException) { - DocumentTypeImpl *typeImpl = new DocumentTypeImpl(qualifiedName, + DocumentTypePtr typeImpl = new DocumentTypeImpl(qualifiedName, publicId, systemId); return typeImpl; } @@ -147,16 +147,16 @@ DocumentType *DOMImplementationImpl::createDocumentType(const DOMString& qualifi /** * */ -Document *DOMImplementationImpl::createDocument( +DocumentPtr DOMImplementationImpl::createDocument( const DOMString& namespaceURI, const DOMString& qualifiedName, - DocumentType *doctype) + DocumentTypePtr doctype) throw(DOMException) { - DocumentImpl *doc = new DocumentImpl(this, - namespaceURI, - qualifiedName, - doctype); + DocumentPtr doc = new DocumentImpl(this, + namespaceURI, + qualifiedName, + doctype); return doc; } @@ -182,13 +182,13 @@ DOMObject *DOMImplementationImpl::getFeature(const DOMString& feature, * Utility for finding the first Element above * a given node. Used by several methods below */ -static Node *getAncestorElement(Node *node) +static NodePtr getAncestorElement(NodePtr node) { - if (!node) + if (!node.get()) return NULL; node = node->getParentNode(); //Either quit because I am an element, or because I am null - while (node) + while (node.get()) { if (node->getNodeType() == Node::ELEMENT_NODE) return node; @@ -232,7 +232,7 @@ unsigned short NodeImpl::getNodeType() /** * */ -Node *NodeImpl::getParentNode() +NodePtr NodeImpl::getParentNode() { return parent; } @@ -243,7 +243,7 @@ Node *NodeImpl::getParentNode() NodeList NodeImpl::getChildNodes() { NodeList list; - for (NodeImpl *node = firstChild ; node ; node=node->next) + for (NodeImplPtr node = firstChild ; node.get() ; node=node->next) list.add(node); return list; } @@ -251,7 +251,7 @@ NodeList NodeImpl::getChildNodes() /** * */ -Node *NodeImpl::getFirstChild() +NodePtr NodeImpl::getFirstChild() { return firstChild; } @@ -259,7 +259,7 @@ Node *NodeImpl::getFirstChild() /** * */ -Node *NodeImpl::getLastChild() +NodePtr NodeImpl::getLastChild() { return lastChild; } @@ -267,7 +267,7 @@ Node *NodeImpl::getLastChild() /** * */ -Node *NodeImpl::getPreviousSibling() +NodePtr NodeImpl::getPreviousSibling() { return prev; } @@ -275,7 +275,7 @@ Node *NodeImpl::getPreviousSibling() /** * */ -Node *NodeImpl::getNextSibling() +NodePtr NodeImpl::getNextSibling() { return next; } @@ -293,7 +293,7 @@ NamedNodeMap &NodeImpl::getAttributes() /** * */ -Document *NodeImpl::getOwnerDocument() +DocumentPtr NodeImpl::getOwnerDocument() { return ownerDocument; } @@ -301,9 +301,9 @@ Document *NodeImpl::getOwnerDocument() /** * */ -Node *NodeImpl::insertBefore(const Node *newChild, - const Node *refChild) - throw(DOMException) +NodePtr NodeImpl::insertBefore(const NodePtr newChild, + const NodePtr refChild) + throw(DOMException) { if (!newChild) return NULL; @@ -312,13 +312,13 @@ Node *NodeImpl::insertBefore(const Node *newChild, if (!refChild) return appendChild(newChild); - NodeImpl *newChildImpl = dynamic_cast((Node *)newChild); - for (NodeImpl *n = firstChild ; n ; n=n->next) + NodeImplPtr newChildImpl = dynamic_cast(newChild.get()); + for (NodeImplPtr n = firstChild ; n.get() ; n=n->next) { if (n == refChild) { //link to new - if (n->prev) + if (n->prev.get()) n->prev->next = newChildImpl; else firstChild = newChildImpl; @@ -338,24 +338,24 @@ Node *NodeImpl::insertBefore(const Node *newChild, /** * */ -Node *NodeImpl::replaceChild(const Node *newChild, - const Node *oldChild) - throw(DOMException) +NodePtr NodeImpl::replaceChild(const NodePtr newChild, + const NodePtr oldChild) + throw(DOMException) { if (!oldChild) return NULL; - NodeImpl *newChildImpl = dynamic_cast((Node *)newChild); - for (NodeImpl *n = firstChild ; n ; n=n->next) + NodeImplPtr newChildImpl = dynamic_cast(newChild.get()); + for (NodeImplPtr n = firstChild ; n.get() ; n=n->next) { if (n == oldChild) { //link to new - if (n->prev) + if (n->prev.get()) n->prev->next = newChildImpl; else firstChild = newChildImpl; - if (n->next) + if (n->next.get()) n->next->prev = newChildImpl; else lastChild = newChildImpl; @@ -374,19 +374,19 @@ Node *NodeImpl::replaceChild(const Node *newChild, /** * */ -Node *NodeImpl::removeChild(const Node *oldChild) - throw(DOMException) +NodePtr NodeImpl::removeChild(const NodePtr oldChild) + throw(DOMException) { if (!oldChild) return NULL; - for (NodeImpl *n = firstChild ; n ; n=n->next) + for (NodeImplPtr n = firstChild ; n.get() ; n=n->next) { if (n == oldChild) { - if (n->prev) + if (n->prev.get()) n->prev->next = n->next; - if (n->next) + if (n->next.get()) n->next->prev = n->prev; return n; } @@ -397,14 +397,14 @@ Node *NodeImpl::removeChild(const Node *oldChild) /** * */ -Node *NodeImpl::appendChild(const Node *newChild) - throw(DOMException) +NodePtr NodeImpl::appendChild(const NodePtr newChild) + throw(DOMException) { if (!newChild) return NULL; - NodeImpl *newChildImpl = - dynamic_cast ((Node *)newChild); + NodeImplPtr newChildImpl = + dynamic_cast (newChild.get()); newChildImpl->parent = this; newChildImpl->ownerDocument = ownerDocument; @@ -423,7 +423,7 @@ Node *NodeImpl::appendChild(const Node *newChild) lastChild = newChildImpl; } - return (Node *)newChild; + return newChild; } /** @@ -431,15 +431,15 @@ Node *NodeImpl::appendChild(const Node *newChild) */ bool NodeImpl::hasChildNodes() { - return (firstChild != NULL); + return (firstChild != (NodeImpl *)0); } /** * */ -Node *NodeImpl::cloneNode(bool deep) +NodePtr NodeImpl::cloneNode(bool deep) { - NodeImpl *node = new NodeImpl(ownerDocument, nodeName); + NodeImplPtr node = new NodeImpl(ownerDocument, nodeName); node->parent = parent; node->prev = prev; node->next = next; @@ -449,7 +449,7 @@ Node *NodeImpl::cloneNode(bool deep) if (deep) { node->firstChild = node->lastChild = NULL; - for (NodeImpl *child = firstChild ; child ; child=child->next) + for (NodeImplPtr child = firstChild ; child.get() ; child=child->next) { node->appendChild(child->cloneNode(deep)); } @@ -469,14 +469,14 @@ Node *NodeImpl::cloneNode(bool deep) void NodeImpl::normalize() { //First, concatenate adjoining text nodes - NodeImpl *next = NULL; - for (NodeImpl *child = firstChild ; child ; child=next) + NodeImplPtr next = (NodeImpl *)0; + for (NodeImplPtr child = firstChild ; child.get() ; child=next) { if (child->getNodeType() != Node::TEXT_NODE) continue; next = NULL; DOMString sval = child->getNodeValue(); - for (NodeImpl *sibling = child->next ; sibling ; sibling=next) + for (NodeImplPtr sibling = child->next ; sibling.get() ; sibling=next) { next = sibling->next; if (sibling->getNodeType() != Node::TEXT_NODE) @@ -484,16 +484,16 @@ void NodeImpl::normalize() sval.append(sibling->getNodeValue()); //unlink and delete child->next = sibling->next; - if (sibling->next) + if (sibling->next.get()) sibling->next->prev = child; - delete sibling; + //delete sibling; } child->setNodeValue(sval); } //Next, we remove zero-length text subnodes next = NULL; - for (NodeImpl *child = firstChild ; child ; child=next) + for (NodeImplPtr child = firstChild ; child.get() ; child=next) { next = child->next; if (child->getNodeType() != Node::TEXT_NODE) @@ -501,11 +501,11 @@ void NodeImpl::normalize() if (child->getNodeValue().size() == 0) { //unlink and delete - if (child->prev) + if (child->prev.get()) child->prev->next = child->next; - if (child->next) + if (child->next.get()) child->next->prev = child->prev; - delete child; + //delete child; } } @@ -515,7 +515,7 @@ void NodeImpl::normalize() * */ bool NodeImpl::isSupported(const DOMString& feature, - const DOMString& version) + const DOMString& version) { //again, no idea return false; @@ -576,22 +576,22 @@ DOMString NodeImpl::getBaseURI() /** * */ -unsigned short NodeImpl::compareDocumentPosition(const Node *otherArg) +unsigned short NodeImpl::compareDocumentPosition(const NodePtr otherArg) { - if (!otherArg || this == otherArg) + if (!otherArg || otherArg == (NodePtr )this) return 0;//no flags - Node *node; - Node *other = (Node *)otherArg; + NodePtr node; + NodePtr other = otherArg; //Look above me - for (node=getParentNode() ; node ; node=node->getParentNode()) + for (node=getParentNode() ; node.get() ; node=node->getParentNode()) if (node == other) return DOCUMENT_POSITION_CONTAINED_BY; //Look above the other guy. See me? - for (node=other->getParentNode() ; node ; node=node->getParentNode()) - if (node == this) + for (node=other->getParentNode() ; node.get() ; node=node->getParentNode()) + if (node == (NodePtr )this) return DOCUMENT_POSITION_CONTAINS; @@ -616,7 +616,7 @@ DOMString NodeImpl::getTextContent() throw(DOMException) nodeType == ENTITY_REFERENCE_NODE || nodeType == DOCUMENT_FRAGMENT_NODE) { - for (Node *n = getFirstChild() ; n ; + for (NodePtr n = getFirstChild() ; n.get() ; n=n->getNextSibling() ) { if (n->getNodeType() != COMMENT_NODE && @@ -634,13 +634,15 @@ DOMString NodeImpl::getTextContent() throw(DOMException) void NodeImpl::setTextContent(const DOMString &val) throw(DOMException) { //Delete children - for (Node *n = getFirstChild() ; n ; - n=n->getNextSibling() ) + /** Not necessary. Just let smart pointers to their work + for (NodePtr n = getFirstChild() ; n.get() ; + n=n->getNextSibling() ) delete n; + */ firstChild = lastChild = NULL; //Replace with a single text node - NodeImpl *tnode = new NodeImpl(ownerDocument); + NodeImplPtr tnode = new NodeImpl(ownerDocument); tnode->nodeType = Node::TEXT_NODE; tnode->setNodeValue(val); appendChild(tnode); @@ -662,13 +664,13 @@ DOMString NodeImpl::lookupPrefix(const DOMString &theNamespaceURI) { case Node::ELEMENT_NODE: { - ElementImpl *elem = (ElementImpl *)this; + ElementPtr elem = (Element *)this; return lookupNamespacePrefix(theNamespaceURI, elem); } case Node::DOCUMENT_NODE: { - Document *doc = (Document *)this; - Element *elem = doc->getDocumentElement(); + DocumentPtr doc = (Document *)this; + ElementPtr elem = doc->getDocumentElement(); return elem->lookupPrefix(theNamespaceURI); } case Node::ENTITY_NODE : @@ -678,9 +680,9 @@ DOMString NodeImpl::lookupPrefix(const DOMString &theNamespaceURI) return DOMString(""); // type is unknown case Node::ATTRIBUTE_NODE: { - Attr *attr = (Attr *)this; - Element *elem = (Element *)attr->getOwnerElement(); - if ( elem ) + AttrPtr attr = (Attr *)this; + ElementPtr elem = attr->getOwnerElement(); + if ( elem.get() ) { return elem->lookupPrefix(theNamespaceURI); } @@ -689,7 +691,8 @@ DOMString NodeImpl::lookupPrefix(const DOMString &theNamespaceURI) default: { //Get ancestor element, if any - if ( Node *ancestor = getAncestorElement(this) ) + NodePtr ancestor = getAncestorElement(this); + if ( ancestor.get() ) { return ancestor->lookupPrefix(theNamespaceURI); } @@ -708,17 +711,19 @@ bool NodeImpl::isDefaultNamespace(const DOMString &theNamespaceURI) switch (nodeType) { case ELEMENT_NODE: + { if ( namespaceURI.size()>0 && prefix.size()==0 ) { return (namespaceURI == theNamespaceURI); } - if ( Node *attr = attributes.getNamedItem("xmlns")) + NodePtr attr = attributes.getNamedItem("xmlns"); + if ( attr.get() ) { - return (attr->getNodeValue() == theNamespaceURI); + return (attr->getNodeValue() == theNamespaceURI); } - - if ( Node *ancestor = getAncestorElement(this) ) + NodePtr ancestor = getAncestorElement(this); + if ( ancestor.get() ) { return ancestor->isDefaultNamespace(theNamespaceURI); } @@ -726,10 +731,11 @@ bool NodeImpl::isDefaultNamespace(const DOMString &theNamespaceURI) { return false; } + } case DOCUMENT_NODE: { //just use braces for local declaration - Document *doc = (Document *)this; - Element *elem = doc->getDocumentElement(); + DocumentPtr doc = (Document *)this; + ElementPtr elem = doc->getDocumentElement(); return elem->isDefaultNamespace(theNamespaceURI); } case ENTITY_NODE: @@ -738,20 +744,22 @@ bool NodeImpl::isDefaultNamespace(const DOMString &theNamespaceURI) case DOCUMENT_FRAGMENT_NODE: return false; case ATTRIBUTE_NODE: - {//braces only for scope - Attr *attr = (Attr *)this; - Element *ownerElement = attr->getOwnerElement(); - if ( ownerElement ) + {//braces only for scope + AttrPtr attr = (Attr *)this; + ElementPtr ownerElement = attr->getOwnerElement(); + if ( ownerElement.get() ) { return ownerElement->isDefaultNamespace(theNamespaceURI); } - else + else { return false; } - } + } default: - if ( Node *ancestor = getAncestorElement(this) ) + { + NodePtr ancestor = getAncestorElement(this); + if ( ancestor.get() ) { return ancestor->isDefaultNamespace(theNamespaceURI); } @@ -759,6 +767,7 @@ bool NodeImpl::isDefaultNamespace(const DOMString &theNamespaceURI) { return false; } + } }//switch return false; @@ -785,7 +794,7 @@ DOMString NodeImpl::lookupNamespaceURI(const DOMString &thePrefix) int nrAttrs = attributes.getLength(); for (int i=0 ; igetPrefix() == "xmlns" && attr->getLocalName() == thePrefix ) { // non default namespace if (attr->getNodeValue().size()>0) @@ -805,7 +814,8 @@ DOMString NodeImpl::lookupNamespaceURI(const DOMString &thePrefix) } } - if ( Node *ancestor = getAncestorElement(this) ) + NodePtr ancestor = getAncestorElement(this); + if ( ancestor.get() ) { return ancestor->lookupNamespaceURI(thePrefix); } @@ -813,8 +823,8 @@ DOMString NodeImpl::lookupNamespaceURI(const DOMString &thePrefix) } case DOCUMENT_NODE: { - Document *doc = (Document *)this; - Element *elem = doc->getDocumentElement(); + DocumentPtr doc = (Document *)this; + ElementPtr elem = doc->getDocumentElement(); return elem->lookupNamespaceURI(thePrefix); } case ENTITY_NODE: @@ -825,7 +835,8 @@ DOMString NodeImpl::lookupNamespaceURI(const DOMString &thePrefix) case ATTRIBUTE_NODE: { - if (Element *ownerElement = ((Attr *)this)->getOwnerElement()) + ElementPtr ownerElement = ((Attr *)this)->getOwnerElement(); + if ( ownerElement.get() ) { return ownerElement->lookupNamespaceURI(thePrefix); } @@ -835,7 +846,9 @@ DOMString NodeImpl::lookupNamespaceURI(const DOMString &thePrefix) } } default: - if ( Node *ancestor = getAncestorElement(this) ) + { + NodePtr ancestor = getAncestorElement(this); + if ( ancestor.get() ) { return ancestor->lookupNamespaceURI(thePrefix); } @@ -843,6 +856,7 @@ DOMString NodeImpl::lookupNamespaceURI(const DOMString &thePrefix) { return DOMString(""); } + } }//switch } @@ -850,15 +864,15 @@ DOMString NodeImpl::lookupNamespaceURI(const DOMString &thePrefix) /** * */ -bool NodeImpl::isEqualNode(const Node *nodeArg) +bool NodeImpl::isEqualNode(const NodePtr nodeArg) { if (!nodeArg) return false; - if (this == nodeArg) + if (nodeArg == (NodePtr )this) return true; - Node *node = (Node *)nodeArg; + NodePtr node = nodeArg; if (getNodeType() != node->getNodeType() || getNodeName() != node->getNodeName() || @@ -973,7 +987,7 @@ void NodeImpl::setNamespaceURI(const DOMString &theNamespaceURI) * From DOM3 Namespace algorithms */ DOMString NodeImpl::lookupNamespacePrefix(const DOMString &theNamespaceURI, - Node *originalElement) + NodePtr originalElement) { if (!originalElement) return DOMString(""); @@ -991,7 +1005,7 @@ DOMString NodeImpl::lookupNamespacePrefix(const DOMString &theNamespaceURI, int nrAttrs = attributes.getLength(); for (int i=0 ; igetLocalName(); if (attr->getPrefix() == "xmlns" && attr->getNodeValue() == theNamespaceURI && @@ -1004,11 +1018,11 @@ DOMString NodeImpl::lookupNamespacePrefix(const DOMString &theNamespaceURI, } //Get ancestor element, if any - NodeImpl *ancestor = parent; - while (ancestor && ancestor->getNodeType()!= Node::ELEMENT_NODE) + NodeImplPtr ancestor = parent; + while (ancestor.get() && ancestor->getNodeType()!= Node::ELEMENT_NODE) ancestor = ancestor->parent; - if ( ancestor ) + if ( ancestor.get() ) { return ancestor->lookupNamespacePrefix(theNamespaceURI, originalElement); } @@ -1049,7 +1063,7 @@ NodeImpl &NodeImpl::operator=(const NodeImpl &other) /** * */ -NodeImpl::NodeImpl(DocumentImpl *owner) +NodeImpl::NodeImpl(DocumentImplPtr owner) : Node() { init(); ownerDocument = owner; @@ -1058,7 +1072,8 @@ NodeImpl::NodeImpl(DocumentImpl *owner) /** * */ -NodeImpl::NodeImpl(DocumentImpl *owner, const DOMString &nodeName) +NodeImpl::NodeImpl(DocumentImplPtr owner, const DOMString &nodeName) + : Node() { init(); ownerDocument = owner; @@ -1068,8 +1083,8 @@ NodeImpl::NodeImpl(DocumentImpl *owner, const DOMString &nodeName) /** * */ -NodeImpl::NodeImpl(DocumentImpl *owner, const DOMString &theNamespaceURI, - const DOMString &qualifiedName) +NodeImpl::NodeImpl(DocumentImplPtr owner, const DOMString &theNamespaceURI, + const DOMString &qualifiedName) : Node() { init(); ownerDocument = owner; @@ -1122,9 +1137,12 @@ NodeImpl::~NodeImpl() if (userDataEntries) delete userDataEntries; //Delete children - for (Node *n = getFirstChild() ; n ; + /** Use smart pointers. do not delete explicitly + for (NodePtr n = getFirstChild() ; n.get() ; n=n->getNextSibling() ) delete n; + */ + firstChild = lastChild = (NodeImpl *)0; } @@ -1144,7 +1162,7 @@ CharacterDataImpl::CharacterDataImpl() : NodeImpl() /** * */ -CharacterDataImpl::CharacterDataImpl(DocumentImpl *owner, +CharacterDataImpl::CharacterDataImpl(DocumentImplPtr owner, const DOMString &theValue) : NodeImpl() { ownerDocument = owner; @@ -1275,7 +1293,7 @@ void AttrImpl::setValue(const DOMString& val) throw(DOMException) /** * */ -Element *AttrImpl::getOwnerElement() +ElementPtr AttrImpl::getOwnerElement() { return ownerElement; } @@ -1284,9 +1302,9 @@ Element *AttrImpl::getOwnerElement() /** * */ -TypeInfo *AttrImpl::getSchemaTypeInfo() +TypeInfo &AttrImpl::getSchemaTypeInfo() { - return NULL; + return typeInfo; } @@ -1305,15 +1323,15 @@ bool AttrImpl::getIsId() //################## -void AttrImpl::setOwnerElement(const Element *elem) +void AttrImpl::setOwnerElement(const ElementPtr elem) { - ownerElement = (Element *)elem; + ownerElement = elem; } /** * */ -AttrImpl::AttrImpl(DocumentImpl *owner, const DOMString &theName) +AttrImpl::AttrImpl(DocumentImplPtr owner, const DOMString &theName) : NodeImpl() { nodeType = ATTRIBUTE_NODE; @@ -1324,7 +1342,7 @@ AttrImpl::AttrImpl(DocumentImpl *owner, const DOMString &theName) /** * */ -AttrImpl::AttrImpl(DocumentImpl *owner, +AttrImpl::AttrImpl(DocumentImplPtr owner, const DOMString &theNamespaceURI, const DOMString &theQualifiedName) : NodeImpl() @@ -1368,10 +1386,10 @@ DOMString ElementImpl::getTagName() */ DOMString ElementImpl::getAttribute(const DOMString& name) { - Node *node = attributes.getNamedItem(name); + NodePtr node = attributes.getNamedItem(name); if (!node || node->getNodeType() != ATTRIBUTE_NODE) return DOMString(""); - Attr *attr = dynamic_cast(node); + AttrPtr attr = dynamic_cast(node.get()); return attr->getValue(); } @@ -1382,7 +1400,7 @@ void ElementImpl::setAttribute(const DOMString& name, const DOMString& value) throw(DOMException) { - AttrImpl *attr = new AttrImpl(ownerDocument, name); + AttrImplPtr attr = new AttrImpl(ownerDocument, name); attr->setValue(value); attr->setOwnerElement(this); attributes.setNamedItem(attr); @@ -1400,19 +1418,19 @@ void ElementImpl::removeAttribute(const DOMString& name) /** * */ -Attr *ElementImpl::getAttributeNode(const DOMString& name) +AttrPtr ElementImpl::getAttributeNode(const DOMString& name) { - Node *node = attributes.getNamedItem(name); + NodePtr node = attributes.getNamedItem(name); if (!node || node->getNodeType() != ATTRIBUTE_NODE) return NULL; - Attr *attr = dynamic_cast(node); + AttrPtr attr = dynamic_cast(node.get()); return attr; } /** * */ -Attr *ElementImpl::setAttributeNode(Attr *attr) +AttrPtr ElementImpl::setAttributeNode(AttrPtr attr) throw(DOMException) { attributes.setNamedItem(attr); @@ -1422,11 +1440,9 @@ Attr *ElementImpl::setAttributeNode(Attr *attr) /** * */ -Attr *ElementImpl::removeAttributeNode(Attr *attr) +AttrPtr ElementImpl::removeAttributeNode(AttrPtr attr) throw(DOMException) { - if (!attr) - return NULL; attributes.removeNamedItem(attr->getName()); return attr; } @@ -1436,18 +1452,19 @@ Attr *ElementImpl::removeAttributeNode(Attr *attr) * */ void ElementImpl::getElementsByTagNameRecursive(NodeList &list, - const DOMString& name, Element *elem) + const DOMString& name, ElementPtr elem) { if (!elem) return; if (name == elem->getTagName()) list.add(elem); - for (Node *node = elem->getFirstChild() ; node ; node=node->getNextSibling()) + for (NodePtr node = elem->getFirstChild() ; node.get() ; + node=node->getNextSibling()) { if (node->getNodeType() != Node::ELEMENT_NODE) continue; - Element *childElem = dynamic_cast(node); + ElementPtr childElem = dynamic_cast(node.get()); getElementsByTagNameRecursive(list, name, childElem); } } @@ -1469,10 +1486,10 @@ NodeList ElementImpl::getElementsByTagName(const DOMString& tagName) DOMString ElementImpl::getAttributeNS(const DOMString& namespaceURI, const DOMString& localName) { - Node *node = attributes.getNamedItemNS(namespaceURI, localName); + NodePtr node = attributes.getNamedItemNS(namespaceURI, localName); if (!node || node->getNodeType()!=ATTRIBUTE_NODE) return DOMString(""); - Attr *attr = dynamic_cast(node); + AttrPtr attr = dynamic_cast(node.get()); return attr->getValue(); } @@ -1484,7 +1501,7 @@ void ElementImpl::setAttributeNS(const DOMString& namespaceURI, const DOMString& value) throw(DOMException) { - AttrImpl *attr = new AttrImpl(ownerDocument, namespaceURI, qualifiedName); + AttrImplPtr attr = new AttrImpl(ownerDocument, namespaceURI, qualifiedName); attr->setValue(value); attr->setOwnerElement(this); attributes.setNamedItemNS(attr); @@ -1503,20 +1520,20 @@ void ElementImpl::removeAttributeNS(const DOMString& namespaceURI, /** * */ - Attr *ElementImpl::getAttributeNodeNS(const DOMString& namespaceURI, + AttrPtr ElementImpl::getAttributeNodeNS(const DOMString& namespaceURI, const DOMString& localName) { - Node *node = attributes.getNamedItemNS(namespaceURI, localName); + NodePtr node = attributes.getNamedItemNS(namespaceURI, localName); if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return NULL; - Attr *attr = dynamic_cast(node); + return (Attr *)0; + AttrPtr attr = dynamic_cast(node.get()); return attr; } /** * */ -Attr *ElementImpl::setAttributeNodeNS(Attr *attr) +AttrPtr ElementImpl::setAttributeNodeNS(AttrPtr attr) throw(DOMException) { attributes.setNamedItemNS(attr); @@ -1528,18 +1545,19 @@ Attr *ElementImpl::setAttributeNodeNS(Attr *attr) * */ void ElementImpl::getElementsByTagNameNSRecursive(NodeList &list, - const DOMString& namespaceURI, const DOMString& tagName, Element *elem) + const DOMString& namespaceURI, + const DOMString& tagName, ElementPtr elem) { if (!elem) return; if (namespaceURI == elem->getNamespaceURI() && tagName == elem->getTagName()) list.add(elem); - for (Node *node = elem->getFirstChild() ; node ; node=node->getNextSibling()) + for (NodePtr node = elem->getFirstChild() ; node.get() ; node=node->getNextSibling()) { if (node->getNodeType() != Node::ELEMENT_NODE) continue; - Element *childElem = dynamic_cast(node); + ElementPtr childElem = dynamic_cast(node.get()); getElementsByTagNameNSRecursive(list, namespaceURI, tagName, childElem); } } @@ -1560,7 +1578,7 @@ NodeList ElementImpl::getElementsByTagNameNS(const DOMString& namespaceURI, */ bool ElementImpl::hasAttribute(const DOMString& attrName) { - Node *node = attributes.getNamedItem(attrName); + NodePtr node = attributes.getNamedItem(attrName); if (!node || node->getNodeType() != ATTRIBUTE_NODE) return false; return true; @@ -1572,7 +1590,7 @@ bool ElementImpl::hasAttribute(const DOMString& attrName) bool ElementImpl::hasAttributeNS(const DOMString& namespaceURI, const DOMString& localName) { - Node *node = attributes.getNamedItemNS(namespaceURI, localName); + NodePtr node = attributes.getNamedItemNS(namespaceURI, localName); if (!node || node->getNodeType() != ATTRIBUTE_NODE) return false; return true; @@ -1581,10 +1599,9 @@ bool ElementImpl::hasAttributeNS(const DOMString& namespaceURI, /** * */ -TypeInfo *ElementImpl::getSchemaTypeInto() +TypeInfo &ElementImpl::getSchemaTypeInfo() { - //fixme - return NULL; + return typeInfo; } @@ -1610,7 +1627,7 @@ void ElementImpl::setIdAttributeNS(const DOMString &namespaceURI, /** * */ -void ElementImpl::setIdAttributeNode(const Attr *idAttr, +void ElementImpl::setIdAttributeNode(const AttrPtr idAttr, bool isId) throw (DOMException) { //fixme @@ -1633,7 +1650,7 @@ ElementImpl::ElementImpl() : NodeImpl() /** * */ -ElementImpl::ElementImpl(DocumentImpl *owner, const DOMString &tagName) +ElementImpl::ElementImpl(DocumentImplPtr owner, const DOMString &tagName) : NodeImpl() { nodeType = ELEMENT_NODE; @@ -1644,7 +1661,7 @@ ElementImpl::ElementImpl(DocumentImpl *owner, const DOMString &tagName) /** * */ -ElementImpl::ElementImpl(DocumentImpl *owner, +ElementImpl::ElementImpl(DocumentImplPtr owner, const DOMString &theNamespaceURI, const DOMString &qualifiedName) : NodeImpl() @@ -1679,10 +1696,10 @@ void ElementImpl::normalizeNamespaces() int nrAttrs = attrs.getLength(); for (int i=0; igetNodeType() != Node::ATTRIBUTE_NODE) continue; - AttrImpl *attr = dynamic_cast(attrNode); + AttrImplPtr attr = dynamic_cast(attrNode.get()); DOMString attrNS = attr->getNamespaceURI(); DOMString attrName = attr->getLocalName(); DOMString attrPrefix = attr->getPrefix(); @@ -1802,10 +1819,10 @@ void ElementImpl::normalizeNamespaces() nrAttrs = attrs.getLength(); for (int i=0; igetNodeType() != Node::ATTRIBUTE_NODE) continue; - Attr *attr = dynamic_cast(attrNode); + AttrPtr attr = dynamic_cast(attrNode.get()); DOMString attrNS = attr->getNamespaceURI(); DOMString attrPrefix = attr->getPrefix(); DOMString attrValue = attr->getNodeValue(); @@ -1893,11 +1910,11 @@ void ElementImpl::normalizeNamespaces() //####################################### //# Recursively normalize children //####################################### - for (Node *child=getFirstChild() ; child ; child=child->getNextSibling()) + for (NodePtr child=getFirstChild() ; child.get() ; child=child->getNextSibling()) { if (child->getNodeType() != Node::ELEMENT_NODE) continue; - ElementImpl *childElement = dynamic_cast(child); + ElementImplPtr childElement = dynamic_cast(child.get()); childElement->normalizeNamespaces(); } @@ -1922,7 +1939,7 @@ TextImpl::TextImpl() : CharacterDataImpl() /** * */ -TextImpl::TextImpl(DocumentImpl *owner, const DOMString &value) +TextImpl::TextImpl(DocumentImplPtr owner, const DOMString &value) : CharacterDataImpl() { nodeType = TEXT_NODE; @@ -1942,7 +1959,7 @@ TextImpl::~TextImpl() /** * */ -Text *TextImpl::splitText(unsigned long offset) +TextPtr TextImpl::splitText(unsigned long offset) throw(DOMException) { return NULL; @@ -1968,7 +1985,7 @@ DOMString TextImpl::getWholeText() /** * */ -Text *TextImpl::replaceWholeText(const DOMString &content) +TextPtr TextImpl::replaceWholeText(const DOMString &content) throw(DOMException) { return NULL; @@ -1992,7 +2009,7 @@ CommentImpl::CommentImpl() : CharacterDataImpl() /** * */ -CommentImpl::CommentImpl(DocumentImpl *owner, const DOMString &value) +CommentImpl::CommentImpl(DocumentImplPtr owner, const DOMString &value) : CharacterDataImpl() { nodeType = COMMENT_NODE; @@ -2012,61 +2029,6 @@ CommentImpl::~CommentImpl() -/*######################################################################### -## TypeInfoImpl -#########################################################################*/ - - -/** - * - */ -TypeInfoImpl::TypeInfoImpl(const DOMString &typeNamespaceArg, - const DOMString &typeNameArg, - const DerivationMethod derivationMethodArg) -{ - typeNamespace = typeNamespaceArg; - typeName = typeNameArg; - derivationMethod = derivationMethodArg; -} - - -/** - * - */ -TypeInfoImpl::~TypeInfoImpl() -{ -} - - -/** - * - */ -DOMString TypeInfoImpl::getTypeName() -{ - return typeName; -} - -/** - * - */ -DOMString TypeInfoImpl::getTypeNamespace() -{ - return typeNamespace; -} - -/** - * - */ -bool TypeInfoImpl::isDerivedFrom(const DOMString &typeNamespaceArg, - const DOMString &typeNameArg, - const DerivationMethod derivationMethodArg) -{ - if (typeNamespaceArg == typeNamespace && - typeName == typeNameArg && - derivationMethod == derivationMethodArg) - return true; - return false; -} @@ -2097,8 +2059,8 @@ UserDataHandlerImpl::~UserDataHandlerImpl() void UserDataHandlerImpl::handle(unsigned short operation, const DOMString &key, const DOMUserData *data, - const Node *src, - const Node *dst) + const NodePtr src, + const NodePtr dst) { //do nothing. do we need anything here? } @@ -2269,7 +2231,7 @@ long DOMLocatorImpl::getUtf16Offset() /** * */ -Node *DOMLocatorImpl::getRelatedNode() +NodePtr DOMLocatorImpl::getRelatedNode() { return relatedNode; } @@ -2357,7 +2319,7 @@ CDATASectionImpl::CDATASectionImpl() : TextImpl() /** * */ -CDATASectionImpl::CDATASectionImpl(DocumentImpl *owner, const DOMString &theValue) +CDATASectionImpl::CDATASectionImpl(DocumentImplPtr owner, const DOMString &theValue) : TextImpl() { nodeType = CDATA_SECTION_NODE; @@ -2465,7 +2427,7 @@ DOMString DocumentTypeImpl::getInternalSubset() /** * */ -NotationImpl::NotationImpl(DocumentImpl *owner) : NodeImpl() +NotationImpl::NotationImpl(DocumentImplPtr owner) : NodeImpl() { nodeType = NOTATION_NODE; ownerDocument = owner; @@ -2519,7 +2481,7 @@ EntityImpl::EntityImpl() : NodeImpl() /** * */ -EntityImpl::EntityImpl(DocumentImpl *owner) : NodeImpl() +EntityImpl::EntityImpl(DocumentImplPtr owner) : NodeImpl() { nodeType = ENTITY_NODE; ownerDocument = owner; @@ -2604,7 +2566,7 @@ EntityReferenceImpl::EntityReferenceImpl() : NodeImpl() /** * */ -EntityReferenceImpl::EntityReferenceImpl(DocumentImpl *owner, +EntityReferenceImpl::EntityReferenceImpl(DocumentImplPtr owner, const DOMString &theName) : NodeImpl() { @@ -2643,7 +2605,7 @@ ProcessingInstructionImpl::ProcessingInstructionImpl(): NodeImpl() /** * */ -ProcessingInstructionImpl::ProcessingInstructionImpl(DocumentImpl *owner, +ProcessingInstructionImpl::ProcessingInstructionImpl(DocumentImplPtr owner, const DOMString &target, const DOMString &data) : NodeImpl() @@ -2712,7 +2674,7 @@ DocumentFragmentImpl::DocumentFragmentImpl() : NodeImpl() /** * */ -DocumentFragmentImpl::DocumentFragmentImpl(DocumentImpl *owner) : NodeImpl() +DocumentFragmentImpl::DocumentFragmentImpl(DocumentImplPtr owner) : NodeImpl() { nodeType = DOCUMENT_FRAGMENT_NODE; nodeName = "#document-fragment"; @@ -2741,7 +2703,7 @@ DocumentFragmentImpl::~DocumentFragmentImpl() /** * */ -DocumentType *DocumentImpl::getDoctype() +DocumentTypePtr DocumentImpl::getDoctype() { return doctype; } @@ -2757,7 +2719,7 @@ DOMImplementation *DocumentImpl::getImplementation() /** * */ -Element *DocumentImpl::getDocumentElement() +ElementPtr DocumentImpl::getDocumentElement() { return documentElement; } @@ -2765,79 +2727,80 @@ Element *DocumentImpl::getDocumentElement() /** * */ -Element *DocumentImpl::createElement(const DOMString& tagName) +ElementPtr DocumentImpl::createElement(const DOMString& tagName) throw(DOMException) { - ElementImpl *impl = new ElementImpl(this, tagName); - return impl; + ElementPtr elem = new ElementImpl(this, tagName); + return elem; } /** * */ -DocumentFragment *DocumentImpl::createDocumentFragment() +DocumentFragmentPtr DocumentImpl::createDocumentFragment() { - DocumentFragmentImpl *frag = new DocumentFragmentImpl(this); + DocumentFragmentPtr frag = new DocumentFragmentImpl(this); return frag; } /** * */ -Text *DocumentImpl::createTextNode(const DOMString& data) +TextPtr DocumentImpl::createTextNode(const DOMString& data) { - TextImpl *text = new TextImpl(this, data); + TextPtr text = new TextImpl(this, data); return text; } /** * */ -Comment *DocumentImpl::createComment(const DOMString& data) +CommentPtr DocumentImpl::createComment(const DOMString& data) { - CommentImpl *comment = new CommentImpl(this, data); + CommentPtr comment = new CommentImpl(this, data); return comment; } /** * */ -CDATASection *DocumentImpl::createCDATASection(const DOMString& data) +CDATASectionPtr DocumentImpl::createCDATASection(const DOMString& data) throw(DOMException) { - CDATASectionImpl *cdata = new CDATASectionImpl(this, data); + CDATASectionPtr cdata = new CDATASectionImpl(this, data); return cdata; } /** * */ -ProcessingInstruction *DocumentImpl::createProcessingInstruction(const DOMString& target, - const DOMString& data) - throw(DOMException) +ProcessingInstructionPtr +DocumentImpl::createProcessingInstruction(const DOMString& target, + const DOMString& data) + throw(DOMException) { - ProcessingInstructionImpl *cdata = + ProcessingInstructionPtr pi = new ProcessingInstructionImpl(this, target, data); - return cdata; + return pi; } /** * */ -Attr *DocumentImpl::createAttribute(const DOMString& attrName) +AttrPtr DocumentImpl::createAttribute(const DOMString& attrName) throw(DOMException) { - AttrImpl *attr = new AttrImpl(this, attrName); + AttrPtr attr = new AttrImpl(this, attrName); return attr; } /** * */ -EntityReference *DocumentImpl::createEntityReference(const DOMString& erName) +EntityReferencePtr DocumentImpl::createEntityReference(const DOMString& erName) throw(DOMException) { - EntityReferenceImpl *ref = new EntityReferenceImpl(this, erName); + EntityReferencePtr ref = new EntityReferenceImpl(this, erName); return ref; } @@ -2857,7 +2820,7 @@ NodeList DocumentImpl::getElementsByTagName(const DOMString& tagname) /** * */ -Node *DocumentImpl::importNode(const Node *importedNode, +NodePtr DocumentImpl::importNode(const NodePtr importedNode, bool deep) throw(DOMException) { @@ -2867,22 +2830,22 @@ Node *DocumentImpl::importNode(const Node *importedNode, /** * */ -Element *DocumentImpl::createElementNS(const DOMString& namespaceURI, +ElementPtr DocumentImpl::createElementNS(const DOMString& namespaceURI, const DOMString& qualifiedName) throw(DOMException) { - ElementImpl *elem = new ElementImpl(this, namespaceURI, qualifiedName); + ElementPtr elem = new ElementImpl(this, namespaceURI, qualifiedName); return elem; } /** * */ -Attr *DocumentImpl::createAttributeNS(const DOMString& namespaceURI, +AttrPtr DocumentImpl::createAttributeNS(const DOMString& namespaceURI, const DOMString& qualifiedName) throw(DOMException) { - AttrImpl *attr = new AttrImpl(this, namespaceURI, qualifiedName); + AttrPtr attr = new AttrImpl(this, namespaceURI, qualifiedName); return attr; } @@ -2902,7 +2865,7 @@ NodeList DocumentImpl::getElementsByTagNameNS(const DOMString& namespaceURI, /** * */ -Element *DocumentImpl::getElementById(const DOMString& elementId) +ElementPtr DocumentImpl::getElementById(const DOMString& elementId) { for (NamedElementItem *entry = elementsById.next; entry ; entry=entry->next) if (entry->name == elementId) @@ -2982,10 +2945,7 @@ void DocumentImpl::setStrictErrorChecking(bool val) */ DOMString DocumentImpl::getDocumentURI() { - if (!documentURI) - return DOMString(""); - DOMString docURI = *documentURI; - return docURI; + return documentURI; } /** @@ -2999,9 +2959,9 @@ void DocumentImpl::setDocumentURI(const DOMString &uri) /** * */ -Node *DocumentImpl::adoptNode(const Node *source) throw (DOMException) +NodePtr DocumentImpl::adoptNode(const NodePtr source) throw (DOMException) { - return (Node *)source; + return (NodePtr )source; } /** @@ -3018,21 +2978,19 @@ DOMConfiguration *DocumentImpl::getDomConfig() void DocumentImpl::normalizeDocument() { //i assume that this means adjusting namespaces & prefixes - if (documentElement) + if (documentElement.get()) documentElement->normalizeNamespaces(); } /** * */ -Node *DocumentImpl::renameNode(const Node *n, +NodePtr DocumentImpl::renameNode(const NodePtr node, const DOMString &namespaceURI, const DOMString &qualifiedName) throw (DOMException) { - Node *node = (Node *) n; - NodeImpl *nodeImpl = dynamic_cast (node); - //nodeImpl->namespaceURI = stringCache(namespaceURI); + NodeImplPtr nodeImpl = dynamic_cast (node.get()); nodeImpl->setNodeName(qualifiedName); return node; } @@ -3049,15 +3007,15 @@ Node *DocumentImpl::renameNode(const Node *n, DocumentImpl::DocumentImpl(const DOMImplementation *domImpl, const DOMString &theNamespaceURI, const DOMString &theQualifiedName, - const DocumentType *theDoctype) : NodeImpl() + const DocumentTypePtr theDoctype) : NodeImpl() { nodeType = DOCUMENT_NODE; nodeName = "#document"; parent = (DOMImplementation *)domImpl; //documentURI = stringCache(theNamespaceURI); qualifiedName = theQualifiedName; - if (theDoctype) //only assign if not null. - doctype = (DocumentType *)theDoctype; + if (theDoctype.get()) //only assign if not null. + doctype = theDoctype; else doctype = new DocumentTypeImpl("", "", ""); documentElement = new ElementImpl(this, "root"); @@ -3070,7 +3028,7 @@ DocumentImpl::DocumentImpl(const DOMImplementation *domImpl, */ DocumentImpl::~DocumentImpl() { - delete documentElement; + documentElement = NULL; } diff --git a/src/dom/domimpl.h b/src/dom/domimpl.h index 669b3d878..cf7ab6564 100644 --- a/src/dom/domimpl.h +++ b/src/dom/domimpl.h @@ -46,9 +46,12 @@ namespace dom class DOMImplementationSourceImpl; class DOMImplementationImpl; class NodeImpl; +typedef Ptr NodeImplPtr; class CharacterDataImpl; class AttrImpl; +typedef Ptr AttrImplPtr; class ElementImpl; +typedef Ptr ElementImplPtr; class TextImpl; class CommentImpl; class TypeInfoImpl; @@ -59,12 +62,14 @@ class DOMLocatorImpl; class DOMConfigurationImpl; class CDATASectionImpl; class DocumentTypeImpl; +typedef Ptr DocumentTypeImplPtr; class NotationImpl; class EntityImpl; class EntityReferenceImpl; class ProcessingInstructionImpl; class DocumentFragmentImpl; class DocumentImpl; +typedef Ptr DocumentImplPtr; @@ -142,7 +147,7 @@ public: /** * */ - virtual DocumentType *createDocumentType(const DOMString& qualifiedName, + virtual DocumentTypePtr createDocumentType(const DOMString& qualifiedName, const DOMString& publicId, const DOMString& systemId) throw(DOMException); @@ -150,9 +155,9 @@ public: /** * */ - virtual Document *createDocument(const DOMString& namespaceURI, + virtual DocumentPtr createDocument(const DOMString& namespaceURI, const DOMString& qualifiedName, - DocumentType *doctype) + DocumentTypePtr doctype) throw(DOMException); /** * @@ -205,7 +210,7 @@ public: /** * */ - virtual Node *getParentNode(); + virtual NodePtr getParentNode(); /** * @@ -215,22 +220,22 @@ public: /** * */ - virtual Node *getFirstChild(); + virtual NodePtr getFirstChild(); /** * */ - virtual Node *getLastChild(); + virtual NodePtr getLastChild(); /** * */ - virtual Node *getPreviousSibling(); + virtual NodePtr getPreviousSibling(); /** * */ - virtual Node *getNextSibling(); + virtual NodePtr getNextSibling(); /** * @@ -241,32 +246,32 @@ public: /** * */ - virtual Document *getOwnerDocument(); + virtual DocumentPtr getOwnerDocument(); /** * */ - virtual Node *insertBefore(const Node *newChild, - const Node *refChild) + virtual NodePtr insertBefore(const NodePtr newChild, + const NodePtr refChild) throw(DOMException); /** * */ - virtual Node *replaceChild(const Node *newChild, - const Node *oldChild) + virtual NodePtr replaceChild(const NodePtr newChild, + const NodePtr oldChild) throw(DOMException); /** * */ - virtual Node *removeChild(const Node *oldChild) + virtual NodePtr removeChild(const NodePtr oldChild) throw(DOMException); /** * */ - virtual Node *appendChild(const Node *newChild) + virtual NodePtr appendChild(const NodePtr newChild) throw(DOMException); /** @@ -277,7 +282,7 @@ public: /** * */ - virtual Node *cloneNode(bool deep); + virtual NodePtr cloneNode(bool deep); /** * @@ -323,7 +328,7 @@ public: /** * */ - virtual unsigned short compareDocumentPosition(const Node *other); + virtual unsigned short compareDocumentPosition(const NodePtr other); /** * @@ -358,7 +363,7 @@ public: /** * */ - virtual bool isEqualNode(const Node *node); + virtual bool isEqualNode(const NodePtr node); @@ -411,7 +416,7 @@ public: DOMString ret = iter->second; return ret; } - if (parent) + if (parent.get()) { DOMString ret = parent->bindingsFind(prefix); if (ret.size() > 0) @@ -434,7 +439,7 @@ public: * */ DOMString lookupNamespacePrefix(const DOMString &namespaceURI, - Node *originalElement); + NodePtr originalElement); /** * */ @@ -453,17 +458,18 @@ public: /** * */ - NodeImpl(DocumentImpl *owner); + NodeImpl(DocumentImplPtr owner); /** * */ - NodeImpl(DocumentImpl *owner, const DOMString &nodeName); + NodeImpl(DocumentImplPtr owner, const DOMString &nodeName); /** * */ - NodeImpl(DocumentImpl *owner, const DOMString &namespaceURI, const DOMString &nodeName); + NodeImpl(DocumentImplPtr owner, const DOMString &namespaceURI, + const DOMString &nodeName); /** * @@ -485,11 +491,11 @@ protected: unsigned short nodeType; - NodeImpl *parent; + NodeImplPtr parent; - NodeImpl *prev; + NodeImplPtr prev; - NodeImpl *next; + NodeImplPtr next; DOMUserData *userData; @@ -505,10 +511,10 @@ protected: DOMString nodeValue; - NodeImpl *firstChild; - NodeImpl *lastChild; + NodeImplPtr firstChild; + NodeImplPtr lastChild; - DocumentImpl *ownerDocument; + DocumentImplPtr ownerDocument; NamedNodeMap attributes; @@ -538,6 +544,8 @@ protected: }; UserDataEntry *userDataEntries; + + TypeInfo typeInfo; //### Our prefix->namespaceURI bindings @@ -622,7 +630,7 @@ public: /** * */ - CharacterDataImpl(DocumentImpl *owner, const DOMString &value); + CharacterDataImpl(DocumentImplPtr owner, const DOMString &value); /** * @@ -673,13 +681,13 @@ public: /** * */ - virtual Element *getOwnerElement(); + virtual ElementPtr getOwnerElement(); /** * */ - virtual TypeInfo *getSchemaTypeInfo(); + virtual TypeInfo &getSchemaTypeInfo(); /** @@ -696,17 +704,18 @@ public: /** * */ - virtual void setOwnerElement(const Element *elem); + virtual void setOwnerElement(const ElementPtr elem); /** * */ - AttrImpl(DocumentImpl *owner, const DOMString &name); + AttrImpl(DocumentImplPtr owner, const DOMString &name); /** * */ - AttrImpl(DocumentImpl *owner, const DOMString &namespaceURI, const DOMString &name); + AttrImpl(DocumentImplPtr owner, const DOMString &namespaceURI, + const DOMString &name); /** * @@ -716,7 +725,7 @@ public: protected: - Element *ownerElement; + ElementPtr ownerElement; }; @@ -762,18 +771,18 @@ public: /** * */ - virtual Attr *getAttributeNode(const DOMString& name); + virtual AttrPtr getAttributeNode(const DOMString& name); /** * */ - virtual Attr *setAttributeNode(Attr *newAttr) + virtual AttrPtr setAttributeNode(AttrPtr newAttr) throw(DOMException); /** * */ - virtual Attr *removeAttributeNode(Attr *oldAttr) + virtual AttrPtr removeAttributeNode(AttrPtr oldAttr) throw(DOMException); /** @@ -805,13 +814,13 @@ public: /** * */ - virtual Attr *getAttributeNodeNS(const DOMString& namespaceURI, + virtual AttrPtr getAttributeNodeNS(const DOMString& namespaceURI, const DOMString& localName); /** * */ - virtual Attr *setAttributeNodeNS(Attr *newAttr) + virtual AttrPtr setAttributeNodeNS(AttrPtr newAttr) throw(DOMException); /** @@ -834,7 +843,7 @@ public: /** * */ - virtual TypeInfo *getSchemaTypeInto(); + virtual TypeInfo &getSchemaTypeInfo(); /** @@ -853,7 +862,7 @@ public: /** * */ - virtual void setIdAttributeNode(const Attr *idAttr, + virtual void setIdAttributeNode(const AttrPtr idAttr, bool isId) throw (DOMException); @@ -871,12 +880,13 @@ public: /** * */ - ElementImpl(DocumentImpl *owner, const DOMString &tagName); + ElementImpl(DocumentImplPtr owner, const DOMString &tagName); /** * */ - ElementImpl(DocumentImpl *owner, const DOMString &namespaceURI, const DOMString &tagName); + ElementImpl(DocumentImplPtr owner, const DOMString &namespaceURI, + const DOMString &tagName); /** * @@ -893,9 +903,10 @@ protected: friend class DocumentImpl; static void getElementsByTagNameRecursive(NodeList &list, - const DOMString& name, Element *elem); + const DOMString& name, ElementPtr elem); static void getElementsByTagNameNSRecursive(NodeList &list, - const DOMString& namespaceURI, const DOMString& tagName, Element *elem); + const DOMString& namespaceURI, const DOMString& tagName, + ElementPtr elem); }; @@ -916,7 +927,7 @@ public: /** * */ - virtual Text *splitText(unsigned long offset) + virtual TextPtr splitText(unsigned long offset) throw(DOMException); /** @@ -933,7 +944,7 @@ public: /** * */ - virtual Text *replaceWholeText(const DOMString &content) + virtual TextPtr replaceWholeText(const DOMString &content) throw(DOMException); //################## @@ -949,7 +960,7 @@ public: /** * */ - TextImpl(DocumentImpl *owner, const DOMString &val); + TextImpl(DocumentImplPtr owner, const DOMString &val); /** * @@ -985,7 +996,7 @@ public: /** * */ - CommentImpl(DocumentImpl *owner, const DOMString &theValue); + CommentImpl(DocumentImplPtr owner, const DOMString &theValue); /** * @@ -1071,8 +1082,8 @@ public: virtual void handle(unsigned short operation, const DOMString &key, const DOMUserData *data, - const Node *src, - const Node *dst); + const NodePtr src, + const NodePtr dst); //################## //# Non-API methods @@ -1238,7 +1249,7 @@ public: /** * */ - virtual Node *getRelatedNode(); + virtual NodePtr getRelatedNode(); /** @@ -1274,7 +1285,7 @@ protected: long utf16Offset; - Node *relatedNode; + NodePtr relatedNode; DOMString uri; }; @@ -1361,7 +1372,7 @@ public: /** * */ - CDATASectionImpl(DocumentImpl *owner, const DOMString &value); + CDATASectionImpl(DocumentImplPtr owner, const DOMString &value); /** * @@ -1483,7 +1494,7 @@ public: /** * */ - NotationImpl(DocumentImpl *owner); + NotationImpl(DocumentImplPtr owner); /** * @@ -1560,7 +1571,7 @@ public: /** * */ - EntityImpl(DocumentImpl *owner); + EntityImpl(DocumentImplPtr owner); /** * @@ -1612,7 +1623,7 @@ public: /** * */ - EntityReferenceImpl(DocumentImpl *owner, const DOMString &theName); + EntityReferenceImpl(DocumentImplPtr owner, const DOMString &theName); /** * @@ -1632,7 +1643,9 @@ public: /** * */ -class ProcessingInstructionImpl : public ProcessingInstruction, public NodeImpl +class ProcessingInstructionImpl : + public ProcessingInstruction, + public NodeImpl { public: @@ -1666,7 +1679,7 @@ public: /** * */ - ProcessingInstructionImpl(DocumentImpl *owner, + ProcessingInstructionImpl(DocumentImplPtr owner, const DOMString &target, const DOMString &data); @@ -1713,7 +1726,7 @@ public: /** * */ - DocumentFragmentImpl(DocumentImpl *owner); + DocumentFragmentImpl(DocumentImplPtr owner); /** * @@ -1741,7 +1754,7 @@ public: /** * */ - virtual DocumentType *getDoctype(); + virtual DocumentTypePtr getDoctype(); /** * @@ -1751,52 +1764,53 @@ public: /** * */ - virtual Element *getDocumentElement(); + virtual ElementPtr getDocumentElement(); /** * */ - virtual Element *createElement(const DOMString& tagName) + virtual ElementPtr createElement(const DOMString& tagName) throw(DOMException); /** * */ - virtual DocumentFragment *createDocumentFragment(); + virtual DocumentFragmentPtr createDocumentFragment(); /** * */ - virtual Text *createTextNode(const DOMString& data); + virtual TextPtr createTextNode(const DOMString& data); /** * */ - virtual Comment *createComment(const DOMString& data); + virtual CommentPtr createComment(const DOMString& data); /** * */ - virtual CDATASection *createCDATASection(const DOMString& data) + virtual CDATASectionPtr createCDATASection(const DOMString& data) throw(DOMException); /** * */ - virtual ProcessingInstruction *createProcessingInstruction(const DOMString& target, - const DOMString& data) - throw(DOMException); + virtual ProcessingInstructionPtr createProcessingInstruction( + const DOMString& target, + const DOMString& data) + throw(DOMException); /** * */ - virtual Attr *createAttribute(const DOMString& name) + virtual AttrPtr createAttribute(const DOMString& name) throw(DOMException); /** * */ - virtual EntityReference *createEntityReference(const DOMString& name) + virtual EntityReferencePtr createEntityReference(const DOMString& name) throw(DOMException); /** @@ -1808,21 +1822,21 @@ public: /** * */ - virtual Node *importNode(const Node *importedNode, + virtual NodePtr importNode(const NodePtr importedNode, bool deep) throw(DOMException); /** * */ - virtual Element *createElementNS(const DOMString& namespaceURI, + virtual ElementPtr createElementNS(const DOMString& namespaceURI, const DOMString& qualifiedName) throw(DOMException); /** * */ - virtual Attr *createAttributeNS(const DOMString& namespaceURI, + virtual AttrPtr createAttributeNS(const DOMString& namespaceURI, const DOMString& qualifiedName) throw(DOMException); @@ -1835,7 +1849,7 @@ public: /** * */ - virtual Element *getElementById(const DOMString& elementId); + virtual ElementPtr getElementById(const DOMString& elementId); /** @@ -1893,7 +1907,7 @@ public: /** * */ - virtual Node *adoptNode(const Node *source) throw (DOMException); + virtual NodePtr adoptNode(const NodePtr source) throw (DOMException); /** * @@ -1908,7 +1922,7 @@ public: /** * */ - virtual Node *renameNode(const Node *n, + virtual NodePtr renameNode(const NodePtr n, const DOMString &name, const DOMString &qualifiedName) throw (DOMException); @@ -1919,9 +1933,9 @@ public: //################## DocumentImpl(const DOMImplementation *domImpl, - const DOMString &namespaceURI, - const DOMString &qualifiedName, - const DocumentType *doctype); + const DOMString &namespaceURI, + const DOMString &qualifiedName, + const DocumentTypePtr doctype); virtual ~DocumentImpl(); @@ -1934,13 +1948,13 @@ protected: DOMImplementation *parent; - DOMString *documentURI; + DOMString documentURI; DOMString qualifiedName; - DocumentType *doctype; + DocumentTypePtr doctype; - ElementImpl *documentElement; + ElementImplPtr documentElement; class NamedElementItem { @@ -1949,7 +1963,7 @@ protected: { next = NULL; } - NamedElementItem(const DOMString &nameArg, Element *elemArg) + NamedElementItem(const DOMString &nameArg, ElementPtr elemArg) { next = NULL; name = nameArg; @@ -1962,7 +1976,7 @@ protected: } NamedElementItem *next; DOMString name; - Element *elem; + ElementPtr elem; }; NamedElementItem elementsById; diff --git a/src/dom/domptr.cpp b/src/dom/domptr.cpp new file mode 100644 index 000000000..d325ae1ad --- /dev/null +++ b/src/dom/domptr.cpp @@ -0,0 +1,86 @@ +/** + * Phoebe DOM Implementation. + * + * This is a C++ approximation of the W3C DOM model, which follows + * fairly closely the specifications in the various .idl files, copies of + * which are provided for reference. Most important is this one: + * + * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html + * + * Authors: + * Bob Jamison + * + * Copyright (C) 2006 Bob Jamison + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "dom.h" + + +namespace org +{ +namespace w3c +{ +namespace dom +{ + + + + +/*######################################################################### +## NodePtr +#########################################################################*/ + + + +/** + * Increment the ref counter of the wrapped class instance + */ +void incrementRefCount(Node *p) +{ + if (p) + p->_refCnt++; +} + +/** + * Decrement the ref counter of the wrapped class instance. Delete + * the object if the reference count goes to zero + */ +void decrementRefCount(Node *p) +{ + if (p) + { + if (--(p->_refCnt) < 1) + delete p; + } +} + + + + +} //namespace dom +} //namespace w3c +} //namespace org + + + +/*######################################################################### +## E N D O F F I L E +#########################################################################*/ + + + + diff --git a/src/dom/events.h b/src/dom/events.h index 5a8fe6ccd..7c9a6f571 100644 --- a/src/dom/events.h +++ b/src/dom/events.h @@ -48,7 +48,7 @@ namespace events { //Local definitions typedef dom::DOMString DOMString; typedef dom::DOMTimeStamp DOMTimeStamp; -typedef dom::Node Node; +typedef dom::NodePtr NodePtr ; @@ -1147,8 +1147,8 @@ public: /** * */ - virtual Node *getRelatedNode() - { return relatedNode; } + virtual NodePtr getRelatedNodePtr () + { return relatedNodePtr ; } /** * @@ -1182,7 +1182,7 @@ public: virtual void initMutationEvent(const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, - const Node *relatedNodeArg, + const NodePtr relatedNodeArg, const DOMString &prevValueArg, const DOMString &newValueArg, const DOMString &attrNameArg, @@ -1197,7 +1197,7 @@ public: const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, - const Node *relatedNodeArg, + const NodePtr relatedNodeArg, const DOMString &prevValueArg, const DOMString &newValueArg, const DOMString &attrNameArg, @@ -1215,7 +1215,7 @@ public: */ MutationEvent() { - relatedNode = NULL; + relatedNodePtr = NULL; } /** @@ -1223,7 +1223,7 @@ public: */ MutationEvent(const MutationEvent &other) : Event(other) { - relatedNode = other.relatedNode; + relatedNodePtr = other.relatedNodePtr ; prevValue = other.prevValue; newValue = other.newValue; attrName = other.attrName; @@ -1237,7 +1237,7 @@ public: protected: - Node *relatedNode; + NodePtr relatedNodePtr ; DOMString prevValue; DOMString newValue; DOMString attrName; @@ -1277,7 +1277,7 @@ public: virtual void initMutationNameEvent(const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, - const Node *relatedNodeArg, + const NodePtr relatedNodeArg, const DOMString &prevNamespaceURIArg, const DOMString &prevNodeNameArg) { @@ -1291,7 +1291,7 @@ public: const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, - const Node *relatedNodeArg, + const NodePtr relatedNodeArg, const DOMString &prevNamespaceURIArg, const DOMString &prevNodeNameArg) { @@ -1315,8 +1315,8 @@ public: MutationNameEvent(const MutationNameEvent &other) : Event(other), MutationEvent(other) { - prevNamespaceURI = other.prevNamespaceURI; - prevNodeName = other.prevNodeName; + prevNamespaceURI = other.prevNamespaceURI; + prevNodeName = other.prevNodeName; } diff --git a/src/dom/jsbind.cpp b/src/dom/jsbind.cpp deleted file mode 100644 index 0cfe47761..000000000 --- a/src/dom/jsbind.cpp +++ /dev/null @@ -1,6116 +0,0 @@ - /** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -/** - * This code provides the ECMAScript (Javascript) binding to the classes - * of the DOM Level 3 Core. This should provide DOM manipulation for - * most general-purpose XML and Document-like applications. More specialized - * applications like SVG should inherit from the core C++ classes, and also - * use the prototypes in this file as the basis for their bindings. - * - * To ensure that we at least attempt to bind ECMAScript to DOM - * as closely as possible to the standards, we will include the entire - * Appendix H of the XML Level 3 Core spec as annotations in this file. - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/ecma-script-binding.html - */ - - - - #include "domimpl.h" - #include "jsengine.h" - - namespace org - { - namespace w3c - { - namespace dom - { - - - - -//######################################################################## -//# U T I L I T Y -//######################################################################## - -//Use this for getting the JavascriptEngine from an object method -#define ENGINE ((JavascriptEngine *) JS_GetContextPrivate(cx)) - - -/** - * The name of the property is an enumeration, so just return the value. - */ -static JSBool JSGetEnumProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) -{ - *vp = id; - return JS_TRUE; -} - - -static JSString *domToJString(JSContext *cx, const DOMString &s) -{ - JSString *str = JS_NewStringCopyN(cx, s.c_str(), s.size()); - return str; -} - -static DOMString jvToDomString(JSContext *cx, jsval s) -{ - JSString *jstr = JS_ValueToString(cx, s); - DOMString str = JS_GetStringBytes(jstr); - return str; -} - -static DOMString jToDomString(JSString *s) -{ - DOMString str = JS_GetStringBytes(s); - return str; -} - - -//######################################################################## -//# C L A S S E S -//######################################################################## - - -/** - * Appendix H: ECMAScript Language Binding - * - * This appendix contains the complete ECMAScript [ECMAScript] binding for the - * Level 3 Document Object Model Core definitions. H.1 ECMAScript Binding - * Extension - * - */ - - -//######################################################################## -//# DOMImplementationRegistry -//######################################################################## - -/** - * This section defines the DOMImplementationRegistry object, discussed in - * Bootstrapping, for ECMAScript. - * - * - * Objects that implements the DOMImplementationRegistry interface - * - * DOMImplementationRegistry is a global variable which has the following - * functions: - * - * getDOMImplementation(features) - * This method returns the first registered object that implements - * the DOMImplementation interface and has the desired features, - * or null if none is found. The features parameter is a String. - * See also DOMImplementationSource.getDOMImplementation(). - * - * getDOMImplementationList(features) - * This method returns a DOMImplementationList list of registered - * object that implements the DOMImplementation interface and - * has the desired features. The features parameter is a String. - * See also DOMImplementationSource.getDOMImplementationList(). - * - * - */ - -class ECMA_DOMImplementationRegistry -{ -public: - - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - //DOMException *p = new DOMException(JSVAL_TO_INT( argv[0] )); - //if ( ! JS_SetPrivate(cx, obj, p) ) - // return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - //DOMException *p = (DOMException *) JS_GetPrivate(cx, obj); - //delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getDOMImplementation(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getDOMImplementationList(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_DOMImplementationRegistry::classDef = -{ - "DOMImplementationRegistry", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DOMImplementationRegistry::properties[] = -{ - { 0 } -}; - -JSFunctionSpec ECMA_DOMImplementationRegistry::methods[] = -{ - { "getDOMImplementation", getDOMImplementation, 1, 0, 0 }, - { "getDOMImplementationList", getDOMImplementationList, 1, 0, 0 }, - { 0 } -}; - - - - - - -/** - * H.2 Other Core interfaces - */ - - - - -//######################################################################## -//# DOMException -//######################################################################## - -/** - * Properties of the DOMException Constructor function: - * - * DOMException.INDEX_SIZE_ERR - * The value of the constant DOMException.INDEX_SIZE_ERR is 1. - * DOMException.DOMSTRING_SIZE_ERR - * The value of the constant DOMException.DOMSTRING_SIZE_ERR is 2. - * DOMException.HIERARCHY_REQUEST_ERR - * The value of the constant DOMException.HIERARCHY_REQUEST_ERR is 3. - * DOMException.WRONG_DOCUMENT_ERR - * The value of the constant DOMException.WRONG_DOCUMENT_ERR is 4. - * DOMException.INVALID_CHARACTER_ERR - * The value of the constant DOMException.INVALID_CHARACTER_ERR is 5. - * DOMException.NO_DATA_ALLOWED_ERR - * The value of the constant DOMException.NO_DATA_ALLOWED_ERR is 6. - * DOMException.NO_MODIFICATION_ALLOWED_ERR - * The value of the constant DOMException.NO_MODIFICATION_ALLOWED_ERR is 7. - * DOMException.NOT_FOUND_ERR - * The value of the constant DOMException.NOT_FOUND_ERR is 8. - * DOMException.NOT_SUPPORTED_ERR - * The value of the constant DOMException.NOT_SUPPORTED_ERR is 9. - * DOMException.INUSE_ATTRIBUTE_ERR - * The value of the constant DOMException.INUSE_ATTRIBUTE_ERR is 10. - * DOMException.INVALID_STATE_ERR - * The value of the constant DOMException.INVALID_STATE_ERR is 11. - * DOMException.SYNTAX_ERR - * The value of the constant DOMException.SYNTAX_ERR is 12. - * DOMException.INVALID_MODIFICATION_ERR - * The value of the constant DOMException.INVALID_MODIFICATION_ERR is 13. - * DOMException.NAMESPACE_ERR - * The value of the constant DOMException.NAMESPACE_ERR is 14. - * DOMException.INVALID_ACCESS_ERR - * The value of the constant DOMException.INVALID_ACCESS_ERR is 15. - * DOMException.VALIDATION_ERR - * The value of the constant DOMException.VALIDATION_ERR is 16. - * DOMException.TYPE_MISMATCH_ERR - * The value of the constant DOMException.TYPE_MISMATCH_ERR is 17. - * - * Objects that implement the DOMException interface: - * - * Properties of objects that implement the DOMException interface: - * - * code - * This property is a Number. - * - */ - -class ECMA_DOMException -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - DOMException *p = new DOMException(JSVAL_TO_INT( argv[0] )); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - staticProperties, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - DOMException *p = (DOMException *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (!JSVAL_IS_INT(id)) - return JS_FALSE; - int index = JSVAL_TO_INT(id); - DOMException *p = (DOMException *) JS_GetPrivate(cx, obj); - switch( index ) - { - case prop_code: - { - *vp = INT_TO_JSVAL(p->code); - return JS_TRUE; - } - } - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (!JSVAL_IS_INT(id)) - return JS_FALSE; - int index = JSVAL_TO_INT( id ); - DOMException *p = (DOMException *) JS_GetPrivate(cx, obj); - switch( index ) - { - case prop_code: - { - p->code = JSVAL_TO_INT( *vp ); - return JS_TRUE; - } - } - return JS_FALSE; - } - - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - enum - { - prop_code - }; - static JSPropertySpec properties[]; - static JSPropertySpec staticProperties[]; - static JSFunctionSpec methods[]; - static JSFunctionSpec staticMethods[]; - -}; - -JSClass ECMA_DOMException::classDef = -{ - "Node", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DOMException::properties[] = -{ - { "code", prop_code, JSPROP_ENUMERATE }, - { 0 } -}; - -JSPropertySpec ECMA_DOMException::staticProperties[] = -{ - { "INDEX_SIZE_ERR", DOMException::INDEX_SIZE_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "DOMSTRING_SIZE_ERR", DOMException::DOMSTRING_SIZE_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "HIERARCHY_REQUEST_ERR", DOMException::HIERARCHY_REQUEST_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "WRONG_DOCUMENT_ERR", DOMException::WRONG_DOCUMENT_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "INVALID_CHARACTER_ERR", DOMException::INVALID_CHARACTER_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "NO_DATA_ALLOWED_ERR", DOMException::NO_DATA_ALLOWED_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "NO_MODIFICATION_ALLOWED_ERR", DOMException::NO_MODIFICATION_ALLOWED_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "NOT_FOUND_ERR", DOMException::NOT_FOUND_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "NOT_SUPPORTED_ERR", DOMException::NOT_SUPPORTED_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "INUSE_ATTRIBUTE_ERR", DOMException::INUSE_ATTRIBUTE_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "INVALID_STATE_ERR", DOMException::INVALID_STATE_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "SYNTAX_ERR", DOMException::SYNTAX_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "INVALID_MODIFICATION_ERR", DOMException::INVALID_MODIFICATION_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "NAMESPACE_ERR", DOMException::NAMESPACE_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "INVALID_ACCESS_ERR", DOMException::INVALID_ACCESS_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "VALIDATION_ERR", DOMException::VALIDATION_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { "TYPE_MISMATCH_ERR", DOMException::TYPE_MISMATCH_ERR, - JSPROP_READONLY, JSGetEnumProperty }, - { 0 } -}; - -JSFunctionSpec ECMA_DOMException::methods[] = -{ - { 0 } -}; - - - - - -//######################################################################## -//# DOMStringList -//######################################################################## - -/** - * Objects that implement the DOMStringList interface: - * - * Properties of objects that implement the DOMStringList interface: - * - * length - * This read-only property is a Number. - * - * Functions of objects that implement the DOMStringList interface: - * - * item(index) - * This function returns a String. - * The index parameter is a Number. - * Note: This object can also be dereferenced using square bracket - * notation (e.g. obj[1]). Dereferencing with an integer index - * is equivalent to invoking the item function with that index. - * - * contains(str) - * This function returns a Boolean. - * The str parameter is a String. - * - */ - -class ECMA_DOMStringList -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - DOMStringList *p = new DOMStringList(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - DOMStringList *p = (DOMStringList *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Use this one for list[index] lookup - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (!JSVAL_IS_INT(id)) - return JS_TRUE; - int index = JSVAL_TO_INT(id); - DOMStringList *p = (DOMStringList *) JS_GetPrivate(cx, obj); - JSString *jstr = domToJString(cx, p->item(index)); - *vp = STRING_TO_JSVAL(jstr); - return JS_FALSE; - } - - /** - * JSGetProperty - Use this one for enumerated property names - */ - static JSBool JSGetNamedProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (JSVAL_IS_INT(id)) - { - DOMStringList *p = (DOMStringList *) JS_GetPrivate(cx, obj); - if (JSVAL_TO_INT(id) == prop_length) - { - *vp = JSVAL_TO_INT(p->getLength()); - return JS_TRUE; - } - } - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool item(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - uint32 index; - if (!JS_ConvertArguments(cx, argc, argv, "u", &index)) - return JS_FALSE; - DOMStringList *p = (DOMStringList *) JS_GetPrivate(cx, obj); - *rval = STRING_TO_JSVAL(domToJString(cx, p->item(index))); - return JS_TRUE; - } - - /** - * - */ - static JSBool contains(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *str; - if (!JS_ConvertArguments(cx, argc, argv, "S", &str)) - return JS_FALSE; - DOMStringList *p = (DOMStringList *) JS_GetPrivate(cx, obj); - *rval = BOOLEAN_TO_JSVAL(p->contains( jToDomString(str))); - return JS_TRUE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_length - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_DOMStringList::classDef = -{ - "DOMStringList", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DOMStringList::properties[] = -{ - { "length", prop_length, JSPROP_READONLY, JSGetNamedProperty }, - { 0 } -}; - -JSFunctionSpec ECMA_DOMStringList::methods[] = -{ - { "item", item, 1, 0, 0 }, - { "contains", contains, 1, 0, 0 }, - { 0 } -}; - - - - - -//######################################################################## -//# NameList -//######################################################################## - -/** - * Objects that implement the NameList interface: - * - * Properties of objects that implement the NameList interface: - * - * length - * This read-only property is a Number. - * - * Functions of objects that implement the NameList interface: - * - * getName(index) - * This function returns a String. - * The index parameter is a Number. - * getNamespaceURI(index) - * This function returns a String. - * The index parameter is a Number. - * contains(str) - * This function returns a Boolean. - * The str parameter is a String. - * containsNS(namespaceURI, name) - * This function returns a Boolean. - * The namespaceURI parameter is a String. - * The name parameter is a String. - */ - -class ECMA_NameList -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - NameList *p = new NameList(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - NameList *p = (NameList *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (!JSVAL_IS_INT(id)) - return JS_TRUE; - int index = JSVAL_TO_INT(id); - NameList *p = (NameList *) JS_GetPrivate(cx, obj); - switch (index) - { - case prop_length: - *vp = INT_TO_JSVAL(p->getLength()); - return JS_TRUE; - } - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getName(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - uint32 index; - if (!JS_ConvertArguments(cx, argc, argv, "u", &index)) - return JS_FALSE; - NameList *p = (NameList *) JS_GetPrivate(cx, obj); - *rval = STRING_TO_JSVAL(domToJString(cx, p->getName(index))); - return JS_TRUE; - } - - /** - * - */ - static JSBool getNamespaceURI(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - uint32 index; - if (!JS_ConvertArguments(cx, argc, argv, "u", &index)) - return JS_FALSE; - NameList *p = (NameList *) JS_GetPrivate(cx, obj); - *rval = STRING_TO_JSVAL(domToJString(cx, p->getNamespaceURI(index))); - return JS_TRUE; - } - - /** - * - */ - static JSBool contains(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *str; - if (!JS_ConvertArguments(cx, argc, argv, "S", &str)) - return JS_FALSE; - NameList *p = (NameList *) JS_GetPrivate(cx, obj); - *rval = BOOLEAN_TO_JSVAL(p->contains( jToDomString(str))); - return JS_TRUE; - } - - /** - * - */ - static JSBool containsNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *ns; JSString *name; - if (!JS_ConvertArguments(cx, argc, argv, "SS", &ns, &name)) - return JS_FALSE; - NameList *p = (NameList *) JS_GetPrivate(cx, obj); - *rval = BOOLEAN_TO_JSVAL( - p->containsNS(jToDomString(ns), jToDomString(name))); - return JS_TRUE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_length - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_NameList::classDef = -{ - "NameList", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_NameList::properties[] = -{ - { "length", prop_length, JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_NameList::methods[] = -{ - { "getName", getName, 1, 0, 0 }, - { "getNamespaceURI", getNamespaceURI, 1, 0, 0 }, - { "contains", contains, 1, 0, 0 }, - { "containsNS", containsNS, 2, 0, 0 }, - { 0 } -}; - - - - - -//######################################################################## -//# DOMImplementationList -//######################################################################## - -/** - * Objects that implement the DOMImplementationList interface: - * - * Properties of objects that implement the DOMImplementationList interface: - * - * length - * This read-only property is a Number. - * - * Functions of objects that implement the DOMImplementationList interface: - * - * item(index) - * This function returns an object that implements the - * DOMImplementation interface. - * The index parameter is a Number. - * Note: This object can also be dereferenced using square bracket - * notation (e.g. obj[1]). Dereferencing with an integer index - * is equivalent to invoking the item function with that index. - * - * - */ - -class ECMA_DOMImplementationList -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - DOMImplementationList *p = new DOMImplementationList(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - DOMImplementationList *p = - (DOMImplementationList *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Use this one for list[index] lookup - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (!JSVAL_IS_INT(id)) - return JS_TRUE; - int index = JSVAL_TO_INT(id); - DOMImplementationList *p = - (DOMImplementationList *) JS_GetPrivate(cx, obj); - DOMImplementation *di = p->item(index); - *vp = OBJECT_TO_JSVAL(ENGINE->new_DOMImplementation(di)); - return JS_FALSE; - } - - /** - * JSGetProperty - Use this one for enumerated property names - */ - static JSBool JSGetNamedProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (!JSVAL_IS_INT(id)) - return JS_TRUE; - int index = JSVAL_TO_INT(id); - DOMImplementationList *p = - (DOMImplementationList *) JS_GetPrivate(cx, obj); - switch (index) - { - case prop_length: - *vp = INT_TO_JSVAL(p->getLength()); - return JS_TRUE; - } - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool item(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - uint32 index; - if (!JS_ConvertArguments(cx, argc, argv, "u", &index)) - return JS_FALSE; - DOMImplementationList *p = - (DOMImplementationList *) JS_GetPrivate(cx, obj); - DOMImplementation *di = p->item(index); - *rval = OBJECT_TO_JSVAL(ENGINE->new_DOMImplementation(di)); - return JS_TRUE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_length - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_DOMImplementationList::classDef = -{ - "DOMImplementationRegistry", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DOMImplementationList::properties[] = -{ - { "length", prop_length, JSPROP_READONLY, JSGetNamedProperty }, - { 0 } -}; - -JSFunctionSpec ECMA_DOMImplementationList::methods[] = -{ - { "item", item, 1, 0, 0 }, - { 0 } -}; - - - - - - -//######################################################################## -//# DOMImplementationSource -//######################################################################## - -/** - * Objects that implement the DOMImplementationSource interface: - * - * Functions of objects that implement the DOMImplementationSource interface: - * - * getDOMImplementation(features) - * This function returns an object that implements the - * DOMImplementation interface. - * The features parameter is a String. - * getDOMImplementationList(features) - * This function returns an object that implements the - * DOMImplementationList interface. - * The features parameter is a String. - */ - -class ECMA_DOMImplementationSource -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - DOMImplementationSource *p = new DOMImplementationSourceImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - DOMImplementationSource *p = - (DOMImplementationSource *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - //####################### - //# M E T H O D S - //####################### - - /** - * - */ - static JSBool getDOMImplementation(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *feature; - if (!JS_ConvertArguments(cx, argc, argv, "S", &feature)) - return JS_FALSE; - DOMImplementationSource *p = - (DOMImplementationSource *) JS_GetPrivate(cx, obj); - DOMImplementation *di = - p->getDOMImplementation(jToDomString(feature)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_DOMImplementation(di)); - return JS_TRUE; - } - - /** - * - */ - static JSBool getDOMImplementationList(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *feature; - if (!JS_ConvertArguments(cx, argc, argv, "S", &feature)) - return JS_FALSE; - DOMImplementationSource *p = - (DOMImplementationSource *) JS_GetPrivate(cx, obj); - DOMImplementationList di = - p->getDOMImplementationList(jToDomString(feature)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_DOMImplementationList(&di)); - return JS_TRUE; - } - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_DOMImplementationSource::classDef = -{ - "DOMImplementationSource", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DOMImplementationSource::properties[] = -{ - { 0 } -}; - -JSFunctionSpec ECMA_DOMImplementationSource::methods[] = -{ - { "getDOMImplementation", getDOMImplementation, 1, 0, 0 }, - { "getDOMImplementationList", getDOMImplementationList, 1, 0, 0 }, - { 0 } -}; - - - - - -//######################################################################## -//# DOMImplementation -//######################################################################## - -/** - * Objects that implement the DOMImplementation interface: - * - * Functions of objects that implement the DOMImplementation interface: - * - * hasFeature(feature, version) - * This function returns a Boolean. - * The feature parameter is a String. - * The version parameter is a String. - * createDocumentType(qualifiedName, publicId, systemId) - * This function returns an object that implements the - * DocumentType interface. - * The qualifiedName parameter is a String. - * The publicId parameter is a String. - * The systemId parameter is a String. - * This function can raise an object that implements the - * DOMException interface. - * createDocument(namespaceURI, qualifiedName, doctype) - * This function returns an object that implements the - * Document interface. - * The namespaceURI parameter is a String. - * The qualifiedName parameter is a String. - * The doctype parameter is an object that implements the - * DocumentType interface. - * This function can raise an object that implements the - * DOMException interface. - * getFeature(feature, version) - * This function returns an object that implements - * the Object interface. - * The feature parameter is a String. - * The version parameter is a String. - */ - -class ECMA_DOMImplementation -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - DOMImplementation *p = new DOMImplementationImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - DOMImplementation *p = (DOMImplementation *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - //####################### - //# M E T H O D S - //####################### - - /** - * - */ - static JSBool hasFeature(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool createDocumentType(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool createDocument(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getFeature(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_DOMImplementation::classDef = -{ - "DOMImplementation", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DOMImplementation::properties[] = -{ - { 0 } -}; - -JSFunctionSpec ECMA_DOMImplementation::methods[] = -{ - { "hasFeature", hasFeature, 2, 0, 0 }, - { "createDocumentType", createDocumentType, 3, 0, 0 }, - { "createDocument", createDocument, 3, 0, 0 }, - { "getFeature", getFeature, 2, 0, 0 }, - { 0 } -}; - - - - -//######################################################################## -//# DocumentFragment -//######################################################################## - -/** - * Objects that implement the DocumentFragment interface: - * - * Objects that implement the DocumentFragment interface have all - * properties and functions of the Node interface. - */ - -class ECMA_DocumentFragment -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - DocumentFragment *p = new DocumentFragmentImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - DocumentFragment *p = (DocumentFragment *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_DocumentFragment::classDef = -{ - "DocumentFragment", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DocumentFragment::properties[] = -{ - { 0 } -}; - -JSFunctionSpec ECMA_DocumentFragment::methods[] = -{ - { 0 } -}; - - - - - - - -//######################################################################## -//# Document -//######################################################################## - -/** - * Objects that implement the Document interface: - * - * Objects that implement the Document interface have all properties - * and functions of the Node interface as well as the properties - * and functions defined below. - * Properties of objects that implement the Document interface: - * - * - * doctype - * This read-only property is an object that implements - * the DocumentType interface. - * implementation - * This read-only property is an object that implements - * the DOMImplementation interface. - * documentElement - * This read-only property is an object that implements - * the Element interface. - * inputEncoding - * This read-only property is a String. - * xmlEncoding - * This read-only property is a String. - * xmlStandalone - * This property is a Boolean and can raise an object - * that implements the DOMException interface on setting. - * xmlVersion - * This property is a String and can raise an object - * that implements the DOMException interface on setting. - * strictErrorChecking - * This property is a Boolean. - * documentURI - * This property is a String. - * domConfig - * This read-only property is an object that implements - * the DOMConfiguration interface. - * - * - * Functions of objects that implement the Document interface: - * - * createElement(tagName) - * This function returns an object that implements - * the Element interface. - * The tagName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * createDocumentFragment() - * This function returns an object that implements - * the DocumentFragment interface. - * createTextNode(data) - * This function returns an object that implements - * the Text interface. - * The data parameter is a String. - * createComment(data) - * This function returns an object that implements - * the Comment interface. - * The data parameter is a String. - * createCDATASection(data) - * This function returns an object that implements - * the CDATASection interface. - * The data parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * createProcessingInstruction(target, data) - * This function returns an object that implements - * the ProcessingInstruction interface. - * The target parameter is a String. - * The data parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * createAttribute(name) - * This function returns an object that implements - * the Attr interface. - * The name parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * createEntityReference(name) - * This function returns an object that implements - * the EntityReference interface. - * The name parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * getElementsByTagName(tagname) - * This function returns an object that implements - * the NodeList interface. - * The tagname parameter is a String. - * importNode(importedNode, deep) - * This function returns an object that implements - * the Node interface. - * The importedNode parameter is an object that implements - * the Node interface. - * The deep parameter is a Boolean. - * This function can raise an object that implements - * the DOMException interface. - * createElementNS(namespaceURI, qualifiedName) - * This function returns an object that implements - * the Element interface. - * The namespaceURI parameter is a String. - * The qualifiedName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * createAttributeNS(namespaceURI, qualifiedName) - * This function returns an object that implements - * the Attr interface. - * The namespaceURI parameter is a String. - * The qualifiedName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * getElementsByTagNameNS(namespaceURI, localName) - * This function returns an object that implements - * the NodeList interface. - * The namespaceURI parameter is a String. - * The localName parameter is a String. - * getElementById(elementId) - * This function returns an object that implements - * the Element interface. - * The elementId parameter is a String. - * adoptNode(source) - * This function returns an object that implements - * the Node interface. - * The source parameter is an object that implements - * the Node interface. - * This function can raise an object that implements - * the DOMException interface. - * normalizeDocument() - * This function has no return value. - * renameNode(n, namespaceURI, qualifiedName) - * This function returns an object that implements - * the Node interface. - * The n parameter is an object that implements - * the Node interface. - * The namespaceURI parameter is a String. - * The qualifiedName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - */ - -class ECMA_Document -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - //Document *p = new DocumentImpl(); - //if ( ! JS_SetPrivate(cx, obj, p) ) - // return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - Document *p = (Document *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (!JSVAL_IS_INT(id)) - return JS_FALSE; - int index = JSVAL_TO_INT(id); - Document *d = (Document *)JS_GetPrivate(cx, obj); - switch (index) - { - case prop_doctype: - { - DocumentType *p = d->getDoctype(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_DocumentType(p)); - return JS_TRUE; - } - case prop_implementation: - { - DOMImplementation *p = d->getImplementation(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_DOMImplementation(p)); - return JS_TRUE; - } - case prop_documentElement: - { - Element *p = d->getDocumentElement(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_Element(p)); - return JS_TRUE; - } - case prop_inputEncoding: - { - DOMString p = d->getInputEncoding(); - *vp = OBJECT_TO_JSVAL(domToJString(cx, p)); - return JS_TRUE; - } - case prop_xmlEncoding: - { - DOMString p = d->getXmlEncoding(); - *vp = OBJECT_TO_JSVAL(domToJString(cx, p)); - return JS_TRUE; - } - case prop_xmlStandalone: - { - *vp = BOOLEAN_TO_JSVAL(d->getXmlStandalone()); - return JS_TRUE; - } - case prop_xmlVersion: - { - DOMString p = d->getXmlVersion(); - *vp = OBJECT_TO_JSVAL(domToJString(cx, p)); - return JS_TRUE; - } - case prop_strictErrorChecking: - { - *vp = BOOLEAN_TO_JSVAL(d->getStrictErrorChecking()); - return JS_TRUE; - } - case prop_documentURI: - { - DOMString p = d->getDocumentURI(); - *vp = OBJECT_TO_JSVAL(domToJString(cx, p)); - return JS_TRUE; - } - case prop_domConfig: - { - DOMConfiguration *p = d->getDomConfig(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_DOMConfiguration(p)); - return JS_TRUE; - } - } - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (!JSVAL_IS_INT(id)) - return JS_FALSE; - int index = JSVAL_TO_INT(id); - Document *d = (Document *)JS_GetPrivate(cx, obj); - switch (index) - { - case prop_xmlStandalone: - { - d->setXmlStandalone(JSVAL_TO_BOOLEAN(*vp)); - return JS_TRUE; - } - case prop_xmlVersion: - { - d->setXmlVersion(jvToDomString(cx, *vp)); - return JS_TRUE; - } - case prop_strictErrorChecking: - { - d->setStrictErrorChecking(JSVAL_TO_BOOLEAN(*vp)); - return JS_TRUE; - } - case prop_documentURI: - { - d->setDocumentURI(jvToDomString(cx, *vp)); - return JS_TRUE; - } - } - return JS_FALSE; - } - - - //####################### - //# M E T H O D S - //####################### - - /** - * - */ - static JSBool createElement(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *str; - if (!JS_ConvertArguments(cx, argc, argv, "S", &str)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - Element *p = d->createElement(jToDomString(str)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_Element(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool createDocumentFragment(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - Document *d = (Document *)JS_GetPrivate(cx, obj); - DocumentFragment *p = d->createDocumentFragment(); - *rval = OBJECT_TO_JSVAL(ENGINE->new_DocumentFragment(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool createTextNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *str; - if (!JS_ConvertArguments(cx, argc, argv, "S", &str)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - Text *p = d->createTextNode(jToDomString(str)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_Text(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool createComment(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *str; - if (!JS_ConvertArguments(cx, argc, argv, "S", &str)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - Comment *p = d->createComment(jToDomString(str)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_Comment(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool createCDATASection(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *str; - if (!JS_ConvertArguments(cx, argc, argv, "S", &str)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - CDATASection *p = d->createCDATASection(jToDomString(str)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_CDATASection(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool createProcessingInstruction(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *name; JSString *data; - if (!JS_ConvertArguments(cx, argc, argv, "SS", &name, &data)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - ProcessingInstruction *p = - d->createProcessingInstruction(jToDomString(name), jToDomString(data)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_ProcessingInstruction(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool createAttribute(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *str; - if (!JS_ConvertArguments(cx, argc, argv, "S", &str)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - Attr *p = d->createAttribute(jToDomString(str)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_Attr(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool createEntityReference(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *str; - if (!JS_ConvertArguments(cx, argc, argv, "S", &str)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - EntityReference *p = d->createEntityReference(jToDomString(str)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_EntityReference(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool getElementsByTagName(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *str; - if (!JS_ConvertArguments(cx, argc, argv, "S", &str)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - NodeList p = d->getElementsByTagName(jToDomString(str)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_NodeList(&p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool importNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSObject *impnode; JSBool deep; - if (!JS_ConvertArguments(cx, argc, argv, "ou", &impnode, &deep)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - Node *n = (Node *)JS_GetPrivate(cx, impnode); - Node *p = d->importNode(n, deep); - *rval = OBJECT_TO_JSVAL(ENGINE->new_Node(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool createElementNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *ns; JSString *name; - if (!JS_ConvertArguments(cx, argc, argv, "SS", &ns, &name)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - Element *p = - d->createElementNS(jToDomString(ns), jToDomString(name)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_Element(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool createAttributeNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *ns; JSString *name; - if (!JS_ConvertArguments(cx, argc, argv, "SS", &ns, &name)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - Attr *p = - d->createAttributeNS(jToDomString(ns), jToDomString(name)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_Attr(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool getElementsByTagNameNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *ns; JSString *name; - if (!JS_ConvertArguments(cx, argc, argv, "SS", &ns, &name)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - NodeList p = - d->getElementsByTagNameNS(jToDomString(ns), jToDomString(name)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_NodeList(&p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool getElementById(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSString *str; - if (!JS_ConvertArguments(cx, argc, argv, "S", &str)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - Element *p = d->getElementById(jToDomString(str)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_Element(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool adoptNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSObject *impnode; - if (!JS_ConvertArguments(cx, argc, argv, "o", &impnode)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - Node *n = (Node *)JS_GetPrivate(cx, impnode); - Node *p = d->adoptNode(n); - *rval = OBJECT_TO_JSVAL(ENGINE->new_Node(p)); - return JS_TRUE; - } - - /** - * - */ - static JSBool normalizeDocument(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - Document *d = (Document *)JS_GetPrivate(cx, obj); - d->normalizeDocument(); - return JS_TRUE; - } - - /** - * - */ - static JSBool renameNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - JSObject *rnode; JSString *nsuri; JSString *qname; - if (!JS_ConvertArguments(cx, argc, argv, "oSS", &rnode, &nsuri, &qname)) - return JS_FALSE; - Document *d = (Document *)JS_GetPrivate(cx, obj); - Node *n = (Node *)JS_GetPrivate(cx, rnode); - Node *p = d->renameNode(n, jToDomString(nsuri), jToDomString(qname)); - *rval = OBJECT_TO_JSVAL(ENGINE->new_Node(p)); - return JS_TRUE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_doctype, - prop_implementation, - prop_documentElement, - prop_inputEncoding, - prop_xmlEncoding, - prop_xmlStandalone, - prop_xmlVersion, - prop_strictErrorChecking, - prop_documentURI, - prop_domConfig - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_Document::classDef = -{ - "Document", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_Document::properties[] = -{ - { "doctype", prop_doctype, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "implementation", prop_implementation, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "documentElement", prop_documentElement, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "inputEncoding", prop_inputEncoding, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "xmlEncoding", prop_xmlEncoding, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "xmlStandalone", prop_xmlStandalone, - JSPROP_ENUMERATE }, - { "xmlVersion", prop_xmlVersion, - JSPROP_ENUMERATE }, - { "strictErrorChecking", prop_strictErrorChecking, - JSPROP_ENUMERATE }, - { "documentURI", prop_documentURI, - JSPROP_ENUMERATE }, - { "domConfig", prop_domConfig, - JSPROP_ENUMERATE }, - { 0 } -}; - -JSFunctionSpec ECMA_Document::methods[] = -{ - { "createElement", createElement, 1, 0, 0 }, - { "createDocumentFragment", createDocumentFragment, 0, 0, 0 }, - { "createTextNode", createTextNode, 1, 0, 0 }, - { "createComment", createComment, 1, 0, 0 }, - { "createCDATASection", createCDATASection, 1, 0, 0 }, - { "createProcessingInstruction", createProcessingInstruction, 2, 0, 0 }, - { "createAttribute", createAttribute, 1, 0, 0 }, - { "createEntityReference", createEntityReference, 1, 0, 0 }, - { "getElementsByTagName", getElementsByTagName, 1, 0, 0 }, - { "importNode", importNode, 2, 0, 0 }, - { "createElementNS", createElementNS, 2, 0, 0 }, - { "createAttributeNS", createAttributeNS, 2, 0, 0 }, - { "getElementsByTagNameNS", getElementsByTagNameNS, 2, 0, 0 }, - { "getElementById", getElementById, 1, 0, 0 }, - { "adoptNode", adoptNode, 1, 0, 0 }, - { "normalizeDocument", normalizeDocument, 0, 0, 0 }, - { "renameNode", renameNode, 3, 0, 0 }, - { 0 } -}; - - - - - - -//######################################################################## -//# Node -//######################################################################## - -/** - * Properties of the Node Constructor function: - * - * Node.ELEMENT_NODE - * The value of the constant Node.ELEMENT_NODE is 1. - * Node.ATTRIBUTE_NODE - * The value of the constant Node.ATTRIBUTE_NODE is 2. - * Node.TEXT_NODE - * The value of the constant Node.TEXT_NODE is 3. - * Node.CDATA_SECTION_NODE - * The value of the constant Node.CDATA_SECTION_NODE is 4. - * Node.ENTITY_REFERENCE_NODE - * The value of the constant Node.ENTITY_REFERENCE_NODE is 5. - * Node.ENTITY_NODE - * The value of the constant Node.ENTITY_NODE is 6. - * Node.PROCESSING_INSTRUCTION_NODE - * The value of the constant Node.PROCESSING_INSTRUCTION_NODE is 7. - * Node.COMMENT_NODE - * The value of the constant Node.COMMENT_NODE is 8. - * Node.DOCUMENT_NODE - * The value of the constant Node.DOCUMENT_NODE is 9. - * Node.DOCUMENT_TYPE_NODE - * The value of the constant Node.DOCUMENT_TYPE_NODE is 10. - * Node.DOCUMENT_FRAGMENT_NODE - * The value of the constant Node.DOCUMENT_FRAGMENT_NODE is 11. - * Node.NOTATION_NODE - * The value of the constant Node.NOTATION_NODE is 12. - * Node.DOCUMENT_POSITION_DISCONNECTED - * The value of the constant Node.DOCUMENT_POSITION_DISCONNECTED - * is 0x01. - * Node.DOCUMENT_POSITION_PRECEDING - * The value of the constant Node.DOCUMENT_POSITION_PRECEDING - * is 0x02. - * Node.DOCUMENT_POSITION_FOLLOWING - * The value of the constant Node.DOCUMENT_POSITION_FOLLOWING - * is 0x04. - * Node.DOCUMENT_POSITION_CONTAINS - * The value of the constant Node.DOCUMENT_POSITION_CONTAINS - * is 0x08. - * Node.DOCUMENT_POSITION_CONTAINED_BY - * The value of the constant Node.DOCUMENT_POSITION_CONTAINED_BY - * is 0x10. - * Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC - * The value of the constant Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC - * is 0x20. - * - * Objects that implement the Node interface: - * - * Properties of objects that implement the Node interface: - * - * nodeName - * This read-only property is a String. - * nodeValue - * This property is a String, can raise an object that implements - * the DOMException - * interface on setting and can raise an object that implements - * the DOMException - * interface on retrieval. - * nodeType - * This read-only property is a Number. - * parentNode - * This read-only property is an object that implements - * the Node interface. - * childNodes - * This read-only property is an object that implements - * the NodeList interface. - * firstChild - * This read-only property is an object that implements - * the Node interface. - * lastChild - * This read-only property is an object that implements - * the Node interface. - * previousSibling - * This read-only property is an object that implements - * the Node interface. - * nextSibling - * This read-only property is an object that implements - * the Node interface. - * attributes - * This read-only property is an object that implements - * the NamedNodeMap interface. - * ownerDocument - * This read-only property is an object that implements - * the Document interface. - * namespaceURI - * This read-only property is a String. - * prefix - * This property is a String and can raise an object - * that implements the DOMException interface on setting. - * localName - * This read-only property is a String. - * baseURI - * This read-only property is a String. - * textContent - * This property is a String, can raise an object that implements - * the DOMException interface on setting and can raise - * an object that implements the DOMException interface - * on retrieval. - * - * - * Functions of objects that implement the Node interface: - * - * insertBefore(newChild, refChild) - * This function returns an object that implements - * the Node interface. - * The newChild parameter is an object that implements - * the Node interface. - * The refChild parameter is an object that implements - * the Node interface. - * This function can raise an object that implements - * the DOMException interface. - * replaceChild(newChild, oldChild) - * This function returns an object that implements - * the Node interface. - * The newChild parameter is an object that implements - * the Node interface. - * The oldChild parameter is an object that implements - * the Node interface. - * This function can raise an object that implements - * the DOMException interface. - * removeChild(oldChild) - * This function returns an object that implements - * the Node interface. - * The oldChild parameter is an object that implements - * the Node interface. - * This function can raise an object that implements - * the DOMException interface. - * appendChild(newChild) - * This function returns an object that implements - * the Node interface. - * The newChild parameter is an object that implements - * the Node interface. - * This function can raise an object that implements - * the DOMException interface. - * hasChildNodes() - * This function returns a Boolean. - * cloneNode(deep) - * This function returns an object that implements - * the Node interface. - * The deep parameter is a Boolean. - * normalize() - * This function has no return value. - * isSupported(feature, version) - * This function returns a Boolean. - * The feature parameter is a String. - * The version parameter is a String. - * hasAttributes() - * This function returns a Boolean. - * compareDocumentPosition(other) - * This function returns a Number. - * The other parameter is an object that implements - * the Node interface. - * This function can raise an object that implements - * the DOMException interface. - * isSameNode(other) - * This function returns a Boolean. - * The other parameter is an object that implements - * the Node interface. - * lookupPrefix(namespaceURI) - * This function returns a String. - * The namespaceURI parameter is a String. - * isDefaultNamespace(namespaceURI) - * This function returns a Boolean. - * The namespaceURI parameter is a String. - * lookupNamespaceURI(prefix) - * This function returns a String. - * The prefix parameter is a String. - * isEqualNode(arg) - * This function returns a Boolean. - * The arg parameter is an object that implements - * the Node interface. - * getFeature(feature, version) - * This function returns an object that implements - * the Object interface. - * The feature parameter is a String. - * The version parameter is a String. - * setUserData(key, data, handler) - * This function returns an object that implements - * the any type interface. - * The key parameter is a String. - * The data parameter is an object that implements - * the any type interface. - * The handler parameter is an object that implements - * the UserDataHandler interface. - * getUserData(key) - * This function returns an object that implements - * the any type interface. - * The key parameter is a String. - * - */ - -class ECMA_Node -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - Node *p = new NodeImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - staticProperties, staticMethods); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - Node *p = (Node *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (!JSVAL_IS_INT(id)) - return JS_FALSE; - int index = JSVAL_TO_INT(id); - Node *n = (Node *)JS_GetPrivate(cx, obj); - switch (index) - { - case prop_nodeName: - { - *vp = OBJECT_TO_JSVAL(domToJString(cx, n->getNodeName())); - return JS_TRUE; - } - case prop_nodeValue: - { - *vp = OBJECT_TO_JSVAL(domToJString(cx, n->getNodeValue())); - return JS_TRUE; - } - case prop_nodeType: - { - *vp = INT_TO_JSVAL(n->getNodeType()); - return JS_TRUE; - } - case prop_parentNode: - { - Node *p = n->getParentNode(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_Node(p)); - return JS_TRUE; - } - case prop_childNodes: - { - NodeList p = n->getChildNodes(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_NodeList(&p)); - return JS_TRUE; - } - case prop_firstChild: - { - Node *p = n->getFirstChild(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_Node(p)); - return JS_TRUE; - } - case prop_lastChild: - { - Node *p = n->getLastChild(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_Node(p)); - return JS_TRUE; - } - case prop_previousSibling: - { - Node *p = n->getPreviousSibling(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_Node(p)); - return JS_TRUE; - } - case prop_nextSibling: - { - Node *p = n->getNextSibling(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_Node(p)); - return JS_TRUE; - } - case prop_attributes: - { - NamedNodeMap p = n->getAttributes(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_NamedNodeMap(&p)); - return JS_TRUE; - } - case prop_ownerDocument: - { - Document *p = n->getOwnerDocument(); - *vp = OBJECT_TO_JSVAL(ENGINE->new_Document(p)); - return JS_TRUE; - } - case prop_namespaceURI: - { - DOMString s = n->getNamespaceURI(); - *vp = OBJECT_TO_JSVAL(domToJString(cx, s)); - return JS_TRUE; - } - case prop_prefix: - { - DOMString s = n->getPrefix(); - *vp = OBJECT_TO_JSVAL(domToJString(cx, s)); - return JS_TRUE; - } - case prop_localName: - { - DOMString s = n->getLocalName(); - *vp = OBJECT_TO_JSVAL(domToJString(cx, s)); - return JS_TRUE; - } - case prop_baseURI: - { - DOMString s = n->getBaseURI(); - *vp = OBJECT_TO_JSVAL(domToJString(cx, s)); - return JS_TRUE; - } - case prop_textContent: - { - DOMString s = n->getTextContent(); - *vp = OBJECT_TO_JSVAL(domToJString(cx, s)); - return JS_TRUE; - } - } - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - if (!JSVAL_IS_INT(id)) - return JS_FALSE; - //Node *p = (Node *) JS_GetPrivate(cx, obj); - switch( JSVAL_TO_INT( id ) ) - { - case prop_nodeValue: - { - return JS_TRUE; - } - case prop_prefix: - { - //*vp = INT_TO_JSVAL(priv->getNode()->GetAge()); - return JS_TRUE; - } - } - return JS_FALSE; - } - - - //####################### - //# M E T H O D S - //####################### - - /** - * - */ - static JSBool insertBefore(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool replaceChild(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool removeChild(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool appendChild(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool hasChildNodes(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool cloneNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool normalize(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool isSupported(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool hasAttributes(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool compareDocumentPosition(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool isSameNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool lookupPrefix(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool isDefaultNamespace(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool lookupNamespaceURI(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool isEqualNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getFeature(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool setUserData(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getUserData(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - static JSClass classDef; - -private: - - // Standard JS Binding fields - enum - { - prop_nodeName, - prop_nodeValue, - prop_nodeType, - prop_parentNode, - prop_childNodes, - prop_firstChild, - prop_lastChild, - prop_previousSibling, - prop_nextSibling, - prop_attributes, - prop_ownerDocument, - prop_namespaceURI, - prop_prefix, - prop_localName, - prop_baseURI, - prop_textContent - }; - static JSPropertySpec properties[]; - static JSPropertySpec staticProperties[]; - static JSFunctionSpec methods[]; - static JSFunctionSpec staticMethods[]; - -}; - -JSClass ECMA_Node::classDef = -{ - "Node", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_Node::properties[] = -{ - { "nodeName", prop_nodeName, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "nodeValue", prop_nodeValue, - JSPROP_ENUMERATE }, - { "nodeType", prop_nodeType, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "parentNode", prop_parentNode, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "childNodes", prop_childNodes, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "firstChild", prop_firstChild, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "lastChild", prop_lastChild, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "previousSibling", prop_previousSibling, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "nextSibling", prop_nextSibling, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "attributes", prop_attributes, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "ownerDocument", prop_ownerDocument, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "namespaceURI", prop_namespaceURI, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "prefix", prop_prefix, - JSPROP_ENUMERATE }, - { "localName", prop_localName, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "baseURI", prop_baseURI, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "textContent", prop_textContent, - JSPROP_ENUMERATE }, - { 0 } -}; - -JSPropertySpec ECMA_Node::staticProperties[] = -{ - { "ELEMENT_NODE", Node::ELEMENT_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "ATTRIBUTE_NODE", Node::ATTRIBUTE_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "TEXT_NODE", Node::TEXT_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "CDATA_SECTION_NODE", Node::CDATA_SECTION_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "ENTITY_REFERENCE_NODE", Node::ENTITY_REFERENCE_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "ENTITY_NODE", Node::ENTITY_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "PROCESSING_INSTRUCTION_NODE", Node::PROCESSING_INSTRUCTION_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "COMMENT_NODE", Node::COMMENT_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "DOCUMENT_NODE", Node::DOCUMENT_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "DOCUMENT_TYPE_NODE", Node::DOCUMENT_TYPE_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "DOCUMENT_FRAGMENT_NODE", Node::DOCUMENT_FRAGMENT_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "NOTATION_NODE", Node::NOTATION_NODE, - JSPROP_READONLY, JSGetEnumProperty }, - { "DOCUMENT_POSITION_DISCONNECTED", 0x01, - JSPROP_READONLY, JSGetEnumProperty }, - { "DOCUMENT_POSITION_PRECEDING", 0x02, - JSPROP_READONLY, JSGetEnumProperty }, - { "DOCUMENT_POSITION_FOLLOWING", 0x04, - JSPROP_READONLY, JSGetEnumProperty }, - { "DOCUMENT_POSITION_CONTAINS", 0x08, - JSPROP_READONLY, JSGetEnumProperty }, - { "DOCUMENT_POSITION_CONTAINED_BY", 0x10, - JSPROP_READONLY, JSGetEnumProperty }, - { "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", 0x20, - JSPROP_READONLY, JSGetEnumProperty }, - { 0 } -}; - -JSFunctionSpec ECMA_Node::methods[] = -{ - { "insertBefore", insertBefore, 2, 0, 0 }, - { "replaceChild", replaceChild, 2, 0, 0 }, - { "removeChild", removeChild, 1, 0, 0 }, - { "appendChild", appendChild, 1, 0, 0 }, - { "hasChildNodes", hasChildNodes, 0, 0, 0 }, - { "cloneNode", cloneNode, 1, 0, 0 }, - { "normalize", normalize, 0, 0, 0 }, - { "isSupported", isSupported, 2, 0, 0 }, - { "hasAttributes", hasAttributes, 0, 0, 0 }, - { "compareDocumentPosition", compareDocumentPosition, 1, 0, 0 }, - { "isSameNode", isSameNode, 1, 0, 0 }, - { "lookupPrefix", lookupPrefix, 1, 0, 0 }, - { "isDefaultNamespace", isDefaultNamespace, 1, 0, 0 }, - { "lookupNamespaceURI", lookupNamespaceURI, 1, 0, 0 }, - { "isEqualNode", isEqualNode, 1, 0, 0 }, - { "getFeature", getFeature, 2, 0, 0 }, - { "setUserData", setUserData, 3, 0, 0 }, - { "getUserData", getUserData, 1, 0, 0 }, - { 0 } -}; - -JSFunctionSpec ECMA_Node::staticMethods[] = -{ - { 0 } -}; - - - - - - -//######################################################################## -//# NodeList -//######################################################################## - -/** - * Objects that implement the NodeList interface: - * - * Properties of objects that implement the NodeList interface: - * - * length - * This read-only property is a Number. - * - * Functions of objects that implement the NodeList interface: - * - * item(index) - * This function returns an object that implements - * the Node interface. - * The index parameter is a Number. - * Note: This object can also be dereferenced using square - * bracket notation (e.g. obj[1]). Dereferencing with - * an integer index is equivalent to invoking the item - * function with that index. - * - * - */ - -class ECMA_NodeList -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - NodeList *p = new NodeList(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - NodeList *p = (NodeList *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - We are using this one for indexes - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSGetNamedProperty - Provide a second property getter if - * the default one is delegated to indexes - */ - static JSBool JSGetNamedProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - //####################### - //# M E T H O D S - //####################### - - /** - * - */ - static JSBool item(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_length, - prop_item - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_NodeList::classDef = -{ - "NodeList", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_NodeList::properties[] = -{ - { "length", prop_length, - JSPROP_ENUMERATE|JSPROP_READONLY, JSGetNamedProperty }, - { 0 } -}; - -JSFunctionSpec ECMA_NodeList::methods[] = -{ - { "item", item, 1, 0, 0 }, - { 0 } -}; - - - - - -//######################################################################## -//# NamedNodeMap -//######################################################################## - -/** - * Objects that implement the NamedNodeMap interface: - * - * Properties of objects that implement the NamedNodeMap interface: - * - * length - * This read-only property is a Number. - * - * Functions of objects that implement the NamedNodeMap interface: - * - * getNamedItem(name) - * This function returns an object that implements - * the Node interface. - * The name parameter is a String. - * setNamedItem(arg) - * This function returns an object that implements - * the Node interface. - * The arg parameter is an object that implements - * the Node interface. - * This function can raise an object that implements - * the DOMException interface. - * removeNamedItem(name) - * This function returns an object that implements - * the Node interface. - * The name parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * item(index) - * This function returns an object that implements - * the Node interface. - * The index parameter is a Number. - * Note: This object can also be dereferenced using square - * bracket notation (e.g. obj[1]). Dereferencing with - * an integer index is equivalent to invoking the item - * function with that index. - * getNamedItemNS(namespaceURI, localName) - * This function returns an object that implements - * the Node interface. - * The namespaceURI parameter is a String. - * The localName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * setNamedItemNS(arg) - * This function returns an object that implements - * the Node interface. - * The arg parameter is an object that implements - * the Node interface. - * This function can raise an object that implements - * the DOMException interface. - * removeNamedItemNS(namespaceURI, localName) - * This function returns an object that implements - * the Node interface. - * The namespaceURI parameter is a String. - * The localName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - */ - - -class ECMA_NamedNodeMap -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - NamedNodeMap *p = new NamedNodeMap(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - NamedNodeMap *p = (NamedNodeMap *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetNamedProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - //####################### - //# M E T H O D S - //####################### - - /** - * - */ - static JSBool getNamedItem(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool setNamedItem(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool removeNamedItem(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool item(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getNamedItemNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool setNamedItemNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool removeNamedItemNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_length - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_NamedNodeMap::classDef = -{ - "NamedNodeMap", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_NamedNodeMap::properties[] = -{ - { "length", prop_length, - JSPROP_ENUMERATE|JSPROP_READONLY, JSGetNamedProperty }, - { 0 } -}; - -JSFunctionSpec ECMA_NamedNodeMap::methods[] = -{ - { "getNamedItem", getNamedItem, 1, 0, 0 }, - { "setNamedItem", setNamedItem, 1, 0, 0 }, - { "removeNamedItem", removeNamedItem, 1, 0, 0 }, - { "item", item, 1, 0, 0 }, - { "getNamedItemNS", getNamedItemNS, 2, 0, 0 }, - { "setNamedItemNS", setNamedItemNS, 2, 0, 0 }, - { "removeNamedItemNS", removeNamedItemNS, 2, 0, 0 }, - { 0 } -}; - - - - -//######################################################################## -//# CharacterData -//######################################################################## - -/** - * Objects that implement the CharacterData interface: - * - * Objects that implement the CharacterData interface have all - * properties and functions of the Node interface as well as - * the properties and functions defined below. Properties - * of objects that implement the CharacterData interface: - * - * - * data - * This property is a String, can raise an object - * that implements the DOMException interface on setting - * and can raise an object that implements the DOMException - * interface on retrieval. - * length - * This read-only property is a Number. - * - * Functions of objects that implement the CharacterData interface: - * - * substringData(offset, count) - * This function returns a String. - * The offset parameter is a Number. - * The count parameter is a Number. - * This function can raise an object that implements - * the DOMException interface. - * appendData(arg) - * This function has no return value. - * The arg parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * insertData(offset, arg) - * This function has no return value. - * The offset parameter is a Number. - * The arg parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * deleteData(offset, count) - * This function has no return value. - * The offset parameter is a Number. - * The count parameter is a Number. - * This function can raise an object that implements - * the DOMException interface. - * replaceData(offset, count, arg) - * This function has no return value. - * The offset parameter is a Number. - * The count parameter is a Number. - * The arg parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - */ - -class ECMA_CharacterData -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - CharacterData *p = new CharacterDataImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - CharacterData *p = (CharacterData *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - //####################### - //# M E T H O D S - //####################### - - /** - * - */ - static JSBool substringData(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool appendData(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool insertData(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool deleteData(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool replaceData(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_data, - prop_length - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_CharacterData::classDef = -{ - "CharacterData", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_CharacterData::properties[] = -{ - { "data", prop_data, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "length", prop_length, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_CharacterData::methods[] = -{ - { "substringData", substringData, 2, 0, 0 }, - { "appendData", appendData, 1, 0, 0 }, - { "insertData", insertData, 2, 0, 0 }, - { "deleteData", deleteData, 2, 0, 0 }, - { "replaceData", replaceData, 3, 0, 0 }, - { 0 } -}; - - - - -//######################################################################## -//# Attr -//######################################################################## - -/** - * Objects that implement the Attr interface: - * - * Objects that implement the Attr interface have all properties - * and functions of the Node interface as well as the properties - * and functions defined below. - * Properties of objects that implement the Attr interface: - * - * - * name - * This read-only property is a String. - * specified - * This read-only property is a Boolean. - * value - * This property is a String and can raise an object - * that implements the DOMException interface on setting. - * ownerElement - * This read-only property is an object that implements - * the Element interface. - * schemaTypeInfo - * This read-only property is an object that implements - * the TypeInfo interface. - * isId - * This read-only property is a Boolean. - * - */ - -class ECMA_Attr -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - //Attr *p = new AttrImpl(); - //if ( ! JS_SetPrivate(cx, obj, p) ) - // return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - Attr *p = (Attr *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_name, - prop_specified, - prop_value, - prop_ownerElement, - prop_schemaTypeInfo, - prop_isId, - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_Attr::classDef = -{ - "Attr", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_Attr::properties[] = -{ - { "name", prop_name, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "specified", prop_specified, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "value", prop_value, - JSPROP_ENUMERATE }, - { "ownerElement", prop_ownerElement, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "schemaTypeInfo", prop_schemaTypeInfo, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "isId", prop_isId, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_Attr::methods[] = -{ - { 0 } -}; - - - - - -//######################################################################## -//# Element -//######################################################################## - -/** - * Objects that implement the Element interface: - * - * Objects that implement the Element interface have all properties - * and functions of the Node interface as well as the properties - * and functions defined below. - * Properties of objects that implement the Element interface: - * - * - * tagName - * This read-only property is a String. - * schemaTypeInfo - * This read-only property is an object that implements - * the TypeInfo interface. - * - * Functions of objects that implement the Element interface: - * - * getAttribute(name) - * This function returns a String. - * The name parameter is a String. - * setAttribute(name, value) - * This function has no return value. - * The name parameter is a String. - * The value parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * removeAttribute(name) - * This function has no return value. - * The name parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * getAttributeNode(name) - * This function returns an object that implements - * the Attr interface. - * The name parameter is a String. - * setAttributeNode(newAttr) - * This function returns an object that implements - * the Attr interface. - * The newAttr parameter is an object that implements - * the Attr interface. - * This function can raise an object that implements - * the DOMException interface. - * removeAttributeNode(oldAttr) - * This function returns an object that implements - * the Attr interface. - * The oldAttr parameter is an object that implements - * the Attr interface. - * This function can raise an object that implements - * the DOMException interface. - * getElementsByTagName(name) - * This function returns an object that implements - * the NodeList interface. - * The name parameter is a String. - * getAttributeNS(namespaceURI, localName) - * This function returns a String. - * The namespaceURI parameter is a String. - * The localName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * setAttributeNS(namespaceURI, qualifiedName, value) - * This function has no return value. - * The namespaceURI parameter is a String. - * The qualifiedName parameter is a String. - * The value parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * removeAttributeNS(namespaceURI, localName) - * This function has no return value. - * The namespaceURI parameter is a String. - * The localName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * getAttributeNodeNS(namespaceURI, localName) - * This function returns an object that implements - * the Attr interface. - * The namespaceURI parameter is a String. - * The localName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * setAttributeNodeNS(newAttr) - * This function returns an object that implements - * the Attr interface. - * The newAttr parameter is an object that implements - * the Attr interface. - * This function can raise an object that implements - * the DOMException interface. - * getElementsByTagNameNS(namespaceURI, localName) - * This function returns an object that implements - * the NodeList interface. - * The namespaceURI parameter is a String. - * The localName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * hasAttribute(name) - * This function returns a Boolean. - * The name parameter is a String. - * hasAttributeNS(namespaceURI, localName) - * This function returns a Boolean. - * The namespaceURI parameter is a String. - * The localName parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * setIdAttribute(name, isId) - * This function has no return value. - * The name parameter is a String. - * The isId parameter is a Boolean. - * This function can raise an object that implements - * the DOMException interface. - * setIdAttributeNS(namespaceURI, localName, isId) - * This function has no return value. - * The namespaceURI parameter is a String. - * The localName parameter is a String. - * The isId parameter is a Boolean. - * This function can raise an object that implements - * the DOMException interface. - * setIdAttributeNode(idAttr, isId) - * This function has no return value. - * The idAttr parameter is an object that implements - * the Attr interface. - * The isId parameter is a Boolean. - * This function can raise an object that implements - * the DOMException interface. - */ - -class ECMA_Element -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - Element *p = new ElementImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - Element *p = (Element *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - //############################ - //# M E T H O D S - //############################ - - /** - * - */ - static JSBool getAttribute(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool setAttribute(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool removeAttribute(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getAttributeNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool setAttributeNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool removeAttributeNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getElementsByTagName(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getAttributeNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool setAttributeNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool removeAttributeNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getAttributeNodeNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool setAttributeNodeNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getElementsByTagNameNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool hasAttribute(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool hasAttributeNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool setIdAttribute(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool setIdAttributeNS(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool setIdAttributeNode(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_tagName, - prop_schemaTypeInfo - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_Element::classDef = -{ - "Element", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_Element::properties[] = -{ - { "tagName", prop_tagName, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "schemaTypeInfo", prop_schemaTypeInfo, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_Element::methods[] = -{ - { "getAttribute", getAttribute, 1, 0, 0 }, - { "setAttribute", setAttribute, 2, 0, 0 }, - { "removeAttribute", removeAttribute, 1, 0, 0 }, - { "getAttributeNode", getAttributeNode, 1, 0, 0 }, - { "setAttributeNode", setAttributeNode, 1, 0, 0 }, - { "removeAttributeNode", removeAttributeNode, 1, 0, 0 }, - { "getElementsByTagName", getElementsByTagName, 1, 0, 0 }, - { "getAttributeNS", getAttributeNS, 2, 0, 0 }, - { "setAttributeNS", setAttributeNS, 3, 0, 0 }, - { "removeAttributeNS", removeAttributeNS, 2, 0, 0 }, - { "getAttributeNodeNS", getAttributeNodeNS, 2, 0, 0 }, - { "setAttributeNodeNS", setAttributeNodeNS, 1, 0, 0 }, - { "getElementsByTagNameNS", getElementsByTagNameNS, 2, 0, 0 }, - { "hasAttribute", hasAttribute, 1, 0, 0 }, - { "hasAttributeNS", hasAttributeNS, 2, 0, 0 }, - { "setIdAttribute", setIdAttribute, 2, 0, 0 }, - { "setIdAttributeNS", setIdAttributeNS, 3, 0, 0 }, - { "setIdAttributeNode", setIdAttributeNode, 2, 0, 0 }, - { 0 } -}; - - - - - -//######################################################################## -//# Text -//######################################################################## - -/** - * Objects that implement the Text interface: - * - * Objects that implement the Text interface have all properties - * and functions of the CharacterData interface as well as - * the properties and functions defined below. Properties of objects - * that implement the Text interface: - * - * - * isElementContentWhitespace - * This read-only property is a Boolean. - * wholeText - * This read-only property is a String. - * - * Functions of objects that implement the Text interface: - * - * splitText(offset) - * This function returns an object that implements - * the Text interface. - * The offset parameter is a Number. - * This function can raise an object that implements - * the DOMException interface. - * replaceWholeText(content) - * This function returns an object that implements - * the Text interface. - * The content parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - */ - -class ECMA_Text -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - Text *p = new TextImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - Text *p = (Text *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - //############################ - //# M E T H O D S - //############################ - - /** - * - */ - static JSBool splitText(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool replaceWholeText(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_isElementContentWhitespace, - prop_wholeText - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_Text::classDef = -{ - "Text", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_Text::properties[] = -{ - { "isElementContentWhitespace", prop_isElementContentWhitespace, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "wholeText", prop_wholeText, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_Text::methods[] = -{ - { "splitText", splitText, 1, 0, 0 }, - { "replaceWholeText", replaceWholeText, 1, 0, 0 }, - { 0 } -}; - - - - - - -//######################################################################## -//# Comment -//######################################################################## - -/** - * Objects that implement the Comment interface: - * - * Objects that implement the Comment interface have all properties - * and functions of the CharacterData interface. - * - */ - -class ECMA_Comment -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - Comment *p = new CommentImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - Comment *p = (Comment *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_Comment::classDef = -{ - "Comment", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_Comment::properties[] = -{ - { 0 } -}; - -JSFunctionSpec ECMA_Comment::methods[] = -{ - { 0 } -}; - - - - - -//######################################################################## -//# TypeInfo -//######################################################################## - -/** - * Properties of the TypeInfo Constructor function: - * - * TypeInfo.DERIVATION_RESTRICTION - * The value of the constant TypeInfo.DERIVATION_RESTRICTION - * is 0x00000001. - * TypeInfo.DERIVATION_EXTENSION - * The value of the constant TypeInfo.DERIVATION_EXTENSION - * is 0x00000002. - * TypeInfo.DERIVATION_UNION - * The value of the constant TypeInfo.DERIVATION_UNION - * is 0x00000004. - * TypeInfo.DERIVATION_LIST - * The value of the constant TypeInfo.DERIVATION_LIST - * is 0x00000008. - * - * Objects that implement the TypeInfo interface: - * - * Properties of objects that implement the TypeInfo interface: - * - * typeName - * This read-only property is a String. - * typeNamespace - * This read-only property is a String. - * - * Functions of objects that implement the TypeInfo interface: - * - * isDerivedFrom(typeNamespaceArg, typeNameArg, derivationMethod) - * This function returns a Boolean. - * The typeNamespaceArg parameter is a String. - * The typeNameArg parameter is a String. - * The derivationMethod parameter is a Number. - */ - -class ECMA_TypeInfo -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - //TypeInfo *p = new TypeInfoImpl(); - //if ( ! JS_SetPrivate(cx, obj, p) ) - // return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - staticProperties, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - TypeInfo *p = (TypeInfo *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - //############################ - //# M E T H O D S - //############################ - - /** - * - */ - static JSBool isDerivedFrom(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_typeName, - prop_typeNamespace - }; - static JSFunctionSpec methods[]; - static JSPropertySpec staticProperties[]; - -}; - -JSClass ECMA_TypeInfo::classDef = -{ - "TypeInfo", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_TypeInfo::properties[] = -{ - { "typeName", prop_typeName, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "typeNamespace", prop_typeNamespace, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_TypeInfo::methods[] = -{ - { "isDerivedFrom", isDerivedFrom, 3, 0, 0 }, - { 0 } -}; - -JSPropertySpec ECMA_TypeInfo::staticProperties[] = -{ - { "DERIVATION_RESTRICTION", TypeInfo::DERIVATION_RESTRICTION, - JSPROP_READONLY, JSGetEnumProperty }, - { "DERIVATION_EXTENSION", TypeInfo::DERIVATION_EXTENSION, - JSPROP_READONLY, JSGetEnumProperty }, - { "DERIVATION_UNION", TypeInfo::DERIVATION_UNION, - JSPROP_READONLY, JSGetEnumProperty }, - { "DERIVATION_LIST", TypeInfo::DERIVATION_LIST, - JSPROP_READONLY, JSGetEnumProperty }, - { 0 } -}; - - - - - - -//######################################################################## -//# UserDataHandler -//######################################################################## - -/** - * Properties of the UserDataHandler Constructor function: - * - * UserDataHandler.NODE_CLONED - * The value of the constant UserDataHandler.NODE_CLONED is 1. - * UserDataHandler.NODE_IMPORTED - * The value of the constant UserDataHandler.NODE_IMPORTED is 2. - * UserDataHandler.NODE_DELETED - * The value of the constant UserDataHandler.NODE_DELETED is 3. - * UserDataHandler.NODE_RENAMED - * The value of the constant UserDataHandler.NODE_RENAMED is 4. - * UserDataHandler.NODE_ADOPTED - * The value of the constant UserDataHandler.NODE_ADOPTED is 5. - * - * UserDataHandler function: - * This function has no return value. - * The first parameter is a Number. - * The second parameter is a String. - * The third parameter is an object that implements the any - * type interface. - * The fourth parameter is an object that implements the Node - * interface. - * The fifth parameter is an object that implements the Node interface. - * Properties of the DOMError Constructor function: - * - * - * DOMError.SEVERITY_WARNING - * The value of the constant DOMError.SEVERITY_WARNING is 1. - * DOMError.SEVERITY_ERROR - * The value of the constant DOMError.SEVERITY_ERROR is 2. - * DOMError.SEVERITY_FATAL_ERROR - * The value of the constant DOMError.SEVERITY_FATAL_ERROR is 3. - */ - - -class ECMA_UserDataHandler -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - //UserDataHandler *p = new UserDataHandlerImpl(); - //if ( ! JS_SetPrivate(cx, obj, p) ) - // return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - staticProperties, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - UserDataHandler *p = (UserDataHandler *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - static JSPropertySpec staticProperties[]; - -}; - -JSClass ECMA_UserDataHandler::classDef = -{ - "UserDataHandler", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_UserDataHandler::properties[] = -{ - { 0 } -}; - -JSFunctionSpec ECMA_UserDataHandler::methods[] = -{ - { 0 } -}; - - -JSPropertySpec ECMA_UserDataHandler::staticProperties[] = -{ - { "NODE_CLONED", UserDataHandler::NODE_CLONED, - JSPROP_READONLY, JSGetEnumProperty }, - { "NODE_IMPORTED", UserDataHandler::NODE_IMPORTED, - JSPROP_READONLY, JSGetEnumProperty }, - { "NODE_DELETED", UserDataHandler::NODE_DELETED, - JSPROP_READONLY, JSGetEnumProperty }, - { "NODE_RENAMED", UserDataHandler::NODE_RENAMED, - JSPROP_READONLY, JSGetEnumProperty }, - { "NODE_ADOPTED", UserDataHandler::NODE_ADOPTED, - JSPROP_READONLY, JSGetEnumProperty }, - { 0 } -}; - - - - - -//######################################################################## -//# DOMError -//######################################################################## - -/** - * Objects that implement the DOMError interface: - * - * Properties of objects that implement the DOMError interface: - * - * severity - * This read-only property is a Number. - * message - * This read-only property is a String. - * type - * This read-only property is a String. - * relatedException - * This read-only property is an object that implements - * the Object interface. - * relatedData - * This read-only property is an object that implements - * the Object interface. - * location - * This read-only property is an object that implements - * the DOMLocator interface. - * - * DOMErrorHandler function: - * This function returns a Boolean. - * The parameter is an object that implements the - * DOMError interface. - * - * - */ - -class ECMA_DOMError -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - //DOMError *p = new DOMErrorImpl(); - //if ( ! JS_SetPrivate(cx, obj, p) ) - // return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - staticProperties, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - DOMError *p = (DOMError *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - enum - { - prop_severity, - prop_message, - prop_type, - prop_relatedException, - prop_relatedData, - prop_location - }; - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - static JSPropertySpec staticProperties[]; - -}; - -JSClass ECMA_DOMError::classDef = -{ - "DOMError", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DOMError::properties[] = -{ - { "severity", prop_severity, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "message", prop_message, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "type", prop_type, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "relatedException", prop_relatedException, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "relatedData", prop_relatedData, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "location", prop_location, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_DOMError::methods[] = -{ - { 0 } -}; - - -JSPropertySpec ECMA_DOMError::staticProperties[] = -{ - { "SEVERITY_WARNING", DOMError::SEVERITY_WARNING, - JSPROP_READONLY, JSGetEnumProperty }, - { "SEVERITY_ERROR", DOMError::SEVERITY_ERROR, - JSPROP_READONLY, JSGetEnumProperty }, - { "SEVERITY_FATAL_ERROR", DOMError::SEVERITY_FATAL_ERROR, - JSPROP_READONLY, JSGetEnumProperty }, - { 0 } -}; - - - - - -//######################################################################## -//# DOMLocator -//######################################################################## - -/** - * Objects that implement the DOMLocator interface: - * - * Properties of objects that implement the DOMLocator interface: - * - * lineNumber - * This read-only property is a Number. - * columnNumber - * This read-only property is a Number. - * byteOffset - * This read-only property is a Number. - * utf16Offset - * This read-only property is a Number. - * relatedNode - * This read-only property is an object that implements - * the Node interface. - * uri - * This read-only property is a String. - */ - -class ECMA_DOMLocator -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - DOMLocator *p = new DOMLocatorImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - DOMLocator *p = (DOMLocator *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - enum - { - prop_lineNumber, - prop_columnNumber, - prop_byteOffset, - prop_utf16Offset, - prop_relatedNode, - prop_uri, - }; - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_DOMLocator::classDef = -{ - "DOMLocator", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DOMLocator::properties[] = -{ - { "lineNumber", prop_lineNumber, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "columnNumber", prop_columnNumber, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "byteOffset", prop_byteOffset, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "utf16Offset", prop_utf16Offset, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "relatedNode", prop_relatedNode, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { "uri", prop_uri, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_DOMLocator::methods[] = -{ - { 0 } -}; - - - - - -//######################################################################## -//# DOMConfiguration -//######################################################################## - -/** - * Objects that implement the DOMConfiguration interface: - * - * Properties of objects that implement the DOMConfiguration interface: - * - * parameterNames - * This read-only property is an object that implements - * the DOMStringList interface. - * - * Functions of objects that implement the DOMConfiguration interface: - * - * setParameter(name, value) - * This function has no return value. - * The name parameter is a String. - * The value parameter is an object that implements - * the any type interface. - * This function can raise an object that implements - * the DOMException interface. - * getParameter(name) - * This function returns an object that implements - * the any type interface. - * The name parameter is a String. - * This function can raise an object that implements - * the DOMException interface. - * canSetParameter(name, value) - * This function returns a Boolean. - * The name parameter is a String. - * The value parameter is an object that implements - * the any type interface. - */ - - -class ECMA_DOMConfiguration -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - DOMConfiguration *p = new DOMConfigurationImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - DOMConfiguration *p = (DOMConfiguration *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - //############################ - //# M E T H O D S - //############################ - - /** - * - */ - static JSBool setParameter(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool getParameter(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - /** - * - */ - static JSBool canSetParameter(JSContext *cx, JSObject *obj, - uintN argc, jsval *argv, jsval *rval) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - enum - { - prop_parameterNames - }; - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_DOMConfiguration::classDef = -{ - "DOMConfiguration", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DOMConfiguration::properties[] = -{ - { "parameterNames", prop_parameterNames, - JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_DOMConfiguration::methods[] = -{ - { "setParameter", setParameter, 2, 0, 0 }, - { "getParameter", getParameter, 1, 0, 0 }, - { "canSetParameter", canSetParameter, 2, 0, 0 }, - { 0 } -}; - - - - - - -//######################################################################## -//# CDATASection -//######################################################################## - -/** - * Objects that implement the CDATASection interface: - * - * Objects that implement the CDATASection interface - * have all properties and functions of the Text interface. - * - */ - -class ECMA_CDATASection -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - CDATASection *p = new CDATASectionImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - CDATASection *p = (CDATASection *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_CDATASection::classDef = -{ - "CDATASection", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_CDATASection::properties[] = -{ - { 0 } -}; - -JSFunctionSpec ECMA_CDATASection::methods[] = -{ - { 0 } -}; - - - - - -//######################################################################## -//# DocumentType -//######################################################################## - -/** - * Objects that implement the DocumentType interface: - * - * Objects that implement the DocumentType interface have all - * properties and functions of the Node interface as well as - * the properties and functions defined below. - * Properties of objects that implement the DocumentType interface: - * - * - * name - * This read-only property is a String. - * entities - * This read-only property is an object that implements - * the NamedNodeMap interface. - * notations - * This read-only property is an object that implements - * the NamedNodeMap interface. - * publicId - * This read-only property is a String. - * systemId - * This read-only property is a String. - * internalSubset - * This read-only property is a String. - */ - - -class ECMA_DocumentType -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - DocumentType *p = new DocumentTypeImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - DocumentType *p = (DocumentType *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - enum - { - prop_name, - prop_entities, - prop_notations, - prop_systemId, - prop_publicId, - prop_internalSubset - }; - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_DocumentType::classDef = -{ - "DocumentType", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_DocumentType::properties[] = -{ - { "name", prop_name, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "entities", prop_entities, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "notations", prop_notations, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "systemId", prop_systemId, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "publicId", prop_publicId, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "internalSubset", prop_internalSubset, JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_DocumentType::methods[] = -{ - { 0 } -}; - - - - - -//######################################################################## -//# Notation -//######################################################################## - -/** - * Objects that implement the Notation interface: - * - * Objects that implement the Notation interface have all - * properties and functions of the Node interface as well as - * the properties and functions defined below. - * Properties of objects that implement the Notation interface: - * - * - * publicId - * This read-only property is a String. - * systemId - * This read-only property is a String. - */ - -class ECMA_Notation -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - Notation *p = new NotationImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - Notation *p = (Notation *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - enum - { - prop_publicId, - prop_systemId - }; - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_Notation::classDef = -{ - "Notation", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_Notation::properties[] = -{ - { "publicId", prop_publicId, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "systemId", prop_systemId, JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_Notation::methods[] = -{ - { 0 } -}; - - - - - -//######################################################################## -//# Entity -//######################################################################## - -/** - * Objects that implement the Entity interface: - * - * Objects that implement the Entity interface have all properties - * and functions of the Node interface as well as the properties - * and functions defined below. - * Properties of objects that implement the Entity interface: - * - * - * publicId - * This read-only property is a String. - * systemId - * This read-only property is a String. - * notationName - * This read-only property is a String. - * inputEncoding - * This read-only property is a String. - * xmlEncoding - * This read-only property is a String. - * xmlVersion - * This read-only property is a String. - */ - -class ECMA_Entity -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - Entity *p = new EntityImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - Entity *p = (Entity *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - enum - { - prop_publicId, - prop_systemId, - prop_notationName, - prop_inputEncoding, - prop_xmlEncoding, - prop_xmlVersion - }; - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_Entity::classDef = -{ - "Entity", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_Entity::properties[] = -{ - { "publicId", prop_publicId, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "systemId", prop_systemId, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "notationName", prop_notationName, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "inputEncoding", prop_inputEncoding, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "xmlEncoding", prop_xmlEncoding, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "xmlVersion", prop_xmlVersion, JSPROP_ENUMERATE|JSPROP_READONLY }, - { 0 } -}; - -JSFunctionSpec ECMA_Entity::methods[] = -{ - { 0 } -}; - - - - -//######################################################################## -//# EntityReference -//######################################################################## - -/** - * Objects that implement the EntityReference interface: - * - * Objects that implement the EntityReference interface have all - * properties and functions of the Node interface. - * - */ - - -class ECMA_EntityReference -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - EntityReference *p = new EntityReferenceImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - EntityReference *p = (EntityReference *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_EntityReference::classDef = -{ - "EntityReference", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_EntityReference::properties[] = -{ - { 0 } -}; - -JSFunctionSpec ECMA_EntityReference::methods[] = -{ - { 0 } -}; - - - - - -//######################################################################## -//# ProcessingInstruction -//######################################################################## - -/** - * Objects that implement the ProcessingInstruction interface: - * - * Objects that implement the ProcessingInstruction interface - * have all properties and functions of the Node interface - * as well as the properties and functions defined below. - * Properties of objects that implement the ProcessingInstruction - * interface: - * - * target - * This read-only property is a String. - * data - * This property is a String and can raise an object - * that implements the DOMException interface on setting. - * - */ - - -class ECMA_ProcessingInstruction -{ -public: - - /** - * JSConstructor - Callback for when a this object is created - */ - static JSBool JSConstructor(JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) - { - if (argc != 1) - return JS_FALSE; - ProcessingInstruction *p = new ProcessingInstructionImpl(); - if ( ! JS_SetPrivate(cx, obj, p) ) - return JS_FALSE; - *rval = OBJECT_TO_JSVAL(obj); - return JS_TRUE; - } - - /** - * JSInit - Create a prototype for this class - */ - static JSObject* JSInit(JSContext *cx, JSObject *obj, JSObject *proto = NULL) - { - JSObject *newObj = JS_InitClass(cx, obj, proto, &classDef, - JSConstructor, 0, - properties, methods, - NULL, NULL); - return newObj; - } - - /** - * JSDestructor - Callback for when a this object is destroyed - */ - static void JSDestructor(JSContext *cx, JSObject *obj) - { - ProcessingInstruction *p = (ProcessingInstruction *) JS_GetPrivate(cx, obj); - delete p; - } - - /** - * JSGetProperty - Callback for retrieving properties - */ - static JSBool JSGetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - /** - * JSSetProperty - Callback for setting properties - */ - static JSBool JSSetProperty(JSContext *cx, JSObject *obj, - jsval id, jsval *vp) - { - return JS_FALSE; - } - - - static JSClass classDef; - -private: - - // Standard JS Binding fields - static JSPropertySpec properties[]; - enum - { - prop_target, - prop_data - }; - static JSFunctionSpec methods[]; - -}; - -JSClass ECMA_ProcessingInstruction::classDef = -{ - "ProcessingInstruction", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, - JSGetProperty, JSSetProperty, - JS_EnumerateStub, JS_ResolveStub, - JS_ConvertStub, JSDestructor -}; - - - -JSPropertySpec ECMA_ProcessingInstruction::properties[] = -{ - { "target", prop_target, JSPROP_ENUMERATE|JSPROP_READONLY }, - { "data", prop_data, JSPROP_ENUMERATE }, - { 0 } -}; - -JSFunctionSpec ECMA_ProcessingInstruction::methods[] = -{ - { 0 } -}; - - - -/** - * Note: In addition of having DOMConfiguration parameters - * exposed to the application using the setParameter - * and getParameter, those parameters are also exposed - * as ECMAScript properties on the DOMConfiguration object. - * The name of the parameter is converted into a property name - * using a camel-case convention: - * the character '-' (HYPHEN-MINUS) is removed - * and the following character is - * being replaced by its uppercase equivalent. - */ - - - - - -//######################################################################## -//# M A I N B I N D I N G -//######################################################################## - -bool JavascriptEngine::createClasses() -{ - proto_Node = - ECMA_Node::JSInit(cx, globalObj); - proto_CharacterData = - ECMA_CharacterData::JSInit(cx, globalObj, proto_Node); - proto_Text = - ECMA_Text::JSInit(cx, globalObj, proto_CharacterData); - proto_CDATASection = - ECMA_CDATASection::JSInit(cx, globalObj, proto_Text); - proto_Document = - ECMA_Document::JSInit(cx, globalObj, proto_CDATASection); - return true; -} - - -JSObject *JavascriptEngine::wrapDocument(const Document *doc) -{ - if (!doc) - { - error("wrapDocument: null document parameter"); - return NULL; - } - - JSObject *jsdoc = JS_NewObject(cx, &ECMA_Document::classDef, - proto_Document, NULL); - - //Wrap around the document... done! - JS_SetPrivate(cx, jsdoc, (void *)doc); - - return jsdoc; -} - -JSObject *JavascriptEngine::new_Attr(Attr *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_Attr::classDef, - proto_Attr, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_CDATASection(CDATASection *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_CDATASection::classDef, - proto_CDATASection, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_CharacterData(CharacterData *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_CharacterData::classDef, - proto_CharacterData, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_Comment(Comment *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_Comment::classDef, - proto_Comment, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_Document(Document *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_Document::classDef, - proto_Document, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DocumentFragment(DocumentFragment *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DocumentFragment::classDef, - proto_DocumentFragment, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DocumentType(DocumentType *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DocumentType::classDef, - proto_DocumentType, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DOMConfiguration(DOMConfiguration *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DOMConfiguration::classDef, - proto_DOMConfiguration, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DOMError(DOMError *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DOMError::classDef, - proto_DOMError, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DOMException(DOMException *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DOMException::classDef, - proto_DOMException, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DOMImplementation(DOMImplementation *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DOMImplementation::classDef, - proto_DOMImplementation, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DOMImplementationList(DOMImplementationList *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DOMImplementationList::classDef, - proto_DOMImplementationList, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DOMImplementationRegistry(DOMImplementationSource *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DOMImplementationRegistry::classDef, - proto_DOMImplementationRegistry, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DOMImplementationSource(DOMImplementationSource *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DOMImplementationSource::classDef, - proto_DOMImplementationSource, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DOMLocator(DOMLocator *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DOMLocator::classDef, - proto_DOMLocator, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_DOMStringList(DOMStringList *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_DOMStringList::classDef, - proto_DOMStringList, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_Element(Element *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_Element::classDef, - proto_Element, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_Entity(Entity *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_Entity::classDef, - proto_Entity, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_EntityReference(EntityReference *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_EntityReference::classDef, - proto_EntityReference, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_NamedNodeMap(NamedNodeMap *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_NamedNodeMap::classDef, - proto_NamedNodeMap, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_NameList(NameList *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_NameList::classDef, - proto_NameList, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_Node(Node *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_Node::classDef, - proto_Node, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_NodeList(NodeList *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_NodeList::classDef, - proto_NodeList, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_Notation(Notation *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_Notation::classDef, - proto_Notation, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_ProcessingInstruction(ProcessingInstruction *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_ProcessingInstruction::classDef, - proto_ProcessingInstruction, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_Text(Text *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_Text::classDef, - proto_Text, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_TypeInfo(TypeInfo *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_TypeInfo::classDef, - proto_TypeInfo, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - -JSObject *JavascriptEngine::new_UserDataHandler(UserDataHandler *obj) -{ - JSObject *newObj = JS_NewObject(cx, - &ECMA_UserDataHandler::classDef, - proto_UserDataHandler, - NULL); - JS_SetPrivate(cx, newObj, obj); - return newObj; -} - - - - -} // namespace dom -} // namespace w3c -} // namespace org - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/dom/jsdombind.cpp b/src/dom/jsdombind.cpp new file mode 100644 index 000000000..d38722636 --- /dev/null +++ b/src/dom/jsdombind.cpp @@ -0,0 +1,3959 @@ + /** + * Phoebe DOM Implementation. + * + * This is a C++ approximation of the W3C DOM model, which follows + * fairly closely the specifications in the various .idl files, copies of + * which are provided for reference. Most important is this one: + * + * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html + * + * Authors: + * Bob Jamison + * + * Copyright (C) 2006 Bob Jamison + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +/** + * This code provides the ECMAScript (Javascript) binding to the classes + * of the DOM Level 3 Core. This should provide DOM manipulation for + * most general-purpose XML and Document-like applications. More specialized + * applications like SVG should inherit from the core C++ classes, and also + * use the prototypes in this file as the basis for their bindings. + * + * To ensure that we at least attempt to bind ECMAScript to DOM + * as closely as possible to the standards, we will include the entire + * Appendix H of the XML Level 3 Core spec as annotations in this file. + * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/ecma-script-binding.html + */ + + + + #include "domimpl.h" + #include "jsdombind.h" + + #include + + + namespace org + { + namespace w3c + { + namespace dom + { + + +//######################################################################## +//# M E S S A G E S +//######################################################################## +void JavascriptDOMBinder::error(char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + fprintf(stderr, "JS error: "); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); + va_end(args); +} + + +void JavascriptDOMBinder::trace(char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + fprintf(stdout, "JS: "); + vfprintf(stdout, fmt, args); + fprintf(stdout, "\n"); + va_end(args); +} + + + +//######################################################################## +//# U T I L I T Y +//######################################################################## + +//Use this for getting the JavascriptEngine from an object method +#define BINDER ((JavascriptDOMBinder *) JS_GetContextPrivate(cx)) + +#define NewObjectVal (CLASSNAME) \ + OBJECT_TO_JSVAL( JS_NewObject(cx, \ + &wrapperClassDef, \ + (JavascriptDOMBinder *) JS_GetContextPrivate(cx)->proto_## CLASSNAME, \ + (void *) priv) ); + +#define NewObjectPtrVal (CLASSNAME) \ + OBJECT_TO_JSVAL( JS_NewObject(cx, \ + &wrapperClassDef, \ + (JavascriptDOMBinder *) JS_GetContextPrivate(cx)->proto_## CLASSNAME, \ + (void *) new ## CLASSNAME ## Ptr (priv) )); + +/** + * The name of the property is an enumeration, so just return the value. + */ +static JSBool GetEnumProperty(JSContext *cx, JSObject *obj, + jsval id, jsval *vp) +{ + *vp = id; + return JS_TRUE; +} + + +static JSString *domToJString(JSContext *cx, const DOMString &s) +{ + JSString *str = JS_NewStringCopyN(cx, s.c_str(), s.size()); + return str; +} + +static DOMString jvToDomString(JSContext *cx, jsval s) +{ + JSString *jstr = JS_ValueToString(cx, s); + DOMString str = JS_GetStringBytes(jstr); + return str; +} + +static DOMString jToDomString(JSString *s) +{ + DOMString str = JS_GetStringBytes(s); + return str; +} + + +//######################################################################## +//# C L A S S E S +//######################################################################## + + +/** + * Appendix H: ECMAScript Language Binding + * + * This appendix contains the complete ECMAScript [ECMAScript] binding for the + * Level 3 Document Object Model Core definitions. H.1 ECMAScript Binding + * Extension + * + */ + +class Wrapper +{ +public: + + Wrapper(JSContext *context, JSObject *object) + { cx = context; obj = object; } + + virtual ~Wrapper() + {} + + virtual JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + virtual JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + virtual JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + +protected: + + JSContext *cx; + + JSObject *obj; + +}; + +/** + * WrapperProperty - Callback for retrieving properties + */ +static JSBool wrapperGetProperty(JSContext *cx, JSObject *obj, + jsval id, jsval *vp) +{ + Wrapper *w = (Wrapper *) JS_GetPrivate(cx, obj); + return w->getProperty(id, vp); +} + +/** + * JSSetProperty - Callback for setting properties + */ +static JSBool wrapperSetProperty(JSContext *cx, JSObject *obj, + jsval id, jsval *vp) +{ + Wrapper *w = (Wrapper *) JS_GetPrivate(cx, obj); + return w->setProperty(id, vp); +} + +/** + * JSConstructor - Callback for when a this object is created + */ +static JSBool wrapperConstructor(JSContext *cx, JSObject *obj, uintN argc, + jsval *argv, jsval *rval) +{ + Wrapper *w = new Wrapper(cx, obj); + JSBool ret = w->init(argc, argv); + *rval = OBJECT_TO_JSVAL(obj); + return ret; +} + +/** + * JSDestructor - Callback for when a this object is destroyed + */ +static void wrapperDestructor(JSContext *cx, JSObject *obj) +{ + Wrapper *w = (Wrapper *) JS_GetPrivate(cx, obj); + delete w; +} + +static JSClass wrapperClassDef = +{ + "DOMWrapper", + JSCLASS_HAS_PRIVATE, + JS_PropertyStub, JS_PropertyStub, + wrapperGetProperty, wrapperSetProperty, + JS_EnumerateStub, JS_ResolveStub, + JS_ConvertStub, wrapperDestructor +}; + + +/** + * JSInit - Create a prototype for this class + */ +static JSObject* wrapperInit(JSContext *cx, JSObject *obj, + JSNative constructor, + JSPropertySpec *properties, + JSFunctionSpec *methods, + JSPropertySpec *staticProperties, + JSFunctionSpec *staticMethods, + JSObject *proto = NULL) +{ + JSObject *protoObj = JS_InitClass(cx, obj, proto, + &wrapperClassDef, + wrapperConstructor, 0, + properties, + methods, + staticProperties, + staticMethods); + return protoObj; +} + +#define WRAP_NAME(NAME) NAME ## _wrapper +#define CLASS_NAME(NAME) WRAP_NAME(NAME) + +#define CONST_NAME(NAME) NAME ## _constructor +#define CONSTRUCTOR_NAME(NAME) CONST_NAME(NAME) + +#define PT_NAME(NAME) NAME ## _properties +#define PROPERTY_TABLE(NAME) PT_NAME(NAME) + +#define M_NAME(NAME) NAME ## _method +#define METHOD_NAME(NAME) M_NAME(NAME) +#define MT_NAME(NAME) NAME ## _methods +#define METHOD_TABLE(NAME) MT_NAME(NAME) + +#define SPT_NAME(NAME) NAME ## _staticProperties +#define STATIC_PROPERTY_TABLE(NAME) SPT_NAME(NAME) + +#define SMT_NAME(NAME) NAME ## _staticMethods +#define STATIC_METHOD_TABLE(NAME) SMT_NAME(NAME) + +#define METHOD(NAME) \ +static JSBool NAME(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) \ +{ return ((CLASS_NAME(CURRENT_CLASS) *) JS_GetPrivate(cx, obj))->METHOD_NAME(NAME)(argc, argv, rval); } \ + JSBool METHOD_NAME(NAME)(uintN argc, jsval *argv, jsval *rval) + +#define CONSTRUCTOR(NAME) \ +static JSBool CONSTRUCTOR_NAME(NAME)(JSContext *cx, \ + JSObject *obj, uintN argc, \ + jsval *argv, jsval *rval) \ +{ \ + CLASS_NAME(NAME) *w = new CLASS_NAME(NAME)(cx, obj); \ + JSBool ret = w->init(argc, argv); \ + *rval = OBJECT_TO_JSVAL(obj); \ + return ret; \ +} + +#define CREATE_PROTO(NAME, cx, obj, proto) \ + JS_InitClass(cx, obj, proto, &wrapperClassDef, \ + CONSTRUCTOR_NAME(NAME), 0, \ + PROPERTY_TABLE(NAME), \ + METHOD_TABLE(NAME), \ + STATIC_PROPERTY_TABLE(NAME), \ + STATIC_METHOD_TABLE(NAME)); + +//######################################################################## +//# DOMImplementationRegistry +//######################################################################## + +/** + * This section defines the DOMImplementationRegistry object, discussed in + * Bootstrapping, for ECMAScript. + * + * + * Objects that implements the DOMImplementationRegistry interface + * + * DOMImplementationRegistry is a global variable which has the following + * functions: + * + * getDOMImplementation(features) + * This method returns the first registered object that implements + * the DOMImplementation interface and has the desired features, + * or null if none is found. The features parameter is a String. + * See also DOMImplementationSource.getDOMImplementation(). + * + * getDOMImplementationList(features) + * This method returns a DOMImplementationList list of registered + * object that implements the DOMImplementation interface and + * has the desired features. The features parameter is a String. + * See also DOMImplementationSource.getDOMImplementationList(). + * + * + */ +#define CURRENT_CLASS DOMImplementationRegistry + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { "getDOMImplementation", + CLASS_NAME(CURRENT_CLASS)::getDOMImplementation, 1, 0, 0 }, + { "getDOMImplementationList", + CLASS_NAME(CURRENT_CLASS)::getDOMImplementationList, 1, 0, 0 }, + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + +/** + * H.2 Other Core interfaces + */ + + + + +//######################################################################## +//# DOMException +//######################################################################## + +/** + * Properties of the DOMException Constructor function: + * + * DOMException.INDEX_SIZE_ERR + * The value of the constant DOMException.INDEX_SIZE_ERR is 1. + * DOMException.DOMSTRING_SIZE_ERR + * The value of the constant DOMException.DOMSTRING_SIZE_ERR is 2. + * DOMException.HIERARCHY_REQUEST_ERR + * The value of the constant DOMException.HIERARCHY_REQUEST_ERR is 3. + * DOMException.WRONG_DOCUMENT_ERR + * The value of the constant DOMException.WRONG_DOCUMENT_ERR is 4. + * DOMException.INVALID_CHARACTER_ERR + * The value of the constant DOMException.INVALID_CHARACTER_ERR is 5. + * DOMException.NO_DATA_ALLOWED_ERR + * The value of the constant DOMException.NO_DATA_ALLOWED_ERR is 6. + * DOMException.NO_MODIFICATION_ALLOWED_ERR + * The value of the constant DOMException.NO_MODIFICATION_ALLOWED_ERR is 7. + * DOMException.NOT_FOUND_ERR + * The value of the constant DOMException.NOT_FOUND_ERR is 8. + * DOMException.NOT_SUPPORTED_ERR + * The value of the constant DOMException.NOT_SUPPORTED_ERR is 9. + * DOMException.INUSE_ATTRIBUTE_ERR + * The value of the constant DOMException.INUSE_ATTRIBUTE_ERR is 10. + * DOMException.INVALID_STATE_ERR + * The value of the constant DOMException.INVALID_STATE_ERR is 11. + * DOMException.SYNTAX_ERR + * The value of the constant DOMException.SYNTAX_ERR is 12. + * DOMException.INVALID_MODIFICATION_ERR + * The value of the constant DOMException.INVALID_MODIFICATION_ERR is 13. + * DOMException.NAMESPACE_ERR + * The value of the constant DOMException.NAMESPACE_ERR is 14. + * DOMException.INVALID_ACCESS_ERR + * The value of the constant DOMException.INVALID_ACCESS_ERR is 15. + * DOMException.VALIDATION_ERR + * The value of the constant DOMException.VALIDATION_ERR is 16. + * DOMException.TYPE_MISMATCH_ERR + * The value of the constant DOMException.TYPE_MISMATCH_ERR is 17. + * + * Objects that implement the DOMException interface: + * + * Properties of objects that implement the DOMException interface: + * + * code + * This property is a Number. + * + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS DOMException + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { "code", CLASS_NAME(CURRENT_CLASS)::prop_code, JSPROP_ENUMERATE }, + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { "INDEX_SIZE_ERR", DOMException::INDEX_SIZE_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "DOMSTRING_SIZE_ERR", DOMException::DOMSTRING_SIZE_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "HIERARCHY_REQUEST_ERR", DOMException::HIERARCHY_REQUEST_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "WRONG_DOCUMENT_ERR", DOMException::WRONG_DOCUMENT_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "INVALID_CHARACTER_ERR", DOMException::INVALID_CHARACTER_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "NO_DATA_ALLOWED_ERR", DOMException::NO_DATA_ALLOWED_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "NO_MODIFICATION_ALLOWED_ERR", DOMException::NO_MODIFICATION_ALLOWED_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "NOT_FOUND_ERR", DOMException::NOT_FOUND_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "NOT_SUPPORTED_ERR", DOMException::NOT_SUPPORTED_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "INUSE_ATTRIBUTE_ERR", DOMException::INUSE_ATTRIBUTE_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "INVALID_STATE_ERR", DOMException::INVALID_STATE_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "SYNTAX_ERR", DOMException::SYNTAX_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "INVALID_MODIFICATION_ERR", DOMException::INVALID_MODIFICATION_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "NAMESPACE_ERR", DOMException::NAMESPACE_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "INVALID_ACCESS_ERR", DOMException::INVALID_ACCESS_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "VALIDATION_ERR", DOMException::VALIDATION_ERR, + JSPROP_READONLY, GetEnumProperty }, + { "TYPE_MISMATCH_ERR", DOMException::TYPE_MISMATCH_ERR, + JSPROP_READONLY, GetEnumProperty }, + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + +//######################################################################## +//# DOMStringList +//######################################################################## + +/** + * Objects that implement the DOMStringList interface: + * + * Properties of objects that implement the DOMStringList interface: + * + * length + * This read-only property is a Number. + * + * Functions of objects that implement the DOMStringList interface: + * + * item(index) + * This function returns a String. + * The index parameter is a Number. + * Note: This object can also be dereferenced using square bracket + * notation (e.g. obj[1]). Dereferencing with an integer index + * is equivalent to invoking the item function with that index. + * + * contains(str) + * This function returns a Boolean. + * The str parameter is a String. + * + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS DOMStringList + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + +//######################################################################## +//# NameList +//######################################################################## + +/** + * Objects that implement the NameList interface: + * + * Properties of objects that implement the NameList interface: + * + * length + * This read-only property is a Number. + * + * Functions of objects that implement the NameList interface: + * + * getName(index) + * This function returns a String. + * The index parameter is a Number. + * getNamespaceURI(index) + * This function returns a String. + * The index parameter is a Number. + * contains(str) + * This function returns a Boolean. + * The str parameter is a String. + * containsNS(namespaceURI, name) + * This function returns a Boolean. + * The namespaceURI parameter is a String. + * The name parameter is a String. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS NameList + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + +//######################################################################## +//# DOMImplementationList +//######################################################################## + +/** + * Objects that implement the DOMImplementationList interface: + * + * Properties of objects that implement the DOMImplementationList interface: + * + * length + * This read-only property is a Number. + * + * Functions of objects that implement the DOMImplementationList interface: + * + * item(index) + * This function returns an object that implements the + * DOMImplementation interface. + * The index parameter is a Number. + * Note: This object can also be dereferenced using square bracket + * notation (e.g. obj[1]). Dereferencing with an integer index + * is equivalent to invoking the item function with that index. + * + * + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS DOMImplementationList + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + +//######################################################################## +//# DOMImplementationSource +//######################################################################## + +/** + * Objects that implement the DOMImplementationSource interface: + * + * Functions of objects that implement the DOMImplementationSource interface: + * + * getDOMImplementation(features) + * This function returns an object that implements the + * DOMImplementation interface. + * The features parameter is a String. + * getDOMImplementationList(features) + * This function returns an object that implements the + * DOMImplementationList interface. + * The features parameter is a String. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS DOMImplementationSource + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + + +//######################################################################## +//# DOMImplementation +//######################################################################## + +/** + * Objects that implement the DOMImplementation interface: + * + * Functions of objects that implement the DOMImplementation interface: + * + * hasFeature(feature, version) + * This function returns a Boolean. + * The feature parameter is a String. + * The version parameter is a String. + * createDocumentType(qualifiedName, publicId, systemId) + * This function returns an object that implements the + * DocumentType interface. + * The qualifiedName parameter is a String. + * The publicId parameter is a String. + * The systemId parameter is a String. + * This function can raise an object that implements the + * DOMException interface. + * createDocument(namespaceURI, qualifiedName, doctype) + * This function returns an object that implements the + * Document interface. + * The namespaceURI parameter is a String. + * The qualifiedName parameter is a String. + * The doctype parameter is an object that implements the + * DocumentType interface. + * This function can raise an object that implements the + * DOMException interface. + * getFeature(feature, version) + * This function returns an object that implements + * the Object interface. + * The feature parameter is a String. + * The version parameter is a String. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS DOMImplementation + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + + + +//######################################################################## +//# DocumentFragment +//######################################################################## + +/** + * Objects that implement the DocumentFragment interface: + * + * Objects that implement the DocumentFragment interface have all + * properties and functions of the Node interface. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS DocumentFragment + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + +//######################################################################## +//# Document +//######################################################################## + +/** + * Objects that implement the Document interface: + * + * Objects that implement the Document interface have all properties + * and functions of the Node interface as well as the properties + * and functions defined below. + * Properties of objects that implement the Document interface: + * + * + * doctype + * This read-only property is an object that implements + * the DocumentType interface. + * implementation + * This read-only property is an object that implements + * the DOMImplementation interface. + * documentElement + * This read-only property is an object that implements + * the Element interface. + * inputEncoding + * This read-only property is a String. + * xmlEncoding + * This read-only property is a String. + * xmlStandalone + * This property is a Boolean and can raise an object + * that implements the DOMException interface on setting. + * xmlVersion + * This property is a String and can raise an object + * that implements the DOMException interface on setting. + * strictErrorChecking + * This property is a Boolean. + * documentURI + * This property is a String. + * domConfig + * This read-only property is an object that implements + * the DOMConfiguration interface. + * + * + * Functions of objects that implement the Document interface: + * + * createElement(tagName) + * This function returns an object that implements + * the Element interface. + * The tagName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * createDocumentFragment() + * This function returns an object that implements + * the DocumentFragment interface. + * createTextNode(data) + * This function returns an object that implements + * the Text interface. + * The data parameter is a String. + * createComment(data) + * This function returns an object that implements + * the Comment interface. + * The data parameter is a String. + * createCDATASection(data) + * This function returns an object that implements + * the CDATASection interface. + * The data parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * createProcessingInstruction(target, data) + * This function returns an object that implements + * the ProcessingInstruction interface. + * The target parameter is a String. + * The data parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * createAttribute(name) + * This function returns an object that implements + * the Attr interface. + * The name parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * createEntityReference(name) + * This function returns an object that implements + * the EntityReference interface. + * The name parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * getElementsByTagName(tagname) + * This function returns an object that implements + * the NodeList interface. + * The tagname parameter is a String. + * importNode(importedNode, deep) + * This function returns an object that implements + * the Node interface. + * The importedNode parameter is an object that implements + * the Node interface. + * The deep parameter is a Boolean. + * This function can raise an object that implements + * the DOMException interface. + * createElementNS(namespaceURI, qualifiedName) + * This function returns an object that implements + * the Element interface. + * The namespaceURI parameter is a String. + * The qualifiedName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * createAttributeNS(namespaceURI, qualifiedName) + * This function returns an object that implements + * the Attr interface. + * The namespaceURI parameter is a String. + * The qualifiedName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * getElementsByTagNameNS(namespaceURI, localName) + * This function returns an object that implements + * the NodeList interface. + * The namespaceURI parameter is a String. + * The localName parameter is a String. + * getElementById(elementId) + * This function returns an object that implements + * the Element interface. + * The elementId parameter is a String. + * adoptNode(source) + * This function returns an object that implements + * the Node interface. + * The source parameter is an object that implements + * the Node interface. + * This function can raise an object that implements + * the DOMException interface. + * normalizeDocument() + * This function has no return value. + * renameNode(n, namespaceURI, qualifiedName) + * This function returns an object that implements + * the Node interface. + * The n parameter is an object that implements + * the Node interface. + * The namespaceURI parameter is a String. + * The qualifiedName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS Document + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + + DocumentPtr doc; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + +//######################################################################## +//# Node +//######################################################################## + +/** + * Properties of the Node Constructor function: + * + * Node.ELEMENT_NODE + * The value of the constant Node.ELEMENT_NODE is 1. + * Node.ATTRIBUTE_NODE + * The value of the constant Node.ATTRIBUTE_NODE is 2. + * Node.TEXT_NODE + * The value of the constant Node.TEXT_NODE is 3. + * Node.CDATA_SECTION_NODE + * The value of the constant Node.CDATA_SECTION_NODE is 4. + * Node.ENTITY_REFERENCE_NODE + * The value of the constant Node.ENTITY_REFERENCE_NODE is 5. + * Node.ENTITY_NODE + * The value of the constant Node.ENTITY_NODE is 6. + * Node.PROCESSING_INSTRUCTION_NODE + * The value of the constant Node.PROCESSING_INSTRUCTION_NODE is 7. + * Node.COMMENT_NODE + * The value of the constant Node.COMMENT_NODE is 8. + * Node.DOCUMENT_NODE + * The value of the constant Node.DOCUMENT_NODE is 9. + * Node.DOCUMENT_TYPE_NODE + * The value of the constant Node.DOCUMENT_TYPE_NODE is 10. + * Node.DOCUMENT_FRAGMENT_NODE + * The value of the constant Node.DOCUMENT_FRAGMENT_NODE is 11. + * Node.NOTATION_NODE + * The value of the constant Node.NOTATION_NODE is 12. + * Node.DOCUMENT_POSITION_DISCONNECTED + * The value of the constant Node.DOCUMENT_POSITION_DISCONNECTED + * is 0x01. + * Node.DOCUMENT_POSITION_PRECEDING + * The value of the constant Node.DOCUMENT_POSITION_PRECEDING + * is 0x02. + * Node.DOCUMENT_POSITION_FOLLOWING + * The value of the constant Node.DOCUMENT_POSITION_FOLLOWING + * is 0x04. + * Node.DOCUMENT_POSITION_CONTAINS + * The value of the constant Node.DOCUMENT_POSITION_CONTAINS + * is 0x08. + * Node.DOCUMENT_POSITION_CONTAINED_BY + * The value of the constant Node.DOCUMENT_POSITION_CONTAINED_BY + * is 0x10. + * Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + * The value of the constant Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + * is 0x20. + * + * Objects that implement the Node interface: + * + * Properties of objects that implement the Node interface: + * + * nodeName + * This read-only property is a String. + * nodeValue + * This property is a String, can raise an object that implements + * the DOMException + * interface on setting and can raise an object that implements + * the DOMException + * interface on retrieval. + * nodeType + * This read-only property is a Number. + * parentNode + * This read-only property is an object that implements + * the Node interface. + * childNodes + * This read-only property is an object that implements + * the NodeList interface. + * firstChild + * This read-only property is an object that implements + * the Node interface. + * lastChild + * This read-only property is an object that implements + * the Node interface. + * previousSibling + * This read-only property is an object that implements + * the Node interface. + * nextSibling + * This read-only property is an object that implements + * the Node interface. + * attributes + * This read-only property is an object that implements + * the NamedNodeMap interface. + * ownerDocument + * This read-only property is an object that implements + * the Document interface. + * namespaceURI + * This read-only property is a String. + * prefix + * This property is a String and can raise an object + * that implements the DOMException interface on setting. + * localName + * This read-only property is a String. + * baseURI + * This read-only property is a String. + * textContent + * This property is a String, can raise an object that implements + * the DOMException interface on setting and can raise + * an object that implements the DOMException interface + * on retrieval. + * + * + * Functions of objects that implement the Node interface: + * + * insertBefore(newChild, refChild) + * This function returns an object that implements + * the Node interface. + * The newChild parameter is an object that implements + * the Node interface. + * The refChild parameter is an object that implements + * the Node interface. + * This function can raise an object that implements + * the DOMException interface. + * replaceChild(newChild, oldChild) + * This function returns an object that implements + * the Node interface. + * The newChild parameter is an object that implements + * the Node interface. + * The oldChild parameter is an object that implements + * the Node interface. + * This function can raise an object that implements + * the DOMException interface. + * removeChild(oldChild) + * This function returns an object that implements + * the Node interface. + * The oldChild parameter is an object that implements + * the Node interface. + * This function can raise an object that implements + * the DOMException interface. + * appendChild(newChild) + * This function returns an object that implements + * the Node interface. + * The newChild parameter is an object that implements + * the Node interface. + * This function can raise an object that implements + * the DOMException interface. + * hasChildNodes() + * This function returns a Boolean. + * cloneNode(deep) + * This function returns an object that implements + * the Node interface. + * The deep parameter is a Boolean. + * normalize() + * This function has no return value. + * isSupported(feature, version) + * This function returns a Boolean. + * The feature parameter is a String. + * The version parameter is a String. + * hasAttributes() + * This function returns a Boolean. + * compareDocumentPosition(other) + * This function returns a Number. + * The other parameter is an object that implements + * the Node interface. + * This function can raise an object that implements + * the DOMException interface. + * isSameNode(other) + * This function returns a Boolean. + * The other parameter is an object that implements + * the Node interface. + * lookupPrefix(namespaceURI) + * This function returns a String. + * The namespaceURI parameter is a String. + * isDefaultNamespace(namespaceURI) + * This function returns a Boolean. + * The namespaceURI parameter is a String. + * lookupNamespaceURI(prefix) + * This function returns a String. + * The prefix parameter is a String. + * isEqualNode(arg) + * This function returns a Boolean. + * The arg parameter is an object that implements + * the Node interface. + * getFeature(feature, version) + * This function returns an object that implements + * the Object interface. + * The feature parameter is a String. + * The version parameter is a String. + * setUserData(key, data, handler) + * This function returns an object that implements + * the any type interface. + * The key parameter is a String. + * The data parameter is an object that implements + * the any type interface. + * The handler parameter is an object that implements + * the UserDataHandler interface. + * getUserData(key) + * This function returns an object that implements + * the any type interface. + * The key parameter is a String. + * + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS Node + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + +//######################################################################## +//# NodeList +//######################################################################## + +/** + * Objects that implement the NodeList interface: + * + * Properties of objects that implement the NodeList interface: + * + * length + * This read-only property is a Number. + * + * Functions of objects that implement the NodeList interface: + * + * item(index) + * This function returns an object that implements + * the Node interface. + * The index parameter is a Number. + * Note: This object can also be dereferenced using square + * bracket notation (e.g. obj[1]). Dereferencing with + * an integer index is equivalent to invoking the item + * function with that index. + * + * + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS NodeList + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + +//######################################################################## +//# NamedNodeMap +//######################################################################## + +/** + * Objects that implement the NamedNodeMap interface: + * + * Properties of objects that implement the NamedNodeMap interface: + * + * length + * This read-only property is a Number. + * + * Functions of objects that implement the NamedNodeMap interface: + * + * getNamedItem(name) + * This function returns an object that implements + * the Node interface. + * The name parameter is a String. + * setNamedItem(arg) + * This function returns an object that implements + * the Node interface. + * The arg parameter is an object that implements + * the Node interface. + * This function can raise an object that implements + * the DOMException interface. + * removeNamedItem(name) + * This function returns an object that implements + * the Node interface. + * The name parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * item(index) + * This function returns an object that implements + * the Node interface. + * The index parameter is a Number. + * Note: This object can also be dereferenced using square + * bracket notation (e.g. obj[1]). Dereferencing with + * an integer index is equivalent to invoking the item + * function with that index. + * getNamedItemNS(namespaceURI, localName) + * This function returns an object that implements + * the Node interface. + * The namespaceURI parameter is a String. + * The localName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * setNamedItemNS(arg) + * This function returns an object that implements + * the Node interface. + * The arg parameter is an object that implements + * the Node interface. + * This function can raise an object that implements + * the DOMException interface. + * removeNamedItemNS(namespaceURI, localName) + * This function returns an object that implements + * the Node interface. + * The namespaceURI parameter is a String. + * The localName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + */ + + +#undef CURRENT_CLASS +#define CURRENT_CLASS NamedNodeMap + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + +//######################################################################## +//# CharacterData +//######################################################################## + +/** + * Objects that implement the CharacterData interface: + * + * Objects that implement the CharacterData interface have all + * properties and functions of the Node interface as well as + * the properties and functions defined below. Properties + * of objects that implement the CharacterData interface: + * + * + * data + * This property is a String, can raise an object + * that implements the DOMException interface on setting + * and can raise an object that implements the DOMException + * interface on retrieval. + * length + * This read-only property is a Number. + * + * Functions of objects that implement the CharacterData interface: + * + * substringData(offset, count) + * This function returns a String. + * The offset parameter is a Number. + * The count parameter is a Number. + * This function can raise an object that implements + * the DOMException interface. + * appendData(arg) + * This function has no return value. + * The arg parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * insertData(offset, arg) + * This function has no return value. + * The offset parameter is a Number. + * The arg parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * deleteData(offset, count) + * This function has no return value. + * The offset parameter is a Number. + * The count parameter is a Number. + * This function can raise an object that implements + * the DOMException interface. + * replaceData(offset, count, arg) + * This function has no return value. + * The offset parameter is a Number. + * The count parameter is a Number. + * The arg parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS CharacterData + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + + + +//######################################################################## +//# Attr +//######################################################################## + +/** + * Objects that implement the Attr interface: + * + * Objects that implement the Attr interface have all properties + * and functions of the Node interface as well as the properties + * and functions defined below. + * Properties of objects that implement the Attr interface: + * + * + * name + * This read-only property is a String. + * specified + * This read-only property is a Boolean. + * value + * This property is a String and can raise an object + * that implements the DOMException interface on setting. + * ownerElement + * This read-only property is an object that implements + * the Element interface. + * schemaTypeInfo + * This read-only property is an object that implements + * the TypeInfo interface. + * isId + * This read-only property is a Boolean. + * + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS Attr + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + +//######################################################################## +//# Element +//######################################################################## + +/** + * Objects that implement the Element interface: + * + * Objects that implement the Element interface have all properties + * and functions of the Node interface as well as the properties + * and functions defined below. + * Properties of objects that implement the Element interface: + * + * + * tagName + * This read-only property is a String. + * schemaTypeInfo + * This read-only property is an object that implements + * the TypeInfo interface. + * + * Functions of objects that implement the Element interface: + * + * getAttribute(name) + * This function returns a String. + * The name parameter is a String. + * setAttribute(name, value) + * This function has no return value. + * The name parameter is a String. + * The value parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * removeAttribute(name) + * This function has no return value. + * The name parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * getAttributeNode(name) + * This function returns an object that implements + * the Attr interface. + * The name parameter is a String. + * setAttributeNode(newAttr) + * This function returns an object that implements + * the Attr interface. + * The newAttr parameter is an object that implements + * the Attr interface. + * This function can raise an object that implements + * the DOMException interface. + * removeAttributeNode(oldAttr) + * This function returns an object that implements + * the Attr interface. + * The oldAttr parameter is an object that implements + * the Attr interface. + * This function can raise an object that implements + * the DOMException interface. + * getElementsByTagName(name) + * This function returns an object that implements + * the NodeList interface. + * The name parameter is a String. + * getAttributeNS(namespaceURI, localName) + * This function returns a String. + * The namespaceURI parameter is a String. + * The localName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * setAttributeNS(namespaceURI, qualifiedName, value) + * This function has no return value. + * The namespaceURI parameter is a String. + * The qualifiedName parameter is a String. + * The value parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * removeAttributeNS(namespaceURI, localName) + * This function has no return value. + * The namespaceURI parameter is a String. + * The localName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * getAttributeNodeNS(namespaceURI, localName) + * This function returns an object that implements + * the Attr interface. + * The namespaceURI parameter is a String. + * The localName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * setAttributeNodeNS(newAttr) + * This function returns an object that implements + * the Attr interface. + * The newAttr parameter is an object that implements + * the Attr interface. + * This function can raise an object that implements + * the DOMException interface. + * getElementsByTagNameNS(namespaceURI, localName) + * This function returns an object that implements + * the NodeList interface. + * The namespaceURI parameter is a String. + * The localName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * hasAttribute(name) + * This function returns a Boolean. + * The name parameter is a String. + * hasAttributeNS(namespaceURI, localName) + * This function returns a Boolean. + * The namespaceURI parameter is a String. + * The localName parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * setIdAttribute(name, isId) + * This function has no return value. + * The name parameter is a String. + * The isId parameter is a Boolean. + * This function can raise an object that implements + * the DOMException interface. + * setIdAttributeNS(namespaceURI, localName, isId) + * This function has no return value. + * The namespaceURI parameter is a String. + * The localName parameter is a String. + * The isId parameter is a Boolean. + * This function can raise an object that implements + * the DOMException interface. + * setIdAttributeNode(idAttr, isId) + * This function has no return value. + * The idAttr parameter is an object that implements + * the Attr interface. + * The isId parameter is a Boolean. + * This function can raise an object that implements + * the DOMException interface. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS Element + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + +//######################################################################## +//# Text +//######################################################################## + +/** + * Objects that implement the Text interface: + * + * Objects that implement the Text interface have all properties + * and functions of the CharacterData interface as well as + * the properties and functions defined below. Properties of objects + * that implement the Text interface: + * + * + * isElementContentWhitespace + * This read-only property is a Boolean. + * wholeText + * This read-only property is a String. + * + * Functions of objects that implement the Text interface: + * + * splitText(offset) + * This function returns an object that implements + * the Text interface. + * The offset parameter is a Number. + * This function can raise an object that implements + * the DOMException interface. + * replaceWholeText(content) + * This function returns an object that implements + * the Text interface. + * The content parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS Text + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + +//######################################################################## +//# Comment +//######################################################################## + +/** + * Objects that implement the Comment interface: + * + * Objects that implement the Comment interface have all properties + * and functions of the CharacterData interface. + * + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS Comment + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + + +//######################################################################## +//# TypeInfo +//######################################################################## + +/** + * Properties of the TypeInfo Constructor function: + * + * TypeInfo.DERIVATION_RESTRICTION + * The value of the constant TypeInfo.DERIVATION_RESTRICTION + * is 0x00000001. + * TypeInfo.DERIVATION_EXTENSION + * The value of the constant TypeInfo.DERIVATION_EXTENSION + * is 0x00000002. + * TypeInfo.DERIVATION_UNION + * The value of the constant TypeInfo.DERIVATION_UNION + * is 0x00000004. + * TypeInfo.DERIVATION_LIST + * The value of the constant TypeInfo.DERIVATION_LIST + * is 0x00000008. + * + * Objects that implement the TypeInfo interface: + * + * Properties of objects that implement the TypeInfo interface: + * + * typeName + * This read-only property is a String. + * typeNamespace + * This read-only property is a String. + * + * Functions of objects that implement the TypeInfo interface: + * + * isDerivedFrom(typeNamespaceArg, typeNameArg, derivationMethod) + * This function returns a Boolean. + * The typeNamespaceArg parameter is a String. + * The typeNameArg parameter is a String. + * The derivationMethod parameter is a Number. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS TypeInfo + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + + + + +//######################################################################## +//# UserDataHandler +//######################################################################## + +/** + * Properties of the UserDataHandler Constructor function: + * + * UserDataHandler.NODE_CLONED + * The value of the constant UserDataHandler.NODE_CLONED is 1. + * UserDataHandler.NODE_IMPORTED + * The value of the constant UserDataHandler.NODE_IMPORTED is 2. + * UserDataHandler.NODE_DELETED + * The value of the constant UserDataHandler.NODE_DELETED is 3. + * UserDataHandler.NODE_RENAMED + * The value of the constant UserDataHandler.NODE_RENAMED is 4. + * UserDataHandler.NODE_ADOPTED + * The value of the constant UserDataHandler.NODE_ADOPTED is 5. + * + * UserDataHandler function: + * This function has no return value. + * The first parameter is a Number. + * The second parameter is a String. + * The third parameter is an object that implements the any + * type interface. + * The fourth parameter is an object that implements the Node + * interface. + * The fifth parameter is an object that implements the Node interface. + * Properties of the DOMError Constructor function: + * + * + * DOMError.SEVERITY_WARNING + * The value of the constant DOMError.SEVERITY_WARNING is 1. + * DOMError.SEVERITY_ERROR + * The value of the constant DOMError.SEVERITY_ERROR is 2. + * DOMError.SEVERITY_FATAL_ERROR + * The value of the constant DOMError.SEVERITY_FATAL_ERROR is 3. + */ + + +#undef CURRENT_CLASS +#define CURRENT_CLASS UserDataHandler + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + +//######################################################################## +//# DOMError +//######################################################################## + +/** + * Objects that implement the DOMError interface: + * + * Properties of objects that implement the DOMError interface: + * + * severity + * This read-only property is a Number. + * message + * This read-only property is a String. + * type + * This read-only property is a String. + * relatedException + * This read-only property is an object that implements + * the Object interface. + * relatedData + * This read-only property is an object that implements + * the Object interface. + * location + * This read-only property is an object that implements + * the DOMLocator interface. + * + * DOMErrorHandler function: + * This function returns a Boolean. + * The parameter is an object that implements the + * DOMError interface. + * + * + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS DOMError + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + +//######################################################################## +//# DOMLocator +//######################################################################## + +/** + * Objects that implement the DOMLocator interface: + * + * Properties of objects that implement the DOMLocator interface: + * + * lineNumber + * This read-only property is a Number. + * columnNumber + * This read-only property is a Number. + * byteOffset + * This read-only property is a Number. + * utf16Offset + * This read-only property is a Number. + * relatedNode + * This read-only property is an object that implements + * the Node interface. + * uri + * This read-only property is a String. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS DOMLocator + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + + + +//######################################################################## +//# DOMConfiguration +//######################################################################## + +/** + * Objects that implement the DOMConfiguration interface: + * + * Properties of objects that implement the DOMConfiguration interface: + * + * parameterNames + * This read-only property is an object that implements + * the DOMStringList interface. + * + * Functions of objects that implement the DOMConfiguration interface: + * + * setParameter(name, value) + * This function has no return value. + * The name parameter is a String. + * The value parameter is an object that implements + * the any type interface. + * This function can raise an object that implements + * the DOMException interface. + * getParameter(name) + * This function returns an object that implements + * the any type interface. + * The name parameter is a String. + * This function can raise an object that implements + * the DOMException interface. + * canSetParameter(name, value) + * This function returns a Boolean. + * The name parameter is a String. + * The value parameter is an object that implements + * the any type interface. + */ + + +#undef CURRENT_CLASS +#define CURRENT_CLASS DOMConfiguration + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + + +//######################################################################## +//# CDATASection +//######################################################################## + +/** + * Objects that implement the CDATASection interface: + * + * Objects that implement the CDATASection interface + * have all properties and functions of the Text interface. + * + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS CDATASection + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + + + +//######################################################################## +//# DocumentType +//######################################################################## + +/** + * Objects that implement the DocumentType interface: + * + * Objects that implement the DocumentType interface have all + * properties and functions of the Node interface as well as + * the properties and functions defined below. + * Properties of objects that implement the DocumentType interface: + * + * + * name + * This read-only property is a String. + * entities + * This read-only property is an object that implements + * the NamedNodeMap interface. + * notations + * This read-only property is an object that implements + * the NamedNodeMap interface. + * publicId + * This read-only property is a String. + * systemId + * This read-only property is a String. + * internalSubset + * This read-only property is a String. + */ + + +#undef CURRENT_CLASS +#define CURRENT_CLASS DocumentType + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + +//######################################################################## +//# Notation +//######################################################################## + +/** + * Objects that implement the Notation interface: + * + * Objects that implement the Notation interface have all + * properties and functions of the Node interface as well as + * the properties and functions defined below. + * Properties of objects that implement the Notation interface: + * + * + * publicId + * This read-only property is a String. + * systemId + * This read-only property is a String. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS Notation + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + + +//######################################################################## +//# Entity +//######################################################################## + +/** + * Objects that implement the Entity interface: + * + * Objects that implement the Entity interface have all properties + * and functions of the Node interface as well as the properties + * and functions defined below. + * Properties of objects that implement the Entity interface: + * + * + * publicId + * This read-only property is a String. + * systemId + * This read-only property is a String. + * notationName + * This read-only property is a String. + * inputEncoding + * This read-only property is a String. + * xmlEncoding + * This read-only property is a String. + * xmlVersion + * This read-only property is a String. + */ + +#undef CURRENT_CLASS +#define CURRENT_CLASS Entity + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + + +//######################################################################## +//# EntityReference +//######################################################################## + +/** + * Objects that implement the EntityReference interface: + * + * Objects that implement the EntityReference interface have all + * properties and functions of the Node interface. + * + */ + + +#undef CURRENT_CLASS +#define CURRENT_CLASS EntityReference + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + +//######################################################################## +//# ProcessingInstruction +//######################################################################## + +/** + * Objects that implement the ProcessingInstruction interface: + * + * Objects that implement the ProcessingInstruction interface + * have all properties and functions of the Node interface + * as well as the properties and functions defined below. + * Properties of objects that implement the ProcessingInstruction + * interface: + * + * target + * This read-only property is a String. + * data + * This property is a String and can raise an object + * that implements the DOMException interface on setting. + * + */ + + +#undef CURRENT_CLASS +#define CURRENT_CLASS ProcessingInstruction + +class CLASS_NAME(CURRENT_CLASS) : public Wrapper +{ +public: + + CLASS_NAME(CURRENT_CLASS)(JSContext*cx, JSObject *obj) + : Wrapper(cx, obj) + {} + + ~CLASS_NAME(CURRENT_CLASS)() + {} + + JSBool init(uintN argc, jsval *argv) + { + return JS_TRUE; + } + + JSBool getProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + JSBool setProperty(jsval id, jsval *vp) + { + return JS_FALSE; + } + + /** + * + */ + METHOD(getDOMImplementation) + { + return JS_FALSE; + } + + + /** + * + */ + METHOD(getDOMImplementationList) + { + return JS_FALSE; + } + + enum + { + prop_code + }; + +}; + + + + +JSPropertySpec PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSPropertySpec STATIC_PROPERTY_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + +JSFunctionSpec STATIC_METHOD_TABLE(CURRENT_CLASS)[] = +{ + { 0 } +}; + + +CONSTRUCTOR ( CURRENT_CLASS ) + + + + + + +/** + * Note: In addition of having DOMConfiguration parameters + * exposed to the application using the setParameter + * and getParameter, those parameters are also exposed + * as ECMAScript properties on the DOMConfiguration object. + * The name of the parameter is converted into a property name + * using a camel-case convention: + * the character '-' (HYPHEN-MINUS) is removed + * and the following character is + * being replaced by its uppercase equivalent. + */ + + + + + +//######################################################################## +//# M A I N B I N D I N G +//######################################################################## + +bool JavascriptDOMBinder::createClasses() +{ + void *savedContext = JS_GetContextPrivate(cx); + JS_SetContextPrivate(cx, (void *)this); + + proto_Node = + CREATE_PROTO(Node, cx, globalObj, NULL); + proto_CharacterData = + CREATE_PROTO(CharacterData, cx, globalObj, proto_Node); + proto_Text = + CREATE_PROTO(Text, cx, globalObj, proto_CharacterData); + proto_CDATASection = + CREATE_PROTO(CDATASection, cx, globalObj, proto_Text); + proto_Document = + CREATE_PROTO(Document, cx, globalObj, proto_CDATASection); + + JS_SetContextPrivate(cx, savedContext); + return true; +} + + +JSObject *JavascriptDOMBinder::wrapDocument(const Document *doc) +{ + if (!doc) + { + error("wrapDocument: null document parameter"); + return NULL; + } + + JSObject *jsdoc = JS_NewObject(cx, &wrapperClassDef, + proto_Document, NULL); + + //Wrap around the document... done! + CLASS_NAME(Document) *docWrap = new CLASS_NAME(Document)(cx, globalObj); + docWrap->doc = doc; + JS_SetPrivate(cx, jsdoc, (void *)docWrap); + + return jsdoc; +} + + + + +} // namespace dom +} // namespace w3c +} // namespace org + +//######################################################################## +//# E N D O F F I L E +//######################################################################## + diff --git a/src/dom/jsdombind.h b/src/dom/jsdombind.h new file mode 100644 index 000000000..f995a1f53 --- /dev/null +++ b/src/dom/jsdombind.h @@ -0,0 +1,156 @@ +#ifndef __JSDOMBIND_H__ +#define __JSDOMBIND_H__ +/** + * Phoebe DOM Implementation. + * + * This is a C++ approximation of the W3C DOM model, which follows + * fairly closely the specifications in the various .idl files, copies of + * which are provided for reference. Most important is this one: + * + * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html + * + * Authors: + * Bob Jamison + * + * Copyright (C) 2006 Bob Jamison + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#include "jsengine.h" + + +namespace org +{ +namespace w3c +{ +namespace dom +{ + + +/** + * Wrap the W3C DOM Core classes around a JavascriptEngine. + */ +class JavascriptDOMBinder +{ +public: + + /** + * Constructor + */ + JavascriptDOMBinder(JavascriptEngine &someEngine) + : engine(someEngine) + { init(); } + + + /** + * Destructor + */ + virtual ~JavascriptDOMBinder() + { } + + + JSObject *wrapDocument(const Document *doc); + + /** + * Bind with the basic DOM classes + */ + bool createClasses(); + + JSObject *proto_Attr; + JSObject *proto_CDATASection; + JSObject *proto_CharacterData; + JSObject *proto_Comment; + JSObject *proto_Document; + JSObject *proto_DocumentFragment; + JSObject *proto_DocumentType; + JSObject *proto_DOMConfiguration; + JSObject *proto_DOMError; + JSObject *proto_DOMException; + JSObject *proto_DOMImplementation; + JSObject *proto_DOMImplementationList; + JSObject *proto_DOMImplementationRegistry; + JSObject *proto_DOMImplementationSource; + JSObject *proto_DOMLocator; + JSObject *proto_DOMStringList; + JSObject *proto_Element; + JSObject *proto_Entity; + JSObject *proto_EntityReference; + JSObject *proto_NamedNodeMap; + JSObject *proto_NameList; + JSObject *proto_Node; + JSObject *proto_NodeList; + JSObject *proto_Notation; + JSObject *proto_ProcessingInstruction; + JSObject *proto_Text; + JSObject *proto_TypeInfo; + JSObject *proto_UserDataHandler; + +private: + + void init() + { + rt = engine.getRuntime(); + cx = engine.getContext(); + globalObj = engine.getGlobalObject(); + } + + /** + * Assignment operator. Let's keep this private for now, + * as we want one Spidermonkey runtime per c++ shell + */ + JavascriptDOMBinder &operator=(const JavascriptDOMBinder &other) + { assign(other); return *this; } + + void assign(const JavascriptDOMBinder &other) + { + rt = other.rt; + cx = other.cx; + globalObj = other.globalObj; + } + + + /** + * Ouput a printf-formatted error message + */ + void error(char *fmt, ...); + + /** + * Ouput a printf-formatted error message + */ + void trace(char *fmt, ...); + + JSRuntime *rt; + + JSContext *cx; + + JSObject *globalObj; + + + + JavascriptEngine &engine; +}; + + + +} // namespace dom +} // namespace w3c +} // namespace org + + +#endif /* __JSDOMBIND_H__ */ + + diff --git a/src/dom/jsengine.cpp b/src/dom/jsengine.cpp index c3c017dc6..38b856c3c 100644 --- a/src/dom/jsengine.cpp +++ b/src/dom/jsengine.cpp @@ -29,6 +29,7 @@ #include "jsengine.h" +#include "jsdombind.h" #include #include @@ -241,6 +242,15 @@ bool JavascriptEngine::evaluateFile(const DOMString &fileName) return true; } +/** + * Bind with the basic DOM classes + */ +bool JavascriptEngine::createClasses() +{ + JavascriptDOMBinder binder(*this); + binder.createClasses(); + return true; +} diff --git a/src/dom/jsengine.h b/src/dom/jsengine.h index aa7297f9c..abcbb23e9 100644 --- a/src/dom/jsengine.h +++ b/src/dom/jsengine.h @@ -73,36 +73,24 @@ public: bool evaluateFile(const DOMString &script); - JSObject *wrapDocument(const Document *doc); - - JSObject *new_Attr(Attr *obj); - JSObject *new_CDATASection(CDATASection *obj); - JSObject *new_CharacterData(CharacterData *obj); - JSObject *new_Comment(Comment *obj); - JSObject *new_Document(Document *obj); - JSObject *new_DocumentFragment(DocumentFragment *obj); - JSObject *new_DocumentType(DocumentType *obj); - JSObject *new_DOMConfiguration(DOMConfiguration *obj); - JSObject *new_DOMError(DOMError *obj); - JSObject *new_DOMException(DOMException *obj); - JSObject *new_DOMImplementation(DOMImplementation *obj); - JSObject *new_DOMImplementationList(DOMImplementationList *obj); - JSObject *new_DOMImplementationRegistry(DOMImplementationSource *obj); - JSObject *new_DOMImplementationSource(DOMImplementationSource *obj); - JSObject *new_DOMLocator(DOMLocator *obj); - JSObject *new_DOMStringList(DOMStringList *obj); - JSObject *new_Element(Element *obj); - JSObject *new_Entity(Entity *obj); - JSObject *new_EntityReference(EntityReference *obj); - JSObject *new_NamedNodeMap(NamedNodeMap *obj); - JSObject *new_NameList(NameList *obj); - JSObject *new_Node(Node *obj); - JSObject *new_NodeList(NodeList *obj); - JSObject *new_Notation(Notation *obj); - JSObject *new_ProcessingInstruction(ProcessingInstruction *obj); - JSObject *new_Text(Text *obj); - JSObject *new_TypeInfo(TypeInfo *obj); - JSObject *new_UserDataHandler(UserDataHandler *obj); + /** + * Return the runtime of the wrapped JS engine + */ + JSRuntime *getRuntime() + { return rt; } + + /** + * Return the current context of the wrapped JS engine + */ + JSContext *getContext() + { return cx; } + + /** + * Return the current global object of the wrapped JS engine + */ + JSObject *getGlobalObject() + { return globalObj; } + private: @@ -166,34 +154,6 @@ private: engine->error((char *)message); } - JSObject *proto_Attr; - JSObject *proto_CDATASection; - JSObject *proto_CharacterData; - JSObject *proto_Comment; - JSObject *proto_Document; - JSObject *proto_DocumentFragment; - JSObject *proto_DocumentType; - JSObject *proto_DOMConfiguration; - JSObject *proto_DOMError; - JSObject *proto_DOMException; - JSObject *proto_DOMImplementation; - JSObject *proto_DOMImplementationList; - JSObject *proto_DOMImplementationRegistry; - JSObject *proto_DOMImplementationSource; - JSObject *proto_DOMLocator; - JSObject *proto_DOMStringList; - JSObject *proto_Element; - JSObject *proto_Entity; - JSObject *proto_EntityReference; - JSObject *proto_NamedNodeMap; - JSObject *proto_NameList; - JSObject *proto_Node; - JSObject *proto_NodeList; - JSObject *proto_Notation; - JSObject *proto_ProcessingInstruction; - JSObject *proto_Text; - JSObject *proto_TypeInfo; - JSObject *proto_UserDataHandler; diff --git a/src/dom/ls.h b/src/dom/ls.h index b6f98bf8b..db009e234 100644 --- a/src/dom/ls.h +++ b/src/dom/ls.h @@ -62,8 +62,11 @@ typedef dom::io::Writer LSWriter; typedef dom::DOMString DOMString; typedef dom::DOMConfiguration DOMConfiguration; typedef dom::Node Node; +typedef dom::NodePtr NodePtr; typedef dom::Document Document; +typedef dom::DocumentPtr DocumentPtr; typedef dom::Element Element; +typedef dom::ElementPtr ElementPtr; //forward declarations @@ -155,12 +158,12 @@ public: /** * */ - virtual unsigned short startElement(const Element *elementArg) =0; + virtual unsigned short startElement(const ElementPtr elementArg) =0; /** * */ - virtual unsigned short acceptNode(const Node *nodeArg) =0; + virtual unsigned short acceptNode(const NodePtr nodeArg) =0; /** * @@ -390,16 +393,16 @@ public: /** * */ - virtual Document *parse(const LSInput &input) - throw(dom::DOMException, LSException) + virtual DocumentPtr parse(const LSInput &input) + throw(dom::DOMException, LSException) { return NULL; } /** * */ - virtual Document *parseURI(const DOMString &uri) - throw(dom::DOMException, LSException) + virtual DocumentPtr parseURI(const DOMString &uri) + throw(dom::DOMException, LSException) { return NULL; } typedef enum @@ -415,10 +418,10 @@ public: /** * */ - virtual Node *parseWithContext(const LSInput &input, - const Node *contextArg, - unsigned short action) - throw(dom::DOMException, LSException) + virtual NodePtr parseWithContext(const LSInput &input, + const NodePtr contextArg, + unsigned short action) + throw(dom::DOMException, LSException) { return NULL; } /** @@ -657,7 +660,7 @@ public: /** * */ - virtual bool write(const Node *nodeArg, + virtual bool write(const NodePtr nodeArg, const LSOutput &destination) throw (LSException) { return false; } @@ -665,7 +668,7 @@ public: /** * */ - virtual bool writeToURI(const Node *nodeArg, + virtual bool writeToURI(const NodePtr nodeArg, const DOMString &uri) throw(LSException) { return false; } @@ -673,7 +676,7 @@ public: /** * */ - virtual DOMString writeToString(const Node *nodeArg) + virtual DOMString writeToString(const NodePtr nodeArg) throw(dom::DOMException, LSException) { DOMString str; @@ -798,7 +801,7 @@ public: /** * */ - virtual Document *getNewDocument() + virtual DocumentPtr getNewDocument() { return newDocument; } /** @@ -814,14 +817,16 @@ public: /** * */ - LSLoadEvent(const LSInput &inputArg, const Document *docArg) + LSLoadEvent(const LSInput &inputArg, + const DocumentPtr docArg) : input((LSInput &)inputArg) - { newDocument = (Document *)docArg; } + { newDocument = docArg; } /** * */ - LSLoadEvent(const LSLoadEvent &other) : events::Event(other) , input(other.input) + LSLoadEvent(const LSLoadEvent &other) + : events::Event(other) , input(other.input) { newDocument = other.newDocument; } @@ -833,7 +838,7 @@ public: protected: - Document *newDocument; + DocumentPtr newDocument; LSInput &input; diff --git a/src/dom/lsimpl.cpp b/src/dom/lsimpl.cpp index 65807cc45..8848a42e4 100644 --- a/src/dom/lsimpl.cpp +++ b/src/dom/lsimpl.cpp @@ -61,8 +61,8 @@ bool LSParserImpl::getBusy() /** * */ -Document *LSParserImpl::parse(const LSInput &input) - throw(dom::DOMException, LSException) +DocumentPtr LSParserImpl::parse(const LSInput &input) + throw(dom::DOMException, LSException) { //#### Check the various inputs of 'input' in order, according @@ -79,7 +79,7 @@ Document *LSParserImpl::parse(const LSInput &input) buf.push_back((XMLCh)ch); } XmlReader reader; - Document *doc = reader.parse(buf); + DocumentPtr doc = reader.parse(buf); return doc; } @@ -95,15 +95,15 @@ Document *LSParserImpl::parse(const LSInput &input) buf.push_back((XMLCh)ch); } XmlReader reader; - Document *doc = reader.parse(buf); + DocumentPtr doc = reader.parse(buf); return doc; } DOMString stringData = input.getStringData(); if (stringData.size() > 0) { - XmlReader reader; - Document *doc = reader.parse(stringData); + XmlReader reader; + DocumentPtr doc = reader.parse(stringData); return doc; } @@ -128,8 +128,8 @@ Document *LSParserImpl::parse(const LSInput &input) /** * */ -Document *LSParserImpl::parseURI(const DOMString &uri) - throw(dom::DOMException, LSException) +DocumentPtr LSParserImpl::parseURI(const DOMString &uri) + throw(dom::DOMException, LSException) { return NULL; } @@ -137,10 +137,10 @@ Document *LSParserImpl::parseURI(const DOMString &uri) /** * */ -Node *LSParserImpl::parseWithContext(const LSInput &input, - const Node *contextArg, - unsigned short action) - throw(dom::DOMException, LSException) +NodePtr LSParserImpl::parseWithContext(const LSInput &input, + const NodePtr contextArg, + unsigned short action) + throw(dom::DOMException, LSException) { return NULL; } @@ -170,7 +170,7 @@ Node *LSParserImpl::parseWithContext(const LSInput &input, * */ bool LSSerializerImpl::write( - const Node *nodeArg, + const NodePtr nodeArg, const LSOutput &destination) throw (LSException) { @@ -215,7 +215,7 @@ bool LSSerializerImpl::write( /** * */ -bool LSSerializerImpl::writeToURI(const Node *nodeArg, +bool LSSerializerImpl::writeToURI(const NodePtr nodeArg, const DOMString &uriArg) throw(LSException) { @@ -241,7 +241,7 @@ bool LSSerializerImpl::writeToURI(const Node *nodeArg, /** * */ -DOMString LSSerializerImpl::writeToString(const Node *nodeArg) +DOMString LSSerializerImpl::writeToString(const NodePtr nodeArg) throw(dom::DOMException, LSException) { outbuf = ""; @@ -312,9 +312,9 @@ void LSSerializerImpl::poxml(const DOMString &str) /** * */ -void LSSerializerImpl::writeNode(const Node *nodeArg) +void LSSerializerImpl::writeNode(const NodePtr nodeArg) { - Node *node = (Node *)nodeArg; + NodePtr node = nodeArg; int type = node->getNodeType(); @@ -326,7 +326,7 @@ void LSSerializerImpl::writeNode(const Node *nodeArg) //############# case Node::DOCUMENT_NODE: { - Document *doc = dynamic_cast(node); + DocumentPtr doc = dynamic_cast(node.get()); writeNode(doc->getDocumentElement()); } break; @@ -374,7 +374,7 @@ void LSSerializerImpl::writeNode(const Node *nodeArg) //### Attributes for (int i=0 ; igetNodeName()); po("=\""); @@ -394,8 +394,8 @@ void LSSerializerImpl::writeNode(const Node *nodeArg) pos(node->getNodeValue()); //### Children - for (Node *child = node->getFirstChild() ; - child ; + for (NodePtr child = node->getFirstChild() ; + child.get() ; child=child->getNextSibling()) { writeNode(child); diff --git a/src/dom/lsimpl.h b/src/dom/lsimpl.h index ee6360143..0f0088684 100644 --- a/src/dom/lsimpl.h +++ b/src/dom/lsimpl.h @@ -72,23 +72,23 @@ public: /** * */ - virtual Document *parse(const LSInput &input) - throw(dom::DOMException, LSException); + virtual DocumentPtr parse(const LSInput &input) + throw(dom::DOMException, LSException); /** * */ - virtual Document *parseURI(const DOMString &uri) - throw(dom::DOMException, LSException); + virtual DocumentPtr parseURI(const DOMString &uri) + throw(dom::DOMException, LSException); /** * */ - virtual Node *parseWithContext(const LSInput &input, - const Node *contextArg, - unsigned short action) - throw(dom::DOMException, LSException); + virtual NodePtr parseWithContext(const LSInput &input, + const NodePtr contextArg, + unsigned short action) + throw(dom::DOMException, LSException); //################## @@ -144,13 +144,13 @@ public: /** * */ - virtual unsigned short startElement(const Element *elementArg) + virtual unsigned short startElement(const ElementPtr elementArg) { return 0; } /** * */ - virtual unsigned short acceptNode(const Node *nodeArg) + virtual unsigned short acceptNode(const NodePtr nodeArg) { return 0; } /** @@ -188,21 +188,21 @@ public: /** * */ - virtual bool write(const Node *nodeArg, + virtual bool write(const NodePtr nodeArg, const LSOutput &destination) throw (LSException); /** * */ - virtual bool writeToURI(const Node *nodeArg, + virtual bool writeToURI(const NodePtr nodeArg, const DOMString &uri) throw(LSException); /** * */ - virtual DOMString writeToString(const Node *nodeArg) + virtual DOMString writeToString(const NodePtr nodeArg) throw(dom::DOMException, LSException); //################## @@ -230,7 +230,7 @@ protected: /** * */ - void writeNode(const Node *nodeArg); + void writeNode(const NodePtr nodeArg); private: diff --git a/src/dom/mingwenv.bat b/src/dom/mingwenv.bat index 996566e7b..f9ec1e7c5 100644 --- a/src/dom/mingwenv.bat +++ b/src/dom/mingwenv.bat @@ -1,2 +1,2 @@ -set PATH=c:\mingw\bin;%PATH% +set PATH=c:\mingw4\bin;%PATH% set RM=del diff --git a/src/dom/stylesheets.h b/src/dom/stylesheets.h index b0d3f0c71..e41b6775d 100644 --- a/src/dom/stylesheets.h +++ b/src/dom/stylesheets.h @@ -192,7 +192,7 @@ public: /** * */ - virtual Node *getOwnerNode() + virtual NodePtr getOwnerNode() { return ownerNode; } @@ -273,7 +273,7 @@ protected: bool disabled; - Node *ownerNode; + NodePtr ownerNode; StyleSheet *parentStylesheet; diff --git a/src/dom/svg/svg.h b/src/dom/svg/svg.h index 0bf44b817..c5f3309b5 100644 --- a/src/dom/svg/svg.h +++ b/src/dom/svg/svg.h @@ -68,13 +68,20 @@ namespace svg typedef dom::DOMString DOMString; typedef dom::DOMException DOMException; typedef dom::Element Element; +typedef dom::ElementPtr ElementPtr; typedef dom::Document Document; +typedef dom::DocumentPtr DocumentPtr; typedef dom::NodeList NodeList; -class SVGSVGElement; +class SVGElement; +typedef Ptr SVGElementPtr; +class SVGSVGElement; +typedef Ptr SVGSVGElementPtr; +class SVGDocument; +typedef Ptr SVGDocumentPtr; /*######################################################################### @@ -113,12 +120,12 @@ public: /** * */ - virtual SVGSVGElement *getOwnerSVGElement() = 0; + virtual SVGSVGElementPtr getOwnerSVGElement() = 0; /** * */ - virtual SVGElement *getViewportElement() = 0; + virtual SVGElementPtr getViewportElement() = 0; //################## @@ -172,7 +179,7 @@ public: /** * */ - virtual SVGSVGElement *getRootElement() =0; + virtual SVGSVGElementPtr getRootElement() =0; //################## @@ -362,24 +369,24 @@ public: /** * */ - virtual NodeList getIntersectionList (const SVGRect &rect, - const SVGElement *referenceElement ) =0; + virtual NodeList getIntersectionList(const SVGRect &rect, + const SVGElementPtr referenceElement ) =0; /** * */ virtual NodeList getEnclosureList (const SVGRect &rect, - const SVGElement *referenceElement ) =0; + const SVGElementPtr referenceElement ) =0; /** * */ - virtual bool checkIntersection (const SVGElement *element, const SVGRect &rect ) =0; + virtual bool checkIntersection (const SVGElementPtr element, const SVGRect &rect ) =0; /** * */ - virtual bool checkEnclosure (const SVGElement *element, const SVGRect &rect ) =0; + virtual bool checkEnclosure (const SVGElementPtr element, const SVGRect &rect ) =0; /** * @@ -429,7 +436,7 @@ public: /** * */ - virtual Element *getElementById (const DOMString& elementId ) =0; + virtual ElementPtr getElementById (const DOMString& elementId ) =0; @@ -777,7 +784,7 @@ public: /** * */ - virtual SVGDocument *getSVGDocument ( ) + virtual SVGDocumentPtr getSVGDocument ( ) throw( DOMException ) =0; //################## @@ -3910,7 +3917,7 @@ public: /** * */ - virtual SVGElement *getTargetElement() =0; + virtual SVGElementPtr getTargetElement() =0; /** diff --git a/src/dom/svg/svgimpl.cpp b/src/dom/svg/svgimpl.cpp index 25406b4fd..03d42e515 100644 --- a/src/dom/svg/svgimpl.cpp +++ b/src/dom/svg/svgimpl.cpp @@ -67,22 +67,22 @@ namespace svg /** * */ -Element *SVGDocumentImpl::createElement(const DOMString& tagName) +ElementPtr SVGDocumentImpl::createElement(const DOMString& tagName) throw(DOMException) { - SVGElementImpl *impl = new SVGElementImpl(this, tagName); - return impl; + SVGElementPtr elem = new SVGElementImpl(this, tagName); + return elem; } /** * */ -Element *SVGDocumentImpl::createElementNS(const DOMString& namespaceURI, +ElementPtr SVGDocumentImpl::createElementNS(const DOMString& namespaceURI, const DOMString& qualifiedName) throw(DOMException) { - SVGElementImpl *elem = new SVGElementImpl(this, namespaceURI, qualifiedName); + SVGElementPtr elem = new SVGElementImpl(this, namespaceURI, qualifiedName); return elem; } @@ -161,7 +161,7 @@ bool SVGSVGElementImpl::animationsPaused( ) * */ NodeList SVGSVGElementImpl::getIntersectionList(const SVGRect &rect, - const SVGElement *referenceElement ) + const SVGElementPtr referenceElement ) { NodeList list; return list; @@ -171,7 +171,7 @@ NodeList SVGSVGElementImpl::getIntersectionList(const SVGRect &rect, * */ NodeList SVGSVGElementImpl::getEnclosureList(const SVGRect &rect, - const SVGElement *referenceElement ) + const SVGElementPtr referenceElement ) { NodeList list; return list; @@ -180,7 +180,7 @@ NodeList SVGSVGElementImpl::getEnclosureList(const SVGRect &rect, /** * */ -bool SVGSVGElementImpl::checkIntersection(const SVGElement *element, +bool SVGSVGElementImpl::checkIntersection(const SVGElementPtr element, const SVGRect &rect ) { return false; @@ -189,7 +189,7 @@ bool SVGSVGElementImpl::checkIntersection(const SVGElement *element, /** * */ -bool SVGSVGElementImpl::checkEnclosure(const SVGElement *element, +bool SVGSVGElementImpl::checkEnclosure(const SVGElementPtr element, const SVGRect &rect ) { return false; @@ -205,7 +205,7 @@ void SVGSVGElementImpl::deselectAll( ) /** * */ -Element *SVGSVGElementImpl::getElementById(const DOMString& elementId ) +ElementPtr SVGSVGElementImpl::getElementById(const DOMString& elementId ) { return NULL; } @@ -350,7 +350,7 @@ Element *SVGSVGElementImpl::getElementById(const DOMString& elementId ) /** * */ -SVGDocument *GetSVGDocumentImpl::getSVGDocument( ) +SVGDocumentPtr GetSVGDocumentImpl::getSVGDocument( ) throw ( DOMException ) { return NULL; diff --git a/src/dom/svg/svgimpl.h b/src/dom/svg/svgimpl.h index a9f6ace9b..5c2e78f1b 100644 --- a/src/dom/svg/svgimpl.h +++ b/src/dom/svg/svgimpl.h @@ -59,6 +59,11 @@ typedef dom::NodeList NodeList; class SVGSVGElementImpl; +typedef Ptr SVGSVGElementImplPtr; +class SVGElementImpl; +typedef Ptr SVGElementImplPtr; +class SVGDocumentImpl; +typedef Ptr SVGDocumentImplPtr; /*######################################################################### ## SVGDocumentImpl @@ -99,7 +104,7 @@ public: /** * */ - virtual SVGSVGElement *getRootElement() + virtual SVGSVGElementPtr getRootElement() { return rootElement; } @@ -111,25 +116,25 @@ public: /** * */ - virtual Element *createElement(const DOMString& tagName) + virtual ElementPtr createElement(const DOMString& tagName) throw(DOMException); /** * */ - virtual Element *createElementNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException); + virtual ElementPtr createElementNS(const DOMString& namespaceURI, + const DOMString& qualifiedName) + throw(DOMException); //################## //# Non-API methods //################## SVGDocumentImpl(const DOMImplementation *domImpl, - const DOMString &namespaceURI, - const DOMString &qualifiedName, - const DocumentType *doctype) + const DOMString &namespaceURI, + const DOMString &qualifiedName, + const DocumentTypePtr doctype) : DocumentImpl(domImpl, namespaceURI, qualifiedName, doctype) { @@ -142,8 +147,6 @@ public: */ virtual ~SVGDocumentImpl() { - if (rootElement) - delete rootElement; } protected: @@ -162,7 +165,7 @@ friend class SvgParser; DOMString referrer; DOMString domain; DOMString url; - SVGSVGElement *rootElement; + SVGSVGElementPtr rootElement; }; @@ -208,13 +211,13 @@ public: /** * */ - virtual SVGSVGElement *getOwnerSVGElement() + virtual SVGSVGElementPtr getOwnerSVGElement() { return ownerSvgElement; } /** * */ - virtual SVGElement *getViewportElement() + virtual SVGElementPtr getViewportElement() { return viewportElement; } @@ -232,14 +235,14 @@ public: /** * */ - SVGElementImpl(SVGDocumentImpl *owner, const DOMString &tagName) + SVGElementImpl(SVGDocumentImplPtr owner, const DOMString &tagName) : ElementImpl(owner, tagName) { init(); } /** * */ - SVGElementImpl(SVGDocumentImpl *owner, + SVGElementImpl(SVGDocumentImplPtr owner, const DOMString &namespaceURI, const DOMString &tagName) : ElementImpl(owner, namespaceURI, tagName) @@ -262,10 +265,10 @@ protected: viewportElement = NULL; } - DOMString id; - DOMString xmlBase; - SVGSVGElement *ownerSvgElement; - SVGElement *viewportElement; + DOMString id; + DOMString xmlBase; + SVGSVGElementPtr ownerSvgElement; + SVGElementPtr viewportElement; }; @@ -456,23 +459,23 @@ public: * */ virtual NodeList getIntersectionList (const SVGRect &rect, - const SVGElement *referenceElement ); + const SVGElementPtr referenceElement ); /** * */ virtual NodeList getEnclosureList (const SVGRect &rect, - const SVGElement *referenceElement ); + const SVGElementPtr referenceElement ); /** * */ - virtual bool checkIntersection (const SVGElement *element, const SVGRect &rect ); + virtual bool checkIntersection (const SVGElementPtr element, const SVGRect &rect ); /** * */ - virtual bool checkEnclosure (const SVGElement *element, const SVGRect &rect ); + virtual bool checkEnclosure (const SVGElementPtr element, const SVGRect &rect ); /** * @@ -556,7 +559,7 @@ public: /** * */ - virtual Element *getElementById (const DOMString& elementId ); + virtual ElementPtr getElementById (const DOMString& elementId ); @@ -977,7 +980,7 @@ public: /** * */ - virtual SVGDocument *getSVGDocument ( ) + virtual SVGDocumentPtr getSVGDocument ( ) throw( DOMException ); //################## @@ -1705,53 +1708,54 @@ public: /** * */ - virtual long getNumberOfChars ( ); + virtual long getNumberOfChars( ); /** * */ - virtual double getComputedTextLength ( ); + virtual double getComputedTextLength( ); /** * */ - virtual double getSubStringLength (unsigned long charnum, unsigned long nchars ) - throw( DOMException ); + virtual double getSubStringLength(unsigned long charnum, + unsigned long nchars ) + throw( DOMException ); /** * */ - virtual SVGPoint getStartPositionOfChar (unsigned long charnum ) - throw( DOMException ); + virtual SVGPoint getStartPositionOfChar(unsigned long charnum ) + throw( DOMException ); /** * */ - virtual SVGPoint getEndPositionOfChar (unsigned long charnum ) - throw( DOMException ); + virtual SVGPoint getEndPositionOfChar(unsigned long charnum ) + throw( DOMException ); /** * */ - virtual SVGRect getExtentOfChar (unsigned long charnum ) - throw( DOMException ); + virtual SVGRect getExtentOfChar(unsigned long charnum ) + throw( DOMException ); /** * */ - virtual double getRotationOfChar (unsigned long charnum ) + virtual double getRotationOfChar(unsigned long charnum ) throw( DOMException ); /** * */ - virtual long getCharNumAtPosition (const SVGPoint &point ); + virtual long getCharNumAtPosition(const SVGPoint &point ); /** * */ - virtual void selectSubString (unsigned long charnum, unsigned long nchars ) - throw( DOMException ); + virtual void selectSubString(unsigned long charnum, unsigned long nchars ) + throw( DOMException ); @@ -4453,7 +4457,7 @@ public: /** * */ - virtual SVGElement *getTargetElement() + virtual SVGElementPtr getTargetElement() { return targetElement; } @@ -4488,7 +4492,7 @@ public: protected: - SVGElement *targetElement; + SVGElementPtr targetElement; double startTime, currentTime, simpleDuration; }; diff --git a/src/dom/svg/svgparser.cpp b/src/dom/svg/svgparser.cpp index 0a0dd3f13..a6e017110 100644 --- a/src/dom/svg/svgparser.cpp +++ b/src/dom/svg/svgparser.cpp @@ -593,7 +593,8 @@ bool SvgParser::parseTransform(const DOMString &str) /** * */ -bool SvgParser::parseElement(ElementImpl *parent, ElementImpl *sourceElem) +bool SvgParser::parseElement(SVGElementImplPtr parent, + ElementImplPtr sourceElem) { if (!parent || !sourceElem) { @@ -606,7 +607,7 @@ bool SvgParser::parseElement(ElementImpl *parent, ElementImpl *sourceElem) DOMString tagName = sourceElem->getTagName(); printf("tag name:%s\n", tagName.c_str()); - ElementImpl *newElement = NULL; + ElementImplPtr newElement = NULL; if (namespaceURI != SVG_NAMESPACE) { newElement = new SVGSVGElementImpl(); @@ -700,22 +701,22 @@ bool SvgParser::parseElement(ElementImpl *parent, ElementImpl *sourceElem) int nodeCount = children.getLength(); for (int i=0 ; igetNodeType(); if (typ == Node::TEXT_NODE) { - Node *newNode = doc->createTextNode(child->getNodeValue()); + NodePtr newNode = doc->createTextNode(child->getNodeValue()); parent->appendChild(newNode); } else if (typ == Node::CDATA_SECTION_NODE) { - Node *newNode = doc->createCDATASection(child->getNodeValue()); + NodePtr newNode = doc->createCDATASection(child->getNodeValue()); parent->appendChild(newNode); } - else if (newElement && typ == Node::ELEMENT_NODE) + else if (newElement.get() && typ == Node::ELEMENT_NODE) { - ElementImpl *childElement = dynamic_cast(child); - parseElement(newElement, childElement); + //ElementImplPtr childElement = dynamic_cast(child.get()); + //parseElement(newElement, childElement); } } return true; @@ -725,23 +726,21 @@ bool SvgParser::parseElement(ElementImpl *parent, ElementImpl *sourceElem) /** * */ -Document *SvgParser::parse(const Document *sourceDoc) +SVGDocumentPtr SvgParser::parse(const DocumentPtr src) { - if (!sourceDoc) + if (!src) { error("NULL source document"); return NULL; } - Document *src = (Document *)sourceDoc; DOMImplementationImpl impl; doc = new SVGDocumentImpl(&impl, SVG_NAMESPACE, "svg" , NULL); - ElementImpl *destElem = dynamic_cast(doc->getDocumentElement()); - ElementImpl *srcElem = dynamic_cast(src->getDocumentElement()); + SVGElementImplPtr destElem = dynamic_cast(doc->getRootElement().get()); + ElementImplPtr srcElem = dynamic_cast(src->getDocumentElement().get()); if (!parseElement(destElem, srcElem)) { - delete doc; return NULL; } diff --git a/src/dom/svg/svgparser.h b/src/dom/svg/svgparser.h index 1b2b704da..9305a553a 100644 --- a/src/dom/svg/svgparser.h +++ b/src/dom/svg/svgparser.h @@ -71,7 +71,7 @@ public: /** * */ - Document *parse(const Document *sourceDoc); + SVGDocumentPtr parse(const DocumentPtr sourceDoc); @@ -115,7 +115,8 @@ protected: /** * */ - bool parseElement(ElementImpl *destElem, ElementImpl *sourceElem); + bool parseElement(SVGElementImplPtr destElem, + ElementImplPtr sourceElem); /** @@ -129,7 +130,7 @@ protected: int parselen; int lastPosition; - SVGDocumentImpl *doc; + SVGDocumentImplPtr doc; }; diff --git a/src/dom/views.h b/src/dom/views.h index 1d300d5d7..0b89b7555 100644 --- a/src/dom/views.h +++ b/src/dom/views.h @@ -305,7 +305,7 @@ public: /** * */ - virtual Node *getNodeArg() + virtual NodePtr getNodeArg() { return nodeArg; } @@ -346,7 +346,7 @@ public: protected: DOMString name; - Node *nodeArg; + NodePtr nodeArg; unsigned long offset; @@ -369,7 +369,7 @@ public: /** * */ - virtual Node *getNodeArg() + virtual NodePtr getNodeArg() { return nodeArg; } /** @@ -419,7 +419,7 @@ public: protected: - Node *nodeArg; + NodePtr nodeArg; std::vector matches; @@ -639,7 +639,7 @@ public: /** * */ - virtual Node *getNodeArg() + virtual NodePtr getNodeArg() { return nodeArg; } /** @@ -676,7 +676,7 @@ public: protected: - Node *nodeArg; + NodePtr nodeArg; long offset; @@ -763,7 +763,7 @@ public: virtual MatchContent createMatchContent(unsigned short test, const DOMString &name, unsigned long offset, - const Node *nodeArg) + const NodePtr nodeArg) { MatchContent ret; return ret; @@ -902,7 +902,7 @@ public: /** * */ - virtual void select(const Node *boundary, + virtual void select(const NodePtr boundary, unsigned long offset, bool extend, bool add) @@ -960,10 +960,10 @@ public: /** * */ - virtual Node *getContentPropertyNode(const DOMString &name) + virtual NodePtr getContentPropertyNode(const DOMString &name) throw(dom::DOMException) { - Node *val = NULL; + NodePtr val = NULL; return val; } @@ -1233,14 +1233,14 @@ public: /** * */ - virtual Node *getMatchNode() + virtual NodePtr getMatchNode() { return matchNode; } /** * */ - virtual void setMatchNode(const Node *val) - { matchNode = (Node *)val; } + virtual void setMatchNode(const NodePtr val) + { matchNode = (NodePtr )val; } /** * @@ -1257,14 +1257,14 @@ public: /** * */ - virtual Node *getMatchNodeR() + virtual NodePtr getMatchNodeR() { return matchNodeR; } /** * */ - virtual void setMatchNodeR(const Node *val) - { matchNodeR = (Node *)val; } + virtual void setMatchNodeR(const NodePtr val) + { matchNodeR = (NodePtr )val; } /** * @@ -1312,7 +1312,7 @@ public: /** * */ - virtual Node *getStartNode() + virtual NodePtr getStartNode() { return startNode; } /** @@ -1324,7 +1324,7 @@ public: /** * */ - virtual Node *getEndNode() + virtual NodePtr getEndNode() { return endNode; } /** @@ -1477,16 +1477,16 @@ protected: long matchYR; bool matchContent; bool matchRange; - Node * matchNode; + NodePtr matchNode; unsigned long matchOffset; - Node * matchNodeR; + NodePtr matchNodeR; unsigned long matchOffsetR; bool matchContainsSelected; bool matchContainsVisible; bool exists; - Node * startNode; + NodePtr startNode; unsigned long startOffset; - Node * endNode; + NodePtr endNode; unsigned long endOffset; long topOffset; long bottomOffset; @@ -1890,7 +1890,7 @@ public: /** * */ - virtual void select(const Node *boundary, + virtual void select(const NodePtr boundary, unsigned long offset, bool extend, bool add) diff --git a/src/dom/work/testdom.cpp b/src/dom/work/testdom.cpp index d3e8d99f3..bd6cf6bfb 100644 --- a/src/dom/work/testdom.cpp +++ b/src/dom/work/testdom.cpp @@ -57,7 +57,7 @@ bool doTest(char *filename) input.setStringData(buf); printf("######## PARSE ######################################\n"); - Document *doc = parser.parse(input); + DocumentPtr doc = parser.parse(input); if (!doc) { @@ -80,14 +80,11 @@ bool doTest(char *filename) printf("Nodes:%d\n", nodeCount); for (int i=0; i -typedef org::w3c::dom::Node Node; -typedef org::w3c::dom::NodeList NodeList; -typedef org::w3c::dom::DOMString DOMString; -typedef org::w3c::dom::Document Document; +typedef org::w3c::dom::Node Node; +typedef org::w3c::dom::NodePtr NodePtr; +typedef org::w3c::dom::NodeList NodeList; +typedef org::w3c::dom::DOMString DOMString; +typedef org::w3c::dom::Document Document; +typedef org::w3c::dom::DocumentPtr DocumentPtr; typedef org::w3c::dom::io::StdWriter StdWriter; typedef org::w3c::dom::ls::DOMImplementationLSImpl DOMImplementationLSImpl; typedef org::w3c::dom::ls::LSSerializer LSSerializer; -typedef org::w3c::dom::ls::LSOutput LSOutput; -typedef org::w3c::dom::ls::LSInput LSInput; -typedef org::w3c::dom::ls::LSParser LSParser; +typedef org::w3c::dom::ls::LSOutput LSOutput; +typedef org::w3c::dom::ls::LSInput LSInput; +typedef org::w3c::dom::ls::LSParser LSParser; typedef org::w3c::dom::xpath::XPathParser XPathParser; @@ -1355,7 +1357,7 @@ bool doStringTests() return true; } -void dumpDoc(Document *doc) +bool dumpDoc(DocumentPtr doc) { DOMImplementationLSImpl domImpl; LSSerializer &serializer = domImpl.createLSSerializer(); @@ -1363,6 +1365,8 @@ void dumpDoc(Document *doc) StdWriter writer; output.setCharacterStream(&writer); serializer.write(doc, output); + + return true; } @@ -1375,7 +1379,7 @@ bool doXmlTest(XpathTest *xpt) LSInput input = domImpl.createLSInput(); LSParser &parser = domImpl.createLSParser(0, ""); input.setStringData(xpt->xml); - Document *doc = parser.parse(input); + DocumentPtr doc = parser.parse(input); //### XPATH XPathParser xp; @@ -1385,13 +1389,12 @@ bool doXmlTest(XpathTest *xpt) NodeList list = xp.evaluate(doc, xpathStr); for (unsigned int i=0 ; igetNodeName().c_str()); } //dumpDoc(doc); - delete doc; return true; } diff --git a/src/dom/xmlreader.cpp b/src/dom/xmlreader.cpp index fbacf48f4..5e8184e4d 100644 --- a/src/dom/xmlreader.cpp +++ b/src/dom/xmlreader.cpp @@ -32,7 +32,6 @@ #include "xmlreader.h" #include "charclass.h" #include "domimpl.h" -#include "svg/svgimpl.h" #include #include @@ -302,27 +301,26 @@ int XmlReader::parseVersion(int p0) colNr += 5; bool quickCloseDummy; - Node *node = new NodeImpl(); + NodePtr node = new NodeImpl(); int p2 = parseAttributes(p, node, &quickCloseDummy); if (p2 < p) { - delete node; + //smart ptr!!do not delete node; return p0; } p = p2; //get the attributes that we need NamedNodeMap attributes = node->getAttributes(); - Node *attr = attributes.getNamedItem("version"); - if (attr) + NodePtr attr = attributes.getNamedItem("version"); + if (attr.get()) document->setXmlVersion(attr->getNodeValue()); attr = attributes.getNamedItem("encoding"); - if (attr) + if (attr.get()) { /*document->setXmlEncoding(attr->getNodeValue());*/ } attr = attributes.getNamedItem("standalone"); - if (attr) + if (attr.get()) document->setXmlStandalone((attr->getNodeValue() == "yes")); - delete node; //#now we should be pointing at '?>' if (!match(p, "?>")) @@ -352,7 +350,7 @@ int XmlReader::parseDoctype(int p0) p += 9; colNr += 9; - DocumentType *doctype = document->getDoctype(); + DocumentTypePtr doctype = document->getDoctype(); if (!doctype) return p0; @@ -427,7 +425,7 @@ int XmlReader::parseDoctype(int p0) /** * Expects '<' on startup, ends on char after '>' */ -int XmlReader::parseComment(int p0, Comment *comment) +int XmlReader::parseComment(int p0, CommentPtr comment) { int p = p0; @@ -461,7 +459,7 @@ int XmlReader::parseComment(int p0, Comment *comment) /** * */ -int XmlReader::parseCDATA(int p0, CDATASection *cdata) +int XmlReader::parseCDATA(int p0, CDATASectionPtr cdata) { int p = p0; @@ -497,7 +495,7 @@ int XmlReader::parseCDATA(int p0, CDATASection *cdata) /** * */ -int XmlReader::parseText(int p0, Text *text) +int XmlReader::parseText(int p0, TextPtr text) { int p = p0; @@ -537,7 +535,7 @@ int XmlReader::parseText(int p0, Text *text) * Parses attributes of a node. Should end pointing at either the * '?' of a version or doctype tag, or a '>' of a normal tag */ -int XmlReader::parseAttributes(int p0, Node *node, bool *quickClose) +int XmlReader::parseAttributes(int p0, NodePtr node, bool *quickClose) { *quickClose = false; @@ -595,7 +593,7 @@ int XmlReader::parseAttributes(int p0, Node *node, bool *quickClose) namespaceURI = XMLNSNAME; //## Now let us make the attribute and give it to the node - Attr *attr = document->createAttributeNS(namespaceURI, qualifiedName); + AttrPtr attr = document->createAttributeNS(namespaceURI, qualifiedName); attr->setValue(attrValue); node->getAttributes().setNamedItemNS(attr); @@ -634,7 +632,7 @@ int XmlReader::parseEntity(int p0, DOMString &buf) * Parse as a document, preserving the original structure as much as * possible */ -int XmlReader::parseNode(int p0, Node *node, int depth) +int XmlReader::parseNode(int p0, NodePtr node, int depth) { int p = p0; @@ -677,14 +675,14 @@ int XmlReader::parseNode(int p0, Node *node, int depth) //### COMMENT if (match(p, "