VirtualBox

Changeset 47125 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 12, 2013 6:24:54 PM (11 years ago)
Author:
vboxsync
Message:

python: Emit VBOX_E_xxx constants. Make pretty output.

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

Legend:

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

    r44529 r47125  
    99        VirtualBox.xidl.
    1010
    11     Copyright (C) 2009-2012 Oracle Corporation
     11    Copyright (C) 2009-2013 Oracle Corporation
    1212
    1313    This file is part of VirtualBox Open Source Edition (OSE), as
     
    2727
    2828<xsl:template match="/">
    29 <xsl:text># Copyright (C) Oracle Corporation
    30 #
    31 # This file is part of VirtualBox Open Source Edition (OSE), as
    32 # available from http://www.virtualbox.org. This file is free software;
    33 # you can redistribute it and/or modify it under the terms of the GNU
    34 # General Public License (GPL) as published by the Free Software
    35 # Foundation, in version 2 as it comes in the "COPYING" file of the
    36 # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
    37 # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    38 #
    39 # This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
    40 #
     29<xsl:text># -*- coding: utf-8 -*-
     30
     31"""
     32VirtualBox COM/XPCOM constants.
     33
     34This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
     35"""
     36
     37__copyright__ = \
     38"""
     39Copyright (C) 2009-2013 Oracle Corporation
     40
     41This file is part of VirtualBox Open Source Edition (OSE), as
     42available from http://www.virtualbox.org. This file is free software;
     43you can redistribute it and/or modify it under the terms of the GNU
     44General Public License (GPL) as published by the Free Software
     45Foundation, in version 2 as it comes in the "COPYING" file of the
     46VirtualBox OSE distribution. VirtualBox OSE is distributed in the
     47hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
     48"""
     49
     50__version__ = "$Revision$";
     51
     52
     53
     54class VirtualBoxReflectionInfo:
     55    """
     56    Enum constants for the various python styles.
     57    """
     58
     59    def __init__(self, fIsSym):
     60        self.__fIsSym = fIsSym
     61
     62    __dValues = {</xsl:text>
     63
     64    <xsl:for-each select="//enum">
     65        <xsl:text>
     66        '</xsl:text> <xsl:value-of select="@name"/><xsl:text>': {</xsl:text>
     67        <xsl:for-each select="const">
     68            <xsl:text>
     69            '</xsl:text>
     70            <xsl:value-of select="@name"/><xsl:text>': </xsl:text>
     71            <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
     72        </xsl:for-each>
     73        <xsl:text>
     74        },</xsl:text>
     75    </xsl:for-each>
     76    <xsl:text>
     77    }
     78
     79    __dValuesSym = {</xsl:text>
     80    <xsl:for-each select="//enum">
     81        <xsl:text>
     82        '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': { </xsl:text>
     83        <xsl:for-each select="const">
     84            <xsl:text>
     85            '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': '</xsl:text>
     86            <xsl:value-of select="@name"/>
     87            <xsl:text>',</xsl:text>
     88        </xsl:for-each>
     89        <xsl:text>
     90        },</xsl:text>
     91    </xsl:for-each>
     92<xsl:text>
     93    }
     94
     95    __dValuesFlat = {</xsl:text>
     96    <xsl:for-each select="//enum">
     97        <xsl:variable name="ename">
     98            <xsl:value-of select="@name"/>
     99        </xsl:variable>
     100        <xsl:for-each select="const">
     101            <xsl:text>
     102        '</xsl:text> <xsl:value-of select="$ename"/> <xsl:text>_</xsl:text>
     103            <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
     104            <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
     105        </xsl:for-each>
     106    </xsl:for-each>
     107    <xsl:text>
     108        # Result constants:</xsl:text>
     109    <xsl:for-each select="//result[@value]">
     110        <xsl:text>
     111        '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
     112        <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
     113    </xsl:for-each>
     114<xsl:text>
     115    }
     116
     117    __dValuesFlatSym = {</xsl:text>
     118    <xsl:for-each select="//enum">
     119        <xsl:variable name="ename">
     120            <xsl:value-of select="@name"/>
     121        </xsl:variable>
     122        <xsl:for-each select="const">
     123            <xsl:variable name="eval">
     124                <xsl:value-of select="concat($ename, '_', @name)"/>
     125            </xsl:variable>
     126            <xsl:text>
     127        '</xsl:text> <xsl:value-of select="$eval"/> <xsl:text>': </xsl:text>
     128            <xsl:text>'</xsl:text> <xsl:value-of select="@name"/> <xsl:text>',</xsl:text>
     129        </xsl:for-each>
     130    </xsl:for-each>
     131    <xsl:text>
     132        # Result constants:</xsl:text>
     133    <xsl:for-each select="//result[@value]">
     134        <xsl:text>
     135        '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
     136        <xsl:text>'</xsl:text><xsl:value-of select="@name"/><xsl:text>',</xsl:text>
     137    </xsl:for-each>
     138    <xsl:text>
     139    }
     140
     141    def __getattr__(self, sAttrName):
     142        if self.__fIsSym:
     143            oValue = self.__dValuesFlatSym.get(sAttrName)
     144        else:
     145            oValue = self.__dValuesFlat.get(sAttrName)
     146        if oValue is None:
     147            raise AttributeError
     148        return oValue
     149
     150    def all_values(self, sEnumName):
     151        """ Returns a dictionary with all the value names for a given enum type. """
     152        if self.__fIsSym:
     153            dValues = self.__dValuesSym.get(sEnumName)
     154        else:
     155            dValues = self.__dValues.get(sEnumName)
     156        if dValues is None:
     157            dValues = {}
     158        return dValues
     159
    41160</xsl:text>
    42 class VirtualBoxReflectionInfo:
    43    def __init__(self, isSym):
    44       self.isSym = isSym
    45 
    46    _Values = {<xsl:for-each select="//enum">
    47                 '<xsl:value-of select="@name"/>':{
    48                   <xsl:for-each select="const">'<xsl:value-of select="@name"/>':<xsl:value-of select="@value"/><xsl:if test="not(position()=last())">,</xsl:if>
    49                   </xsl:for-each>}<xsl:if test="not(position()=last())">,</xsl:if>
    50 
    51               </xsl:for-each>}
    52 
    53    _ValuesSym = {<xsl:for-each select="//enum">
    54                 '<xsl:value-of select="@name"/>':{
    55                   <xsl:for-each select="const">'<xsl:value-of select="@name"/>': '<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">,</xsl:if>
    56                   </xsl:for-each>}<xsl:if test="not(position()=last())">,</xsl:if>
    57 
    58               </xsl:for-each>}
    59 
    60    _ValuesFlat = {<xsl:for-each select="//enum">
    61                    <xsl:variable name="ename">
    62                     <xsl:value-of select="@name"/>
    63                    </xsl:variable>
    64                    <xsl:for-each select="const">
    65                         '<xsl:value-of select="$ename"/>_<xsl:value-of select="@name"/>':<xsl:value-of select="@value"/><xsl:if test="not(position()=last())">,</xsl:if>
    66                    </xsl:for-each>
    67                    <xsl:if test="not(position()=last())">,</xsl:if>
    68                   </xsl:for-each>}
    69 
    70    _ValuesFlatSym = {<xsl:for-each select="//enum">
    71                    <xsl:variable name="ename">
    72                     <xsl:value-of select="@name"/>
    73                    </xsl:variable>
    74                    <xsl:for-each select="const">
    75                      <xsl:variable name="eval">
    76                        <xsl:value-of select="concat($ename, '_', @name)"/>
    77                    </xsl:variable>
    78                         '<xsl:value-of select="$eval"/>': '<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">,</xsl:if>
    79                    </xsl:for-each>
    80                    <xsl:if test="not(position()=last())">,</xsl:if>
    81                   </xsl:for-each>}
    82 
    83    def __getattr__(self,attr):
    84       if self.isSym:
    85         v = self._ValuesFlatSym.get(attr)
    86       else:
    87         v = self._ValuesFlat.get(attr)
    88       if v is not None:
    89          return v
    90       else:
    91          raise AttributeError
    92 
    93    def all_values(self,enum_name):
    94       if self.isSym:
    95         vals = self._ValuesSym.get(enum_name)
    96       else:
    97         vals = self._Values.get(enum_name)
    98       if vals is not None:
    99          return vals
    100       else:
    101          return {}
    102 
    103161</xsl:template>
    104162</xsl:stylesheet>
     163
  • trunk/src/VBox/Main/glue/vboxapi.py

    r47124 r47125  
    606606
    607607    def getBinDir(self):
     608        """
     609        Returns the VirtualBox binary directory.
     610        """
    608611        global VBoxBinDir
    609612        return VBoxBinDir
    610613
    611614    def getSdkDir(self):
     615        """
     616        Returns the VirtualBox SDK directory.
     617        """
    612618        global VBoxSdkDir
    613619        return VBoxSdkDir
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