configure: Rename the shared heap segment to avoid a Mac OS linker bug with 16-char...
[wine.git] / dlls / msxml3 / comment.c
blob717c73d0c45d6c5cd8426c5929032a1c7f61a212
1 /*
2 * DOM comment node implementation
4 * Copyright 2006 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "msxml2.h"
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
38 #ifdef HAVE_LIBXML2
40 typedef struct _domcomment
42 const struct IXMLDOMCommentVtbl *lpVtbl;
43 LONG ref;
44 IUnknown *node_unk;
45 IXMLDOMNode *node;
46 } domcomment;
48 static inline domcomment *impl_from_IXMLDOMComment( IXMLDOMComment *iface )
50 return (domcomment *)((char*)iface - FIELD_OFFSET(domcomment, lpVtbl));
53 static HRESULT WINAPI domcomment_QueryInterface(
54 IXMLDOMComment *iface,
55 REFIID riid,
56 void** ppvObject )
58 domcomment *This = impl_from_IXMLDOMComment( iface );
59 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
61 if ( IsEqualGUID( riid, &IID_IXMLDOMComment ) ||
62 IsEqualGUID( riid, &IID_IXMLDOMCharacterData) ||
63 IsEqualGUID( riid, &IID_IDispatch ) ||
64 IsEqualGUID( riid, &IID_IUnknown ) )
66 *ppvObject = iface;
68 else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
70 return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
72 else
74 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
75 return E_NOINTERFACE;
78 IXMLDOMComment_AddRef( iface );
80 return S_OK;
83 static ULONG WINAPI domcomment_AddRef(
84 IXMLDOMComment *iface )
86 domcomment *This = impl_from_IXMLDOMComment( iface );
87 return InterlockedIncrement( &This->ref );
90 static ULONG WINAPI domcomment_Release(
91 IXMLDOMComment *iface )
93 domcomment *This = impl_from_IXMLDOMComment( iface );
94 ULONG ref;
96 ref = InterlockedDecrement( &This->ref );
97 if ( ref == 0 )
99 IUnknown_Release( This->node_unk );
100 HeapFree( GetProcessHeap(), 0, This );
103 return ref;
106 static HRESULT WINAPI domcomment_GetTypeInfoCount(
107 IXMLDOMComment *iface,
108 UINT* pctinfo )
110 domcomment *This = impl_from_IXMLDOMComment( iface );
112 TRACE("(%p)->(%p)\n", This, pctinfo);
114 *pctinfo = 1;
116 return S_OK;
119 static HRESULT WINAPI domcomment_GetTypeInfo(
120 IXMLDOMComment *iface,
121 UINT iTInfo, LCID lcid,
122 ITypeInfo** ppTInfo )
124 domcomment *This = impl_from_IXMLDOMComment( iface );
125 HRESULT hr;
127 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
129 hr = get_typeinfo(IXMLDOMComment_tid, ppTInfo);
131 return hr;
134 static HRESULT WINAPI domcomment_GetIDsOfNames(
135 IXMLDOMComment *iface,
136 REFIID riid, LPOLESTR* rgszNames,
137 UINT cNames, LCID lcid, DISPID* rgDispId )
139 domcomment *This = impl_from_IXMLDOMComment( iface );
140 ITypeInfo *typeinfo;
141 HRESULT hr;
143 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
144 lcid, rgDispId);
146 if(!rgszNames || cNames == 0 || !rgDispId)
147 return E_INVALIDARG;
149 hr = get_typeinfo(IXMLDOMComment_tid, &typeinfo);
150 if(SUCCEEDED(hr))
152 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
153 ITypeInfo_Release(typeinfo);
156 return hr;
159 static HRESULT WINAPI domcomment_Invoke(
160 IXMLDOMComment *iface,
161 DISPID dispIdMember, REFIID riid, LCID lcid,
162 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
163 EXCEPINFO* pExcepInfo, UINT* puArgErr )
165 domcomment *This = impl_from_IXMLDOMComment( iface );
166 ITypeInfo *typeinfo;
167 HRESULT hr;
169 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
170 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
172 hr = get_typeinfo(IXMLDOMComment_tid, &typeinfo);
173 if(SUCCEEDED(hr))
175 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
176 pVarResult, pExcepInfo, puArgErr);
177 ITypeInfo_Release(typeinfo);
180 return hr;
183 static HRESULT WINAPI domcomment_get_nodeName(
184 IXMLDOMComment *iface,
185 BSTR* p )
187 domcomment *This = impl_from_IXMLDOMComment( iface );
188 return IXMLDOMNode_get_nodeName( This->node, p );
191 static HRESULT WINAPI domcomment_get_nodeValue(
192 IXMLDOMComment *iface,
193 VARIANT* var1 )
195 domcomment *This = impl_from_IXMLDOMComment( iface );
196 return IXMLDOMNode_get_nodeValue( This->node, var1 );
199 static HRESULT WINAPI domcomment_put_nodeValue(
200 IXMLDOMComment *iface,
201 VARIANT var1 )
203 domcomment *This = impl_from_IXMLDOMComment( iface );
204 return IXMLDOMNode_put_nodeValue( This->node, var1 );
207 static HRESULT WINAPI domcomment_get_nodeType(
208 IXMLDOMComment *iface,
209 DOMNodeType* domNodeType )
211 domcomment *This = impl_from_IXMLDOMComment( iface );
212 return IXMLDOMNode_get_nodeType( This->node, domNodeType );
215 static HRESULT WINAPI domcomment_get_parentNode(
216 IXMLDOMComment *iface,
217 IXMLDOMNode** parent )
219 domcomment *This = impl_from_IXMLDOMComment( iface );
220 return IXMLDOMNode_get_parentNode( This->node, parent );
223 static HRESULT WINAPI domcomment_get_childNodes(
224 IXMLDOMComment *iface,
225 IXMLDOMNodeList** outList)
227 domcomment *This = impl_from_IXMLDOMComment( iface );
228 return IXMLDOMNode_get_childNodes( This->node, outList );
231 static HRESULT WINAPI domcomment_get_firstChild(
232 IXMLDOMComment *iface,
233 IXMLDOMNode** domNode)
235 domcomment *This = impl_from_IXMLDOMComment( iface );
236 return IXMLDOMNode_get_firstChild( This->node, domNode );
239 static HRESULT WINAPI domcomment_get_lastChild(
240 IXMLDOMComment *iface,
241 IXMLDOMNode** domNode)
243 domcomment *This = impl_from_IXMLDOMComment( iface );
244 return IXMLDOMNode_get_lastChild( This->node, domNode );
247 static HRESULT WINAPI domcomment_get_previousSibling(
248 IXMLDOMComment *iface,
249 IXMLDOMNode** domNode)
251 domcomment *This = impl_from_IXMLDOMComment( iface );
252 return IXMLDOMNode_get_previousSibling( This->node, domNode );
255 static HRESULT WINAPI domcomment_get_nextSibling(
256 IXMLDOMComment *iface,
257 IXMLDOMNode** domNode)
259 domcomment *This = impl_from_IXMLDOMComment( iface );
260 return IXMLDOMNode_get_nextSibling( This->node, domNode );
263 static HRESULT WINAPI domcomment_get_attributes(
264 IXMLDOMComment *iface,
265 IXMLDOMNamedNodeMap** attributeMap)
267 domcomment *This = impl_from_IXMLDOMComment( iface );
268 return IXMLDOMNode_get_attributes( This->node, attributeMap );
271 static HRESULT WINAPI domcomment_insertBefore(
272 IXMLDOMComment *iface,
273 IXMLDOMNode* newNode, VARIANT var1,
274 IXMLDOMNode** outOldNode)
276 domcomment *This = impl_from_IXMLDOMComment( iface );
277 return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode );
280 static HRESULT WINAPI domcomment_replaceChild(
281 IXMLDOMComment *iface,
282 IXMLDOMNode* newNode,
283 IXMLDOMNode* oldNode,
284 IXMLDOMNode** outOldNode)
286 domcomment *This = impl_from_IXMLDOMComment( iface );
287 return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode );
290 static HRESULT WINAPI domcomment_removeChild(
291 IXMLDOMComment *iface,
292 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
294 domcomment *This = impl_from_IXMLDOMComment( iface );
295 return IXMLDOMNode_removeChild( This->node, domNode, oldNode );
298 static HRESULT WINAPI domcomment_appendChild(
299 IXMLDOMComment *iface,
300 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
302 domcomment *This = impl_from_IXMLDOMComment( iface );
303 return IXMLDOMNode_appendChild( This->node, newNode, outNewNode );
306 static HRESULT WINAPI domcomment_hasChildNodes(
307 IXMLDOMComment *iface,
308 VARIANT_BOOL* pbool)
310 domcomment *This = impl_from_IXMLDOMComment( iface );
311 return IXMLDOMNode_hasChildNodes( This->node, pbool );
314 static HRESULT WINAPI domcomment_get_ownerDocument(
315 IXMLDOMComment *iface,
316 IXMLDOMDocument** domDocument)
318 domcomment *This = impl_from_IXMLDOMComment( iface );
319 return IXMLDOMNode_get_ownerDocument( This->node, domDocument );
322 static HRESULT WINAPI domcomment_cloneNode(
323 IXMLDOMComment *iface,
324 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
326 domcomment *This = impl_from_IXMLDOMComment( iface );
327 return IXMLDOMNode_cloneNode( This->node, pbool, outNode );
330 static HRESULT WINAPI domcomment_get_nodeTypeString(
331 IXMLDOMComment *iface,
332 BSTR* p)
334 domcomment *This = impl_from_IXMLDOMComment( iface );
335 return IXMLDOMNode_get_nodeTypeString( This->node, p );
338 static HRESULT WINAPI domcomment_get_text(
339 IXMLDOMComment *iface,
340 BSTR* p)
342 domcomment *This = impl_from_IXMLDOMComment( iface );
343 return IXMLDOMNode_get_text( This->node, p );
346 static HRESULT WINAPI domcomment_put_text(
347 IXMLDOMComment *iface,
348 BSTR p)
350 domcomment *This = impl_from_IXMLDOMComment( iface );
351 return IXMLDOMNode_put_text( This->node, p );
354 static HRESULT WINAPI domcomment_get_specified(
355 IXMLDOMComment *iface,
356 VARIANT_BOOL* pbool)
358 domcomment *This = impl_from_IXMLDOMComment( iface );
359 return IXMLDOMNode_get_specified( This->node, pbool );
362 static HRESULT WINAPI domcomment_get_definition(
363 IXMLDOMComment *iface,
364 IXMLDOMNode** domNode)
366 domcomment *This = impl_from_IXMLDOMComment( iface );
367 return IXMLDOMNode_get_definition( This->node, domNode );
370 static HRESULT WINAPI domcomment_get_nodeTypedValue(
371 IXMLDOMComment *iface,
372 VARIANT* var1)
374 domcomment *This = impl_from_IXMLDOMComment( iface );
375 return IXMLDOMNode_get_nodeTypedValue( This->node, var1 );
378 static HRESULT WINAPI domcomment_put_nodeTypedValue(
379 IXMLDOMComment *iface,
380 VARIANT var1)
382 domcomment *This = impl_from_IXMLDOMComment( iface );
383 return IXMLDOMNode_put_nodeTypedValue( This->node, var1 );
386 static HRESULT WINAPI domcomment_get_dataType(
387 IXMLDOMComment *iface,
388 VARIANT* var1)
390 domcomment *This = impl_from_IXMLDOMComment( iface );
391 return IXMLDOMNode_get_dataType( This->node, var1 );
394 static HRESULT WINAPI domcomment_put_dataType(
395 IXMLDOMComment *iface,
396 BSTR p)
398 domcomment *This = impl_from_IXMLDOMComment( iface );
399 return IXMLDOMNode_put_dataType( This->node, p );
402 static HRESULT WINAPI domcomment_get_xml(
403 IXMLDOMComment *iface,
404 BSTR* p)
406 domcomment *This = impl_from_IXMLDOMComment( iface );
407 return IXMLDOMNode_get_xml( This->node, p );
410 static HRESULT WINAPI domcomment_transformNode(
411 IXMLDOMComment *iface,
412 IXMLDOMNode* domNode, BSTR* p)
414 domcomment *This = impl_from_IXMLDOMComment( iface );
415 return IXMLDOMNode_transformNode( This->node, domNode, p );
418 static HRESULT WINAPI domcomment_selectNodes(
419 IXMLDOMComment *iface,
420 BSTR p, IXMLDOMNodeList** outList)
422 domcomment *This = impl_from_IXMLDOMComment( iface );
423 return IXMLDOMNode_selectNodes( This->node, p, outList );
426 static HRESULT WINAPI domcomment_selectSingleNode(
427 IXMLDOMComment *iface,
428 BSTR p, IXMLDOMNode** outNode)
430 domcomment *This = impl_from_IXMLDOMComment( iface );
431 return IXMLDOMNode_selectSingleNode( This->node, p, outNode );
434 static HRESULT WINAPI domcomment_get_parsed(
435 IXMLDOMComment *iface,
436 VARIANT_BOOL* pbool)
438 domcomment *This = impl_from_IXMLDOMComment( iface );
439 return IXMLDOMNode_get_parsed( This->node, pbool );
442 static HRESULT WINAPI domcomment_get_namespaceURI(
443 IXMLDOMComment *iface,
444 BSTR* p)
446 domcomment *This = impl_from_IXMLDOMComment( iface );
447 return IXMLDOMNode_get_namespaceURI( This->node, p );
450 static HRESULT WINAPI domcomment_get_prefix(
451 IXMLDOMComment *iface,
452 BSTR* p)
454 domcomment *This = impl_from_IXMLDOMComment( iface );
455 return IXMLDOMNode_get_prefix( This->node, p );
458 static HRESULT WINAPI domcomment_get_baseName(
459 IXMLDOMComment *iface,
460 BSTR* p)
462 domcomment *This = impl_from_IXMLDOMComment( iface );
463 return IXMLDOMNode_get_baseName( This->node, p );
466 static HRESULT WINAPI domcomment_transformNodeToObject(
467 IXMLDOMComment *iface,
468 IXMLDOMNode* domNode, VARIANT var1)
470 domcomment *This = impl_from_IXMLDOMComment( iface );
471 return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 );
474 static HRESULT WINAPI domcomment_get_data(
475 IXMLDOMComment *iface,
476 BSTR *p)
478 domcomment *This = impl_from_IXMLDOMComment( iface );
479 HRESULT hr = E_FAIL;
480 VARIANT vRet;
482 if(!p)
483 return E_INVALIDARG;
485 hr = IXMLDOMNode_get_nodeValue( This->node, &vRet );
486 if(hr == S_OK)
488 *p = V_BSTR(&vRet);
491 return hr;
494 static HRESULT WINAPI domcomment_put_data(
495 IXMLDOMComment *iface,
496 BSTR data)
498 domcomment *This = impl_from_IXMLDOMComment( iface );
499 HRESULT hr = E_FAIL;
500 VARIANT val;
502 TRACE("%p %s\n", This, debugstr_w(data) );
504 V_VT(&val) = VT_BSTR;
505 V_BSTR(&val) = data;
507 hr = IXMLDOMNode_put_nodeValue( This->node, val );
509 return hr;
512 static HRESULT WINAPI domcomment_get_length(
513 IXMLDOMComment *iface,
514 LONG *len)
516 domcomment *This = impl_from_IXMLDOMComment( iface );
517 xmlnode *pDOMNode = impl_from_IXMLDOMNode( This->node );
518 xmlChar *pContent;
519 LONG nLength = 0;
521 TRACE("%p\n", iface);
523 if(!len)
524 return E_INVALIDARG;
526 pContent = xmlNodeGetContent(pDOMNode->node);
527 if(pContent)
529 nLength = xmlStrlen(pContent);
530 xmlFree(pContent);
533 *len = nLength;
535 return S_OK;
538 static HRESULT WINAPI domcomment_substringData(
539 IXMLDOMComment *iface,
540 LONG offset, LONG count, BSTR *p)
542 domcomment *This = impl_from_IXMLDOMComment( iface );
543 xmlnode *pDOMNode = impl_from_IXMLDOMNode( This->node );
544 xmlChar *pContent;
545 LONG nLength = 0;
546 HRESULT hr = S_FALSE;
548 TRACE("%p\n", iface);
550 if(!p)
551 return E_INVALIDARG;
553 *p = NULL;
554 if(offset < 0 || count < 0)
555 return E_INVALIDARG;
557 if(count == 0)
558 return hr;
560 pContent = xmlNodeGetContent(pDOMNode->node);
561 if(pContent)
563 nLength = xmlStrlen(pContent);
565 if( offset < nLength)
567 BSTR sContent = bstr_from_xmlChar(pContent);
568 if(offset + count > nLength)
569 *p = SysAllocString(&sContent[offset]);
570 else
571 *p = SysAllocStringLen(&sContent[offset], count);
573 SysFreeString(sContent);
574 hr = S_OK;
577 xmlFree(pContent);
580 return hr;
583 static HRESULT WINAPI domcomment_appendData(
584 IXMLDOMComment *iface,
585 BSTR p)
587 domcomment *This = impl_from_IXMLDOMComment( iface );
588 xmlnode *pDOMNode = impl_from_IXMLDOMNode( This->node );
589 xmlChar *pContent;
590 HRESULT hr = S_FALSE;
592 TRACE("%p\n", iface);
594 /* Nothing to do if NULL or an Empty string passed in. */
595 if(p == NULL || SysStringLen(p) == 0)
596 return S_OK;
598 pContent = xmlChar_from_wchar( p );
599 if(pContent)
601 /* Older versions of libxml < 2.6.27 didn't correctly support
602 xmlTextConcat on Comment nodes. Fallback to setting the
603 contents directly if xmlTextConcat fails.
605 if(xmlTextConcat(pDOMNode->node, pContent, SysStringLen(p) ) == 0)
606 hr = S_OK;
607 else
609 xmlChar *pNew;
610 pNew = xmlStrcat(xmlNodeGetContent(pDOMNode->node), pContent);
611 if(pNew)
613 xmlNodeSetContent(pDOMNode->node, pNew);
614 hr = S_OK;
616 else
617 hr = E_FAIL;
619 HeapFree( GetProcessHeap(), 0, pContent );
621 else
622 hr = E_FAIL;
624 return hr;
627 static HRESULT WINAPI domcomment_insertData(
628 IXMLDOMComment *iface,
629 LONG offset, BSTR p)
631 domcomment *This = impl_from_IXMLDOMComment( iface );
632 xmlnode *pDOMNode = impl_from_IXMLDOMNode( This->node );
633 xmlChar *pXmlContent;
634 BSTR sNewString;
635 HRESULT hr = S_FALSE;
636 LONG nLength = 0, nLengthP = 0;
637 xmlChar *str = NULL;
639 TRACE("%p\n", This);
641 /* If have a NULL or empty string, don't do anything. */
642 if(SysStringLen(p) == 0)
643 return S_OK;
645 if(offset < 0)
647 return E_INVALIDARG;
650 pXmlContent = xmlNodeGetContent(pDOMNode->node);
651 if(pXmlContent)
653 BSTR sContent = bstr_from_xmlChar( pXmlContent );
654 nLength = SysStringLen(sContent);
655 nLengthP = SysStringLen(p);
657 if(nLength < offset)
659 SysFreeString(sContent);
660 xmlFree(pXmlContent);
662 return E_INVALIDARG;
665 sNewString = SysAllocStringLen(NULL, nLength + nLengthP + 1);
666 if(sNewString)
668 if(offset > 0)
669 memcpy(sNewString, sContent, offset * sizeof(WCHAR));
671 memcpy(&sNewString[offset], p, nLengthP * sizeof(WCHAR));
673 if(offset+nLengthP < nLength)
674 memcpy(&sNewString[offset+nLengthP], &sContent[offset], (nLength-offset) * sizeof(WCHAR));
676 sNewString[nLengthP + nLength] = 0;
678 str = xmlChar_from_wchar(sNewString);
679 if(str)
681 xmlNodeSetContent(pDOMNode->node, str);
682 hr = S_OK;
684 HeapFree( GetProcessHeap(), 0, str );
686 SysFreeString(sNewString);
689 SysFreeString(sContent);
691 xmlFree(pXmlContent);
694 return hr;
697 static HRESULT WINAPI domcomment_deleteData(
698 IXMLDOMComment *iface,
699 LONG offset, LONG count)
701 FIXME("\n");
702 return E_NOTIMPL;
705 static HRESULT WINAPI domcomment_replaceData(
706 IXMLDOMComment *iface,
707 LONG offset, LONG count, BSTR p)
709 FIXME("\n");
710 return E_NOTIMPL;
713 static const struct IXMLDOMCommentVtbl domcomment_vtbl =
715 domcomment_QueryInterface,
716 domcomment_AddRef,
717 domcomment_Release,
718 domcomment_GetTypeInfoCount,
719 domcomment_GetTypeInfo,
720 domcomment_GetIDsOfNames,
721 domcomment_Invoke,
722 domcomment_get_nodeName,
723 domcomment_get_nodeValue,
724 domcomment_put_nodeValue,
725 domcomment_get_nodeType,
726 domcomment_get_parentNode,
727 domcomment_get_childNodes,
728 domcomment_get_firstChild,
729 domcomment_get_lastChild,
730 domcomment_get_previousSibling,
731 domcomment_get_nextSibling,
732 domcomment_get_attributes,
733 domcomment_insertBefore,
734 domcomment_replaceChild,
735 domcomment_removeChild,
736 domcomment_appendChild,
737 domcomment_hasChildNodes,
738 domcomment_get_ownerDocument,
739 domcomment_cloneNode,
740 domcomment_get_nodeTypeString,
741 domcomment_get_text,
742 domcomment_put_text,
743 domcomment_get_specified,
744 domcomment_get_definition,
745 domcomment_get_nodeTypedValue,
746 domcomment_put_nodeTypedValue,
747 domcomment_get_dataType,
748 domcomment_put_dataType,
749 domcomment_get_xml,
750 domcomment_transformNode,
751 domcomment_selectNodes,
752 domcomment_selectSingleNode,
753 domcomment_get_parsed,
754 domcomment_get_namespaceURI,
755 domcomment_get_prefix,
756 domcomment_get_baseName,
757 domcomment_transformNodeToObject,
758 domcomment_get_data,
759 domcomment_put_data,
760 domcomment_get_length,
761 domcomment_substringData,
762 domcomment_appendData,
763 domcomment_insertData,
764 domcomment_deleteData,
765 domcomment_replaceData
768 IUnknown* create_comment( xmlNodePtr comment )
770 domcomment *This;
771 HRESULT hr;
773 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
774 if ( !This )
775 return NULL;
777 This->lpVtbl = &domcomment_vtbl;
778 This->ref = 1;
780 This->node_unk = create_basic_node( comment, (IUnknown*)&This->lpVtbl );
781 if(!This->node_unk)
783 HeapFree(GetProcessHeap(), 0, This);
784 return NULL;
787 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
788 if(FAILED(hr))
790 IUnknown_Release(This->node_unk);
791 HeapFree( GetProcessHeap(), 0, This );
792 return NULL;
794 /* The ref on This->node is actually looped back into this object, so release it */
795 IXMLDOMNode_Release(This->node);
797 return (IUnknown*) &This->lpVtbl;
800 #endif