Commit d48246e1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

msxml3: Return xmlnode object from create_basic_node.

parent 85201ceb
......@@ -547,7 +547,7 @@ static const struct IXMLDOMAttributeVtbl domattr_vtbl =
IUnknown* create_attribute( xmlNodePtr attribute )
{
domattr *This;
HRESULT hr;
xmlnode *node;
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
if ( !This )
......@@ -556,22 +556,15 @@ IUnknown* create_attribute( xmlNodePtr attribute )
This->lpVtbl = &domattr_vtbl;
This->ref = 1;
This->node_unk = create_basic_node( attribute, (IUnknown*)&This->lpVtbl );
if(!This->node_unk)
node = create_basic_node( attribute, (IUnknown*)&This->lpVtbl );
if(!node)
{
HeapFree(GetProcessHeap(), 0, This);
return NULL;
}
hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
if(FAILED(hr))
{
IUnknown_Release(This->node_unk);
HeapFree( GetProcessHeap(), 0, This );
return NULL;
}
/* The ref on This->node is actually looped back into this object, so release it */
IXMLDOMNode_Release(This->node);
This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl;
This->node = IXMLDOMNode_from_impl(node);
return (IUnknown*) &This->lpVtbl;
}
......
......@@ -770,7 +770,7 @@ static const struct IXMLDOMCDATASectionVtbl domcdata_vtbl =
IUnknown* create_cdata( xmlNodePtr text )
{
domcdata *This;
HRESULT hr;
xmlnode *node;
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
if ( !This )
......@@ -779,22 +779,15 @@ IUnknown* create_cdata( xmlNodePtr text )
This->lpVtbl = &domcdata_vtbl;
This->ref = 1;
This->node_unk = create_basic_node( text, (IUnknown*)&This->lpVtbl );
if(!This->node_unk)
node = create_basic_node( text, (IUnknown*)&This->lpVtbl );
if(!node)
{
HeapFree(GetProcessHeap(), 0, This);
return NULL;
}
hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
if(FAILED(hr))
{
IUnknown_Release(This->node_unk);
HeapFree( GetProcessHeap(), 0, This );
return NULL;
}
/* The ref on This->node is actually looped back into this object, so release it */
IXMLDOMNode_Release(This->node);
This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl;
This->node = IXMLDOMNode_from_impl(node);
return (IUnknown*) &This->lpVtbl;
}
......
......@@ -768,7 +768,7 @@ static const struct IXMLDOMCommentVtbl domcomment_vtbl =
IUnknown* create_comment( xmlNodePtr comment )
{
domcomment *This;
HRESULT hr;
xmlnode *node;
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
if ( !This )
......@@ -777,22 +777,15 @@ IUnknown* create_comment( xmlNodePtr comment )
This->lpVtbl = &domcomment_vtbl;
This->ref = 1;
This->node_unk = create_basic_node( comment, (IUnknown*)&This->lpVtbl );
if(!This->node_unk)
node = create_basic_node( comment, (IUnknown*)&This->lpVtbl );
if(!node)
{
HeapFree(GetProcessHeap(), 0, This);
return NULL;
}
hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
if(FAILED(hr))
{
IUnknown_Release(This->node_unk);
HeapFree( GetProcessHeap(), 0, This );
return NULL;
}
/* The ref on This->node is actually looped back into this object, so release it */
IXMLDOMNode_Release(This->node);
This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl;
This->node = IXMLDOMNode_from_impl(node);
return (IUnknown*) &This->lpVtbl;
}
......
......@@ -520,7 +520,7 @@ static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
IUnknown* create_doc_fragment( xmlNodePtr fragment )
{
domfrag *This;
HRESULT hr;
xmlnode *node;
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
if ( !This )
......@@ -529,22 +529,15 @@ IUnknown* create_doc_fragment( xmlNodePtr fragment )
This->lpVtbl = &domfrag_vtbl;
This->ref = 1;
This->node_unk = create_basic_node( fragment, (IUnknown*)&This->lpVtbl );
if(!This->node_unk)
node = create_basic_node( fragment, (IUnknown*)&This->lpVtbl );
if(!node)
{
HeapFree(GetProcessHeap(), 0, This);
return NULL;
}
hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
if(FAILED(hr))
{
IUnknown_Release(This->node_unk);
HeapFree( GetProcessHeap(), 0, This );
return NULL;
}
/* The ref on This->node is actually looped back into this object, so release it */
IXMLDOMNode_Release(This->node);
This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl;
This->node = IXMLDOMNode_from_impl(node);
return (IUnknown*) &This->lpVtbl;
}
......
......@@ -2198,7 +2198,7 @@ static dispex_static_data_t domdoc_dispex = {
HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **document)
{
domdoc *doc;
HRESULT hr;
xmlnode *node;
doc = HeapAlloc( GetProcessHeap(), 0, sizeof (*doc) );
if( !doc )
......@@ -2222,26 +2222,18 @@ HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **docu
doc->safeopt = 0;
doc->bsc = NULL;
doc->node_unk = create_basic_node( (xmlNodePtr)xmldoc, (IUnknown*)&doc->lpVtbl );
if(!doc->node_unk)
node = create_basic_node( (xmlNodePtr)xmldoc, (IUnknown*)&doc->lpVtbl );
if(!node)
{
HeapFree(GetProcessHeap(), 0, doc);
return E_FAIL;
}
hr = IUnknown_QueryInterface(doc->node_unk, &IID_IXMLDOMNode, (LPVOID*)&doc->node);
if(FAILED(hr))
{
IUnknown_Release(doc->node_unk);
HeapFree( GetProcessHeap(), 0, doc );
return E_FAIL;
}
doc->node_unk = (IUnknown*)&node->lpInternalUnkVtbl;
doc->node = IXMLDOMNode_from_impl(node);
init_dispex(&doc->dispex, (IUnknown*)&doc->lpVtbl, &domdoc_dispex);
/* The ref on doc->node is actually looped back into this object, so release it */
IXMLDOMNode_Release(doc->node);
*document = (IXMLDOMDocument2*)&doc->lpVtbl;
TRACE("returning iface %p\n", *document);
......
......@@ -790,7 +790,7 @@ static const struct IUnknownVtbl internal_unk_vtbl =
IUnknown* create_element( xmlNodePtr element, IUnknown *pUnkOuter )
{
domelem *This;
HRESULT hr;
xmlnode *node;
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
if ( !This )
......@@ -805,22 +805,15 @@ IUnknown* create_element( xmlNodePtr element, IUnknown *pUnkOuter )
else
This->pUnkOuter = (IUnknown *)&This->lpInternalUnkVtbl;
This->node_unk = create_basic_node( element, (IUnknown*)&This->lpVtbl );
if(!This->node_unk)
node = create_basic_node( element, (IUnknown*)&This->lpVtbl );
if(!node)
{
HeapFree(GetProcessHeap(), 0, This);
return NULL;
}
hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
if(FAILED(hr))
{
IUnknown_Release(This->node_unk);
HeapFree( GetProcessHeap(), 0, This );
return NULL;
}
/* The ref on This->node is actually looped back into this object, so release it */
IXMLDOMNode_Release(This->node);
This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl;
This->node = IXMLDOMNode_from_impl(node);
return (IUnknown*) &This->lpInternalUnkVtbl;
}
......
......@@ -519,7 +519,7 @@ static const struct IXMLDOMEntityReferenceVtbl entityref_vtbl =
IUnknown* create_doc_entity_ref( xmlNodePtr entity )
{
entityref *This;
HRESULT hr;
xmlnode *node;
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
if ( !This )
......@@ -528,22 +528,15 @@ IUnknown* create_doc_entity_ref( xmlNodePtr entity )
This->lpVtbl = &entityref_vtbl;
This->ref = 1;
This->node_unk = create_basic_node( entity, (IUnknown*)&This->lpVtbl );
if(!This->node_unk)
node = create_basic_node( entity, (IUnknown*)&This->lpVtbl );
if(!node)
{
HeapFree(GetProcessHeap(), 0, This);
return NULL;
}
hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
if(FAILED(hr))
{
IUnknown_Release(This->node_unk);
HeapFree( GetProcessHeap(), 0, This );
return NULL;
}
/* The ref on This->node is actually looped back into this object, so release it */
IXMLDOMNode_Release(This->node);
This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl;
This->node = IXMLDOMNode_from_impl(node);
return (IUnknown*) &This->lpVtbl;
}
......
......@@ -39,7 +39,6 @@
extern IUnknown *create_domdoc( xmlNodePtr document );
extern IUnknown *create_xmldoc( void );
extern IXMLDOMNode *create_node( xmlNodePtr node );
extern IUnknown *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter );
extern IUnknown *create_element( xmlNodePtr element, IUnknown *pUnkOuter );
extern IUnknown *create_attribute( xmlNodePtr attribute );
extern IUnknown *create_text( xmlNodePtr text );
......@@ -84,6 +83,13 @@ static inline xmlnode *impl_from_IXMLDOMNode( IXMLDOMNode *iface )
return (xmlnode *)((char*)iface - FIELD_OFFSET(xmlnode, lpVtbl));
}
static inline IXMLDOMNode *IXMLDOMNode_from_impl(xmlnode *This)
{
return (IXMLDOMNode*)&This->lpVtbl;
}
extern xmlnode *create_basic_node(xmlNodePtr,IUnknown*);
extern HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **document);
static inline BSTR bstr_from_xmlChar(const xmlChar *str)
......
......@@ -1542,7 +1542,7 @@ static const struct IUnknownVtbl internal_unk_vtbl =
Internal_Release
};
IUnknown *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter )
xmlnode *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter )
{
xmlnode *This;
......@@ -1564,7 +1564,7 @@ IUnknown *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter )
This->ref = 1;
This->node = node;
return (IUnknown*)&This->lpInternalUnkVtbl;
return This;
}
IXMLDOMNode *create_node( xmlNodePtr node )
......@@ -1599,7 +1599,7 @@ IXMLDOMNode *create_node( xmlNodePtr node )
break;
default:
FIXME("only creating basic node for type %d\n", node->type);
pUnk = create_basic_node( node, NULL );
pUnk = (IUnknown*)&create_basic_node( node, NULL )->lpInternalUnkVtbl;
}
hr = IUnknown_QueryInterface(pUnk, &IID_IXMLDOMNode, (LPVOID*)&ret);
......
......@@ -605,7 +605,7 @@ static const struct IXMLDOMProcessingInstructionVtbl dom_pi_vtbl =
IUnknown* create_pi( xmlNodePtr pi )
{
dom_pi *This;
HRESULT hr;
xmlnode *node;
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
if ( !This )
......@@ -614,22 +614,15 @@ IUnknown* create_pi( xmlNodePtr pi )
This->lpVtbl = &dom_pi_vtbl;
This->ref = 1;
This->node_unk = create_basic_node( pi, (IUnknown*)&This->lpVtbl );
if(!This->node_unk)
node = create_basic_node( pi, (IUnknown*)&This->lpVtbl );
if(!node)
{
HeapFree(GetProcessHeap(), 0, This);
return NULL;
}
hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
if(FAILED(hr))
{
IUnknown_Release(This->node_unk);
HeapFree( GetProcessHeap(), 0, This );
return NULL;
}
/* The ref on This->node is actually looped back into this object, so release it */
IXMLDOMNode_Release(This->node);
This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl;
This->node = IXMLDOMNode_from_impl(node);
return (IUnknown*) &This->lpVtbl;
}
......
......@@ -772,7 +772,7 @@ static const struct IXMLDOMTextVtbl domtext_vtbl =
IUnknown* create_text( xmlNodePtr text )
{
domtext *This;
HRESULT hr;
xmlnode *node;
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
if ( !This )
......@@ -781,22 +781,15 @@ IUnknown* create_text( xmlNodePtr text )
This->lpVtbl = &domtext_vtbl;
This->ref = 1;
This->node_unk = create_basic_node( text, (IUnknown*)&This->lpVtbl );
if(!This->node_unk)
node = create_basic_node( text, (IUnknown*)&This->lpVtbl );
if(!node)
{
HeapFree(GetProcessHeap(), 0, This);
return NULL;
}
hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
if(FAILED(hr))
{
IUnknown_Release(This->node_unk);
HeapFree( GetProcessHeap(), 0, This );
return NULL;
}
/* The ref on This->node is actually looped back into this object, so release it */
IXMLDOMNode_Release(This->node);
This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl;
This->node = IXMLDOMNode_from_impl(node);
return (IUnknown*) &This->lpVtbl;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment