2 * Node list implementation
4 * Copyright 2005 Mike McCormack
6 * iface 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 * iface 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include "msxml_private.h"
38 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
44 typedef struct _xmlnodelist
46 const struct IXMLDOMNodeListVtbl *lpVtbl;
52 static inline xmlnodelist *impl_from_IXMLDOMNodeList( IXMLDOMNodeList *iface )
54 return (xmlnodelist *)((char*)iface - FIELD_OFFSET(xmlnodelist, lpVtbl));
57 static HRESULT WINAPI xmlnodelist_QueryInterface(
58 IXMLDOMNodeList *iface,
62 TRACE("%p %p %p\n", iface, debugstr_guid(riid), ppvObject);
64 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
65 IsEqualGUID( riid, &IID_IDispatch ) ||
66 IsEqualGUID( riid, &IID_IXMLDOMNodeList ) )
73 IXMLDOMNodeList_AddRef( iface );
78 static ULONG WINAPI xmlnodelist_AddRef(
79 IXMLDOMNodeList *iface )
81 xmlnodelist *This = impl_from_IXMLDOMNodeList( iface );
82 return InterlockedIncrement( &This->ref );
85 static ULONG WINAPI xmlnodelist_Release(
86 IXMLDOMNodeList *iface )
88 xmlnodelist *This = impl_from_IXMLDOMNodeList( iface );
91 ref = InterlockedDecrement( &This->ref );
94 HeapFree( GetProcessHeap(), 0, This );
100 static HRESULT WINAPI xmlnodelist_GetTypeInfoCount(
101 IXMLDOMNodeList *iface,
108 static HRESULT WINAPI xmlnodelist_GetTypeInfo(
109 IXMLDOMNodeList *iface,
112 ITypeInfo** ppTInfo )
118 static HRESULT WINAPI xmlnodelist_GetIDsOfNames(
119 IXMLDOMNodeList *iface,
130 static HRESULT WINAPI xmlnodelist_Invoke(
131 IXMLDOMNodeList *iface,
136 DISPPARAMS* pDispParams,
138 EXCEPINFO* pExcepInfo,
145 static HRESULT WINAPI xmlnodelist_get_item(
146 IXMLDOMNodeList* iface,
148 IXMLDOMNode** listItem)
154 static HRESULT WINAPI xmlnodelist_get_length(
155 IXMLDOMNodeList* iface,
162 static HRESULT WINAPI xmlnodelist_nextNode(
163 IXMLDOMNodeList* iface,
164 IXMLDOMNode** nextItem)
166 xmlnodelist *This = impl_from_IXMLDOMNodeList( iface );
168 TRACE("%p %p\n", This, nextItem );
173 *nextItem = create_node( This->current );
174 This->current = This->current->next;
178 static HRESULT WINAPI xmlnodelist_reset(
179 IXMLDOMNodeList* iface)
185 static HRESULT WINAPI xmlnodelist__newEnum(
186 IXMLDOMNodeList* iface,
194 static const struct IXMLDOMNodeListVtbl xmlnodelist_vtbl =
196 xmlnodelist_QueryInterface,
199 xmlnodelist_GetTypeInfoCount,
200 xmlnodelist_GetTypeInfo,
201 xmlnodelist_GetIDsOfNames,
203 xmlnodelist_get_item,
204 xmlnodelist_get_length,
205 xmlnodelist_nextNode,
207 xmlnodelist__newEnum,
210 IXMLDOMNodeList* create_nodelist( xmlNodePtr node )
212 xmlnodelist *nodelist;
214 nodelist = HeapAlloc( GetProcessHeap(), 0, sizeof *nodelist );
218 nodelist->lpVtbl = &xmlnodelist_vtbl;
220 nodelist->node = node;
221 nodelist->current = node;
223 return (IXMLDOMNodeList*) &nodelist->lpVtbl;