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 ) \