Rémi Bernon (@rbernon) commented about dlls/geolocation/weakref.h:
- 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
- */
+#ifndef __WINE_WEAKREF_H +#define __WINE_WEAKREF_H
+#include "weakreference.h"
+/* Create a IWeakReference managing the object */ +HRESULT weak_reference_create( IUnknown *object, IWeakReference **out ); +/* Add a strong reference to the managed object */ +ULONG weak_reference_strong_add_ref( IWeakReference *iface ); +/* Release a strong reference to the managed object */ +ULONG weak_reference_strong_release( IWeakReference *iface );
Hmm, I had missed that you also had macros for `IWeakReferenceSource` boilerplate. In that case and as it seems to me from https://gitlab.winehq.org/wine/wine/-/merge_requests/6207 that macros are frowned upon, what do you think about moving this to the source too, with something like that instead:
```suggestion:-5+0 struct weak_reference_source { IWeakReferenceSource IWeakReferenceSource_iface; IWeakReference *weak_ref; IUnknown *object; };
/* Create a IWeakReference managing the object */ HRESULT weak_reference_source_init( IUnkown *object, struct weak_reference_source *source ); /* Add a strong reference to the managed object */ ULONG weak_reference_strong_add_ref( weak_reference_source *iface ); /* Release a strong reference to the managed object */ ULONG weak_reference_strong_release( weak_reference_source *iface ); ```
Classes can then embed a `struct weak_reference_source weak_reference_source;` member, and `weak_reference_source_init` would be implemented like that: ``` HRESULT weak_reference_source_init( IUnknown *object, struct weak_reference_source *source ) { source->IWeakReferenceSource_iface = weak_reference_source_vtbl; source->object = object; return weak_reference_create( object, &source->weak_ref ); } ```
That should allow to implement `IWeakReferenceSource` in a generic way (`impl_from_IWeakReferenceSource` would return the struct, which gives you access to the `IUnknown` pointer for dispatching `QueryInterface/AddRef/Release`).