From: Zhiyi Zhang zzhang@codeweavers.com
The DEFINE_IINSPECTABLE macro is defined in a private .idl file because there are later patches that need a private COM interface. So store them all in a .idl file for simplicity. --- dlls/wintypes/Makefile.in | 3 +- dlls/wintypes/main.c | 48 ++----------------------- dlls/wintypes/wintypes_private.idl | 58 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 47 deletions(-) create mode 100644 dlls/wintypes/wintypes_private.idl
diff --git a/dlls/wintypes/Makefile.in b/dlls/wintypes/Makefile.in index c6789d41974..b2f099b4076 100644 --- a/dlls/wintypes/Makefile.in +++ b/dlls/wintypes/Makefile.in @@ -3,4 +3,5 @@ IMPORTS = combase
SOURCES = \ classes.idl \ - main.c + main.c \ + wintypes_private.idl diff --git a/dlls/wintypes/main.c b/dlls/wintypes/main.c index 7d59ab92c41..e50beee8a9f 100644 --- a/dlls/wintypes/main.c +++ b/dlls/wintypes/main.c @@ -31,6 +31,7 @@
#define WIDL_using_Windows_Foundation_Metadata #include "windows.foundation.metadata.h" +#include "wintypes_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(wintypes);
@@ -67,11 +68,6 @@ static inline struct wintypes *impl_from_IActivationFactory(IActivationFactory * return CONTAINING_RECORD(iface, struct wintypes, IActivationFactory_iface); }
-static inline struct wintypes *impl_from_IApiInformationStatics(IApiInformationStatics *iface) -{ - return CONTAINING_RECORD(iface, struct wintypes, IApiInformationStatics_iface); -} - static HRESULT STDMETHODCALLTYPE wintypes_QueryInterface(IActivationFactory *iface, REFIID iid, void **out) { @@ -158,47 +154,7 @@ static const struct IActivationFactoryVtbl activation_factory_vtbl = wintypes_ActivateInstance, };
-static HRESULT STDMETHODCALLTYPE api_information_statics_QueryInterface( - IApiInformationStatics *iface, REFIID iid, void **out) -{ - struct wintypes *impl = impl_from_IApiInformationStatics(iface); - return wintypes_QueryInterface(&impl->IActivationFactory_iface, iid, out); -} - -static ULONG STDMETHODCALLTYPE api_information_statics_AddRef( - IApiInformationStatics *iface) -{ - struct wintypes *impl = impl_from_IApiInformationStatics(iface); - return wintypes_AddRef(&impl->IActivationFactory_iface); -} - -static ULONG STDMETHODCALLTYPE api_information_statics_Release( - IApiInformationStatics *iface) -{ - struct wintypes *impl = impl_from_IApiInformationStatics(iface); - return wintypes_Release(&impl->IActivationFactory_iface); -} - -static HRESULT STDMETHODCALLTYPE api_information_statics_GetIids( - IApiInformationStatics *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 STDMETHODCALLTYPE api_information_statics_GetRuntimeClassName( - IApiInformationStatics *iface, HSTRING *class_name) -{ - FIXME("iface %p, class_name %p stub!\n", iface, class_name); - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE api_information_statics_GetTrustLevel( - IApiInformationStatics *iface, TrustLevel *trust_level) -{ - FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); - return E_NOTIMPL; -} +DEFINE_IINSPECTABLE(api_information_statics, IApiInformationStatics, struct wintypes, IActivationFactory_iface)
static HRESULT STDMETHODCALLTYPE api_information_statics_IsTypePresent( IApiInformationStatics *iface, HSTRING type_name, BOOLEAN *value) diff --git a/dlls/wintypes/wintypes_private.idl b/dlls/wintypes/wintypes_private.idl new file mode 100644 index 00000000000..87ccd81c228 --- /dev/null +++ b/dlls/wintypes/wintypes_private.idl @@ -0,0 +1,58 @@ +/* + * Copyright 2024 Zhiyi Zhang 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 + */ + +#pragma makedep header + +cpp_quote("#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \") +cpp_quote(" static inline impl_type *impl_from( iface_type *iface ) \") +cpp_quote(" { \") +cpp_quote(" return CONTAINING_RECORD( iface, impl_type, iface_mem ); \") +cpp_quote(" } \") +cpp_quote(" static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \") +cpp_quote(" { \") +cpp_quote(" impl_type *impl = impl_from( iface ); \") +cpp_quote(" return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \") +cpp_quote(" } \") +cpp_quote(" static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \") +cpp_quote(" { \") +cpp_quote(" impl_type *impl = impl_from( iface ); \") +cpp_quote(" return IInspectable_AddRef( (IInspectable *)(expr) ); \") +cpp_quote(" } \") +cpp_quote(" static ULONG WINAPI pfx##_Release( iface_type *iface ) \") +cpp_quote(" { \") +cpp_quote(" impl_type *impl = impl_from( iface ); \") +cpp_quote(" return IInspectable_Release( (IInspectable *)(expr) ); \") +cpp_quote(" } \") +cpp_quote(" static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \") +cpp_quote(" { \") +cpp_quote(" impl_type *impl = impl_from( iface ); \") +cpp_quote(" return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \") +cpp_quote(" } \") +cpp_quote(" static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \") +cpp_quote(" { \") +cpp_quote(" impl_type *impl = impl_from( iface ); \") +cpp_quote(" return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \") +cpp_quote(" } \") +cpp_quote(" static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \") +cpp_quote(" { \") +cpp_quote(" impl_type *impl = impl_from( iface ); \") +cpp_quote(" return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \") +cpp_quote(" }") + +cpp_quote("#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \") +cpp_quote(" DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->base_iface )")