VirtualBox

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

Last change on this file since 59808 was 59808, checked in by vboxsync, 9 years ago

no space at the end (fixes a pylint warning)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 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: 59808 $";
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 <!-- hack alert: force new output element to avoid large reallocations. -->
77 <xsl:text disable-output-escaping="yes"><![CDATA[
78 }
79
80 __dValuesSym = {]]></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> <xsl:value-of select="@name"/> <xsl:text>': '</xsl:text>
87 <xsl:value-of select="@name"/>
88 <xsl:text>',</xsl:text>
89 </xsl:for-each>
90 <xsl:text>
91 },</xsl:text>
92 </xsl:for-each>
93 <!-- hack alert: force new output element to avoid large reallocations. -->
94 <xsl:text disable-output-escaping="yes"><![CDATA[
95 }
96
97 __dValuesFlat = {]]></xsl:text>
98 <xsl:for-each select="//enum">
99 <xsl:variable name="ename">
100 <xsl:value-of select="@name"/>
101 </xsl:variable>
102 <xsl:for-each select="const">
103 <xsl:text>
104 '</xsl:text> <xsl:value-of select="$ename"/> <xsl:text>_</xsl:text>
105 <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
106 <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
107 </xsl:for-each>
108 </xsl:for-each>
109 <!-- hack alert: force new output element to avoid large reallocations. -->
110 <xsl:text disable-output-escaping="yes"><![CDATA[
111 # Result constants:]]></xsl:text>
112 <xsl:for-each select="//result[@value]">
113 <xsl:text>
114 '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
115 <xsl:value-of select="@value"/><xsl:text>,</xsl:text>
116 </xsl:for-each>
117 <!-- hack alert: force new output element to avoid large reallocations. -->
118 <xsl:text>
119 }
120
121 __dValuesFlatSym = {</xsl:text>
122 <xsl:for-each select="//enum">
123 <xsl:variable name="ename">
124 <xsl:value-of select="@name"/>
125 </xsl:variable>
126 <xsl:for-each select="const">
127 <xsl:variable name="eval">
128 <xsl:value-of select="concat($ename, '_', @name)"/>
129 </xsl:variable>
130 <xsl:text>
131 '</xsl:text> <xsl:value-of select="$eval"/> <xsl:text>': </xsl:text>
132 <xsl:text>'</xsl:text> <xsl:value-of select="@name"/> <xsl:text>',</xsl:text>
133 </xsl:for-each>
134 </xsl:for-each>
135 <xsl:text>
136 # Result constants:</xsl:text>
137 <xsl:for-each select="//result[@value]">
138 <xsl:text>
139 '</xsl:text> <xsl:value-of select="@name"/> <xsl:text>': </xsl:text>
140 <xsl:text>'</xsl:text><xsl:value-of select="@name"/><xsl:text>',</xsl:text>
141 </xsl:for-each>
142 <xsl:text>
143 }
144
145 def __getattr__(self, sAttrName):
146 if self.__fIsSym:
147 oValue = self.__dValuesFlatSym.get(sAttrName)
148 else:
149 oValue = self.__dValuesFlat.get(sAttrName)
150 if oValue is None:
151 raise AttributeError
152 return oValue
153
154 def all_values(self, sEnumName):
155 """ Returns a dictionary with all the value names for a given enum type. """
156 if self.__fIsSym:
157 dValues = self.__dValuesSym.get(sEnumName)
158 else:
159 dValues = self.__dValues.get(sEnumName)
160 if dValues is None:
161 dValues = {}
162 return dValues
163
164</xsl:text>
165</xsl:template>
166</xsl:stylesheet>
167
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