VirtualBox

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

Last change on this file since 93943 was 82970, checked in by vboxsync, 5 years ago

Copyright year updates - manual ones.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 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-2020 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:param name="g_sErrHFile"/>
29
30<xsl:template match="/">
31<xsl:text># -*- coding: utf-8 -*-
32
33"""
34VirtualBox COM/XPCOM constants.
35
36This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
37"""
38
39__copyright__ = \
40"""
41Copyright (C) 2009-2020 Oracle Corporation
42
43This file is part of VirtualBox Open Source Edition (OSE), as
44available from http://www.virtualbox.org. This file is free software;
45you can redistribute it and/or modify it under the terms of the GNU
46General Public License (GPL) as published by the Free Software
47Foundation, in version 2 as it comes in the "COPYING" file of the
48VirtualBox OSE distribution. VirtualBox OSE is distributed in the
49hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
50
51The contents of this file may alternatively be used under the terms
52of the Common Development and Distribution License Version 1.0
53(CDDL) only, as it comes in the "COPYING.CDDL" file of the
54VirtualBox OSE distribution, in which case the provisions of the
55CDDL are applicable instead of those of the GPL.
56
57You may elect to license modified versions of this file under the
58terms and conditions of either the GPL or the CDDL or both.
59"""
60
61__version__ = "$Revision: 82970 $";
62
63
64
65class VirtualBoxReflectionInfo:
66 """
67 Enum constants for the various python styles.
68 """
69
70 def __init__(self, fIsSym):
71 self.__fIsSym = fIsSym
72
73 # iprt/err.h + VBox/err.h constants:
74 __dVBoxStatuses = {</xsl:text>
75 <xsl:value-of select="document($g_sErrHFile)"/>
76
77 <xsl:text disable-output-escaping="yes"><![CDATA[
78 }
79
80 __dValues = {]]></xsl:text>
81 <xsl:for-each select="//enum">
82 <xsl:text>
83 '</xsl:text> <xsl:value-of select="@name"/><xsl:text>': {</xsl:text>
84 <xsl:for-each select="const">
85 <xsl:text>
86 '</xsl:text>
87 <xsl:value-of select="@name"/><xsl:text>': </xsl:text>
88 <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
89 </xsl:for-each>
90 <xsl:text>
91 },</xsl:text>
92 </xsl:for-each>
93 <!-- VBox status codes: -->
94 <xsl:text disable-output-escaping="yes"><![CDATA[
95 # iprt/err.h + VBox/err.h constants:
96 'VBoxStatus': __dVBoxStatuses,
97 }
98
99 __dValuesSym = {]]></xsl:text>
100 <xsl:for-each select="//enum">
101 <xsl:text>
102 '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': {</xsl:text>
103 <xsl:for-each select="const">
104 <xsl:text>
105 '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': '</xsl:text>
106 <xsl:value-of select="@name"/>
107 <xsl:text>',</xsl:text>
108 </xsl:for-each>
109 <xsl:text>
110 },</xsl:text>
111 </xsl:for-each>
112 <!-- hack alert: force new output element to avoid large reallocations. -->
113 <xsl:text disable-output-escaping="yes"><![CDATA[
114 }
115
116 __dValuesFlat = dict({]]></xsl:text>
117 <xsl:for-each select="//enum">
118 <xsl:variable name="ename">
119 <xsl:value-of select="@name"/>
120 </xsl:variable>
121 <xsl:for-each select="const">
122 <xsl:text>
123 '</xsl:text> <xsl:value-of select="$ename"/> <xsl:text>_</xsl:text>
124 <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
125 <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
126 </xsl:for-each>
127 </xsl:for-each>
128 <!-- hack alert: force new output element to avoid large reallocations. -->
129 <xsl:text disable-output-escaping="yes"><![CDATA[
130 # Result constants:]]></xsl:text>
131 <xsl:for-each select="//result[@value]">
132 <xsl:text>
133 '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
134 <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
135 </xsl:for-each>
136
137 <!-- hack alert: force new output element to avoid large reallocations. -->
138 <xsl:text>
139 }, **__dVBoxStatuses)
140
141 __dValuesFlatSym = {</xsl:text>
142 <xsl:for-each select="//enum">
143 <xsl:variable name="ename">
144 <xsl:value-of select="@name"/>
145 </xsl:variable>
146 <xsl:for-each select="const">
147 <xsl:variable name="eval">
148 <xsl:value-of select="concat($ename, '_', @name)"/>
149 </xsl:variable>
150 <xsl:text>
151 '</xsl:text> <xsl:value-of select="$eval"/> <xsl:text>': </xsl:text>
152 <xsl:text>'</xsl:text> <xsl:value-of select="@name"/> <xsl:text>',</xsl:text>
153 </xsl:for-each>
154 </xsl:for-each>
155 <xsl:text>
156 # Result constants:</xsl:text>
157 <xsl:for-each select="//result[@value]">
158 <xsl:text>
159 '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
160 <xsl:text>'</xsl:text><xsl:value-of select="@name"/><xsl:text>',</xsl:text>
161 </xsl:for-each>
162 <xsl:text>
163 }
164
165 def __getattr__(self, sAttrName):
166 if self.__fIsSym:
167 oValue = self.__dValuesFlatSym.get(sAttrName)
168 else:
169 oValue = self.__dValuesFlat.get(sAttrName)
170 if oValue is None:
171 raise AttributeError
172 return oValue
173
174 def all_values(self, sEnumName):
175 """ Returns a dictionary with all the value names for a given enum type. """
176 if self.__fIsSym:
177 dValues = self.__dValuesSym.get(sEnumName)
178 else:
179 dValues = self.__dValues.get(sEnumName)
180 if dValues is None:
181 dValues = {}
182 return dValues
183
184</xsl:text>
185</xsl:template>
186</xsl:stylesheet>
187
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