mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
vbox: Introduce VBOX_QUERY_INTERFACE()
So far we haven't needed to use a different interface for objects we are working with. We were happy with calling their respective vtbl callbacks. Well, this will change soon as we will query an exception (type of nsIException) but will need to promote it to IVirtualBoxErrorInfo class. This promoting is done by QueryInterface() callback which accepts 3 arguments: the original object, ID of the new interface and address where to store the promoted object. As this is very basic operation, available to every object, it is part of the ISupports interface among with other goodies like AddRef() and Release(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
b93d2a0aaa
commit
d4b6aa6305
@ -405,6 +405,9 @@ typedef nsISupports IKeyboard;
|
||||
abort(); \
|
||||
} while (0)
|
||||
|
||||
#define VBOX_QUERY_INTERFACE(nsi, iid, resultp) \
|
||||
gVBoxAPI.nsUISupports.QueryInterface((void*)(nsi), iid, resultp)
|
||||
|
||||
#define VBOX_ADDREF(arg) gVBoxAPI.nsUISupports.AddRef((void *)(arg))
|
||||
|
||||
#define VBOX_RELEASE(arg) \
|
||||
|
@ -561,6 +561,11 @@ static void* _handleHostGetNetworkInterfaces(IHost *host)
|
||||
return host->vtbl->GetNetworkInterfaces;
|
||||
}
|
||||
|
||||
static nsresult _nsisupportsQueryInterface(nsISupports *nsi, const nsID *iid, void **resultp)
|
||||
{
|
||||
return nsi->vtbl->QueryInterface(nsi, iid, resultp);
|
||||
}
|
||||
|
||||
static nsresult _nsisupportsRelease(nsISupports *nsi)
|
||||
{
|
||||
return nsi->vtbl->Release(nsi);
|
||||
@ -2219,6 +2224,7 @@ static vboxUniformedArray _UArray = {
|
||||
};
|
||||
|
||||
static vboxUniformednsISupports _nsUISupports = {
|
||||
.QueryInterface = _nsisupportsQueryInterface,
|
||||
.Release = _nsisupportsRelease,
|
||||
.AddRef = _nsisupportsAddRef,
|
||||
};
|
||||
|
@ -145,6 +145,7 @@ typedef struct {
|
||||
|
||||
/* Functions for nsISupports */
|
||||
typedef struct {
|
||||
nsresult (*QueryInterface)(nsISupports *nsi, const nsID *iid, void **resultp);
|
||||
nsresult (*Release)(nsISupports *nsi);
|
||||
nsresult (*AddRef)(nsISupports *nsi);
|
||||
} vboxUniformednsISupports;
|
||||
|
Loading…
x
Reference in New Issue
Block a user