Rémi Bernon (@rbernon) commented about dlls/windows.ui/private.h:
+ * 6. Call "IWeakReference_Release( &impl->weakref->IWeakReference_iface );" in object_Release() + * when object->weakref->ref_strong reaches zero. + */ + +/* The control block is contained in struct weakref so that we don't have to allocate a separate + * struct for it */ +struct weakref +{ + IWeakReference IWeakReference_iface; + IUnknown *object; + /* control block */ + LONG ref_strong; + LONG ref_weak; +}; + +#define DEFINE_WEAKREF(pfx, iface_type, impl_type) \ It doesn't seem necessary to use a macro for this, a separate file with the implementation and a simple API like:
``` HRESULT weak_reference_create( IUnknown *object, IWeakReference **out ); ULONG weak_reference_strong_add_ref( IWeakReference *iface ); ULONG weak_reference_strong_release( IWeakReference *iface ); ``` Should work and be easily shared across modules. Also, lets keep the code style consistent with most other WinRT modules (ie: ntdll style). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8078#note_104173