You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sc...@apache.org on 2017/07/05 18:52:15 UTC

svn commit: r1800911 - in /xerces/c/trunk: ./ samples/ samples/src/XInclude/ src/ src/xercesc/dom/impl/ src/xercesc/util/NetAccessors/ tests/ tests/src/XSTSHarness/

Author: scantor
Date: Wed Jul  5 18:52:15 2017
New Revision: 1800911

URL: http://svn.apache.org/viewvc?rev=1800911&view=rev
Log:
XERCESC-2088 - Fix undefined casting behavior in DOM

Added:
    xerces/c/trunk/src/xercesc/dom/impl/DOMNodeBase.hpp
Modified:
    xerces/c/trunk/   (props changed)
    xerces/c/trunk/samples/   (props changed)
    xerces/c/trunk/samples/src/XInclude/   (props changed)
    xerces/c/trunk/src/CMakeLists.txt
    xerces/c/trunk/src/Makefile.am
    xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMCasts.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMChildNode.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMCommentImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMCommentImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentFragmentImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentFragmentImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMEntityImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMEntityImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMEntityReferenceImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMEntityReferenceImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMNodeImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMNodeImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMNotationImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMNotationImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMProcessingInstructionImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMProcessingInstructionImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.hpp
    xerces/c/trunk/src/xercesc/util/NetAccessors/   (props changed)
    xerces/c/trunk/tests/   (props changed)
    xerces/c/trunk/tests/src/XSTSHarness/   (props changed)

Propchange: xerces/c/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jul  5 18:52:15 2017
@@ -18,3 +18,4 @@ xerces-c.pc
 .cproject
 .vscode
 .settings
+test-results.log

Propchange: xerces/c/trunk/samples/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jul  5 18:52:15 2017
@@ -15,4 +15,5 @@ SAXPrint
 SCMPrint
 SEnumVal
 StdInParse
+XInclude
 Makefile.in

Propchange: xerces/c/trunk/samples/src/XInclude/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jul  5 18:52:15 2017
@@ -1 +1 @@
-.deps
+.*

