VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/python/primitives.py@ 72426

Last change on this file since 72426 was 59798, checked in by vboxsync, 9 years ago

re-applied the Python 3 changes which were backed out in r105674 sans the changes in .cpp

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1# Various utilities for working with nsISupportsPrimitive
2from xpcom import components
3
4_primitives_map = {}
5
6def _build_map():
7 ifaces = components.interfaces
8 iface = ifaces.nsISupportsPrimitive
9 m = _primitives_map
10
11 m[iface.TYPE_ID] = ifaces.nsISupportsID
12 m[iface.TYPE_CSTRING] = ifaces.nsISupportsCString
13 m[iface.TYPE_STRING] = ifaces.nsISupportsString
14 m[iface.TYPE_PRBOOL] = ifaces.nsISupportsPRBool
15 m[iface.TYPE_PRUINT8] = ifaces.nsISupportsPRUint8
16 m[iface.TYPE_PRUINT16] = ifaces.nsISupportsPRUint16
17 m[iface.TYPE_PRUINT32] = ifaces.nsISupportsPRUint32
18 m[iface.TYPE_PRUINT64] = ifaces.nsISupportsPRUint64
19 m[iface.TYPE_PRINT16] = ifaces.nsISupportsPRInt16
20 m[iface.TYPE_PRINT32] = ifaces.nsISupportsPRInt32
21 m[iface.TYPE_PRINT64] = ifaces.nsISupportsPRInt64
22 m[iface.TYPE_PRTIME] = ifaces.nsISupportsPRTime
23 m[iface.TYPE_CHAR] = ifaces.nsISupportsChar
24 m[iface.TYPE_FLOAT] = ifaces.nsISupportsFloat
25 m[iface.TYPE_DOUBLE] = ifaces.nsISupportsDouble
26 # Do interface pointer specially - it provides the IID.
27 #m[iface.TYPE_INTERFACE_POINTER] = ifaces.nsISupportsDouble
28
29def GetPrimitive(ob):
30 if len(_primitives_map)==0:
31 _build_map()
32
33 prin = ob.QueryInterface(components.interfaces.nsISupportsPrimitive)
34 try:
35 better = _primitives_map[prin.type]
36 except KeyError:
37 raise ValueError("This primitive type (%d) is not supported" % (prin.type,))
38 prin = prin.QueryInterface(better)
39 return prin.data
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette