VirtualBox

source: vbox/trunk/src/VBox/Main/glue/constants-python.xsl@ 52720

Last change on this file since 52720 was 47125, checked in by vboxsync, 11 years ago

python: Emit VBOX_E_xxx constants. Make pretty output.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1<xsl:stylesheet version = '1.0'
2 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
3 xmlns:vbox="http://www.virtualbox.org/">
4
5<!--
6
7 constants-python.xsl:
8 XSLT stylesheet that generates VirtualBox_constants.py from
9 VirtualBox.xidl.
10
11 Copyright (C) 2009-2013 Oracle Corporation
12
13 This file is part of VirtualBox Open Source Edition (OSE), as
14 available from http://www.virtualbox.org. This file is free software;
15 you can redistribute it and/or modify it under the terms of the GNU
16 General Public License (GPL) as published by the Free Software
17 Foundation, in version 2 as it comes in the "COPYING" file of the
18 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20-->
21
22<xsl:output
23 method="text"
24 version="1.0"
25 encoding="utf-8"
26 indent="no"/>
27
28<xsl:template match="/">
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: 47125 $";
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
160</xsl:text>
161</xsl:template>
162</xsl:stylesheet>
163
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