summaryrefslogtreecommitdiffstats
path: root/src/libs/xpcom18a4/python/primitives.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
commitf215e02bf85f68d3a6106c2a1f4f7f063f819064 (patch)
tree6bb5b92c046312c4e95ac2620b10ddf482d3fa8b /src/libs/xpcom18a4/python/primitives.py
parentInitial commit. (diff)
downloadvirtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.tar.xz
virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.zip
Adding upstream version 7.0.14-dfsg.upstream/7.0.14-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libs/xpcom18a4/python/primitives.py')
-rwxr-xr-xsrc/libs/xpcom18a4/python/primitives.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/libs/xpcom18a4/python/primitives.py b/src/libs/xpcom18a4/python/primitives.py
new file mode 100755
index 00000000..464f12e4
--- /dev/null
+++ b/src/libs/xpcom18a4/python/primitives.py
@@ -0,0 +1,39 @@
+# Various utilities for working with nsISupportsPrimitive
+from xpcom import components
+
+_primitives_map = {}
+
+def _build_map():
+ ifaces = components.interfaces
+ iface = ifaces.nsISupportsPrimitive
+ m = _primitives_map
+
+ m[iface.TYPE_ID] = ifaces.nsISupportsID
+ m[iface.TYPE_CSTRING] = ifaces.nsISupportsCString
+ m[iface.TYPE_STRING] = ifaces.nsISupportsString
+ m[iface.TYPE_PRBOOL] = ifaces.nsISupportsPRBool
+ m[iface.TYPE_PRUINT8] = ifaces.nsISupportsPRUint8
+ m[iface.TYPE_PRUINT16] = ifaces.nsISupportsPRUint16
+ m[iface.TYPE_PRUINT32] = ifaces.nsISupportsPRUint32
+ m[iface.TYPE_PRUINT64] = ifaces.nsISupportsPRUint64
+ m[iface.TYPE_PRINT16] = ifaces.nsISupportsPRInt16
+ m[iface.TYPE_PRINT32] = ifaces.nsISupportsPRInt32
+ m[iface.TYPE_PRINT64] = ifaces.nsISupportsPRInt64
+ m[iface.TYPE_PRTIME] = ifaces.nsISupportsPRTime
+ m[iface.TYPE_CHAR] = ifaces.nsISupportsChar
+ m[iface.TYPE_FLOAT] = ifaces.nsISupportsFloat
+ m[iface.TYPE_DOUBLE] = ifaces.nsISupportsDouble
+ # Do interface pointer specially - it provides the IID.
+ #m[iface.TYPE_INTERFACE_POINTER] = ifaces.nsISupportsDouble
+
+def GetPrimitive(ob):
+ if len(_primitives_map)==0:
+ _build_map()
+
+ prin = ob.QueryInterface(components.interfaces.nsISupportsPrimitive)
+ try:
+ better = _primitives_map[prin.type]
+ except KeyError:
+ raise ValueError("This primitive type (%d) is not supported" % (prin.type,))
+ prin = prin.QueryInterface(better)
+ return prin.data