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>
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) \
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);
};
static vboxUniformednsISupports _nsUISupports = {
+ .QueryInterface = _nsisupportsQueryInterface,
.Release = _nsisupportsRelease,
.AddRef = _nsisupportsAddRef,
};
/* Functions for nsISupports */
typedef struct {
+ nsresult (*QueryInterface)(nsISupports *nsi, const nsID *iid, void **resultp);
nsresult (*Release)(nsISupports *nsi);
nsresult (*AddRef)(nsISupports *nsi);
} vboxUniformednsISupports;