From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/async.c | 2 +- dlls/windows.gaming.input/condition_effect.c | 2 +- dlls/windows.gaming.input/controller.c | 34 ++++----- dlls/windows.gaming.input/force_feedback.c | 2 +- dlls/windows.gaming.input/gamepad.c | 12 +-- dlls/windows.gaming.input/manager.c | 6 +- dlls/windows.gaming.input/periodic_effect.c | 2 +- dlls/windows.gaming.input/private.h | 67 +++-------------- dlls/windows.gaming.input/provider.c | 2 +- dlls/windows.gaming.input/racing_wheel.c | 10 +-- dlls/windows.gaming.input/vector.c | 6 +- include/Makefile.in | 1 + include/wine/comimpl.h | 77 ++++++++++++++++++++ 13 files changed, 126 insertions(+), 97 deletions(-) create mode 100644 include/wine/comimpl.h
diff --git a/dlls/windows.gaming.input/async.c b/dlls/windows.gaming.input/async.c index c2b1efe3eba..c142c6426d7 100644 --- a/dlls/windows.gaming.input/async.c +++ b/dlls/windows.gaming.input/async.c @@ -204,7 +204,7 @@ static const struct IWineAsyncInfoImplVtbl async_impl_vtbl = async_impl_Start, };
-DEFINE_IINSPECTABLE_OUTER( async_info, IAsyncInfo, struct async_info, IInspectable_outer ) +DEFINE_IINSPECTABLE_OUTER( async_info, IAsyncInfo, async_info, IInspectable_outer )
static HRESULT WINAPI async_info_get_Id( IAsyncInfo *iface, UINT32 *id ) { diff --git a/dlls/windows.gaming.input/condition_effect.c b/dlls/windows.gaming.input/condition_effect.c index e5bd7d439e1..46b82523eeb 100644 --- a/dlls/windows.gaming.input/condition_effect.c +++ b/dlls/windows.gaming.input/condition_effect.c @@ -242,7 +242,7 @@ static const struct IActivationFactoryVtbl activation_vtbl = activation_ActivateInstance, };
-DEFINE_IINSPECTABLE( factory, IConditionForceEffectFactory, struct condition_factory, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( factory, IConditionForceEffectFactory, condition_factory, IActivationFactory_iface )
static HRESULT WINAPI factory_CreateInstance( IConditionForceEffectFactory *iface, enum ConditionForceEffectKind kind, IForceFeedbackEffect **out ) { diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 4b789076793..778e55fec18 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -69,14 +69,11 @@ struct controller IWineGameControllerProvider *wine_provider; };
-static inline struct controller *impl_from_IGameControllerImpl( IGameControllerImpl *iface ) -{ - return CONTAINING_RECORD( iface, struct controller, IGameControllerImpl_iface ); -} +INTERFACE_IMPL_FROM( controller, IGameControllerImpl );
static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REFIID iid, void **out ) { - struct controller *impl = impl_from_IGameControllerImpl( iface ); + struct controller *impl = controller_from_IGameControllerImpl( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
@@ -113,7 +110,7 @@ static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REF
static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface ) { - struct controller *impl = impl_from_IGameControllerImpl( iface ); + struct controller *impl = controller_from_IGameControllerImpl( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); return ref; @@ -121,7 +118,7 @@ static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface )
static ULONG WINAPI controller_Release( IGameControllerImpl *iface ) { - struct controller *impl = impl_from_IGameControllerImpl( iface ); + struct controller *impl = controller_from_IGameControllerImpl( iface ); ULONG ref = InterlockedDecrement( &impl->ref );
TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); @@ -159,7 +156,7 @@ static HRESULT WINAPI controller_GetTrustLevel( IGameControllerImpl *iface, Trus static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) { - struct controller *impl = impl_from_IGameControllerImpl( iface ); + struct controller *impl = controller_from_IGameControllerImpl( iface ); HRESULT hr;
TRACE( "iface %p, outer %p, provider %p.\n", iface, outer, provider ); @@ -181,7 +178,7 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo
INTERFACE_VTBL_IGameControllerImpl( controller );
-DEFINE_IINSPECTABLE_OUTER( controller_IGameControllerInputSink, IGameControllerInputSink, struct controller, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( controller_IGameControllerInputSink, IGameControllerInputSink, controller, IGameController_outer )
static HRESULT WINAPI controller_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { @@ -197,7 +194,7 @@ static HRESULT WINAPI controller_IGameControllerInputSink_OnInputSuspended( IGam
INTERFACE_VTBL_IGameControllerInputSink( controller_IGameControllerInputSink );
-DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController, IRawGameController, struct controller, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController, IRawGameController, controller, IGameController_outer )
static HRESULT WINAPI controller_IRawGameController_get_AxisCount( IRawGameController *iface, INT32 *value ) { @@ -298,7 +295,7 @@ static HRESULT WINAPI controller_IRawGameController_GetSwitchKind( IRawGameContr
INTERFACE_VTBL_IRawGameController( controller_IRawGameController );
-DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController2, IRawGameController2, struct controller, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController2, IRawGameController2, controller, IGameController_outer )
static HRESULT WINAPI controller_IRawGameController2_get_SimpleHapticsControllers( IRawGameController2 *iface, @@ -348,14 +345,11 @@ struct controller_statics LONG ref; };
-static inline struct controller_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct controller_statics, IActivationFactory_iface ); -} +INTERFACE_IMPL_FROM( controller_statics, IActivationFactory );
static HRESULT WINAPI controller_statics_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) { - struct controller_statics *impl = impl_from_IActivationFactory( iface ); + struct controller_statics *impl = controller_statics_from_IActivationFactory( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
@@ -392,7 +386,7 @@ static HRESULT WINAPI controller_statics_QueryInterface( IActivationFactory *ifa
static ULONG WINAPI controller_statics_AddRef( IActivationFactory *iface ) { - struct controller_statics *impl = impl_from_IActivationFactory( iface ); + struct controller_statics *impl = controller_statics_from_IActivationFactory( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); return ref; @@ -400,7 +394,7 @@ static ULONG WINAPI controller_statics_AddRef( IActivationFactory *iface )
static ULONG WINAPI controller_statics_Release( IActivationFactory *iface ) { - struct controller_statics *impl = impl_from_IActivationFactory( iface ); + struct controller_statics *impl = controller_statics_from_IActivationFactory( iface ); ULONG ref = InterlockedDecrement( &impl->ref ); TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); return ref; @@ -433,7 +427,7 @@ static HRESULT WINAPI controller_statics_ActivateInstance( IActivationFactory *i INTERFACE_VTBL_IActivationFactory( controller_statics );
DEFINE_IINSPECTABLE( controller_statics_IRawGameControllerStatics, IRawGameControllerStatics, - struct controller_statics, IActivationFactory_iface ) + controller_statics, IActivationFactory_iface )
static HRESULT WINAPI controller_statics_IRawGameControllerStatics_add_RawGameControllerAdded( IRawGameControllerStatics *iface, @@ -509,7 +503,7 @@ controller_statics_IRawGameControllerStatics_FromGameController( IRawGameControl INTERFACE_VTBL_IRawGameControllerStatics( controller_statics_IRawGameControllerStatics );
DEFINE_IINSPECTABLE( controller_statics_ICustomGameControllerFactory, ICustomGameControllerFactory, - struct controller_statics, IActivationFactory_iface ) + controller_statics, IActivationFactory_iface )
static HRESULT WINAPI controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index 941bde2ce80..296dfa2a1e0 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -250,7 +250,7 @@ static const struct IWineForceFeedbackEffectImplVtbl effect_impl_vtbl = effect_impl_put_Parameters, };
-DEFINE_IINSPECTABLE_OUTER( effect, IForceFeedbackEffect, struct effect, IInspectable_outer ) +DEFINE_IINSPECTABLE_OUTER( effect, IForceFeedbackEffect, effect, IInspectable_outer )
static HRESULT WINAPI effect_get_Gain( IForceFeedbackEffect *iface, DOUBLE *value ) { diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c index 434d369bc90..1c2d0c53299 100644 --- a/dlls/windows.gaming.input/gamepad.c +++ b/dlls/windows.gaming.input/gamepad.c @@ -192,7 +192,7 @@ static const struct IGameControllerImplVtbl controller_vtbl = controller_Initialize, };
-DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, struct gamepad, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, gamepad, IGameController_outer )
static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { @@ -220,7 +220,7 @@ static const struct IGameControllerInputSinkVtbl input_sink_vtbl = input_sink_OnInputSuspended, };
-DEFINE_IINSPECTABLE_OUTER( gamepad, IGamepad, struct gamepad, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( gamepad, IGamepad, gamepad, IGameController_outer )
static HRESULT WINAPI gamepad_get_Vibration( IGamepad *iface, struct GamepadVibration *value ) { @@ -337,7 +337,7 @@ static const struct IGamepadVtbl gamepad_vtbl = gamepad_GetCurrentReading, };
-DEFINE_IINSPECTABLE_OUTER( gamepad2, IGamepad2, struct gamepad, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( gamepad2, IGamepad2, gamepad, IGameController_outer )
static HRESULT WINAPI gamepad2_GetButtonLabel( IGamepad2 *iface, GamepadButtons button, GameControllerButtonLabel *value ) { @@ -470,7 +470,7 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
-DEFINE_IINSPECTABLE( statics, IGamepadStatics, struct gamepad_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics, IGamepadStatics, gamepad_statics, IActivationFactory_iface )
static HRESULT WINAPI statics_add_GamepadAdded( IGamepadStatics *iface, IEventHandler_Gamepad *handler, EventRegistrationToken *token ) @@ -531,7 +531,7 @@ static const struct IGamepadStaticsVtbl statics_vtbl = statics_get_Gamepads, };
-DEFINE_IINSPECTABLE( statics2, IGamepadStatics2, struct gamepad_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics2, IGamepadStatics2, gamepad_statics, IActivationFactory_iface )
static HRESULT WINAPI statics2_FromGameController( IGamepadStatics2 *iface, IGameController *game_controller, IGamepad **value ) { @@ -564,7 +564,7 @@ static const struct IGamepadStatics2Vtbl statics2_vtbl = statics2_FromGameController, };
-DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, struct gamepad_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, gamepad_statics, IActivationFactory_iface )
static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) diff --git a/dlls/windows.gaming.input/manager.c b/dlls/windows.gaming.input/manager.c index 4bc16c78844..3c6334bc0eb 100644 --- a/dlls/windows.gaming.input/manager.c +++ b/dlls/windows.gaming.input/manager.c @@ -207,7 +207,7 @@ static const struct IGameControllerVtbl controller_vtbl = controller_get_User, };
-DEFINE_IINSPECTABLE( battery, IGameControllerBatteryInfo, struct controller, IGameController_iface ) +DEFINE_IINSPECTABLE( battery, IGameControllerBatteryInfo, controller, IGameController_iface )
static HRESULT WINAPI battery_TryGetBatteryReport( IGameControllerBatteryInfo *iface, IBatteryReport **value ) { @@ -334,7 +334,7 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
-DEFINE_IINSPECTABLE( statics, IGameControllerFactoryManagerStatics, struct manager_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics, IGameControllerFactoryManagerStatics, manager_statics, IActivationFactory_iface )
static HRESULT WINAPI statics_RegisterCustomFactoryForGipInterface( IGameControllerFactoryManagerStatics *iface, @@ -378,7 +378,7 @@ static const struct IGameControllerFactoryManagerStaticsVtbl statics_vtbl = statics_RegisterCustomFactoryForXusbType, };
-DEFINE_IINSPECTABLE( statics2, IGameControllerFactoryManagerStatics2, struct manager_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics2, IGameControllerFactoryManagerStatics2, manager_statics, IActivationFactory_iface )
static HRESULT WINAPI statics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManagerStatics2 *iface, diff --git a/dlls/windows.gaming.input/periodic_effect.c b/dlls/windows.gaming.input/periodic_effect.c index f05aba36f94..335c9f903fc 100644 --- a/dlls/windows.gaming.input/periodic_effect.c +++ b/dlls/windows.gaming.input/periodic_effect.c @@ -280,7 +280,7 @@ static const struct IActivationFactoryVtbl activation_vtbl = activation_ActivateInstance, };
-DEFINE_IINSPECTABLE( factory, IPeriodicForceEffectFactory, struct periodic_factory, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( factory, IPeriodicForceEffectFactory, periodic_factory, IActivationFactory_iface )
static HRESULT WINAPI factory_CreateInstance( IPeriodicForceEffectFactory *iface, enum PeriodicForceEffectKind kind, IForceFeedbackEffect **out ) { diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index 1f98f5e828c..07650e52fad 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -39,6 +39,7 @@ #define WIDL_using_Windows_Gaming_Input_ForceFeedback #include "windows.gaming.input.custom.h"
+#include "wine/comimpl.h" #include "wine/debug.h" #include "wine/list.h"
@@ -83,61 +84,17 @@ extern HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown 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 ) - -#define DEFINE_IAGILEOBJECT( type, base, expr ) \ - static HRESULT WINAPI type##_IAgileObject_QueryInterface( IAgileObject *iface, REFIID iid, void **out ) \ - { \ - struct type *object = CONTAINING_RECORD( iface, struct type, IAgileObject_iface ); \ - return base##_QueryInterface( (expr), iid, out ); \ - } \ - static ULONG WINAPI type##_IAgileObject_AddRef( IAgileObject *iface ) \ - { \ - struct type *object = CONTAINING_RECORD( iface, struct type, IAgileObject_iface ); \ - return base##_AddRef( (expr) ); \ - } \ - static ULONG WINAPI type##_IAgileObject_Release( IAgileObject *iface ) \ - { \ - struct type *object = CONTAINING_RECORD( iface, struct type, IAgileObject_iface ); \ - return base##_Release( (expr) ); \ - } \ + INTERFACE_IMPL_FROM_( impl_type, iface_type, impl_from, iface_mem ) \ + IUNKNOWN_FWD_( impl_type, iface_type, IInspectable, expr, impl_from, pfx ) \ + IINSPECTABLE_FWD_( impl_type, iface_type, IInspectable, expr, impl_from, pfx ) +#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, (IInspectable *)&object->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, (IInspectable *)object->outer_iface ) + +#define DEFINE_IAGILEOBJECT( type, base, expr ) \ + INTERFACE_IMPL_FROM_( type, IAgileObject, type ## _from_IAgileObject, IAgileObject_iface ) \ + IUNKNOWN_FWD_( type, IAgileObject, base, expr, type ## _from_IAgileObject, type ## _IAgileObject ) \ INTERFACE_VTBL_IAgileObject( type ## _IAgileObject );
static inline const char *debugstr_vector3( const Vector3 *vector ) diff --git a/dlls/windows.gaming.input/provider.c b/dlls/windows.gaming.input/provider.c index ecd14f866b7..33f9471fae1 100644 --- a/dlls/windows.gaming.input/provider.c +++ b/dlls/windows.gaming.input/provider.c @@ -370,7 +370,7 @@ static const struct IWineGameControllerProviderVtbl wine_provider_vtbl = wine_provider_get_ForceFeedbackMotor, };
-DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, struct provider, IWineGameControllerProvider_iface ) +DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, provider, IWineGameControllerProvider_iface )
static HRESULT WINAPI game_provider_get_FirmwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) { diff --git a/dlls/windows.gaming.input/racing_wheel.c b/dlls/windows.gaming.input/racing_wheel.c index c39a5c45c42..c7004d935af 100644 --- a/dlls/windows.gaming.input/racing_wheel.c +++ b/dlls/windows.gaming.input/racing_wheel.c @@ -183,7 +183,7 @@ static const struct IGameControllerImplVtbl controller_vtbl = controller_Initialize, };
-DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, struct racing_wheel, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, racing_wheel, IGameController_outer )
static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { @@ -211,7 +211,7 @@ static const struct IGameControllerInputSinkVtbl input_sink_vtbl = input_sink_OnInputSuspended, };
-DEFINE_IINSPECTABLE_OUTER( racing_wheel, IRacingWheel, struct racing_wheel, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( racing_wheel, IRacingWheel, racing_wheel, IGameController_outer )
static HRESULT WINAPI racing_wheel_get_HasClutch( IRacingWheel *iface, boolean *value ) { @@ -396,7 +396,7 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
-DEFINE_IINSPECTABLE( statics, IRacingWheelStatics, struct racing_wheel_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics, IRacingWheelStatics, racing_wheel_statics, IActivationFactory_iface )
static HRESULT WINAPI statics_add_RacingWheelAdded( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, EventRegistrationToken *token ) @@ -456,7 +456,7 @@ static const struct IRacingWheelStaticsVtbl statics_vtbl = statics_get_RacingWheels, };
-DEFINE_IINSPECTABLE( statics2, IRacingWheelStatics2, struct racing_wheel_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics2, IRacingWheelStatics2, racing_wheel_statics, IActivationFactory_iface )
static HRESULT WINAPI statics2_FromGameController( IRacingWheelStatics2 *iface, IGameController *game_controller, IRacingWheel **value ) { @@ -489,7 +489,7 @@ static const struct IRacingWheelStatics2Vtbl statics2_vtbl = statics2_FromGameController, };
-DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, struct racing_wheel_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, racing_wheel_statics, IActivationFactory_iface )
static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) diff --git a/dlls/windows.gaming.input/vector.c b/dlls/windows.gaming.input/vector.c index a96662ea99f..6e16e9ace01 100644 --- a/dlls/windows.gaming.input/vector.c +++ b/dlls/windows.gaming.input/vector.c @@ -325,8 +325,8 @@ static const struct IVectorView_IInspectableVtbl vector_view_vtbl = vector_view_GetMany, };
-DEFINE_IINSPECTABLE_( iterable_view, IIterable_IInspectable, struct vector_view, view_impl_from_IIterable_IInspectable, - IIterable_IInspectable_iface, &impl->IVectorView_IInspectable_iface ) +DEFINE_IINSPECTABLE_( iterable_view, IIterable_IInspectable, vector_view, view_impl_from_IIterable_IInspectable, + IIterable_IInspectable_iface, (IInspectable *)&object->IVectorView_IInspectable_iface )
static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) { @@ -646,7 +646,7 @@ static const struct IVector_IInspectableVtbl vector_vtbl = vector_ReplaceAll, };
-DEFINE_IINSPECTABLE( iterable, IIterable_IInspectable, struct vector, IVector_IInspectable_iface ) +DEFINE_IINSPECTABLE( iterable, IIterable_IInspectable, vector, IVector_IInspectable_iface )
static HRESULT WINAPI iterable_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) { diff --git a/include/Makefile.in b/include/Makefile.in index bbf28cfc87e..83d27a84031 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -899,6 +899,7 @@ SOURCES = \ wine/afd.h \ wine/asm.h \ wine/atsvc.idl \ + wine/comimpl.h \ wine/condrv.h \ wine/dcetypes.idl \ wine/debug.h \ diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h new file mode 100644 index 00000000000..c8078f40827 --- /dev/null +++ b/include/wine/comimpl.h @@ -0,0 +1,77 @@ +/* + * Wine COM implementation helpers + * + * Copyright 2024 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#if 0 +#pragma makedep install +#endif + +#ifndef __WINE_WINE_COMIMPL_H +#define __WINE_WINE_COMIMPL_H + +#include <stdarg.h> +#include <stdio.h> + +#include <windef.h> +#include <winbase.h> + +#define INTERFACE_IMPL_FROM( type, name ) INTERFACE_IMPL_FROM_( type, name, type ## _from_ ## name, name ## _iface ) +#define INTERFACE_IMPL_FROM_( type, name, impl_from, iface_mem ) \ + static struct type *impl_from( name *iface ) \ + { \ + return CONTAINING_RECORD( iface, struct type, iface_mem ); \ + } + +#define IUNKNOWN_FWD( type, name, base, expr ) IUNKNOWN_FWD_( type, name, base, expr, type ## _from_ ## name, type ## _ ## name ) +#define IUNKNOWN_FWD_( type, name, base, expr, impl_from, prefix ) \ + static HRESULT WINAPI prefix ## _QueryInterface( name *iface, REFIID iid, void **out ) \ + { \ + struct type *object = impl_from( iface ); \ + return base ## _QueryInterface( (expr), iid, out ); \ + } \ + static ULONG WINAPI prefix ## _AddRef( name *iface ) \ + { \ + struct type *object = impl_from( iface ); \ + return base ## _AddRef( (expr) ); \ + } \ + static ULONG WINAPI prefix ## _Release( name *iface ) \ + { \ + struct type *object = impl_from( iface ); \ + return base ## _Release( (expr) ); \ + } + +#define IINSPECTABLE_FWD( type, name, base, expr ) IINSPECTABLE_FWD_( type, name, base, expr, type ## _from_ ## name, type ## _ ## name ) +#define IINSPECTABLE_FWD_( type, name, base, expr, impl_from, prefix ) \ + static HRESULT WINAPI prefix ## _GetIids( name *iface, ULONG *count, IID **iids ) \ + { \ + struct type *object = impl_from( iface ); \ + return base ## _GetIids( (expr), count, iids ); \ + } \ + static HRESULT WINAPI prefix ## _GetRuntimeClassName( name *iface, HSTRING *class_name ) \ + { \ + struct type *object = impl_from( iface ); \ + return base ## _GetRuntimeClassName( (expr), class_name ); \ + } \ + static HRESULT WINAPI prefix ## _GetTrustLevel( name *iface, TrustLevel *trust_level ) \ + { \ + struct type *object = impl_from( iface ); \ + return base ## _GetTrustLevel( (expr), trust_level ); \ + } + +#endif /* __WINE_WINE_COMIMPL_H */