aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/windows/msofficecomm/WeakReference.cxx
blob: a8589174f9116606a1841ec8c76bfe4ca980a305 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
#include "WeakReference.h"

STDMETHODIMP WeakReference::QueryInterface(REFIID iid, PVOID *obj)
{
    HRESULT hr;

    if (!obj)
        hr = E_POINTER;
    else if (IID_IWeakReferenceSource == iid)
    {
        /*
         * While a weak reference to a weak reference should technically be
         * possible, such functionality does not seem necessary at the time of
         * this writing.
         */
        *obj = NULL;
        hr = E_NOINTERFACE;
    }
    else
        hr = UnknownImpl::QueryInterface(iid, obj);
    return hr;
}

STDMETHODIMP WeakReference::Resolve(REFIID iid, PVOID *obj)
{
    HRESULT hr;

    if (obj)
    {
        if (_iUnknown)
            hr = _iUnknown->QueryInterface(iid, obj);
        else
        {
            *obj = NULL;
            hr = E_FAIL;
        }
    }
    else
        hr = E_POINTER;
    return hr;
}