From 7b30c79cfdf5829a2b2a5fc4d0be0e510a33af25 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sat, 29 Aug 2009 15:01:37 +0200 Subject: [PATCH] msxml3: Moved IDispatchEx implementation from domdoc to xmlnode. --- dlls/msxml3/attribute.c | 2 +- dlls/msxml3/cdata.c | 2 +- dlls/msxml3/comment.c | 2 +- dlls/msxml3/docfrag.c | 2 +- dlls/msxml3/domdoc.c | 9 +-- dlls/msxml3/element.c | 2 +- dlls/msxml3/entityref.c | 2 +- dlls/msxml3/msxml_private.h | 145 ++++++++++++++++++------------------ dlls/msxml3/node.c | 7 +- dlls/msxml3/pi.c | 2 +- dlls/msxml3/text.c | 2 +- 11 files changed, 88 insertions(+), 89 deletions(-) diff --git a/dlls/msxml3/attribute.c b/dlls/msxml3/attribute.c index 9fabc469a7d..2fc32be11d0 100644 --- a/dlls/msxml3/attribute.c +++ b/dlls/msxml3/attribute.c @@ -556,7 +556,7 @@ IUnknown* create_attribute( xmlNodePtr attribute ) This->lpVtbl = &domattr_vtbl; This->ref = 1; - node = create_basic_node( attribute, (IUnknown*)&This->lpVtbl ); + node = create_basic_node( attribute, (IUnknown*)&This->lpVtbl, NULL ); if(!node) { HeapFree(GetProcessHeap(), 0, This); diff --git a/dlls/msxml3/cdata.c b/dlls/msxml3/cdata.c index a9b7fee34a0..b0ef3d76595 100644 --- a/dlls/msxml3/cdata.c +++ b/dlls/msxml3/cdata.c @@ -779,7 +779,7 @@ IUnknown* create_cdata( xmlNodePtr text ) This->lpVtbl = &domcdata_vtbl; This->ref = 1; - node = create_basic_node( text, (IUnknown*)&This->lpVtbl ); + node = create_basic_node( text, (IUnknown*)&This->lpVtbl, NULL ); if(!node) { HeapFree(GetProcessHeap(), 0, This); diff --git a/dlls/msxml3/comment.c b/dlls/msxml3/comment.c index a8cf528a374..346ad192730 100644 --- a/dlls/msxml3/comment.c +++ b/dlls/msxml3/comment.c @@ -777,7 +777,7 @@ IUnknown* create_comment( xmlNodePtr comment ) This->lpVtbl = &domcomment_vtbl; This->ref = 1; - node = create_basic_node( comment, (IUnknown*)&This->lpVtbl ); + node = create_basic_node( comment, (IUnknown*)&This->lpVtbl, NULL ); if(!node) { HeapFree(GetProcessHeap(), 0, This); diff --git a/dlls/msxml3/docfrag.c b/dlls/msxml3/docfrag.c index 572d223d44d..1330c196ba0 100644 --- a/dlls/msxml3/docfrag.c +++ b/dlls/msxml3/docfrag.c @@ -529,7 +529,7 @@ IUnknown* create_doc_fragment( xmlNodePtr fragment ) This->lpVtbl = &domfrag_vtbl; This->ref = 1; - node = create_basic_node( fragment, (IUnknown*)&This->lpVtbl ); + node = create_basic_node( fragment, (IUnknown*)&This->lpVtbl, NULL ); if(!node) { HeapFree(GetProcessHeap(), 0, This); diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index 2d54fe012b4..ad0fe0a49bc 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -77,9 +77,6 @@ typedef struct _domdoc /* IObjectSafety */ DWORD safeopt; - - /* IDispatchEx */ - DispatchEx dispex; } domdoc; /* @@ -466,7 +463,7 @@ static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument2 *iface, REFIID rii { *ppvObject = &This->lpvtblISupportErrorInfo; } - else if(dispex_query_interface(&This->dispex, riid, ppvObject)) + else if(dispex_query_interface(&This->node->dispex, riid, ppvObject)) { return *ppvObject ? S_OK : E_NOINTERFACE; } @@ -2218,15 +2215,13 @@ HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **docu doc->safeopt = 0; doc->bsc = NULL; - doc->node = create_basic_node( (xmlNodePtr)xmldoc, (IUnknown*)&doc->lpVtbl ); + doc->node = create_basic_node( (xmlNodePtr)xmldoc, (IUnknown*)&doc->lpVtbl, &domdoc_dispex ); if(!doc->node) { HeapFree(GetProcessHeap(), 0, doc); return E_FAIL; } - init_dispex(&doc->dispex, (IUnknown*)&doc->lpVtbl, &domdoc_dispex); - *document = (IXMLDOMDocument2*)&doc->lpVtbl; TRACE("returning iface %p\n", *document); diff --git a/dlls/msxml3/element.c b/dlls/msxml3/element.c index ce99ba98107..6590e5baed5 100644 --- a/dlls/msxml3/element.c +++ b/dlls/msxml3/element.c @@ -762,7 +762,7 @@ IUnknown* create_element( xmlNodePtr element ) This->lpVtbl = &domelem_vtbl; This->ref = 1; - This->node = create_basic_node( element, (IUnknown*)&This->lpVtbl ); + This->node = create_basic_node( element, (IUnknown*)&This->lpVtbl, NULL ); if(!This->node) { HeapFree(GetProcessHeap(), 0, This); diff --git a/dlls/msxml3/entityref.c b/dlls/msxml3/entityref.c index 1726e2f1697..102bf44533b 100644 --- a/dlls/msxml3/entityref.c +++ b/dlls/msxml3/entityref.c @@ -528,7 +528,7 @@ IUnknown* create_doc_entity_ref( xmlNodePtr entity ) This->lpVtbl = &entityref_vtbl; This->ref = 1; - node = create_basic_node( entity, (IUnknown*)&This->lpVtbl ); + node = create_basic_node( entity, (IUnknown*)&This->lpVtbl, NULL ); if(!node) { HeapFree(GetProcessHeap(), 0, This); diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index 18b44bdd3d5..d74d7ae9e39 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -68,78 +68,6 @@ extern HRESULT XMLElement_create( IUnknown *pUnkOuter, xmlNodePtr node, LPVOID * extern xmlDocPtr parse_xml(char *ptr, int len); -/* IXMLDOMNode Internal Structure */ -typedef struct _xmlnode -{ - const struct IXMLDOMNodeVtbl *lpVtbl; - const struct IUnknownVtbl *lpInternalUnkVtbl; - IUnknown *pUnkOuter; - LONG ref; - xmlNodePtr node; -} xmlnode; - -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) -{ - BSTR ret = NULL; - - if(str) { - DWORD len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1, NULL, 0); - ret = SysAllocStringLen(NULL, len-1); - if(ret) - MultiByteToWideChar( CP_UTF8, 0, (LPCSTR)str, -1, ret, len); - } - - return ret; -} - -#endif - -void* libxslt_handle; -#ifdef SONAME_LIBXSLT -# ifdef HAVE_LIBXSLT_PATTERN_H -# include -# endif -# ifdef HAVE_LIBXSLT_TRANSFORM_H -# include -# endif -# include -# include - -# define MAKE_FUNCPTR(f) extern typeof(f) * p##f -MAKE_FUNCPTR(xsltApplyStylesheet); -MAKE_FUNCPTR(xsltCleanupGlobals); -MAKE_FUNCPTR(xsltFreeStylesheet); -MAKE_FUNCPTR(xsltParseStylesheetDoc); -# undef MAKE_FUNCPTR -#endif - -extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText, - LONG line, LONG linepos, LONG filepos ); -extern HRESULT DOMDocument_create( IUnknown *pUnkOuter, LPVOID *ppObj ); -extern HRESULT SchemaCache_create( IUnknown *pUnkOuter, LPVOID *ppObj ); -extern HRESULT XMLDocument_create( IUnknown *pUnkOuter, LPVOID *ppObj ); -extern HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj ); -extern HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, LPVOID *ppObj); - -typedef struct bsc_t bsc_t; - -HRESULT bind_url(LPCWSTR, HRESULT (*onDataAvailable)(void*,char*,DWORD), void*, bsc_t**); -void detach_bsc(bsc_t*); - /* typelibs */ typedef enum tid_t { IXMLDOMAttribute_tid, @@ -210,6 +138,79 @@ typedef struct { void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*); BOOL dispex_query_interface(DispatchEx*,REFIID,void**); +/* IXMLDOMNode Internal Structure */ +typedef struct _xmlnode +{ + DispatchEx dispex; + const struct IXMLDOMNodeVtbl *lpVtbl; + const struct IUnknownVtbl *lpInternalUnkVtbl; + IUnknown *pUnkOuter; + LONG ref; + xmlNodePtr node; +} xmlnode; + +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*,dispex_static_data_t*); + +extern HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **document); + +static inline BSTR bstr_from_xmlChar(const xmlChar *str) +{ + BSTR ret = NULL; + + if(str) { + DWORD len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1, NULL, 0); + ret = SysAllocStringLen(NULL, len-1); + if(ret) + MultiByteToWideChar( CP_UTF8, 0, (LPCSTR)str, -1, ret, len); + } + + return ret; +} + +#endif + +void* libxslt_handle; +#ifdef SONAME_LIBXSLT +# ifdef HAVE_LIBXSLT_PATTERN_H +# include +# endif +# ifdef HAVE_LIBXSLT_TRANSFORM_H +# include +# endif +# include +# include + +# define MAKE_FUNCPTR(f) extern typeof(f) * p##f +MAKE_FUNCPTR(xsltApplyStylesheet); +MAKE_FUNCPTR(xsltCleanupGlobals); +MAKE_FUNCPTR(xsltFreeStylesheet); +MAKE_FUNCPTR(xsltParseStylesheetDoc); +# undef MAKE_FUNCPTR +#endif + +extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText, + LONG line, LONG linepos, LONG filepos ); +extern HRESULT DOMDocument_create( IUnknown *pUnkOuter, LPVOID *ppObj ); +extern HRESULT SchemaCache_create( IUnknown *pUnkOuter, LPVOID *ppObj ); +extern HRESULT XMLDocument_create( IUnknown *pUnkOuter, LPVOID *ppObj ); +extern HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj ); +extern HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, LPVOID *ppObj); + +typedef struct bsc_t bsc_t; + +HRESULT bind_url(LPCWSTR, HRESULT (*onDataAvailable)(void*,char*,DWORD), void*, bsc_t**); +void detach_bsc(bsc_t*); + /* memory allocation functions */ static inline void *heap_alloc(size_t len) diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index a7fa63f4acf..987b07d2d09 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -1542,7 +1542,7 @@ static const struct IUnknownVtbl internal_unk_vtbl = Internal_Release }; -xmlnode *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter ) +xmlnode *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter, dispex_static_data_t *dispex_data ) { xmlnode *This; @@ -1561,6 +1561,9 @@ xmlnode *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter ) else This->pUnkOuter = (IUnknown *)&This->lpInternalUnkVtbl; + if(dispex_data) + init_dispex(&This->dispex, This->pUnkOuter, dispex_data); + This->ref = 1; This->node = node; @@ -1599,7 +1602,7 @@ IXMLDOMNode *create_node( xmlNodePtr node ) break; default: FIXME("only creating basic node for type %d\n", node->type); - pUnk = (IUnknown*)&create_basic_node( node, NULL )->lpInternalUnkVtbl; + pUnk = (IUnknown*)&create_basic_node( node, NULL, NULL )->lpInternalUnkVtbl; } hr = IUnknown_QueryInterface(pUnk, &IID_IXMLDOMNode, (LPVOID*)&ret); diff --git a/dlls/msxml3/pi.c b/dlls/msxml3/pi.c index 00a52665088..ddcf68b9415 100644 --- a/dlls/msxml3/pi.c +++ b/dlls/msxml3/pi.c @@ -614,7 +614,7 @@ IUnknown* create_pi( xmlNodePtr pi ) This->lpVtbl = &dom_pi_vtbl; This->ref = 1; - node = create_basic_node( pi, (IUnknown*)&This->lpVtbl ); + node = create_basic_node( pi, (IUnknown*)&This->lpVtbl, NULL ); if(!node) { HeapFree(GetProcessHeap(), 0, This); diff --git a/dlls/msxml3/text.c b/dlls/msxml3/text.c index 58de405c321..cb1966c03ad 100644 --- a/dlls/msxml3/text.c +++ b/dlls/msxml3/text.c @@ -781,7 +781,7 @@ IUnknown* create_text( xmlNodePtr text ) This->lpVtbl = &domtext_vtbl; This->ref = 1; - node = create_basic_node( text, (IUnknown*)&This->lpVtbl ); + node = create_basic_node( text, (IUnknown*)&This->lpVtbl, NULL ); if(!node) { HeapFree(GetProcessHeap(), 0, This);