wbemdisp: Reimplement ISWbemObjectSet::get__NewEnum on top of IEnumWbemClassObject::Clone.

This commit is contained in:
Hans Leidekker 2015-01-15 12:43:52 +01:00 committed by Alexandre Julliard
parent 9d52d8c07d
commit 0a6d0d327c

View file

@ -36,7 +36,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp); WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp);
static HRESULT EnumVARIANT_create( ISWbemObjectSet *, IEnumVARIANT ** ); static HRESULT EnumVARIANT_create( IEnumWbemClassObject *, IEnumVARIANT ** );
enum type_id enum type_id
{ {
@ -489,10 +489,17 @@ static HRESULT WINAPI objectset_get__NewEnum(
IUnknown **pUnk ) IUnknown **pUnk )
{ {
struct objectset *objectset = impl_from_ISWbemObjectSet( iface ); struct objectset *objectset = impl_from_ISWbemObjectSet( iface );
IEnumWbemClassObject *objectenum;
HRESULT hr;
TRACE( "%p, %p\n", objectset, pUnk ); TRACE( "%p, %p\n", objectset, pUnk );
return EnumVARIANT_create( iface, (IEnumVARIANT **)pUnk ); hr = IEnumWbemClassObject_Clone( objectset->objectenum, &objectenum );
if (FAILED( hr )) return hr;
hr = EnumVARIANT_create( objectenum, (IEnumVARIANT **)pUnk );
IEnumWbemClassObject_Release( objectenum );
return hr;
} }
static HRESULT WINAPI objectset_Item( static HRESULT WINAPI objectset_Item(
@ -581,7 +588,7 @@ struct enumvar
{ {
IEnumVARIANT IEnumVARIANT_iface; IEnumVARIANT IEnumVARIANT_iface;
LONG refs; LONG refs;
ISWbemObjectSet *objectset; IEnumWbemClassObject *objectenum;
}; };
static inline struct enumvar *impl_from_IEnumVARIANT( static inline struct enumvar *impl_from_IEnumVARIANT(
@ -605,7 +612,7 @@ static ULONG WINAPI enumvar_Release(
if (!refs) if (!refs)
{ {
TRACE( "destroying %p\n", enumvar ); TRACE( "destroying %p\n", enumvar );
ISWbemObjectSet_Release( enumvar->objectset ); IEnumWbemClassObject_Release( enumvar->objectenum );
heap_free( enumvar ); heap_free( enumvar );
} }
return refs; return refs;
@ -637,13 +644,12 @@ static HRESULT WINAPI enumvar_QueryInterface(
static HRESULT WINAPI enumvar_Next( IEnumVARIANT *iface, ULONG celt, VARIANT *var, ULONG *fetched ) static HRESULT WINAPI enumvar_Next( IEnumVARIANT *iface, ULONG celt, VARIANT *var, ULONG *fetched )
{ {
struct enumvar *enumvar = impl_from_IEnumVARIANT( iface ); struct enumvar *enumvar = impl_from_IEnumVARIANT( iface );
struct objectset *objectset = impl_from_ISWbemObjectSet( enumvar->objectset );
IWbemClassObject *obj; IWbemClassObject *obj;
ULONG count = 0; ULONG count = 0;
TRACE( "%p, %u, %p, %p\n", iface, celt, var, fetched ); TRACE( "%p, %u, %p, %p\n", iface, celt, var, fetched );
if (celt) IEnumWbemClassObject_Next( objectset->objectenum, WBEM_INFINITE, 1, &obj, &count ); if (celt) IEnumWbemClassObject_Next( enumvar->objectenum, WBEM_INFINITE, 1, &obj, &count );
if (count) if (count)
{ {
ISWbemObject *sobj; ISWbemObject *sobj;
@ -663,21 +669,19 @@ static HRESULT WINAPI enumvar_Next( IEnumVARIANT *iface, ULONG celt, VARIANT *va
static HRESULT WINAPI enumvar_Skip( IEnumVARIANT *iface, ULONG celt ) static HRESULT WINAPI enumvar_Skip( IEnumVARIANT *iface, ULONG celt )
{ {
struct enumvar *enumvar = impl_from_IEnumVARIANT( iface ); struct enumvar *enumvar = impl_from_IEnumVARIANT( iface );
struct objectset *objectset = impl_from_ISWbemObjectSet( enumvar->objectset );
TRACE( "%p, %u\n", iface, celt ); TRACE( "%p, %u\n", iface, celt );
return IEnumWbemClassObject_Skip( objectset->objectenum, WBEM_INFINITE, celt ); return IEnumWbemClassObject_Skip( enumvar->objectenum, WBEM_INFINITE, celt );
} }
static HRESULT WINAPI enumvar_Reset( IEnumVARIANT *iface ) static HRESULT WINAPI enumvar_Reset( IEnumVARIANT *iface )
{ {
struct enumvar *enumvar = impl_from_IEnumVARIANT( iface ); struct enumvar *enumvar = impl_from_IEnumVARIANT( iface );
struct objectset *objectset = impl_from_ISWbemObjectSet( enumvar->objectset );
TRACE( "%p\n", iface ); TRACE( "%p\n", iface );
return IEnumWbemClassObject_Reset( objectset->objectenum ); return IEnumWbemClassObject_Reset( enumvar->objectenum );
} }
static HRESULT WINAPI enumvar_Clone( IEnumVARIANT *iface, IEnumVARIANT **penum ) static HRESULT WINAPI enumvar_Clone( IEnumVARIANT *iface, IEnumVARIANT **penum )
@ -697,15 +701,15 @@ static const struct IEnumVARIANTVtbl enumvar_vtbl =
enumvar_Clone enumvar_Clone
}; };
static HRESULT EnumVARIANT_create( ISWbemObjectSet *objectset, IEnumVARIANT **obj ) static HRESULT EnumVARIANT_create( IEnumWbemClassObject *objectenum, IEnumVARIANT **obj )
{ {
struct enumvar *enumvar; struct enumvar *enumvar;
if (!(enumvar = heap_alloc( sizeof(*enumvar) ))) return E_OUTOFMEMORY; if (!(enumvar = heap_alloc( sizeof(*enumvar) ))) return E_OUTOFMEMORY;
enumvar->IEnumVARIANT_iface.lpVtbl = &enumvar_vtbl; enumvar->IEnumVARIANT_iface.lpVtbl = &enumvar_vtbl;
enumvar->refs = 1; enumvar->refs = 1;
enumvar->objectset = objectset; enumvar->objectenum = objectenum;
ISWbemObjectSet_AddRef( enumvar->objectset ); IEnumWbemClassObject_AddRef( enumvar->objectenum );
*obj = &enumvar->IEnumVARIANT_iface; *obj = &enumvar->IEnumVARIANT_iface;
TRACE( "returning iface %p\n", *obj ); TRACE( "returning iface %p\n", *obj );