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