From: Vibhav Pant vibhavp@gmail.com
Implement GetView() for Windows.Foundation.Collections.PropertySet using an instance of this stub. --- dlls/wintypes/propertyset.c | 187 +++++++++++++++++++++++++++++- dlls/wintypes/tests/propertyset.c | 4 +- 2 files changed, 187 insertions(+), 4 deletions(-)
diff --git a/dlls/wintypes/propertyset.c b/dlls/wintypes/propertyset.c index ccbe30010fd..00736812730 100644 --- a/dlls/wintypes/propertyset.c +++ b/dlls/wintypes/propertyset.c @@ -30,6 +30,176 @@
WINE_DEFAULT_DEBUG_CHANNEL( wintypes );
+struct mapview_HSTRING_IInspectable +{ + IMapView_HSTRING_IInspectable IMapView_HSTRING_IInspectable_iface; + IIterable_IKeyValuePair_HSTRING_IInspectable IIterable_IKeyValuePair_HSTRING_IInspectable_iface; + + LONG ref; +}; + +static inline struct mapview_HSTRING_IInspectable * +impl_from_IMapView_HSTRING_IInspectable( IMapView_HSTRING_IInspectable *iface ) +{ + return CONTAINING_RECORD( iface, struct mapview_HSTRING_IInspectable, + IMapView_HSTRING_IInspectable_iface ); +} + +static HRESULT STDMETHODCALLTYPE mapview_HSTRING_IInspectable_QueryInterface( + IMapView_HSTRING_IInspectable *iface, REFIID iid, void **out ) +{ + TRACE( "(%p, %s, %p)\n", iface, debugstr_guid( iid ), out ); + + *out = NULL; + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IMapView_HSTRING_IInspectable )) + { + *out = iface; + IUnknown_AddRef( iface ); + return S_OK; + } + + if (IsEqualGUID( iid, &IID_IIterable_IKeyValuePair_HSTRING_IInspectable )) + { + struct mapview_HSTRING_IInspectable *impl = + impl_from_IMapView_HSTRING_IInspectable( iface ); + *out = &impl->IIterable_IKeyValuePair_HSTRING_IInspectable_iface; + IUnknown_AddRef( iface ); + return S_OK; + } + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE +mapview_HSTRING_IInspectable_AddRef( IMapView_HSTRING_IInspectable *iface ) +{ + struct mapview_HSTRING_IInspectable *impl; + + TRACE( "(%p)\n", iface ); + impl = impl_from_IMapView_HSTRING_IInspectable( iface ); + return InterlockedIncrement( &impl->ref ); +} + +static ULONG STDMETHODCALLTYPE +mapview_HSTRING_IInspectable_Release( IMapView_HSTRING_IInspectable *iface ) +{ + struct mapview_HSTRING_IInspectable *impl; + ULONG ref; + + TRACE( "(%p)\n", iface ); + impl = impl_from_IMapView_HSTRING_IInspectable( iface ); + ref = InterlockedDecrement( &impl->ref ); + if (!ref) + { + free( impl ); + } + + return ref; +} + +static HRESULT STDMETHODCALLTYPE mapview_HSTRING_IInspectable_GetIids( + IMapView_HSTRING_IInspectable *iface, ULONG *iid_count, IID **iids ) +{ + FIXME( "(%p, %p, %p) stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE mapview_HSTRING_IInspectable_GetRuntimeClassName( + IMapView_HSTRING_IInspectable *iface, HSTRING *class_name ) +{ + FIXME( "(%p, %p) stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE mapview_HSTRING_IInspectable_GetTrustLevel( + IMapView_HSTRING_IInspectable *iface, TrustLevel *trust_level ) +{ + FIXME( "(%p, %p) stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE +mapview_HSTRING_IInspectable_get_Size( IMapView_HSTRING_IInspectable *iface, UINT32 *size ) +{ + FIXME( "(%p, %p) stub!\n", iface, size ); + *size = 0; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE mapview_HSTRING_IInspectable_HaKey( + IMapView_HSTRING_IInspectable *iface, HSTRING key, boolean *exists ) +{ + FIXME( "(%p, %s, %p) stub!\n", iface, debugstr_hstring( key ), exists ); + *exists = 0; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE mapview_HSTRING_IInspectable_Lookup( + IMapView_HSTRING_IInspectable *iface, HSTRING key, IInspectable **value ) +{ + FIXME( "(%p, %s, %p) stub!\n", iface, debugstr_hstring( key ), value ); + *value = NULL; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE mapview_HSTRING_IInspectable_Split( + IMapView_HSTRING_IInspectable *iface, IMapView_HSTRING_IInspectable **first, + IMapView_HSTRING_IInspectable **second ) +{ + FIXME( "(%p, %p, %p) stub!\n", iface, first, second ); + *first = NULL; + *second = NULL; + return E_NOTIMPL; +} + +const static IMapView_HSTRING_IInspectableVtbl mapview_HSTRING_IInspectable_vtbl = +{ + /* IUnknown */ + mapview_HSTRING_IInspectable_QueryInterface, + mapview_HSTRING_IInspectable_AddRef, + mapview_HSTRING_IInspectable_Release, + /* IInspectable */ + mapview_HSTRING_IInspectable_GetIids, + mapview_HSTRING_IInspectable_GetRuntimeClassName, + mapview_HSTRING_IInspectable_GetTrustLevel, + /* IMapView<HSTRING, IInspectable*> */ + mapview_HSTRING_IInspectable_Lookup, + mapview_HSTRING_IInspectable_get_Size, + mapview_HSTRING_IInspectable_HaKey, + mapview_HSTRING_IInspectable_Split, +}; + +DEFINE_IINSPECTABLE_( mapview_iterable_kvpair_HSTRING_IInspectable, + IIterable_IKeyValuePair_HSTRING_IInspectable, + struct mapview_HSTRING_IInspectable, + mapview_impl_from_IIterable_IKeyValuePair_HSTRING_IInspectable, + IIterable_IKeyValuePair_HSTRING_IInspectable_iface, + &impl->IMapView_HSTRING_IInspectable_iface ); + +static HRESULT STDMETHODCALLTYPE mapview_iterable_kvpair_HSTRING_IInspectable_First( + IIterable_IKeyValuePair_HSTRING_IInspectable *iface, + IIterator_IKeyValuePair_HSTRING_IInspectable **iter ) +{ + FIXME( "(%p, %p) stub!\n", iface, iter ); + return E_NOTIMPL; +} + +const static IIterable_IKeyValuePair_HSTRING_IInspectableVtbl + mapview_iterable_kvpair_HSTRING_IInspectable_vtbl = +{ + /* IUnknown */ + mapview_iterable_kvpair_HSTRING_IInspectable_QueryInterface, + mapview_iterable_kvpair_HSTRING_IInspectable_AddRef, + mapview_iterable_kvpair_HSTRING_IInspectable_Release, + /* IInspectable */ + mapview_iterable_kvpair_HSTRING_IInspectable_GetIids, + mapview_iterable_kvpair_HSTRING_IInspectable_GetRuntimeClassName, + mapview_iterable_kvpair_HSTRING_IInspectable_GetTrustLevel, + /* IIterable<IKeyValuePair<HSTRING, IInspectable*>> */ + mapview_iterable_kvpair_HSTRING_IInspectable_First +}; + struct propertyset { IPropertySet IPropertySet_iface; @@ -209,9 +379,22 @@ static HRESULT STDMETHODCALLTYPE propertyset_HasKey( IMap_HSTRING_IInspectable * static HRESULT STDMETHODCALLTYPE propertyset_GetView( IMap_HSTRING_IInspectable *iface, IMapView_HSTRING_IInspectable **view ) { - FIXME( "(%p, %p) stub!\n", iface, view ); + struct mapview_HSTRING_IInspectable *view_impl; + + FIXME( "(%p, %p) semi-stub!\n", iface, view ); *view = NULL; - return E_NOTIMPL; + view_impl = calloc( 1, sizeof( *view_impl ) ); + if (!view_impl) + return E_OUTOFMEMORY; + + view_impl->IMapView_HSTRING_IInspectable_iface.lpVtbl = &mapview_HSTRING_IInspectable_vtbl; + view_impl->IIterable_IKeyValuePair_HSTRING_IInspectable_iface.lpVtbl = + &mapview_iterable_kvpair_HSTRING_IInspectable_vtbl; + + view_impl->ref = 1; + *view = &view_impl->IMapView_HSTRING_IInspectable_iface; + + return S_OK; }
static HRESULT STDMETHODCALLTYPE propertyset_Insert( IMap_HSTRING_IInspectable *iface, diff --git a/dlls/wintypes/tests/propertyset.c b/dlls/wintypes/tests/propertyset.c index 9b8235192a6..b91cc0ed46d 100644 --- a/dlls/wintypes/tests/propertyset.c +++ b/dlls/wintypes/tests/propertyset.c @@ -124,12 +124,12 @@ static void test_IPropertySet(void) skip( "Could not obtain IIterable<IKeyValuePair<HSTRING, IInspectable *>> instance.\n");
hr = IMap_HSTRING_IInspectable_GetView( map, &map_view ); - todo_wine ok( SUCCEEDED( hr ), "GetView failed, got %#lx\n", hr ); + ok( SUCCEEDED( hr ), "GetView failed, got %#lx\n", hr ); if (SUCCEEDED( hr )) { hr = IMapView_HSTRING_IInspectable_QueryInterface( map_view, &IID_IIterable_IKeyValuePair_HSTRING_IInspectable, (void **)&iterable ); - todo_wine ok( SUCCEEDED( hr ), "QuerInterface failed, got %#lx\n", hr ); + ok( SUCCEEDED( hr ), "QuerInterface failed, got %#lx\n", hr ); if (iterable) { hr = IIterable_IKeyValuePair_HSTRING_IInspectable_First( iterable, &iterator );