From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.media.speech/Makefile.in | 3 +- dlls/windows.media.speech/listconstraint.c | 4 +- dlls/windows.media.speech/private.h | 3 - include/wine/winrt.idl | 3 + libs/winewinrt/Makefile.in | 1 + .../winewinrt/vector_hstring.c | 342 ++++++++---------- 6 files changed, 163 insertions(+), 193 deletions(-) rename dlls/windows.media.speech/vector.c => libs/winewinrt/vector_hstring.c (62%)
diff --git a/dlls/windows.media.speech/Makefile.in b/dlls/windows.media.speech/Makefile.in index 3cf24580732..c7faee34f46 100644 --- a/dlls/windows.media.speech/Makefile.in +++ b/dlls/windows.media.speech/Makefile.in @@ -7,7 +7,6 @@ C_SRCS = \ listconstraint.c \ main.c \ recognizer.c \ - synthesizer.c \ - vector.c + synthesizer.c
IDL_SRCS = classes.idl diff --git a/dlls/windows.media.speech/listconstraint.c b/dlls/windows.media.speech/listconstraint.c index ef0dff0e4d5..24194fdf38a 100644 --- a/dlls/windows.media.speech/listconstraint.c +++ b/dlls/windows.media.speech/listconstraint.c @@ -129,7 +129,7 @@ static HRESULT WINAPI list_constraint_get_Commands( ISpeechRecognitionListConst hr = IVector_HSTRING_QueryInterface(impl->commands, &IID_IIterable_HSTRING, (void **)&iterable); if (FAILED(hr)) return hr;
- hr = vector_hstring_create_copy(iterable, value); + hr = vector_hstring_copy(iterable, value); IIterable_HSTRING_Release(iterable);
return hr; @@ -359,7 +359,7 @@ static HRESULT WINAPI constraint_factory_CreateWithTag( ISpeechRecognitionListCo return E_POINTER;
if (!(impl = calloc(1, sizeof(*impl)))) return E_OUTOFMEMORY; - if (FAILED(hr = vector_hstring_create_copy(commands, &impl->commands))) goto error; + if (FAILED(hr = vector_hstring_copy(commands, &impl->commands))) goto error;
impl->ISpeechRecognitionListConstraint_iface.lpVtbl = &speech_recognition_list_constraint_vtbl; impl->ISpeechRecognitionConstraint_iface.lpVtbl = &speech_recognition_constraint_vtbl; diff --git a/dlls/windows.media.speech/private.h b/dlls/windows.media.speech/private.h index f41024e2fe2..3195df11033 100644 --- a/dlls/windows.media.speech/private.h +++ b/dlls/windows.media.speech/private.h @@ -74,7 +74,4 @@ HRESULT typed_event_handlers_remove( struct list *list, EventRegistrationToken * HRESULT typed_event_handlers_notify( struct list *list, IInspectable *sender, IInspectable *args ); HRESULT typed_event_handlers_clear( struct list* list );
-HRESULT vector_hstring_create( IVector_HSTRING **out ); -HRESULT vector_hstring_create_copy( IIterable_HSTRING *iterable, IVector_HSTRING **out ); - #endif diff --git a/include/wine/winrt.idl b/include/wine/winrt.idl index 9a4285dd70f..95322875656 100644 --- a/include/wine/winrt.idl +++ b/include/wine/winrt.idl @@ -35,6 +35,9 @@ struct vector_iids const GUID *iterator; };
+extern HRESULT vector_hstring_create( Windows.Foundation.Collections.IVector<HSTRING> **out ); +extern HRESULT vector_hstring_copy( Windows.Foundation.Collections.IIterable<HSTRING> *iterable, + Windows.Foundation.Collections.IVector<HSTRING> **out ); extern HRESULT vector_inspectable_create( const struct vector_iids *iids, void **out );
extern const char *debugstr_hstring( HSTRING hstr ); diff --git a/libs/winewinrt/Makefile.in b/libs/winewinrt/Makefile.in index 6998a68b1c1..937df798735 100644 --- a/libs/winewinrt/Makefile.in +++ b/libs/winewinrt/Makefile.in @@ -2,4 +2,5 @@ STATICLIB = libwinewinrt.a
C_SRCS = \ debug.c \ + vector_hstring.c \ vector_inspectable.c diff --git a/dlls/windows.media.speech/vector.c b/libs/winewinrt/vector_hstring.c similarity index 62% rename from dlls/windows.media.speech/vector.c rename to libs/winewinrt/vector_hstring.c index 61b63077d62..fa6a01c6ddc 100644 --- a/dlls/windows.media.speech/vector.c +++ b/libs/winewinrt/vector_hstring.c @@ -1,4 +1,4 @@ -/* WinRT Windows.Media.Speech implementation +/* WinRT Vector<HSTRING> implementation * * Copyright 2022 Bernhard Kölbl for CodeWeavers * @@ -19,70 +19,62 @@
#include "private.h"
-#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(speech); - -/* - * - * IIterator<HSTRING> - * - */ +WINE_DEFAULT_DEBUG_CHANNEL(winrt);
struct iterator_hstring { - IIterator_HSTRING IIterator_HSTRING_iface; - LONG ref; + IIterator_HSTRING IIterator_HSTRING_iface; + LONG ref;
- IVectorView_HSTRING *view; - UINT32 index; - UINT32 size; + IVectorView_HSTRING *view; + UINT32 index; + UINT32 size; };
static inline struct iterator_hstring *impl_from_IIterator_HSTRING( IIterator_HSTRING *iface ) { - return CONTAINING_RECORD(iface, struct iterator_hstring, IIterator_HSTRING_iface); + return CONTAINING_RECORD( iface, struct iterator_hstring, IIterator_HSTRING_iface ); }
static HRESULT WINAPI iterator_hstring_QueryInterface( IIterator_HSTRING *iface, REFIID iid, void **out ) { - struct iterator_hstring *impl = impl_from_IIterator_HSTRING(iface); + struct iterator_hstring *impl = impl_from_IIterator_HSTRING( iface );
- TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
- if (IsEqualGUID(iid, &IID_IUnknown) || - IsEqualGUID(iid, &IID_IInspectable) || - IsEqualGUID(iid, &IID_IAgileObject) || - IsEqualGUID(iid, &IID_IIterator_HSTRING)) + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IIterator_HSTRING )) { - IInspectable_AddRef((*out = &impl->IIterator_HSTRING_iface)); - return S_OK; + IInspectable_AddRef( (*out = &impl->IIterator_HSTRING_iface) ); + return S_OK; }
- WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; }
static ULONG WINAPI iterator_hstring_AddRef( IIterator_HSTRING *iface ) { - struct iterator_hstring *impl = impl_from_IIterator_HSTRING(iface); - ULONG ref = InterlockedIncrement(&impl->ref); - TRACE("iface %p increasing refcount to %lu.\n", iface, ref); + struct iterator_hstring *impl = impl_from_IIterator_HSTRING( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); return ref; }
static ULONG WINAPI iterator_hstring_Release( IIterator_HSTRING *iface ) { - struct iterator_hstring *impl = impl_from_IIterator_HSTRING(iface); - ULONG ref = InterlockedDecrement(&impl->ref); + struct iterator_hstring *impl = impl_from_IIterator_HSTRING( iface ); + ULONG ref = InterlockedDecrement( &impl->ref );
- TRACE("iface %p decreasing refcount to %lu.\n", iface, ref); + TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref );
if (!ref) { - IVectorView_HSTRING_Release(impl->view); - free(impl); + IVectorView_HSTRING_Release( impl->view ); + free( impl ); }
return ref; @@ -90,34 +82,34 @@ static ULONG WINAPI iterator_hstring_Release( IIterator_HSTRING *iface )
static HRESULT WINAPI iterator_hstring_GetIids( IIterator_HSTRING *iface, ULONG *iid_count, IID **iids ) { - FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids); + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); return E_NOTIMPL; }
static HRESULT WINAPI iterator_hstring_GetRuntimeClassName( IIterator_HSTRING *iface, HSTRING *class_name ) { - FIXME("iface %p, class_name %p stub!\n", iface, class_name); + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); return E_NOTIMPL; }
static HRESULT WINAPI iterator_hstring_GetTrustLevel( IIterator_HSTRING *iface, TrustLevel *trust_level ) { - FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); return E_NOTIMPL; }
static HRESULT WINAPI iterator_hstring_get_Current( IIterator_HSTRING *iface, HSTRING *value ) { - struct iterator_hstring *impl = impl_from_IIterator_HSTRING(iface); - TRACE("iface %p, value %p.\n", iface, value); - return IVectorView_HSTRING_GetAt(impl->view, impl->index, value); + struct iterator_hstring *impl = impl_from_IIterator_HSTRING( iface ); + TRACE( "iface %p, value %p.\n", iface, value ); + return IVectorView_HSTRING_GetAt( impl->view, impl->index, value ); }
static HRESULT WINAPI iterator_hstring_get_HasCurrent( IIterator_HSTRING *iface, BOOL *value ) { - struct iterator_hstring *impl = impl_from_IIterator_HSTRING(iface); + struct iterator_hstring *impl = impl_from_IIterator_HSTRING( iface );
- TRACE("iface %p, value %p.\n", iface, value); + TRACE( "iface %p, value %p.\n", iface, value );
*value = impl->index < impl->size; return S_OK; @@ -125,20 +117,19 @@ static HRESULT WINAPI iterator_hstring_get_HasCurrent( IIterator_HSTRING *iface,
static HRESULT WINAPI iterator_hstring_MoveNext( IIterator_HSTRING *iface, BOOL *value ) { - struct iterator_hstring *impl = impl_from_IIterator_HSTRING(iface); + struct iterator_hstring *impl = impl_from_IIterator_HSTRING( iface );
- TRACE("iface %p, value %p.\n", iface, value); + TRACE( "iface %p, value %p.\n", iface, value );
if (impl->index < impl->size) impl->index++; - return IIterator_HSTRING_get_HasCurrent(iface, value); + return IIterator_HSTRING_get_HasCurrent( iface, value ); }
-static HRESULT WINAPI iterator_hstring_GetMany( IIterator_HSTRING *iface, UINT32 items_size, - HSTRING *items, UINT *count ) +static HRESULT WINAPI iterator_hstring_GetMany( IIterator_HSTRING *iface, UINT32 items_size, HSTRING *items, UINT *count ) { - struct iterator_hstring *impl = impl_from_IIterator_HSTRING(iface); - TRACE("iface %p, items_size %u, items %p, count %p.\n", iface, items_size, items, count); - return IVectorView_HSTRING_GetMany(impl->view, impl->index, items_size, items, count); + struct iterator_hstring *impl = impl_from_IIterator_HSTRING( iface ); + TRACE( "iface %p, items_size %u, items %p, count %p.\n", iface, items_size, items, count ); + return IVectorView_HSTRING_GetMany( impl->view, impl->index, items_size, items, count ); }
static const IIterator_HSTRINGVtbl iterator_hstring_vtbl = @@ -158,12 +149,6 @@ static const IIterator_HSTRINGVtbl iterator_hstring_vtbl = iterator_hstring_GetMany, };
-/* - * - * IVectorView<HSTRING> - * - */ - struct vector_view_hstring { IVectorView_HSTRING IVectorView_HSTRING_iface; @@ -174,58 +159,58 @@ struct vector_view_hstring HSTRING elements[]; };
-C_ASSERT(sizeof(struct vector_view_hstring) == offsetof(struct vector_view_hstring, elements[0])); +C_ASSERT( sizeof(struct vector_view_hstring) == offsetof( struct vector_view_hstring, elements[0] ) );
static inline struct vector_view_hstring *impl_from_IVectorView_HSTRING( IVectorView_HSTRING *iface ) { - return CONTAINING_RECORD(iface, struct vector_view_hstring, IVectorView_HSTRING_iface); + return CONTAINING_RECORD( iface, struct vector_view_hstring, IVectorView_HSTRING_iface ); }
static HRESULT WINAPI vector_view_hstring_QueryInterface( IVectorView_HSTRING *iface, REFIID iid, void **out ) { - struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING(iface); + struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING( iface );
- TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
- if (IsEqualGUID(iid, &IID_IUnknown) || - IsEqualGUID(iid, &IID_IInspectable) || - IsEqualGUID(iid, &IID_IAgileObject) || - IsEqualGUID(iid, &IID_IVectorView_HSTRING)) + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IVectorView_HSTRING )) { - IInspectable_AddRef((*out = &impl->IVectorView_HSTRING_iface)); + IInspectable_AddRef( (*out = &impl->IVectorView_HSTRING_iface) ); return S_OK; }
- if (IsEqualGUID(iid, &IID_IIterable_HSTRING)) + if (IsEqualGUID( iid, &IID_IIterable_HSTRING )) { - IInspectable_AddRef((*out = &impl->IIterable_HSTRING_iface)); + IInspectable_AddRef( (*out = &impl->IIterable_HSTRING_iface) ); return S_OK; }
- WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; }
static ULONG WINAPI vector_view_hstring_AddRef( IVectorView_HSTRING *iface ) { - struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING(iface); - ULONG ref = InterlockedIncrement(&impl->ref); - TRACE("iface %p increasing refcount to %lu.\n", iface, ref); + struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); return ref; }
static ULONG WINAPI vector_view_hstring_Release( IVectorView_HSTRING *iface ) { - struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING(iface); - ULONG i, ref = InterlockedDecrement(&impl->ref); + struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING( iface ); + ULONG i, ref = InterlockedDecrement( &impl->ref );
- TRACE("iface %p decreasing refcount to %lu.\n", iface, ref); + TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref );
if (!ref) { - for (i = 0; i < impl->size; ++i) WindowsDeleteString(impl->elements[i]); - free(impl); + for (i = 0; i < impl->size; ++i) WindowsDeleteString( impl->elements[i] ); + free( impl ); }
return ref; @@ -233,39 +218,39 @@ static ULONG WINAPI vector_view_hstring_Release( IVectorView_HSTRING *iface )
static HRESULT WINAPI vector_view_hstring_GetIids( IVectorView_HSTRING *iface, ULONG *iid_count, IID **iids ) { - FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids); + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); return E_NOTIMPL; }
static HRESULT WINAPI vector_view_hstring_GetRuntimeClassName( IVectorView_HSTRING *iface, HSTRING *class_name ) { - FIXME("iface %p, class_name %p stub!\n", iface, class_name); + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); return E_NOTIMPL; }
static HRESULT WINAPI vector_view_hstring_GetTrustLevel( IVectorView_HSTRING *iface, TrustLevel *trust_level ) { - FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); return E_NOTIMPL; }
static HRESULT WINAPI vector_view_hstring_GetAt( IVectorView_HSTRING *iface, UINT32 index, HSTRING *value ) { - struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING(iface); + struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING( iface );
- TRACE("iface %p, index %u, value %p.\n", iface, index, value); + TRACE( "iface %p, index %u, value %p.\n", iface, index, value );
*value = NULL; if (index >= impl->size) return E_BOUNDS;
- return WindowsDuplicateString(impl->elements[index], value); + return WindowsDuplicateString( impl->elements[index], value ); }
static HRESULT WINAPI vector_view_hstring_get_Size( IVectorView_HSTRING *iface, UINT32 *value ) { - struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING(iface); + struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING( iface );
- TRACE("iface %p, value %p.\n", iface, value); + TRACE( "iface %p, value %p.\n", iface, value );
*value = impl->size; return S_OK; @@ -274,10 +259,10 @@ static HRESULT WINAPI vector_view_hstring_get_Size( IVectorView_HSTRING *iface, static HRESULT WINAPI vector_view_hstring_IndexOf( IVectorView_HSTRING *iface, HSTRING element, UINT32 *index, BOOLEAN *found ) { - struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING(iface); + struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING( iface ); ULONG i;
- TRACE("iface %p, element %p, index %p, found %p.\n", iface, element, index, found); + TRACE( "iface %p, element %p, index %p, found %p.\n", iface, element, index, found );
for (i = 0; i < impl->size; ++i) if (impl->elements[i] == element) break; if ((*found = (i < impl->size))) *index = i; @@ -289,7 +274,7 @@ static HRESULT WINAPI vector_view_hstring_IndexOf( IVectorView_HSTRING *iface, H static HRESULT WINAPI vector_view_hstring_GetMany( IVectorView_HSTRING *iface, UINT32 start_index, UINT32 items_size, HSTRING *items, UINT *count ) { - struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING(iface); + struct vector_view_hstring *impl = impl_from_IVectorView_HSTRING( iface ); HRESULT hr; UINT32 i;
@@ -301,7 +286,7 @@ static HRESULT WINAPI vector_view_hstring_GetMany( IVectorView_HSTRING *iface, U for (i = start_index; i < impl->size; ++i) { if (i - start_index >= items_size) break; - if (FAILED(hr = WindowsDuplicateString(impl->elements[i], &items[i - start_index]))) goto error; + if (FAILED(hr = WindowsDuplicateString( impl->elements[i], &items[i - start_index] ))) goto error; } *count = i - start_index;
@@ -309,7 +294,7 @@ static HRESULT WINAPI vector_view_hstring_GetMany( IVectorView_HSTRING *iface, U
error: *count = 0; - while (i-- > start_index) WindowsDeleteString(items[i-start_index]); + while (i-- > start_index) WindowsDeleteString( items[i - start_index] ); return hr; }
@@ -330,27 +315,21 @@ static const struct IVectorView_HSTRINGVtbl vector_view_hstring_vtbl = vector_view_hstring_GetMany, };
-/* - * - * IIterable<HSTRING> - * - */ - -DEFINE_IINSPECTABLE_(iterable_view_hstring, IIterable_HSTRING, struct vector_view_hstring, view_impl_from_IIterable_HSTRING, - IIterable_HSTRING_iface, &impl->IVectorView_HSTRING_iface) +DEFINE_IINSPECTABLE_( iterable_view_hstring, IIterable_HSTRING, struct vector_view_hstring, view_impl_from_IIterable_HSTRING, + IIterable_HSTRING_iface, &impl->IVectorView_HSTRING_iface )
static HRESULT WINAPI iterable_view_hstring_First( IIterable_HSTRING *iface, IIterator_HSTRING **value ) { - struct vector_view_hstring *impl = view_impl_from_IIterable_HSTRING(iface); + struct vector_view_hstring *impl = view_impl_from_IIterable_HSTRING( iface ); struct iterator_hstring *iter;
- TRACE("iface %p, value %p.\n", iface, value); + TRACE( "iface %p, value %p.\n", iface, value );
- if (!(iter = calloc(1, sizeof(*iter)))) return E_OUTOFMEMORY; + if (!(iter = calloc( 1, sizeof(struct iterator_hstring) ))) return E_OUTOFMEMORY; iter->IIterator_HSTRING_iface.lpVtbl = &iterator_hstring_vtbl; iter->ref = 1;
- IVectorView_HSTRING_AddRef((iter->view = &impl->IVectorView_HSTRING_iface)); + IVectorView_HSTRING_AddRef( (iter->view = &impl->IVectorView_HSTRING_iface) ); iter->size = impl->size;
*value = &iter->IIterator_HSTRING_iface; @@ -371,12 +350,6 @@ static const struct IIterable_HSTRINGVtbl iterable_view_hstring_vtbl = iterable_view_hstring_First, };
-/* - * - * IVector<HSTRING> - * - */ - struct vector_hstring { IVector_HSTRING IVector_HSTRING_iface; @@ -390,54 +363,54 @@ struct vector_hstring
static inline struct vector_hstring *impl_from_IVector_HSTRING( IVector_HSTRING *iface ) { - return CONTAINING_RECORD(iface, struct vector_hstring, IVector_HSTRING_iface); + return CONTAINING_RECORD( iface, struct vector_hstring, IVector_HSTRING_iface ); }
static HRESULT WINAPI vector_hstring_QueryInterface( IVector_HSTRING *iface, REFIID iid, void **out ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface );
- TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
- if (IsEqualGUID(iid, &IID_IUnknown) || - IsEqualGUID(iid, &IID_IInspectable) || - IsEqualGUID(iid, &IID_IAgileObject) || - IsEqualGUID(iid, &IID_IVector_HSTRING)) + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IVector_HSTRING )) { - IInspectable_AddRef((*out = &impl->IVector_HSTRING_iface)); + IInspectable_AddRef( (*out = &impl->IVector_HSTRING_iface) ); return S_OK; }
- if (IsEqualGUID(iid, &IID_IIterable_HSTRING)) + if (IsEqualGUID( iid, &IID_IIterable_HSTRING )) { - IInspectable_AddRef((*out = &impl->IIterable_HSTRING_iface)); + IInspectable_AddRef( (*out = &impl->IIterable_HSTRING_iface) ); return S_OK; }
- WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; }
static ULONG WINAPI vector_hstring_AddRef( IVector_HSTRING *iface ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); - ULONG ref = InterlockedIncrement(&impl->ref); - TRACE("iface %p, ref %lu.\n", iface, ref); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); return ref; }
static ULONG WINAPI vector_hstring_Release( IVector_HSTRING *iface ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); - ULONG ref = InterlockedDecrement(&impl->ref); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface ); + ULONG ref = InterlockedDecrement( &impl->ref );
- TRACE("iface %p, ref %lu.\n", iface, ref); + TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref );
if (!ref) { - IVector_HSTRING_Clear(iface); - free(impl); + IVector_HSTRING_Clear( iface ); + free( impl ); }
return ref; @@ -463,19 +436,19 @@ static HRESULT WINAPI vector_hstring_GetTrustLevel( IVector_HSTRING *iface, Trus
static HRESULT WINAPI vector_hstring_GetAt( IVector_HSTRING *iface, UINT32 index, HSTRING *value ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface );
TRACE( "iface %p, index %u, value %p.\n", iface, index, value );
*value = NULL; if (index >= impl->size) return E_BOUNDS;
- return WindowsDuplicateString(impl->elements[index], value); + return WindowsDuplicateString( impl->elements[index], value ); }
static HRESULT WINAPI vector_hstring_get_Size( IVector_HSTRING *iface, UINT32 *value ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface ); TRACE( "iface %p, value %p.\n", iface, value ); *value = impl->size; return S_OK; @@ -483,36 +456,39 @@ static HRESULT WINAPI vector_hstring_get_Size( IVector_HSTRING *iface, UINT32 *v
static HRESULT WINAPI vector_hstring_GetView( IVector_HSTRING *iface, IVectorView_HSTRING **value ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface ); struct vector_view_hstring *view; HRESULT hr; ULONG i;
- TRACE("iface %p, value %p.\n", iface, value); + TRACE( "iface %p, value %p.\n", iface, value );
- if (!(view = calloc(1, offsetof(struct vector_view_hstring, elements[impl->size])))) return E_OUTOFMEMORY; + if (!(view = calloc( 1, offsetof( struct vector_view_hstring, elements[impl->size] ) ))) return E_OUTOFMEMORY; view->IVectorView_HSTRING_iface.lpVtbl = &vector_view_hstring_vtbl; view->IIterable_HSTRING_iface.lpVtbl = &iterable_view_hstring_vtbl; view->ref = 1;
for (i = 0; i < impl->size; ++i) - if (FAILED(hr = WindowsDuplicateString(impl->elements[i], &view->elements[view->size++]))) goto error; + { + hr = WindowsDuplicateString( impl->elements[i], &view->elements[view->size++] ); + if (FAILED(hr)) goto error; + }
*value = &view->IVectorView_HSTRING_iface; return S_OK;
error: - while (i-- > 0) WindowsDeleteString(view->elements[i]); - free(view); + while (i-- > 0) WindowsDeleteString( view->elements[i] ); + free( view ); return hr; }
static HRESULT WINAPI vector_hstring_IndexOf( IVector_HSTRING *iface, HSTRING element, UINT32 *index, BOOLEAN *found ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface ); ULONG i;
- TRACE("iface %p, element %p, index %p, found %p.\n", iface, element, index, found); + TRACE( "iface %p, element %p, index %p, found %p.\n", iface, element, index, found );
for (i = 0; i < impl->size; ++i) if (impl->elements[i] == element) break; if ((*found = (i < impl->size))) *index = i; @@ -523,86 +499,85 @@ static HRESULT WINAPI vector_hstring_IndexOf( IVector_HSTRING *iface, HSTRING el
static HRESULT WINAPI vector_hstring_SetAt( IVector_HSTRING *iface, UINT32 index, HSTRING value ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface ); HSTRING tmp; HRESULT hr;
TRACE( "iface %p, index %u, value %p.\n", iface, index, value );
if (index >= impl->size) return E_BOUNDS; + if (FAILED(hr = WindowsDuplicateString( value, &tmp ))) return hr;
- if (FAILED(hr = WindowsDuplicateString(value, &tmp))) return hr; - - WindowsDeleteString(impl->elements[index]); + WindowsDeleteString( impl->elements[index] ); impl->elements[index] = tmp; return S_OK; }
static HRESULT WINAPI vector_hstring_InsertAt( IVector_HSTRING *iface, UINT32 index, HSTRING value ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); - HSTRING tmp, *tmp2 = impl->elements; + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface ); + HSTRING tmp, *elements = impl->elements; HRESULT hr;
TRACE( "iface %p, index %u, value %p.\n", iface, index, value );
- if (FAILED(hr = WindowsDuplicateString(value, &tmp))) return hr; + if (FAILED(hr = WindowsDuplicateString( value, &tmp ))) return hr;
if (impl->size == impl->capacity) { - impl->capacity = max(32, impl->capacity * 3 / 2); - if (!(impl->elements = realloc(impl->elements, impl->capacity * sizeof(*impl->elements)))) + impl->capacity = max( 32, impl->capacity * 3 / 2 ); + if (!(impl->elements = realloc( impl->elements, impl->capacity * sizeof(*impl->elements) ))) { - impl->elements = tmp2; + impl->elements = elements; return E_OUTOFMEMORY; } }
- memmove(impl->elements + index + 1, impl->elements + index, (impl->size++ - index) * sizeof(*impl->elements)); + memmove( impl->elements + index + 1, impl->elements + index, (impl->size++ - index) * sizeof(*impl->elements) ); impl->elements[index] = tmp; return S_OK; }
static HRESULT WINAPI vector_hstring_RemoveAt( IVector_HSTRING *iface, UINT32 index ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface );
- TRACE("iface %p, index %u.\n", iface, index); + TRACE( "iface %p, index %u.\n", iface, index );
if (index >= impl->size) return E_BOUNDS;
- WindowsDeleteString(impl->elements[index]); - memmove(impl->elements + index, impl->elements + index + 1, (--impl->size - index) * sizeof(*impl->elements)); + WindowsDeleteString( impl->elements[index] ); + memmove( impl->elements + index, impl->elements + index + 1, (--impl->size - index) * sizeof(*impl->elements) ); return S_OK; }
static HRESULT WINAPI vector_hstring_Append( IVector_HSTRING *iface, HSTRING value ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface );
- TRACE("iface %p, value %p.\n", iface, value); + TRACE( "iface %p, value %p.\n", iface, value );
- return IVector_HSTRING_InsertAt(iface, impl->size, value); + return IVector_HSTRING_InsertAt( iface, impl->size, value ); }
static HRESULT WINAPI vector_hstring_RemoveAtEnd( IVector_HSTRING *iface ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface );
- TRACE("iface %p.\n", iface); + TRACE( "iface %p.\n", iface );
- if (impl->size) WindowsDeleteString(impl->elements[--impl->size]); + if (impl->size) WindowsDeleteString( impl->elements[--impl->size] ); return S_OK; }
static HRESULT WINAPI vector_hstring_Clear( IVector_HSTRING *iface ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface );
- TRACE("iface %p.\n", iface); + TRACE( "iface %p.\n", iface );
- while (impl->size) IVector_HSTRING_RemoveAtEnd(iface); - free(impl->elements); + while (impl->size) IVector_HSTRING_RemoveAtEnd( iface ); + free( impl->elements ); impl->capacity = 0; impl->elements = NULL;
@@ -612,18 +587,19 @@ static HRESULT WINAPI vector_hstring_Clear( IVector_HSTRING *iface ) static HRESULT WINAPI vector_hstring_GetMany( IVector_HSTRING *iface, UINT32 start_index, UINT32 items_size, HSTRING *items, UINT32 *count ) { - struct vector_hstring *impl = impl_from_IVector_HSTRING(iface); + struct vector_hstring *impl = impl_from_IVector_HSTRING( iface ); HRESULT hr; UINT32 i;
- TRACE("iface %p, start_index %u, items_size %u, items %p, count %p.\n", iface, start_index, items_size, items, count); + TRACE( "iface %p, start_index %u, items_size %u, items %p, count %p.\n", + iface, start_index, items_size, items, count );
if (start_index >= impl->size) return E_BOUNDS;
for (i = start_index; i < impl->size; ++i) { if (i - start_index >= items_size) break; - if (FAILED(hr = WindowsDuplicateString(impl->elements[i], &items[i-start_index]))) goto error; + if (FAILED(hr = WindowsDuplicateString( impl->elements[i], &items[i - start_index] ))) goto error; } *count = i - start_index;
@@ -631,7 +607,7 @@ static HRESULT WINAPI vector_hstring_GetMany( IVector_HSTRING *iface, UINT32 sta
error: *count = 0; - while (i-- > start_index) WindowsDeleteString(items[i-start_index]); + while (i-- > start_index) WindowsDeleteString( items[i - start_index] ); return hr; }
@@ -640,10 +616,10 @@ static HRESULT WINAPI vector_hstring_ReplaceAll( IVector_HSTRING *iface, UINT32 HRESULT hr; ULONG i;
- TRACE("iface %p, count %u, items %p.\n", iface, count, items); + TRACE( "iface %p, count %u, items %p.\n", iface, count, items );
- hr = IVector_HSTRING_Clear(iface); - for (i = 0; i < count && SUCCEEDED(hr); ++i) hr = IVector_HSTRING_Append(iface, items[i]); + hr = IVector_HSTRING_Clear( iface ); + for (i = 0; i < count && SUCCEEDED(hr); ++i) hr = IVector_HSTRING_Append( iface, items[i] ); return hr; }
@@ -672,31 +648,25 @@ static const struct IVector_HSTRINGVtbl vector_hstring_vtbl = vector_hstring_ReplaceAll, };
-/* - * - * IIterable<HSTRING> - * - */ - -DEFINE_IINSPECTABLE(iterable_hstring, IIterable_HSTRING, struct vector_hstring, IVector_HSTRING_iface) +DEFINE_IINSPECTABLE( iterable_hstring, IIterable_HSTRING, struct vector_hstring, IVector_HSTRING_iface )
static HRESULT WINAPI iterable_hstring_First( IIterable_HSTRING *iface, IIterator_HSTRING **value ) { - struct vector_hstring *impl = impl_from_IIterable_HSTRING(iface); + struct vector_hstring *impl = impl_from_IIterable_HSTRING( iface ); IIterable_HSTRING *iterable; IVectorView_HSTRING *view; HRESULT hr;
- TRACE("iface %p, value %p.\n", iface, value); + TRACE( "iface %p, value %p.\n", iface, value );
- if (FAILED(hr = IVector_HSTRING_GetView(&impl->IVector_HSTRING_iface, &view))) return hr; + if (FAILED(hr = IVector_HSTRING_GetView( &impl->IVector_HSTRING_iface, &view ))) return hr;
- hr = IVectorView_HSTRING_QueryInterface(view, &IID_IIterable_HSTRING, (void **)&iterable); - IVectorView_HSTRING_Release(view); + hr = IVectorView_HSTRING_QueryInterface( view, &IID_IIterable_HSTRING, (void **)&iterable ); + IVectorView_HSTRING_Release( view ); if (FAILED(hr)) return hr;
- hr = IIterable_HSTRING_First(iterable, value); - IIterable_HSTRING_Release(iterable); + hr = IIterable_HSTRING_First( iterable, value ); + IIterable_HSTRING_Release( iterable ); return hr; }
@@ -718,19 +688,19 @@ HRESULT vector_hstring_create( IVector_HSTRING **out ) { struct vector_hstring *impl;
- TRACE("out %p.\n", out); + TRACE( "out %p.\n", out );
- if (!(impl = calloc(1, sizeof(*impl)))) return E_OUTOFMEMORY; + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IVector_HSTRING_iface.lpVtbl = &vector_hstring_vtbl; impl->IIterable_HSTRING_iface.lpVtbl = &iterable_hstring_vtbl; impl->ref = 1;
*out = &impl->IVector_HSTRING_iface; - TRACE("created %p\n", *out); + TRACE( "created %p\n", *out ); return S_OK; }
-HRESULT vector_hstring_create_copy( IIterable_HSTRING *iterable, IVector_HSTRING **out ) +HRESULT vector_hstring_copy( IIterable_HSTRING *iterable, IVector_HSTRING **out ) { struct vector_hstring *impl; IIterator_HSTRING *iterator;