[PATCH 1/8] vbox: Introduce VBOX_QUERY_INTERFACE()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/vbox/vbox_common.h        | 3 +++
 src/vbox/vbox_tmpl.c          | 6 ++++++
 src/vbox/vbox_uniformed_api.h | 1 +
 3 files changed, 10 insertions(+)

diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h
index 1fb922aaf0..38afdfddfa 100644
--- a/src/vbox/vbox_common.h
+++ b/src/vbox/vbox_common.h
@@ -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) \
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 52b1c93b6d..f01f8bd487 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -563,6 +563,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);
@@ -2238,6 +2243,7 @@ static vboxUniformedArray _UArray = {
 };
 
 static vboxUniformednsISupports _nsUISupports = {
+    .QueryInterface = _nsisupportsQueryInterface,
     .Release = _nsisupportsRelease,
     .AddRef = _nsisupportsAddRef,
 };
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 18f352d98e..3ac6ba92a6 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -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;
-- 
2.39.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux