diff options
Diffstat (limited to 'src/VBox/Main/glue/constants-python.xsl')
-rw-r--r-- | src/VBox/Main/glue/constants-python.xsl | 205 |
1 files changed, 132 insertions, 73 deletions
diff --git a/src/VBox/Main/glue/constants-python.xsl b/src/VBox/Main/glue/constants-python.xsl index df18f43b..3795d25e 100644 --- a/src/VBox/Main/glue/constants-python.xsl +++ b/src/VBox/Main/glue/constants-python.xsl @@ -8,7 +8,7 @@ XSLT stylesheet that generates VirtualBox_constants.py from VirtualBox.xidl. - Copyright (C) 2009 Oracle Corporation + Copyright (C) 2009-2013 Oracle Corporation This file is part of VirtualBox Open Source Edition (OSE), as available from http://www.virtualbox.org. This file is free software; @@ -26,79 +26,138 @@ indent="no"/> <xsl:template match="/"> -<xsl:text># Copyright (C) Oracle Corporation -# -# This file is part of VirtualBox Open Source Edition (OSE), as -# available from http://www.virtualbox.org. This file is free software; -# you can redistribute it and/or modify it under the terms of the GNU -# General Public License (GPL) as published by the Free Software -# Foundation, in version 2 as it comes in the "COPYING" file of the -# VirtualBox OSE distribution. VirtualBox OSE is distributed in the -# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. -# -# This file is autogenerated from VirtualBox.xidl, DO NOT EDIT! -# -</xsl:text> +<xsl:text># -*- coding: utf-8 -*- + +""" +VirtualBox COM/XPCOM constants. + +This file is autogenerated from VirtualBox.xidl, DO NOT EDIT! +""" + +__copyright__ = \ +""" +Copyright (C) 2009-2013 Oracle Corporation + +This file is part of VirtualBox Open Source Edition (OSE), as +available from http://www.virtualbox.org. This file is free software; +you can redistribute it and/or modify it under the terms of the GNU +General Public License (GPL) as published by the Free Software +Foundation, in version 2 as it comes in the "COPYING" file of the +VirtualBox OSE distribution. VirtualBox OSE is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +""" + +__version__ = "$Revision: 87223 $"; + + + class VirtualBoxReflectionInfo: - def __init__(self, isSym): - self.isSym = isSym - - _Values = {<xsl:for-each select="//enum"> - '<xsl:value-of select="@name"/>':{ - <xsl:for-each select="const">'<xsl:value-of select="@name"/>':<xsl:value-of select="@value"/><xsl:if test="not(position()=last())">,</xsl:if> - </xsl:for-each>}<xsl:if test="not(position()=last())">,</xsl:if> - - </xsl:for-each>} - - _ValuesSym = {<xsl:for-each select="//enum"> - '<xsl:value-of select="@name"/>':{ - <xsl:for-each select="const">'<xsl:value-of select="@name"/>': '<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">,</xsl:if> - </xsl:for-each>}<xsl:if test="not(position()=last())">,</xsl:if> - - </xsl:for-each>} - - _ValuesFlat = {<xsl:for-each select="//enum"> - <xsl:variable name="ename"> - <xsl:value-of select="@name"/> - </xsl:variable> - <xsl:for-each select="const"> - '<xsl:value-of select="$ename"/>_<xsl:value-of select="@name"/>':<xsl:value-of select="@value"/><xsl:if test="not(position()=last())">,</xsl:if> - </xsl:for-each> - <xsl:if test="not(position()=last())">,</xsl:if> - </xsl:for-each>} - - _ValuesFlatSym = {<xsl:for-each select="//enum"> - <xsl:variable name="ename"> - <xsl:value-of select="@name"/> - </xsl:variable> - <xsl:for-each select="const"> - <xsl:variable name="eval"> - <xsl:value-of select="concat($ename, '_', @name)"/> - </xsl:variable> - '<xsl:value-of select="$eval"/>': '<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">,</xsl:if> - </xsl:for-each> - <xsl:if test="not(position()=last())">,</xsl:if> - </xsl:for-each>} - - def __getattr__(self,attr): - if self.isSym: - v = self._ValuesFlatSym.get(attr) - else: - v = self._ValuesFlat.get(attr) - if v is not None: - return v - else: - raise AttributeError - - def all_values(self,enum_name): - if self.isSym: - vals = self._ValuesSym.get(enum_name) - else: - vals = self._Values.get(enum_name) - if vals is not None: - return vals - else: - return {} + """ + Enum constants for the various python styles. + """ + + def __init__(self, fIsSym): + self.__fIsSym = fIsSym + __dValues = {</xsl:text> + + <xsl:for-each select="//enum"> + <xsl:text> + '</xsl:text> <xsl:value-of select="@name"/><xsl:text>': {</xsl:text> + <xsl:for-each select="const"> + <xsl:text> + '</xsl:text> + <xsl:value-of select="@name"/><xsl:text>': </xsl:text> + <xsl:value-of select="@value"/><xsl:text>,</xsl:text> + </xsl:for-each> + <xsl:text> + },</xsl:text> + </xsl:for-each> + <xsl:text> + } + + __dValuesSym = {</xsl:text> + <xsl:for-each select="//enum"> + <xsl:text> + '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': { </xsl:text> + <xsl:for-each select="const"> + <xsl:text> + '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': '</xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>',</xsl:text> + </xsl:for-each> + <xsl:text> + },</xsl:text> + </xsl:for-each> +<xsl:text> + } + + __dValuesFlat = {</xsl:text> + <xsl:for-each select="//enum"> + <xsl:variable name="ename"> + <xsl:value-of select="@name"/> + </xsl:variable> + <xsl:for-each select="const"> + <xsl:text> + '</xsl:text> <xsl:value-of select="$ename"/> <xsl:text>_</xsl:text> + <xsl:value-of select="@name"/> <xsl:text>': </xsl:text> + <xsl:value-of select="@value"/><xsl:text>,</xsl:text> + </xsl:for-each> + </xsl:for-each> + <xsl:text> + # Result constants:</xsl:text> + <xsl:for-each select="//result[@value]"> + <xsl:text> + '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': </xsl:text> + <xsl:value-of select="@value"/><xsl:text>,</xsl:text> + </xsl:for-each> +<xsl:text> + } + + __dValuesFlatSym = {</xsl:text> + <xsl:for-each select="//enum"> + <xsl:variable name="ename"> + <xsl:value-of select="@name"/> + </xsl:variable> + <xsl:for-each select="const"> + <xsl:variable name="eval"> + <xsl:value-of select="concat($ename, '_', @name)"/> + </xsl:variable> + <xsl:text> + '</xsl:text> <xsl:value-of select="$eval"/> <xsl:text>': </xsl:text> + <xsl:text>'</xsl:text> <xsl:value-of select="@name"/> <xsl:text>',</xsl:text> + </xsl:for-each> + </xsl:for-each> + <xsl:text> + # Result constants:</xsl:text> + <xsl:for-each select="//result[@value]"> + <xsl:text> + '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': </xsl:text> + <xsl:text>'</xsl:text><xsl:value-of select="@name"/><xsl:text>',</xsl:text> + </xsl:for-each> + <xsl:text> + } + + def __getattr__(self, sAttrName): + if self.__fIsSym: + oValue = self.__dValuesFlatSym.get(sAttrName) + else: + oValue = self.__dValuesFlat.get(sAttrName) + if oValue is None: + raise AttributeError + return oValue + + def all_values(self, sEnumName): + """ Returns a dictionary with all the value names for a given enum type. """ + if self.__fIsSym: + dValues = self.__dValuesSym.get(sEnumName) + else: + dValues = self.__dValues.get(sEnumName) + if dValues is None: + dValues = {} + return dValues + +</xsl:text> </xsl:template> </xsl:stylesheet> + |