From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/Makefile.in | 3 +- dlls/windows.gaming.input/controller.c | 4 +- dlls/windows.gaming.input/gamepad.c | 2 +- dlls/windows.gaming.input/private.h | 63 +------------------ dlls/windows.gaming.input/racing_wheel.c | 2 +- dlls/winewinrt/Makefile.in | 3 +- .../vector_inspectable.c} | 28 +++++---- dlls/winewinrt/winewinrt_private.h | 57 +++++++++++++++++ 8 files changed, 83 insertions(+), 79 deletions(-) rename dlls/{windows.gaming.input/vector.c => winewinrt/vector_inspectable.c} (96%)
diff --git a/dlls/windows.gaming.input/Makefile.in b/dlls/windows.gaming.input/Makefile.in index 3ec3dd0d864..2c9b935564a 100644 --- a/dlls/windows.gaming.input/Makefile.in +++ b/dlls/windows.gaming.input/Makefile.in @@ -1,5 +1,6 @@ MODULE = windows.gaming.input.dll IMPORTS = combase uuid user32 dinput8 setupapi hid +PARENTSRC = ../winewinrt
C_SRCS = \ async.c \ @@ -15,7 +16,7 @@ C_SRCS = \ provider.c \ racing_wheel.c \ ramp_effect.c \ - vector.c + vector_inspectable.c
IDL_SRCS = \ classes.idl \ diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index bd3d441c445..86e4d3bd030 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -50,7 +50,7 @@ static HRESULT init_controllers(void)
EnterCriticalSection( &controller_cs ); if (controllers) hr = S_OK; - else hr = vector_create( &iids, (void **)&controllers ); + else hr = vector_inspectable_create( &iids, (void **)&controllers ); LeaveCriticalSection( &controller_cs );
return hr; @@ -243,7 +243,7 @@ static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController
TRACE( "iface %p, value %p\n", iface, value );
- if (FAILED(hr = vector_create( &iids, (void **)&vector ))) return hr; + if (FAILED(hr = vector_inspectable_create( &iids, (void **)&vector ))) return hr;
if (SUCCEEDED(IWineGameControllerProvider_get_ForceFeedbackMotor( impl->wine_provider, &motor )) && motor) { diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c index 112ec49a1d3..389659311ed 100644 --- a/dlls/windows.gaming.input/gamepad.c +++ b/dlls/windows.gaming.input/gamepad.c @@ -50,7 +50,7 @@ static HRESULT init_gamepads(void)
EnterCriticalSection( &gamepad_cs ); if (gamepads) hr = S_OK; - else hr = vector_create( &iids, (void **)&gamepads ); + else hr = vector_inspectable_create( &iids, (void **)&gamepads ); LeaveCriticalSection( &gamepad_cs );
return hr; diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index f53d5b5bc37..d41eda53c36 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -17,22 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include <stdarg.h> -#include <stddef.h> +#include "winewinrt_private.h"
-#define COBJMACROS -#include "windef.h" -#include "winbase.h" -#include "winstring.h" -#include "objbase.h" #include "dinput.h"
-#include "activation.h" - -#define WIDL_using_Windows_Foundation -#define WIDL_using_Windows_Foundation_Collections -#define WIDL_using_Windows_Foundation_Numerics -#include "windows.foundation.h" #define WIDL_using_Windows_Devices_Power #define WIDL_using_Windows_Gaming_Input #define WIDL_using_Windows_Gaming_Input_Custom @@ -54,15 +42,6 @@ extern IInspectable *ramp_effect_factory; extern IInspectable *periodic_effect_factory; extern IInspectable *condition_effect_factory;
-struct vector_iids -{ - const GUID *vector; - const GUID *view; - const GUID *iterable; - const GUID *iterator; -}; -extern HRESULT vector_create( const struct vector_iids *iids, void **out ); - extern void provider_create( const WCHAR *device_path ); extern void provider_remove( const WCHAR *device_path );
@@ -82,46 +61,6 @@ extern HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *para extern HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_ForceFeedbackLoadEffectResult **out );
-#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ - static inline impl_type *impl_from( iface_type *iface ) \ - { \ - return CONTAINING_RECORD( iface, impl_type, iface_mem ); \ - } \ - static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \ - { \ - impl_type *impl = impl_from( iface ); \ - return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \ - } \ - static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \ - { \ - impl_type *impl = impl_from( iface ); \ - return IInspectable_AddRef( (IInspectable *)(expr) ); \ - } \ - static ULONG WINAPI pfx##_Release( iface_type *iface ) \ - { \ - impl_type *impl = impl_from( iface ); \ - return IInspectable_Release( (IInspectable *)(expr) ); \ - } \ - static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \ - { \ - impl_type *impl = impl_from( iface ); \ - return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \ - } \ - static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \ - { \ - impl_type *impl = impl_from( iface ); \ - return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \ - } \ - static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \ - { \ - impl_type *impl = impl_from( iface ); \ - return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \ - } -#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ - DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->base_iface ) -#define DEFINE_IINSPECTABLE_OUTER( pfx, iface_type, impl_type, outer_iface ) \ - DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, impl->outer_iface ) - static inline const char *debugstr_vector3( const Vector3 *vector ) { if (!vector) return "(null)"; diff --git a/dlls/windows.gaming.input/racing_wheel.c b/dlls/windows.gaming.input/racing_wheel.c index d646ca26c03..5f186fa9e9f 100644 --- a/dlls/windows.gaming.input/racing_wheel.c +++ b/dlls/windows.gaming.input/racing_wheel.c @@ -50,7 +50,7 @@ static HRESULT init_racing_wheels(void)
EnterCriticalSection( &racing_wheel_cs ); if (racing_wheels) hr = S_OK; - else hr = vector_create( &iids, (void **)&racing_wheels ); + else hr = vector_inspectable_create( &iids, (void **)&racing_wheels ); LeaveCriticalSection( &racing_wheel_cs );
return hr; diff --git a/dlls/winewinrt/Makefile.in b/dlls/winewinrt/Makefile.in index d76556fd157..812db0a6227 100644 --- a/dlls/winewinrt/Makefile.in +++ b/dlls/winewinrt/Makefile.in @@ -2,4 +2,5 @@ MODULE = winewinrt.dll IMPORTS = combase uuid
C_SRCS = \ - main.c + main.c \ + vector_inspectable.c diff --git a/dlls/windows.gaming.input/vector.c b/dlls/winewinrt/vector_inspectable.c similarity index 96% rename from dlls/windows.gaming.input/vector.c rename to dlls/winewinrt/vector_inspectable.c index 8958b07c0f2..5b6fecb2804 100644 --- a/dlls/windows.gaming.input/vector.c +++ b/dlls/winewinrt/vector_inspectable.c @@ -1,4 +1,4 @@ -/* WinRT Windows.Gaming.Input implementation +/* WinRT Vector<IInspectable> implementation * * Copyright 2021 Rémi Bernon for CodeWeavers * @@ -17,11 +17,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "private.h" +#include "winewinrt_private.h"
-#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(combase); +WINE_DEFAULT_DEBUG_CHANNEL(winrt);
struct iterator { @@ -129,7 +127,7 @@ static HRESULT WINAPI iterator_MoveNext( IIterator_IInspectable *iface, BOOL *va }
static HRESULT WINAPI iterator_GetMany( IIterator_IInspectable *iface, UINT32 items_size, - IInspectable **items, UINT *count ) + IInspectable **items, UINT32 *count ) { struct iterator *impl = impl_from_IIterator_IInspectable( iface ); TRACE( "iface %p, items_size %u, items %p, count %p.\n", iface, items_size, items, count ); @@ -138,6 +136,7 @@ static HRESULT WINAPI iterator_GetMany( IIterator_IInspectable *iface, UINT32 it
static const IIterator_IInspectableVtbl iterator_vtbl = { + /* IUnknown methods */ iterator_QueryInterface, iterator_AddRef, iterator_Release, @@ -160,9 +159,11 @@ struct vector_view LONG ref;
UINT32 size; - IInspectable *elements[1]; + IInspectable *elements[]; };
+C_ASSERT( sizeof(struct vector_view) == offsetof( struct vector_view, elements[0] ) ); + static inline struct vector_view *impl_from_IVectorView_IInspectable( IVectorView_IInspectable *iface ) { return CONTAINING_RECORD( iface, struct vector_view, IVectorView_IInspectable_iface ); @@ -275,7 +276,7 @@ static HRESULT WINAPI vector_view_IndexOf( IVectorView_IInspectable *iface, IIns }
static HRESULT WINAPI vector_view_GetMany( IVectorView_IInspectable *iface, UINT32 start_index, - UINT32 items_size, IInspectable **items, UINT *count ) + UINT32 items_size, IInspectable **items, UINT32 *count ) { struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); UINT32 i; @@ -297,6 +298,7 @@ static HRESULT WINAPI vector_view_GetMany( IVectorView_IInspectable *iface, UINT
static const struct IVectorView_IInspectableVtbl vector_view_vtbl = { + /* IUnknown methods */ vector_view_QueryInterface, vector_view_AddRef, vector_view_Release, @@ -335,6 +337,7 @@ static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IItera
static const struct IIterable_IInspectableVtbl iterable_view_vtbl = { + /* IUnknown methods */ iterable_view_QueryInterface, iterable_view_AddRef, iterable_view_Release, @@ -472,7 +475,8 @@ static HRESULT WINAPI vector_GetView( IVector_IInspectable *iface, IVectorView_I return S_OK; }
-static HRESULT WINAPI vector_IndexOf( IVector_IInspectable *iface, IInspectable *element, UINT32 *index, BOOLEAN *found ) +static HRESULT WINAPI vector_IndexOf( IVector_IInspectable *iface, IInspectable *element, + UINT32 *index, BOOLEAN *found ) { struct vector *impl = impl_from_IVector_IInspectable( iface ); ULONG i; @@ -566,7 +570,7 @@ static HRESULT WINAPI vector_Clear( IVector_IInspectable *iface ) }
static HRESULT WINAPI vector_GetMany( IVector_IInspectable *iface, UINT32 start_index, - UINT32 items_size, IInspectable **items, UINT *count ) + UINT32 items_size, IInspectable **items, UINT32 *count ) { struct vector *impl = impl_from_IVector_IInspectable( iface ); UINT32 i; @@ -600,6 +604,7 @@ static HRESULT WINAPI vector_ReplaceAll( IVector_IInspectable *iface, UINT32 cou
static const struct IVector_IInspectableVtbl vector_vtbl = { + /* IUnknown methods */ vector_QueryInterface, vector_AddRef, vector_Release, @@ -646,6 +651,7 @@ static HRESULT WINAPI iterable_First( IIterable_IInspectable *iface, IIterator_I
static const struct IIterable_IInspectableVtbl iterable_vtbl = { + /* IUnknown methods */ iterable_QueryInterface, iterable_AddRef, iterable_Release, @@ -657,7 +663,7 @@ static const struct IIterable_IInspectableVtbl iterable_vtbl = iterable_First, };
-HRESULT vector_create( const struct vector_iids *iids, void **out ) +HRESULT vector_inspectable_create( const struct vector_iids *iids, void **out ) { struct vector *impl;
diff --git a/dlls/winewinrt/winewinrt_private.h b/dlls/winewinrt/winewinrt_private.h index 19d7ed67e69..9f478f077d0 100644 --- a/dlls/winewinrt/winewinrt_private.h +++ b/dlls/winewinrt/winewinrt_private.h @@ -26,4 +26,61 @@ #include "winstring.h" #include "activation.h"
+#define WIDL_using_Windows_Foundation +#define WIDL_using_Windows_Foundation_Collections +#define WIDL_using_Windows_Foundation_Numerics +#include "windows.foundation.h" + #include "wine/debug.h" + +/* vector_inspectable.c */ + +struct vector_iids +{ + const GUID *vector; + const GUID *view; + const GUID *iterable; + const GUID *iterator; +}; + +extern HRESULT vector_inspectable_create( const struct vector_iids *iids, void **out ); + +#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ + static inline impl_type *impl_from( iface_type *iface ) \ + { \ + return CONTAINING_RECORD( iface, impl_type, iface_mem ); \ + } \ + static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \ + } \ + static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_AddRef( (IInspectable *)(expr) ); \ + } \ + static ULONG WINAPI pfx##_Release( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_Release( (IInspectable *)(expr) ); \ + } \ + static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \ + } \ + static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \ + } \ + static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \ + } +#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->base_iface ) +#define DEFINE_IINSPECTABLE_OUTER( pfx, iface_type, impl_type, outer_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, impl->outer_iface )