VirtualBox

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

最後變更 在這個檔案從85201是 59798,由 vboxsync 提交於 9 年 前

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

  • 屬性 svn:eol-style 設為 native
檔案大小: 1.5 KB
 
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
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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