I think it would be very nice to have something like that to reduce the burden of implementing COM interfaces. This shows for instance on the windows.gaming.input module a 30% LoC reduction (from ~6800 to ~4700), even though the module already had a boilerplate helper macros already.
The MR introduces macros to automatically implement each IUnknown method, as well as all of them at once. It also includes a helper to implement IInspectable methods at once, as well as macros to forward both interface methods to a base interface or an outer object. Last, it provides higher-level macros to implement a main interface and any number of sub interfaces and generate IUnknown, forwarding and vtables for all of them at once, with IInspectable support when needed.
It uses widl to generate additional per-interface macros, for things like inheritance and vtable generation. The rest of the macros are otherwise shared in a Wine-specific header.
The implementation is split to show individual macro being used, although they are later replaced by higher-level macros. The individual helpers are still useful in some corner cases where specific behavior needs to be implemented, or for aggregating classes.
-- v3: include: Add a parameter to COM helper END to control QI traces. windows.gaming.input: Use the new COM macros everywhere possible. include: Introduce new macros for COM heritage implementation. widl: Generate some INTERFACE_IMPL/FWD helper macros. include: Introduce new macros for IInspectable WinRT implementation. include: Introduce new macros for COM IUnknown implementation. include: Introduce new macros for COM QueryInterface implementation. widl: Generate some QUERY_INTERFACE helper macros. include: Introduce new macros for COM AddRef/Release implementation. include: Introduce new helper macros for COM implementation. windows.gaming.input: Use the new INTERFACE_VTBL macros. widl: Generate some INTERFACE_VTBL helper macros. windows.gaming.input: Use a separate interface for IAgileObject.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/async.c | 13 ++++++-- dlls/windows.gaming.input/condition_effect.c | 12 +++++-- dlls/windows.gaming.input/constant_effect.c | 12 +++++-- dlls/windows.gaming.input/controller.c | 11 ++++++- dlls/windows.gaming.input/force_feedback.c | 22 +++++++++++-- dlls/windows.gaming.input/gamepad.c | 11 ++++++- dlls/windows.gaming.input/manager.c | 22 +++++++++++-- dlls/windows.gaming.input/periodic_effect.c | 12 +++++-- dlls/windows.gaming.input/private.h | 23 ++++++++++++++ dlls/windows.gaming.input/provider.c | 11 ++++++- dlls/windows.gaming.input/racing_wheel.c | 11 ++++++- dlls/windows.gaming.input/ramp_effect.c | 12 +++++-- dlls/windows.gaming.input/vector.c | 33 ++++++++++++++++++-- 13 files changed, 183 insertions(+), 22 deletions(-)
diff --git a/dlls/windows.gaming.input/async.c b/dlls/windows.gaming.input/async.c index d70994289f1..c2b1efe3eba 100644 --- a/dlls/windows.gaming.input/async.c +++ b/dlls/windows.gaming.input/async.c @@ -32,6 +32,7 @@ struct async_info { IWineAsyncInfoImpl IWineAsyncInfoImpl_iface; IAsyncInfo IAsyncInfo_iface; + IAgileObject IAgileObject_iface; IInspectable *IInspectable_outer; LONG ref;
@@ -60,7 +61,6 @@ static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFI
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IWineAsyncInfoImpl )) { IInspectable_AddRef( (*out = &impl->IWineAsyncInfoImpl_iface) ); @@ -73,6 +73,12 @@ static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFI return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -299,6 +305,8 @@ static const struct IAsyncInfoVtbl async_info_vtbl = async_info_Close, };
+DEFINE_IAGILEOBJECT( async_info, IInspectable, object->IInspectable_outer ); + static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *iface, TP_WORK *work ) { struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); @@ -340,6 +348,7 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper if (!(impl = calloc( 1, sizeof(struct async_info) ))) return E_OUTOFMEMORY; impl->IWineAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; impl->IAsyncInfo_iface.lpVtbl = &async_info_vtbl; + impl->IAgileObject_iface.lpVtbl = &async_info_IAgileObject_vtbl; impl->IInspectable_outer = outer; impl->ref = 1;
@@ -383,7 +392,6 @@ static HRESULT WINAPI async_bool_QueryInterface( IAsyncOperation_boolean *iface,
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IAsyncOperation_boolean )) { IInspectable_AddRef( (*out = &impl->IAsyncOperation_boolean_iface) ); @@ -528,7 +536,6 @@ static HRESULT WINAPI async_result_QueryInterface( IAsyncOperation_ForceFeedback
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IAsyncOperation_ForceFeedbackLoadEffectResult )) { IInspectable_AddRef( (*out = &impl->IAsyncOperation_ForceFeedbackLoadEffectResult_iface) ); diff --git a/dlls/windows.gaming.input/condition_effect.c b/dlls/windows.gaming.input/condition_effect.c index c3a5a1fcd8b..e5bd7d439e1 100644 --- a/dlls/windows.gaming.input/condition_effect.c +++ b/dlls/windows.gaming.input/condition_effect.c @@ -44,7 +44,6 @@ static HRESULT WINAPI effect_QueryInterface( IConditionForceEffect *iface, REFII
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IConditionForceEffect )) { IInspectable_AddRef( (*out = &impl->IConditionForceEffect_iface) ); @@ -150,6 +149,7 @@ struct condition_factory { IActivationFactory IActivationFactory_iface; IConditionForceEffectFactory IConditionForceEffectFactory_iface; + IAgileObject IAgileObject_iface; LONG ref; };
@@ -166,7 +166,6 @@ static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFI
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IActivationFactory )) { IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); @@ -179,6 +178,12 @@ static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFI return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -278,10 +283,13 @@ static const struct IConditionForceEffectFactoryVtbl factory_vtbl = factory_CreateInstance, };
+DEFINE_IAGILEOBJECT( condition_factory, IActivationFactory, &object->IActivationFactory_iface ); + static struct condition_factory condition_statics = { {&activation_vtbl}, {&factory_vtbl}, + {&condition_factory_IAgileObject_vtbl}, 1, };
diff --git a/dlls/windows.gaming.input/constant_effect.c b/dlls/windows.gaming.input/constant_effect.c index 15763b30d67..3e0a8cb0295 100644 --- a/dlls/windows.gaming.input/constant_effect.c +++ b/dlls/windows.gaming.input/constant_effect.c @@ -42,7 +42,6 @@ static HRESULT WINAPI effect_QueryInterface( IConstantForceEffect *iface, REFIID
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IConstantForceEffect )) { IInspectable_AddRef( (*out = &impl->IConstantForceEffect_iface) ); @@ -168,6 +167,7 @@ static const struct IConstantForceEffectVtbl effect_vtbl = struct constant_factory { IActivationFactory IActivationFactory_iface; + IAgileObject IAgileObject_iface; LONG ref; };
@@ -184,13 +184,18 @@ static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFI
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IActivationFactory )) { IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -266,9 +271,12 @@ static const struct IActivationFactoryVtbl activation_vtbl = activation_ActivateInstance, };
+DEFINE_IAGILEOBJECT( constant_factory, IActivationFactory, &object->IActivationFactory_iface ); + static struct constant_factory constant_statics = { {&activation_vtbl}, + {&constant_factory_IAgileObject_vtbl}, 1, };
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index e1749a3032d..62a10bc887c 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -394,6 +394,7 @@ struct controller_statics IActivationFactory IActivationFactory_iface; IRawGameControllerStatics IRawGameControllerStatics_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; + IAgileObject IAgileObject_iface; LONG ref; };
@@ -410,7 +411,6 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IActivationFactory )) { IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); @@ -429,6 +429,12 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -657,11 +663,14 @@ static const struct ICustomGameControllerFactoryVtbl controller_factory_vtbl = controller_factory_OnGameControllerRemoved, };
+DEFINE_IAGILEOBJECT( controller_statics, IActivationFactory, &object->IActivationFactory_iface ); + static struct controller_statics controller_statics = { {&factory_vtbl}, {&statics_vtbl}, {&controller_factory_vtbl}, + {&controller_statics_IAgileObject_vtbl}, 1, };
diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index a272daee25f..941bde2ce80 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -34,6 +34,7 @@ struct effect { IWineForceFeedbackEffectImpl IWineForceFeedbackEffectImpl_iface; IForceFeedbackEffect IForceFeedbackEffect_iface; + IAgileObject IAgileObject_iface; IInspectable *IInspectable_outer; LONG ref;
@@ -65,7 +66,6 @@ static HRESULT WINAPI effect_impl_QueryInterface( IWineForceFeedbackEffectImpl *
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IWineForceFeedbackEffectImpl )) { IWineForceFeedbackEffectImpl_AddRef( (*out = &impl->IWineForceFeedbackEffectImpl_iface) ); @@ -78,6 +78,12 @@ static HRESULT WINAPI effect_impl_QueryInterface( IWineForceFeedbackEffectImpl * return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -344,6 +350,8 @@ static const struct IForceFeedbackEffectVtbl effect_vtbl = effect_Stop, };
+DEFINE_IAGILEOBJECT( effect, IInspectable, object->IInspectable_outer ); + HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IInspectable *outer, IWineForceFeedbackEffectImpl **out ) { struct effect *impl; @@ -353,6 +361,7 @@ HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IIn if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IWineForceFeedbackEffectImpl_iface.lpVtbl = &effect_impl_vtbl; impl->IForceFeedbackEffect_iface.lpVtbl = &effect_vtbl; + impl->IAgileObject_iface.lpVtbl = &effect_IAgileObject_vtbl; impl->IInspectable_outer = outer; impl->ref = 1;
@@ -431,6 +440,7 @@ HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IIn struct motor { IForceFeedbackMotor IForceFeedbackMotor_iface; + IAgileObject IAgileObject_iface; LONG ref;
IDirectInputDevice8W *device; @@ -449,13 +459,18 @@ static HRESULT WINAPI motor_QueryInterface( IForceFeedbackMotor *iface, REFIID i
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IForceFeedbackMotor )) { IInspectable_AddRef( (*out = &impl->IForceFeedbackMotor_iface) ); return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -810,6 +825,8 @@ static const struct IForceFeedbackMotorVtbl motor_vtbl = motor_TryUnloadEffectAsync, };
+DEFINE_IAGILEOBJECT( motor, IForceFeedbackMotor, &object->IForceFeedbackMotor_iface ); + HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ) { struct motor *impl; @@ -823,6 +840,7 @@ HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbac
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IForceFeedbackMotor_iface.lpVtbl = &motor_vtbl; + impl->IAgileObject_iface.lpVtbl = &motor_IAgileObject_vtbl; impl->ref = 1;
IDirectInputDevice_AddRef( device ); diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c index 0d7cd690821..434d369bc90 100644 --- a/dlls/windows.gaming.input/gamepad.c +++ b/dlls/windows.gaming.input/gamepad.c @@ -365,6 +365,7 @@ struct gamepad_statics IGamepadStatics IGamepadStatics_iface; IGamepadStatics2 IGamepadStatics2_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; + IAgileObject IAgileObject_iface; LONG ref; };
@@ -381,7 +382,6 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IActivationFactory )) { IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); @@ -406,6 +406,12 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -644,12 +650,15 @@ static const struct ICustomGameControllerFactoryVtbl controller_factory_vtbl = controller_factory_OnGameControllerRemoved, };
+DEFINE_IAGILEOBJECT( gamepad_statics, IActivationFactory, &object->IActivationFactory_iface ); + static struct gamepad_statics gamepad_statics = { {&factory_vtbl}, {&statics_vtbl}, {&statics2_vtbl}, {&controller_factory_vtbl}, + {&gamepad_statics_IAgileObject_vtbl}, 1, };
diff --git a/dlls/windows.gaming.input/manager.c b/dlls/windows.gaming.input/manager.c index d54b01d92e3..4bc16c78844 100644 --- a/dlls/windows.gaming.input/manager.c +++ b/dlls/windows.gaming.input/manager.c @@ -39,6 +39,7 @@ struct controller { IGameController IGameController_iface; IGameControllerBatteryInfo IGameControllerBatteryInfo_iface; + IAgileObject IAgileObject_iface; IInspectable *IInspectable_inner; LONG ref;
@@ -60,7 +61,6 @@ static HRESULT WINAPI controller_QueryInterface( IGameController *iface, REFIID
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IGameController )) { IInspectable_AddRef( (*out = &impl->IGameController_iface) ); @@ -73,6 +73,12 @@ static HRESULT WINAPI controller_QueryInterface( IGameController *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + return IInspectable_QueryInterface( impl->IInspectable_inner, iid, out ); }
@@ -222,11 +228,14 @@ static const struct IGameControllerBatteryInfoVtbl battery_vtbl = battery_TryGetBatteryReport, };
+DEFINE_IAGILEOBJECT( controller, IGameController, &object->IGameController_iface ); + struct manager_statics { IActivationFactory IActivationFactory_iface; IGameControllerFactoryManagerStatics IGameControllerFactoryManagerStatics_iface; IGameControllerFactoryManagerStatics2 IGameControllerFactoryManagerStatics2_iface; + IAgileObject IAgileObject_iface; LONG ref; };
@@ -243,7 +252,6 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IActivationFactory )) { IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); @@ -262,6 +270,12 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -416,11 +430,14 @@ static const struct IGameControllerFactoryManagerStatics2Vtbl statics2_vtbl = statics2_TryGetFactoryControllerFromGameController, };
+DEFINE_IAGILEOBJECT( manager_statics, IActivationFactory, &object->IActivationFactory_iface ); + static struct manager_statics manager_statics = { {&factory_vtbl}, {&statics_vtbl}, {&statics2_vtbl}, + {&manager_statics_IAgileObject_vtbl}, 1, };
@@ -436,6 +453,7 @@ static HRESULT controller_create( ICustomGameControllerFactory *factory, IGameCo if (!(impl = malloc(sizeof(*impl)))) return E_OUTOFMEMORY; impl->IGameController_iface.lpVtbl = &controller_vtbl; impl->IGameControllerBatteryInfo_iface.lpVtbl = &battery_vtbl; + impl->IAgileObject_iface.lpVtbl = &controller_IAgileObject_vtbl; impl->ref = 1;
if (FAILED(hr = ICustomGameControllerFactory_CreateGameController( factory, provider, &impl->IInspectable_inner ))) diff --git a/dlls/windows.gaming.input/periodic_effect.c b/dlls/windows.gaming.input/periodic_effect.c index 8633a8fb9b9..f05aba36f94 100644 --- a/dlls/windows.gaming.input/periodic_effect.c +++ b/dlls/windows.gaming.input/periodic_effect.c @@ -44,7 +44,6 @@ static HRESULT WINAPI effect_QueryInterface( IPeriodicForceEffect *iface, REFIID
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IPeriodicForceEffect )) { IInspectable_AddRef( (*out = &impl->IPeriodicForceEffect_iface) ); @@ -188,6 +187,7 @@ struct periodic_factory { IActivationFactory IActivationFactory_iface; IPeriodicForceEffectFactory IPeriodicForceEffectFactory_iface; + IAgileObject IAgileObject_iface; LONG ref; };
@@ -204,7 +204,6 @@ static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFI
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IActivationFactory )) { IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); @@ -217,6 +216,12 @@ static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFI return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -316,10 +321,13 @@ static const struct IPeriodicForceEffectFactoryVtbl factory_vtbl = factory_CreateInstance, };
+DEFINE_IAGILEOBJECT( periodic_factory, IActivationFactory, &object->IActivationFactory_iface ); + static struct periodic_factory periodic_statics = { {&activation_vtbl}, {&factory_vtbl}, + {&periodic_factory_IAgileObject_vtbl}, 1, };
diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index f53d5b5bc37..c0fdac02198 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -122,6 +122,29 @@ extern HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown #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) ); \ + } \ + static const IAgileObjectVtbl type##_IAgileObject_vtbl = \ + { \ + type##_IAgileObject_QueryInterface, \ + type##_IAgileObject_AddRef, \ + type##_IAgileObject_Release, \ + }; + static inline const char *debugstr_vector3( const Vector3 *vector ) { if (!vector) return "(null)"; diff --git a/dlls/windows.gaming.input/provider.c b/dlls/windows.gaming.input/provider.c index 6908d733a53..ecd14f866b7 100644 --- a/dlls/windows.gaming.input/provider.c +++ b/dlls/windows.gaming.input/provider.c @@ -46,6 +46,7 @@ struct provider { IWineGameControllerProvider IWineGameControllerProvider_iface; IGameControllerProvider IGameControllerProvider_iface; + IAgileObject IAgileObject_iface; LONG ref;
IDirectInputDevice8W *dinput_device; @@ -78,7 +79,6 @@ static HRESULT WINAPI wine_provider_QueryInterface( IWineGameControllerProvider
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IWineGameControllerProvider )) { IInspectable_AddRef( (*out = &impl->IWineGameControllerProvider_iface) ); @@ -91,6 +91,12 @@ static HRESULT WINAPI wine_provider_QueryInterface( IWineGameControllerProvider return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -427,6 +433,8 @@ static const struct IGameControllerProviderVtbl game_provider_vtbl = game_provider_get_IsConnected, };
+DEFINE_IAGILEOBJECT( provider, IWineGameControllerProvider, &object->IWineGameControllerProvider_iface ); + static void check_haptics_caps( struct provider *provider, HANDLE device, PHIDP_PREPARSED_DATA preparsed, HIDP_LINK_COLLECTION_NODE *collections, HIDP_VALUE_CAPS *caps ) { @@ -573,6 +581,7 @@ void provider_create( const WCHAR *device_path ) if (!(impl = calloc( 1, sizeof(*impl) ))) goto done; impl->IWineGameControllerProvider_iface.lpVtbl = &wine_provider_vtbl; impl->IGameControllerProvider_iface.lpVtbl = &game_provider_vtbl; + impl->IAgileObject_iface.lpVtbl = &provider_IAgileObject_vtbl; IDirectInputDevice_AddRef( dinput_device ); impl->dinput_device = dinput_device; impl->ref = 1; diff --git a/dlls/windows.gaming.input/racing_wheel.c b/dlls/windows.gaming.input/racing_wheel.c index d646ca26c03..c39a5c45c42 100644 --- a/dlls/windows.gaming.input/racing_wheel.c +++ b/dlls/windows.gaming.input/racing_wheel.c @@ -291,6 +291,7 @@ struct racing_wheel_statics IRacingWheelStatics IRacingWheelStatics_iface; IRacingWheelStatics2 IRacingWheelStatics2_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; + IAgileObject IAgileObject_iface; LONG ref; };
@@ -307,7 +308,6 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IActivationFactory )) { IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); @@ -332,6 +332,12 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -568,12 +574,15 @@ static const struct ICustomGameControllerFactoryVtbl controller_factory_vtbl = controller_factory_OnGameControllerRemoved, };
+DEFINE_IAGILEOBJECT( racing_wheel_statics, IActivationFactory, &object->IActivationFactory_iface ); + static struct racing_wheel_statics racing_wheel_statics = { {&factory_vtbl}, {&statics_vtbl}, {&statics2_vtbl}, {&controller_factory_vtbl}, + {&racing_wheel_statics_IAgileObject_vtbl}, 1, };
diff --git a/dlls/windows.gaming.input/ramp_effect.c b/dlls/windows.gaming.input/ramp_effect.c index fadcf151c04..f0eb4efaa31 100644 --- a/dlls/windows.gaming.input/ramp_effect.c +++ b/dlls/windows.gaming.input/ramp_effect.c @@ -42,7 +42,6 @@ static HRESULT WINAPI effect_QueryInterface( IRampForceEffect *iface, REFIID iid
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IRampForceEffect )) { IInspectable_AddRef( (*out = &impl->IRampForceEffect_iface) ); @@ -171,6 +170,7 @@ static const struct IRampForceEffectVtbl effect_vtbl = struct ramp_factory { IActivationFactory IActivationFactory_iface; + IAgileObject IAgileObject_iface; LONG ref; };
@@ -187,13 +187,18 @@ static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFI
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, &IID_IActivationFactory )) { IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -269,9 +274,12 @@ static const struct IActivationFactoryVtbl activation_vtbl = activation_ActivateInstance, };
+DEFINE_IAGILEOBJECT( ramp_factory, IActivationFactory, &object->IActivationFactory_iface ); + static struct ramp_factory ramp_statics = { {&activation_vtbl}, + {&ramp_factory_IAgileObject_vtbl}, 1, };
diff --git a/dlls/windows.gaming.input/vector.c b/dlls/windows.gaming.input/vector.c index 954d7df3552..a96662ea99f 100644 --- a/dlls/windows.gaming.input/vector.c +++ b/dlls/windows.gaming.input/vector.c @@ -26,6 +26,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(combase); struct iterator { IIterator_IInspectable IIterator_IInspectable_iface; + IAgileObject IAgileObject_iface; const GUID *iid; LONG ref;
@@ -47,13 +48,18 @@ static HRESULT WINAPI iterator_QueryInterface( IIterator_IInspectable *iface, RE
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, impl->iid )) { IInspectable_AddRef( (*out = &impl->IIterator_IInspectable_iface) ); return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -152,10 +158,13 @@ static const IIterator_IInspectableVtbl iterator_vtbl = iterator_GetMany, };
+DEFINE_IAGILEOBJECT( iterator, IIterator_IInspectable, &object->IIterator_IInspectable_iface ); + struct vector_view { IVectorView_IInspectable IVectorView_IInspectable_iface; IIterable_IInspectable IIterable_IInspectable_iface; + IAgileObject IAgileObject_iface; struct vector_iids iids; LONG ref;
@@ -176,7 +185,6 @@ static HRESULT WINAPI vector_view_QueryInterface( IVectorView_IInspectable *ifac
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, impl->iids.view )) { IInspectable_AddRef( (*out = &impl->IVectorView_IInspectable_iface) ); @@ -189,6 +197,12 @@ static HRESULT WINAPI vector_view_QueryInterface( IVectorView_IInspectable *ifac return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -323,6 +337,7 @@ static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IItera
if (!(iter = calloc( 1, sizeof(struct iterator) ))) return E_OUTOFMEMORY; iter->IIterator_IInspectable_iface.lpVtbl = &iterator_vtbl; + iter->IAgileObject_iface.lpVtbl = &iterator_IAgileObject_vtbl; iter->iid = impl->iids.iterator; iter->ref = 1;
@@ -346,10 +361,13 @@ static const struct IIterable_IInspectableVtbl iterable_view_vtbl = iterable_view_First, };
+DEFINE_IAGILEOBJECT( vector_view, IVectorView_IInspectable, &object->IVectorView_IInspectable_iface ); + struct vector { IVector_IInspectable IVector_IInspectable_iface; IIterable_IInspectable IIterable_IInspectable_iface; + IAgileObject IAgileObject_iface; struct vector_iids iids; LONG ref;
@@ -371,7 +389,6 @@ static HRESULT WINAPI vector_QueryInterface( IVector_IInspectable *iface, REFIID
if (IsEqualGUID( iid, &IID_IUnknown ) || IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAgileObject ) || IsEqualGUID( iid, impl->iids.vector )) { IInspectable_AddRef( (*out = &impl->IVector_IInspectable_iface) ); @@ -384,6 +401,12 @@ static HRESULT WINAPI vector_QueryInterface( IVector_IInspectable *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_IAgileObject )) + { + IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -463,6 +486,7 @@ static HRESULT WINAPI vector_GetView( IVector_IInspectable *iface, IVectorView_I if (!(view = calloc( 1, offsetof( struct vector_view, elements[impl->size] ) ))) return E_OUTOFMEMORY; view->IVectorView_IInspectable_iface.lpVtbl = &vector_view_vtbl; view->IIterable_IInspectable_iface.lpVtbl = &iterable_view_vtbl; + view->IAgileObject_iface.lpVtbl = &vector_view_IAgileObject_vtbl; view->iids = impl->iids; view->ref = 1;
@@ -657,6 +681,8 @@ static const struct IIterable_IInspectableVtbl iterable_vtbl = iterable_First, };
+DEFINE_IAGILEOBJECT( vector, IVector_IInspectable, &object->IVector_IInspectable_iface ); + HRESULT vector_create( const struct vector_iids *iids, void **out ) { struct vector *impl; @@ -666,6 +692,7 @@ HRESULT vector_create( const struct vector_iids *iids, void **out ) if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IVector_IInspectable_iface.lpVtbl = &vector_vtbl; impl->IIterable_IInspectable_iface.lpVtbl = &iterable_vtbl; + impl->IAgileObject_iface.lpVtbl = &vector_IAgileObject_vtbl; impl->iids = *iids; impl->ref = 1;
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/header.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 413354d5b56..bd625b385af 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -46,6 +46,7 @@ static void write_apicontract_guard_start(FILE *header, const expr_t *expr); static void write_apicontract_guard_end(FILE *header, const expr_t *expr);
static void write_widl_using_macros(FILE *header, type_t *iface); +static void write_widl_impl_macros(FILE *header, type_t *iface);
static void indent(FILE *h, int delta) { @@ -1645,6 +1646,8 @@ static void write_widl_using_macros(FILE *header, type_t *iface) macro = format_namespace(iface->namespace, "WIDL_using_", "_", NULL, NULL); fprintf(header, "#ifdef %s\n", macro);
+ fprintf(header, "#define INTERFACE_VTBL_%s INTERFACE_VTBL_%s\n", name, iface->c_name); + if (uuid) fprintf(header, "#define IID_%s IID_%s\n", name, iface->c_name); if (iface->type_type == TYPE_INTERFACE) fprintf(header, "#define %sVtbl %sVtbl\n", name, iface->c_name); fprintf(header, "#define %s %s\n", name, iface->c_name); @@ -1655,6 +1658,38 @@ static void write_widl_using_macros(FILE *header, type_t *iface) free(macro); }
+static void write_widl_impl_macros_methods(FILE *header, const type_t *iface, const type_t *top_iface, const char *prefix) +{ + const statement_t *stmt; + + if (type_iface_get_inherit(iface)) write_widl_impl_macros_methods(header, type_iface_get_inherit(iface), top_iface, prefix); + + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) + { + const var_t *func = stmt->u.var; + + if (is_override_method(iface, top_iface, func)) continue; + if (is_callas(func->attrs)) continue; + + fprintf(header, " %s_%s, \\n", prefix, get_name(func)); + } +} + +static void write_widl_impl_macros(FILE *header, type_t *iface) +{ + const struct uuid *uuid = get_attrp(iface->attrs, ATTR_UUID); + + if (uuid) + { + fprintf(header, "#define INTERFACE_VTBL_%s( pfx ) \\n", iface->c_name); + fprintf(header, " static const %sVtbl %s_vtbl = \\n", iface->c_name, "pfx ## "); + fprintf(header, " { \\n"); + write_widl_impl_macros_methods(header, iface, iface, "pfx ## "); + fprintf(header, " };\n"); + fprintf(header, "\n" ); + } +} + static void write_com_interface_end(FILE *header, type_t *iface) { int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE); @@ -1731,7 +1766,10 @@ static void write_com_interface_end(FILE *header, type_t *iface) write_method_macro(header, type, type, iface->c_name); fprintf(header, "#else\n"); write_inline_wrappers(header, type, type, iface->c_name); - fprintf(header, "#endif\n"); + fprintf(header, "#endif\n\n"); + fprintf(header, "#ifdef __WINESRC__\n\n"); + write_widl_impl_macros(header, iface); + fprintf(header, "#endif /* __WINESRC__ */\n\n"); if (winrt_mode) write_widl_using_macros(header, iface); fprintf(header, "#endif\n"); fprintf(header, "\n");
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 226 ++++++++----------------- dlls/windows.gaming.input/private.h | 7 +- 2 files changed, 75 insertions(+), 158 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 62a10bc887c..4b789076793 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -179,62 +179,40 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo return hr; }
-static const struct IGameControllerImplVtbl controller_vtbl = -{ - controller_QueryInterface, - controller_AddRef, - controller_Release, - /* IInspectable methods */ - controller_GetIids, - controller_GetRuntimeClassName, - controller_GetTrustLevel, - /* IGameControllerImpl methods */ - controller_Initialize, -}; +INTERFACE_VTBL_IGameControllerImpl( controller );
-DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, struct controller, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( controller_IGameControllerInputSink, IGameControllerInputSink, struct controller, IGameController_outer )
-static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI controller_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static HRESULT WINAPI input_sink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI controller_IGameControllerInputSink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static const struct IGameControllerInputSinkVtbl input_sink_vtbl = -{ - input_sink_QueryInterface, - input_sink_AddRef, - input_sink_Release, - /* IInspectable methods */ - input_sink_GetIids, - input_sink_GetRuntimeClassName, - input_sink_GetTrustLevel, - /* IGameControllerInputSink methods */ - input_sink_OnInputResumed, - input_sink_OnInputSuspended, -}; +INTERFACE_VTBL_IGameControllerInputSink( controller_IGameControllerInputSink );
-DEFINE_IINSPECTABLE_OUTER( raw_controller, IRawGameController, struct controller, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController, IRawGameController, struct controller, IGameController_outer )
-static HRESULT WINAPI raw_controller_get_AxisCount( IRawGameController *iface, INT32 *value ) +static HRESULT WINAPI controller_IRawGameController_get_AxisCount( IRawGameController *iface, INT32 *value ) { struct controller *impl = impl_from_IRawGameController( iface ); return IWineGameControllerProvider_get_AxisCount( impl->wine_provider, value ); }
-static HRESULT WINAPI raw_controller_get_ButtonCount( IRawGameController *iface, INT32 *value ) +static HRESULT WINAPI controller_IRawGameController_get_ButtonCount( IRawGameController *iface, INT32 *value ) { struct controller *impl = impl_from_IRawGameController( iface ); return IWineGameControllerProvider_get_ButtonCount( impl->wine_provider, value ); }
-static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController *iface, IVectorView_ForceFeedbackMotor **value ) +static HRESULT WINAPI controller_IRawGameController_get_ForceFeedbackMotors( IRawGameController *iface, + IVectorView_ForceFeedbackMotor **value ) { static const struct vector_iids iids = { @@ -264,34 +242,35 @@ static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController return hr; }
-static HRESULT WINAPI raw_controller_get_HardwareProductId( IRawGameController *iface, UINT16 *value ) +static HRESULT WINAPI controller_IRawGameController_get_HardwareProductId( IRawGameController *iface, UINT16 *value ) { struct controller *impl = impl_from_IRawGameController( iface ); return IGameControllerProvider_get_HardwareProductId( impl->provider, value ); }
-static HRESULT WINAPI raw_controller_get_HardwareVendorId( IRawGameController *iface, UINT16 *value ) +static HRESULT WINAPI controller_IRawGameController_get_HardwareVendorId( IRawGameController *iface, UINT16 *value ) { struct controller *impl = impl_from_IRawGameController( iface ); return IGameControllerProvider_get_HardwareVendorId( impl->provider, value ); }
-static HRESULT WINAPI raw_controller_get_SwitchCount( IRawGameController *iface, INT32 *value ) +static HRESULT WINAPI controller_IRawGameController_get_SwitchCount( IRawGameController *iface, INT32 *value ) { struct controller *impl = impl_from_IRawGameController( iface ); return IWineGameControllerProvider_get_SwitchCount( impl->wine_provider, value ); }
-static HRESULT WINAPI raw_controller_GetButtonLabel( IRawGameController *iface, INT32 index, - enum GameControllerButtonLabel *value ) +static HRESULT WINAPI controller_IRawGameController_GetButtonLabel( IRawGameController *iface, INT32 index, + enum GameControllerButtonLabel *value ) { FIXME( "iface %p, index %d, value %p stub!\n", iface, index, value ); return E_NOTIMPL; }
-static HRESULT WINAPI raw_controller_GetCurrentReading( IRawGameController *iface, UINT32 buttons_size, BOOLEAN *buttons, - UINT32 switches_size, enum GameControllerSwitchPosition *switches, - UINT32 axes_size, DOUBLE *axes, UINT64 *timestamp ) +static HRESULT WINAPI +controller_IRawGameController_GetCurrentReading( IRawGameController *iface, UINT32 buttons_size, BOOLEAN *buttons, + UINT32 switches_size, enum GameControllerSwitchPosition *switches, + UINT32 axes_size, DOUBLE *axes, UINT64 *timestamp ) { struct controller *impl = impl_from_IRawGameController( iface ); WineGameControllerState state; @@ -310,36 +289,20 @@ static HRESULT WINAPI raw_controller_GetCurrentReading( IRawGameController *ifac return hr; }
-static HRESULT WINAPI raw_controller_GetSwitchKind( IRawGameController *iface, INT32 index, enum GameControllerSwitchKind *value ) +static HRESULT WINAPI controller_IRawGameController_GetSwitchKind( IRawGameController *iface, INT32 index, + enum GameControllerSwitchKind *value ) { FIXME( "iface %p, index %d, value %p stub!\n", iface, index, value ); return E_NOTIMPL; }
-static const struct IRawGameControllerVtbl raw_controller_vtbl = -{ - raw_controller_QueryInterface, - raw_controller_AddRef, - raw_controller_Release, - /* IInspectable methods */ - raw_controller_GetIids, - raw_controller_GetRuntimeClassName, - raw_controller_GetTrustLevel, - /* IRawGameController methods */ - raw_controller_get_AxisCount, - raw_controller_get_ButtonCount, - raw_controller_get_ForceFeedbackMotors, - raw_controller_get_HardwareProductId, - raw_controller_get_HardwareVendorId, - raw_controller_get_SwitchCount, - raw_controller_GetButtonLabel, - raw_controller_GetCurrentReading, - raw_controller_GetSwitchKind, -}; +INTERFACE_VTBL_IRawGameController( controller_IRawGameController );
-DEFINE_IINSPECTABLE_OUTER( raw_controller_2, IRawGameController2, struct controller, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController2, IRawGameController2, struct controller, IGameController_outer )
-static HRESULT WINAPI raw_controller_2_get_SimpleHapticsControllers( IRawGameController2 *iface, IVectorView_SimpleHapticsController** value) +static HRESULT WINAPI +controller_IRawGameController2_get_SimpleHapticsControllers( IRawGameController2 *iface, + IVectorView_SimpleHapticsController **value ) { static const struct vector_iids iids = { @@ -362,32 +325,19 @@ static HRESULT WINAPI raw_controller_2_get_SimpleHapticsControllers( IRawGameCon return hr; }
-static HRESULT WINAPI raw_controller_2_get_NonRoamableId( IRawGameController2 *iface, HSTRING* value ) +static HRESULT WINAPI controller_IRawGameController2_get_NonRoamableId( IRawGameController2 *iface, HSTRING *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI raw_controller_2_get_DisplayName( IRawGameController2 *iface, HSTRING* value ) +static HRESULT WINAPI controller_IRawGameController2_get_DisplayName( IRawGameController2 *iface, HSTRING *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static const struct IRawGameController2Vtbl raw_controller_2_vtbl = -{ - raw_controller_2_QueryInterface, - raw_controller_2_AddRef, - raw_controller_2_Release, - /* IInspectable methods */ - raw_controller_2_GetIids, - raw_controller_2_GetRuntimeClassName, - raw_controller_2_GetTrustLevel, - /* IRawGameController2 methods */ - raw_controller_2_get_SimpleHapticsControllers, - raw_controller_2_get_NonRoamableId, - raw_controller_2_get_DisplayName, -}; +INTERFACE_VTBL_IRawGameController2( controller_IRawGameController2 );
struct controller_statics { @@ -403,7 +353,7 @@ static inline struct controller_statics *impl_from_IActivationFactory( IActivati return CONTAINING_RECORD( iface, struct controller_statics, IActivationFactory_iface ); }
-static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +static HRESULT WINAPI controller_statics_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) { struct controller_statics *impl = impl_from_IActivationFactory( iface );
@@ -440,7 +390,7 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return E_NOINTERFACE; }
-static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) +static ULONG WINAPI controller_statics_AddRef( IActivationFactory *iface ) { struct controller_statics *impl = impl_from_IActivationFactory( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); @@ -448,7 +398,7 @@ static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) return ref; }
-static ULONG WINAPI factory_Release( IActivationFactory *iface ) +static ULONG WINAPI controller_statics_Release( IActivationFactory *iface ) { struct controller_statics *impl = impl_from_IActivationFactory( iface ); ULONG ref = InterlockedDecrement( &impl->ref ); @@ -456,76 +406,72 @@ static ULONG WINAPI factory_Release( IActivationFactory *iface ) return ref; }
-static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) +static HRESULT WINAPI controller_statics_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) { FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); return E_NOTIMPL; }
-static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) +static HRESULT WINAPI controller_statics_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) { FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); return E_NOTIMPL; }
-static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) +static HRESULT WINAPI controller_statics_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) { FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); return E_NOTIMPL; }
-static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI controller_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IActivationFactory methods */ - factory_ActivateInstance, -}; +INTERFACE_VTBL_IActivationFactory( controller_statics );
-DEFINE_IINSPECTABLE( statics, IRawGameControllerStatics, struct controller_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( controller_statics_IRawGameControllerStatics, IRawGameControllerStatics, + struct controller_statics, IActivationFactory_iface )
-static HRESULT WINAPI statics_add_RawGameControllerAdded( IRawGameControllerStatics *iface, - IEventHandler_RawGameController *handler, - EventRegistrationToken *token ) +static HRESULT WINAPI +controller_statics_IRawGameControllerStatics_add_RawGameControllerAdded( IRawGameControllerStatics *iface, + IEventHandler_RawGameController *handler, + EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); if (!handler) return E_INVALIDARG; return event_handlers_append( &controller_added_handlers, (IEventHandler_IInspectable *)handler, token ); }
-static HRESULT WINAPI statics_remove_RawGameControllerAdded( IRawGameControllerStatics *iface, EventRegistrationToken token ) +static HRESULT WINAPI +controller_statics_IRawGameControllerStatics_remove_RawGameControllerAdded( IRawGameControllerStatics *iface, EventRegistrationToken token ) { TRACE( "iface %p, token %#I64x.\n", iface, token.value ); return event_handlers_remove( &controller_added_handlers, &token ); }
-static HRESULT WINAPI statics_add_RawGameControllerRemoved( IRawGameControllerStatics *iface, - IEventHandler_RawGameController *handler, - EventRegistrationToken *token ) +static HRESULT WINAPI +controller_statics_IRawGameControllerStatics_add_RawGameControllerRemoved( IRawGameControllerStatics *iface, + IEventHandler_RawGameController *handler, + EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); if (!handler) return E_INVALIDARG; return event_handlers_append( &controller_removed_handlers, (IEventHandler_IInspectable *)handler, token ); }
-static HRESULT WINAPI statics_remove_RawGameControllerRemoved( IRawGameControllerStatics *iface, EventRegistrationToken token ) +static HRESULT WINAPI +controller_statics_IRawGameControllerStatics_remove_RawGameControllerRemoved( IRawGameControllerStatics *iface, EventRegistrationToken token ) { TRACE( "iface %p, token %#I64x.\n", iface, token.value ); return event_handlers_remove( &controller_removed_handlers, &token ); }
-static HRESULT WINAPI statics_get_RawGameControllers( IRawGameControllerStatics *iface, IVectorView_RawGameController **value ) +static HRESULT WINAPI +controller_statics_IRawGameControllerStatics_get_RawGameControllers( IRawGameControllerStatics *iface, + IVectorView_RawGameController **value ) { HRESULT hr;
@@ -539,8 +485,9 @@ static HRESULT WINAPI statics_get_RawGameControllers( IRawGameControllerStatics return hr; }
-static HRESULT WINAPI statics_FromGameController( IRawGameControllerStatics *iface, IGameController *game_controller, - IRawGameController **value ) +static HRESULT WINAPI +controller_statics_IRawGameControllerStatics_FromGameController( IRawGameControllerStatics *iface, IGameController *game_controller, + IRawGameController **value ) { struct controller_statics *impl = impl_from_IRawGameControllerStatics( iface ); IGameController *controller; @@ -559,28 +506,14 @@ static HRESULT WINAPI statics_FromGameController( IRawGameControllerStatics *ifa return hr; }
-static const struct IRawGameControllerStaticsVtbl statics_vtbl = -{ - statics_QueryInterface, - statics_AddRef, - statics_Release, - /* IInspectable methods */ - statics_GetIids, - statics_GetRuntimeClassName, - statics_GetTrustLevel, - /* IRawGameControllerStatics methods */ - statics_add_RawGameControllerAdded, - statics_remove_RawGameControllerAdded, - statics_add_RawGameControllerRemoved, - statics_remove_RawGameControllerRemoved, - statics_get_RawGameControllers, - statics_FromGameController, -}; +INTERFACE_VTBL_IRawGameControllerStatics( controller_statics_IRawGameControllerStatics );
-DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, struct controller_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( controller_statics_ICustomGameControllerFactory, ICustomGameControllerFactory, + struct controller_statics, IActivationFactory_iface )
-static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, - IInspectable **value ) +static HRESULT WINAPI +controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, + IGameControllerProvider *provider, IInspectable **value ) { struct controller *impl;
@@ -588,9 +521,9 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IGameControllerImpl_iface.lpVtbl = &controller_vtbl; - impl->IGameControllerInputSink_iface.lpVtbl = &input_sink_vtbl; - impl->IRawGameController_iface.lpVtbl = &raw_controller_vtbl; - impl->IRawGameController2_iface.lpVtbl = &raw_controller_2_vtbl; + impl->IGameControllerInputSink_iface.lpVtbl = &controller_IGameControllerInputSink_vtbl; + impl->IRawGameController_iface.lpVtbl = &controller_IRawGameController_vtbl; + impl->IRawGameController2_iface.lpVtbl = &controller_IRawGameController2_vtbl; impl->ref = 1;
TRACE( "created RawGameController %p\n", impl ); @@ -599,7 +532,8 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro return S_OK; }
-static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value ) +static HRESULT WINAPI +controller_statics_ICustomGameControllerFactory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value ) { IRawGameController *controller; HRESULT hr; @@ -614,7 +548,8 @@ static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameContr return S_OK; }
-static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value ) +static HRESULT WINAPI +controller_statics_ICustomGameControllerFactory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value ) { IRawGameController *controller; BOOLEAN found; @@ -648,28 +583,15 @@ static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameCon return S_OK; }
-static const struct ICustomGameControllerFactoryVtbl controller_factory_vtbl = -{ - controller_factory_QueryInterface, - controller_factory_AddRef, - controller_factory_Release, - /* IInspectable methods */ - controller_factory_GetIids, - controller_factory_GetRuntimeClassName, - controller_factory_GetTrustLevel, - /* ICustomGameControllerFactory methods */ - controller_factory_CreateGameController, - controller_factory_OnGameControllerAdded, - controller_factory_OnGameControllerRemoved, -}; +INTERFACE_VTBL_ICustomGameControllerFactory( controller_statics_ICustomGameControllerFactory );
DEFINE_IAGILEOBJECT( controller_statics, IActivationFactory, &object->IActivationFactory_iface );
static struct controller_statics controller_statics = { - {&factory_vtbl}, - {&statics_vtbl}, - {&controller_factory_vtbl}, + {&controller_statics_vtbl}, + {&controller_statics_IRawGameControllerStatics_vtbl}, + {&controller_statics_ICustomGameControllerFactory_vtbl}, {&controller_statics_IAgileObject_vtbl}, 1, }; diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index c0fdac02198..1f98f5e828c 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -138,12 +138,7 @@ extern HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown struct type *object = CONTAINING_RECORD( iface, struct type, IAgileObject_iface ); \ return base##_Release( (expr) ); \ } \ - static const IAgileObjectVtbl type##_IAgileObject_vtbl = \ - { \ - type##_IAgileObject_QueryInterface, \ - type##_IAgileObject_AddRef, \ - type##_IAgileObject_Release, \ - }; + INTERFACE_VTBL_IAgileObject( type ## _IAgileObject );
static inline const char *debugstr_vector3( const Vector3 *vector ) {
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 */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 51 +++++--------------------- include/wine/comimpl.h | 35 ++++++++++++++++++ 2 files changed, 45 insertions(+), 41 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 778e55fec18..bf78f037d8c 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -63,7 +63,7 @@ struct controller IRawGameController IRawGameController_iface; IRawGameController2 IRawGameController2_iface; IGameController *IGameController_outer; - LONG ref; + LONG refcount;
IGameControllerProvider *provider; IWineGameControllerProvider *wine_provider; @@ -108,31 +108,15 @@ static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REF return E_NOINTERFACE; }
-static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface ) +static void controller_destroy( struct controller *impl ) { - struct controller *impl = controller_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; + if (impl->wine_provider) IWineGameControllerProvider_Release( impl->wine_provider ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
-static ULONG WINAPI controller_Release( IGameControllerImpl *iface ) -{ - struct controller *impl = controller_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - if (impl->wine_provider) - IWineGameControllerProvider_Release( impl->wine_provider ); - IGameControllerProvider_Release( impl->provider ); - free( impl ); - } - - return ref; -} +IUNKNOWN_IMPL_ADDREF( controller, IGameControllerImpl ); +IUNKNOWN_IMPL_RELEASE( controller, IGameControllerImpl );
static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) { @@ -342,7 +326,6 @@ struct controller_statics IRawGameControllerStatics IRawGameControllerStatics_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; };
INTERFACE_IMPL_FROM( controller_statics, IActivationFactory ); @@ -384,21 +367,8 @@ static HRESULT WINAPI controller_statics_QueryInterface( IActivationFactory *ifa return E_NOINTERFACE; }
-static ULONG WINAPI controller_statics_AddRef( 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; -} - -static ULONG WINAPI controller_statics_Release( 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; -} +IUNKNOWN_IMPL_STATIC_ADDREF( controller_statics, IActivationFactory ); +IUNKNOWN_IMPL_STATIC_RELEASE( controller_statics, IActivationFactory );
static HRESULT WINAPI controller_statics_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) { @@ -518,7 +488,7 @@ controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGam impl->IGameControllerInputSink_iface.lpVtbl = &controller_IGameControllerInputSink_vtbl; impl->IRawGameController_iface.lpVtbl = &controller_IRawGameController_vtbl; impl->IRawGameController2_iface.lpVtbl = &controller_IRawGameController2_vtbl; - impl->ref = 1; + impl->refcount = 1;
TRACE( "created RawGameController %p\n", impl );
@@ -587,7 +557,6 @@ static struct controller_statics controller_statics = {&controller_statics_IRawGameControllerStatics_vtbl}, {&controller_statics_ICustomGameControllerFactory_vtbl}, {&controller_statics_IAgileObject_vtbl}, - 1, };
ICustomGameControllerFactory *controller_factory = &controller_statics.ICustomGameControllerFactory_iface; diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index c8078f40827..5eff3b5ff02 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -38,6 +38,41 @@ return CONTAINING_RECORD( iface, struct type, iface_mem ); \ }
+#define IUNKNOWN_IMPL_ADDREF( type, name ) IUNKNOWN_IMPL_ADDREF_( type, name, type ## _from_ ## name ) +#define IUNKNOWN_IMPL_ADDREF_( type, name, impl_from ) \ + static ULONG WINAPI type ## _AddRef( name *iface ) \ + { \ + struct type *object = impl_from( iface ); \ + ULONG ref = InterlockedIncrement( &object->refcount ); \ + TRACE( "object %p increasing refcount to %lu.\n", object, ref ); \ + return ref; \ + } +#define IUNKNOWN_IMPL_STATIC_ADDREF( type, name ) \ + static ULONG WINAPI type ## _AddRef( name *iface ) \ + { \ + return 2; \ + } + +#define IUNKNOWN_IMPL_RELEASE( type, name ) IUNKNOWN_IMPL_RELEASE_( type, name, type ## _from_ ## name ) +#define IUNKNOWN_IMPL_RELEASE_( type, name, impl_from ) \ + static ULONG WINAPI type ## _Release( name *iface ) \ + { \ + struct type *object = impl_from( iface ); \ + ULONG ref = InterlockedDecrement( &object->refcount ); \ + TRACE( "object %p decreasing refcount to %lu.\n", object, ref); \ + if (!ref) \ + { \ + InterlockedIncrement( &object->refcount ); /* guard against re-entry when aggregated */ \ + type ## _destroy( object ); \ + } \ + return ref; \ + } +#define IUNKNOWN_IMPL_STATIC_RELEASE( type, name ) \ + static ULONG WINAPI type ## _Release( name *iface ) \ + { \ + return 1; \ + } + #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 ) \
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/header.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/tools/widl/header.c b/tools/widl/header.c index bd625b385af..b815b07c791 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1646,6 +1646,11 @@ static void write_widl_using_macros(FILE *header, type_t *iface) macro = format_namespace(iface->namespace, "WIDL_using_", "_", NULL, NULL); fprintf(header, "#ifdef %s\n", macro);
+ fprintf(header, "#define QUERY_INTERFACE_OPT_%s QUERY_INTERFACE_OPT_%s\n", name, iface->c_name); + fprintf(header, "#define QUERY_INTERFACE_%s QUERY_INTERFACE_%s\n", name, iface->c_name); + fprintf(header, "#define QUERY_INTERFACES_OPT_%s QUERY_INTERFACES_OPT_%s\n", name, iface->c_name); + fprintf(header, "#define QUERY_INTERFACES_%s QUERY_INTERFACES_%s\n", name, iface->c_name); + fprintf(header, "#define INTERFACE_VTBL_%s INTERFACE_VTBL_%s\n", name, iface->c_name);
if (uuid) fprintf(header, "#define IID_%s IID_%s\n", name, iface->c_name); @@ -1678,9 +1683,31 @@ static void write_widl_impl_macros_methods(FILE *header, const type_t *iface, co static void write_widl_impl_macros(FILE *header, type_t *iface) { const struct uuid *uuid = get_attrp(iface->attrs, ATTR_UUID); + const char *name = iface->short_name ? iface->short_name : iface->name; + type_t *base = type_iface_get_inherit(iface);
if (uuid) { + fprintf(header, "#define QUERY_INTERFACE_OPT_%s( object, iid, out, mem ) \\n", iface->c_name); + fprintf(header, " if ((object)->mem.lpVtbl) QUERY_INTERFACE_%s( object, iid, out, mem )\n", iface->c_name); + fprintf(header, "#define QUERY_INTERFACE_%s( object, iid, out, mem ) \\n", iface->c_name); + fprintf(header, " if (0 " ); + for (base = iface; base; (base = type_iface_get_inherit(base))) + fprintf(header, "%s|| IsEqualGUID( (iid), &IID_%s )", base == iface ? "" : " \\n ", base->c_name ); + fprintf(header, ") \\n" ); + fprintf(header, " { \\n" ); + fprintf(header, " *(out) = &(object)->mem; \\n" ); + fprintf(header, " %s_AddRef( &(object)->mem ); \\n", iface->c_name ); + fprintf(header, " return S_OK; \\n" ); + fprintf(header, " }\n" ); + fprintf(header, "#define QUERY_INTERFACES_OPT_%s( object, iid, out, X, ... ) \\n", iface->c_name); + fprintf(header, " QUERY_INTERFACE_OPT_%s( object, iid, out, %s_iface ) \\n", iface->c_name, name); + fprintf(header, " QUERY_INTERFACES_ ## X( object, iid, out, __VA_ARGS__ )\n"); + fprintf(header, "#define QUERY_INTERFACES_%s( object, iid, out, X, ... ) \\n", iface->c_name); + fprintf(header, " QUERY_INTERFACE_%s( object, iid, out, %s_iface ) \\n", iface->c_name, name); + fprintf(header, " QUERY_INTERFACES_ ## X( object, iid, out, __VA_ARGS__ )\n"); + fprintf(header, "\n"); + fprintf(header, "#define INTERFACE_VTBL_%s( pfx ) \\n", iface->c_name); fprintf(header, " static const %sVtbl %s_vtbl = \\n", iface->c_name, "pfx ## "); fprintf(header, " { \\n");
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 79 ++------------------------ include/wine/comimpl.h | 15 +++++ 2 files changed, 19 insertions(+), 75 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index bf78f037d8c..11dd4d31921 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -70,43 +70,8 @@ struct controller };
INTERFACE_IMPL_FROM( controller, IGameControllerImpl ); - -static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REFIID iid, void **out ) -{ - struct controller *impl = controller_from_IGameControllerImpl( iface ); - - 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_IGameControllerImpl )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerInputSink )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerInputSink_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IRawGameController )) - { - IInspectable_AddRef( (*out = &impl->IRawGameController_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IRawGameController2 )) - { - IInspectable_AddRef( (*out = &impl->IRawGameController2_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} +IUNKNOWN_IMPL_QUERY_INTERFACE( controller, IGameControllerImpl, IGameControllerInputSink, + IRawGameController, IRawGameController2, END );
static void controller_destroy( struct controller *impl ) { @@ -329,44 +294,8 @@ struct controller_statics };
INTERFACE_IMPL_FROM( controller_statics, IActivationFactory ); - -static HRESULT WINAPI controller_statics_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct controller_statics *impl = controller_statics_from_IActivationFactory( iface ); - - 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_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IRawGameControllerStatics )) - { - IInspectable_AddRef( (*out = &impl->IRawGameControllerStatics_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_ICustomGameControllerFactory )) - { - IInspectable_AddRef( (*out = &impl->ICustomGameControllerFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - +IUNKNOWN_IMPL_QUERY_INTERFACE( controller_statics, IActivationFactory, IRawGameControllerStatics, + ICustomGameControllerFactory, IAgileObject, END ); IUNKNOWN_IMPL_STATIC_ADDREF( controller_statics, IActivationFactory ); IUNKNOWN_IMPL_STATIC_RELEASE( controller_statics, IActivationFactory );
diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index 5eff3b5ff02..41691d21ef3 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -31,6 +31,9 @@ #include <windef.h> #include <winbase.h>
+#define QUERY_INTERFACES_END( object, iid, out, ... ) +#define QUERY_INTERFACES( object, iid, out, X, ... ) QUERY_INTERFACES_ ## X( object, iid, out, __VA_ARGS__ ) + #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 ) \ @@ -38,6 +41,18 @@ return CONTAINING_RECORD( iface, struct type, iface_mem ); \ }
+#define IUNKNOWN_IMPL_QUERY_INTERFACE( type, name, ... ) IUNKNOWN_IMPL_QUERY_INTERFACE_( type, name, type ## _from_ ## name, __VA_ARGS__ ) +#define IUNKNOWN_IMPL_QUERY_INTERFACE_( type, name, impl_from, ... ) \ + static HRESULT WINAPI type ## _QueryInterface( name *iface, REFIID iid, void **out ) \ + { \ + struct type *object = impl_from( iface ); \ + TRACE( "object %p, iid %s, out %p.\n", object, debugstr_guid(iid), out ); \ + QUERY_INTERFACES( object, iid, out, name, __VA_ARGS__ ); \ + *out = NULL; \ + WARN( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid) ); \ + return E_NOINTERFACE; \ + } + #define IUNKNOWN_IMPL_ADDREF( type, name ) IUNKNOWN_IMPL_ADDREF_( type, name, type ## _from_ ## name ) #define IUNKNOWN_IMPL_ADDREF_( type, name, impl_from ) \ static ULONG WINAPI type ## _AddRef( name *iface ) \
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 12 ++++-------- include/wine/comimpl.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 11dd4d31921..880752ee9e8 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -70,8 +70,6 @@ struct controller };
INTERFACE_IMPL_FROM( controller, IGameControllerImpl ); -IUNKNOWN_IMPL_QUERY_INTERFACE( controller, IGameControllerImpl, IGameControllerInputSink, - IRawGameController, IRawGameController2, END );
static void controller_destroy( struct controller *impl ) { @@ -80,8 +78,8 @@ static void controller_destroy( struct controller *impl ) free( impl ); }
-IUNKNOWN_IMPL_ADDREF( controller, IGameControllerImpl ); -IUNKNOWN_IMPL_RELEASE( controller, IGameControllerImpl ); +IUNKNOWN_IMPL( controller, IGameControllerImpl, IGameControllerInputSink, + IRawGameController, IRawGameController2, END );
static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) { @@ -294,10 +292,8 @@ struct controller_statics };
INTERFACE_IMPL_FROM( controller_statics, IActivationFactory ); -IUNKNOWN_IMPL_QUERY_INTERFACE( controller_statics, IActivationFactory, IRawGameControllerStatics, - ICustomGameControllerFactory, IAgileObject, END ); -IUNKNOWN_IMPL_STATIC_ADDREF( controller_statics, IActivationFactory ); -IUNKNOWN_IMPL_STATIC_RELEASE( controller_statics, IActivationFactory ); +IUNKNOWN_IMPL_STATIC( controller_statics, IActivationFactory, IRawGameControllerStatics, + ICustomGameControllerFactory, IAgileObject, END );
static HRESULT WINAPI controller_statics_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) { diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index 41691d21ef3..2631f2d97ac 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -88,6 +88,16 @@ return 1; \ }
+#define IUNKNOWN_IMPL( type, name, ... ) \ + IUNKNOWN_IMPL_QUERY_INTERFACE_( type, name, type ## _from_ ## name, __VA_ARGS__ ) \ + IUNKNOWN_IMPL_ADDREF_( type, name, type ## _from_ ## name ) \ + IUNKNOWN_IMPL_RELEASE_( type, name, type ## _from_ ## name ) + +#define IUNKNOWN_IMPL_STATIC( type, name, ... ) \ + IUNKNOWN_IMPL_QUERY_INTERFACE_( type, name, type ## _from_ ## name, __VA_ARGS__ ) \ + IUNKNOWN_IMPL_STATIC_ADDREF( type, name ) \ + IUNKNOWN_IMPL_STATIC_RELEASE( type, name ) + #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 ) \
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 43 ++++---------------------- include/wine/comimpl.h | 26 ++++++++++++++++ 2 files changed, 32 insertions(+), 37 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 880752ee9e8..b05381a3967 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -63,6 +63,7 @@ struct controller IRawGameController IRawGameController_iface; IRawGameController2 IRawGameController2_iface; IGameController *IGameController_outer; + const WCHAR *class_name; LONG refcount;
IGameControllerProvider *provider; @@ -80,25 +81,7 @@ static void controller_destroy( struct controller *impl )
IUNKNOWN_IMPL( controller, IGameControllerImpl, IGameControllerInputSink, IRawGameController, IRawGameController2, END ); - -static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_GetRuntimeClassName( IGameControllerImpl *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_RawGameController, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_RawGameController), - class_name ); -} - -static HRESULT WINAPI controller_GetTrustLevel( IGameControllerImpl *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IINSPECTABLE_IMPL( controller, IGameControllerImpl );
static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) @@ -289,29 +272,13 @@ struct controller_statics IRawGameControllerStatics IRawGameControllerStatics_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; IAgileObject IAgileObject_iface; + const WCHAR *class_name; };
INTERFACE_IMPL_FROM( controller_statics, IActivationFactory ); IUNKNOWN_IMPL_STATIC( controller_statics, IActivationFactory, IRawGameControllerStatics, ICustomGameControllerFactory, IAgileObject, END ); - -static HRESULT WINAPI controller_statics_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_statics_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_statics_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IINSPECTABLE_IMPL( controller_statics, IActivationFactory );
static HRESULT WINAPI controller_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { @@ -413,6 +380,7 @@ controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGam impl->IGameControllerInputSink_iface.lpVtbl = &controller_IGameControllerInputSink_vtbl; impl->IRawGameController_iface.lpVtbl = &controller_IRawGameController_vtbl; impl->IRawGameController2_iface.lpVtbl = &controller_IRawGameController2_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_RawGameController; impl->refcount = 1;
TRACE( "created RawGameController %p\n", impl ); @@ -482,6 +450,7 @@ static struct controller_statics controller_statics = {&controller_statics_IRawGameControllerStatics_vtbl}, {&controller_statics_ICustomGameControllerFactory_vtbl}, {&controller_statics_IAgileObject_vtbl}, + RuntimeClass_Windows_Gaming_Input_RawGameController, };
ICustomGameControllerFactory *controller_factory = &controller_statics.ICustomGameControllerFactory_iface; diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index 2631f2d97ac..44c5d7f204a 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -116,6 +116,32 @@ return base ## _Release( (expr) ); \ }
+#define IINSPECTABLE_IMPL( type, name ) IINSPECTABLE_IMPL_( type, name, type ## _from_ ## name ) +#define IINSPECTABLE_IMPL_( type, name, impl_from ) \ + static HRESULT WINAPI type ## _GetIids( name *iface, ULONG *count, IID **iids ) \ + { \ + struct type *object = impl_from( iface ); \ + FIXME( "object %p, count %p, iids %p, stub!\n", object, count, iids ); \ + return E_NOTIMPL; \ + } \ + static HRESULT WINAPI type ## _GetRuntimeClassName( name *iface, HSTRING *class_name ) \ + { \ + struct type *object = impl_from( iface ); \ + if (!object->class_name) \ + { \ + FIXME( "object %p, class_name %p, stub!\n", object, class_name ); \ + return E_NOTIMPL; \ + } \ + TRACE( "object %p, class_name %p.\n", object, class_name ); \ + return WindowsCreateString( object->class_name, wcslen( object->class_name ), class_name ); \ + } \ + static HRESULT WINAPI type ## _GetTrustLevel( name *iface, TrustLevel *trust_level ) \ + { \ + struct type *object = impl_from( iface ); \ + FIXME( "object %p, trust_level %p, stub!\n", object, trust_level ); \ + return E_NOTIMPL; \ + } + #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 ) \
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/header.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/tools/widl/header.c b/tools/widl/header.c index b815b07c791..d63b33e23b9 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1652,6 +1652,14 @@ static void write_widl_using_macros(FILE *header, type_t *iface) fprintf(header, "#define QUERY_INTERFACES_%s QUERY_INTERFACES_%s\n", name, iface->c_name);
fprintf(header, "#define INTERFACE_VTBL_%s INTERFACE_VTBL_%s\n", name, iface->c_name); + fprintf(header, "#define INTERFACE_IMPL_%s INTERFACE_IMPL_%s\n", name, iface->c_name); + fprintf(header, "#define INTERFACE_IMPL_OUTER_%s INTERFACE_IMPL_OUTER_%s\n", name, iface->c_name); + fprintf(header, "#define INTERFACE_IMPL_STATIC_%s INTERFACE_IMPL_STATIC_%s\n", name, iface->c_name); + + fprintf(header, "#define INTERFACE_FWD_OPT_%s INTERFACE_FWD_OPT_%s\n", name, iface->c_name); + fprintf(header, "#define INTERFACE_FWD_%s INTERFACE_FWD_%s\n", name, iface->c_name); + fprintf(header, "#define INTERFACES_FWD_OPT_%s INTERFACES_FWD_OPT_%s\n", name, iface->c_name); + fprintf(header, "#define INTERFACES_FWD_%s INTERFACES_FWD_%s\n", name, iface->c_name);
if (uuid) fprintf(header, "#define IID_%s IID_%s\n", name, iface->c_name); if (iface->type_type == TYPE_INTERFACE) fprintf(header, "#define %sVtbl %sVtbl\n", name, iface->c_name); @@ -1688,6 +1696,8 @@ static void write_widl_impl_macros(FILE *header, type_t *iface)
if (uuid) { + int inspectable = base && !strcmp(base->c_name, "IInspectable"); + fprintf(header, "#define QUERY_INTERFACE_OPT_%s( object, iid, out, mem ) \\n", iface->c_name); fprintf(header, " if ((object)->mem.lpVtbl) QUERY_INTERFACE_%s( object, iid, out, mem )\n", iface->c_name); fprintf(header, "#define QUERY_INTERFACE_%s( object, iid, out, mem ) \\n", iface->c_name); @@ -1714,6 +1724,36 @@ static void write_widl_impl_macros(FILE *header, type_t *iface) write_widl_impl_macros_methods(header, iface, iface, "pfx ## "); fprintf(header, " };\n"); fprintf(header, "\n" ); + + fprintf(header, "#define INTERFACE_IMPL_%s( type, ... ) \\n", iface->c_name); + fprintf(header, " INTERFACE_IMPL_FROM_( type, %s, type ## _from_%s, %s_iface ) \\n", name, name, name ); + fprintf(header, " IUNKNOWN_IMPL( type, %s, __VA_ARGS__ ) \\n", name ); + if (inspectable) fprintf(header, " IINSPECTABLE_IMPL( type, %s ) \\n", name ); + fprintf(header, " INTERFACES_FWD( type, %s, &object->%s_iface, __VA_ARGS__ )\n", name, name); + + fprintf(header, "#define INTERFACE_IMPL_OUTER_%s( type, ... ) \\n", iface->c_name); + fprintf(header, " INTERFACE_IMPL_FROM_( type, %s, type ## _from_%s, %s_iface ) \\n", name, name, name); + fprintf(header, " IUNKNOWN_IMPL( type, %s, __VA_ARGS__ ) \\n", name); + if (inspectable) fprintf(header, " IINSPECTABLE_IMPL( type, %s ) \\n", name ); + fprintf(header, " INTERFACES_FWD( type, %s, object->outer, __VA_ARGS__ )\n", inspectable ? "IInspectable" : "IUnknown"); + + fprintf(header, "#define INTERFACE_IMPL_STATIC_%s( type, ... ) \\n", iface->c_name); + fprintf(header, " INTERFACE_IMPL_FROM_( type, %s, type ## _from_%s, %s_iface ) \\n", name, name, name ); + fprintf(header, " IUNKNOWN_IMPL_STATIC( type, %s, __VA_ARGS__ ) \\n", name ); + if (inspectable) fprintf(header, " IINSPECTABLE_IMPL( type, %s ) \\n", name ); + fprintf(header, " INTERFACES_FWD( type, %s, &object->%s_iface, __VA_ARGS__ )\n", name, name); + + fprintf(header, "#define INTERFACE_FWD_%s( type, base, expr ) \\n", iface->c_name); + fprintf(header, " INTERFACE_IMPL_FROM_( type, %s, type ## _from_%s, %s_iface ) \\n", name, name, name ); + fprintf(header, " IUNKNOWN_FWD( type, %s, base, expr ) \\n", name ); + if (inspectable) fprintf(header, " IINSPECTABLE_FWD( type, %s, base, expr ) \\n", name ); + fprintf(header, "\n"); + + fprintf(header, "#define INTERFACES_FWD_OPT_%s INTERFACES_FWD_%s\n", iface->c_name, iface->c_name); + fprintf(header, "#define INTERFACES_FWD_%s( type, base, expr, X, ... ) \\n", iface->c_name); + fprintf(header, " INTERFACE_FWD_%s( type, base, expr ) \\n", name); + fprintf(header, " INTERFACES_FWD_ ## X( type, base, expr, __VA_ARGS__ )\n"); + fprintf(header, "\n"); } }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 48 ++++++++------------------ include/wine/comimpl.h | 3 ++ 2 files changed, 18 insertions(+), 33 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index b05381a3967..0c6efe2714b 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -62,7 +62,7 @@ struct controller IGameControllerInputSink IGameControllerInputSink_iface; IRawGameController IRawGameController_iface; IRawGameController2 IRawGameController2_iface; - IGameController *IGameController_outer; + IInspectable *outer; const WCHAR *class_name; LONG refcount;
@@ -70,8 +70,6 @@ struct controller IWineGameControllerProvider *wine_provider; };
-INTERFACE_IMPL_FROM( controller, IGameControllerImpl ); - static void controller_destroy( struct controller *impl ) { if (impl->wine_provider) IWineGameControllerProvider_Release( impl->wine_provider ); @@ -79,9 +77,8 @@ static void controller_destroy( struct controller *impl ) free( impl ); }
-IUNKNOWN_IMPL( controller, IGameControllerImpl, IGameControllerInputSink, - IRawGameController, IRawGameController2, END ); -IINSPECTABLE_IMPL( controller, IGameControllerImpl ); +INTERFACE_IMPL_OUTER_IGameControllerImpl( controller, IGameControllerInputSink, + IRawGameController, IRawGameController2, END );
static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) @@ -91,7 +88,7 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo
TRACE( "iface %p, outer %p, provider %p.\n", iface, outer, provider );
- impl->IGameController_outer = outer; + impl->outer = (IInspectable *)outer; IGameControllerProvider_AddRef( (impl->provider = provider) );
hr = IGameControllerProvider_QueryInterface( provider, &IID_IWineGameControllerProvider, @@ -108,8 +105,6 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo
INTERFACE_VTBL_IGameControllerImpl( controller );
-DEFINE_IINSPECTABLE_OUTER( controller_IGameControllerInputSink, IGameControllerInputSink, controller, IGameController_outer ) - static HRESULT WINAPI controller_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); @@ -124,17 +119,15 @@ static HRESULT WINAPI controller_IGameControllerInputSink_OnInputSuspended( IGam
INTERFACE_VTBL_IGameControllerInputSink( controller_IGameControllerInputSink );
-DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController, IRawGameController, controller, IGameController_outer ) - static HRESULT WINAPI controller_IRawGameController_get_AxisCount( IRawGameController *iface, INT32 *value ) { - struct controller *impl = impl_from_IRawGameController( iface ); + struct controller *impl = controller_from_IRawGameController( iface ); return IWineGameControllerProvider_get_AxisCount( impl->wine_provider, value ); }
static HRESULT WINAPI controller_IRawGameController_get_ButtonCount( IRawGameController *iface, INT32 *value ) { - struct controller *impl = impl_from_IRawGameController( iface ); + struct controller *impl = controller_from_IRawGameController( iface ); return IWineGameControllerProvider_get_ButtonCount( impl->wine_provider, value ); }
@@ -148,7 +141,7 @@ static HRESULT WINAPI controller_IRawGameController_get_ForceFeedbackMotors( IRa .iterable = &IID_IIterable_ForceFeedbackMotor, .iterator = &IID_IIterator_ForceFeedbackMotor, }; - struct controller *impl = impl_from_IRawGameController( iface ); + struct controller *impl = controller_from_IRawGameController( iface ); IVector_ForceFeedbackMotor *vector; IForceFeedbackMotor *motor; HRESULT hr; @@ -171,19 +164,19 @@ static HRESULT WINAPI controller_IRawGameController_get_ForceFeedbackMotors( IRa
static HRESULT WINAPI controller_IRawGameController_get_HardwareProductId( IRawGameController *iface, UINT16 *value ) { - struct controller *impl = impl_from_IRawGameController( iface ); + struct controller *impl = controller_from_IRawGameController( iface ); return IGameControllerProvider_get_HardwareProductId( impl->provider, value ); }
static HRESULT WINAPI controller_IRawGameController_get_HardwareVendorId( IRawGameController *iface, UINT16 *value ) { - struct controller *impl = impl_from_IRawGameController( iface ); + struct controller *impl = controller_from_IRawGameController( iface ); return IGameControllerProvider_get_HardwareVendorId( impl->provider, value ); }
static HRESULT WINAPI controller_IRawGameController_get_SwitchCount( IRawGameController *iface, INT32 *value ) { - struct controller *impl = impl_from_IRawGameController( iface ); + struct controller *impl = controller_from_IRawGameController( iface ); return IWineGameControllerProvider_get_SwitchCount( impl->wine_provider, value ); }
@@ -199,7 +192,7 @@ controller_IRawGameController_GetCurrentReading( IRawGameController *iface, UINT UINT32 switches_size, enum GameControllerSwitchPosition *switches, UINT32 axes_size, DOUBLE *axes, UINT64 *timestamp ) { - struct controller *impl = impl_from_IRawGameController( iface ); + struct controller *impl = controller_from_IRawGameController( iface ); WineGameControllerState state; HRESULT hr;
@@ -225,8 +218,6 @@ static HRESULT WINAPI controller_IRawGameController_GetSwitchKind( IRawGameContr
INTERFACE_VTBL_IRawGameController( controller_IRawGameController );
-DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController2, IRawGameController2, controller, IGameController_outer ) - static HRESULT WINAPI controller_IRawGameController2_get_SimpleHapticsControllers( IRawGameController2 *iface, IVectorView_SimpleHapticsController **value ) @@ -275,10 +266,8 @@ struct controller_statics const WCHAR *class_name; };
-INTERFACE_IMPL_FROM( controller_statics, IActivationFactory ); -IUNKNOWN_IMPL_STATIC( controller_statics, IActivationFactory, IRawGameControllerStatics, - ICustomGameControllerFactory, IAgileObject, END ); -IINSPECTABLE_IMPL( controller_statics, IActivationFactory ); +INTERFACE_IMPL_STATIC_IActivationFactory( controller_statics, IRawGameControllerStatics, + ICustomGameControllerFactory, IAgileObject, END );
static HRESULT WINAPI controller_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { @@ -287,9 +276,7 @@ static HRESULT WINAPI controller_statics_ActivateInstance( IActivationFactory *i }
INTERFACE_VTBL_IActivationFactory( controller_statics ); - -DEFINE_IINSPECTABLE( controller_statics_IRawGameControllerStatics, IRawGameControllerStatics, - controller_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IAgileObject( controller_statics_IAgileObject );
static HRESULT WINAPI controller_statics_IRawGameControllerStatics_add_RawGameControllerAdded( IRawGameControllerStatics *iface, @@ -345,7 +332,7 @@ static HRESULT WINAPI controller_statics_IRawGameControllerStatics_FromGameController( IRawGameControllerStatics *iface, IGameController *game_controller, IRawGameController **value ) { - struct controller_statics *impl = impl_from_IRawGameControllerStatics( iface ); + struct controller_statics *impl = controller_statics_from_IRawGameControllerStatics( iface ); IGameController *controller; HRESULT hr;
@@ -364,9 +351,6 @@ controller_statics_IRawGameControllerStatics_FromGameController( IRawGameControl
INTERFACE_VTBL_IRawGameControllerStatics( controller_statics_IRawGameControllerStatics );
-DEFINE_IINSPECTABLE( controller_statics_ICustomGameControllerFactory, ICustomGameControllerFactory, - controller_statics, IActivationFactory_iface ) - static HRESULT WINAPI controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) @@ -442,8 +426,6 @@ controller_statics_ICustomGameControllerFactory_OnGameControllerRemoved( ICustom
INTERFACE_VTBL_ICustomGameControllerFactory( controller_statics_ICustomGameControllerFactory );
-DEFINE_IAGILEOBJECT( controller_statics, IActivationFactory, &object->IActivationFactory_iface ); - static struct controller_statics controller_statics = { {&controller_statics_vtbl}, diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index 44c5d7f204a..6b21fa4c16e 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -34,6 +34,9 @@ #define QUERY_INTERFACES_END( object, iid, out, ... ) #define QUERY_INTERFACES( object, iid, out, X, ... ) QUERY_INTERFACES_ ## X( object, iid, out, __VA_ARGS__ )
+#define INTERFACES_FWD_END( type, base, expr, ... ) +#define INTERFACES_FWD( type, base, expr, X, ... ) INTERFACES_FWD_ ## X( type, base, expr, __VA_ARGS__ ) + #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 ) \
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/async.c | 344 ++++------------- dlls/windows.gaming.input/condition_effect.c | 209 ++--------- dlls/windows.gaming.input/constant_effect.c | 184 ++------- dlls/windows.gaming.input/force_feedback.c | 269 +++---------- dlls/windows.gaming.input/gamepad.c | 374 +++---------------- dlls/windows.gaming.input/manager.c | 261 ++----------- dlls/windows.gaming.input/periodic_effect.c | 214 ++--------- dlls/windows.gaming.input/private.h | 14 - dlls/windows.gaming.input/provider.c | 181 ++------- dlls/windows.gaming.input/provider.idl | 4 +- dlls/windows.gaming.input/racing_wheel.c | 357 +++--------------- dlls/windows.gaming.input/ramp_effect.c | 184 ++------- dlls/windows.gaming.input/vector.c | 330 ++++------------ 13 files changed, 509 insertions(+), 2416 deletions(-)
diff --git a/dlls/windows.gaming.input/async.c b/dlls/windows.gaming.input/async.c index c142c6426d7..1b03cfac761 100644 --- a/dlls/windows.gaming.input/async.c +++ b/dlls/windows.gaming.input/async.c @@ -33,8 +33,9 @@ struct async_info IWineAsyncInfoImpl IWineAsyncInfoImpl_iface; IAsyncInfo IAsyncInfo_iface; IAgileObject IAgileObject_iface; - IInspectable *IInspectable_outer; - LONG ref; + IInspectable *outer; + const WCHAR *class_name; + LONG refcount;
async_operation_callback callback; TP_WORK *async_run_work; @@ -48,73 +49,22 @@ struct async_info HRESULT hr; };
-static inline struct async_info *impl_from_IWineAsyncInfoImpl( IWineAsyncInfoImpl *iface ) +static void async_info_destroy( struct async_info *impl ) { - return CONTAINING_RECORD( iface, struct async_info, IWineAsyncInfoImpl_iface ); + if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler ); + IAsyncInfo_Close( &impl->IAsyncInfo_iface ); + if (impl->param) IUnknown_Release( impl->param ); + if (impl->invoker) IUnknown_Release( impl->invoker ); + impl->cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection( &impl->cs ); + free( impl ); }
-static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFIID iid, void **out ) -{ - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); - - 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_IWineAsyncInfoImpl )) - { - IInspectable_AddRef( (*out = &impl->IWineAsyncInfoImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAsyncInfo )) - { - IInspectable_AddRef( (*out = &impl->IAsyncInfo_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI async_impl_AddRef( IWineAsyncInfoImpl *iface ) -{ - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) -{ - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); +INTERFACE_IMPL_OUTER_IWineAsyncInfoImpl( async_info, IAgileObject, IAsyncInfo, END );
- if (!ref) - { - if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler ); - IAsyncInfo_Close( &impl->IAsyncInfo_iface ); - if (impl->param) IUnknown_Release( impl->param ); - if (impl->invoker) IUnknown_Release( impl->invoker ); - impl->cs.DebugInfo->Spare[0] = 0; - DeleteCriticalSection( &impl->cs ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) +static HRESULT WINAPI async_info_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -128,7 +78,7 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine
if (impl->status > Started) { - IInspectable *operation = impl->IInspectable_outer; + IInspectable *operation = impl->outer; AsyncStatus status = impl->status; impl->handler = NULL; /* Prevent concurrent invoke. */ LeaveCriticalSection( &impl->cs ); @@ -144,9 +94,9 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine return hr; }
-static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler **handler ) +static HRESULT WINAPI async_info_get_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler **handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -160,9 +110,9 @@ static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWine return hr; }
-static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARIANT *result ) +static HRESULT WINAPI async_info_get_Result( IWineAsyncInfoImpl *iface, PROPVARIANT *result ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface ); HRESULT hr = E_ILLEGAL_METHOD_CALL;
TRACE( "iface %p, result %p.\n", iface, result ); @@ -178,37 +128,24 @@ static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARI return hr; }
-static HRESULT WINAPI async_impl_Start( IWineAsyncInfoImpl *iface ) +static HRESULT WINAPI async_info_Start( IWineAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface );
TRACE( "iface %p.\n", iface );
/* keep the async alive in the callback */ - IInspectable_AddRef( impl->IInspectable_outer ); + IInspectable_AddRef( impl->outer ); SubmitThreadpoolWork( impl->async_run_work );
return S_OK; }
-static const struct IWineAsyncInfoImplVtbl async_impl_vtbl = -{ - /* IUnknown methods */ - async_impl_QueryInterface, - async_impl_AddRef, - async_impl_Release, - /* IWineAsyncInfoImpl */ - async_impl_put_Completed, - async_impl_get_Completed, - async_impl_get_Result, - async_impl_Start, -}; +INTERFACE_VTBL_IWineAsyncInfoImpl( async_info );
-DEFINE_IINSPECTABLE_OUTER( async_info, IAsyncInfo, async_info, IInspectable_outer ) - -static HRESULT WINAPI async_info_get_Id( IAsyncInfo *iface, UINT32 *id ) +static HRESULT WINAPI async_info_IAsyncInfo_get_Id( IAsyncInfo *iface, UINT32 *id ) { - struct async_info *impl = impl_from_IAsyncInfo( iface ); + struct async_info *impl = async_info_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, id %p.\n", iface, id ); @@ -221,9 +158,9 @@ static HRESULT WINAPI async_info_get_Id( IAsyncInfo *iface, UINT32 *id ) return hr; }
-static HRESULT WINAPI async_info_get_Status( IAsyncInfo *iface, AsyncStatus *status ) +static HRESULT WINAPI async_info_IAsyncInfo_get_Status( IAsyncInfo *iface, AsyncStatus *status ) { - struct async_info *impl = impl_from_IAsyncInfo( iface ); + struct async_info *impl = async_info_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, status %p.\n", iface, status ); @@ -236,9 +173,9 @@ static HRESULT WINAPI async_info_get_Status( IAsyncInfo *iface, AsyncStatus *sta return hr; }
-static HRESULT WINAPI async_info_get_ErrorCode( IAsyncInfo *iface, HRESULT *error_code ) +static HRESULT WINAPI async_info_IAsyncInfo_get_ErrorCode( IAsyncInfo *iface, HRESULT *error_code ) { - struct async_info *impl = impl_from_IAsyncInfo( iface ); + struct async_info *impl = async_info_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, error_code %p.\n", iface, error_code ); @@ -251,9 +188,9 @@ static HRESULT WINAPI async_info_get_ErrorCode( IAsyncInfo *iface, HRESULT *erro return hr; }
-static HRESULT WINAPI async_info_Cancel( IAsyncInfo *iface ) +static HRESULT WINAPI async_info_IAsyncInfo_Cancel( IAsyncInfo *iface ) { - struct async_info *impl = impl_from_IAsyncInfo( iface ); + struct async_info *impl = async_info_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
TRACE( "iface %p.\n", iface ); @@ -266,9 +203,9 @@ static HRESULT WINAPI async_info_Cancel( IAsyncInfo *iface ) return hr; }
-static HRESULT WINAPI async_info_Close( IAsyncInfo *iface ) +static HRESULT WINAPI async_info_IAsyncInfo_Close( IAsyncInfo *iface ) { - struct async_info *impl = impl_from_IAsyncInfo( iface ); + struct async_info *impl = async_info_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
TRACE( "iface %p.\n", iface ); @@ -287,30 +224,13 @@ static HRESULT WINAPI async_info_Close( IAsyncInfo *iface ) return hr; }
-static const struct IAsyncInfoVtbl async_info_vtbl = -{ - /* IUnknown methods */ - async_info_QueryInterface, - async_info_AddRef, - async_info_Release, - /* IInspectable methods */ - async_info_GetIids, - async_info_GetRuntimeClassName, - async_info_GetTrustLevel, - /* IAsyncInfo */ - async_info_get_Id, - async_info_get_Status, - async_info_get_ErrorCode, - async_info_Cancel, - async_info_Close, -}; - -DEFINE_IAGILEOBJECT( async_info, IInspectable, object->IInspectable_outer ); +INTERFACE_VTBL_IAgileObject( async_info_IAgileObject ); +INTERFACE_VTBL_IAsyncInfo( async_info_IAsyncInfo );
static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *iface, TP_WORK *work ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); - IInspectable *operation = impl->IInspectable_outer; + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface ); + IInspectable *operation = impl->outer; PROPVARIANT result; HRESULT hr;
@@ -346,11 +266,11 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper HRESULT hr;
if (!(impl = calloc( 1, sizeof(struct async_info) ))) return E_OUTOFMEMORY; - impl->IWineAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; - impl->IAsyncInfo_iface.lpVtbl = &async_info_vtbl; + impl->IWineAsyncInfoImpl_iface.lpVtbl = &async_info_vtbl; + impl->IAsyncInfo_iface.lpVtbl = &async_info_IAsyncInfo_vtbl; impl->IAgileObject_iface.lpVtbl = &async_info_IAgileObject_vtbl; - impl->IInspectable_outer = outer; - impl->ref = 1; + impl->outer = outer; + impl->refcount = 1;
impl->callback = callback; impl->handler = HANDLER_NOT_SET; @@ -376,79 +296,35 @@ struct async_bool { IAsyncOperation_boolean IAsyncOperation_boolean_iface; IWineAsyncInfoImpl *IWineAsyncInfoImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount; };
-static inline struct async_bool *impl_from_IAsyncOperation_boolean( IAsyncOperation_boolean *iface ) -{ - return CONTAINING_RECORD( iface, struct async_bool, IAsyncOperation_boolean_iface ); -} +INTERFACE_IMPL_FROM( async_bool, IAsyncOperation_boolean );
static HRESULT WINAPI async_bool_QueryInterface( IAsyncOperation_boolean *iface, REFIID iid, void **out ) { - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); - + struct async_bool *impl = async_bool_from_IAsyncOperation_boolean( iface ); 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_IAsyncOperation_boolean )) - { - IInspectable_AddRef( (*out = &impl->IAsyncOperation_boolean_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IAsyncOperation_boolean( impl, iid, out, IAsyncOperation_boolean_iface ) return IWineAsyncInfoImpl_QueryInterface( impl->IWineAsyncInfoImpl_inner, iid, out ); }
-static ULONG WINAPI async_bool_AddRef( IAsyncOperation_boolean *iface ) -{ - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI async_bool_Release( IAsyncOperation_boolean *iface ) -{ - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI async_bool_GetIids( IAsyncOperation_boolean *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( async_bool, IAsyncOperation_boolean );
-static HRESULT WINAPI async_bool_GetRuntimeClassName( IAsyncOperation_boolean *iface, HSTRING *class_name ) +static void async_bool_destroy( struct async_bool *impl ) { - return WindowsCreateString( L"Windows.Foundation.IAsyncOperation`1<Boolean>", - ARRAY_SIZE(L"Windows.Foundation.IAsyncOperation`1<Boolean>"), - class_name ); + IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + free( impl ); }
-static HRESULT WINAPI async_bool_GetTrustLevel( IAsyncOperation_boolean *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( async_bool, IAsyncOperation_boolean ); +IINSPECTABLE_IMPL( async_bool, IAsyncOperation_boolean );
static HRESULT WINAPI async_bool_put_Completed( IAsyncOperation_boolean *iface, IAsyncOperationCompletedHandler_boolean *bool_handler ) { IWineAsyncOperationCompletedHandler *handler = (IWineAsyncOperationCompletedHandler *)bool_handler; - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + struct async_bool *impl = async_bool_from_IAsyncOperation_boolean( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); return IWineAsyncInfoImpl_put_Completed( impl->IWineAsyncInfoImpl_inner, handler ); } @@ -456,14 +332,14 @@ static HRESULT WINAPI async_bool_put_Completed( IAsyncOperation_boolean *iface, static HRESULT WINAPI async_bool_get_Completed( IAsyncOperation_boolean *iface, IAsyncOperationCompletedHandler_boolean **bool_handler ) { IWineAsyncOperationCompletedHandler **handler = (IWineAsyncOperationCompletedHandler **)bool_handler; - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + struct async_bool *impl = async_bool_from_IAsyncOperation_boolean( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); return IWineAsyncInfoImpl_get_Completed( impl->IWineAsyncInfoImpl_inner, handler ); }
static HRESULT WINAPI async_bool_GetResults( IAsyncOperation_boolean *iface, BOOLEAN *results ) { - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + struct async_bool *impl = async_bool_from_IAsyncOperation_boolean( iface ); PROPVARIANT result = {.vt = VT_BOOL}; HRESULT hr;
@@ -476,21 +352,7 @@ static HRESULT WINAPI async_bool_GetResults( IAsyncOperation_boolean *iface, BOO return hr; }
-static const struct IAsyncOperation_booleanVtbl async_bool_vtbl = -{ - /* IUnknown methods */ - async_bool_QueryInterface, - async_bool_AddRef, - async_bool_Release, - /* IInspectable methods */ - async_bool_GetIids, - async_bool_GetRuntimeClassName, - async_bool_GetTrustLevel, - /* IAsyncOperation<boolean> */ - async_bool_put_Completed, - async_bool_get_Completed, - async_bool_GetResults, -}; +INTERFACE_VTBL_IAsyncOperation_boolean( async_bool );
HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_boolean **out ) @@ -501,7 +363,8 @@ HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, asyn *out = NULL; if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IAsyncOperation_boolean_iface.lpVtbl = &async_bool_vtbl; - impl->ref = 1; + impl->class_name = L"Windows.Foundation.IAsyncOperation`1<Boolean>"; + impl->refcount = 1;
if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IWineAsyncInfoImpl_inner )) || FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner ))) @@ -520,92 +383,48 @@ struct async_result { IAsyncOperation_ForceFeedbackLoadEffectResult IAsyncOperation_ForceFeedbackLoadEffectResult_iface; IWineAsyncInfoImpl *IWineAsyncInfoImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount; };
-static inline struct async_result *impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( IAsyncOperation_ForceFeedbackLoadEffectResult *iface ) -{ - return CONTAINING_RECORD( iface, struct async_result, IAsyncOperation_ForceFeedbackLoadEffectResult_iface ); -} +INTERFACE_IMPL_FROM( async_result, IAsyncOperation_ForceFeedbackLoadEffectResult );
static HRESULT WINAPI async_result_QueryInterface( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, REFIID iid, void **out ) { - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); - + struct async_result *impl = async_result_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); 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_IAsyncOperation_ForceFeedbackLoadEffectResult )) - { - IInspectable_AddRef( (*out = &impl->IAsyncOperation_ForceFeedbackLoadEffectResult_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IAsyncOperation_ForceFeedbackLoadEffectResult( impl, iid, out, IAsyncOperation_ForceFeedbackLoadEffectResult_iface ) return IWineAsyncInfoImpl_QueryInterface( impl->IWineAsyncInfoImpl_inner, iid, out ); }
-static ULONG WINAPI async_result_AddRef( IAsyncOperation_ForceFeedbackLoadEffectResult *iface ) -{ - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI async_result_Release( IAsyncOperation_ForceFeedbackLoadEffectResult *iface ) -{ - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI async_result_GetIids( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( async_result, IAsyncOperation_ForceFeedbackLoadEffectResult );
-static HRESULT WINAPI async_result_GetRuntimeClassName( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, HSTRING *class_name ) +static void async_result_destroy( struct async_result *impl ) { - return WindowsCreateString( L"Windows.Foundation.IAsyncOperation`1<Windows.Gaming.Input.ForceFeedback.ForceFeedbackLoadEffectResult>", - ARRAY_SIZE(L"Windows.Foundation.IAsyncOperation`1<Windows.Gaming.Input.ForceFeedback.ForceFeedbackLoadEffectResult>"), - class_name ); + IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + free( impl ); }
-static HRESULT WINAPI async_result_GetTrustLevel( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( async_result, IAsyncOperation_ForceFeedbackLoadEffectResult ); +IINSPECTABLE_IMPL( async_result, IAsyncOperation_ForceFeedbackLoadEffectResult );
static HRESULT WINAPI async_result_put_Completed( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, IAsyncOperationCompletedHandler_ForceFeedbackLoadEffectResult *handler ) { - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); + struct async_result *impl = async_result_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); return IWineAsyncInfoImpl_put_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler *)handler ); }
static HRESULT WINAPI async_result_get_Completed( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, IAsyncOperationCompletedHandler_ForceFeedbackLoadEffectResult **handler ) { - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); + struct async_result *impl = async_result_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); return IWineAsyncInfoImpl_get_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler **)handler ); }
static HRESULT WINAPI async_result_GetResults( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, ForceFeedbackLoadEffectResult *results ) { - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); + struct async_result *impl = async_result_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); PROPVARIANT result = {.vt = VT_UI4}; HRESULT hr;
@@ -618,21 +437,7 @@ static HRESULT WINAPI async_result_GetResults( IAsyncOperation_ForceFeedbackLoad return hr; }
-static const struct IAsyncOperation_ForceFeedbackLoadEffectResultVtbl async_result_vtbl = -{ - /* IUnknown methods */ - async_result_QueryInterface, - async_result_AddRef, - async_result_Release, - /* IInspectable methods */ - async_result_GetIids, - async_result_GetRuntimeClassName, - async_result_GetTrustLevel, - /* IAsyncOperation<ForceFeedbackLoadEffectResult> */ - async_result_put_Completed, - async_result_get_Completed, - async_result_GetResults, -}; +INTERFACE_VTBL_IAsyncOperation_ForceFeedbackLoadEffectResult( async_result );
HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_ForceFeedbackLoadEffectResult **out ) @@ -643,7 +448,8 @@ HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown *param *out = NULL; if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IAsyncOperation_ForceFeedbackLoadEffectResult_iface.lpVtbl = &async_result_vtbl; - impl->ref = 1; + impl->class_name = L"Windows.Foundation.IAsyncOperation`1<Windows.Gaming.Input.ForceFeedback.ForceFeedbackLoadEffectResult>"; + impl->refcount = 1;
if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_ForceFeedbackLoadEffectResult_iface, &impl->IWineAsyncInfoImpl_inner )) || FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner ))) diff --git a/dlls/windows.gaming.input/condition_effect.c b/dlls/windows.gaming.input/condition_effect.c index 46b82523eeb..82506f9b506 100644 --- a/dlls/windows.gaming.input/condition_effect.c +++ b/dlls/windows.gaming.input/condition_effect.c @@ -26,90 +26,45 @@ struct condition_effect { IConditionForceEffect IConditionForceEffect_iface; IWineForceFeedbackEffectImpl *IWineForceFeedbackEffectImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount;
ConditionForceEffectKind kind; };
-static inline struct condition_effect *impl_from_IConditionForceEffect( IConditionForceEffect *iface ) -{ - return CONTAINING_RECORD( iface, struct condition_effect, IConditionForceEffect_iface ); -} +INTERFACE_IMPL_FROM( condition_effect, IConditionForceEffect );
-static HRESULT WINAPI effect_QueryInterface( IConditionForceEffect *iface, REFIID iid, void **out ) +static HRESULT WINAPI condition_effect_QueryInterface( IConditionForceEffect *iface, REFIID iid, void **out ) { - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); - + struct condition_effect *impl = condition_effect_from_IConditionForceEffect( iface ); 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_IConditionForceEffect )) - { - IInspectable_AddRef( (*out = &impl->IConditionForceEffect_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IConditionForceEffect( impl, iid, out, IConditionForceEffect_iface ) return IWineForceFeedbackEffectImpl_QueryInterface( impl->IWineForceFeedbackEffectImpl_inner, iid, out ); }
-static ULONG WINAPI effect_AddRef( IConditionForceEffect *iface ) -{ - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI effect_Release( IConditionForceEffect *iface ) -{ - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI effect_GetIids( IConditionForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( condition_effect, IConditionForceEffect );
-static HRESULT WINAPI effect_GetRuntimeClassName( IConditionForceEffect *iface, HSTRING *class_name ) +static void condition_effect_destroy( struct condition_effect *impl ) { - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect), - class_name ); + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetTrustLevel( IConditionForceEffect *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( condition_effect, IConditionForceEffect ); +IINSPECTABLE_IMPL( condition_effect, IConditionForceEffect );
-static HRESULT WINAPI effect_get_Kind( IConditionForceEffect *iface, ConditionForceEffectKind *kind ) +static HRESULT WINAPI condition_effect_get_Kind( IConditionForceEffect *iface, ConditionForceEffectKind *kind ) { - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); + struct condition_effect *impl = condition_effect_from_IConditionForceEffect( iface ); TRACE( "iface %p, kind %p.\n", iface, kind ); *kind = impl->kind; return S_OK; }
-static HRESULT WINAPI effect_SetParameters( IConditionForceEffect *iface, Vector3 direction, FLOAT positive_coeff, FLOAT negative_coeff, +static HRESULT WINAPI condition_effect_SetParameters( IConditionForceEffect *iface, Vector3 direction, FLOAT positive_coeff, FLOAT negative_coeff, FLOAT max_positive_magnitude, FLOAT max_negative_magnitude, FLOAT deadzone, FLOAT bias ) { - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); + struct condition_effect *impl = condition_effect_from_IConditionForceEffect( iface ); WineForceFeedbackEffectParameters params = { .condition = @@ -131,120 +86,27 @@ static HRESULT WINAPI effect_SetParameters( IConditionForceEffect *iface, Vector return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, NULL ); }
-static const struct IConditionForceEffectVtbl effect_vtbl = -{ - effect_QueryInterface, - effect_AddRef, - effect_Release, - /* IInspectable methods */ - effect_GetIids, - effect_GetRuntimeClassName, - effect_GetTrustLevel, - /* IConditionForceEffect methods */ - effect_get_Kind, - effect_SetParameters, -}; +INTERFACE_VTBL_IConditionForceEffect( condition_effect );
struct condition_factory { IActivationFactory IActivationFactory_iface; IConditionForceEffectFactory IConditionForceEffectFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct condition_factory *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct condition_factory, IActivationFactory_iface ); -} - -static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct condition_factory *impl = impl_from_IActivationFactory( iface ); - - 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_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IConditionForceEffectFactory )) - { - IInspectable_AddRef( (*out = &impl->IConditionForceEffectFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI activation_AddRef( IActivationFactory *iface ) -{ - struct condition_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI activation_Release( IActivationFactory *iface ) -{ - struct condition_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI activation_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +INTERFACE_IMPL_STATIC_IActivationFactory( condition_factory, IConditionForceEffectFactory, IAgileObject, END );
-static HRESULT WINAPI activation_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI condition_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl activation_vtbl = -{ - activation_QueryInterface, - activation_AddRef, - activation_Release, - /* IInspectable methods */ - activation_GetIids, - activation_GetRuntimeClassName, - activation_GetTrustLevel, - /* IActivationFactory methods */ - activation_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( factory, IConditionForceEffectFactory, condition_factory, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( condition_factory );
-static HRESULT WINAPI factory_CreateInstance( IConditionForceEffectFactory *iface, enum ConditionForceEffectKind kind, IForceFeedbackEffect **out ) +static HRESULT WINAPI condition_factory_IConditionForceEffectFactory_CreateInstance( IConditionForceEffectFactory *iface, enum ConditionForceEffectKind kind, IForceFeedbackEffect **out ) { enum WineForceFeedbackEffectType type = WineForceFeedbackEffectType_Condition + kind; struct condition_effect *impl; @@ -253,8 +115,9 @@ static HRESULT WINAPI factory_CreateInstance( IConditionForceEffectFactory *ifac TRACE( "iface %p, kind %u, out %p.\n", iface, kind, out );
if (!(impl = calloc( 1, sizeof(struct condition_effect) ))) return E_OUTOFMEMORY; - impl->IConditionForceEffect_iface.lpVtbl = &effect_vtbl; - impl->ref = 1; + impl->IConditionForceEffect_iface.lpVtbl = &condition_effect_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect; + impl->refcount = 1; impl->kind = kind;
if (FAILED(hr = force_feedback_effect_create( type, (IInspectable *)&impl->IConditionForceEffect_iface, &impl->IWineForceFeedbackEffectImpl_inner )) || @@ -270,27 +133,15 @@ static HRESULT WINAPI factory_CreateInstance( IConditionForceEffectFactory *ifac return S_OK; }
-static const struct IConditionForceEffectFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IConditionForceEffectFactory methods */ - factory_CreateInstance, -}; - -DEFINE_IAGILEOBJECT( condition_factory, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IConditionForceEffectFactory( condition_factory_IConditionForceEffectFactory ); +INTERFACE_VTBL_IAgileObject( condition_factory_IAgileObject );
static struct condition_factory condition_statics = { - {&activation_vtbl}, - {&factory_vtbl}, + {&condition_factory_vtbl}, + {&condition_factory_IConditionForceEffectFactory_vtbl}, {&condition_factory_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect, };
IInspectable *condition_effect_factory = (IInspectable *)&condition_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/constant_effect.c b/dlls/windows.gaming.input/constant_effect.c index 3e0a8cb0295..d20be1ad13f 100644 --- a/dlls/windows.gaming.input/constant_effect.c +++ b/dlls/windows.gaming.input/constant_effect.c @@ -26,77 +26,32 @@ struct constant_effect { IConstantForceEffect IConstantForceEffect_iface; IWineForceFeedbackEffectImpl *IWineForceFeedbackEffectImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount; };
-static inline struct constant_effect *impl_from_IConstantForceEffect( IConstantForceEffect *iface ) -{ - return CONTAINING_RECORD( iface, struct constant_effect, IConstantForceEffect_iface ); -} +INTERFACE_IMPL_FROM( constant_effect, IConstantForceEffect );
-static HRESULT WINAPI effect_QueryInterface( IConstantForceEffect *iface, REFIID iid, void **out ) +static HRESULT WINAPI constant_effect_QueryInterface( IConstantForceEffect *iface, REFIID iid, void **out ) { - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); - + struct constant_effect *impl = constant_effect_from_IConstantForceEffect( iface ); 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_IConstantForceEffect )) - { - IInspectable_AddRef( (*out = &impl->IConstantForceEffect_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IConstantForceEffect( impl, iid, out, IConstantForceEffect_iface ) return IWineForceFeedbackEffectImpl_QueryInterface( impl->IWineForceFeedbackEffectImpl_inner, iid, out ); }
-static ULONG WINAPI effect_AddRef( IConstantForceEffect *iface ) -{ - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( constant_effect, IConstantForceEffect );
-static ULONG WINAPI effect_Release( IConstantForceEffect *iface ) +static void constant_effect_destroy( struct constant_effect *impl ) { - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetIids( IConstantForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI effect_GetRuntimeClassName( IConstantForceEffect *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect), - class_name ); -} - -static HRESULT WINAPI effect_GetTrustLevel( IConstantForceEffect *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( constant_effect, IConstantForceEffect ); +IINSPECTABLE_IMPL( constant_effect, IConstantForceEffect );
-static HRESULT WINAPI effect_SetParameters( IConstantForceEffect *iface, Vector3 direction, TimeSpan duration ) +static HRESULT WINAPI constant_effect_SetParameters( IConstantForceEffect *iface, Vector3 direction, TimeSpan duration ) { WineForceFeedbackEffectParameters params = { @@ -109,14 +64,14 @@ static HRESULT WINAPI effect_SetParameters( IConstantForceEffect *iface, Vector3 .gain = 1., }, }; - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); + struct constant_effect *impl = constant_effect_from_IConstantForceEffect( iface );
TRACE( "iface %p, direction %s, duration %I64u.\n", iface, debugstr_vector3( &direction ), duration.Duration );
return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, NULL ); }
-static HRESULT WINAPI effect_SetParametersWithEnvelope( IConstantForceEffect *iface, Vector3 direction, FLOAT attack_gain, +static HRESULT WINAPI constant_effect_SetParametersWithEnvelope( IConstantForceEffect *iface, Vector3 direction, FLOAT attack_gain, FLOAT sustain_gain, FLOAT release_gain, TimeSpan start_delay, TimeSpan attack_duration, TimeSpan sustain_duration, TimeSpan release_duration, UINT32 repeat_count ) @@ -140,7 +95,7 @@ static HRESULT WINAPI effect_SetParametersWithEnvelope( IConstantForceEffect *if .attack_duration = attack_duration, .release_duration = release_duration, }; - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); + struct constant_effect *impl = constant_effect_from_IConstantForceEffect( iface );
TRACE( "iface %p, direction %s, attack_gain %f, sustain_gain %f, release_gain %f, start_delay %I64u, attack_duration %I64u, " "sustain_duration %I64u, release_duration %I64u, repeat_count %u.\n", iface, debugstr_vector3( &direction ), @@ -150,92 +105,18 @@ static HRESULT WINAPI effect_SetParametersWithEnvelope( IConstantForceEffect *if return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, &envelope ); }
-static const struct IConstantForceEffectVtbl effect_vtbl = -{ - effect_QueryInterface, - effect_AddRef, - effect_Release, - /* IInspectable methods */ - effect_GetIids, - effect_GetRuntimeClassName, - effect_GetTrustLevel, - /* IConstantForceEffect methods */ - effect_SetParameters, - effect_SetParametersWithEnvelope, -}; +INTERFACE_VTBL_IConstantForceEffect( constant_effect );
struct constant_factory { IActivationFactory IActivationFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct constant_factory *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct constant_factory, IActivationFactory_iface ); -} +INTERFACE_IMPL_STATIC_IActivationFactory( constant_factory, IAgileObject, END );
-static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct constant_factory *impl = impl_from_IActivationFactory( iface ); - - 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_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI activation_AddRef( IActivationFactory *iface ) -{ - struct constant_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI activation_Release( IActivationFactory *iface ) -{ - struct constant_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI activation_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI constant_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { struct constant_effect *impl; HRESULT hr; @@ -243,8 +124,9 @@ static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, II TRACE( "iface %p, instance %p.\n", iface, instance );
if (!(impl = calloc( 1, sizeof(struct constant_effect) ))) return E_OUTOFMEMORY; - impl->IConstantForceEffect_iface.lpVtbl = &effect_vtbl; - impl->ref = 1; + impl->IConstantForceEffect_iface.lpVtbl = &constant_effect_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect; + impl->refcount = 1;
if (FAILED(hr = force_feedback_effect_create( WineForceFeedbackEffectType_Constant, (IInspectable *)&impl->IConstantForceEffect_iface, &impl->IWineForceFeedbackEffectImpl_inner ))) @@ -258,26 +140,14 @@ static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, II return S_OK; }
-static const struct IActivationFactoryVtbl activation_vtbl = -{ - activation_QueryInterface, - activation_AddRef, - activation_Release, - /* IInspectable methods */ - activation_GetIids, - activation_GetRuntimeClassName, - activation_GetTrustLevel, - /* IActivationFactory methods */ - activation_ActivateInstance, -}; - -DEFINE_IAGILEOBJECT( constant_factory, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IActivationFactory( constant_factory ); +INTERFACE_VTBL_IAgileObject( constant_factory_IAgileObject );
static struct constant_factory constant_statics = { - {&activation_vtbl}, + {&constant_factory_vtbl}, {&constant_factory_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect, };
IInspectable *constant_effect_factory = (IInspectable *)&constant_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index 296dfa2a1e0..bf98a4702fb 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -35,8 +35,9 @@ struct effect IWineForceFeedbackEffectImpl IWineForceFeedbackEffectImpl_iface; IForceFeedbackEffect IForceFeedbackEffect_iface; IAgileObject IAgileObject_iface; - IInspectable *IInspectable_outer; - LONG ref; + IInspectable *outer; + const WCHAR *class_name; + LONG refcount;
CRITICAL_SECTION cs; IDirectInputEffect *effect; @@ -53,67 +54,15 @@ struct effect DIEFFECT params; };
-static inline struct effect *impl_from_IWineForceFeedbackEffectImpl( IWineForceFeedbackEffectImpl *iface ) +static void effect_destroy( struct effect *impl ) { - return CONTAINING_RECORD( iface, struct effect, IWineForceFeedbackEffectImpl_iface ); + if (impl->effect) IDirectInputEffect_Release( impl->effect ); + impl->cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection( &impl->cs ); + free( impl ); }
-static HRESULT WINAPI effect_impl_QueryInterface( IWineForceFeedbackEffectImpl *iface, REFIID iid, void **out ) -{ - struct effect *impl = impl_from_IWineForceFeedbackEffectImpl( iface ); - - 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_IWineForceFeedbackEffectImpl )) - { - IWineForceFeedbackEffectImpl_AddRef( (*out = &impl->IWineForceFeedbackEffectImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IForceFeedbackEffect )) - { - IInspectable_AddRef( (*out = &impl->IForceFeedbackEffect_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI effect_impl_AddRef( IWineForceFeedbackEffectImpl *iface ) -{ - struct effect *impl = impl_from_IWineForceFeedbackEffectImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI effect_impl_Release( IWineForceFeedbackEffectImpl *iface ) -{ - struct effect *impl = impl_from_IWineForceFeedbackEffectImpl( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - if (impl->effect) IDirectInputEffect_Release( impl->effect ); - impl->cs.DebugInfo->Spare[0] = 0; - DeleteCriticalSection( &impl->cs ); - free( impl ); - } - - return ref; -} +INTERFACE_IMPL_OUTER_IWineForceFeedbackEffectImpl( effect, IForceFeedbackEffect, IAgileObject, END );
static int effect_reorient_direction( const WineForceFeedbackEffectParameters *params, Vector3 *direction ) { @@ -155,10 +104,10 @@ static int effect_reorient_direction( const WineForceFeedbackEffectParameters *p return sign; }
-static HRESULT WINAPI effect_impl_put_Parameters( IWineForceFeedbackEffectImpl *iface, WineForceFeedbackEffectParameters params, +static HRESULT WINAPI effect_put_Parameters( IWineForceFeedbackEffectImpl *iface, WineForceFeedbackEffectParameters params, WineForceFeedbackEffectEnvelope *envelope ) { - struct effect *impl = impl_from_IWineForceFeedbackEffectImpl( iface ); + struct effect *impl = effect_from_IWineForceFeedbackEffectImpl( iface ); Vector3 direction = {0}; double magnitude = 0; DWORD count = 0; @@ -241,20 +190,11 @@ static HRESULT WINAPI effect_impl_put_Parameters( IWineForceFeedbackEffectImpl * return hr; }
-static const struct IWineForceFeedbackEffectImplVtbl effect_impl_vtbl = -{ - effect_impl_QueryInterface, - effect_impl_AddRef, - effect_impl_Release, - /* IWineForceFeedbackEffectImpl methods */ - effect_impl_put_Parameters, -}; +INTERFACE_VTBL_IWineForceFeedbackEffectImpl( effect );
-DEFINE_IINSPECTABLE_OUTER( effect, IForceFeedbackEffect, effect, IInspectable_outer ) - -static HRESULT WINAPI effect_get_Gain( IForceFeedbackEffect *iface, DOUBLE *value ) +static HRESULT WINAPI effect_IForceFeedbackEffect_get_Gain( IForceFeedbackEffect *iface, DOUBLE *value ) { - struct effect *impl = impl_from_IForceFeedbackEffect( iface ); + struct effect *impl = effect_from_IForceFeedbackEffect( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -265,9 +205,9 @@ static HRESULT WINAPI effect_get_Gain( IForceFeedbackEffect *iface, DOUBLE *valu return S_OK; }
-static HRESULT WINAPI effect_put_Gain( IForceFeedbackEffect *iface, DOUBLE value ) +static HRESULT WINAPI effect_IForceFeedbackEffect_put_Gain( IForceFeedbackEffect *iface, DOUBLE value ) { - struct effect *impl = impl_from_IForceFeedbackEffect( iface ); + struct effect *impl = effect_from_IForceFeedbackEffect( iface ); HRESULT hr;
TRACE( "iface %p, value %f.\n", iface, value ); @@ -281,9 +221,9 @@ static HRESULT WINAPI effect_put_Gain( IForceFeedbackEffect *iface, DOUBLE value return hr; }
-static HRESULT WINAPI effect_get_State( IForceFeedbackEffect *iface, ForceFeedbackEffectState *value ) +static HRESULT WINAPI effect_IForceFeedbackEffect_get_State( IForceFeedbackEffect *iface, ForceFeedbackEffectState *value ) { - struct effect *impl = impl_from_IForceFeedbackEffect( iface ); + struct effect *impl = effect_from_IForceFeedbackEffect( iface ); DWORD status; HRESULT hr;
@@ -304,9 +244,9 @@ static HRESULT WINAPI effect_get_State( IForceFeedbackEffect *iface, ForceFeedba return S_OK; }
-static HRESULT WINAPI effect_Start( IForceFeedbackEffect *iface ) +static HRESULT WINAPI effect_IForceFeedbackEffect_Start( IForceFeedbackEffect *iface ) { - struct effect *impl = impl_from_IForceFeedbackEffect( iface ); + struct effect *impl = effect_from_IForceFeedbackEffect( iface ); HRESULT hr = E_UNEXPECTED; DWORD flags = 0;
@@ -319,9 +259,9 @@ static HRESULT WINAPI effect_Start( IForceFeedbackEffect *iface ) return hr; }
-static HRESULT WINAPI effect_Stop( IForceFeedbackEffect *iface ) +static HRESULT WINAPI effect_IForceFeedbackEffect_Stop( IForceFeedbackEffect *iface ) { - struct effect *impl = impl_from_IForceFeedbackEffect( iface ); + struct effect *impl = effect_from_IForceFeedbackEffect( iface ); HRESULT hr = E_UNEXPECTED;
TRACE( "iface %p.\n", iface ); @@ -333,24 +273,8 @@ static HRESULT WINAPI effect_Stop( IForceFeedbackEffect *iface ) return hr; }
-static const struct IForceFeedbackEffectVtbl effect_vtbl = -{ - effect_QueryInterface, - effect_AddRef, - effect_Release, - /* IInspectable methods */ - effect_GetIids, - effect_GetRuntimeClassName, - effect_GetTrustLevel, - /* IForceFeedbackEffect methods */ - effect_get_Gain, - effect_put_Gain, - effect_get_State, - effect_Start, - effect_Stop, -}; - -DEFINE_IAGILEOBJECT( effect, IInspectable, object->IInspectable_outer ); +INTERFACE_VTBL_IForceFeedbackEffect( effect_IForceFeedbackEffect ); +INTERFACE_VTBL_IAgileObject( effect_IAgileObject );
HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IInspectable *outer, IWineForceFeedbackEffectImpl **out ) { @@ -359,11 +283,11 @@ HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IIn TRACE( "outer %p, out %p\n", outer, out );
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; - impl->IWineForceFeedbackEffectImpl_iface.lpVtbl = &effect_impl_vtbl; - impl->IForceFeedbackEffect_iface.lpVtbl = &effect_vtbl; + impl->IWineForceFeedbackEffectImpl_iface.lpVtbl = &effect_vtbl; + impl->IForceFeedbackEffect_iface.lpVtbl = &effect_IForceFeedbackEffect_vtbl; impl->IAgileObject_iface.lpVtbl = &effect_IAgileObject_vtbl; - impl->IInspectable_outer = outer; - impl->ref = 1; + impl->outer = outer; + impl->refcount = 1;
switch (type) { @@ -441,87 +365,23 @@ struct motor { IForceFeedbackMotor IForceFeedbackMotor_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; + LONG refcount;
IDirectInputDevice8W *device; };
-static inline struct motor *impl_from_IForceFeedbackMotor( IForceFeedbackMotor *iface ) +static void motor_destroy( struct motor *impl ) { - return CONTAINING_RECORD( iface, struct motor, IForceFeedbackMotor_iface ); + IDirectInputDevice8_Release( impl->device ); + free( impl ); }
-static HRESULT WINAPI motor_QueryInterface( IForceFeedbackMotor *iface, REFIID iid, void **out ) -{ - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); - - 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_IForceFeedbackMotor )) - { - IInspectable_AddRef( (*out = &impl->IForceFeedbackMotor_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI motor_AddRef( IForceFeedbackMotor *iface ) -{ - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI motor_Release( IForceFeedbackMotor *iface ) -{ - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - IDirectInputDevice8_Release( impl->device ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI motor_GetIids( IForceFeedbackMotor *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI motor_GetRuntimeClassName( IForceFeedbackMotor *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor), - class_name ); -} - -static HRESULT WINAPI motor_GetTrustLevel( IForceFeedbackMotor *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +INTERFACE_IMPL_IForceFeedbackMotor( motor, IAgileObject, END );
static HRESULT WINAPI motor_get_AreEffectsPaused( IForceFeedbackMotor *iface, BOOLEAN *value ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface ); DWORD state; HRESULT hr;
@@ -535,7 +395,7 @@ static HRESULT WINAPI motor_get_AreEffectsPaused( IForceFeedbackMotor *iface, BO
static HRESULT WINAPI motor_get_MasterGain( IForceFeedbackMotor *iface, double *value ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface ); DIPROPDWORD gain = { .diph = @@ -557,7 +417,7 @@ static HRESULT WINAPI motor_get_MasterGain( IForceFeedbackMotor *iface, double *
static HRESULT WINAPI motor_put_MasterGain( IForceFeedbackMotor *iface, double value ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface ); DIPROPDWORD gain = { .diph = @@ -576,7 +436,7 @@ static HRESULT WINAPI motor_put_MasterGain( IForceFeedbackMotor *iface, double v
static HRESULT WINAPI motor_get_IsEnabled( IForceFeedbackMotor *iface, BOOLEAN *value ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface ); DWORD state; HRESULT hr;
@@ -604,7 +464,7 @@ static BOOL CALLBACK check_ffb_axes( const DIDEVICEOBJECTINSTANCEW *obj, void *a
static HRESULT WINAPI motor_get_SupportedAxes( IForceFeedbackMotor *iface, enum ForceFeedbackEffectAxes *value ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface ); HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value ); @@ -618,9 +478,9 @@ static HRESULT WINAPI motor_get_SupportedAxes( IForceFeedbackMotor *iface, enum
static HRESULT WINAPI motor_load_effect_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - struct effect *effect = impl_from_IForceFeedbackEffect( (IForceFeedbackEffect *)param ); + struct effect *effect = effect_from_IForceFeedbackEffect( (IForceFeedbackEffect *)param ); IForceFeedbackMotor *motor = (IForceFeedbackMotor *)invoker; - struct motor *impl = impl_from_IForceFeedbackMotor( motor ); + struct motor *impl = motor_from_IForceFeedbackMotor( motor ); ForceFeedbackEffectAxes supported_axes = 0; IDirectInputEffect *dinput_effect; HRESULT hr; @@ -682,7 +542,7 @@ static HRESULT WINAPI motor_LoadEffectAsync( IForceFeedbackMotor *iface, IForceF
static HRESULT WINAPI motor_PauseAllEffects( IForceFeedbackMotor *iface ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface );
TRACE( "iface %p.\n", iface );
@@ -691,7 +551,7 @@ static HRESULT WINAPI motor_PauseAllEffects( IForceFeedbackMotor *iface )
static HRESULT WINAPI motor_ResumeAllEffects( IForceFeedbackMotor *iface ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface );
TRACE( "iface %p.\n", iface );
@@ -700,7 +560,7 @@ static HRESULT WINAPI motor_ResumeAllEffects( IForceFeedbackMotor *iface )
static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface );
TRACE( "iface %p.\n", iface );
@@ -709,7 +569,7 @@ static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface )
static HRESULT WINAPI motor_try_disable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); + struct motor *impl = motor_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSOFF ); @@ -727,7 +587,7 @@ static HRESULT WINAPI motor_TryDisableAsync( IForceFeedbackMotor *iface, IAsyncO
static HRESULT WINAPI motor_try_enable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); + struct motor *impl = motor_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSON ); @@ -745,7 +605,7 @@ static HRESULT WINAPI motor_TryEnableAsync( IForceFeedbackMotor *iface, IAsyncOp
static HRESULT WINAPI motor_try_reset_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); + struct motor *impl = motor_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_RESET ); @@ -763,7 +623,7 @@ static HRESULT WINAPI motor_TryResetAsync( IForceFeedbackMotor *iface, IAsyncOpe
static HRESULT WINAPI motor_unload_effect_async( IUnknown *iface, IUnknown *param, PROPVARIANT *result ) { - struct effect *effect = impl_from_IForceFeedbackEffect( (IForceFeedbackEffect *)param ); + struct effect *effect = effect_from_IForceFeedbackEffect( (IForceFeedbackEffect *)param ); IDirectInputEffect *dinput_effect; HRESULT hr;
@@ -787,7 +647,7 @@ static HRESULT WINAPI motor_unload_effect_async( IUnknown *iface, IUnknown *para static HRESULT WINAPI motor_TryUnloadEffectAsync( IForceFeedbackMotor *iface, IForceFeedbackEffect *effect, IAsyncOperation_boolean **async_op ) { - struct effect *impl = impl_from_IForceFeedbackEffect( (IForceFeedbackEffect *)effect ); + struct effect *impl = effect_from_IForceFeedbackEffect( (IForceFeedbackEffect *)effect ); HRESULT hr = S_OK;
TRACE( "iface %p, effect %p, async_op %p.\n", iface, effect, async_op ); @@ -800,32 +660,8 @@ static HRESULT WINAPI motor_TryUnloadEffectAsync( IForceFeedbackMotor *iface, IF return async_operation_boolean_create( (IUnknown *)iface, (IUnknown *)effect, motor_unload_effect_async, async_op ); }
-static const struct IForceFeedbackMotorVtbl motor_vtbl = -{ - motor_QueryInterface, - motor_AddRef, - motor_Release, - /* IInspectable methods */ - motor_GetIids, - motor_GetRuntimeClassName, - motor_GetTrustLevel, - /* IForceFeedbackMotor methods */ - motor_get_AreEffectsPaused, - motor_get_MasterGain, - motor_put_MasterGain, - motor_get_IsEnabled, - motor_get_SupportedAxes, - motor_LoadEffectAsync, - motor_PauseAllEffects, - motor_ResumeAllEffects, - motor_StopAllEffects, - motor_TryDisableAsync, - motor_TryEnableAsync, - motor_TryResetAsync, - motor_TryUnloadEffectAsync, -}; - -DEFINE_IAGILEOBJECT( motor, IForceFeedbackMotor, &object->IForceFeedbackMotor_iface ); +INTERFACE_VTBL_IForceFeedbackMotor( motor ); +INTERFACE_VTBL_IAgileObject( motor_IAgileObject );
HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ) { @@ -841,7 +677,8 @@ HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbac if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IForceFeedbackMotor_iface.lpVtbl = &motor_vtbl; impl->IAgileObject_iface.lpVtbl = &motor_IAgileObject_vtbl; - impl->ref = 1; + impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor; + impl->refcount = 1;
IDirectInputDevice_AddRef( device ); impl->device = device; diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c index 1c2d0c53299..2712152f99f 100644 --- a/dlls/windows.gaming.input/gamepad.c +++ b/dlls/windows.gaming.input/gamepad.c @@ -62,109 +62,33 @@ struct gamepad IGameControllerInputSink IGameControllerInputSink_iface; IGamepad IGamepad_iface; IGamepad2 IGamepad2_iface; - IGameController *IGameController_outer; - LONG ref; + IInspectable *outer; + const WCHAR *class_name; + LONG refcount;
IGameControllerProvider *provider; IWineGameControllerProvider *wine_provider; };
-static inline struct gamepad *impl_from_IGameControllerImpl( IGameControllerImpl *iface ) +static void gamepad_destroy( struct gamepad *impl ) { - return CONTAINING_RECORD( iface, struct gamepad, IGameControllerImpl_iface ); + if (impl->wine_provider) + IWineGameControllerProvider_Release( impl->wine_provider ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
-static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REFIID iid, void **out ) -{ - struct gamepad *impl = impl_from_IGameControllerImpl( iface ); - - 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_IGameControllerImpl )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerInputSink )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerInputSink_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGamepad )) - { - IInspectable_AddRef( (*out = &impl->IGamepad_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGamepad2 )) - { - IInspectable_AddRef( (*out = &impl->IGamepad2_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} +INTERFACE_IMPL_OUTER_IGameControllerImpl( gamepad, IGameControllerInputSink, IGamepad, IGamepad2, END );
-static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface ) -{ - struct gamepad *impl = impl_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI controller_Release( IGameControllerImpl *iface ) -{ - struct gamepad *impl = impl_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - if (impl->wine_provider) - IWineGameControllerProvider_Release( impl->wine_provider ); - IGameControllerProvider_Release( impl->provider ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_GetRuntimeClassName( IGameControllerImpl *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_Gamepad, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_Gamepad), - class_name ); -} - -static HRESULT WINAPI controller_GetTrustLevel( IGameControllerImpl *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, +static HRESULT WINAPI gamepad_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) { - struct gamepad *impl = impl_from_IGameControllerImpl( iface ); + struct gamepad *impl = gamepad_from_IGameControllerImpl( iface ); HRESULT hr;
TRACE( "iface %p, outer %p, provider %p.\n", iface, outer, provider );
- impl->IGameController_outer = outer; + impl->outer = (IInspectable *)outer; IGameControllerProvider_AddRef( (impl->provider = provider) );
hr = IGameControllerProvider_QueryInterface( provider, &IID_IWineGameControllerProvider, @@ -179,52 +103,25 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo return hr; }
-static const struct IGameControllerImplVtbl controller_vtbl = -{ - controller_QueryInterface, - controller_AddRef, - controller_Release, - /* IInspectable methods */ - controller_GetIids, - controller_GetRuntimeClassName, - controller_GetTrustLevel, - /* IGameControllerImpl methods */ - controller_Initialize, -}; - -DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, gamepad, IGameController_outer ) +INTERFACE_VTBL_IGameControllerImpl( gamepad );
-static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI gamepad_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static HRESULT WINAPI input_sink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI gamepad_IGameControllerInputSink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static const struct IGameControllerInputSinkVtbl input_sink_vtbl = -{ - input_sink_QueryInterface, - input_sink_AddRef, - input_sink_Release, - /* IInspectable methods */ - input_sink_GetIids, - input_sink_GetRuntimeClassName, - input_sink_GetTrustLevel, - /* IGameControllerInputSink methods */ - input_sink_OnInputResumed, - input_sink_OnInputSuspended, -}; - -DEFINE_IINSPECTABLE_OUTER( gamepad, IGamepad, gamepad, IGameController_outer ) +INTERFACE_VTBL_IGameControllerInputSink( gamepad_IGameControllerInputSink );
-static HRESULT WINAPI gamepad_get_Vibration( IGamepad *iface, struct GamepadVibration *value ) +static HRESULT WINAPI gamepad_IGamepad_get_Vibration( IGamepad *iface, struct GamepadVibration *value ) { - struct gamepad *impl = impl_from_IGamepad( iface ); + struct gamepad *impl = gamepad_from_IGamepad( iface ); struct WineGameControllerVibration vibration; HRESULT hr;
@@ -240,9 +137,9 @@ static HRESULT WINAPI gamepad_get_Vibration( IGamepad *iface, struct GamepadVibr return S_OK; }
-static HRESULT WINAPI gamepad_put_Vibration( IGamepad *iface, struct GamepadVibration value ) +static HRESULT WINAPI gamepad_IGamepad_put_Vibration( IGamepad *iface, struct GamepadVibration value ) { - struct gamepad *impl = impl_from_IGamepad( iface ); + struct gamepad *impl = gamepad_from_IGamepad( iface ); struct WineGameControllerVibration vibration = { .rumble = value.LeftMotor * 65535., @@ -256,9 +153,9 @@ static HRESULT WINAPI gamepad_put_Vibration( IGamepad *iface, struct GamepadVibr return IWineGameControllerProvider_put_Vibration( impl->wine_provider, vibration ); }
-static HRESULT WINAPI gamepad_GetCurrentReading( IGamepad *iface, struct GamepadReading *value ) +static HRESULT WINAPI gamepad_IGamepad_GetCurrentReading( IGamepad *iface, struct GamepadReading *value ) { - struct gamepad *impl = impl_from_IGamepad( iface ); + struct gamepad *impl = gamepad_from_IGamepad( iface ); struct WineGameControllerState state; HRESULT hr;
@@ -322,42 +219,16 @@ static HRESULT WINAPI gamepad_GetCurrentReading( IGamepad *iface, struct Gamepad return hr; }
-static const struct IGamepadVtbl gamepad_vtbl = -{ - gamepad_QueryInterface, - gamepad_AddRef, - gamepad_Release, - /* IInspectable methods */ - gamepad_GetIids, - gamepad_GetRuntimeClassName, - gamepad_GetTrustLevel, - /* IGamepad methods */ - gamepad_get_Vibration, - gamepad_put_Vibration, - gamepad_GetCurrentReading, -}; - -DEFINE_IINSPECTABLE_OUTER( gamepad2, IGamepad2, gamepad, IGameController_outer ) +INTERFACE_VTBL_IGamepad( gamepad_IGamepad );
-static HRESULT WINAPI gamepad2_GetButtonLabel( IGamepad2 *iface, GamepadButtons button, GameControllerButtonLabel *value ) +static HRESULT WINAPI gamepad_IGamepad2_GetButtonLabel( IGamepad2 *iface, GamepadButtons button, GameControllerButtonLabel *value ) { FIXME( "iface %p, button %#x, value %p stub!\n", iface, button, value ); *value = GameControllerButtonLabel_None; return S_OK; }
-static const struct IGamepad2Vtbl gamepad2_vtbl = -{ - gamepad2_QueryInterface, - gamepad2_AddRef, - gamepad2_Release, - /* IInspectable methods */ - gamepad2_GetIids, - gamepad2_GetRuntimeClassName, - gamepad2_GetTrustLevel, - /* IGamepad2 methods */ - gamepad2_GetButtonLabel, -}; +INTERFACE_VTBL_IGamepad2( gamepad_IGamepad2 );
struct gamepad_statics { @@ -366,113 +237,21 @@ struct gamepad_statics IGamepadStatics2 IGamepadStatics2_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct gamepad_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct gamepad_statics, IActivationFactory_iface ); -} +INTERFACE_IMPL_STATIC_IActivationFactory( gamepad_statics, IGamepadStatics, IGamepadStatics2, + ICustomGameControllerFactory, IAgileObject, END );
-static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct gamepad_statics *impl = impl_from_IActivationFactory( iface ); - - 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_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGamepadStatics )) - { - IInspectable_AddRef( (*out = &impl->IGamepadStatics_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGamepadStatics2 )) - { - IInspectable_AddRef( (*out = &impl->IGamepadStatics2_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_ICustomGameControllerFactory )) - { - IInspectable_AddRef( (*out = &impl->ICustomGameControllerFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) -{ - struct gamepad_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI factory_Release( IActivationFactory *iface ) -{ - struct gamepad_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI gamepad_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IActivationFactory methods */ - factory_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( statics, IGamepadStatics, gamepad_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( gamepad_statics );
-static HRESULT WINAPI statics_add_GamepadAdded( IGamepadStatics *iface, IEventHandler_Gamepad *handler, +static HRESULT WINAPI gamepad_statics_IGamepadStatics_add_GamepadAdded( IGamepadStatics *iface, IEventHandler_Gamepad *handler, EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); @@ -480,13 +259,13 @@ static HRESULT WINAPI statics_add_GamepadAdded( IGamepadStatics *iface, IEventHa return event_handlers_append( &gamepad_added_handlers, (IEventHandler_IInspectable *)handler, token ); }
-static HRESULT WINAPI statics_remove_GamepadAdded( IGamepadStatics *iface, EventRegistrationToken token ) +static HRESULT WINAPI gamepad_statics_IGamepadStatics_remove_GamepadAdded( IGamepadStatics *iface, EventRegistrationToken token ) { TRACE( "iface %p, token %#I64x.\n", iface, token.value ); return event_handlers_remove( &gamepad_added_handlers, &token ); }
-static HRESULT WINAPI statics_add_GamepadRemoved( IGamepadStatics *iface, IEventHandler_Gamepad *handler, +static HRESULT WINAPI gamepad_statics_IGamepadStatics_add_GamepadRemoved( IGamepadStatics *iface, IEventHandler_Gamepad *handler, EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); @@ -494,13 +273,13 @@ static HRESULT WINAPI statics_add_GamepadRemoved( IGamepadStatics *iface, IEvent return event_handlers_append( &gamepad_removed_handlers, (IEventHandler_IInspectable *)handler, token ); }
-static HRESULT WINAPI statics_remove_GamepadRemoved( IGamepadStatics *iface, EventRegistrationToken token ) +static HRESULT WINAPI gamepad_statics_IGamepadStatics_remove_GamepadRemoved( IGamepadStatics *iface, EventRegistrationToken token ) { TRACE( "iface %p, token %#I64x.\n", iface, token.value ); return event_handlers_remove( &gamepad_removed_handlers, &token ); }
-static HRESULT WINAPI statics_get_Gamepads( IGamepadStatics *iface, IVectorView_Gamepad **value ) +static HRESULT WINAPI gamepad_statics_IGamepadStatics_get_Gamepads( IGamepadStatics *iface, IVectorView_Gamepad **value ) { HRESULT hr;
@@ -514,28 +293,11 @@ static HRESULT WINAPI statics_get_Gamepads( IGamepadStatics *iface, IVectorView_ return hr; }
-static const struct IGamepadStaticsVtbl statics_vtbl = -{ - statics_QueryInterface, - statics_AddRef, - statics_Release, - /* IInspectable methods */ - statics_GetIids, - statics_GetRuntimeClassName, - statics_GetTrustLevel, - /* IGamepadStatics methods */ - statics_add_GamepadAdded, - statics_remove_GamepadAdded, - statics_add_GamepadRemoved, - statics_remove_GamepadRemoved, - statics_get_Gamepads, -}; - -DEFINE_IINSPECTABLE( statics2, IGamepadStatics2, gamepad_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IGamepadStatics( gamepad_statics_IGamepadStatics );
-static HRESULT WINAPI statics2_FromGameController( IGamepadStatics2 *iface, IGameController *game_controller, IGamepad **value ) +static HRESULT WINAPI gamepad_statics_IGamepadStatics2_FromGameController( IGamepadStatics2 *iface, IGameController *game_controller, IGamepad **value ) { - struct gamepad_statics *impl = impl_from_IGamepadStatics2( iface ); + struct gamepad_statics *impl = gamepad_statics_from_IGamepadStatics2( iface ); IGameController *controller; HRESULT hr;
@@ -551,22 +313,9 @@ static HRESULT WINAPI statics2_FromGameController( IGamepadStatics2 *iface, IGam return hr; }
-static const struct IGamepadStatics2Vtbl statics2_vtbl = -{ - statics2_QueryInterface, - statics2_AddRef, - statics2_Release, - /* IInspectable methods */ - statics2_GetIids, - statics2_GetRuntimeClassName, - statics2_GetTrustLevel, - /* IGamepadStatics2 methods */ - statics2_FromGameController, -}; - -DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, gamepad_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IGamepadStatics2( gamepad_statics_IGamepadStatics2 );
-static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, +static HRESULT WINAPI gamepad_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) { struct gamepad *impl; @@ -574,11 +323,12 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro TRACE( "iface %p, provider %p, value %p.\n", iface, provider, value );
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; - impl->IGameControllerImpl_iface.lpVtbl = &controller_vtbl; - impl->IGameControllerInputSink_iface.lpVtbl = &input_sink_vtbl; - impl->IGamepad_iface.lpVtbl = &gamepad_vtbl; - impl->IGamepad2_iface.lpVtbl = &gamepad2_vtbl; - impl->ref = 1; + impl->IGameControllerImpl_iface.lpVtbl = &gamepad_vtbl; + impl->IGameControllerInputSink_iface.lpVtbl = &gamepad_IGameControllerInputSink_vtbl; + impl->IGamepad_iface.lpVtbl = &gamepad_IGamepad_vtbl; + impl->IGamepad2_iface.lpVtbl = &gamepad_IGamepad2_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_Gamepad; + impl->refcount = 1;
TRACE( "created Gamepad %p\n", impl );
@@ -586,7 +336,7 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro return S_OK; }
-static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value ) +static HRESULT WINAPI gamepad_statics_ICustomGameControllerFactory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value ) { IGamepad *gamepad; HRESULT hr; @@ -601,7 +351,7 @@ static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameContr return S_OK; }
-static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value ) +static HRESULT WINAPI gamepad_statics_ICustomGameControllerFactory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value ) { IGamepad *gamepad; BOOLEAN found; @@ -635,31 +385,17 @@ static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameCon return S_OK; }
-static const struct ICustomGameControllerFactoryVtbl controller_factory_vtbl = -{ - controller_factory_QueryInterface, - controller_factory_AddRef, - controller_factory_Release, - /* IInspectable methods */ - controller_factory_GetIids, - controller_factory_GetRuntimeClassName, - controller_factory_GetTrustLevel, - /* ICustomGameControllerFactory methods */ - controller_factory_CreateGameController, - controller_factory_OnGameControllerAdded, - controller_factory_OnGameControllerRemoved, -}; - -DEFINE_IAGILEOBJECT( gamepad_statics, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_ICustomGameControllerFactory( gamepad_statics_ICustomGameControllerFactory ); +INTERFACE_VTBL_IAgileObject( gamepad_statics_IAgileObject );
static struct gamepad_statics gamepad_statics = { - {&factory_vtbl}, - {&statics_vtbl}, - {&statics2_vtbl}, - {&controller_factory_vtbl}, + {&gamepad_statics_vtbl}, + {&gamepad_statics_IGamepadStatics_vtbl}, + {&gamepad_statics_IGamepadStatics2_vtbl}, + {&gamepad_statics_ICustomGameControllerFactory_vtbl}, {&gamepad_statics_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_Gamepad, };
ICustomGameControllerFactory *gamepad_factory = &gamepad_statics.ICustomGameControllerFactory_iface; diff --git a/dlls/windows.gaming.input/manager.c b/dlls/windows.gaming.input/manager.c index 3c6334bc0eb..1a3640a2b0f 100644 --- a/dlls/windows.gaming.input/manager.c +++ b/dlls/windows.gaming.input/manager.c @@ -41,75 +41,38 @@ struct controller IGameControllerBatteryInfo IGameControllerBatteryInfo_iface; IAgileObject IAgileObject_iface; IInspectable *IInspectable_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount;
struct list entry; IGameControllerProvider *provider; ICustomGameControllerFactory *factory; };
-static inline struct controller *impl_from_IGameController( IGameController *iface ) -{ - return CONTAINING_RECORD( iface, struct controller, IGameController_iface ); -} +INTERFACE_IMPL_FROM( controller, IGameController );
static HRESULT WINAPI controller_QueryInterface( IGameController *iface, REFIID iid, void **out ) { - struct controller *impl = impl_from_IGameController( iface ); - + struct controller *impl = controller_from_IGameController( iface ); 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_IGameController )) - { - IInspectable_AddRef( (*out = &impl->IGameController_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerBatteryInfo )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerBatteryInfo_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IGameController( impl, iid, out, IGameController_iface ) + QUERY_INTERFACE_IGameControllerBatteryInfo( impl, iid, out, IGameControllerBatteryInfo_iface ) + QUERY_INTERFACE_IAgileObject( impl, iid, out, IAgileObject_iface ) return IInspectable_QueryInterface( impl->IInspectable_inner, iid, out ); }
-static ULONG WINAPI controller_AddRef( IGameController *iface ) -{ - struct controller *impl = impl_from_IGameController( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( controller, IGameController );
-static ULONG WINAPI controller_Release( IGameController *iface ) +static void controller_destroy( struct controller *impl ) { - struct controller *impl = impl_from_IGameController( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IInspectable_Release( impl->IInspectable_inner ); - ICustomGameControllerFactory_Release( impl->factory ); - IGameControllerProvider_Release( impl->provider ); - free( impl ); - } - - return ref; + IInspectable_Release( impl->IInspectable_inner ); + ICustomGameControllerFactory_Release( impl->factory ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
+IUNKNOWN_IMPL_RELEASE( controller, IGameController ); + static HRESULT WINAPI controller_GetIids( IGameController *iface, ULONG *iid_count, IID **iids ) { FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); @@ -118,13 +81,13 @@ static HRESULT WINAPI controller_GetIids( IGameController *iface, ULONG *iid_cou
static HRESULT WINAPI controller_GetRuntimeClassName( IGameController *iface, HSTRING *class_name ) { - struct controller *impl = impl_from_IGameController( iface ); + struct controller *impl = controller_from_IGameController( iface ); return IInspectable_GetRuntimeClassName( impl->IInspectable_inner, class_name ); }
static HRESULT WINAPI controller_GetTrustLevel( IGameController *iface, TrustLevel *trust_level ) { - struct controller *impl = impl_from_IGameController( iface ); + struct controller *impl = controller_from_IGameController( iface ); return IInspectable_GetTrustLevel( impl->IInspectable_inner, trust_level ); }
@@ -186,49 +149,20 @@ static HRESULT WINAPI controller_get_User( IGameController *iface, __x_ABI_CWind return E_NOTIMPL; }
-static const struct IGameControllerVtbl controller_vtbl = -{ - controller_QueryInterface, - controller_AddRef, - controller_Release, - /* IInspectable methods */ - controller_GetIids, - controller_GetRuntimeClassName, - controller_GetTrustLevel, - /* IGameController methods */ - controller_add_HeadsetConnected, - controller_remove_HeadsetConnected, - controller_add_HeadsetDisconnected, - controller_remove_HeadsetDisconnected, - controller_add_UserChanged, - controller_remove_UserChanged, - controller_get_Headset, - controller_get_IsWireless, - controller_get_User, -}; +INTERFACE_VTBL_IGameController( controller );
-DEFINE_IINSPECTABLE( battery, IGameControllerBatteryInfo, controller, IGameController_iface ) +INTERFACE_FWD_IGameControllerBatteryInfo( controller, IGameController, &object->IGameController_iface );
-static HRESULT WINAPI battery_TryGetBatteryReport( IGameControllerBatteryInfo *iface, IBatteryReport **value ) +static HRESULT WINAPI controller_IGameControllerBatteryInfo_TryGetBatteryReport( IGameControllerBatteryInfo *iface, IBatteryReport **value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static const struct IGameControllerBatteryInfoVtbl battery_vtbl = -{ - battery_QueryInterface, - battery_AddRef, - battery_Release, - /* IInspectable methods */ - battery_GetIids, - battery_GetRuntimeClassName, - battery_GetTrustLevel, - /* IGameControllerBatteryInfo methods */ - battery_TryGetBatteryReport, -}; +INTERFACE_VTBL_IGameControllerBatteryInfo( controller_IGameControllerBatteryInfo );
-DEFINE_IAGILEOBJECT( controller, IGameController, &object->IGameController_iface ); +INTERFACE_FWD_IAgileObject( controller, IGameController, &object->IGameController_iface ); +INTERFACE_VTBL_IAgileObject( controller_IAgileObject );
struct manager_statics { @@ -236,108 +170,22 @@ struct manager_statics IGameControllerFactoryManagerStatics IGameControllerFactoryManagerStatics_iface; IGameControllerFactoryManagerStatics2 IGameControllerFactoryManagerStatics2_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct manager_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct manager_statics, IActivationFactory_iface ); -} - -static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct manager_statics *impl = impl_from_IActivationFactory( iface ); - - 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_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerFactoryManagerStatics )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerFactoryManagerStatics_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerFactoryManagerStatics2 )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerFactoryManagerStatics2_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } +INTERFACE_IMPL_STATIC_IActivationFactory( manager_statics, IGameControllerFactoryManagerStatics, + IGameControllerFactoryManagerStatics2, IAgileObject, END )
- FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) -{ - struct manager_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI factory_Release( IActivationFactory *iface ) -{ - struct manager_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI manager_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IActivationFactory methods */ - factory_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( statics, IGameControllerFactoryManagerStatics, manager_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( manager_statics );
static HRESULT WINAPI -statics_RegisterCustomFactoryForGipInterface( IGameControllerFactoryManagerStatics *iface, +manager_statics_IGameControllerFactoryManagerStatics_RegisterCustomFactoryForGipInterface( IGameControllerFactoryManagerStatics *iface, ICustomGameControllerFactory *factory, GUID interface_id ) { @@ -346,7 +194,7 @@ statics_RegisterCustomFactoryForGipInterface( IGameControllerFactoryManagerStati }
static HRESULT WINAPI -statics_RegisterCustomFactoryForHardwareId( IGameControllerFactoryManagerStatics *iface, +manager_statics_IGameControllerFactoryManagerStatics_RegisterCustomFactoryForHardwareId( IGameControllerFactoryManagerStatics *iface, ICustomGameControllerFactory *factory, UINT16 vendor_id, UINT16 product_id ) { @@ -355,7 +203,7 @@ statics_RegisterCustomFactoryForHardwareId( IGameControllerFactoryManagerStatics }
static HRESULT WINAPI -statics_RegisterCustomFactoryForXusbType( IGameControllerFactoryManagerStatics *iface, +manager_statics_IGameControllerFactoryManagerStatics_RegisterCustomFactoryForXusbType( IGameControllerFactoryManagerStatics *iface, ICustomGameControllerFactory *factory, XusbDeviceType type, XusbDeviceSubtype subtype ) { @@ -363,25 +211,10 @@ statics_RegisterCustomFactoryForXusbType( IGameControllerFactoryManagerStatics * return E_NOTIMPL; }
-static const struct IGameControllerFactoryManagerStaticsVtbl statics_vtbl = -{ - statics_QueryInterface, - statics_AddRef, - statics_Release, - /* IInspectable methods */ - statics_GetIids, - statics_GetRuntimeClassName, - statics_GetTrustLevel, - /* IGameControllerFactoryManagerStatics methods */ - statics_RegisterCustomFactoryForGipInterface, - statics_RegisterCustomFactoryForHardwareId, - statics_RegisterCustomFactoryForXusbType, -}; - -DEFINE_IINSPECTABLE( statics2, IGameControllerFactoryManagerStatics2, manager_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IGameControllerFactoryManagerStatics( manager_statics_IGameControllerFactoryManagerStatics );
static HRESULT WINAPI -statics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManagerStatics2 *iface, +manager_statics_IGameControllerFactoryManagerStatics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManagerStatics2 *iface, ICustomGameControllerFactory *factory, IGameController *controller, IGameController **value ) { @@ -417,28 +250,16 @@ done: return S_OK; }
-static const struct IGameControllerFactoryManagerStatics2Vtbl statics2_vtbl = -{ - statics2_QueryInterface, - statics2_AddRef, - statics2_Release, - /* IInspectable methods */ - statics2_GetIids, - statics2_GetRuntimeClassName, - statics2_GetTrustLevel, - /* IGameControllerFactoryManagerStatics2 methods */ - statics2_TryGetFactoryControllerFromGameController, -}; - -DEFINE_IAGILEOBJECT( manager_statics, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IGameControllerFactoryManagerStatics2( manager_statics_IGameControllerFactoryManagerStatics2 ); +INTERFACE_VTBL_IAgileObject( manager_statics_IAgileObject );
static struct manager_statics manager_statics = { - {&factory_vtbl}, - {&statics_vtbl}, - {&statics2_vtbl}, + {&manager_statics_vtbl}, + {&manager_statics_IGameControllerFactoryManagerStatics_vtbl}, + {&manager_statics_IGameControllerFactoryManagerStatics2_vtbl}, {&manager_statics_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_Custom_GameControllerFactoryManager, };
IGameControllerFactoryManagerStatics2 *manager_factory = &manager_statics.IGameControllerFactoryManagerStatics2_iface; @@ -452,9 +273,9 @@ static HRESULT controller_create( ICustomGameControllerFactory *factory, IGameCo
if (!(impl = malloc(sizeof(*impl)))) return E_OUTOFMEMORY; impl->IGameController_iface.lpVtbl = &controller_vtbl; - impl->IGameControllerBatteryInfo_iface.lpVtbl = &battery_vtbl; + impl->IGameControllerBatteryInfo_iface.lpVtbl = &controller_IGameControllerBatteryInfo_vtbl; impl->IAgileObject_iface.lpVtbl = &controller_IAgileObject_vtbl; - impl->ref = 1; + impl->refcount = 1;
if (FAILED(hr = ICustomGameControllerFactory_CreateGameController( factory, provider, &impl->IInspectable_inner ))) WARN( "Failed to create game controller, hr %#lx\n", hr ); diff --git a/dlls/windows.gaming.input/periodic_effect.c b/dlls/windows.gaming.input/periodic_effect.c index 335c9f903fc..c3a07e090a6 100644 --- a/dlls/windows.gaming.input/periodic_effect.c +++ b/dlls/windows.gaming.input/periodic_effect.c @@ -26,90 +26,45 @@ struct periodic_effect { IPeriodicForceEffect IPeriodicForceEffect_iface; IWineForceFeedbackEffectImpl *IWineForceFeedbackEffectImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount;
PeriodicForceEffectKind kind; };
-static inline struct periodic_effect *impl_from_IPeriodicForceEffect( IPeriodicForceEffect *iface ) -{ - return CONTAINING_RECORD( iface, struct periodic_effect, IPeriodicForceEffect_iface ); -} +INTERFACE_IMPL_FROM( periodic_effect, IPeriodicForceEffect );
-static HRESULT WINAPI effect_QueryInterface( IPeriodicForceEffect *iface, REFIID iid, void **out ) +static HRESULT WINAPI periodic_effect_QueryInterface( IPeriodicForceEffect *iface, REFIID iid, void **out ) { - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); - + struct periodic_effect *impl = periodic_effect_from_IPeriodicForceEffect( iface ); 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_IPeriodicForceEffect )) - { - IInspectable_AddRef( (*out = &impl->IPeriodicForceEffect_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IPeriodicForceEffect( impl, iid, out, IPeriodicForceEffect_iface ) return IWineForceFeedbackEffectImpl_QueryInterface( impl->IWineForceFeedbackEffectImpl_inner, iid, out ); }
-static ULONG WINAPI effect_AddRef( IPeriodicForceEffect *iface ) -{ - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI effect_Release( IPeriodicForceEffect *iface ) -{ - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI effect_GetIids( IPeriodicForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( periodic_effect, IPeriodicForceEffect );
-static HRESULT WINAPI effect_GetRuntimeClassName( IPeriodicForceEffect *iface, HSTRING *class_name ) +static void periodic_effect_destroy( struct periodic_effect *impl ) { - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect), - class_name ); + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetTrustLevel( IPeriodicForceEffect *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( periodic_effect, IPeriodicForceEffect ); +IINSPECTABLE_IMPL( periodic_effect, IPeriodicForceEffect );
-static HRESULT WINAPI effect_get_Kind( IPeriodicForceEffect *iface, PeriodicForceEffectKind *kind ) +static HRESULT WINAPI periodic_effect_get_Kind( IPeriodicForceEffect *iface, PeriodicForceEffectKind *kind ) { - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); + struct periodic_effect *impl = periodic_effect_from_IPeriodicForceEffect( iface ); TRACE( "iface %p, kind %p.\n", iface, kind ); *kind = impl->kind; return S_OK; }
-static HRESULT WINAPI effect_SetParameters( IPeriodicForceEffect *iface, Vector3 direction, FLOAT frequency, FLOAT phase, +static HRESULT WINAPI periodic_effect_SetParameters( IPeriodicForceEffect *iface, Vector3 direction, FLOAT frequency, FLOAT phase, FLOAT bias, TimeSpan duration ) { - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); + struct periodic_effect *impl = periodic_effect_from_IPeriodicForceEffect( iface ); WineForceFeedbackEffectParameters params = { .periodic = @@ -131,12 +86,12 @@ static HRESULT WINAPI effect_SetParameters( IPeriodicForceEffect *iface, Vector3 return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, NULL ); }
-static HRESULT WINAPI effect_SetParametersWithEnvelope( IPeriodicForceEffect *iface, Vector3 direction, FLOAT frequency, FLOAT phase, FLOAT bias, +static HRESULT WINAPI periodic_effect_SetParametersWithEnvelope( IPeriodicForceEffect *iface, Vector3 direction, FLOAT frequency, FLOAT phase, FLOAT bias, FLOAT attack_gain, FLOAT sustain_gain, FLOAT release_gain, TimeSpan start_delay, TimeSpan attack_duration, TimeSpan sustain_duration, TimeSpan release_duration, UINT32 repeat_count ) { - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); + struct periodic_effect *impl = periodic_effect_from_IPeriodicForceEffect( iface ); WineForceFeedbackEffectParameters params = { .periodic = @@ -168,121 +123,27 @@ static HRESULT WINAPI effect_SetParametersWithEnvelope( IPeriodicForceEffect *if return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, &envelope ); }
-static const struct IPeriodicForceEffectVtbl effect_vtbl = -{ - effect_QueryInterface, - effect_AddRef, - effect_Release, - /* IInspectable methods */ - effect_GetIids, - effect_GetRuntimeClassName, - effect_GetTrustLevel, - /* IPeriodicForceEffect methods */ - effect_get_Kind, - effect_SetParameters, - effect_SetParametersWithEnvelope, -}; +INTERFACE_VTBL_IPeriodicForceEffect( periodic_effect );
struct periodic_factory { IActivationFactory IActivationFactory_iface; IPeriodicForceEffectFactory IPeriodicForceEffectFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct periodic_factory *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct periodic_factory, IActivationFactory_iface ); -} - -static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct periodic_factory *impl = impl_from_IActivationFactory( iface ); - - 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_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IPeriodicForceEffectFactory )) - { - IInspectable_AddRef( (*out = &impl->IPeriodicForceEffectFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI activation_AddRef( IActivationFactory *iface ) -{ - struct periodic_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI activation_Release( IActivationFactory *iface ) -{ - struct periodic_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI activation_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +INTERFACE_IMPL_STATIC_IActivationFactory( periodic_factory, IPeriodicForceEffectFactory, IAgileObject, END )
-static HRESULT WINAPI activation_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI periodic_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl activation_vtbl = -{ - activation_QueryInterface, - activation_AddRef, - activation_Release, - /* IInspectable methods */ - activation_GetIids, - activation_GetRuntimeClassName, - activation_GetTrustLevel, - /* IActivationFactory methods */ - activation_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( factory, IPeriodicForceEffectFactory, periodic_factory, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( periodic_factory );
-static HRESULT WINAPI factory_CreateInstance( IPeriodicForceEffectFactory *iface, enum PeriodicForceEffectKind kind, IForceFeedbackEffect **out ) +static HRESULT WINAPI periodic_factory_IPeriodicForceEffectFactory_CreateInstance( IPeriodicForceEffectFactory *iface, enum PeriodicForceEffectKind kind, IForceFeedbackEffect **out ) { enum WineForceFeedbackEffectType type = WineForceFeedbackEffectType_Periodic + kind; struct periodic_effect *impl; @@ -291,8 +152,9 @@ static HRESULT WINAPI factory_CreateInstance( IPeriodicForceEffectFactory *iface TRACE( "iface %p, kind %u, out %p.\n", iface, kind, out );
if (!(impl = calloc( 1, sizeof(struct periodic_effect) ))) return E_OUTOFMEMORY; - impl->IPeriodicForceEffect_iface.lpVtbl = &effect_vtbl; - impl->ref = 1; + impl->IPeriodicForceEffect_iface.lpVtbl = &periodic_effect_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect; + impl->refcount = 1; impl->kind = kind;
if (FAILED(hr = force_feedback_effect_create( type, (IInspectable *)&impl->IPeriodicForceEffect_iface, &impl->IWineForceFeedbackEffectImpl_inner )) || @@ -308,27 +170,15 @@ static HRESULT WINAPI factory_CreateInstance( IPeriodicForceEffectFactory *iface return S_OK; }
-static const struct IPeriodicForceEffectFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IPeriodicForceEffectFactory methods */ - factory_CreateInstance, -}; - -DEFINE_IAGILEOBJECT( periodic_factory, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IPeriodicForceEffectFactory( periodic_factory_IPeriodicForceEffectFactory ); +INTERFACE_VTBL_IAgileObject( periodic_factory_IAgileObject );
static struct periodic_factory periodic_statics = { - {&activation_vtbl}, - {&factory_vtbl}, + {&periodic_factory_vtbl}, + {&periodic_factory_IPeriodicForceEffectFactory_vtbl}, {&periodic_factory_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect, };
IInspectable *periodic_effect_factory = (IInspectable *)&periodic_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index 07650e52fad..90907553aeb 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -83,20 +83,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 ) \ - 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 ) { if (!vector) return "(null)"; diff --git a/dlls/windows.gaming.input/provider.c b/dlls/windows.gaming.input/provider.c index 33f9471fae1..a7e49918513 100644 --- a/dlls/windows.gaming.input/provider.c +++ b/dlls/windows.gaming.input/provider.c @@ -47,7 +47,8 @@ struct provider IWineGameControllerProvider IWineGameControllerProvider_iface; IGameControllerProvider IGameControllerProvider_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; + LONG refcount;
IDirectInputDevice8W *dinput_device; WCHAR device_path[MAX_PATH]; @@ -66,86 +67,16 @@ struct provider HANDLE device; };
-static inline struct provider *impl_from_IWineGameControllerProvider( IWineGameControllerProvider *iface ) +static void provider_destroy( struct provider *impl ) { - return CONTAINING_RECORD( iface, struct provider, IWineGameControllerProvider_iface ); + IDirectInputDevice8_Release( impl->dinput_device ); + HidD_FreePreparsedData( impl->preparsed ); + CloseHandle( impl->device ); + free( impl->report_buf ); + free( impl ); }
-static HRESULT WINAPI wine_provider_QueryInterface( IWineGameControllerProvider *iface, REFIID iid, void **out ) -{ - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); - - 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_IWineGameControllerProvider )) - { - IInspectable_AddRef( (*out = &impl->IWineGameControllerProvider_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerProvider )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerProvider_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI wine_provider_AddRef( IWineGameControllerProvider *iface ) -{ - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI wine_provider_Release( IWineGameControllerProvider *iface ) -{ - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - IDirectInputDevice8_Release( impl->dinput_device ); - HidD_FreePreparsedData( impl->preparsed ); - CloseHandle( impl->device ); - free( impl->report_buf ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI wine_provider_GetIids( IWineGameControllerProvider *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI wine_provider_GetRuntimeClassName( IWineGameControllerProvider *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI wine_provider_GetTrustLevel( IWineGameControllerProvider *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +INTERFACE_IMPL_IWineGameControllerProvider( provider, IGameControllerProvider, IAgileObject, END );
static BOOL CALLBACK count_ffb_axes( const DIDEVICEOBJECTINSTANCEW *obj, void *args ) { @@ -154,9 +85,9 @@ static BOOL CALLBACK count_ffb_axes( const DIDEVICEOBJECTINSTANCEW *obj, void *a return DIENUM_CONTINUE; }
-static HRESULT WINAPI wine_provider_get_Type( IWineGameControllerProvider *iface, WineGameControllerType *value ) +static HRESULT WINAPI provider_get_Type( IWineGameControllerProvider *iface, WineGameControllerType *value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIDEVICEINSTANCEW instance = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; HRESULT hr;
@@ -181,9 +112,9 @@ static HRESULT WINAPI wine_provider_get_Type( IWineGameControllerProvider *iface return S_OK; }
-static HRESULT WINAPI wine_provider_get_AxisCount( IWineGameControllerProvider *iface, INT32 *value ) +static HRESULT WINAPI provider_get_AxisCount( IWineGameControllerProvider *iface, INT32 *value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; HRESULT hr;
@@ -194,9 +125,9 @@ static HRESULT WINAPI wine_provider_get_AxisCount( IWineGameControllerProvider * return hr; }
-static HRESULT WINAPI wine_provider_get_ButtonCount( IWineGameControllerProvider *iface, INT32 *value ) +static HRESULT WINAPI provider_get_ButtonCount( IWineGameControllerProvider *iface, INT32 *value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; HRESULT hr;
@@ -207,9 +138,9 @@ static HRESULT WINAPI wine_provider_get_ButtonCount( IWineGameControllerProvider return hr; }
-static HRESULT WINAPI wine_provider_get_SwitchCount( IWineGameControllerProvider *iface, INT32 *value ) +static HRESULT WINAPI provider_get_SwitchCount( IWineGameControllerProvider *iface, INT32 *value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; HRESULT hr;
@@ -220,9 +151,9 @@ static HRESULT WINAPI wine_provider_get_SwitchCount( IWineGameControllerProvider return hr; }
-static HRESULT WINAPI wine_provider_get_State( IWineGameControllerProvider *iface, struct WineGameControllerState *out ) +static HRESULT WINAPI provider_get_State( IWineGameControllerProvider *iface, struct WineGameControllerState *out ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIJOYSTATE2 state = {0}; UINT32 i = 0; HRESULT hr; @@ -283,17 +214,17 @@ static HRESULT WINAPI wine_provider_get_State( IWineGameControllerProvider *ifac return S_OK; }
-static HRESULT WINAPI wine_provider_get_Vibration( IWineGameControllerProvider *iface, struct WineGameControllerVibration *out ) +static HRESULT WINAPI provider_get_Vibration( IWineGameControllerProvider *iface, struct WineGameControllerVibration *out ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); TRACE( "iface %p, out %p.\n", iface, out ); *out = impl->vibration; return S_OK; }
-static HRESULT WINAPI wine_provider_put_Vibration( IWineGameControllerProvider *iface, struct WineGameControllerVibration value ) +static HRESULT WINAPI provider_put_Vibration( IWineGameControllerProvider *iface, struct WineGameControllerVibration value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); ULONG report_len = impl->caps.OutputReportByteLength; PHIDP_PREPARSED_DATA preparsed = impl->preparsed; char *report_buf = impl->report_buf; @@ -335,9 +266,9 @@ static HRESULT WINAPI wine_provider_put_Vibration( IWineGameControllerProvider * return S_OK; }
-static HRESULT WINAPI wine_provider_get_ForceFeedbackMotor( IWineGameControllerProvider *iface, IForceFeedbackMotor **value ) +static HRESULT WINAPI provider_get_ForceFeedbackMotor( IWineGameControllerProvider *iface, IForceFeedbackMotor **value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; HRESULT hr;
@@ -350,38 +281,18 @@ static HRESULT WINAPI wine_provider_get_ForceFeedbackMotor( IWineGameControllerP return S_OK; }
-static const struct IWineGameControllerProviderVtbl wine_provider_vtbl = -{ - wine_provider_QueryInterface, - wine_provider_AddRef, - wine_provider_Release, - /* IInspectable methods */ - wine_provider_GetIids, - wine_provider_GetRuntimeClassName, - wine_provider_GetTrustLevel, - /* IWineGameControllerProvider methods */ - wine_provider_get_Type, - wine_provider_get_AxisCount, - wine_provider_get_ButtonCount, - wine_provider_get_SwitchCount, - wine_provider_get_State, - wine_provider_get_Vibration, - wine_provider_put_Vibration, - wine_provider_get_ForceFeedbackMotor, -}; - -DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, provider, IWineGameControllerProvider_iface ) +INTERFACE_VTBL_IWineGameControllerProvider( provider );
-static HRESULT WINAPI game_provider_get_FirmwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_FirmwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI game_provider_get_HardwareProductId( IGameControllerProvider *iface, UINT16 *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_HardwareProductId( IGameControllerProvider *iface, UINT16 *value ) { DIPROPDWORD vid_pid = {.diph = {.dwHeaderSize = sizeof(DIPROPHEADER), .dwSize = sizeof(DIPROPDWORD)}}; - struct provider *impl = impl_from_IGameControllerProvider( iface ); + struct provider *impl = provider_from_IGameControllerProvider( iface ); HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value ); @@ -391,10 +302,10 @@ static HRESULT WINAPI game_provider_get_HardwareProductId( IGameControllerProvid return hr; }
-static HRESULT WINAPI game_provider_get_HardwareVendorId( IGameControllerProvider *iface, UINT16 *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_HardwareVendorId( IGameControllerProvider *iface, UINT16 *value ) { DIPROPDWORD vid_pid = {.diph = {.dwHeaderSize = sizeof(DIPROPHEADER), .dwSize = sizeof(DIPROPDWORD)}}; - struct provider *impl = impl_from_IGameControllerProvider( iface ); + struct provider *impl = provider_from_IGameControllerProvider( iface ); HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value ); @@ -404,36 +315,20 @@ static HRESULT WINAPI game_provider_get_HardwareVendorId( IGameControllerProvide return hr; }
-static HRESULT WINAPI game_provider_get_HardwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_HardwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI game_provider_get_IsConnected( IGameControllerProvider *iface, boolean *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_IsConnected( IGameControllerProvider *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static const struct IGameControllerProviderVtbl game_provider_vtbl = -{ - game_provider_QueryInterface, - game_provider_AddRef, - game_provider_Release, - /* IInspectable methods */ - game_provider_GetIids, - game_provider_GetRuntimeClassName, - game_provider_GetTrustLevel, - /* IGameControllerProvider methods */ - game_provider_get_FirmwareVersionInfo, - game_provider_get_HardwareProductId, - game_provider_get_HardwareVendorId, - game_provider_get_HardwareVersionInfo, - game_provider_get_IsConnected, -}; - -DEFINE_IAGILEOBJECT( provider, IWineGameControllerProvider, &object->IWineGameControllerProvider_iface ); +INTERFACE_VTBL_IGameControllerProvider( provider_IGameControllerProvider ); +INTERFACE_VTBL_IAgileObject( provider_IAgileObject );
static void check_haptics_caps( struct provider *provider, HANDLE device, PHIDP_PREPARSED_DATA preparsed, HIDP_LINK_COLLECTION_NODE *collections, HIDP_VALUE_CAPS *caps ) @@ -579,12 +474,12 @@ void provider_create( const WCHAR *device_path ) if (FAILED(hr = IDirectInputDevice8_Acquire( dinput_device ))) goto done;
if (!(impl = calloc( 1, sizeof(*impl) ))) goto done; - impl->IWineGameControllerProvider_iface.lpVtbl = &wine_provider_vtbl; - impl->IGameControllerProvider_iface.lpVtbl = &game_provider_vtbl; + impl->IWineGameControllerProvider_iface.lpVtbl = &provider_vtbl; + impl->IGameControllerProvider_iface.lpVtbl = &provider_IGameControllerProvider_vtbl; impl->IAgileObject_iface.lpVtbl = &provider_IAgileObject_vtbl; IDirectInputDevice_AddRef( dinput_device ); impl->dinput_device = dinput_device; - impl->ref = 1; + impl->refcount = 1;
wcscpy( impl->device_path, device_path ); list_init( &impl->entry ); diff --git a/dlls/windows.gaming.input/provider.idl b/dlls/windows.gaming.input/provider.idl index e7b6e96b8aa..072c381461e 100644 --- a/dlls/windows.gaming.input/provider.idl +++ b/dlls/windows.gaming.input/provider.idl @@ -188,7 +188,7 @@ namespace Windows.Gaming.Input.Custom { [ uuid(27833469-7760-417e-adbe-e011a66e16ee) ] - interface IWineForceFeedbackEffectImpl : IUnknown + interface IWineForceFeedbackEffectImpl : IInspectable requires Windows.Gaming.Input.ForceFeedback.IForceFeedbackEffect { [propput] HRESULT Parameters([in] WineForceFeedbackEffectParameters parameters, @@ -198,7 +198,7 @@ namespace Windows.Gaming.Input.Custom { [ uuid(83f377ee-c799-11ec-9d64-0242ac120002) ] - interface IWineAsyncInfoImpl : IUnknown + interface IWineAsyncInfoImpl : IInspectable { [propput] HRESULT Completed([in] WineAsyncOperationCompletedHandler *handler); [propget] HRESULT Completed([out, retval] WineAsyncOperationCompletedHandler **handler); diff --git a/dlls/windows.gaming.input/racing_wheel.c b/dlls/windows.gaming.input/racing_wheel.c index c7004d935af..e6045be9665 100644 --- a/dlls/windows.gaming.input/racing_wheel.c +++ b/dlls/windows.gaming.input/racing_wheel.c @@ -61,101 +61,32 @@ struct racing_wheel IGameControllerImpl IGameControllerImpl_iface; IGameControllerInputSink IGameControllerInputSink_iface; IRacingWheel IRacingWheel_iface; - IGameController *IGameController_outer; - LONG ref; + IInspectable *outer; + const WCHAR *class_name; + LONG refcount;
IGameControllerProvider *provider; IWineGameControllerProvider *wine_provider; };
-static inline struct racing_wheel *impl_from_IGameControllerImpl( IGameControllerImpl *iface ) +static void racing_wheel_destroy( struct racing_wheel *impl ) { - return CONTAINING_RECORD( iface, struct racing_wheel, IGameControllerImpl_iface ); + if (impl->wine_provider) IWineGameControllerProvider_Release( impl->wine_provider ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
-static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REFIID iid, void **out ) -{ - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); - - 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_IGameControllerImpl )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerInputSink )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerInputSink_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IRacingWheel )) - { - IInspectable_AddRef( (*out = &impl->IRacingWheel_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface ) -{ - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI controller_Release( IGameControllerImpl *iface ) -{ - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - if (impl->wine_provider) IWineGameControllerProvider_Release( impl->wine_provider ); - IGameControllerProvider_Release( impl->provider ); - free( impl ); - } - - return ref; -} +INTERFACE_IMPL_OUTER_IGameControllerImpl( racing_wheel, IGameControllerInputSink, IRacingWheel, END );
-static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_GetRuntimeClassName( IGameControllerImpl *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_RacingWheel, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_RacingWheel), class_name ); -} - -static HRESULT WINAPI controller_GetTrustLevel( IGameControllerImpl *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, +static HRESULT WINAPI racing_wheel_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) { - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); + struct racing_wheel *impl = racing_wheel_from_IGameControllerImpl( iface ); HRESULT hr;
TRACE( "iface %p, outer %p, provider %p.\n", iface, outer, provider );
- impl->IGameController_outer = outer; + impl->outer = (IInspectable *)outer; IGameControllerProvider_AddRef( (impl->provider = provider) );
hr = IGameControllerProvider_QueryInterface( provider, &IID_IWineGameControllerProvider, @@ -170,120 +101,75 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo return hr; }
-static const struct IGameControllerImplVtbl controller_vtbl = -{ - controller_QueryInterface, - controller_AddRef, - controller_Release, - /* IInspectable methods */ - controller_GetIids, - controller_GetRuntimeClassName, - controller_GetTrustLevel, - /* IGameControllerImpl methods */ - controller_Initialize, -}; - -DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, racing_wheel, IGameController_outer ) +INTERFACE_VTBL_IGameControllerImpl( racing_wheel );
-static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI racing_wheel_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static HRESULT WINAPI input_sink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI racing_wheel_IGameControllerInputSink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static const struct IGameControllerInputSinkVtbl input_sink_vtbl = -{ - input_sink_QueryInterface, - input_sink_AddRef, - input_sink_Release, - /* IInspectable methods */ - input_sink_GetIids, - input_sink_GetRuntimeClassName, - input_sink_GetTrustLevel, - /* IGameControllerInputSink methods */ - input_sink_OnInputResumed, - input_sink_OnInputSuspended, -}; - -DEFINE_IINSPECTABLE_OUTER( racing_wheel, IRacingWheel, racing_wheel, IGameController_outer ) +INTERFACE_VTBL_IGameControllerInputSink( racing_wheel_IGameControllerInputSink );
-static HRESULT WINAPI racing_wheel_get_HasClutch( IRacingWheel *iface, boolean *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_HasClutch( IRacingWheel *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_HasHandbrake( IRacingWheel *iface, boolean *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_HasHandbrake( IRacingWheel *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_HasPatternShifter( IRacingWheel *iface, boolean *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_HasPatternShifter( IRacingWheel *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_MaxPatternShifterGear( IRacingWheel *iface, INT32 *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_MaxPatternShifterGear( IRacingWheel *iface, INT32 *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_MaxWheelAngle( IRacingWheel *iface, DOUBLE *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_MaxWheelAngle( IRacingWheel *iface, DOUBLE *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_WheelMotor( IRacingWheel *iface, IForceFeedbackMotor **value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_WheelMotor( IRacingWheel *iface, IForceFeedbackMotor **value ) { - struct racing_wheel *impl = impl_from_IRacingWheel( iface ); + struct racing_wheel *impl = racing_wheel_from_IRacingWheel( iface );
TRACE( "iface %p, value %p\n", iface, value );
return IWineGameControllerProvider_get_ForceFeedbackMotor( impl->wine_provider, value ); }
-static HRESULT WINAPI racing_wheel_GetButtonLabel( IRacingWheel *iface, enum RacingWheelButtons button, +static HRESULT WINAPI racing_wheel_IRacingWheel_GetButtonLabel( IRacingWheel *iface, enum RacingWheelButtons button, enum GameControllerButtonLabel *value ) { FIXME( "iface %p, button %d, value %p stub!\n", iface, button, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_GetCurrentReading( IRacingWheel *iface, struct RacingWheelReading *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_GetCurrentReading( IRacingWheel *iface, struct RacingWheelReading *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static const struct IRacingWheelVtbl racing_wheel_vtbl = -{ - racing_wheel_QueryInterface, - racing_wheel_AddRef, - racing_wheel_Release, - /* IInspectable methods */ - racing_wheel_GetIids, - racing_wheel_GetRuntimeClassName, - racing_wheel_GetTrustLevel, - /* IRacingWheel methods */ - racing_wheel_get_HasClutch, - racing_wheel_get_HasHandbrake, - racing_wheel_get_HasPatternShifter, - racing_wheel_get_MaxPatternShifterGear, - racing_wheel_get_MaxWheelAngle, - racing_wheel_get_WheelMotor, - racing_wheel_GetButtonLabel, - racing_wheel_GetCurrentReading, -}; +INTERFACE_VTBL_IRacingWheel( racing_wheel_IRacingWheel );
struct racing_wheel_statics { @@ -292,113 +178,21 @@ struct racing_wheel_statics IRacingWheelStatics2 IRacingWheelStatics2_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct racing_wheel_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct racing_wheel_statics, IActivationFactory_iface ); -} +INTERFACE_IMPL_STATIC_IActivationFactory( racing_wheel_statics, IRacingWheelStatics, IRacingWheelStatics2, + ICustomGameControllerFactory, IAgileObject, END );
-static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct racing_wheel_statics *impl = impl_from_IActivationFactory( iface ); - - 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_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IRacingWheelStatics )) - { - IInspectable_AddRef( (*out = &impl->IRacingWheelStatics_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IRacingWheelStatics2 )) - { - IInspectable_AddRef( (*out = &impl->IRacingWheelStatics2_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_ICustomGameControllerFactory )) - { - IInspectable_AddRef( (*out = &impl->ICustomGameControllerFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) -{ - struct racing_wheel_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI factory_Release( IActivationFactory *iface ) -{ - struct racing_wheel_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI racing_wheel_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IActivationFactory methods */ - factory_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( statics, IRacingWheelStatics, racing_wheel_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( racing_wheel_statics );
-static HRESULT WINAPI statics_add_RacingWheelAdded( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_add_RacingWheelAdded( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); @@ -406,13 +200,13 @@ static HRESULT WINAPI statics_add_RacingWheelAdded( IRacingWheelStatics *iface, return event_handlers_append( &racing_wheel_added_handlers, (IEventHandler_IInspectable *)handler, token ); }
-static HRESULT WINAPI statics_remove_RacingWheelAdded( IRacingWheelStatics *iface, EventRegistrationToken token ) +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_remove_RacingWheelAdded( IRacingWheelStatics *iface, EventRegistrationToken token ) { TRACE( "iface %p, token %#I64x.\n", iface, token.value ); return event_handlers_remove( &racing_wheel_added_handlers, &token ); }
-static HRESULT WINAPI statics_add_RacingWheelRemoved( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_add_RacingWheelRemoved( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); @@ -420,13 +214,13 @@ static HRESULT WINAPI statics_add_RacingWheelRemoved( IRacingWheelStatics *iface return event_handlers_append( &racing_wheel_removed_handlers, (IEventHandler_IInspectable *)handler, token ); }
-static HRESULT WINAPI statics_remove_RacingWheelRemoved( IRacingWheelStatics *iface, EventRegistrationToken token ) +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_remove_RacingWheelRemoved( IRacingWheelStatics *iface, EventRegistrationToken token ) { TRACE( "iface %p, token %#I64x.\n", iface, token.value ); return event_handlers_remove( &racing_wheel_removed_handlers, &token ); }
-static HRESULT WINAPI statics_get_RacingWheels( IRacingWheelStatics *iface, IVectorView_RacingWheel **value ) +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_get_RacingWheels( IRacingWheelStatics *iface, IVectorView_RacingWheel **value ) { HRESULT hr;
@@ -439,28 +233,11 @@ static HRESULT WINAPI statics_get_RacingWheels( IRacingWheelStatics *iface, IVec return hr; }
-static const struct IRacingWheelStaticsVtbl statics_vtbl = -{ - statics_QueryInterface, - statics_AddRef, - statics_Release, - /* IInspectable methods */ - statics_GetIids, - statics_GetRuntimeClassName, - statics_GetTrustLevel, - /* IRacingWheelStatics methods */ - statics_add_RacingWheelAdded, - statics_remove_RacingWheelAdded, - statics_add_RacingWheelRemoved, - statics_remove_RacingWheelRemoved, - statics_get_RacingWheels, -}; - -DEFINE_IINSPECTABLE( statics2, IRacingWheelStatics2, racing_wheel_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IRacingWheelStatics( racing_wheel_statics_IRacingWheelStatics );
-static HRESULT WINAPI statics2_FromGameController( IRacingWheelStatics2 *iface, IGameController *game_controller, IRacingWheel **value ) +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics2_FromGameController( IRacingWheelStatics2 *iface, IGameController *game_controller, IRacingWheel **value ) { - struct racing_wheel_statics *impl = impl_from_IRacingWheelStatics2( iface ); + struct racing_wheel_statics *impl = racing_wheel_statics_from_IRacingWheelStatics2( iface ); IGameController *controller; HRESULT hr;
@@ -476,22 +253,9 @@ static HRESULT WINAPI statics2_FromGameController( IRacingWheelStatics2 *iface, return hr; }
-static const struct IRacingWheelStatics2Vtbl statics2_vtbl = -{ - statics2_QueryInterface, - statics2_AddRef, - statics2_Release, - /* IInspectable methods */ - statics2_GetIids, - statics2_GetRuntimeClassName, - statics2_GetTrustLevel, - /* IRacingWheelStatics2 methods */ - statics2_FromGameController, -}; - -DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, racing_wheel_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IRacingWheelStatics2( racing_wheel_statics_IRacingWheelStatics2 );
-static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, +static HRESULT WINAPI racing_wheel_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) { struct racing_wheel *impl; @@ -499,10 +263,11 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro TRACE( "iface %p, provider %p, value %p.\n", iface, provider, value );
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; - impl->IGameControllerImpl_iface.lpVtbl = &controller_vtbl; - impl->IGameControllerInputSink_iface.lpVtbl = &input_sink_vtbl; - impl->IRacingWheel_iface.lpVtbl = &racing_wheel_vtbl; - impl->ref = 1; + impl->IGameControllerImpl_iface.lpVtbl = &racing_wheel_vtbl; + impl->IGameControllerInputSink_iface.lpVtbl = &racing_wheel_IGameControllerInputSink_vtbl; + impl->IRacingWheel_iface.lpVtbl = &racing_wheel_IRacingWheel_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_RacingWheel; + impl->refcount = 1;
TRACE( "created RacingWheel %p\n", impl );
@@ -510,7 +275,7 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro return S_OK; }
-static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value ) +static HRESULT WINAPI racing_wheel_statics_ICustomGameControllerFactory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value ) { IRacingWheel *racing_wheel; HRESULT hr; @@ -525,7 +290,7 @@ static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameContr return S_OK; }
-static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value ) +static HRESULT WINAPI racing_wheel_statics_ICustomGameControllerFactory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value ) { IRacingWheel *racing_wheel; BOOLEAN found; @@ -559,31 +324,17 @@ static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameCon return S_OK; }
-static const struct ICustomGameControllerFactoryVtbl controller_factory_vtbl = -{ - controller_factory_QueryInterface, - controller_factory_AddRef, - controller_factory_Release, - /* IInspectable methods */ - controller_factory_GetIids, - controller_factory_GetRuntimeClassName, - controller_factory_GetTrustLevel, - /* ICustomGameControllerFactory methods */ - controller_factory_CreateGameController, - controller_factory_OnGameControllerAdded, - controller_factory_OnGameControllerRemoved, -}; - -DEFINE_IAGILEOBJECT( racing_wheel_statics, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_ICustomGameControllerFactory( racing_wheel_statics_ICustomGameControllerFactory ); +INTERFACE_VTBL_IAgileObject( racing_wheel_statics_IAgileObject );
static struct racing_wheel_statics racing_wheel_statics = { - {&factory_vtbl}, - {&statics_vtbl}, - {&statics2_vtbl}, - {&controller_factory_vtbl}, + {&racing_wheel_statics_vtbl}, + {&racing_wheel_statics_IRacingWheelStatics_vtbl}, + {&racing_wheel_statics_IRacingWheelStatics2_vtbl}, + {&racing_wheel_statics_ICustomGameControllerFactory_vtbl}, {&racing_wheel_statics_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_RacingWheel, };
ICustomGameControllerFactory *racing_wheel_factory = &racing_wheel_statics.ICustomGameControllerFactory_iface; diff --git a/dlls/windows.gaming.input/ramp_effect.c b/dlls/windows.gaming.input/ramp_effect.c index f0eb4efaa31..eb2aef856a5 100644 --- a/dlls/windows.gaming.input/ramp_effect.c +++ b/dlls/windows.gaming.input/ramp_effect.c @@ -26,77 +26,32 @@ struct ramp_effect { IRampForceEffect IRampForceEffect_iface; IWineForceFeedbackEffectImpl *IWineForceFeedbackEffectImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount; };
-static inline struct ramp_effect *impl_from_IRampForceEffect( IRampForceEffect *iface ) -{ - return CONTAINING_RECORD( iface, struct ramp_effect, IRampForceEffect_iface ); -} +INTERFACE_IMPL_FROM( ramp_effect, IRampForceEffect );
-static HRESULT WINAPI effect_QueryInterface( IRampForceEffect *iface, REFIID iid, void **out ) +static HRESULT WINAPI ramp_effect_QueryInterface( IRampForceEffect *iface, REFIID iid, void **out ) { - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); - + struct ramp_effect *impl = ramp_effect_from_IRampForceEffect( iface ); 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_IRampForceEffect )) - { - IInspectable_AddRef( (*out = &impl->IRampForceEffect_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IRampForceEffect( impl, iid, out, IRampForceEffect_iface ) return IWineForceFeedbackEffectImpl_QueryInterface( impl->IWineForceFeedbackEffectImpl_inner, iid, out ); }
-static ULONG WINAPI effect_AddRef( IRampForceEffect *iface ) -{ - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( ramp_effect, IRampForceEffect );
-static ULONG WINAPI effect_Release( IRampForceEffect *iface ) +static void ramp_effect_destroy( struct ramp_effect *impl ) { - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetIids( IRampForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI effect_GetRuntimeClassName( IRampForceEffect *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect), - class_name ); -} - -static HRESULT WINAPI effect_GetTrustLevel( IRampForceEffect *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( ramp_effect, IRampForceEffect ); +IINSPECTABLE_IMPL( ramp_effect, IRampForceEffect );
-static HRESULT WINAPI effect_SetParameters( IRampForceEffect *iface, Vector3 start_vector, Vector3 end_vector, TimeSpan duration ) +static HRESULT WINAPI ramp_effect_SetParameters( IRampForceEffect *iface, Vector3 start_vector, Vector3 end_vector, TimeSpan duration ) { WineForceFeedbackEffectParameters params = { @@ -110,7 +65,7 @@ static HRESULT WINAPI effect_SetParameters( IRampForceEffect *iface, Vector3 sta .gain = 1., }, }; - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); + struct ramp_effect *impl = ramp_effect_from_IRampForceEffect( iface );
TRACE( "iface %p, start_vector %s, end_vector %s, duration %I64u.\n", iface, debugstr_vector3( &start_vector ), debugstr_vector3( &end_vector ), duration.Duration ); @@ -118,7 +73,7 @@ static HRESULT WINAPI effect_SetParameters( IRampForceEffect *iface, Vector3 sta return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, NULL ); }
-static HRESULT WINAPI effect_SetParametersWithEnvelope( IRampForceEffect *iface, Vector3 start_vector, Vector3 end_vector, FLOAT attack_gain, +static HRESULT WINAPI ramp_effect_SetParametersWithEnvelope( IRampForceEffect *iface, Vector3 start_vector, Vector3 end_vector, FLOAT attack_gain, FLOAT sustain_gain, FLOAT release_gain, TimeSpan start_delay, TimeSpan attack_duration, TimeSpan sustain_duration, TimeSpan release_duration, UINT32 repeat_count ) @@ -143,7 +98,7 @@ static HRESULT WINAPI effect_SetParametersWithEnvelope( IRampForceEffect *iface, .attack_duration = attack_duration, .release_duration = release_duration, }; - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); + struct ramp_effect *impl = ramp_effect_from_IRampForceEffect( iface );
TRACE( "iface %p, start_vector %s, end_vector %s, attack_gain %f, sustain_gain %f, release_gain %f, start_delay %I64u, attack_duration %I64u, " "sustain_duration %I64u, release_duration %I64u, repeat_count %u.\n", iface, debugstr_vector3( &start_vector ), debugstr_vector3( &end_vector ), @@ -153,92 +108,18 @@ static HRESULT WINAPI effect_SetParametersWithEnvelope( IRampForceEffect *iface, return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, &envelope ); }
-static const struct IRampForceEffectVtbl effect_vtbl = -{ - effect_QueryInterface, - effect_AddRef, - effect_Release, - /* IInspectable methods */ - effect_GetIids, - effect_GetRuntimeClassName, - effect_GetTrustLevel, - /* IRampForceEffect methods */ - effect_SetParameters, - effect_SetParametersWithEnvelope, -}; +INTERFACE_VTBL_IRampForceEffect( ramp_effect );
struct ramp_factory { IActivationFactory IActivationFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct ramp_factory *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct ramp_factory, IActivationFactory_iface ); -} +INTERFACE_IMPL_STATIC_IActivationFactory( ramp_factory, IAgileObject, END );
-static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct ramp_factory *impl = impl_from_IActivationFactory( iface ); - - 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_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI activation_AddRef( IActivationFactory *iface ) -{ - struct ramp_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI activation_Release( IActivationFactory *iface ) -{ - struct ramp_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI activation_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI ramp_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { struct ramp_effect *impl; HRESULT hr; @@ -246,8 +127,9 @@ static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, II TRACE( "iface %p, instance %p.\n", iface, instance );
if (!(impl = calloc( 1, sizeof(struct ramp_effect) ))) return E_OUTOFMEMORY; - impl->IRampForceEffect_iface.lpVtbl = &effect_vtbl; - impl->ref = 1; + impl->IRampForceEffect_iface.lpVtbl = &ramp_effect_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect; + impl->refcount = 1;
if (FAILED(hr = force_feedback_effect_create( WineForceFeedbackEffectType_Ramp, (IInspectable *)&impl->IRampForceEffect_iface, &impl->IWineForceFeedbackEffectImpl_inner ))) @@ -261,26 +143,14 @@ static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, II return S_OK; }
-static const struct IActivationFactoryVtbl activation_vtbl = -{ - activation_QueryInterface, - activation_AddRef, - activation_Release, - /* IInspectable methods */ - activation_GetIids, - activation_GetRuntimeClassName, - activation_GetTrustLevel, - /* IActivationFactory methods */ - activation_ActivateInstance, -}; - -DEFINE_IAGILEOBJECT( ramp_factory, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IActivationFactory( ramp_factory ); +INTERFACE_VTBL_IAgileObject( ramp_factory_IAgileObject );
static struct ramp_factory ramp_statics = { - {&activation_vtbl}, + {&ramp_factory_vtbl}, {&ramp_factory_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect, };
IInspectable *ramp_effect_factory = (IInspectable *)&ramp_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/vector.c b/dlls/windows.gaming.input/vector.c index 6e16e9ace01..9ed3d7e2f62 100644 --- a/dlls/windows.gaming.input/vector.c +++ b/dlls/windows.gaming.input/vector.c @@ -27,22 +27,20 @@ struct iterator { IIterator_IInspectable IIterator_IInspectable_iface; IAgileObject IAgileObject_iface; + const WCHAR *class_name; const GUID *iid; - LONG ref; + LONG refcount;
IVectorView_IInspectable *view; UINT32 index; UINT32 size; };
-static inline struct iterator *impl_from_IIterator_IInspectable( IIterator_IInspectable *iface ) -{ - return CONTAINING_RECORD( iface, struct iterator, IIterator_IInspectable_iface ); -} +INTERFACE_IMPL_FROM( iterator, IIterator_IInspectable );
static HRESULT WINAPI iterator_QueryInterface( IIterator_IInspectable *iface, REFIID iid, void **out ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
@@ -54,69 +52,34 @@ static HRESULT WINAPI iterator_QueryInterface( IIterator_IInspectable *iface, RE return S_OK; }
- if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } + QUERY_INTERFACE_IAgileObject( impl, iid, out, IAgileObject_iface );
FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; }
-static ULONG WINAPI iterator_AddRef( IIterator_IInspectable *iface ) -{ - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( iterator, IIterator_IInspectable );
-static ULONG WINAPI iterator_Release( IIterator_IInspectable *iface ) +static void iterator_destroy( struct iterator *impl ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - IVectorView_IInspectable_Release( impl->view ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI iterator_GetIids( IIterator_IInspectable *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; + IVectorView_IInspectable_Release( impl->view ); + free( impl ); }
-static HRESULT WINAPI iterator_GetRuntimeClassName( IIterator_IInspectable *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI iterator_GetTrustLevel( IIterator_IInspectable *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( iterator, IIterator_IInspectable ); +IINSPECTABLE_IMPL( iterator, IIterator_IInspectable );
static HRESULT WINAPI iterator_get_Current( IIterator_IInspectable *iface, IInspectable **value ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface ); TRACE( "iface %p, value %p.\n", iface, value ); return IVectorView_IInspectable_GetAt( impl->view, impl->index, value ); }
static HRESULT WINAPI iterator_get_HasCurrent( IIterator_IInspectable *iface, boolean *value ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -126,7 +89,7 @@ static HRESULT WINAPI iterator_get_HasCurrent( IIterator_IInspectable *iface, bo
static HRESULT WINAPI iterator_MoveNext( IIterator_IInspectable *iface, boolean *value ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -137,28 +100,15 @@ static HRESULT WINAPI iterator_MoveNext( IIterator_IInspectable *iface, boolean static HRESULT WINAPI iterator_GetMany( IIterator_IInspectable *iface, UINT32 items_size, IInspectable **items, UINT *count ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface ); TRACE( "iface %p, items_size %u, items %p, count %p.\n", iface, items_size, items, count ); return IVectorView_IInspectable_GetMany( impl->view, impl->index, items_size, items, count ); }
-static const IIterator_IInspectableVtbl iterator_vtbl = -{ - iterator_QueryInterface, - iterator_AddRef, - iterator_Release, - /* IInspectable methods */ - iterator_GetIids, - iterator_GetRuntimeClassName, - iterator_GetTrustLevel, - /* IIterator<IInspectable*> methods */ - iterator_get_Current, - iterator_get_HasCurrent, - iterator_MoveNext, - iterator_GetMany, -}; +INTERFACE_VTBL_IIterator_IInspectable( iterator );
-DEFINE_IAGILEOBJECT( iterator, IIterator_IInspectable, &object->IIterator_IInspectable_iface ); +INTERFACE_FWD_IAgileObject( iterator, IIterator_IInspectable, &object->IIterator_IInspectable_iface ); +INTERFACE_VTBL_IAgileObject( iterator_IAgileObject );
struct vector_view { @@ -166,20 +116,18 @@ struct vector_view IIterable_IInspectable IIterable_IInspectable_iface; IAgileObject IAgileObject_iface; struct vector_iids iids; - LONG ref; + const WCHAR *class_name; + LONG refcount;
UINT32 size; IInspectable *elements[1]; };
-static inline struct vector_view *impl_from_IVectorView_IInspectable( IVectorView_IInspectable *iface ) -{ - return CONTAINING_RECORD( iface, struct vector_view, IVectorView_IInspectable_iface ); -} +INTERFACE_IMPL_FROM( vector_view, IVectorView_IInspectable );
static HRESULT WINAPI vector_view_QueryInterface( IVectorView_IInspectable *iface, REFIID iid, void **out ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IVectorView_IInspectable( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
@@ -197,62 +145,28 @@ static HRESULT WINAPI vector_view_QueryInterface( IVectorView_IInspectable *ifac return S_OK; }
- if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } + QUERY_INTERFACE_IAgileObject( impl, iid, out, IAgileObject_iface );
FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; }
-static ULONG WINAPI vector_view_AddRef( IVectorView_IInspectable *iface ) -{ - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( vector_view, IVectorView_IInspectable );
-static ULONG WINAPI vector_view_Release( IVectorView_IInspectable *iface ) +static void vector_view_destroy( struct vector_view *impl ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); - ULONG i, ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - for (i = 0; i < impl->size; ++i) IInspectable_Release( impl->elements[i] ); - free( impl ); - } - - return ref; + UINT i; + for (i = 0; i < impl->size; ++i) IInspectable_Release( impl->elements[i] ); + free( impl ); }
-static HRESULT WINAPI vector_view_GetIids( IVectorView_IInspectable *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI vector_view_GetRuntimeClassName( IVectorView_IInspectable *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI vector_view_GetTrustLevel( IVectorView_IInspectable *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( vector_view, IVectorView_IInspectable ); +IINSPECTABLE_IMPL( vector_view, IVectorView_IInspectable );
static HRESULT WINAPI vector_view_GetAt( IVectorView_IInspectable *iface, UINT32 index, IInspectable **value ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IVectorView_IInspectable( iface );
TRACE( "iface %p, index %u, value %p.\n", iface, index, value );
@@ -265,7 +179,7 @@ static HRESULT WINAPI vector_view_GetAt( IVectorView_IInspectable *iface, UINT32
static HRESULT WINAPI vector_view_get_Size( IVectorView_IInspectable *iface, UINT32 *value ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IVectorView_IInspectable( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -276,7 +190,7 @@ static HRESULT WINAPI vector_view_get_Size( IVectorView_IInspectable *iface, UIN static HRESULT WINAPI vector_view_IndexOf( IVectorView_IInspectable *iface, IInspectable *element, UINT32 *index, BOOLEAN *found ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IVectorView_IInspectable( iface ); ULONG i;
TRACE( "iface %p, element %p, index %p, found %p.\n", iface, element, index, found ); @@ -291,7 +205,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 ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IVectorView_IInspectable( iface ); UINT32 i;
TRACE( "iface %p, start_index %u, items_size %u, items %p, count %p.\n", @@ -309,28 +223,13 @@ static HRESULT WINAPI vector_view_GetMany( IVectorView_IInspectable *iface, UINT return S_OK; }
-static const struct IVectorView_IInspectableVtbl vector_view_vtbl = -{ - vector_view_QueryInterface, - vector_view_AddRef, - vector_view_Release, - /* IInspectable methods */ - vector_view_GetIids, - vector_view_GetRuntimeClassName, - vector_view_GetTrustLevel, - /* IVectorView<IInspectable*> methods */ - vector_view_GetAt, - vector_view_get_Size, - vector_view_IndexOf, - vector_view_GetMany, -}; +INTERFACE_VTBL_IVectorView_IInspectable( vector_view );
-DEFINE_IINSPECTABLE_( iterable_view, IIterable_IInspectable, vector_view, view_impl_from_IIterable_IInspectable, - IIterable_IInspectable_iface, (IInspectable *)&object->IVectorView_IInspectable_iface ) +INTERFACE_FWD_IIterable_IInspectable( vector_view, IVectorView_IInspectable, &object->IVectorView_IInspectable_iface );
-static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) +static HRESULT WINAPI vector_view_IIterable_IInspectable_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) { - struct vector_view *impl = view_impl_from_IIterable_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IIterable_IInspectable( iface ); struct iterator *iter;
TRACE( "iface %p, value %p.\n", iface, value ); @@ -339,7 +238,7 @@ static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IItera iter->IIterator_IInspectable_iface.lpVtbl = &iterator_vtbl; iter->IAgileObject_iface.lpVtbl = &iterator_IAgileObject_vtbl; iter->iid = impl->iids.iterator; - iter->ref = 1; + iter->refcount = 1;
IVectorView_IInspectable_AddRef( (iter->view = &impl->IVectorView_IInspectable_iface) ); iter->size = impl->size; @@ -348,20 +247,10 @@ static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IItera return S_OK; }
-static const struct IIterable_IInspectableVtbl iterable_view_vtbl = -{ - iterable_view_QueryInterface, - iterable_view_AddRef, - iterable_view_Release, - /* IInspectable methods */ - iterable_view_GetIids, - iterable_view_GetRuntimeClassName, - iterable_view_GetTrustLevel, - /* IIterable<T> methods */ - iterable_view_First, -}; +INTERFACE_VTBL_IIterable_IInspectable( vector_view_IIterable_IInspectable );
-DEFINE_IAGILEOBJECT( vector_view, IVectorView_IInspectable, &object->IVectorView_IInspectable_iface ); +INTERFACE_FWD_IAgileObject( vector_view, IIterable_IInspectable, &object->IIterable_IInspectable_iface ); +INTERFACE_VTBL_IAgileObject( vector_view_IAgileObject );
struct vector { @@ -369,21 +258,19 @@ struct vector IIterable_IInspectable IIterable_IInspectable_iface; IAgileObject IAgileObject_iface; struct vector_iids iids; - LONG ref; + const WCHAR *class_name; + LONG refcount;
UINT32 size; UINT32 capacity; IInspectable **elements; };
-static inline struct vector *impl_from_IVector_IInspectable( IVector_IInspectable *iface ) -{ - return CONTAINING_RECORD( iface, struct vector, IVector_IInspectable_iface ); -} +INTERFACE_IMPL_FROM( vector, IVector_IInspectable );
static HRESULT WINAPI vector_QueryInterface( IVector_IInspectable *iface, REFIID iid, void **out ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
@@ -401,62 +288,27 @@ static HRESULT WINAPI vector_QueryInterface( IVector_IInspectable *iface, REFIID return S_OK; }
- if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } + QUERY_INTERFACE_IAgileObject( impl, iid, out, IAgileObject_iface );
FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; }
-static ULONG WINAPI vector_AddRef( IVector_IInspectable *iface ) -{ - struct vector *impl = impl_from_IVector_IInspectable( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI vector_Release( IVector_IInspectable *iface ) -{ - struct vector *impl = impl_from_IVector_IInspectable( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - IVector_IInspectable_Clear( iface ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI vector_GetIids( IVector_IInspectable *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( vector, IVector_IInspectable );
-static HRESULT WINAPI vector_GetRuntimeClassName( IVector_IInspectable *iface, HSTRING *class_name ) +static void vector_destroy( struct vector *impl ) { - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; + IVector_IInspectable_Clear( &impl->IVector_IInspectable_iface ); + free( impl ); }
-static HRESULT WINAPI vector_GetTrustLevel( IVector_IInspectable *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( vector, IVector_IInspectable ); +IINSPECTABLE_IMPL( vector, IVector_IInspectable );
static HRESULT WINAPI vector_GetAt( IVector_IInspectable *iface, UINT32 index, IInspectable **value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p, index %u, value %p.\n", iface, index, value );
@@ -469,7 +321,7 @@ static HRESULT WINAPI vector_GetAt( IVector_IInspectable *iface, UINT32 index, I
static HRESULT WINAPI vector_get_Size( IVector_IInspectable *iface, UINT32 *value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface ); TRACE( "iface %p, value %p.\n", iface, value ); *value = impl->size; return S_OK; @@ -477,7 +329,7 @@ static HRESULT WINAPI vector_get_Size( IVector_IInspectable *iface, UINT32 *valu
static HRESULT WINAPI vector_GetView( IVector_IInspectable *iface, IVectorView_IInspectable **value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface ); struct vector_view *view; ULONG i;
@@ -485,10 +337,10 @@ static HRESULT WINAPI vector_GetView( IVector_IInspectable *iface, IVectorView_I
if (!(view = calloc( 1, offsetof( struct vector_view, elements[impl->size] ) ))) return E_OUTOFMEMORY; view->IVectorView_IInspectable_iface.lpVtbl = &vector_view_vtbl; - view->IIterable_IInspectable_iface.lpVtbl = &iterable_view_vtbl; + view->IIterable_IInspectable_iface.lpVtbl = &vector_view_IIterable_IInspectable_vtbl; view->IAgileObject_iface.lpVtbl = &vector_view_IAgileObject_vtbl; view->iids = impl->iids; - view->ref = 1; + view->refcount = 1;
for (i = 0; i < impl->size; ++i) IInspectable_AddRef( (view->elements[view->size++] = impl->elements[i]) );
@@ -498,7 +350,7 @@ static HRESULT WINAPI vector_GetView( IVector_IInspectable *iface, IVectorView_I
static HRESULT WINAPI vector_IndexOf( IVector_IInspectable *iface, IInspectable *element, UINT32 *index, BOOLEAN *found ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface ); ULONG i;
TRACE( "iface %p, element %p, index %p, found %p.\n", iface, element, index, found ); @@ -512,7 +364,7 @@ static HRESULT WINAPI vector_IndexOf( IVector_IInspectable *iface, IInspectable
static HRESULT WINAPI vector_SetAt( IVector_IInspectable *iface, UINT32 index, IInspectable *value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p, index %u, value %p.\n", iface, index, value );
@@ -524,7 +376,7 @@ static HRESULT WINAPI vector_SetAt( IVector_IInspectable *iface, UINT32 index, I
static HRESULT WINAPI vector_InsertAt( IVector_IInspectable *iface, UINT32 index, IInspectable *value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface ); IInspectable **tmp = impl->elements;
TRACE( "iface %p, index %u, value %p.\n", iface, index, value ); @@ -546,7 +398,7 @@ static HRESULT WINAPI vector_InsertAt( IVector_IInspectable *iface, UINT32 index
static HRESULT WINAPI vector_RemoveAt( IVector_IInspectable *iface, UINT32 index ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p, index %u.\n", iface, index );
@@ -558,7 +410,7 @@ static HRESULT WINAPI vector_RemoveAt( IVector_IInspectable *iface, UINT32 index
static HRESULT WINAPI vector_Append( IVector_IInspectable *iface, IInspectable *value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -567,7 +419,7 @@ static HRESULT WINAPI vector_Append( IVector_IInspectable *iface, IInspectable *
static HRESULT WINAPI vector_RemoveAtEnd( IVector_IInspectable *iface ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p.\n", iface );
@@ -577,7 +429,7 @@ static HRESULT WINAPI vector_RemoveAtEnd( IVector_IInspectable *iface )
static HRESULT WINAPI vector_Clear( IVector_IInspectable *iface ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p.\n", iface );
@@ -592,7 +444,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 ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface ); UINT32 i;
TRACE( "iface %p, start_index %u, items_size %u, items %p, count %p.\n", @@ -622,35 +474,13 @@ static HRESULT WINAPI vector_ReplaceAll( IVector_IInspectable *iface, UINT32 cou return hr; }
-static const struct IVector_IInspectableVtbl vector_vtbl = -{ - vector_QueryInterface, - vector_AddRef, - vector_Release, - /* IInspectable methods */ - vector_GetIids, - vector_GetRuntimeClassName, - vector_GetTrustLevel, - /* IVector<IInspectable*> methods */ - vector_GetAt, - vector_get_Size, - vector_GetView, - vector_IndexOf, - vector_SetAt, - vector_InsertAt, - vector_RemoveAt, - vector_Append, - vector_RemoveAtEnd, - vector_Clear, - vector_GetMany, - vector_ReplaceAll, -}; +INTERFACE_VTBL_IVector_IInspectable( vector );
-DEFINE_IINSPECTABLE( iterable, IIterable_IInspectable, vector, IVector_IInspectable_iface ) +INTERFACE_FWD_IIterable_IInspectable( vector, IVector_IInspectable, &object->IVector_IInspectable_iface );
-static HRESULT WINAPI iterable_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) +static HRESULT WINAPI vector_IIterable_IInspectable_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) { - struct vector *impl = impl_from_IIterable_IInspectable( iface ); + struct vector *impl = vector_from_IIterable_IInspectable( iface ); IIterable_IInspectable *iterable; IVectorView_IInspectable *view; HRESULT hr; @@ -668,20 +498,10 @@ static HRESULT WINAPI iterable_First( IIterable_IInspectable *iface, IIterator_I return hr; }
-static const struct IIterable_IInspectableVtbl iterable_vtbl = -{ - iterable_QueryInterface, - iterable_AddRef, - iterable_Release, - /* IInspectable methods */ - iterable_GetIids, - iterable_GetRuntimeClassName, - iterable_GetTrustLevel, - /* IIterable<T> methods */ - iterable_First, -}; +INTERFACE_VTBL_IIterable_IInspectable( vector_IIterable_IInspectable );
-DEFINE_IAGILEOBJECT( vector, IVector_IInspectable, &object->IVector_IInspectable_iface ); +INTERFACE_FWD_IAgileObject( vector, IVector_IInspectable, &object->IVector_IInspectable_iface ); +INTERFACE_VTBL_IAgileObject( vector_IAgileObject );
HRESULT vector_create( const struct vector_iids *iids, void **out ) { @@ -691,10 +511,10 @@ HRESULT vector_create( const struct vector_iids *iids, void **out )
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IVector_IInspectable_iface.lpVtbl = &vector_vtbl; - impl->IIterable_IInspectable_iface.lpVtbl = &iterable_vtbl; + impl->IIterable_IInspectable_iface.lpVtbl = &vector_IIterable_IInspectable_vtbl; impl->IAgileObject_iface.lpVtbl = &vector_IAgileObject_vtbl; impl->iids = *iids; - impl->ref = 1; + impl->refcount = 1;
*out = &impl->IVector_IInspectable_iface; TRACE( "created %p\n", *out );
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/constant_effect.c | 2 +- dlls/windows.gaming.input/controller.c | 4 ++-- dlls/windows.gaming.input/force_feedback.c | 4 ++-- dlls/windows.gaming.input/gamepad.c | 4 ++-- dlls/windows.gaming.input/manager.c | 2 +- dlls/windows.gaming.input/periodic_effect.c | 2 +- dlls/windows.gaming.input/provider.c | 2 +- dlls/windows.gaming.input/racing_wheel.c | 4 ++-- dlls/windows.gaming.input/ramp_effect.c | 2 +- include/wine/comimpl.h | 10 +++++----- 12 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/dlls/windows.gaming.input/async.c b/dlls/windows.gaming.input/async.c index 1b03cfac761..47e30a0db0c 100644 --- a/dlls/windows.gaming.input/async.c +++ b/dlls/windows.gaming.input/async.c @@ -60,7 +60,7 @@ static void async_info_destroy( struct async_info *impl ) free( impl ); }
-INTERFACE_IMPL_OUTER_IWineAsyncInfoImpl( async_info, IAgileObject, IAsyncInfo, END ); +INTERFACE_IMPL_OUTER_IWineAsyncInfoImpl( async_info, IAgileObject, IAsyncInfo, END, FIXME );
static HRESULT WINAPI async_info_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) { diff --git a/dlls/windows.gaming.input/condition_effect.c b/dlls/windows.gaming.input/condition_effect.c index 82506f9b506..78d11a41d5f 100644 --- a/dlls/windows.gaming.input/condition_effect.c +++ b/dlls/windows.gaming.input/condition_effect.c @@ -96,7 +96,7 @@ struct condition_factory const WCHAR *class_name; };
-INTERFACE_IMPL_STATIC_IActivationFactory( condition_factory, IConditionForceEffectFactory, IAgileObject, END ); +INTERFACE_IMPL_STATIC_IActivationFactory( condition_factory, IConditionForceEffectFactory, IAgileObject, END, FIXME );
static HRESULT WINAPI condition_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { diff --git a/dlls/windows.gaming.input/constant_effect.c b/dlls/windows.gaming.input/constant_effect.c index d20be1ad13f..13e8f76bf9f 100644 --- a/dlls/windows.gaming.input/constant_effect.c +++ b/dlls/windows.gaming.input/constant_effect.c @@ -114,7 +114,7 @@ struct constant_factory const WCHAR *class_name; };
-INTERFACE_IMPL_STATIC_IActivationFactory( constant_factory, IAgileObject, END ); +INTERFACE_IMPL_STATIC_IActivationFactory( constant_factory, IAgileObject, END, FIXME );
static HRESULT WINAPI constant_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 0c6efe2714b..f1631b83f5c 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -78,7 +78,7 @@ static void controller_destroy( struct controller *impl ) }
INTERFACE_IMPL_OUTER_IGameControllerImpl( controller, IGameControllerInputSink, - IRawGameController, IRawGameController2, END ); + IRawGameController, IRawGameController2, END, FIXME );
static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) @@ -267,7 +267,7 @@ struct controller_statics };
INTERFACE_IMPL_STATIC_IActivationFactory( controller_statics, IRawGameControllerStatics, - ICustomGameControllerFactory, IAgileObject, END ); + ICustomGameControllerFactory, IAgileObject, END, FIXME );
static HRESULT WINAPI controller_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index bf98a4702fb..0c5ecff7146 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -62,7 +62,7 @@ static void effect_destroy( struct effect *impl ) free( impl ); }
-INTERFACE_IMPL_OUTER_IWineForceFeedbackEffectImpl( effect, IForceFeedbackEffect, IAgileObject, END ); +INTERFACE_IMPL_OUTER_IWineForceFeedbackEffectImpl( effect, IForceFeedbackEffect, IAgileObject, END, FIXME );
static int effect_reorient_direction( const WineForceFeedbackEffectParameters *params, Vector3 *direction ) { @@ -377,7 +377,7 @@ static void motor_destroy( struct motor *impl ) free( impl ); }
-INTERFACE_IMPL_IForceFeedbackMotor( motor, IAgileObject, END ); +INTERFACE_IMPL_IForceFeedbackMotor( motor, IAgileObject, END, FIXME );
static HRESULT WINAPI motor_get_AreEffectsPaused( IForceFeedbackMotor *iface, BOOLEAN *value ) { diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c index 2712152f99f..92b1bc554b9 100644 --- a/dlls/windows.gaming.input/gamepad.c +++ b/dlls/windows.gaming.input/gamepad.c @@ -78,7 +78,7 @@ static void gamepad_destroy( struct gamepad *impl ) free( impl ); }
-INTERFACE_IMPL_OUTER_IGameControllerImpl( gamepad, IGameControllerInputSink, IGamepad, IGamepad2, END ); +INTERFACE_IMPL_OUTER_IGameControllerImpl( gamepad, IGameControllerInputSink, IGamepad, IGamepad2, END, FIXME );
static HRESULT WINAPI gamepad_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) @@ -241,7 +241,7 @@ struct gamepad_statics };
INTERFACE_IMPL_STATIC_IActivationFactory( gamepad_statics, IGamepadStatics, IGamepadStatics2, - ICustomGameControllerFactory, IAgileObject, END ); + ICustomGameControllerFactory, IAgileObject, END, FIXME );
static HRESULT WINAPI gamepad_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { diff --git a/dlls/windows.gaming.input/manager.c b/dlls/windows.gaming.input/manager.c index 1a3640a2b0f..c339baba794 100644 --- a/dlls/windows.gaming.input/manager.c +++ b/dlls/windows.gaming.input/manager.c @@ -174,7 +174,7 @@ struct manager_statics };
INTERFACE_IMPL_STATIC_IActivationFactory( manager_statics, IGameControllerFactoryManagerStatics, - IGameControllerFactoryManagerStatics2, IAgileObject, END ) + IGameControllerFactoryManagerStatics2, IAgileObject, END, FIXME )
static HRESULT WINAPI manager_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { diff --git a/dlls/windows.gaming.input/periodic_effect.c b/dlls/windows.gaming.input/periodic_effect.c index c3a07e090a6..491c2a4e9c7 100644 --- a/dlls/windows.gaming.input/periodic_effect.c +++ b/dlls/windows.gaming.input/periodic_effect.c @@ -133,7 +133,7 @@ struct periodic_factory const WCHAR *class_name; };
-INTERFACE_IMPL_STATIC_IActivationFactory( periodic_factory, IPeriodicForceEffectFactory, IAgileObject, END ) +INTERFACE_IMPL_STATIC_IActivationFactory( periodic_factory, IPeriodicForceEffectFactory, IAgileObject, END, FIXME )
static HRESULT WINAPI periodic_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { diff --git a/dlls/windows.gaming.input/provider.c b/dlls/windows.gaming.input/provider.c index a7e49918513..348b6f1be7b 100644 --- a/dlls/windows.gaming.input/provider.c +++ b/dlls/windows.gaming.input/provider.c @@ -76,7 +76,7 @@ static void provider_destroy( struct provider *impl ) free( impl ); }
-INTERFACE_IMPL_IWineGameControllerProvider( provider, IGameControllerProvider, IAgileObject, END ); +INTERFACE_IMPL_IWineGameControllerProvider( provider, IGameControllerProvider, IAgileObject, END, FIXME );
static BOOL CALLBACK count_ffb_axes( const DIDEVICEOBJECTINSTANCEW *obj, void *args ) { diff --git a/dlls/windows.gaming.input/racing_wheel.c b/dlls/windows.gaming.input/racing_wheel.c index e6045be9665..14bc609a838 100644 --- a/dlls/windows.gaming.input/racing_wheel.c +++ b/dlls/windows.gaming.input/racing_wheel.c @@ -76,7 +76,7 @@ static void racing_wheel_destroy( struct racing_wheel *impl ) free( impl ); }
-INTERFACE_IMPL_OUTER_IGameControllerImpl( racing_wheel, IGameControllerInputSink, IRacingWheel, END ); +INTERFACE_IMPL_OUTER_IGameControllerImpl( racing_wheel, IGameControllerInputSink, IRacingWheel, END, FIXME );
static HRESULT WINAPI racing_wheel_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) @@ -182,7 +182,7 @@ struct racing_wheel_statics };
INTERFACE_IMPL_STATIC_IActivationFactory( racing_wheel_statics, IRacingWheelStatics, IRacingWheelStatics2, - ICustomGameControllerFactory, IAgileObject, END ); + ICustomGameControllerFactory, IAgileObject, END, FIXME );
static HRESULT WINAPI racing_wheel_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { diff --git a/dlls/windows.gaming.input/ramp_effect.c b/dlls/windows.gaming.input/ramp_effect.c index eb2aef856a5..5dd9b7d14d7 100644 --- a/dlls/windows.gaming.input/ramp_effect.c +++ b/dlls/windows.gaming.input/ramp_effect.c @@ -117,7 +117,7 @@ struct ramp_factory const WCHAR *class_name; };
-INTERFACE_IMPL_STATIC_IActivationFactory( ramp_factory, IAgileObject, END ); +INTERFACE_IMPL_STATIC_IActivationFactory( ramp_factory, IAgileObject, END, FIXME );
static HRESULT WINAPI ramp_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index 6b21fa4c16e..7e9478bd196 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -31,11 +31,14 @@ #include <windef.h> #include <winbase.h>
-#define QUERY_INTERFACES_END( object, iid, out, ... ) #define QUERY_INTERFACES( object, iid, out, X, ... ) QUERY_INTERFACES_ ## X( object, iid, out, __VA_ARGS__ ) +#define QUERY_INTERFACES_END( object, iid, out, X, ... ) \ + *out = NULL; \ + X( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid) ); \ + return E_NOINTERFACE;
-#define INTERFACES_FWD_END( type, base, expr, ... ) #define INTERFACES_FWD( type, base, expr, X, ... ) INTERFACES_FWD_ ## X( type, base, expr, __VA_ARGS__ ) +#define INTERFACES_FWD_END( type, base, expr, ... )
#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 ) \ @@ -51,9 +54,6 @@ struct type *object = impl_from( iface ); \ TRACE( "object %p, iid %s, out %p.\n", object, debugstr_guid(iid), out ); \ QUERY_INTERFACES( object, iid, out, name, __VA_ARGS__ ); \ - *out = NULL; \ - WARN( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid) ); \ - return E_NOINTERFACE; \ }
#define IUNKNOWN_IMPL_ADDREF( type, name ) IUNKNOWN_IMPL_ADDREF_( type, name, type ## _from_ ## name )
v3: Add a parameter to control QI traces.
@jacek I believe you have started using similar macros to mshtml, what would you think of this?
If you mean `DISPEX_IDISPATCH_IMPL` macro, it's rather specific to MSHTML, which has a single "base" class that's used by tens of different objects. It's a single macro saving us a ton of code, but it's just one very specific macro, not much to share, really. (There are also macros in `oleobj.c` that... I didn't reject. Note that they forward between different objects, so that's not exactly what your targeting here).
I agree that there is room for improvements with our approach to COM interfaces. I was considering extending widl at some point too (but never got it into a shape). My thinking was to have a separate code generator rather than using more macros, somewhat similar to how we allow a dedicated mode for registration. widl could generate 'implementation' source file based on some input IDL with something like coclasses desribing implemented objects. This source file could define all vtbls, forward shared functions, maybe even default `IUnknown`-alike implementation or class factories. (It would probably also need to generate a header file that the rest of module would use to access it, or the whole thing could just be a header). Anyway, I'm not sure, just throwing another idea for a consideration.
(I was also considering "MSHTML" mode; a lot of MSHTML code that just forwards to Gecko could be generated in a similar way, that that's, again, not really something useful outside MSHTML.)
widl could generate 'implementation' source file based on some input IDL with something like coclasses desribing implemented objects. This source file could define all vtbls, forward shared functions, maybe even default `IUnknown`-alike implementation or class factories. (It would probably also need to generate a header file that the rest of module would use to access it, or the whole thing could just be a header). Anyway, I'm not sure, just throwing another idea for a consideration.
I thought about something like that also, although never really got to it, as I thought it would also be interesting to make mock class creation easier for testing. However I ended up with the idea that it wouldn't be very flexible to have it generate everything, and that it would add annoying indirection or hide some details.
For instance with this approach here, I find it convenient that it allows you to selectively replace functions with generated ones through fine-grained macros. It can be useful for some exotic or specific use cases, COM aggregation for instance (although that could also be supported). It also only requires a couple of naming conventions in the implementation structs, but doesn't add any kind of indirection there, you still see all the details of the implementation, only the actual boiler place functions are hidden within macros.
What I don't like much is the use of macros, which doesn't make it very easy to have a look at how the generated code actually looks like (well unless you have editor plugins that expand them for you), but I'm not sure it's a big issue. Alternatively we could perhaps use things like #pragma makedep instead, but although it could generate things in clear text in an annex file, it would be more misleading to the uninformed reader.
This merge request was approved by Elizabeth Figura.
Just out of curiosity, what do you think about an approach that instead creates a`QITAB` with an entry for every inherited interface in `write_widl_impl_macros_methods`, so that the final `QueryInterface` can be done with a `QISearch`? Would it reduce macro usage?
On Mon Nov 18 11:02:49 2024 +0000, Vibhav Pant wrote:
Just out of curiosity, what do you think about an approach that instead creates a`QITAB` with an entry for every inherited interface in `write_widl_impl_macros_methods`, so that the final `QueryInterface` can be done with a `QISearch`? Would it reduce macro usage?
I'm not sure what you mean by `QITAB`, but implementing QueryInterface is just one small piece of macro usage. The main source is probably the higher level macro that generates all the boilerplates (ie: vtables and forwards for every implemented interfaces of a given class).
On Mon Nov 18 12:46:38 2024 +0000, Rémi Bernon wrote:
widl could generate 'implementation' source file based on some input
IDL with something like coclasses desribing implemented objects. This source file could define all vtbls, forward shared functions, maybe even default `IUnknown`-alike implementation or class factories. (It would probably also need to generate a header file that the rest of module would use to access it, or the whole thing could just be a header). Anyway, I'm not sure, just throwing another idea for a consideration. I thought about something like that also, although never really got to it, as I thought it would also be interesting to make mock class creation easier for testing. However I ended up with the idea that it wouldn't be very flexible to have it generate everything, and that it would add annoying indirection or hide some details. For instance with this approach here, I find it convenient that it allows you to selectively replace functions with generated ones through fine-grained macros. It can be useful for some exotic or specific use cases, COM aggregation for instance (although that could also be supported). It also only requires a couple of naming conventions in the implementation structs, but doesn't add any kind of indirection there, you still see all the details of the implementation, only the actual boiler place functions are hidden within macros. What I don't like much is the use of macros, which doesn't make it very easy to have a look at how the generated code actually looks like (well unless you have editor plugins that expand them for you), but I'm not sure it's a big issue. Alternatively we could perhaps use things like #pragma makedep instead, but although it could generate things in clear text in an annex file, it would be more misleading to the uninformed reader.
We could at least move those macros to private generated headers instead of extending public ones.
On Mon Nov 18 11:02:49 2024 +0000, Rémi Bernon wrote:
I'm not sure what you mean by `QITAB`, but implementing QueryInterface is just one small piece of macro usage. The main source is probably the higher level macro that generates all the boilerplates (ie: vtables and forwards for every implemented interfaces of a given class).
Here's a rough example of what I meant. Take `IWineForceFeedbackEffectImpl` for instance:
``` interface IWineForceFeedbackEffectImpl : IInspectable requires Windows.Gaming.Input.ForceFeedback.IForceFeedbackEffect ```
From this, widl would create something like (using unmangled interface names for clarity):
``` #define INTERFACES_IWineForceFeedbackEffectImpl(type, ...) \ const static QITAB QITAB_IWineForceFeedbackEffectImpl[] = \ { \ {&IID_IInspectable, offsetof( type, IWineForceFeedbackEffectImpl_iface )}, \ {&IID_IForceFeedbackEffect, offsetof( type, IForceFeedbackEffect_iface )}, \ __VA_ARGS__ \ }; ```
With the following definitions in `wine/comimpl.h`:
``` #define QITAB_ENTRY(type, X) {&IID##_x, offsetof(type, X##_face)}, #define QITAB_END {NULL, 0} ... #define IUNKNOWN_IMPL_QUERY_INTERFACE_( type, name, impl_from, log ) \ static HRESULT WINAPI type ## _QueryInterface( name *iface, REFIID iid, void **out ) \ { \ struct type *object = impl_from( iface ); \ HRESULT hres; TRACE( "object %p, iid %s, out %p.\n", object, debugstr_guid(iid), out ); \ hres = QISearch(object, QITAB##_name, iid, out); if (hres == E_NOINTERFACE) (log)( "%s not implemented, returning E_NOINTERFACE.", debugstr_guid(iid)); return hres; } ```
[This line](https://gitlab.winehq.org/wine/wine/-/merge_requests/6207/diffs#1645e0df6b8e...) in `force_feedback.c` could be written as
``` INTERFACE_IMPL_OUTER_IWineForceFeedbackEffectImpl( effect, QITAB_ENTRY(IAgileObject), QITAB_END, FIXME ); ```
Which would then expand to the `QITAB` array above + remaining macros. The idea is that this would replace all `QUERY_INTERFACE{S}{_OPT}` macros with one `QITAB` array, simplify `QueryInterface`'s code, and also provide a convenient way to implement `GetIids`, if we ever need to in the future (as we now have an array of all known IIDs for the object). `QISearch` is already in kernelbase, so this shouldn't add any new dependencies if I understand correctly. It also makes it mandatory for the implementation to implement the interfaces annotated with `requires`. (I do realize now that it doesn't really reduce macro usage all that much, but I'd still be interested in knowing what you think about this :P)