Modified: xerces/c/trunk/src/CMakeLists.txt
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/CMakeLists.txt?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/CMakeLists.txt (original)
+++ xerces/c/trunk/src/CMakeLists.txt Wed Jul  5 18:52:15 2017
@@ -148,6 +148,7 @@ set(domimpl_headers
   xercesc/dom/impl/DOMImplementationListImpl.hpp
   xercesc/dom/impl/DOMLocatorImpl.hpp
   xercesc/dom/impl/DOMNamedNodeMapImpl.hpp
+  xercesc/dom/impl/DOMNodeBase.hpp
   xercesc/dom/impl/DOMNodeIDMap.hpp
   xercesc/dom/impl/DOMNodeImpl.hpp
   xercesc/dom/impl/DOMNodeIteratorImpl.hpp

Modified: xerces/c/trunk/src/Makefile.am
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/Makefile.am?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/Makefile.am (original)
+++ xerces/c/trunk/src/Makefile.am Wed Jul  5 18:52:15 2017
@@ -296,6 +296,7 @@ domimpl_headers	= \
 	xercesc/dom/impl/DOMImplementationListImpl.hpp \
 	xercesc/dom/impl/DOMLocatorImpl.hpp \
 	xercesc/dom/impl/DOMNamedNodeMapImpl.hpp \
+	xercesc/dom/impl/DOMNodeBase.hpp \
 	xercesc/dom/impl/DOMNodeIDMap.hpp \
 	xercesc/dom/impl/DOMNodeImpl.hpp \
 	xercesc/dom/impl/DOMNodeIteratorImpl.hpp \

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.cpp Wed Jul  5 18:52:15 2017
@@ -31,7 +31,7 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 DOMAttrImpl::DOMAttrImpl(DOMDocument *ownerDoc, const XMLCh *aName)
-    : fNode(ownerDoc), fParent (ownerDoc), fSchemaType(0)
+    : fNode(this, ownerDoc), fParent(this, ownerDoc), fSchemaType(0)
 {
     DOMDocumentImpl *docImpl = (DOMDocumentImpl *)ownerDoc;
     fName = docImpl->getPooledString(aName);
@@ -40,8 +40,8 @@ DOMAttrImpl::DOMAttrImpl(DOMDocument *ow
 
 DOMAttrImpl::DOMAttrImpl(const DOMAttrImpl &other, bool /*deep*/)
     : DOMAttr(other)
-    , fNode(other.fNode)
-    , fParent (other.fParent)
+    , fNode(this, other.fNode)
+    , fParent(this, other.fParent)
     , fName(other.fName)
     , fSchemaType(other.fSchemaType)
 {
@@ -359,4 +359,8 @@ void* DOMAttrImpl::getFeature(const XMLC
            bool             DOMAttrImpl::isDefaultNamespace(const XMLCh* namespaceURI) const {return fNode.isDefaultNamespace(namespaceURI); }
            const XMLCh*     DOMAttrImpl::lookupNamespaceURI(const XMLCh* prefix) const  {return fNode.lookupNamespaceURI(prefix); }
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMAttrImpl);
+DOMPARENTIMPL_IMPL(DOMAttrImpl);
+
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.hpp Wed Jul  5 18:52:15 2017
@@ -33,6 +33,7 @@
 
 
 #include <xercesc/util/XercesDefs.hpp>
+#include "DOMNodeBase.hpp"
 #include "DOMParentNode.hpp"
 #include "DOMNodeImpl.hpp"
 #include "DOMDocumentImpl.hpp"
@@ -45,7 +46,7 @@ XERCES_CPP_NAMESPACE_BEGIN
 class DOMElementImpl;
 class DOMTypeInfoImpl;
 
-class CDOM_EXPORT DOMAttrImpl: public DOMAttr {
+class CDOM_EXPORT DOMAttrImpl: public DOMAttr, public HasDOMNodeImpl, public HasDOMParentImpl {
 
 public:
     DOMNodeImpl        fNode;
@@ -64,6 +65,10 @@ public:
      // Add all functions that are pure virtual in DOMNODE
     DOMNODE_FUNCTIONS;
 
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMPARENTIMPL_DECL;
+
 public:
     virtual const XMLCh *       getName() const;
     virtual bool                getSpecified() const;

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp Wed Jul  5 18:52:15 2017
@@ -32,24 +32,22 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
-DOMCDATASectionImpl::DOMCDATASectionImpl(DOMDocument *ownerDoc,
-                                   const XMLCh *dat)
-    : fNode(ownerDoc), fCharacterData(ownerDoc, dat)
+DOMCDATASectionImpl::DOMCDATASectionImpl(DOMDocument *ownerDoc, const XMLCh *dat)
+    : fNode(this, ownerDoc), fCharacterData(ownerDoc, dat)
 {
     fNode.setIsLeafNode(true);
 }
 
-DOMCDATASectionImpl::
-DOMCDATASectionImpl(DOMDocument *ownerDoc, const XMLCh* data, XMLSize_t n)
-    : fNode(ownerDoc), fCharacterData(ownerDoc, data, n)
+DOMCDATASectionImpl::DOMCDATASectionImpl(DOMDocument *ownerDoc, const XMLCh* data, XMLSize_t n)
+    : fNode(this, ownerDoc), fCharacterData(ownerDoc, data, n)
 {
     fNode.setIsLeafNode(true);
 }
 
 DOMCDATASectionImpl::DOMCDATASectionImpl(const DOMCDATASectionImpl &other, bool /*deep*/)
     : DOMCDATASection(other),
-    fNode(*castToNodeImpl(&other)),
-    fChild(*castToChildImpl(&other)),
+    fNode(this, other.fNode),
+    fChild(other.fChild),
     fCharacterData(other.fCharacterData)
 {
     // revisit.  Something nees to make "deep" work.
@@ -318,4 +316,8 @@ void DOMCDATASectionImpl::release()
            void             DOMCDATASectionImpl::setData(const XMLCh *data)              {fCharacterData.setData(this, data);}
            void             DOMCDATASectionImpl::setNodeValue(const XMLCh  *nodeValue)   {fCharacterData.setNodeValue (this, nodeValue); }
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMCDATASectionImpl);
+DOMCHILDIMPL_IMPL(DOMCDATASectionImpl);
+
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp Wed Jul  5 18:52:15 2017
@@ -34,6 +34,7 @@
 
 #include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/dom/DOMCDATASection.hpp>
+#include "DOMNodeBase.hpp"
 #include "DOMNodeImpl.hpp"
 #include "DOMChildNode.hpp"
 #include "DOMParentNode.hpp"
@@ -42,7 +43,7 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 
-class CDOM_EXPORT DOMCDATASectionImpl: public DOMCDATASection {
+class CDOM_EXPORT DOMCDATASectionImpl: public DOMCDATASection, public HasDOMNodeImpl, public HasDOMChildImpl {
 protected:
     DOMNodeImpl           fNode;
     DOMChildNode          fChild;
@@ -71,6 +72,10 @@ public:
     // Declare all of the functions from DOMNode.
     DOMNODE_FUNCTIONS;
 
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMCHILDIMPL_DECL;
+
 public:
     // Functions introduced by DOMCharacterData
     virtual const XMLCh* getData() const;

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMCasts.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMCasts.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMCasts.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMCasts.hpp Wed Jul  5 18:52:15 2017
@@ -33,120 +33,75 @@
 
 //
 //  Define inline casting functions to convert from
-//    (DOMNode *) to DOMParentNode or DOMChildNode *.
+//    (DOMNode*) to the embedded instances of DOMNodeImpl,
+//    DOMParentNode, and DOMChildNode.
 //
-//  This requires knowledge of the structure of the fields of
-//   for all node types.  There are three categories -
+//  Each type of embedded object corresponds to a HasXXX virtual
+//  interface class that a given DOM implementation class will
+//  support to expose its embedded object(s) to other implementation
+//  classes.
 //
-//  Nodetypes that can have children and can be a child themselves.
-//    e.g.  Elements
-//
-//       Object
-//           DOMNodeImpl     fNode;
-//           DOMParentNode   fParent;
-//           DOMChildNode    fChild;
-//             ...            // other fields, depending on node type.
-//
-//  Nodetypes that can not have children, e.g. TEXT
-//
-//       Object
-//           DOMNodeImpl     fNode;
-//           DOMChildNode    fChild;
-//              ...            // other fields, depending on node type
-//
-//  Nodetypes that can not be a child of other nodes, but that can
-//  have children (are a parent)  e.g. ATTR
-//       Object
-//           DOMNodeImpl     fNode;
-//           DOMParentNode   fParent
-//               ...           // other fields, depending on node type
-//
-//   The casting functions make these assumptions:
-//      1.  The cast is possible.  Using code will not attempt to
-//          cast to something that does not exist, such as the child
-//          part of an ATTR
-//
-//      2.  The nodes belong to this implementation.
-//
-//    Some of the casts use the LEAFNODE flag in the common fNode part to
-//    determine whether an fParent field exists, and thus the
-//    position of the fChild part within the node.
-//
-//  These functions also cast off const.  It was either do that, or make
-//  a second overloaded set that took and returned const arguements.
-//
-
-//
-//	Note that using offsetof, or taking the offset of an object member at
-//	a 0 address, is now undefined in C++. And gcc now warns about this behavior.
-//	This is because doing do so is unreliable for some types of objects.
-//		See: http://gcc.gnu.org/ml/gcc/2004-06/msg00227.html
-//		   : http://gcc.gnu.org/ml/gcc-bugs/2000-03/msg00805.html
-//  The casting code below works around gcc's warnings by using a dummy
-//	pointer, which the compiler cannot tell is null. The defeats the warning,
-//	but also masks the potential problem.
-//	The gcc option -Wno-invalid-offsetof may also be used to turn off this warning.
+//  This replaces the previous implementation that relied upon unsafe
+//  casts and member offsets that rely on unspecified behavior in C++,
+//  with a hopefully small cost in memory and performance.
 //
 
+#include <xercesc/dom/DOMException.hpp>
+#include "DOMNodeBase.hpp"
 #include "DOMElementImpl.hpp"
 #include "DOMTextImpl.hpp"
 
 XERCES_CPP_NAMESPACE_BEGIN
 
 
-static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
+static inline const DOMNodeImpl *castToNodeImpl(const DOMNode *p)
 {
-    // Note: hairy cast which is used for all node types, not just
-    // DOMElementImpl.
-    DOMElementImpl *pE = const_cast<DOMElementImpl *>(static_cast<const DOMElementImpl *>(p));
-    return &(pE->fNode);
+    const HasDOMNodeImpl* pE = dynamic_cast<const HasDOMNodeImpl*>(p);
+    if (!pE || !pE->getNodeImpl()) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, XMLPlatformUtils::fgMemoryManager);
+    }
+    return pE->getNodeImpl();
 }
 
-
-static inline DOMParentNode *castToParentImpl(const DOMNode *p) {
-    // Note: hairy cast which is used for all node types, not just
-    // DOMElementImpl.
-    DOMElementImpl *pE = const_cast<DOMElementImpl *>(static_cast<const DOMElementImpl *>(p));
-    return &(pE->fParent);
+static inline DOMNodeImpl *castToNodeImpl(DOMNode *p)
+{
+    HasDOMNodeImpl *pE = dynamic_cast<HasDOMNodeImpl*>(p);
+    if (!pE || !pE->getNodeImpl()) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, XMLPlatformUtils::fgMemoryManager);
+    }
+    return pE->getNodeImpl();
 }
 
-
-static inline DOMChildNode *castToChildImpl(const DOMNode *p) {
-    // Note: hairy cast which is used for all node types, not just
-    // DOMElementImpl.
-    DOMElementImpl *pE = const_cast<DOMElementImpl *>(static_cast<const DOMElementImpl *>(p));
-    if (pE->fNode.isLeafNode())  {
-        // Note: hairy cast which is used for all leaf node types, not just
-        // DOMTextImpl.
-        DOMTextImpl *pT = const_cast<DOMTextImpl *>(static_cast<const DOMTextImpl *>(p));
-        return &(pT->fChild);
+static inline const DOMParentNode *castToParentImpl(const DOMNode *p) {
+    const HasDOMParentImpl *pE = dynamic_cast<const HasDOMParentImpl*>(p);
+    if (!pE || !pE->getParentNodeImpl()) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, XMLPlatformUtils::fgMemoryManager);
     }
-    return &(pE->fChild);
+    return pE->getParentNodeImpl();
 }
 
-
-static inline DOMNode *castToNode(const DOMParentNode *p ) {
-	DOMElementImpl* dummy = 0;
-    XMLSize_t parentOffset = (char *)&(dummy->fParent) - (char *)dummy;
-    char *retPtr = (char *)p - parentOffset;
-    return reinterpret_cast<DOMNode *>(retPtr);
+static inline DOMParentNode *castToParentImpl(DOMNode *p) {
+    HasDOMParentImpl *pE = dynamic_cast<HasDOMParentImpl*>(p);
+    if (!pE || !pE->getParentNodeImpl()) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, XMLPlatformUtils::fgMemoryManager);
+    }
+    return pE->getParentNodeImpl();
 }
 
-static inline DOMNode *castToNode(const DOMNodeImpl *p) {
-	DOMElementImpl* dummy = 0;
-    XMLSize_t nodeImplOffset = (char *)&(dummy->fNode) - (char *)dummy;
-    char *retPtr = (char *)p - nodeImplOffset;
-    return reinterpret_cast<DOMNode *>(retPtr);
+static inline const DOMChildNode *castToChildImpl(const DOMNode *p) {
+    const HasDOMChildImpl *pE = dynamic_cast<const HasDOMChildImpl*>(p);
+    if (!pE || !pE->getChildNodeImpl()) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, XMLPlatformUtils::fgMemoryManager);
+    }
+    return pE->getChildNodeImpl();
 }
 
-
-static inline DOMNodeImpl *castToNodeImpl(const DOMParentNode *p)
-{
-	DOMElementImpl* dummy = 0;
-    XMLSize_t nodeImplOffset = (char *)&(dummy->fNode) - (char *)dummy;
-    XMLSize_t parentOffset = (char *)&(dummy->fParent) - (char *)dummy;
-    char *retPtr = (char *)p - parentOffset + nodeImplOffset;
-    return reinterpret_cast<DOMNodeImpl *>(retPtr);
+static inline DOMChildNode *castToChildImpl(DOMNode *p) {
+    HasDOMChildImpl *pE = dynamic_cast<HasDOMChildImpl*>(p);
+    if (!pE || !pE->getChildNodeImpl()) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, XMLPlatformUtils::fgMemoryManager);
+    }
+    return pE->getChildNodeImpl();
 }
 
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMChildNode.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMChildNode.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMChildNode.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMChildNode.cpp Wed Jul  5 18:52:15 2017
@@ -64,7 +64,7 @@ DOMNode * DOMChildNode::getParentNode(co
 {
     // if we have an owner, ownerNode is our parent, otherwise it's
     // our ownerDocument and we don't have a parent
-    DOMNodeImpl *thisNodeImpl = castToNodeImpl(thisNode);
+    const DOMNodeImpl *thisNodeImpl = castToNodeImpl(thisNode);
     return thisNodeImpl->isOwned() ? thisNodeImpl->fOwnerNode : 0;
 }
 

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMCommentImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMCommentImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMCommentImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMCommentImpl.cpp Wed Jul  5 18:52:15 2017
@@ -32,7 +32,7 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 DOMCommentImpl::DOMCommentImpl(DOMDocument *ownerDoc, const XMLCh *dat)
-    : fNode(ownerDoc),  fCharacterData(ownerDoc, dat)
+    : fNode(this, ownerDoc),  fCharacterData(ownerDoc, dat)
 {
     fNode.setIsLeafNode(true);
 }
@@ -40,7 +40,7 @@ DOMCommentImpl::DOMCommentImpl(DOMDocume
 
 DOMCommentImpl::DOMCommentImpl(const DOMCommentImpl &other, bool)
 
-    : fNode(other.fNode),
+    : fNode(this, other.fNode),
     fChild(other.fChild),
     fCharacterData(other.fCharacterData)
 {
@@ -186,4 +186,8 @@ DOMComment *DOMCommentImpl::splitText(XM
            void             DOMCommentImpl::setData(const XMLCh *data)              {fCharacterData.setData(this, data);}
            void             DOMCommentImpl::setNodeValue(const XMLCh  *nodeValue)   {fCharacterData.setNodeValue (this, nodeValue); }
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMCommentImpl);
+DOMCHILDIMPL_IMPL(DOMCommentImpl);
+
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMCommentImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMCommentImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMCommentImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMCommentImpl.hpp Wed Jul  5 18:52:15 2017
@@ -35,6 +35,7 @@
 #include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/dom/DOMComment.hpp>
 
+#include "DOMNodeBase.hpp"
 #include "DOMNodeImpl.hpp"
 #include "DOMChildNode.hpp"
 #include "DOMCharacterDataImpl.hpp"
@@ -42,7 +43,7 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 
-class CDOM_EXPORT DOMCommentImpl: public DOMComment {
+class CDOM_EXPORT DOMCommentImpl: public DOMComment, public HasDOMNodeImpl, public HasDOMChildImpl {
 public:
     DOMNodeImpl            fNode;
     DOMChildNode           fChild;
@@ -57,6 +58,10 @@ public:
     // Declare all of the functions from DOMNode.
     DOMNODE_FUNCTIONS;
 
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMCHILDIMPL_DECL;
+
 public:
     // Functions from DOMCharacterData
     virtual void          appendData(const  XMLCh *data);

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentFragmentImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentFragmentImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentFragmentImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentFragmentImpl.cpp Wed Jul  5 18:52:15 2017
@@ -29,14 +29,14 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 DOMDocumentFragmentImpl::DOMDocumentFragmentImpl(DOMDocument *masterDoc)
-    : fNode(masterDoc), fParent(masterDoc)
+    : fNode(this, masterDoc), fParent(this, masterDoc)
 {
 }
 
 
 DOMDocumentFragmentImpl::DOMDocumentFragmentImpl(const DOMDocumentFragmentImpl &other,
                                            bool deep)
-    : fNode(other.fNode), fParent(other.fParent)
+    : fNode(this, other.fNode), fParent(this, other.fParent)
 {
     if (deep)
         castToParentImpl(this)->cloneChildren(&other);
@@ -134,4 +134,8 @@ void DOMDocumentFragmentImpl::release()
            const XMLCh*     DOMDocumentFragmentImpl::lookupNamespaceURI(const XMLCh* prefix) const  {return fNode.lookupNamespaceURI(prefix); }
            void*            DOMDocumentFragmentImpl::getFeature(const XMLCh* feature, const XMLCh* version) const {return fNode.getFeature(feature, version); }
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMDocumentFragmentImpl);
+DOMPARENTIMPL_IMPL(DOMDocumentFragmentImpl);
+
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentFragmentImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentFragmentImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentFragmentImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentFragmentImpl.hpp Wed Jul  5 18:52:15 2017
@@ -33,13 +33,15 @@
 
 #include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/dom/DOMDocumentFragment.hpp>
+#include "DOMNodeBase.hpp"
 #include "DOMParentNode.hpp"
 #include "DOMNodeImpl.hpp"
 
 XERCES_CPP_NAMESPACE_BEGIN
 
 
-class CDOM_EXPORT DOMDocumentFragmentImpl: public DOMDocumentFragment {
+class CDOM_EXPORT DOMDocumentFragmentImpl: public DOMDocumentFragment,
+        public HasDOMNodeImpl, public HasDOMParentImpl {
 protected:
     DOMNodeImpl     fNode;
     DOMParentNode   fParent;
@@ -61,6 +63,10 @@ public:
 public:
     // Declare all of the functions from DOMNode.
     DOMNODE_FUNCTIONS;
+
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMPARENTIMPL_DECL;
 };
 
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp Wed Jul  5 18:52:15 2017
@@ -79,8 +79,8 @@ void XMLInitializer::initializeDOMHeap (
 //                             allocate.
 //
 DOMDocumentImpl::DOMDocumentImpl(DOMImplementation* domImpl, MemoryManager* const manager)
-    : fNode(this),
-      fParent(this),
+    : fNode(this, this),
+      fParent(this, this),
       fNodeIDMap(0),
       fInputEncoding(0),
       fXmlEncoding(0),
@@ -122,8 +122,8 @@ DOMDocumentImpl::DOMDocumentImpl(const X
                                DOMDocumentType *doctype,
                                DOMImplementation* domImpl,
                                MemoryManager* const manager)
-    : fNode(this),
-      fParent(this),
+    : fNode(this, this),
+      fParent(this, this),
       fNodeIDMap(0),
       fInputEncoding(0),
       fXmlEncoding(0),
@@ -709,7 +709,7 @@ void DOMDocumentImpl::removeRange(DOMRan
     ????? It feels like there must be a more efficient solution,
     but for the life of me I can't think what it would be.
 */
-bool DOMDocumentImpl::isKidOK(DOMNode *parent, DOMNode *child)
+bool DOMDocumentImpl::isKidOK(const DOMNode *parent, const DOMNode *child)
 {
       static int kidOK[14];
 
@@ -797,6 +797,9 @@ int             DOMDocumentImpl::changes
            const XMLCh*     DOMDocumentImpl::lookupNamespaceURI(const XMLCh* prefix) const  {return fNode.lookupNamespaceURI(prefix); }
 
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMDocumentImpl);
+DOMPARENTIMPL_IMPL(DOMDocumentImpl);
 
 
 //-----------------------------------------------------------------------

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.hpp Wed Jul  5 18:52:15 2017
@@ -40,6 +40,7 @@
 #include <xercesc/dom/DOMDocument.hpp>
 #include <xercesc/dom/DOMUserDataHandler.hpp>
 #include <xercesc/dom/DOMMemoryManager.hpp>
+#include "DOMNodeBase.hpp"
 #include "DOMNodeImpl.hpp"
 #include "DOMStringPool.hpp"
 #include "DOMParentNode.hpp"
@@ -79,7 +80,8 @@ typedef RefVectorOf<DOMNodeIteratorImpl>
 typedef KeyRefPair<void, DOMUserDataHandler> DOMUserDataRecord;
 typedef RefStackOf<DOMNode>               DOMNodePtr;
 
-class CDOM_EXPORT DOMDocumentImpl: public XMemory, public DOMMemoryManager, public DOMDocument {
+class CDOM_EXPORT DOMDocumentImpl: public XMemory, public DOMMemoryManager, public DOMDocument,
+        public HasDOMNodeImpl, public HasDOMParentImpl {
 public:
     // -----------------------------------------------------------------------
     //  data
@@ -103,6 +105,10 @@ public:
     // Add all functions that are pure virtual in DOMNODE
     DOMNODE_FUNCTIONS;
 
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMPARENTIMPL_DECL;
+
 public:
     // Add all functions that are pure virtual in DOMDocument
     virtual DOMAttr*             createAttribute(const XMLCh *name);
@@ -251,7 +257,7 @@ public:
     //Return the index > 0 of ':' in the given qualified name qName="prefix:localName".
     //Return 0 if there is no ':', or -1 if qName is malformed such as ":abcd".
     static  int                  indexofQualifiedName(const XMLCh * qName);
-    static  bool                 isKidOK(DOMNode *parent, DOMNode *child);
+    static  bool                 isKidOK(const DOMNode *parent, const DOMNode *child);
 
     inline DOMNodeIDMap*         getNodeIDMap() {return fNodeIDMap;};
 

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp Wed Jul  5 18:52:15 2017
@@ -60,8 +60,8 @@ void XMLInitializer::terminateDOMDocumen
 DOMDocumentTypeImpl::DOMDocumentTypeImpl(DOMDocument *ownerDoc,
                                    const XMLCh *dtName,
                                    bool heap)
-    : fNode(ownerDoc),
-    fParent(ownerDoc),
+    : fNode(this, ownerDoc),
+    fParent(this, ownerDoc),
     fName(0),
     fEntities(0),
     fNotations(0),
@@ -97,8 +97,8 @@ DOMDocumentTypeImpl::DOMDocumentTypeImpl
                                    const XMLCh *pubId,
                                    const XMLCh *sysId,
                                    bool heap)
-    : fNode(ownerDoc),
-    fParent(ownerDoc),
+    : fNode(this, ownerDoc),
+    fParent(this, ownerDoc),
     fName(0),
     fEntities(0),
     fNotations(0),
@@ -169,8 +169,8 @@ DOMDocumentTypeImpl::DOMDocumentTypeImpl
 
 
 DOMDocumentTypeImpl::DOMDocumentTypeImpl(const DOMDocumentTypeImpl &other, bool heap, bool deep)
-    : fNode(other.fNode),
-    fParent(other.fParent),
+    : fNode(this, other.fNode),
+    fParent(this, other.fParent),
     fChild(other.fChild),
     fName(0),
     fEntities(0),
@@ -440,6 +440,11 @@ void DOMDocumentTypeImpl::release()
            bool             DOMDocumentTypeImpl::isDefaultNamespace(const XMLCh* namespaceURI) const {return fNode.isDefaultNamespace(namespaceURI); }
            const XMLCh*     DOMDocumentTypeImpl::lookupNamespaceURI(const XMLCh* prefix) const  {return fNode.lookupNamespaceURI(prefix); }
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMDocumentTypeImpl);
+DOMPARENTIMPL_IMPL(DOMDocumentTypeImpl);
+DOMCHILDIMPL_IMPL(DOMDocumentTypeImpl);
+
 
 bool DOMDocumentTypeImpl::isEqualNode(const DOMNode* arg) const
 {

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp Wed Jul  5 18:52:15 2017
@@ -35,6 +35,7 @@
 
 #include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/dom/DOMDocumentType.hpp>
+#include "DOMNodeBase.hpp"
 #include "DOMNodeImpl.hpp"
 #include "DOMChildNode.hpp"
 #include "DOMParentNode.hpp"
@@ -44,7 +45,8 @@ XERCES_CPP_NAMESPACE_BEGIN
 
 class DOMNamedNodeMapImpl;
 
-class CDOM_EXPORT DOMDocumentTypeImpl: public DOMDocumentType {
+class CDOM_EXPORT DOMDocumentTypeImpl: public DOMDocumentType,
+        public HasDOMNodeImpl, public HasDOMParentImpl, public HasDOMChildImpl {
 protected:
     DOMNodeImpl          fNode;
     DOMParentNode        fParent;
@@ -81,6 +83,11 @@ public:
     // Declare all of the functions from DOMNode.
     DOMNODE_FUNCTIONS;
 
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMPARENTIMPL_DECL;
+    DOMCHILDIMPL_DECL;
+
 public:
     virtual void setOwnerDocument(DOMDocument *doc);
     virtual DOMNamedNodeMap * getEntities() const;

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.cpp Wed Jul  5 18:52:15 2017
@@ -43,7 +43,7 @@ XERCES_CPP_NAMESPACE_BEGIN
 class DOMAttr;
 
 DOMElementImpl::DOMElementImpl(DOMDocument *ownerDoc, const XMLCh *eName)
-    : fNode(ownerDoc), fParent(ownerDoc), fAttributes(0), fDefaultAttributes(0)
+    : fNode(this, ownerDoc), fParent(this, ownerDoc), fAttributes(0), fDefaultAttributes(0)
 {
     DOMDocumentImpl *docImpl = (DOMDocumentImpl *)ownerDoc;
     fName = docImpl->getPooledString(eName);
@@ -60,8 +60,8 @@ DOMElementImpl::DOMElementImpl(DOMDocume
 
 DOMElementImpl::DOMElementImpl(const DOMElementImpl &other, bool deep)
     : DOMElement(other),
-      fNode (other.fParent.fOwnerDocument),
-      fParent (other.fParent.fOwnerDocument),
+      fNode(this, other.fParent.fOwnerDocument),
+      fParent(this, other.fParent.fOwnerDocument),
       fAttributes(0),
       fDefaultAttributes(0)
 {
@@ -579,7 +579,10 @@ const XMLCh* DOMElementImpl::getBaseURI(
            const XMLCh*     DOMElementImpl::lookupNamespaceURI(const XMLCh* prefix) const  {return fNode.lookupNamespaceURI(prefix); }
            void*            DOMElementImpl::getFeature(const XMLCh* feature, const XMLCh* version) const {return fNode.getFeature(feature, version); }
 
-
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMElementImpl);
+DOMPARENTIMPL_IMPL(DOMElementImpl);
+DOMCHILDIMPL_IMPL(DOMElementImpl);
 
 bool DOMElementImpl::isEqualNode(const DOMNode* arg) const
 {

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.hpp Wed Jul  5 18:52:15 2017
@@ -36,6 +36,7 @@
 #include <xercesc/util/XMLString.hpp>
 #include <xercesc/dom/DOMElement.hpp>
 
+#include "DOMNodeBase.hpp"
 #include "DOMChildNode.hpp"
 #include "DOMNodeImpl.hpp"
 #include "DOMParentNode.hpp"
@@ -52,7 +53,8 @@ class DOMDocument;
 
 
 
-class CDOM_EXPORT DOMElementImpl: public DOMElement {
+class CDOM_EXPORT DOMElementImpl: public DOMElement,
+        public HasDOMNodeImpl, public HasDOMParentImpl, public HasDOMChildImpl {
 public:
     DOMNodeImpl       fNode;
     DOMParentNode     fParent;
@@ -71,6 +73,11 @@ public:
     // Declare functions from DOMNode.  They all must be implemented by this class
     DOMNODE_FUNCTIONS;
 
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMPARENTIMPL_DECL;
+    DOMCHILDIMPL_DECL;
+
 public:
     // Functions introduced on Element...
     virtual const XMLCh*      getAttribute(const XMLCh *name) const;

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMEntityImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMEntityImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMEntityImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMEntityImpl.cpp Wed Jul  5 18:52:15 2017
@@ -28,8 +28,8 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 DOMEntityImpl::DOMEntityImpl(DOMDocument *ownerDoc, const XMLCh *eName)
-   : fNode(ownerDoc),
-     fParent(ownerDoc),
+   : fNode(this, ownerDoc),
+     fParent(this, ownerDoc),
      fPublicId(0),
      fSystemId(0),
      fNotationName(0),
@@ -47,8 +47,8 @@ DOMEntityImpl::DOMEntityImpl(DOMDocument
 
 DOMEntityImpl::DOMEntityImpl(const DOMEntityImpl &other, bool deep)
     : DOMEntity(other),
-      fNode(other.fNode),
-      fParent(other.fParent),
+      fNode(this, other.fNode),
+      fParent(this, other.fParent),
       fName(other.fName),
       fPublicId(other.fPublicId),
       fSystemId(other.fSystemId),
@@ -263,6 +263,9 @@ void DOMEntityImpl::release()
            const XMLCh*     DOMEntityImpl::lookupNamespaceURI(const XMLCh* prefix) const  {return fNode.lookupNamespaceURI(prefix); }
            void*            DOMEntityImpl::getFeature(const XMLCh* feature, const XMLCh* version) const {return fNode.getFeature(feature, version); }
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMEntityImpl);
+DOMPARENTIMPL_IMPL(DOMEntityImpl);
 
 //Introduced in DOM Level 3
 const XMLCh* DOMEntityImpl::getInputEncoding() const {

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMEntityImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMEntityImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMEntityImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMEntityImpl.hpp Wed Jul  5 18:52:15 2017
@@ -32,6 +32,7 @@
 //
 
 #include <xercesc/util/XercesDefs.hpp>
+#include "DOMNodeBase.hpp"
 #include "DOMNodeImpl.hpp"
 #include "DOMParentNode.hpp"
 #include <xercesc/dom/DOMEntity.hpp>
@@ -41,7 +42,7 @@ XERCES_CPP_NAMESPACE_BEGIN
 
 class    DOMEntityReference;
 
-class CDOM_EXPORT DOMEntityImpl: public DOMEntity {
+class CDOM_EXPORT DOMEntityImpl: public DOMEntity, public HasDOMNodeImpl, public HasDOMParentImpl {
 protected:
     DOMNodeImpl      fNode;
     DOMParentNode    fParent;
@@ -73,6 +74,10 @@ public:
     // Declare all of the functions from DOMNode.
     DOMNODE_FUNCTIONS;
 
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMPARENTIMPL_DECL;
+
 public:
     virtual const XMLCh *   getPublicId() const;
     virtual const XMLCh *   getSystemId() const;

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMEntityReferenceImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMEntityReferenceImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMEntityReferenceImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMEntityReferenceImpl.cpp Wed Jul  5 18:52:15 2017
@@ -32,7 +32,7 @@ XERCES_CPP_NAMESPACE_BEGIN
 
 DOMEntityReferenceImpl::DOMEntityReferenceImpl(DOMDocument *ownerDoc,
                                          const XMLCh *entityName)
-    : fNode(ownerDoc), fParent(ownerDoc), fBaseURI(0)
+    : fNode(this, ownerDoc), fParent(this, ownerDoc), fBaseURI(0)
 {
     fName = ((DOMDocumentImpl*)fParent.fOwnerDocument)->getPooledString(entityName);
     // EntityReference behaves as a read-only node, since its contents
@@ -61,7 +61,7 @@ DOMEntityReferenceImpl::DOMEntityReferen
 DOMEntityReferenceImpl::DOMEntityReferenceImpl(DOMDocument *ownerDoc,
                                          const XMLCh *entityName,
                                          bool cloneChild)
-    : fNode(ownerDoc), fParent(ownerDoc), fBaseURI(0)
+    : fNode(this, ownerDoc), fParent(this, ownerDoc), fBaseURI(0)
 {
     fName = ((DOMDocumentImpl*)fParent.fOwnerDocument)->getPooledString(entityName);
     // EntityReference behaves as a read-only node, since its contents
@@ -88,11 +88,10 @@ DOMEntityReferenceImpl::DOMEntityReferen
     fNode.setReadOnly(true, true);
 }
 
-DOMEntityReferenceImpl::DOMEntityReferenceImpl(const DOMEntityReferenceImpl &other,
-                                         bool deep)
+DOMEntityReferenceImpl::DOMEntityReferenceImpl(const DOMEntityReferenceImpl &other, bool deep)
     : DOMEntityReference(other),
-      fNode(other.fNode),
-      fParent(other.fParent),
+      fNode(this, other.fNode),
+      fParent(this, other.fParent),
       fChild(other.fChild),
       fName(other.fName),
       fBaseURI(other.fBaseURI)
@@ -220,4 +219,9 @@ const XMLCh* DOMEntityReferenceImpl::get
            const XMLCh*     DOMEntityReferenceImpl::lookupNamespaceURI(const XMLCh* prefix) const  {return fNode.lookupNamespaceURI(prefix); }
            void*            DOMEntityReferenceImpl::getFeature(const XMLCh* feature, const XMLCh* version) const {return fNode.getFeature(feature, version); }
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMEntityReferenceImpl);
+DOMPARENTIMPL_IMPL(DOMEntityReferenceImpl);
+DOMCHILDIMPL_IMPL(DOMEntityReferenceImpl);
+
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMEntityReferenceImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMEntityReferenceImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMEntityReferenceImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMEntityReferenceImpl.hpp Wed Jul  5 18:52:15 2017
@@ -33,7 +33,7 @@
 
 #include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/dom/DOMEntityReference.hpp>
-
+#include "DOMNodeBase.hpp"
 #include "DOMParentNode.hpp"
 #include "DOMChildNode.hpp"
 #include "DOMNodeImpl.hpp"
@@ -41,7 +41,8 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 
-class CDOM_EXPORT DOMEntityReferenceImpl: public DOMEntityReference
+class CDOM_EXPORT DOMEntityReferenceImpl: public DOMEntityReference,
+        public HasDOMNodeImpl, public HasDOMParentImpl, public HasDOMChildImpl
 {
 protected:
     DOMNodeImpl      fNode;
@@ -62,6 +63,11 @@ public:
 public:
     // Declare all of the functions from DOMNode.
     DOMNODE_FUNCTIONS;
+
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMPARENTIMPL_DECL;
+    DOMCHILDIMPL_DECL;
     
 public:
     virtual void setReadOnly(bool readOnly,bool deep);

Added: xerces/c/trunk/src/xercesc/dom/impl/DOMNodeBase.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMNodeBase.hpp?rev=1800911&view=auto
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMNodeBase.hpp (added)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMNodeBase.hpp Wed Jul  5 18:52:15 2017
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * $Id:$
+ */
+
+#if !defined(XERCESC_INCLUDE_GUARD_DOMNODEBASE_HPP)
+#define XERCESC_INCLUDE_GUARD_DOMNODEBASE_HPP
+
+#include <xercesc/util/XercesDefs.hpp>
+
+XERCES_CPP_NAMESPACE_BEGIN
+
+
+class DOMNodeImpl;
+class DOMParentNode;
+class DOMChildNode;
+
+//
+//  This file is part of the internal implementation of the C++ XML DOM.
+//  It should NOT be included or used directly by application programs.
+//
+//  Applications should include the file <xercesc/dom/DOM.hpp> for the entire
+//  DOM API, or xercesc/dom/DOM*.hpp for individual DOM classes, where the class
+//  name is substituded for the *.
+//
+
+/**
+ * Virtual base class with accessors for shared characteristics of DOM implementation
+ * types, this is a workaround for the current class design that allows the various
+ * implementation classes to punch into the internals of each others members without
+ * using unsafe casts that depend on object layout.
+ */
+class  CDOM_EXPORT HasDOMNodeImpl {
+protected:
+    // -----------------------------------------------------------------------
+    //  Hidden constructor
+    // -----------------------------------------------------------------------
+    /** @name Hidden constructors */
+    //@{
+    HasDOMNodeImpl() {}
+    //@}
+
+private:
+    // -----------------------------------------------------------------------
+    // Unimplemented constructors and operators
+    // -----------------------------------------------------------------------
+    /** @name Unimplemented operators */
+    //@{
+    HasDOMNodeImpl & operator= (const HasDOMNodeImpl &);
+    //@}
+
+public:
+    // -----------------------------------------------------------------------
+    //  All constructors are hidden, just the destructor is available
+    // -----------------------------------------------------------------------
+    /** @name Destructor */
+    //@{
+    /**
+     * Destructor
+     *
+     */
+    virtual ~HasDOMNodeImpl() {};
+    //@}
+
+    // -----------------------------------------------------------------------
+    //  Virtual HasDOMNodeImpl interface
+    // -----------------------------------------------------------------------
+    //@{
+    // -----------------------------------------------------------------------
+    //  Getter methods
+    // -----------------------------------------------------------------------
+
+    /**
+     * Gets the embedded <code>DOMNodeImpl</code> member.
+     */
+    virtual DOMNodeImpl        *getNodeImpl() = 0;
+
+    /**
+     * Gets the embedded <code>DOMNodeImpl</code> member.
+     */
+    virtual const DOMNodeImpl  *getNodeImpl() const = 0;
+    //@}
+};
+
+/**
+ * Virtual base class with accessors for shared characteristics of DOM implementation
+ * types, this is a workaround for the current class design that allows the various
+ * implementation classes to punch into the internals of each others members without
+ * using unsafe casts that depend on object layout.
+ */
+class  CDOM_EXPORT HasDOMParentImpl {
+protected:
+    // -----------------------------------------------------------------------
+    //  Hidden constructor
+    // -----------------------------------------------------------------------
+    /** @name Hidden constructors */
+    //@{
+    HasDOMParentImpl() {}
+    //@}
+
+private:
+    // -----------------------------------------------------------------------
+    // Unimplemented constructors and operators
+    // -----------------------------------------------------------------------
+    /** @name Unimplemented operators */
+    //@{
+    HasDOMParentImpl & operator= (const HasDOMParentImpl &);
+    //@}
+
+public:
+    // -----------------------------------------------------------------------
+    //  All constructors are hidden, just the destructor is available
+    // -----------------------------------------------------------------------
+    /** @name Destructor */
+    //@{
+    /**
+     * Destructor
+     *
+     */
+    virtual ~HasDOMParentImpl() {};
+    //@}
+
+    // -----------------------------------------------------------------------
+    //  Virtual HasDOMParentImpl interface
+    // -----------------------------------------------------------------------
+    //@{
+    // -----------------------------------------------------------------------
+    //  Getter methods
+    // -----------------------------------------------------------------------
+
+    /**
+     * Gets the embedded <code>DOMParentNode</code> member.
+     */
+    virtual DOMParentNode      *getParentNodeImpl() = 0;
+
+    /**
+     * Gets the embedded <code>DOMParentNode</code> member.
+     */
+    virtual const DOMParentNode *getParentNodeImpl() const = 0;
+    //@}
+};
+
+/**
+ * Virtual base class with accessors for shared characteristics of DOM implementation
+ * types, this is a workaround for the current class design that allows the various
+ * implementation classes to punch into the internals of each others members without
+ * using unsafe casts that depend on object layout.
+ */
+class  CDOM_EXPORT HasDOMChildImpl {
+protected:
+    // -----------------------------------------------------------------------
+    //  Hidden constructor
+    // -----------------------------------------------------------------------
+    /** @name Hidden constructors */
+    //@{
+    HasDOMChildImpl() {}
+    //@}
+
+private:
+    // -----------------------------------------------------------------------
+    // Unimplemented constructors and operators
+    // -----------------------------------------------------------------------
+    /** @name Unimplemented operators */
+    //@{
+    HasDOMChildImpl & operator= (const HasDOMChildImpl &);
+    //@}
+
+public:
+    // -----------------------------------------------------------------------
+    //  All constructors are hidden, just the destructor is available
+    // -----------------------------------------------------------------------
+    /** @name Destructor */
+    //@{
+    /**
+     * Destructor
+     *
+     */
+    virtual ~HasDOMChildImpl() {};
+    //@}
+
+    // -----------------------------------------------------------------------
+    //  Virtual HasDOMChildImpl interface
+    // -----------------------------------------------------------------------
+    //@{
+    // -----------------------------------------------------------------------
+    //  Getter methods
+    // -----------------------------------------------------------------------
+
+    /**
+     * Gets the embedded <code>DOMChildNode</code> member.
+     */
+    virtual DOMChildNode      *getChildNodeImpl() = 0;
+
+    /**
+     * Gets the embedded <code>DOMChildNode</code> member.
+     */
+    virtual const DOMChildNode *getChildNodeImpl() const = 0;
+    //@}
+};
+
+#define DOMNODEIMPL_DECL \
+    virtual DOMNodeImpl* getNodeImpl(); \
+    virtual const DOMNodeImpl* getNodeImpl() const;
+
+#define DOMNODEIMPL_IMPL(classname) \
+    DOMNodeImpl*         classname::getNodeImpl() {return &fNode;} \
+    const DOMNodeImpl*   classname::getNodeImpl() const {return &fNode;}
+
+#define DOMPARENTIMPL_DECL \
+    virtual DOMParentNode* getParentNodeImpl(); \
+    virtual const DOMParentNode* getParentNodeImpl() const;
+
+#define DOMPARENTIMPL_IMPL(classname) \
+    DOMParentNode*       classname::getParentNodeImpl() {return &fParent;} \
+    const DOMParentNode* classname::getParentNodeImpl() const {return &fParent;}
+
+#define DOMCHILDIMPL_DECL \
+    virtual DOMChildNode* getChildNodeImpl(); \
+    virtual const DOMChildNode* getChildNodeImpl() const;
+    
+#define DOMCHILDIMPL_IMPL(classname) \
+    DOMChildNode*       classname::getChildNodeImpl() {return &fChild;} \
+    const DOMChildNode* classname::getChildNodeImpl() const {return &fChild;}
+
+
+XERCES_CPP_NAMESPACE_END
+
+#endif

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMNodeImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMNodeImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMNodeImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMNodeImpl.cpp Wed Jul  5 18:52:15 2017
@@ -76,17 +76,26 @@ void XMLInitializer::terminateDOMNodeLis
 // -----------------------------------------------------------------------
 //  DOMNodeImpl Functions
 // -----------------------------------------------------------------------
-DOMNodeImpl::DOMNodeImpl(DOMNode *ownerNode)
-:  fOwnerNode(ownerNode)
+DOMNodeImpl::DOMNodeImpl(DOMNode* containingNode, DOMNode *ownerNode)
+:  fContainingNode(containingNode), fOwnerNode(ownerNode)
 {
+    if (!fContainingNode) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, GetDOMNodeMemoryManager);
+    }
+    
     this->flags = 0;
     // as long as we do not have any owner, fOwnerNode is our ownerDocument
 }
 
 // This only makes a shallow copy, cloneChildren must also be called for a
 // deep clone
-DOMNodeImpl::DOMNodeImpl(const DOMNodeImpl &other)
+DOMNodeImpl::DOMNodeImpl(DOMNode* containingNode, const DOMNodeImpl &other)
+    : fContainingNode(containingNode)
 {
+    if (!fContainingNode) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, GetDOMNodeMemoryManager);
+    }
+
     this->flags = other.flags;
     this->isReadOnly(false);
 
@@ -100,6 +109,13 @@ DOMNodeImpl::DOMNodeImpl(const DOMNodeIm
 DOMNodeImpl::~DOMNodeImpl() {
 }
 
+DOMNode* DOMNodeImpl::getContainingNode() {
+    return fContainingNode;
+}
+
+const DOMNode* DOMNodeImpl::getContainingNode() const {
+    return fContainingNode;
+}
 
 DOMNode * DOMNodeImpl::appendChild(DOMNode *)
 {
@@ -151,8 +167,9 @@ DOMDocument *DOMNodeImpl::getOwnerDocume
 {
     if (!this->isLeafNode())
     {
-        DOMElementImpl *ep = (DOMElementImpl *)castToNode(this);
-        return ep->fParent.fOwnerDocument;
+        const DOMNode *ep = getContainingNode();
+        const DOMParentNode* parent = castToParentImpl(getContainingNode());
+        return parent ? parent->fOwnerDocument : 0;
     }
 
     //  Leaf node types - those that cannot have children, like Text.
@@ -236,7 +253,7 @@ void DOMNodeImpl::setReadOnly(bool readO
     this->isReadOnly(readOnl);
 
     if (deep) {
-        for (DOMNode *mykid = castToNode(this)->getFirstChild();
+        for (DOMNode *mykid = getContainingNode()->getFirstChild();
             mykid != 0;
             mykid = mykid->getNextSibling()) {
 
@@ -364,7 +381,7 @@ void DOMNodeImpl::callUserDataHandlers(D
 
 bool DOMNodeImpl::isSameNode(const DOMNode* other) const
 {
-    return (castToNode(this) == other);
+    return (getContainingNode() == other);
 }
 
 bool DOMNodeImpl::isEqualNode(const DOMNode* arg) const
@@ -376,7 +393,7 @@ bool DOMNodeImpl::isEqualNode(const DOMN
         return true;
     }
 
-    DOMNode* thisNode = castToNode(this);
+    const DOMNode* thisNode = getContainingNode();
 
     if (arg->getNodeType() != thisNode->getNodeType()) {
         return false;
@@ -413,7 +430,7 @@ const XMLCh* DOMNodeImpl::lookupPrefix(c
         return 0;
     }
 
-    DOMNode *thisNode = castToNode(this);
+    const DOMNode *thisNode = getContainingNode();
 
     short type = thisNode->getNodeType();
 
@@ -462,7 +479,7 @@ DOMNode* DOMNodeImpl::getElementAncestor
 
 
 const XMLCh* DOMNodeImpl::lookupPrefix(const XMLCh* const namespaceURI, DOMElement *originalElement) const {
-    DOMNode *thisNode = castToNode(this);
+    const DOMNode *thisNode = getContainingNode();
 
     const XMLCh* ns = thisNode->getNamespaceURI();
     // REVISIT: if no prefix is available is it null or empty string, or
@@ -510,7 +527,7 @@ const XMLCh* DOMNodeImpl::lookupPrefix(c
 }
 
 const XMLCh* DOMNodeImpl::lookupNamespaceURI(const XMLCh* specifiedPrefix) const  {
-    DOMNode *thisNode = castToNode(this);
+    const DOMNode *thisNode = getContainingNode();
 
     short type = thisNode->getNodeType();
     switch (type) {
@@ -575,7 +592,7 @@ const XMLCh* DOMNodeImpl::lookupNamespac
         return 0;
     }
     default:{
-        DOMNode *ancestor = getElementAncestor(castToNode(this));
+        DOMNode *ancestor = getElementAncestor(getContainingNode());
         if (ancestor != 0) {
             return ancestor->lookupNamespaceURI(specifiedPrefix);
         }
@@ -586,7 +603,7 @@ const XMLCh* DOMNodeImpl::lookupNamespac
 
 
 const XMLCh*     DOMNodeImpl::getBaseURI() const{
-    DOMNode *thisNode = castToNode(this);
+    const DOMNode *thisNode = getContainingNode();
     DOMNode* parent = thisNode->getParentNode();
     if (parent)
         return parent->getBaseURI();
@@ -608,8 +625,8 @@ const DOMNode*   DOMNodeImpl::getTreePar
     return 0;
 }
 
-short            DOMNodeImpl::compareDocumentPosition(const DOMNode* other) const {
-    DOMNode* thisNode = castToNode(this);
+short DOMNodeImpl::compareDocumentPosition(const DOMNode* other) const {
+    const DOMNode* thisNode = getContainingNode();
 
     // If the two nodes being compared are the same node, then no flags are set on the return.
     if (thisNode == other)
@@ -639,7 +656,7 @@ short            DOMNodeImpl::compareDoc
     // its attribute node and its child node, which both follow it.
 
     const DOMNode* tmpNode;
-    const DOMNode* myRoot = castToNode(this);
+    const DOMNode* myRoot = getContainingNode();
     int myDepth=0;
     while((tmpNode=getTreeParentNode(myRoot))!=0)
     {
@@ -676,7 +693,7 @@ short            DOMNodeImpl::compareDoc
     // are or contain the corresponding nodes being compared.
 
     // if the two depths are different, go to the same one
-    myRoot = castToNode(this);
+    myRoot = getContainingNode();
     hisRoot = other;
     if (myDepth > hisDepth) {
         for (int i= 0 ; i < myDepth - hisDepth; i++)
@@ -829,7 +846,7 @@ const XMLCh*    DOMNodeImpl::getTextCont
 	if (pzBuffer)
 		*pzBuffer = 0;
 
-	DOMNode *thisNode = castToNode(this);
+	const DOMNode *thisNode = getContainingNode();
 
 	switch (thisNode->getNodeType())
 	{
@@ -907,8 +924,8 @@ const XMLCh*    DOMNodeImpl::getTextCont
 
 }
 
-void DOMNodeImpl::setTextContent(const XMLCh* textContent){
-    DOMNode *thisNode = castToNode(this);
+void DOMNodeImpl::setTextContent(const XMLCh* textContent) {
+    DOMNode *thisNode = getContainingNode();
     switch (thisNode->getNodeType())
     {
         case DOMNode::ELEMENT_NODE:
@@ -957,8 +974,8 @@ void DOMNodeImpl::setTextContent(const X
 }
 
 
-bool DOMNodeImpl::isDefaultNamespace(const XMLCh* namespaceURI) const{
-	DOMNode *thisNode = castToNode(this);
+bool DOMNodeImpl::isDefaultNamespace(const XMLCh* namespaceURI) const {
+	const DOMNode *thisNode = getContainingNode();
     short type = thisNode->getNodeType();
     switch (type) {
     case DOMNode::ELEMENT_NODE: {

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMNodeImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMNodeImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMNodeImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMNodeImpl.hpp Wed Jul  5 18:52:15 2017
@@ -65,6 +65,7 @@ class CDOM_EXPORT DOMNodeImpl {
 public:
 
     // data
+    DOMNode                *fContainingNode; // the impl object that we're contained by
     DOMNode                *fOwnerNode; // typically the parent but not always!
 
     unsigned short flags;
@@ -85,10 +86,18 @@ public:
 
 
 public:
-    DOMNodeImpl(DOMNode *ownerDocument);
-    DOMNodeImpl(const DOMNodeImpl &other);
+    DOMNodeImpl(DOMNode* containingNode, DOMNode *ownerDocument);
+    DOMNodeImpl(DOMNode* containingNode, const DOMNodeImpl &other);
     ~DOMNodeImpl();
 
+private:
+    // Make sure this can't be called to corrupt the containing node ptr.
+    DOMNodeImpl(const DOMNodeImpl &other);
+
+    DOMNode* getContainingNode();
+    const DOMNode* getContainingNode() const;
+
+public:
     DOMNode         * appendChild(DOMNode *newChild);
     DOMNamedNodeMap * getAttributes() const;
     DOMNodeList     * getChildNodes() const;

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMNotationImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMNotationImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMNotationImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMNotationImpl.cpp Wed Jul  5 18:52:15 2017
@@ -27,7 +27,7 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 DOMNotationImpl::DOMNotationImpl(DOMDocument *ownerDoc, const XMLCh *nName)
-    : fNode(ownerDoc), fName(0), fPublicId(0), fSystemId(0), fBaseURI(0)
+    : fNode(this, ownerDoc), fName(0), fPublicId(0), fSystemId(0), fBaseURI(0)
 {
     fNode.setIsLeafNode(true);
     fName = ((DOMDocumentImpl *)ownerDoc)->getPooledString(nName);
@@ -35,7 +35,7 @@ DOMNotationImpl::DOMNotationImpl(DOMDocu
 
 DOMNotationImpl::DOMNotationImpl(const DOMNotationImpl &other, bool /*deep*/)
     : DOMNotation(other),
-      fNode(other.fNode),
+      fNode(this, other.fNode),
       fName(other.fName),
       fPublicId(other.fPublicId),
       fSystemId(other.fSystemId),
@@ -175,5 +175,8 @@ const XMLCh* DOMNotationImpl::getBaseURI
            const XMLCh*     DOMNotationImpl::lookupNamespaceURI(const XMLCh* prefix) const  {return fNode.lookupNamespaceURI(prefix); }
            void*            DOMNotationImpl::getFeature(const XMLCh* feature, const XMLCh* version) const {return fNode.getFeature(feature, version); }
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMNotationImpl);
+
 
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMNotationImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMNotationImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMNotationImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMNotationImpl.hpp Wed Jul  5 18:52:15 2017
@@ -36,13 +36,13 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
-
+#include "DOMNodeBase.hpp"
 #include "DOMNodeImpl.hpp"
 
 class DOMDocument;
 
 
-class CDOM_EXPORT DOMNotationImpl: public DOMNotation {
+class CDOM_EXPORT DOMNotationImpl: public DOMNotation, public HasDOMNodeImpl {
 public:
     DOMNodeImpl      fNode;
 
@@ -61,6 +61,9 @@ public:
     // Declare all of the functions from DOMNode.
     DOMNODE_FUNCTIONS;
 
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+
 public:
     //
     // The Public Identifier for this Notation. If no public identifier

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.cpp Wed Jul  5 18:52:15 2017
@@ -31,22 +31,49 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
-DOMParentNode::DOMParentNode(DOMDocument *ownerDoc)
-    : fOwnerDocument(ownerDoc), fFirstChild(0), fChildNodeList(this)
+DOMParentNode::DOMParentNode(DOMNode* containingNode, DOMDocument *ownerDoc)
+    : fContainingNode(containingNode), fOwnerDocument(ownerDoc), fFirstChild(0), fChildNodeList(this)
 {
+    if (!fContainingNode) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, GetDOMNodeMemoryManager);
+    }
 }
 
 // This only makes a shallow copy, cloneChildren must also be called for a
 // deep clone
-DOMParentNode::DOMParentNode(const DOMParentNode &other)  :
-    fChildNodeList(this)
+DOMParentNode::DOMParentNode(DOMNode* containingNode, const DOMParentNode &other)  :
+    fContainingNode(containingNode), fChildNodeList(this)
 {
+    if (!fContainingNode) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, GetDOMNodeMemoryManager);
+    }
+
     this->fOwnerDocument = other.fOwnerDocument;
 
     // Need to break the association w/ original kids
     this->fFirstChild = 0;
 }
 
+DOMParentNode::~DOMParentNode() {
+
+}
+
+DOMNode* DOMParentNode::getContainingNode() {
+    return fContainingNode;
+}
+
+const DOMNode* DOMParentNode::getContainingNode() const {
+    return fContainingNode;
+}
+
+const DOMNodeImpl* DOMParentNode::getContainingNodeImpl() const {
+    const HasDOMNodeImpl* p = dynamic_cast<const HasDOMNodeImpl*>(getContainingNode());
+    if (!p || !p->getNodeImpl()) {
+        throw DOMException(DOMException::INVALID_STATE_ERR, 0, GetDOMNodeMemoryManager);
+    }
+    return p->getNodeImpl();
+}
+
 void DOMParentNode::changed()
 {
   ((DOMDocumentImpl*)fOwnerDocument)->changed();
@@ -141,7 +168,7 @@ DOMNode *DOMParentNode::insertBefore(DOM
     if(newChild==NULL)
         throw DOMException(DOMException::HIERARCHY_REQUEST_ERR,0, GetDOMParentNodeMemoryManager);
 
-    DOMNodeImpl *thisNodeImpl = castToNodeImpl(this);
+    const DOMNodeImpl *thisNodeImpl = getContainingNodeImpl();
     if (thisNodeImpl->isReadOnly())
         throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMParentNodeMemoryManager);
 
@@ -152,7 +179,7 @@ DOMNode *DOMParentNode::insertBefore(DOM
     //only need to do this if the node has children
     if(newChild->hasChildNodes()) {
         bool treeSafe=true;
-        for(DOMNode *a=castToNode(this)->getParentNode();
+        for(DOMNode *a=getContainingNode()->getParentNode();
             treeSafe && a!=0;
             a=a->getParentNode())
             treeSafe=(newChild!=a);
@@ -161,7 +188,7 @@ DOMNode *DOMParentNode::insertBefore(DOM
     }
 
     // refChild must in fact be a child of this node (or 0)
-    if (refChild!=0 && refChild->getParentNode() != castToNode(this))
+    if (refChild!=0 && refChild->getParentNode() != getContainingNode())
         throw DOMException(DOMException::NOT_FOUND_ERR,0, GetDOMParentNodeMemoryManager);
 
     // if the new node has to be placed before itself, we don't have to do anything
@@ -192,14 +219,14 @@ DOMNode *DOMParentNode::insertBefore(DOM
               kid!=0;
               kid=kid->getNextSibling())
         {
-            if (!DOMDocumentImpl::isKidOK(castToNode(this), kid))
+            if (!DOMDocumentImpl::isKidOK(getContainingNode(), kid))
               throw DOMException(DOMException::HIERARCHY_REQUEST_ERR,0, GetDOMParentNodeMemoryManager);
         }
         while(newChild->hasChildNodes())     // Move
-            castToNode(this)->insertBefore(newChild->getFirstChild(),refChild);
+            getContainingNode()->insertBefore(newChild->getFirstChild(),refChild);
     }
 
-    else if (!DOMDocumentImpl::isKidOK(castToNode(this), newChild))
+    else if (!DOMDocumentImpl::isKidOK(getContainingNode(), newChild))
         throw DOMException(DOMException::HIERARCHY_REQUEST_ERR,0, GetDOMParentNodeMemoryManager);
 
     else
@@ -209,7 +236,7 @@ DOMNode *DOMParentNode::insertBefore(DOM
             oldparent->removeChild(newChild);
 
         // Attach up
-        castToNodeImpl(newChild)->fOwnerNode = castToNode(this);
+        castToNodeImpl(newChild)->fOwnerNode = getContainingNode();
         castToNodeImpl(newChild)->isOwned(true);
 
         // Attach before and after
@@ -271,11 +298,11 @@ DOMNode *DOMParentNode::insertBefore(DOM
 
 DOMNode *DOMParentNode::removeChild(DOMNode *oldChild)
 {
-    if (castToNodeImpl(this)->isReadOnly())
+    if (getContainingNodeImpl()->isReadOnly())
         throw DOMException(
         DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMParentNodeMemoryManager);
 
-    if (oldChild == 0 || oldChild->getParentNode() != castToNode(this))
+    if (oldChild == 0 || oldChild->getParentNode() != getContainingNode())
         throw DOMException(DOMException::NOT_FOUND_ERR, 0, GetDOMParentNodeMemoryManager);
 
     if (fOwnerDocument !=  0) {
@@ -364,7 +391,7 @@ DOMNode * DOMParentNode::appendChildFast
     //
 
     // Attach up
-    castToNodeImpl(newChild)->fOwnerNode = castToNode(this);
+    castToNodeImpl(newChild)->fOwnerNode = getContainingNode();
     castToNodeImpl(newChild)->isOwned(true);
 
     // Attach before and after
@@ -427,10 +454,10 @@ void DOMParentNode::normalize()
 
 bool DOMParentNode::isEqualNode(const DOMNode* arg) const
 {
-    if (arg && castToNodeImpl(this)->isSameNode(arg))
+    if (arg && getContainingNodeImpl()->isSameNode(arg))
         return true;
 
-    if (arg && castToNodeImpl(this)->isEqualNode(arg))
+    if (arg && getContainingNodeImpl()->isEqualNode(arg))
     {
         DOMNode *kid, *argKid;
         for (kid = fFirstChild, argKid = arg->getFirstChild();

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.hpp Wed Jul  5 18:52:15 2017
@@ -55,14 +55,25 @@ class DOMNodeList;
 
 class CDOM_EXPORT DOMParentNode  {
 public:
+    DOMNode                *fContainingNode; // the impl object that we're contained by
     DOMDocument            *fOwnerDocument; // Document this node belongs to
     DOMNode                *fFirstChild;
     DOMNodeListImpl            fChildNodeList;      // for GetChildNodes()
 
 public:
-    DOMParentNode(DOMDocument *ownerDocument);
+    DOMParentNode(DOMNode* containingNode, DOMDocument *ownerDocument);
+    DOMParentNode(DOMNode* containingNode, const DOMParentNode &other);
+    ~DOMParentNode();
+
+private:
+    // Make sure this can't be called to corrupt the containing node ptr.
     DOMParentNode(const DOMParentNode &other);
 
+    DOMNode* getContainingNode();
+    const DOMNode* getContainingNode() const;
+    const DOMNodeImpl* getContainingNodeImpl() const;
+
+public:
     DOMDocument * getOwnerDocument() const;
     void setOwnerDocument(DOMDocument* doc);
 

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMProcessingInstructionImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMProcessingInstructionImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMProcessingInstructionImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMProcessingInstructionImpl.cpp Wed Jul  5 18:52:15 2017
@@ -33,7 +33,7 @@ XERCES_CPP_NAMESPACE_BEGIN
 DOMProcessingInstructionImpl::DOMProcessingInstructionImpl(DOMDocument *ownerDoc,
                                                      const XMLCh *targt,
                                                      const XMLCh *dat)
-    : fNode(ownerDoc), fCharacterData(ownerDoc, dat), fBaseURI(0)
+    : fNode(this, ownerDoc), fCharacterData(ownerDoc, dat), fBaseURI(0)
 {
     fNode.setIsLeafNode(true);
     this->fTarget = ((DOMDocumentImpl *)ownerDoc)->cloneString(targt);
@@ -44,7 +44,7 @@ DOMProcessingInstructionImpl::DOMProcess
                                         const DOMProcessingInstructionImpl &other,
                                         bool /*deep*/)
     : DOMProcessingInstruction(other),
-      fNode(other.fNode),
+      fNode(this, other.fNode),
       fChild(other.fChild),
       fCharacterData(other.fCharacterData),
       fTarget(other.fTarget),
@@ -198,6 +198,10 @@ DOMProcessingInstruction *DOMProcessingI
            const XMLCh*     DOMProcessingInstructionImpl::lookupNamespaceURI(const XMLCh* prefix) const  {return fNode.lookupNamespaceURI(prefix); }
            void*            DOMProcessingInstructionImpl::getFeature(const XMLCh* feature, const XMLCh* version) const {return fNode.getFeature(feature, version); }
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMProcessingInstructionImpl);
+DOMCHILDIMPL_IMPL(DOMProcessingInstructionImpl);
+
 //
 //   Delegation of CharacerData functions.
 //

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMProcessingInstructionImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMProcessingInstructionImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMProcessingInstructionImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMProcessingInstructionImpl.hpp Wed Jul  5 18:52:15 2017
@@ -34,6 +34,7 @@
 
 #include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/dom/DOMProcessingInstruction.hpp>
+#include "DOMNodeBase.hpp"
 #include "DOMCharacterDataImpl.hpp"
 #include "DOMNodeImpl.hpp"
 #include "DOMChildNode.hpp"
@@ -44,7 +45,8 @@ XERCES_CPP_NAMESPACE_BEGIN
 class    DocumentImpl;
 
 
-class CDOM_EXPORT DOMProcessingInstructionImpl: public DOMProcessingInstruction {
+class CDOM_EXPORT DOMProcessingInstructionImpl: public DOMProcessingInstruction,
+        public HasDOMNodeImpl, public HasDOMChildImpl {
 protected:
     DOMNodeImpl   fNode;
     DOMChildNode  fChild;
@@ -66,6 +68,10 @@ public:
     // Declare all of the functions from DOMNode.
     DOMNODE_FUNCTIONS;
 
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMCHILDIMPL_DECL;
+
 public:
     virtual const XMLCh *getData() const;
     virtual const XMLCh *getTarget() const;

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.cpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.cpp Wed Jul  5 18:52:15 2017
@@ -44,21 +44,21 @@ XERCES_CPP_NAMESPACE_BEGIN
 class DOMDocument;
 
 DOMTextImpl::DOMTextImpl(DOMDocument *ownerDoc, const XMLCh *dat)
-    : fNode(ownerDoc), fCharacterData(ownerDoc, dat)
+    : fNode(this, ownerDoc), fCharacterData(ownerDoc, dat)
 {
     fNode.setIsLeafNode(true);
 }
 
 DOMTextImpl::
 DOMTextImpl(DOMDocument *ownerDoc, const XMLCh* dat, XMLSize_t n)
-    : fNode(ownerDoc), fCharacterData(ownerDoc, dat, n)
+    : fNode(this, ownerDoc), fCharacterData(ownerDoc, dat, n)
 {
     fNode.setIsLeafNode(true);
 }
 
 DOMTextImpl::DOMTextImpl(const DOMTextImpl &other, bool)
     : DOMText(other)
-    , fNode(other.fNode)
+    , fNode(this, other.fNode)
     , fCharacterData(other.fCharacterData)
 {
     fNode.setIsLeafNode(true);
@@ -306,6 +306,10 @@ void DOMTextImpl::release()
            void*            DOMTextImpl::getFeature(const XMLCh* feature, const XMLCh* version) const {return fNode.getFeature(feature, version); }
 
 
+// Macro-in implementation accessors.
+DOMNODEIMPL_IMPL(DOMTextImpl);
+DOMCHILDIMPL_IMPL(DOMTextImpl);
+
 
 //
 //   Delegation of CharacerData functions.

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.hpp?rev=1800911&r1=1800910&r2=1800911&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.hpp Wed Jul  5 18:52:15 2017
@@ -35,7 +35,7 @@
 
 #include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/dom/DOMText.hpp>
-
+#include "DOMNodeBase.hpp"
 #include "DOMChildNode.hpp"
 #include "DOMNodeImpl.hpp"
 #include "DOMCharacterDataImpl.hpp"
@@ -43,7 +43,7 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 
-class CDOM_EXPORT DOMTextImpl: public DOMText {
+class CDOM_EXPORT DOMTextImpl: public DOMText, public HasDOMNodeImpl, public HasDOMChildImpl {
 public:
     DOMNodeImpl             fNode;
     DOMChildNode            fChild;
@@ -68,6 +68,10 @@ public:
     // Declare the functions coming from DOMNode.
     DOMNODE_FUNCTIONS;
 
+    // Add accessors for implementation bits.
+    DOMNODEIMPL_DECL;
+    DOMCHILDIMPL_DECL;
+
 public:
     // All of the functions coming from DOMCharacterData
     virtual const XMLCh*    getData() const;

Propchange: xerces/c/trunk/src/xercesc/util/NetAccessors/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jul  5 18:52:15 2017
@@ -1 +1 @@
-.deps
+.*

Propchange: xerces/c/trunk/tests/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jul  5 18:52:15 2017
@@ -2,13 +2,18 @@
 Makefile
 DOMTest
 DOMMemTest
+DOMTraversalTest
+DOMTypeInfoTest
+MemHandlerTest
 Normalizer
 EncodingTest
 InitTermTest
 NetAccessorTest
 RangeTest
+ThreadTest
 TypeInfo
 Traversal
 XSerializerTest
 XSValueTest
+XSTSHarness
 Makefile.in

Propchange: xerces/c/trunk/tests/src/XSTSHarness/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jul  5 18:52:15 2017
@@ -1 +1 @@
-.deps
+.*



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org