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 | constants-python.xsl:
|
---|
7 | XSLT stylesheet that generates VirtualBox_constants.py from
|
---|
8 | VirtualBox.xidl.
|
---|
9 | -->
|
---|
10 | <!--
|
---|
11 | Copyright (C) 2009-2022 Oracle and/or its affiliates.
|
---|
12 |
|
---|
13 | This file is part of VirtualBox base platform packages, as
|
---|
14 | available from https://www.virtualbox.org.
|
---|
15 |
|
---|
16 | This program is free software; you can redistribute it and/or
|
---|
17 | modify it under the terms of the GNU General Public License
|
---|
18 | as published by the Free Software Foundation, in version 3 of the
|
---|
19 | License.
|
---|
20 |
|
---|
21 | This program is distributed in the hope that it will be useful, but
|
---|
22 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
24 | General Public License for more details.
|
---|
25 |
|
---|
26 | You should have received a copy of the GNU General Public License
|
---|
27 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
28 |
|
---|
29 | SPDX-License-Identifier: GPL-3.0-only
|
---|
30 | -->
|
---|
31 |
|
---|
32 | <xsl:output
|
---|
33 | method="text"
|
---|
34 | version="1.0"
|
---|
35 | encoding="utf-8"
|
---|
36 | indent="no"/>
|
---|
37 |
|
---|
38 | <xsl:param name="g_sErrHFile"/>
|
---|
39 |
|
---|
40 | <xsl:template match="/">
|
---|
41 | <xsl:text># -*- coding: utf-8 -*-
|
---|
42 |
|
---|
43 | """
|
---|
44 | VirtualBox COM/XPCOM constants.
|
---|
45 |
|
---|
46 | This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
|
---|
47 | """
|
---|
48 |
|
---|
49 | __copyright__ = \
|
---|
50 | """
|
---|
51 | Copyright (C) 2009-2022 Oracle and/or its affiliates.
|
---|
52 |
|
---|
53 | This file is part of VirtualBox base platform packages, as
|
---|
54 | available from https://www.virtualbox.org.
|
---|
55 |
|
---|
56 | This program is free software; you can redistribute it and/or
|
---|
57 | modify it under the terms of the GNU General Public License
|
---|
58 | as published by the Free Software Foundation, in version 3 of the
|
---|
59 | License.
|
---|
60 |
|
---|
61 | This program is distributed in the hope that it will be useful, but
|
---|
62 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
63 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
64 | General Public License for more details.
|
---|
65 |
|
---|
66 | You should have received a copy of the GNU General Public License
|
---|
67 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
68 |
|
---|
69 | SPDX-License-Identifier: GPL-3.0-only
|
---|
70 | """
|
---|
71 |
|
---|
72 | __version__ = "$Revision: 96412 $";
|
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 | class VirtualBoxReflectionInfo:
|
---|
77 | """
|
---|
78 | Enum constants for the various python styles.
|
---|
79 | """
|
---|
80 |
|
---|
81 | def __init__(self, fIsSym):
|
---|
82 | self.__fIsSym = fIsSym
|
---|
83 |
|
---|
84 | # iprt/err.h + VBox/err.h constants:
|
---|
85 | __dVBoxStatuses = {</xsl:text>
|
---|
86 | <xsl:value-of select="document($g_sErrHFile)"/>
|
---|
87 |
|
---|
88 | <xsl:text disable-output-escaping="yes"><![CDATA[
|
---|
89 | }
|
---|
90 |
|
---|
91 | __dValues = {]]></xsl:text>
|
---|
92 | <xsl:for-each select="//enum">
|
---|
93 | <xsl:text>
|
---|
94 | '</xsl:text> <xsl:value-of select="@name"/><xsl:text>': {</xsl:text>
|
---|
95 | <xsl:for-each select="const">
|
---|
96 | <xsl:text>
|
---|
97 | '</xsl:text>
|
---|
98 | <xsl:value-of select="@name"/><xsl:text>': </xsl:text>
|
---|
99 | <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
|
---|
100 | </xsl:for-each>
|
---|
101 | <xsl:text>
|
---|
102 | },</xsl:text>
|
---|
103 | </xsl:for-each>
|
---|
104 | <!-- VBox status codes: -->
|
---|
105 | <xsl:text disable-output-escaping="yes"><![CDATA[
|
---|
106 | # iprt/err.h + VBox/err.h constants:
|
---|
107 | 'VBoxStatus': __dVBoxStatuses,
|
---|
108 | }
|
---|
109 |
|
---|
110 | __dValuesSym = {]]></xsl:text>
|
---|
111 | <xsl:for-each select="//enum">
|
---|
112 | <xsl:text>
|
---|
113 | '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': {</xsl:text>
|
---|
114 | <xsl:for-each select="const">
|
---|
115 | <xsl:text>
|
---|
116 | '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': '</xsl:text>
|
---|
117 | <xsl:value-of select="@name"/>
|
---|
118 | <xsl:text>',</xsl:text>
|
---|
119 | </xsl:for-each>
|
---|
120 | <xsl:text>
|
---|
121 | },</xsl:text>
|
---|
122 | </xsl:for-each>
|
---|
123 | <!-- hack alert: force new output element to avoid large reallocations. -->
|
---|
124 | <xsl:text disable-output-escaping="yes"><![CDATA[
|
---|
125 | }
|
---|
126 |
|
---|
127 | __dValuesFlat = dict({]]></xsl:text>
|
---|
128 | <xsl:for-each select="//enum">
|
---|
129 | <xsl:variable name="ename">
|
---|
130 | <xsl:value-of select="@name"/>
|
---|
131 | </xsl:variable>
|
---|
132 | <xsl:for-each select="const">
|
---|
133 | <xsl:text>
|
---|
134 | '</xsl:text> <xsl:value-of select="$ename"/> <xsl:text>_</xsl:text>
|
---|
135 | <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
|
---|
136 | <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
|
---|
137 | </xsl:for-each>
|
---|
138 | </xsl:for-each>
|
---|
139 | <!-- hack alert: force new output element to avoid large reallocations. -->
|
---|
140 | <xsl:text disable-output-escaping="yes"><![CDATA[
|
---|
141 | # Result constants:]]></xsl:text>
|
---|
142 | <xsl:for-each select="//result[@value]">
|
---|
143 | <xsl:text>
|
---|
144 | '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
|
---|
145 | <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
|
---|
146 | </xsl:for-each>
|
---|
147 |
|
---|
148 | <!-- hack alert: force new output element to avoid large reallocations. -->
|
---|
149 | <xsl:text>
|
---|
150 | }, **__dVBoxStatuses)
|
---|
151 |
|
---|
152 | __dValuesFlatSym = {</xsl:text>
|
---|
153 | <xsl:for-each select="//enum">
|
---|
154 | <xsl:variable name="ename">
|
---|
155 | <xsl:value-of select="@name"/>
|
---|
156 | </xsl:variable>
|
---|
157 | <xsl:for-each select="const">
|
---|
158 | <xsl:variable name="eval">
|
---|
159 | <xsl:value-of select="concat($ename, '_', @name)"/>
|
---|
160 | </xsl:variable>
|
---|
161 | <xsl:text>
|
---|
162 | '</xsl:text> <xsl:value-of select="$eval"/> <xsl:text>': </xsl:text>
|
---|
163 | <xsl:text>'</xsl:text> <xsl:value-of select="@name"/> <xsl:text>',</xsl:text>
|
---|
164 | </xsl:for-each>
|
---|
165 | </xsl:for-each>
|
---|
166 | <xsl:text>
|
---|
167 | # Result constants:</xsl:text>
|
---|
168 | <xsl:for-each select="//result[@value]">
|
---|
169 | <xsl:text>
|
---|
170 | '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
|
---|
171 | <xsl:text>'</xsl:text><xsl:value-of select="@name"/><xsl:text>',</xsl:text>
|
---|
172 | </xsl:for-each>
|
---|
173 | <xsl:text>
|
---|
174 | }
|
---|
175 |
|
---|
176 | def __getattr__(self, sAttrName):
|
---|
177 | if self.__fIsSym:
|
---|
178 | oValue = self.__dValuesFlatSym.get(sAttrName)
|
---|
179 | else:
|
---|
180 | oValue = self.__dValuesFlat.get(sAttrName)
|
---|
181 | if oValue is None:
|
---|
182 | raise AttributeError
|
---|
183 | return oValue
|
---|
184 |
|
---|
185 | def all_values(self, sEnumName):
|
---|
186 | """ Returns a dictionary with all the value names for a given enum type. """
|
---|
187 | if self.__fIsSym:
|
---|
188 | dValues = self.__dValuesSym.get(sEnumName)
|
---|
189 | else:
|
---|
190 | dValues = self.__dValues.get(sEnumName)
|
---|
191 | if dValues is None:
|
---|
192 | dValues = {}
|
---|
193 | return dValues
|
---|
194 |
|
---|
195 | </xsl:text>
|
---|
196 | </xsl:template>
|
---|
197 | </xsl:stylesheet>
|
---|
198 |
|
---|