React Native apps require these.
From: Zhiyi Zhang zzhang@codeweavers.com
--- include/windows.foundation.idl | 108 +++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+)
diff --git a/include/windows.foundation.idl b/include/windows.foundation.idl index 9303ee8a64a..6a5edce6f9c 100644 --- a/include/windows.foundation.idl +++ b/include/windows.foundation.idl @@ -87,6 +87,8 @@ namespace Windows.Foundation { interface IMemoryBuffer; interface IMemoryBufferFactory; interface IMemoryBufferReference; + interface IPropertyValue; + interface IPropertyValueStatics; interface IStringable; interface IUriEscapeStatics; interface IUriRuntimeClass; @@ -98,6 +100,7 @@ namespace Windows.Foundation {
runtimeclass Deferral; runtimeclass MemoryBuffer; + runtimeclass PropertyValue; runtimeclass Uri; runtimeclass WwwFormUrlDecoder; runtimeclass WwwFormUrlDecoderEntry; @@ -335,6 +338,101 @@ namespace Windows.Foundation { [eventremove] HRESULT Closed([in] EventRegistrationToken cookie); }
+ [ + contract(Windows.Foundation.FoundationContract, 1.0), + uuid(4bd682dd-7554-40e9-9a9b-82654ede7e62) + ] + interface IPropertyValue : IInspectable + { + [propget] HRESULT Type([out, retval] Windows.Foundation.PropertyType *value); + [propget] HRESULT IsNumericScalar([out, retval] boolean *value); + HRESULT GetUInt8([out, retval] BYTE *value); + HRESULT GetInt16([out, retval] INT16 *value); + HRESULT GetUInt16([out, retval] UINT16 *value); + HRESULT GetInt32([out, retval] INT32 *value); + HRESULT GetUInt32([out, retval] UINT32 *value); + HRESULT GetInt64([out, retval] INT64 *value); + HRESULT GetUInt64([out, retval] UINT64 *value); + HRESULT GetSingle([out, retval] FLOAT *value); + HRESULT GetDouble([out, retval] DOUBLE *value); + HRESULT GetChar16([out, retval] WCHAR *value); + HRESULT GetBoolean([out, retval] boolean *value); + HRESULT GetString([out, retval] HSTRING *value); + HRESULT GetGuid([out, retval] GUID *value); + HRESULT GetDateTime([out, retval] Windows.Foundation.DateTime *value); + HRESULT GetTimeSpan([out, retval] Windows.Foundation.TimeSpan *value); + HRESULT GetPoint([out, retval] Windows.Foundation.Point *value); + HRESULT GetSize([out, retval] Windows.Foundation.Size *value); + HRESULT GetRect([out, retval] Windows.Foundation.Rect *value); + HRESULT GetUInt8Array([out] UINT32 *value_size, [out, size_is(*value_size)] BYTE **value); + HRESULT GetInt16Array([out] UINT32 *value_size, [out, size_is(*value_size)] INT16 **value); + HRESULT GetUInt16Array([out] UINT32 *value_size, [out, size_is(*value_size)] UINT16 **value); + HRESULT GetInt32Array([out] UINT32 *value_size, [out, size_is(*value_size)] INT32 **value); + HRESULT GetUInt32Array([out] UINT32 *value_size, [out, size_is(*value_size)] UINT32 **value); + HRESULT GetInt64Array([out] UINT32 *value_size, [out, size_is(*value_size)] INT64 **value); + HRESULT GetUInt64Array([out] UINT32 *value_size, [out, size_is(*value_size)] UINT64 **value); + HRESULT GetSingleArray([out] UINT32 *value_size, [out, size_is(*value_size)] FLOAT **value); + HRESULT GetDoubleArray([out] UINT32 *value_size, [out, size_is(*value_size)] DOUBLE **value); + HRESULT GetChar16Array([out] UINT32 *value_size, [out, size_is(*value_size)] WCHAR **value); + HRESULT GetBooleanArray([out] UINT32 *value_size, [out, size_is(*value_size)] boolean **value); + HRESULT GetStringArray([out] UINT32 *value_size, [out, size_is(*value_size)] HSTRING **value); + HRESULT GetInspectableArray([out] UINT32 *value_size, [out, size_is(*value_size)] IInspectable ***value); + HRESULT GetGuidArray([out] UINT32 *value_size, [out, size_is(*value_size)] GUID **value); + HRESULT GetDateTimeArray([out] UINT32 *value_size, [out, size_is(*value_size)] Windows.Foundation.DateTime **value); + HRESULT GetTimeSpanArray([out] UINT32 *value_size, [out, size_is(*value_size)] Windows.Foundation.TimeSpan **value); + HRESULT GetPointArray([out] UINT32 *value_size, [out, size_is(*value_size)] Windows.Foundation.Point **value); + HRESULT GetSizeArray([out] UINT32 *value_size, [out, size_is(*value_size)] Windows.Foundation.Size **value); + HRESULT GetRectArray([out] UINT32 *value_size, [out, size_is(*value_size)] Windows.Foundation.Rect **value); + } + + [ + contract(Windows.Foundation.FoundationContract, 1.0), + exclusiveto(Windows.Foundation.PropertyValue), + uuid(629bdbc8-d932-4ff4-96b9-8d96c5c1e858) + ] + interface IPropertyValueStatics : IInspectable + { + HRESULT CreateEmpty([out, retval] IInspectable **property_value); + HRESULT CreateUInt8([in] BYTE value, [out, retval] IInspectable **property_value); + HRESULT CreateInt16([in] INT16 value, [out, retval] IInspectable **property_value); + HRESULT CreateUInt16([in] UINT16 value, [out, retval] IInspectable **property_value); + HRESULT CreateInt32([in] INT32 value, [out, retval] IInspectable **property_value); + HRESULT CreateUInt32([in] UINT32 value, [out, retval] IInspectable **property_value); + HRESULT CreateInt64([in] INT64 value, [out, retval] IInspectable **property_value); + HRESULT CreateUInt64([in] UINT64 value, [out, retval] IInspectable **property_value); + HRESULT CreateSingle([in] FLOAT value, [out, retval] IInspectable **property_value); + HRESULT CreateDouble([in] DOUBLE value, [out, retval] IInspectable **property_value); + HRESULT CreateChar16([in] WCHAR value, [out, retval] IInspectable **property_value); + HRESULT CreateBoolean([in] boolean value, [out, retval] IInspectable **property_value); + HRESULT CreateString([in] HSTRING value, [out, retval] IInspectable **property_value); + HRESULT CreateInspectable([in] IInspectable *value, [out, retval] IInspectable **property_value); + HRESULT CreateGuid([in] GUID value, [out, retval] IInspectable **property_value); + HRESULT CreateDateTime([in] Windows.Foundation.DateTime value, [out, retval] IInspectable **property_value); + HRESULT CreateTimeSpan([in] Windows.Foundation.TimeSpan value, [out, retval] IInspectable **property_value); + HRESULT CreatePoint([in] Windows.Foundation.Point value, [out, retval] IInspectable **property_value); + HRESULT CreateSize([in] Windows.Foundation.Size value, [out, retval] IInspectable **property_value); + HRESULT CreateRect([in] Windows.Foundation.Rect value, [out, retval] IInspectable **property_value); + HRESULT CreateUInt8Array([in] UINT32 value_size, [in, size_is(value_size)] BYTE *value, [out, retval] IInspectable **property_value); + HRESULT CreateInt16Array([in] UINT32 value_size, [in, size_is(value_size)] INT16 *value, [out, retval] IInspectable **property_value); + HRESULT CreateUInt16Array([in] UINT32 value_size, [in, size_is(value_size)] UINT16 *value, [out, retval] IInspectable **property_value); + HRESULT CreateInt32Array([in] UINT32 value_size, [in, size_is(value_size)] INT32 *value, [out, retval] IInspectable **property_value); + HRESULT CreateUInt32Array([in] UINT32 value_size, [in, size_is(value_size)] UINT32 *value, [out, retval] IInspectable **property_value); + HRESULT CreateInt64Array([in] UINT32 value_size, [in, size_is(value_size)] INT64 *value, [out, retval] IInspectable **property_value); + HRESULT CreateUInt64Array([in] UINT32 value_size, [in, size_is(value_size)] UINT64 *value, [out, retval] IInspectable **property_value); + HRESULT CreateSingleArray([in] UINT32 value_size, [in, size_is(value_size)] FLOAT *value, [out, retval] IInspectable **property_value); + HRESULT CreateDoubleArray([in] UINT32 value_size, [in, size_is(value_size)] DOUBLE *value, [out, retval] IInspectable **property_value); + HRESULT CreateChar16Array([in] UINT32 value_size, [in, size_is(value_size)] WCHAR *value, [out, retval] IInspectable **property_value); + HRESULT CreateBooleanArray([in] UINT32 value_size, [in, size_is(value_size)] boolean *value, [out, retval] IInspectable **property_value); + HRESULT CreateStringArray([in] UINT32 value_size, [in, size_is(value_size)] HSTRING *value, [out, retval] IInspectable **property_value); + HRESULT CreateInspectableArray([in] UINT32 value_size, [in, size_is(value_size)] IInspectable **value, [out, retval] IInspectable **property_value); + HRESULT CreateGuidArray([in] UINT32 value_size, [in, size_is(value_size)] GUID *value, [out, retval] IInspectable **property_value); + HRESULT CreateDateTimeArray([in] UINT32 value_size, [in, size_is(value_size)] Windows.Foundation.DateTime *value, [out, retval] IInspectable **property_value); + HRESULT CreateTimeSpanArray([in] UINT32 value_size, [in, size_is(value_size)] Windows.Foundation.TimeSpan *value, [out, retval] IInspectable **property_value); + HRESULT CreatePointArray([in] UINT32 value_size, [in, size_is(value_size)] Windows.Foundation.Point *value, [out, retval] IInspectable **property_value); + HRESULT CreateSizeArray([in] UINT32 value_size, [in, size_is(value_size)] Windows.Foundation.Size *value, [out, retval] IInspectable **property_value); + HRESULT CreateRectArray([in] UINT32 value_size, [in, size_is(value_size)] Windows.Foundation.Rect *value, [out, retval] IInspectable **property_value); + } + [ contract(Windows.Foundation.UniversalApiContract, 1.0), exclusiveto(Windows.Foundation.Uri), @@ -449,6 +547,16 @@ namespace Windows.Foundation { interface Windows.Foundation.IClosable; }
+ [ + contract(Windows.Foundation.FoundationContract, 1.0), + marshaling_behavior(agile), + static(Windows.Foundation.IPropertyValueStatics, Windows.Foundation.FoundationContract, 1.0), + threading(both) + ] + runtimeclass PropertyValue + { + } + [ activatable(Windows.Foundation.IUriRuntimeClassFactory, Windows.Foundation.UniversalApiContract, 1.0), contract(Windows.Foundation.UniversalApiContract, 1.0),
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 )")
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/wintypes/classes.idl | 6 + dlls/wintypes/main.c | 339 +++++++++++++++++++++++- include/windows.foundation.metadata.idl | 2 + 3 files changed, 346 insertions(+), 1 deletion(-)
diff --git a/dlls/wintypes/classes.idl b/dlls/wintypes/classes.idl index d8ab31e69be..daf3fc62f66 100644 --- a/dlls/wintypes/classes.idl +++ b/dlls/wintypes/classes.idl @@ -20,4 +20,10 @@
#pragma makedep register
+#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +#define DO_NO_IMPORTS +#include "windows.foundation.idl" #include "windows.foundation.metadata.idl" diff --git a/dlls/wintypes/main.c b/dlls/wintypes/main.c index e50beee8a9f..f12acebfb6b 100644 --- a/dlls/wintypes/main.c +++ b/dlls/wintypes/main.c @@ -1,5 +1,5 @@ /* - * Copyright 2022 Zhiyi Zhang for CodeWeavers + * Copyright 2022-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 @@ -29,6 +29,7 @@ #include "activation.h" #include "rometadataresolution.h"
+#define WIDL_using_Windows_Foundation #define WIDL_using_Windows_Foundation_Metadata #include "windows.foundation.metadata.h" #include "wintypes_private.h" @@ -60,6 +61,7 @@ struct wintypes { IActivationFactory IActivationFactory_iface; IApiInformationStatics IApiInformationStatics_iface; + IPropertyValueStatics IPropertyValueStatics_iface; LONG ref; };
@@ -92,6 +94,13 @@ static HRESULT STDMETHODCALLTYPE wintypes_QueryInterface(IActivationFactory *ifa return S_OK; }
+ if (IsEqualGUID(iid, &IID_IPropertyValueStatics)) + { + IUnknown_AddRef(iface); + *out = &impl->IPropertyValueStatics_iface; + return S_OK; + } + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); *out = NULL; return E_NOINTERFACE; @@ -302,10 +311,338 @@ static const struct IApiInformationStaticsVtbl api_information_statics_vtbl = api_information_statics_IsApiContractPresentByMajorAndMinor };
+DEFINE_IINSPECTABLE(property_value_statics, IPropertyValueStatics, struct wintypes, IActivationFactory_iface) + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateEmpty(IPropertyValueStatics *iface, + IInspectable **property_value) +{ + FIXME("iface %p, property_value %p stub!\n", iface, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt8(IPropertyValueStatics *iface, + BYTE value, IInspectable **property_value) +{ + FIXME("iface %p, value %#x, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt16(IPropertyValueStatics *iface, + INT16 value, IInspectable **property_value) +{ + FIXME("iface %p, value %d, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt16(IPropertyValueStatics *iface, + UINT16 value, IInspectable **property_value) +{ + FIXME("iface %p, value %u, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt32(IPropertyValueStatics *iface, + INT32 value, IInspectable **property_value) +{ + FIXME("iface %p, value %d, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt32(IPropertyValueStatics *iface, + UINT32 value, IInspectable **property_value) +{ + FIXME("iface %p, value %u, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt64(IPropertyValueStatics *iface, + INT64 value, IInspectable **property_value) +{ + FIXME("iface %p, value %I64d, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt64(IPropertyValueStatics *iface, + UINT64 value, IInspectable **property_value) +{ + FIXME("iface %p, value %I64u, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateSingle(IPropertyValueStatics *iface, + FLOAT value, IInspectable **property_value) +{ + FIXME("iface %p, value %f, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateDouble(IPropertyValueStatics *iface, + DOUBLE value, IInspectable **property_value) +{ + FIXME("iface %p, value %f, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateChar16(IPropertyValueStatics *iface, + WCHAR value, IInspectable **property_value) +{ + FIXME("iface %p, value %s, property_value %p stub!\n", iface, wine_dbgstr_wn(&value, 1), property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateBoolean(IPropertyValueStatics *iface, + boolean value, IInspectable **property_value) +{ + FIXME("iface %p, value %d, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateString(IPropertyValueStatics *iface, + HSTRING value, IInspectable **property_value) +{ + FIXME("iface %p, value %s, property_value %p stub!\n", iface, debugstr_hstring(value), property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInspectable(IPropertyValueStatics *iface, + IInspectable *value, IInspectable **property_value) +{ + FIXME("iface %p, value %p, property_value %p stub!\n", iface, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateGuid(IPropertyValueStatics *iface, + GUID value, IInspectable **property_value) +{ + FIXME("iface %p, value %s, property_value %p stub!\n", iface, debugstr_guid(&value), property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateDateTime(IPropertyValueStatics *iface, + DateTime value, IInspectable **property_value) +{ + FIXME("iface %p, value %I64d, property_value %p stub!\n", iface, value.UniversalTime, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateTimeSpan(IPropertyValueStatics *iface, + TimeSpan value, IInspectable **property_value) +{ + FIXME("iface %p, value %I64d, property_value %p stub!\n", iface, value.Duration, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreatePoint(IPropertyValueStatics *iface, + Point value, IInspectable **property_value) +{ + FIXME("iface %p, value (%f, %f), property_value %p stub!\n", iface, value.X, value.Y, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateSize(IPropertyValueStatics *iface, + Size value, IInspectable **property_value) +{ + FIXME("iface %p, value (%fx%f), property_value %p stub!\n", iface, value.Width, value.Height, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateRect(IPropertyValueStatics *iface, + Rect value, IInspectable **property_value) +{ + FIXME("iface %p, value (%f, %f %fx%f), property_value %p stub!\n", iface, value.X, value.Y, value.Width, + value.Height, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt8Array(IPropertyValueStatics *iface, + UINT32 value_size, BYTE *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt16Array(IPropertyValueStatics *iface, + UINT32 value_size, INT16 *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt16Array(IPropertyValueStatics *iface, + UINT32 value_size, UINT16 *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt32Array(IPropertyValueStatics *iface, + UINT32 value_size, INT32 *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt32Array(IPropertyValueStatics *iface, + UINT32 value_size, UINT32 *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt64Array(IPropertyValueStatics *iface, + UINT32 value_size, INT64 *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt64Array(IPropertyValueStatics *iface, + UINT32 value_size, UINT64 *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateSingleArray(IPropertyValueStatics *iface, + UINT32 value_size, FLOAT *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateDoubleArray(IPropertyValueStatics *iface, + UINT32 value_size, DOUBLE *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateChar16Array(IPropertyValueStatics *iface, + UINT32 value_size, WCHAR *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateBooleanArray(IPropertyValueStatics *iface, + UINT32 value_size, boolean *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateStringArray(IPropertyValueStatics *iface, + UINT32 value_size, HSTRING *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInspectableArray(IPropertyValueStatics *iface, + UINT32 value_size, IInspectable **value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateGuidArray(IPropertyValueStatics *iface, + UINT32 value_size, GUID *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateDateTimeArray(IPropertyValueStatics *iface, + UINT32 value_size, DateTime *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateTimeSpanArray(IPropertyValueStatics *iface, + UINT32 value_size, TimeSpan *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreatePointArray(IPropertyValueStatics *iface, + UINT32 value_size, Point *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateSizeArray(IPropertyValueStatics *iface, + UINT32 value_size, Size *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_statics_CreateRectArray(IPropertyValueStatics *iface, + UINT32 value_size, Rect *value, IInspectable **property_value) +{ + FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); + return E_NOTIMPL; +} + +static const struct IPropertyValueStaticsVtbl property_value_statics_vtbl = +{ + property_value_statics_QueryInterface, + property_value_statics_AddRef, + property_value_statics_Release, + /* IInspectable methods */ + property_value_statics_GetIids, + property_value_statics_GetRuntimeClassName, + property_value_statics_GetTrustLevel, + /* IPropertyValueStatics methods */ + property_value_statics_CreateEmpty, + property_value_statics_CreateUInt8, + property_value_statics_CreateInt16, + property_value_statics_CreateUInt16, + property_value_statics_CreateInt32, + property_value_statics_CreateUInt32, + property_value_statics_CreateInt64, + property_value_statics_CreateUInt64, + property_value_statics_CreateSingle, + property_value_statics_CreateDouble, + property_value_statics_CreateChar16, + property_value_statics_CreateBoolean, + property_value_statics_CreateString, + property_value_statics_CreateInspectable, + property_value_statics_CreateGuid, + property_value_statics_CreateDateTime, + property_value_statics_CreateTimeSpan, + property_value_statics_CreatePoint, + property_value_statics_CreateSize, + property_value_statics_CreateRect, + property_value_statics_CreateUInt8Array, + property_value_statics_CreateInt16Array, + property_value_statics_CreateUInt16Array, + property_value_statics_CreateInt32Array, + property_value_statics_CreateUInt32Array, + property_value_statics_CreateInt64Array, + property_value_statics_CreateUInt64Array, + property_value_statics_CreateSingleArray, + property_value_statics_CreateDoubleArray, + property_value_statics_CreateChar16Array, + property_value_statics_CreateBooleanArray, + property_value_statics_CreateStringArray, + property_value_statics_CreateInspectableArray, + property_value_statics_CreateGuidArray, + property_value_statics_CreateDateTimeArray, + property_value_statics_CreateTimeSpanArray, + property_value_statics_CreatePointArray, + property_value_statics_CreateSizeArray, + property_value_statics_CreateRectArray, +}; + static struct wintypes wintypes = { {&activation_factory_vtbl}, {&api_information_statics_vtbl}, + {&property_value_statics_vtbl}, 1 };
diff --git a/include/windows.foundation.metadata.idl b/include/windows.foundation.metadata.idl index 9487737e071..6488405aa7a 100644 --- a/include/windows.foundation.metadata.idl +++ b/include/windows.foundation.metadata.idl @@ -20,11 +20,13 @@ #pragma winrt ns_prefix #endif
+#ifndef DO_NO_IMPORTS import "inspectable.idl"; import "asyncinfo.idl"; import "eventtoken.idl"; import "windowscontracts.idl"; import "windows.foundation.idl"; +#endif
namespace Windows.Foundation.Metadata {
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/wintypes/main.c | 501 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 462 insertions(+), 39 deletions(-)
diff --git a/dlls/wintypes/main.c b/dlls/wintypes/main.c index f12acebfb6b..6ad6464c89a 100644 --- a/dlls/wintypes/main.c +++ b/dlls/wintypes/main.c @@ -311,97 +311,520 @@ static const struct IApiInformationStaticsVtbl api_information_statics_vtbl = api_information_statics_IsApiContractPresentByMajorAndMinor };
+struct property_value +{ + IPropertyValue IPropertyValue_iface; + PropertyType type; + void *value; + LONG ref; +}; + +static inline struct property_value *impl_from_IPropertyValue(IPropertyValue *iface) +{ + return CONTAINING_RECORD(iface, struct property_value, IPropertyValue_iface); +} + +#define property_value_get_primitive(type) _property_value_get_primitive(iface, type, value, sizeof(*value)) +static HRESULT _property_value_get_primitive(IPropertyValue *iface, PropertyType type, void *value, size_t size) +{ + struct property_value *impl = impl_from_IPropertyValue(iface); + + if (!value) + return E_POINTER; + + if (impl->type != type) + return TYPE_E_TYPEMISMATCH; + + memcpy(value, impl->value, size); + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE property_value_QueryInterface(IPropertyValue *iface, REFIID riid, void **out) +{ + struct property_value *impl = impl_from_IPropertyValue(iface); + + TRACE("%p, %s, %p\n", impl, debugstr_guid(riid), out); + + if (IsEqualIID(riid, &IID_IUnknown) + || IsEqualIID(riid, &IID_IInspectable) + || IsEqualIID(riid, &IID_IPropertyValue)) + { + IPropertyValue_AddRef(iface); + *out = &impl->IPropertyValue_iface; + return S_OK; + } + + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE property_value_AddRef(IPropertyValue *iface) +{ + struct property_value *impl = impl_from_IPropertyValue(iface); + ULONG refcount = InterlockedIncrement(&impl->ref); + + TRACE("%p, refcount %lu.\n", iface, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE property_value_Release(IPropertyValue *iface) +{ + struct property_value *impl = impl_from_IPropertyValue(iface); + ULONG refcount = InterlockedDecrement(&impl->ref); + + TRACE("%p, refcount %lu.\n", iface, refcount); + + if (!refcount) + { + if (impl->value) + free(impl->value); + free(impl); + } + + return refcount; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetIids(IPropertyValue *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 property_value_GetRuntimeClassName(IPropertyValue *iface, HSTRING *class_name) +{ + FIXME("iface %p, class_name %p stub!\n", iface, class_name); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetTrustLevel(IPropertyValue *iface, TrustLevel *trust_level) +{ + FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_get_Type(IPropertyValue *iface, enum PropertyType *type) +{ + struct property_value *impl = impl_from_IPropertyValue(iface); + + TRACE("iface %p, type %p.\n", iface, type); + + if (!type) + return E_POINTER; + + *type = impl->type; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE property_value_get_IsNumericScalar(IPropertyValue *iface, boolean *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + + *value = FALSE; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetUInt8(IPropertyValue *iface, BYTE *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_UInt8); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetInt16(IPropertyValue *iface, INT16 *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Int16); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetUInt16(IPropertyValue *iface, UINT16 *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_UInt16); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetInt32(IPropertyValue *iface, INT32 *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Int32); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetUInt32(IPropertyValue *iface, UINT32 *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_UInt32); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetInt64(IPropertyValue *iface, INT64 *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Int64); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetUInt64(IPropertyValue *iface, UINT64 *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_UInt64); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetSingle(IPropertyValue *iface, FLOAT *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Single); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetDouble(IPropertyValue *iface, DOUBLE *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Double); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetChar16(IPropertyValue *iface, WCHAR *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Char16); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetBoolean(IPropertyValue *iface, boolean *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Boolean); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetString(IPropertyValue *iface, HSTRING *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_String); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetGuid(IPropertyValue *iface, GUID *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Guid); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetDateTime(IPropertyValue *iface, + struct DateTime *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_DateTime); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetTimeSpan(IPropertyValue *iface, struct TimeSpan *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_TimeSpan); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetPoint(IPropertyValue *iface, struct Point *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Point); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetSize(IPropertyValue *iface, struct Size *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Size); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetRect(IPropertyValue *iface, struct Rect *value) +{ + TRACE("iface %p, value %p.\n", iface, value); + return property_value_get_primitive(PropertyType_Rect); +} + +static HRESULT STDMETHODCALLTYPE property_value_GetUInt8Array(IPropertyValue *iface, UINT32 *value_size, BYTE **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetInt16Array(IPropertyValue *iface, UINT32 *value_size, INT16 **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetUInt16Array(IPropertyValue *iface, UINT32 *value_size, UINT16 **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetInt32Array(IPropertyValue *iface, UINT32 *value_size, INT32 **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetUInt32Array(IPropertyValue *iface, UINT32 *value_size, UINT32 **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetInt64Array(IPropertyValue *iface, UINT32 *value_size, INT64 **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetUInt64Array(IPropertyValue *iface, UINT32 *value_size, UINT64 **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetSingleArray(IPropertyValue *iface, UINT32 *value_size, FLOAT **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetDoubleArray(IPropertyValue *iface, UINT32 *value_size, DOUBLE **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetChar16Array(IPropertyValue *iface, UINT32 *value_size, WCHAR **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetBooleanArray(IPropertyValue *iface, UINT32 *value_size, boolean **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetStringArray(IPropertyValue *iface, UINT32 *value_size, HSTRING **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetInspectableArray(IPropertyValue *iface, UINT32 *value_size, IInspectable ***value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetGuidArray(IPropertyValue *iface, UINT32 *value_size, GUID **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetDateTimeArray(IPropertyValue *iface, UINT32 *value_size, struct DateTime **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetTimeSpanArray(IPropertyValue *iface, UINT32 *value_size, struct TimeSpan **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetPointArray(IPropertyValue *iface, UINT32 *value_size, struct Point **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetSizeArray(IPropertyValue *iface, UINT32 *value_size, struct Size **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE property_value_GetRectArray(IPropertyValue *iface, UINT32 *value_size, struct Rect **value) +{ + FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); + return E_NOTIMPL; +} + +static const struct IPropertyValueVtbl property_value_vtbl = +{ + property_value_QueryInterface, + property_value_AddRef, + property_value_Release, + /* IInspectable methods */ + property_value_GetIids, + property_value_GetRuntimeClassName, + property_value_GetTrustLevel, + /* IPropertyValue methods */ + property_value_get_Type, + property_value_get_IsNumericScalar, + property_value_GetUInt8, + property_value_GetInt16, + property_value_GetUInt16, + property_value_GetInt32, + property_value_GetUInt32, + property_value_GetInt64, + property_value_GetUInt64, + property_value_GetSingle, + property_value_GetDouble, + property_value_GetChar16, + property_value_GetBoolean, + property_value_GetString, + property_value_GetGuid, + property_value_GetDateTime, + property_value_GetTimeSpan, + property_value_GetPoint, + property_value_GetSize, + property_value_GetRect, + property_value_GetUInt8Array, + property_value_GetInt16Array, + property_value_GetUInt16Array, + property_value_GetInt32Array, + property_value_GetUInt32Array, + property_value_GetInt64Array, + property_value_GetUInt64Array, + property_value_GetSingleArray, + property_value_GetDoubleArray, + property_value_GetChar16Array, + property_value_GetBooleanArray, + property_value_GetStringArray, + property_value_GetInspectableArray, + property_value_GetGuidArray, + property_value_GetDateTimeArray, + property_value_GetTimeSpanArray, + property_value_GetPointArray, + property_value_GetSizeArray, + property_value_GetRectArray, +}; + +#define create_primitive_property_value(type) _create_primitive_property_value(type, &value, sizeof(value), property_value) +static HRESULT _create_primitive_property_value(PropertyType type, void *value, size_t size, IInspectable **property_value) +{ + struct property_value *impl; + + if (!value || !property_value) + return E_POINTER; + + impl = calloc(1, sizeof(*impl)); + if (!impl) + return E_OUTOFMEMORY; + + impl->IPropertyValue_iface.lpVtbl = &property_value_vtbl; + impl->type = type; + impl->ref = 1; + if (type != PropertyType_Empty) + { + impl->value = malloc(size); + if (!impl->value) + { + free(impl); + return E_OUTOFMEMORY; + } + memcpy(impl->value, value, size); + } + + *property_value = (IInspectable *)&impl->IPropertyValue_iface; + return S_OK; +} + DEFINE_IINSPECTABLE(property_value_statics, IPropertyValueStatics, struct wintypes, IActivationFactory_iface)
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateEmpty(IPropertyValueStatics *iface, IInspectable **property_value) { - FIXME("iface %p, property_value %p stub!\n", iface, property_value); - return E_NOTIMPL; + TRACE("iface %p, property_value %p.\n", iface, property_value); + + if (!property_value) + return E_POINTER; + + *property_value = NULL; + return S_OK; }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt8(IPropertyValueStatics *iface, BYTE value, IInspectable **property_value) { - FIXME("iface %p, value %#x, property_value %p stub!\n", iface, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %#x, property_value %p.\n", iface, value, property_value); + return create_primitive_property_value(PropertyType_UInt8); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt16(IPropertyValueStatics *iface, INT16 value, IInspectable **property_value) { - FIXME("iface %p, value %d, property_value %p stub!\n", iface, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %d, property_value %p.\n", iface, value, property_value); + return create_primitive_property_value(PropertyType_Int16); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt16(IPropertyValueStatics *iface, UINT16 value, IInspectable **property_value) { - FIXME("iface %p, value %u, property_value %p stub!\n", iface, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %u, property_value %p.\n", iface, value, property_value); + return create_primitive_property_value(PropertyType_UInt16); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt32(IPropertyValueStatics *iface, INT32 value, IInspectable **property_value) { - FIXME("iface %p, value %d, property_value %p stub!\n", iface, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %d, property_value %p.\n", iface, value, property_value); + return create_primitive_property_value(PropertyType_Int32); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt32(IPropertyValueStatics *iface, UINT32 value, IInspectable **property_value) { - FIXME("iface %p, value %u, property_value %p stub!\n", iface, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %u, property_value %p.\n", iface, value, property_value); + return create_primitive_property_value(PropertyType_UInt32); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt64(IPropertyValueStatics *iface, INT64 value, IInspectable **property_value) { - FIXME("iface %p, value %I64d, property_value %p stub!\n", iface, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %I64d, property_value %p.\n", iface, value, property_value); + return create_primitive_property_value(PropertyType_Int64); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt64(IPropertyValueStatics *iface, UINT64 value, IInspectable **property_value) { - FIXME("iface %p, value %I64u, property_value %p stub!\n", iface, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %I64u, property_value %p.\n", iface, value, property_value); + return create_primitive_property_value(PropertyType_UInt64); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateSingle(IPropertyValueStatics *iface, FLOAT value, IInspectable **property_value) { - FIXME("iface %p, value %f, property_value %p stub!\n", iface, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %f, property_value %p.\n", iface, value, property_value); + return create_primitive_property_value(PropertyType_Single); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateDouble(IPropertyValueStatics *iface, DOUBLE value, IInspectable **property_value) { - FIXME("iface %p, value %f, property_value %p stub!\n", iface, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %f, property_value %p.\n", iface, value, property_value); + return create_primitive_property_value(PropertyType_Double); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateChar16(IPropertyValueStatics *iface, WCHAR value, IInspectable **property_value) { - FIXME("iface %p, value %s, property_value %p stub!\n", iface, wine_dbgstr_wn(&value, 1), property_value); - return E_NOTIMPL; + TRACE("iface %p, value %s, property_value %p.\n", iface, wine_dbgstr_wn(&value, 1), property_value); + return create_primitive_property_value(PropertyType_Char16); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateBoolean(IPropertyValueStatics *iface, boolean value, IInspectable **property_value) { - FIXME("iface %p, value %d, property_value %p stub!\n", iface, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %d, property_value %p.\n", iface, value, property_value); + return create_primitive_property_value(PropertyType_Boolean); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateString(IPropertyValueStatics *iface, HSTRING value, IInspectable **property_value) { - FIXME("iface %p, value %s, property_value %p stub!\n", iface, debugstr_hstring(value), property_value); - return E_NOTIMPL; + TRACE("iface %p, value %s, property_value %p.\n", iface, debugstr_hstring(value), property_value); + return create_primitive_property_value(PropertyType_String); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInspectable(IPropertyValueStatics *iface, @@ -414,44 +837,44 @@ static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInspectable(IPrope static HRESULT STDMETHODCALLTYPE property_value_statics_CreateGuid(IPropertyValueStatics *iface, GUID value, IInspectable **property_value) { - FIXME("iface %p, value %s, property_value %p stub!\n", iface, debugstr_guid(&value), property_value); - return E_NOTIMPL; + TRACE("iface %p, value %s, property_value %p.\n", iface, wine_dbgstr_guid(&value), property_value); + return create_primitive_property_value(PropertyType_Guid); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateDateTime(IPropertyValueStatics *iface, DateTime value, IInspectable **property_value) { - FIXME("iface %p, value %I64d, property_value %p stub!\n", iface, value.UniversalTime, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %I64d, property_value %p.\n", iface, value.UniversalTime, property_value); + return create_primitive_property_value(PropertyType_DateTime); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateTimeSpan(IPropertyValueStatics *iface, TimeSpan value, IInspectable **property_value) { - FIXME("iface %p, value %I64d, property_value %p stub!\n", iface, value.Duration, property_value); - return E_NOTIMPL; + TRACE("iface %p, value %I64d, property_value %p.\n", iface, value.Duration, property_value); + return create_primitive_property_value(PropertyType_TimeSpan); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreatePoint(IPropertyValueStatics *iface, Point value, IInspectable **property_value) { - FIXME("iface %p, value (%f, %f), property_value %p stub!\n", iface, value.X, value.Y, property_value); - return E_NOTIMPL; + TRACE("iface %p, value (%f, %f), property_value %p.\n", iface, value.X, value.Y, property_value); + return create_primitive_property_value(PropertyType_Point); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateSize(IPropertyValueStatics *iface, Size value, IInspectable **property_value) { - FIXME("iface %p, value (%fx%f), property_value %p stub!\n", iface, value.Width, value.Height, property_value); - return E_NOTIMPL; + TRACE("iface %p, value (%fx%f), property_value %p.\n", iface, value.Width, value.Height, property_value); + return create_primitive_property_value(PropertyType_Size); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateRect(IPropertyValueStatics *iface, Rect value, IInspectable **property_value) { - FIXME("iface %p, value (%f, %f %fx%f), property_value %p stub!\n", iface, value.X, value.Y, value.Width, - value.Height, property_value); - return E_NOTIMPL; + TRACE("iface %p, value (%f, %f %fx%f), property_value %p.\n", iface, value.X, value.Y, + value.Width, value.Height, property_value); + return create_primitive_property_value(PropertyType_Rect); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt8Array(IPropertyValueStatics *iface,
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/wintypes/main.c | 172 ++++++++++++++++++++++++------------------- 1 file changed, 96 insertions(+), 76 deletions(-)
diff --git a/dlls/wintypes/main.c b/dlls/wintypes/main.c index 6ad6464c89a..bcc5c97341a 100644 --- a/dlls/wintypes/main.c +++ b/dlls/wintypes/main.c @@ -315,6 +315,7 @@ struct property_value { IPropertyValue IPropertyValue_iface; PropertyType type; + unsigned int value_size; void *value; LONG ref; }; @@ -339,6 +340,22 @@ static HRESULT _property_value_get_primitive(IPropertyValue *iface, PropertyType return S_OK; }
+#define property_value_get_primitive_array(type) _property_value_get_primitive_array(iface, type, value_size, (void **)value) +static HRESULT _property_value_get_primitive_array(IPropertyValue *iface, PropertyType type, unsigned int *value_size, void **value) +{ + struct property_value *impl = impl_from_IPropertyValue(iface); + + if (!value_size || !value) + return E_POINTER; + + if (impl->type != type) + return TYPE_E_TYPEMISMATCH; + + *value_size = impl->value_size; + *value = impl->value; + return S_OK; +} + static HRESULT STDMETHODCALLTYPE property_value_QueryInterface(IPropertyValue *iface, REFIID riid, void **out) { struct property_value *impl = impl_from_IPropertyValue(iface); @@ -536,74 +553,74 @@ static HRESULT STDMETHODCALLTYPE property_value_GetRect(IPropertyValue *iface, s
static HRESULT STDMETHODCALLTYPE property_value_GetUInt8Array(IPropertyValue *iface, UINT32 *value_size, BYTE **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_UInt8Array); }
static HRESULT STDMETHODCALLTYPE property_value_GetInt16Array(IPropertyValue *iface, UINT32 *value_size, INT16 **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_Int16Array); }
static HRESULT STDMETHODCALLTYPE property_value_GetUInt16Array(IPropertyValue *iface, UINT32 *value_size, UINT16 **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_UInt16Array); }
static HRESULT STDMETHODCALLTYPE property_value_GetInt32Array(IPropertyValue *iface, UINT32 *value_size, INT32 **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_Int32Array); }
static HRESULT STDMETHODCALLTYPE property_value_GetUInt32Array(IPropertyValue *iface, UINT32 *value_size, UINT32 **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_UInt32Array); }
static HRESULT STDMETHODCALLTYPE property_value_GetInt64Array(IPropertyValue *iface, UINT32 *value_size, INT64 **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_Int64Array); }
static HRESULT STDMETHODCALLTYPE property_value_GetUInt64Array(IPropertyValue *iface, UINT32 *value_size, UINT64 **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_UInt64Array); }
static HRESULT STDMETHODCALLTYPE property_value_GetSingleArray(IPropertyValue *iface, UINT32 *value_size, FLOAT **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_SingleArray); }
static HRESULT STDMETHODCALLTYPE property_value_GetDoubleArray(IPropertyValue *iface, UINT32 *value_size, DOUBLE **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_DoubleArray); }
static HRESULT STDMETHODCALLTYPE property_value_GetChar16Array(IPropertyValue *iface, UINT32 *value_size, WCHAR **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_Char16Array); }
static HRESULT STDMETHODCALLTYPE property_value_GetBooleanArray(IPropertyValue *iface, UINT32 *value_size, boolean **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_BooleanArray); }
static HRESULT STDMETHODCALLTYPE property_value_GetStringArray(IPropertyValue *iface, UINT32 *value_size, HSTRING **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_StringArray); }
static HRESULT STDMETHODCALLTYPE property_value_GetInspectableArray(IPropertyValue *iface, UINT32 *value_size, IInspectable ***value) @@ -614,38 +631,38 @@ static HRESULT STDMETHODCALLTYPE property_value_GetInspectableArray(IPropertyVal
static HRESULT STDMETHODCALLTYPE property_value_GetGuidArray(IPropertyValue *iface, UINT32 *value_size, GUID **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_GuidArray); }
static HRESULT STDMETHODCALLTYPE property_value_GetDateTimeArray(IPropertyValue *iface, UINT32 *value_size, struct DateTime **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_DateTimeArray); }
static HRESULT STDMETHODCALLTYPE property_value_GetTimeSpanArray(IPropertyValue *iface, UINT32 *value_size, struct TimeSpan **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_TimeSpanArray); }
static HRESULT STDMETHODCALLTYPE property_value_GetPointArray(IPropertyValue *iface, UINT32 *value_size, struct Point **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_PointArray); }
static HRESULT STDMETHODCALLTYPE property_value_GetSizeArray(IPropertyValue *iface, UINT32 *value_size, struct Size **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_SizeArray); }
static HRESULT STDMETHODCALLTYPE property_value_GetRectArray(IPropertyValue *iface, UINT32 *value_size, struct Rect **value) { - FIXME("iface %p, value_size %p, value %p stub!\n", iface, value_size, value); - return E_NOTIMPL; + TRACE("iface %p, value_size %p, value %p.\n", iface, value_size, value); + return property_value_get_primitive_array(PropertyType_RectArray); }
static const struct IPropertyValueVtbl property_value_vtbl = @@ -699,8 +716,10 @@ static const struct IPropertyValueVtbl property_value_vtbl = property_value_GetRectArray, };
-#define create_primitive_property_value(type) _create_primitive_property_value(type, &value, sizeof(value), property_value) -static HRESULT _create_primitive_property_value(PropertyType type, void *value, size_t size, IInspectable **property_value) +#define create_primitive_property_value(type) _create_primitive_property_value(type, &value, 1, sizeof(value), property_value) +#define create_primitive_property_value_array(type) _create_primitive_property_value(type, value, value_size, sizeof(*value), property_value) +static HRESULT _create_primitive_property_value(PropertyType type, void *value, + unsigned int count, size_t unit_size, IInspectable **property_value) { struct property_value *impl;
@@ -716,13 +735,14 @@ static HRESULT _create_primitive_property_value(PropertyType type, void *value, impl->ref = 1; if (type != PropertyType_Empty) { - impl->value = malloc(size); + impl->value = malloc(unit_size * count); if (!impl->value) { free(impl); return E_OUTOFMEMORY; } - memcpy(impl->value, value, size); + memcpy(impl->value, value, unit_size * count); + impl->value_size = count; }
*property_value = (IInspectable *)&impl->IPropertyValue_iface; @@ -880,85 +900,85 @@ static HRESULT STDMETHODCALLTYPE property_value_statics_CreateRect(IPropertyValu static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt8Array(IPropertyValueStatics *iface, UINT32 value_size, BYTE *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_UInt8Array); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt16Array(IPropertyValueStatics *iface, UINT32 value_size, INT16 *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_Int16Array); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt16Array(IPropertyValueStatics *iface, UINT32 value_size, UINT16 *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_UInt16Array); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt32Array(IPropertyValueStatics *iface, UINT32 value_size, INT32 *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_Int32Array); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt32Array(IPropertyValueStatics *iface, UINT32 value_size, UINT32 *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_UInt32Array); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInt64Array(IPropertyValueStatics *iface, UINT32 value_size, INT64 *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_Int64Array); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateUInt64Array(IPropertyValueStatics *iface, UINT32 value_size, UINT64 *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_UInt64Array); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateSingleArray(IPropertyValueStatics *iface, UINT32 value_size, FLOAT *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_SingleArray); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateDoubleArray(IPropertyValueStatics *iface, UINT32 value_size, DOUBLE *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_DoubleArray); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateChar16Array(IPropertyValueStatics *iface, UINT32 value_size, WCHAR *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_Char16Array); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateBooleanArray(IPropertyValueStatics *iface, UINT32 value_size, boolean *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_BooleanArray); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateStringArray(IPropertyValueStatics *iface, UINT32 value_size, HSTRING *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_StringArray); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInspectableArray(IPropertyValueStatics *iface, @@ -971,43 +991,43 @@ static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInspectableArray(I static HRESULT STDMETHODCALLTYPE property_value_statics_CreateGuidArray(IPropertyValueStatics *iface, UINT32 value_size, GUID *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_GuidArray); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateDateTimeArray(IPropertyValueStatics *iface, UINT32 value_size, DateTime *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_DateTimeArray); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateTimeSpanArray(IPropertyValueStatics *iface, UINT32 value_size, TimeSpan *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_TimeSpanArray); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreatePointArray(IPropertyValueStatics *iface, UINT32 value_size, Point *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_PointArray); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateSizeArray(IPropertyValueStatics *iface, UINT32 value_size, Size *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_SizeArray); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateRectArray(IPropertyValueStatics *iface, UINT32 value_size, Rect *value, IInspectable **property_value) { - FIXME("iface %p, value_size %u, value %p, property_value %p stub!\n", iface, value_size, value, property_value); - return E_NOTIMPL; + TRACE("iface %p, value_size %u, value %p, property_value %p.\n", iface, value_size, value, property_value); + return create_primitive_property_value_array(PropertyType_RectArray); }
static const struct IPropertyValueStaticsVtbl property_value_statics_vtbl =
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/wintypes/main.c | 54 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/dlls/wintypes/main.c b/dlls/wintypes/main.c index bcc5c97341a..1a61caccc1b 100644 --- a/dlls/wintypes/main.c +++ b/dlls/wintypes/main.c @@ -314,6 +314,10 @@ static const struct IApiInformationStaticsVtbl api_information_statics_vtbl = struct property_value { IPropertyValue IPropertyValue_iface; + union + { + IReference_boolean boolean_iface; + } irefs; PropertyType type; unsigned int value_size; void *value; @@ -325,6 +329,11 @@ static inline struct property_value *impl_from_IPropertyValue(IPropertyValue *if return CONTAINING_RECORD(iface, struct property_value, IPropertyValue_iface); }
+static inline struct property_value *impl_from_IInspectable(IInspectable *iface) +{ + return CONTAINING_RECORD(iface, struct property_value, IPropertyValue_iface); +} + #define property_value_get_primitive(type) _property_value_get_primitive(iface, type, value, sizeof(*value)) static HRESULT _property_value_get_primitive(IPropertyValue *iface, PropertyType type, void *value, size_t size) { @@ -370,6 +379,12 @@ static HRESULT STDMETHODCALLTYPE property_value_QueryInterface(IPropertyValue *i *out = &impl->IPropertyValue_iface; return S_OK; } + else if (IsEqualIID(riid, &IID_IReference_boolean) && impl->type == PropertyType_Boolean) + { + IReference_boolean_AddRef(&impl->irefs.boolean_iface); + *out = &impl->irefs.boolean_iface; + return S_OK; + }
FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); *out = NULL; @@ -749,6 +764,43 @@ static HRESULT _create_primitive_property_value(PropertyType type, void *value, return S_OK; }
+#define create_primitive_property_value_iref(type, iref_vtbl, vtbl) \ + do \ + { \ + HRESULT hr = create_primitive_property_value(type); \ + if (hr == S_OK) \ + { \ + struct property_value *value_impl = impl_from_IInspectable(*property_value); \ + value_impl->iref_vtbl = &vtbl; \ + } \ + return hr; \ + } while (0) + +DEFINE_IINSPECTABLE_(iref_boolean, IReference_boolean, struct property_value, + impl_from_IReference_boolean, irefs.boolean_iface, &impl->IPropertyValue_iface); + +static HRESULT STDMETHODCALLTYPE iref_boolean_get_Value(IReference_boolean *iface, boolean *value) +{ + struct property_value *impl = impl_from_IReference_boolean(iface); + + TRACE("iface %p, value %p.\n", iface, value); + + return property_value_GetBoolean(&impl->IPropertyValue_iface, value); +} + +static const struct IReference_booleanVtbl iref_boolean_vtbl = +{ + iref_boolean_QueryInterface, + iref_boolean_AddRef, + iref_boolean_Release, + /* IInspectable methods */ + iref_boolean_GetIids, + iref_boolean_GetRuntimeClassName, + iref_boolean_GetTrustLevel, + /* IReference<boolean> methods */ + iref_boolean_get_Value, +}; + DEFINE_IINSPECTABLE(property_value_statics, IPropertyValueStatics, struct wintypes, IActivationFactory_iface)
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateEmpty(IPropertyValueStatics *iface, @@ -837,7 +889,7 @@ static HRESULT STDMETHODCALLTYPE property_value_statics_CreateBoolean(IPropertyV boolean value, IInspectable **property_value) { TRACE("iface %p, value %d, property_value %p.\n", iface, value, property_value); - return create_primitive_property_value(PropertyType_Boolean); + create_primitive_property_value_iref(PropertyType_Boolean, irefs.boolean_iface.lpVtbl, iref_boolean_vtbl); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateString(IPropertyValueStatics *iface,
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/wintypes/main.c | 34 +++++++++++++++++++++++++++++- dlls/wintypes/wintypes_private.idl | 10 +++++++++ 2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/dlls/wintypes/main.c b/dlls/wintypes/main.c index 1a61caccc1b..8497be1564e 100644 --- a/dlls/wintypes/main.c +++ b/dlls/wintypes/main.c @@ -317,6 +317,7 @@ struct property_value union { IReference_boolean boolean_iface; + IReference_HSTRING hstring_iface; } irefs; PropertyType type; unsigned int value_size; @@ -385,6 +386,12 @@ static HRESULT STDMETHODCALLTYPE property_value_QueryInterface(IPropertyValue *i *out = &impl->irefs.boolean_iface; return S_OK; } + else if (IsEqualIID(riid, &IID_IReference_HSTRING) && impl->type == PropertyType_String) + { + IReference_HSTRING_AddRef(&impl->irefs.hstring_iface); + *out = &impl->irefs.hstring_iface; + return S_OK; + }
FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); *out = NULL; @@ -801,6 +808,31 @@ static const struct IReference_booleanVtbl iref_boolean_vtbl = iref_boolean_get_Value, };
+DEFINE_IINSPECTABLE_(iref_hstring, IReference_HSTRING, struct property_value, + impl_from_IReference_HSTRING, irefs.hstring_iface, &impl->IPropertyValue_iface); + +static HRESULT STDMETHODCALLTYPE iref_hstring_get_Value(IReference_HSTRING *iface, HSTRING *value) +{ + struct property_value *impl = impl_from_IReference_HSTRING(iface); + + TRACE("iface %p, value %p.\n", iface, value); + + return property_value_GetString(&impl->IPropertyValue_iface, value); +} + +static const struct IReference_HSTRINGVtbl iref_hstring_vtbl = +{ + iref_hstring_QueryInterface, + iref_hstring_AddRef, + iref_hstring_Release, + /* IInspectable methods */ + iref_hstring_GetIids, + iref_hstring_GetRuntimeClassName, + iref_hstring_GetTrustLevel, + /* IReference<HSTRING> methods */ + iref_hstring_get_Value, +}; + DEFINE_IINSPECTABLE(property_value_statics, IPropertyValueStatics, struct wintypes, IActivationFactory_iface)
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateEmpty(IPropertyValueStatics *iface, @@ -896,7 +928,7 @@ static HRESULT STDMETHODCALLTYPE property_value_statics_CreateString(IPropertyVa HSTRING value, IInspectable **property_value) { TRACE("iface %p, value %s, property_value %p.\n", iface, debugstr_hstring(value), property_value); - return create_primitive_property_value(PropertyType_String); + create_primitive_property_value_iref(PropertyType_String, irefs.hstring_iface.lpVtbl, iref_hstring_vtbl); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateInspectable(IPropertyValueStatics *iface, diff --git a/dlls/wintypes/wintypes_private.idl b/dlls/wintypes/wintypes_private.idl index 87ccd81c228..b0d7b7d2241 100644 --- a/dlls/wintypes/wintypes_private.idl +++ b/dlls/wintypes/wintypes_private.idl @@ -18,6 +18,16 @@
#pragma makedep header
+#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "windows.foundation.idl"; + +declare { + interface Windows.Foundation.IReference<HSTRING>; +} + 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(" { \")
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/wintypes/main.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/dlls/wintypes/main.c b/dlls/wintypes/main.c index 8497be1564e..ac4214b486f 100644 --- a/dlls/wintypes/main.c +++ b/dlls/wintypes/main.c @@ -317,6 +317,7 @@ struct property_value union { IReference_boolean boolean_iface; + IReference_DOUBLE double_iface; IReference_HSTRING hstring_iface; } irefs; PropertyType type; @@ -386,6 +387,12 @@ static HRESULT STDMETHODCALLTYPE property_value_QueryInterface(IPropertyValue *i *out = &impl->irefs.boolean_iface; return S_OK; } + else if (IsEqualIID(riid, &IID_IReference_DOUBLE) && impl->type == PropertyType_Double) + { + IReference_DOUBLE_AddRef(&impl->irefs.double_iface); + *out = &impl->irefs.double_iface; + return S_OK; + } else if (IsEqualIID(riid, &IID_IReference_HSTRING) && impl->type == PropertyType_String) { IReference_HSTRING_AddRef(&impl->irefs.hstring_iface); @@ -833,6 +840,31 @@ static const struct IReference_HSTRINGVtbl iref_hstring_vtbl = iref_hstring_get_Value, };
+DEFINE_IINSPECTABLE_(iref_double, IReference_DOUBLE, struct property_value, + impl_from_IReference_DOUBLE, irefs.double_iface, &impl->IPropertyValue_iface); + +static HRESULT STDMETHODCALLTYPE iref_double_get_Value(IReference_DOUBLE *iface, DOUBLE *value) +{ + struct property_value *impl = impl_from_IReference_DOUBLE(iface); + + TRACE("iface %p, value %p.\n", iface, value); + + return property_value_GetDouble(&impl->IPropertyValue_iface, value); +} + +static const struct IReference_DOUBLEVtbl iref_double_vtbl = +{ + iref_double_QueryInterface, + iref_double_AddRef, + iref_double_Release, + /* IInspectable methods */ + iref_double_GetIids, + iref_double_GetRuntimeClassName, + iref_double_GetTrustLevel, + /* IReference<DOUBLE> methods */ + iref_double_get_Value, +}; + DEFINE_IINSPECTABLE(property_value_statics, IPropertyValueStatics, struct wintypes, IActivationFactory_iface)
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateEmpty(IPropertyValueStatics *iface, @@ -907,7 +939,7 @@ static HRESULT STDMETHODCALLTYPE property_value_statics_CreateDouble(IPropertyVa DOUBLE value, IInspectable **property_value) { TRACE("iface %p, value %f, property_value %p.\n", iface, value, property_value); - return create_primitive_property_value(PropertyType_Double); + create_primitive_property_value_iref(PropertyType_Double, irefs.double_iface.lpVtbl, iref_double_vtbl); }
static HRESULT STDMETHODCALLTYPE property_value_statics_CreateChar16(IPropertyValueStatics *iface,
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/wintypes/tests/Makefile.in | 3 +- dlls/wintypes/tests/wintypes.c | 298 ++++++++++++++++++++++++++ dlls/wintypes/tests/wintypes_test.idl | 29 +++ 3 files changed, 329 insertions(+), 1 deletion(-) create mode 100644 dlls/wintypes/tests/wintypes_test.idl
diff --git a/dlls/wintypes/tests/Makefile.in b/dlls/wintypes/tests/Makefile.in index 2f667a48085..e177cd8b42b 100644 --- a/dlls/wintypes/tests/Makefile.in +++ b/dlls/wintypes/tests/Makefile.in @@ -2,4 +2,5 @@ TESTDLL = wintypes.dll IMPORTS = combase uuid
SOURCES = \ - wintypes.c + wintypes.c \ + wintypes_test.idl diff --git a/dlls/wintypes/tests/wintypes.c b/dlls/wintypes/tests/wintypes.c index 0703582d325..ff98774ef8c 100644 --- a/dlls/wintypes/tests/wintypes.c +++ b/dlls/wintypes/tests/wintypes.c @@ -26,8 +26,10 @@ #include "initguid.h" #include "roapi.h"
+#define WIDL_using_Windows_Foundation #define WIDL_using_Windows_Foundation_Metadata #include "windows.foundation.metadata.h" +#include "wintypes_test.h"
#include "wine/test.h"
@@ -457,7 +459,303 @@ static void test_IApiInformationStatics(void) RoUninitialize(); }
+static void test_IPropertyValueStatics(void) +{ + static const WCHAR *class_name = L"Windows.Foundation.PropertyValue"; + static const BYTE byte_value = 0x12; + static const INT16 int16_value = 0x1234; + static const UINT16 uint16_value = 0x1234; + static const INT32 int32_value= 0x1234abcd; + static const UINT32 uint32_value = 0x1234abcd; + static const INT64 int64_value = 0x12345678abcdef; + static const UINT64 uint64_value = 0x12345678abcdef; + static const FLOAT float_value = 1.5; + static const DOUBLE double_value = 1.5; + static const WCHAR wchar_value = 0x1234; + static const boolean boolean_value = TRUE; + static const struct DateTime datetime_value = {0x12345678abcdef}; + static const struct TimeSpan timespan_value = {0x12345678abcdef}; + static const struct Point point_value = {1, 2}; + static const struct Size size_value = {1, 2}; + static const struct Rect rect_value = {1, 2, 3, 4}; + IAgileObject *agile_object = NULL, *tmp_agile_object = NULL; + IInspectable *inspectable = NULL, *tmp_inspectable = NULL; + IPropertyValueStatics *statics = NULL; + IActivationFactory *factory = NULL; + IReference_boolean *iref_boolean; + IReference_HSTRING *iref_hstring; + IReference_DOUBLE *iref_double; + IPropertyValue *value = NULL; + enum PropertyType type; + unsigned int i, count; + BYTE byte, *ptr_byte; + HSTRING str, ret_str; + DOUBLE ret_double; + boolean ret; + HRESULT hr; + + hr = RoInitialize(RO_INIT_MULTITHREADED); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = WindowsCreateString(class_name, wcslen(class_name), &str); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory); + ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG), "RoGetActivationFactory failed, hr %#lx.\n", hr); + if (hr == REGDB_E_CLASSNOTREG) + { + win_skip("%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w(class_name)); + WindowsDeleteString(str); + RoUninitialize(); + return; + } + + hr = IActivationFactory_QueryInterface(factory, &IID_IInspectable, (void **)&inspectable); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = IActivationFactory_QueryInterface(factory, &IID_IAgileObject, (void **)&agile_object); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = IActivationFactory_QueryInterface(factory, &IID_IPropertyValueStatics, (void **)&statics); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValueStatics_QueryInterface(statics, &IID_IInspectable, (void **)&tmp_inspectable); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(tmp_inspectable == inspectable, "QueryInterface IID_IInspectable returned %p, expected %p.\n", + tmp_inspectable, inspectable); + IInspectable_Release(tmp_inspectable); + IInspectable_Release(inspectable); + + hr = IPropertyValueStatics_QueryInterface(statics, &IID_IAgileObject, (void **)&tmp_agile_object); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(tmp_agile_object == agile_object, "QueryInterface IID_IAgileObject returned %p, expected %p.\n", + tmp_agile_object, agile_object); + IAgileObject_Release(tmp_agile_object); + IAgileObject_Release(agile_object); + + /* Parameter checks */ + hr = IPropertyValueStatics_CreateUInt8(statics, 0x12, NULL); + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValueStatics_CreateUInt8(statics, 0x12, &inspectable); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = IInspectable_QueryInterface(inspectable, &IID_IPropertyValue, (void **)&value); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(value == (IPropertyValue *)inspectable, "Expected the same pointer.\n"); + IInspectable_Release(inspectable); + + hr = IPropertyValue_get_Type(value, NULL); + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValue_GetBoolean(value, NULL); + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValue_GetBoolean(value, &ret); + ok(hr == TYPE_E_TYPEMISMATCH, "Got unexpected hr %#lx.\n", hr); + + IPropertyValue_Release(value); + + /* Parameter checks for array types */ + hr = IPropertyValueStatics_CreateUInt8Array(statics, 1, NULL, &inspectable); + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValueStatics_CreateUInt8Array(statics, 1, &byte, NULL); + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValueStatics_CreateUInt8Array(statics, 1, &byte, &inspectable); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = IInspectable_QueryInterface(inspectable, &IID_IPropertyValue, (void **)&value); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(value == (IPropertyValue *)inspectable, "Expected the same pointer.\n"); + IInspectable_Release(inspectable); + + hr = IPropertyValue_get_Type(value, NULL); + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValue_GetBoolean(value, NULL); + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValue_GetBoolean(value, &ret); + ok(hr == TYPE_E_TYPEMISMATCH, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValue_GetUInt8Array(value, NULL, &ptr_byte); + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValue_GetUInt8Array(value, &count, NULL); + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); + + hr = IPropertyValue_GetUInt8Array(value, &count, &ptr_byte); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + IPropertyValue_Release(value); + + /* PropertyType_Empty */ + hr = IPropertyValueStatics_CreateEmpty(statics, NULL); + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); + + inspectable = (IInspectable *)0xdeadbeef; + hr = IPropertyValueStatics_CreateEmpty(statics, &inspectable); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(inspectable == NULL, "Got unexpected inspectable.\n"); + + /* Test a single property value */ +#define TEST_PROPERTY_VALUE(PROPERTY_TYPE, TYPE, VALUE) \ + do \ + { \ + TYPE expected_value; \ + \ + inspectable = NULL; \ + hr = IPropertyValueStatics_Create##PROPERTY_TYPE(statics, VALUE, &inspectable); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + ok(inspectable != NULL, "Got unexpected inspectable.\n"); \ + \ + hr = IInspectable_QueryInterface(inspectable, &IID_IPropertyValue, (void **)&value); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + IInspectable_Release(inspectable); \ + \ + hr = IPropertyValue_get_Type(value, &type); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + ok(type == PropertyType_##PROPERTY_TYPE, "Got unexpected type %d.\n", \ + PropertyType_##PROPERTY_TYPE); \ + \ + ret = TRUE; \ + hr = IPropertyValue_get_IsNumericScalar(value, &ret); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + ok(ret == FALSE, "Expected not numeric scalar.\n"); \ + \ + hr = IPropertyValue_Get##PROPERTY_TYPE(value, &expected_value); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + ok(!memcmp(&VALUE, &expected_value, sizeof(VALUE)), "Got unexpected value.\n"); \ + \ + IPropertyValue_Release(value); \ + } while (0); + + TEST_PROPERTY_VALUE(UInt8, BYTE, byte_value) + TEST_PROPERTY_VALUE(Int16, INT16, int16_value) + TEST_PROPERTY_VALUE(UInt16, UINT16, uint16_value) + TEST_PROPERTY_VALUE(Int32, INT32, int32_value) + TEST_PROPERTY_VALUE(UInt32, UINT32, uint32_value) + TEST_PROPERTY_VALUE(Int64, INT64, int64_value) + TEST_PROPERTY_VALUE(UInt64, UINT64, uint64_value) + TEST_PROPERTY_VALUE(Single, FLOAT, float_value) + TEST_PROPERTY_VALUE(Double, DOUBLE, double_value) + TEST_PROPERTY_VALUE(Char16, WCHAR, wchar_value) + TEST_PROPERTY_VALUE(Boolean, boolean, boolean_value) + TEST_PROPERTY_VALUE(String, HSTRING, str) + TEST_PROPERTY_VALUE(DateTime, DateTime, datetime_value) + TEST_PROPERTY_VALUE(TimeSpan, TimeSpan, timespan_value) + TEST_PROPERTY_VALUE(Guid, GUID, IID_IPropertyValue) + TEST_PROPERTY_VALUE(Point, Point, point_value) + TEST_PROPERTY_VALUE(Size, Size, size_value) + TEST_PROPERTY_VALUE(Rect, Rect, rect_value) + +#undef TEST_PROPERTY_VALUE + + /* Test property value array */ +#define TEST_PROPERTY_COUNT 2 +#define TEST_PROPERTY_VALUE_ARRAY(PROPERTY_TYPE, TYPE, VALUE) \ + do \ + { \ + TYPE values[TEST_PROPERTY_COUNT], *expected_values; \ + \ + for (i = 0; i < TEST_PROPERTY_COUNT; i++) \ + memcpy(&values[i], &VALUE, sizeof(VALUE)); \ + \ + hr = IPropertyValueStatics_Create##PROPERTY_TYPE(statics, TEST_PROPERTY_COUNT, values, \ + NULL); \ + ok(hr == E_POINTER, "Got unexpected hr %#lx.\n", hr); \ + \ + inspectable = NULL; \ + hr = IPropertyValueStatics_Create##PROPERTY_TYPE(statics, TEST_PROPERTY_COUNT, values, \ + &inspectable); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + ok(inspectable != NULL, "Got unexpected inspectable.\n"); \ + \ + hr = IInspectable_QueryInterface(inspectable, &IID_IPropertyValue, (void **)&value); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + IInspectable_Release(inspectable); \ + \ + hr = IPropertyValue_get_Type(value, &type); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + ok(type == PropertyType_##PROPERTY_TYPE, "Got unexpected type %d.\n", \ + PropertyType_##PROPERTY_TYPE); \ + \ + ret = TRUE; \ + hr = IPropertyValue_get_IsNumericScalar(value, &ret); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + ok(ret == FALSE, "Expected not numeric scalar.\n"); \ + \ + count = 0; \ + hr = IPropertyValue_Get##PROPERTY_TYPE(value, &count, &expected_values); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + ok(count == TEST_PROPERTY_COUNT, "Got unexpected count %u.\n", count); \ + ok(expected_values != values, "Got same pointer.\n"); \ + for (i = 0; i < TEST_PROPERTY_COUNT; i++) \ + ok(!memcmp(&VALUE, &expected_values[i], sizeof(VALUE)), "Got unexpected value.\n"); \ + \ + IPropertyValue_Release(value); \ + } while (0); + + TEST_PROPERTY_VALUE_ARRAY(UInt8Array, BYTE, byte_value) + TEST_PROPERTY_VALUE_ARRAY(Int16Array, INT16, int16_value) + TEST_PROPERTY_VALUE_ARRAY(UInt16Array, UINT16, uint16_value) + TEST_PROPERTY_VALUE_ARRAY(Int32Array, INT32, int32_value) + TEST_PROPERTY_VALUE_ARRAY(UInt32Array, UINT32, uint32_value) + TEST_PROPERTY_VALUE_ARRAY(Int64Array, INT64, int64_value) + TEST_PROPERTY_VALUE_ARRAY(UInt64Array, UINT64, uint64_value) + TEST_PROPERTY_VALUE_ARRAY(SingleArray, FLOAT, float_value) + TEST_PROPERTY_VALUE_ARRAY(DoubleArray, DOUBLE, double_value) + TEST_PROPERTY_VALUE_ARRAY(Char16Array, WCHAR, wchar_value) + TEST_PROPERTY_VALUE_ARRAY(BooleanArray, boolean, boolean_value) + TEST_PROPERTY_VALUE_ARRAY(StringArray, HSTRING, str) + TEST_PROPERTY_VALUE_ARRAY(DateTimeArray, DateTime, datetime_value) + TEST_PROPERTY_VALUE_ARRAY(TimeSpanArray, TimeSpan, timespan_value) + TEST_PROPERTY_VALUE_ARRAY(GuidArray, GUID, IID_IPropertyValue) + TEST_PROPERTY_VALUE_ARRAY(PointArray, Point, point_value) + TEST_PROPERTY_VALUE_ARRAY(SizeArray, Size, size_value) + TEST_PROPERTY_VALUE_ARRAY(RectArray, Rect, rect_value) + +#undef TEST_PROPERTY_VALUE_ARRAY +#undef TEST_PROPERTY_COUNT + + /* Test IReference<*> interface */ +#define TEST_PROPERTY_VALUE_IREFERENCE(TYPE, IFACE_TYPE, VALUE, RET_OBJ, RET_VALUE) \ + do \ + { \ + hr = IPropertyValueStatics_Create##TYPE(statics, VALUE, &inspectable); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + \ + hr = IInspectable_QueryInterface(inspectable, &IID_IPropertyValue, (void **)&value); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + ok(value == (IPropertyValue *)inspectable, "Expected the same pointer.\n"); \ + \ + hr = IPropertyValue_QueryInterface(value, &IID_##IFACE_TYPE, (void **)&RET_OBJ); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + \ + hr = IFACE_TYPE##_get_Value(RET_OBJ, &RET_VALUE); \ + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); \ + ok(RET_VALUE == VALUE, "Got unexpected value.\n"); \ + \ + IFACE_TYPE##_Release(RET_OBJ); \ + IPropertyValue_Release(value); \ + IInspectable_Release(inspectable); \ + } while (0); + + TEST_PROPERTY_VALUE_IREFERENCE(Boolean, IReference_boolean, TRUE, iref_boolean, ret) + TEST_PROPERTY_VALUE_IREFERENCE(String, IReference_HSTRING, str, iref_hstring, ret_str) + TEST_PROPERTY_VALUE_IREFERENCE(Double, IReference_DOUBLE, 1.5, iref_double, ret_double) + +#undef TEST_PROPERTY_VALUE_IREFERENCE + + IPropertyValueStatics_Release(statics); + IActivationFactory_Release(factory); + WindowsDeleteString(str); + RoUninitialize(); +} + START_TEST(wintypes) { test_IApiInformationStatics(); + test_IPropertyValueStatics(); } diff --git a/dlls/wintypes/tests/wintypes_test.idl b/dlls/wintypes/tests/wintypes_test.idl new file mode 100644 index 00000000000..33cfbed210b --- /dev/null +++ b/dlls/wintypes/tests/wintypes_test.idl @@ -0,0 +1,29 @@ +/* + * 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 + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "windows.foundation.idl"; + +declare { + interface Windows.Foundation.IReference<HSTRING>; +}