VirtualBox

Changeset 21968 in vbox


Ignore:
Timestamp:
Aug 5, 2009 8:01:34 AM (16 years ago)
Author:
vboxsync
Message:

Python WS: use symbolic enumeration values, not numerical

Location:
trunk/src/VBox/Main/glue
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/constants-python.xsl

    r21965 r21968  
    4949</xsl:text>
    5050class VirtualBoxReflectionInfo:
    51    def __init__(self):
    52       self.map = {}
     51   def __init__(self, isSym):
     52      self.isSym = isSym
    5353
    5454   _Values = {<xsl:for-each select="//enum">
     
    6868                   <xsl:if test="not(position()=last())">,</xsl:if>
    6969                  </xsl:for-each>}
     70 
     71   _ValuesFlatSym = {<xsl:for-each select="//enum">
     72                   <xsl:variable name="ename">
     73                    <xsl:value-of select="@name"/>
     74                   </xsl:variable>
     75                   <xsl:for-each select="const">
     76                     <xsl:variable name="eval">
     77                       <xsl:value-of select="concat($ename, '_', @name)"/>
     78                   </xsl:variable>
     79                        '<xsl:value-of select="$eval"/>': '<xsl:value-of select="$eval"/>'<xsl:if test="not(position()=last())">,</xsl:if>
     80                   </xsl:for-each>
     81                   <xsl:if test="not(position()=last())">,</xsl:if>
     82                  </xsl:for-each>}
    7083
    7184   def __getattr__(self,attr):
    72       v = self._ValuesFlat.get(attr)
     85      if self.isSym:
     86        v = self._ValuesFlatSym.get(attr)
     87      else:
     88        v = self._ValuesFlat.get(attr)
    7389      if v is not None:
    7490         return v
  • trunk/src/VBox/Main/glue/vboxapi.py

    r21959 r21968  
    205205            import pythoncom
    206206            import win32api
    207             self.constants = PlatformMSCOM.InterfacesWrapper()
    208207            from win32con import DUPLICATE_SAME_ACCESS
    209208            from win32api import GetCurrentThread,GetCurrentThreadId,DuplicateHandle,GetCurrentProcess
     
    230229        return win32com.client.Dispatch("VirtualBox.VirtualBox")
    231230
    232     def getConstants(self):
    233         return self.constants
    234 
    235231    def getType(self):
    236232        return 'MSCOM'
     
    321317        import xpcom.components
    322318        return xpcom.components.classes["@virtualbox.org/VirtualBox;1"].createInstance()
    323 
    324     def getConstants(self):
    325         import xpcom.components
    326         return xpcom.components.interfaces
    327319
    328320    def getType(self):
     
    411403                self.wsmgr = None
    412404
    413     def getConstants(self):
    414         return None
    415 
    416405    def getType(self):
    417406        return 'WEBSERVICE'
     
    457446                style = "XPCOM"
    458447
     448
    459449        exec "self.platform = Platform"+style+"(platparams)"
    460 
    461         self.constants = VirtualBoxReflectionInfo()
     450        # for webservices, enums are symbolic
     451        self.constants = VirtualBoxReflectionInfo(style == "WEBSERVICE")
    462452        self.type = self.platform.getType()
    463453        self.remote = self.platform.getRemote()
Note: See TracChangeset for help on using the changeset viewer.

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