windows.gaming.input: Introduce helpers to define IInspectable interface boilerplate.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2022-03-02 14:03:01 +01:00 committed by Alexandre Julliard
parent e53b68acec
commit 45eb5d0909
3 changed files with 38 additions and 80 deletions

View File

@ -35,11 +35,6 @@ static inline struct controller_statics *impl_from_IActivationFactory( IActivati
return CONTAINING_RECORD( iface, struct controller_statics, IActivationFactory_iface );
}
static inline struct controller_statics *impl_from_IRawGameControllerStatics( IRawGameControllerStatics *iface )
{
return CONTAINING_RECORD( iface, struct controller_statics, IRawGameControllerStatics_iface );
}
static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out )
{
struct controller_statics *impl = impl_from_IActivationFactory( iface );
@ -121,41 +116,7 @@ static const struct IActivationFactoryVtbl factory_vtbl =
factory_ActivateInstance,
};
static HRESULT WINAPI statics_QueryInterface( IRawGameControllerStatics *iface, REFIID iid, void **out )
{
struct controller_statics *impl = impl_from_IRawGameControllerStatics( iface );
return IActivationFactory_QueryInterface( &impl->IActivationFactory_iface, iid, out );
}
static ULONG WINAPI statics_AddRef( IRawGameControllerStatics *iface )
{
struct controller_statics *impl = impl_from_IRawGameControllerStatics( iface );
return IActivationFactory_AddRef( &impl->IActivationFactory_iface );
}
static ULONG WINAPI statics_Release( IRawGameControllerStatics *iface )
{
struct controller_statics *impl = impl_from_IRawGameControllerStatics( iface );
return IActivationFactory_Release( &impl->IActivationFactory_iface );
}
static HRESULT WINAPI statics_GetIids( IRawGameControllerStatics *iface, ULONG *iid_count, IID **iids )
{
struct controller_statics *impl = impl_from_IRawGameControllerStatics( iface );
return IActivationFactory_Release( &impl->IActivationFactory_iface );
}
static HRESULT WINAPI statics_GetRuntimeClassName( IRawGameControllerStatics *iface, HSTRING *class_name )
{
struct controller_statics *impl = impl_from_IRawGameControllerStatics( iface );
return IActivationFactory_Release( &impl->IActivationFactory_iface );
}
static HRESULT WINAPI statics_GetTrustLevel( IRawGameControllerStatics *iface, TrustLevel *trust_level )
{
struct controller_statics *impl = impl_from_IRawGameControllerStatics( iface );
return IActivationFactory_Release( &impl->IActivationFactory_iface );
}
DEFINE_IINSPECTABLE( statics, IRawGameControllerStatics, struct controller_statics, IActivationFactory_iface )
static HRESULT WINAPI statics_add_RawGameControllerAdded( IRawGameControllerStatics *iface, IEventHandler_RawGameController *value,
EventRegistrationToken *token )

View File

@ -35,11 +35,6 @@ static inline struct gamepad_statics *impl_from_IActivationFactory( IActivationF
return CONTAINING_RECORD( iface, struct gamepad_statics, IActivationFactory_iface );
}
static inline struct gamepad_statics *impl_from_IGamepadStatics( IGamepadStatics *iface )
{
return CONTAINING_RECORD( iface, struct gamepad_statics, IGamepadStatics_iface );
}
static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out )
{
struct gamepad_statics *impl = impl_from_IActivationFactory( iface );
@ -121,41 +116,7 @@ static const struct IActivationFactoryVtbl factory_vtbl =
factory_ActivateInstance,
};
static HRESULT WINAPI statics_QueryInterface( IGamepadStatics *iface, REFIID iid, void **out )
{
struct gamepad_statics *impl = impl_from_IGamepadStatics( iface );
return IActivationFactory_QueryInterface( &impl->IActivationFactory_iface, iid, out );
}
static ULONG WINAPI statics_AddRef( IGamepadStatics *iface )
{
struct gamepad_statics *impl = impl_from_IGamepadStatics( iface );
return IActivationFactory_AddRef( &impl->IActivationFactory_iface );
}
static ULONG WINAPI statics_Release( IGamepadStatics *iface )
{
struct gamepad_statics *impl = impl_from_IGamepadStatics( iface );
return IActivationFactory_Release( &impl->IActivationFactory_iface );
}
static HRESULT WINAPI statics_GetIids( IGamepadStatics *iface, ULONG *iid_count, IID **iids )
{
struct gamepad_statics *impl = impl_from_IGamepadStatics( iface );
return IActivationFactory_Release( &impl->IActivationFactory_iface );
}
static HRESULT WINAPI statics_GetRuntimeClassName( IGamepadStatics *iface, HSTRING *class_name )
{
struct gamepad_statics *impl = impl_from_IGamepadStatics( iface );
return IActivationFactory_Release( &impl->IActivationFactory_iface );
}
static HRESULT WINAPI statics_GetTrustLevel( IGamepadStatics *iface, TrustLevel *trust_level )
{
struct gamepad_statics *impl = impl_from_IGamepadStatics( iface );
return IActivationFactory_Release( &impl->IActivationFactory_iface );
}
DEFINE_IINSPECTABLE( statics, IGamepadStatics, struct gamepad_statics, IActivationFactory_iface )
static HRESULT WINAPI statics_add_GamepadAdded( IGamepadStatics *iface, IEventHandler_Gamepad *value,
EventRegistrationToken *token )

View File

@ -38,3 +38,39 @@ extern IActivationFactory *controller_factory;
extern IActivationFactory *gamepad_factory;
extern HRESULT vector_create( REFIID iid, REFIID view_iid, void **out );
#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \
static inline impl_type *impl_from_##iface_type( iface_type *iface ) \
{ \
return CONTAINING_RECORD( iface, impl_type, iface_type##_iface ); \
} \
static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \
{ \
impl_type *impl = impl_from_##iface_type( iface ); \
return IInspectable_QueryInterface( (IInspectable *)&impl->base_iface, iid, out ); \
} \
static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \
{ \
impl_type *impl = impl_from_##iface_type( iface ); \
return IInspectable_AddRef( (IInspectable *)&impl->base_iface ); \
} \
static ULONG WINAPI pfx##_Release( iface_type *iface ) \
{ \
impl_type *impl = impl_from_##iface_type( iface ); \
return IInspectable_Release( (IInspectable *)&impl->base_iface ); \
} \
static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \
{ \
impl_type *impl = impl_from_##iface_type( iface ); \
return IInspectable_GetIids( (IInspectable *)&impl->base_iface, iid_count, iids ); \
} \
static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \
{ \
impl_type *impl = impl_from_##iface_type( iface ); \
return IInspectable_GetRuntimeClassName( (IInspectable *)&impl->base_iface, class_name ); \
} \
static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \
{ \
impl_type *impl = impl_from_##iface_type( iface ); \
return IInspectable_GetTrustLevel( (IInspectable *)&impl->base_iface, trust_level ); \
}