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 Sun Microsystems, Inc.
|
---|
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 | Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
22 | Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
23 | additional information or have any questions.
|
---|
24 | -->
|
---|
25 |
|
---|
26 | <xsl:output
|
---|
27 | method="text"
|
---|
28 | version="1.0"
|
---|
29 | encoding="utf-8"
|
---|
30 | indent="no"/>
|
---|
31 |
|
---|
32 | <xsl:template match="/">
|
---|
33 | <xsl:text># Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
34 | #
|
---|
35 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
36 | # available from http://www.virtualbox.org. This file is free software;
|
---|
37 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
38 | # General Public License (GPL) as published by the Free Software
|
---|
39 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
40 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
41 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
42 | #
|
---|
43 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
44 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
45 | # additional information or have any questions.
|
---|
46 | #
|
---|
47 | # This file is autogenerated from VirtualBox.xidl, DO NOT EDIT!
|
---|
48 | #
|
---|
49 | </xsl:text>
|
---|
50 | class VirtualBoxReflectionInfo:
|
---|
51 | def __init__(self, isSym):
|
---|
52 | self.isSym = isSym
|
---|
53 |
|
---|
54 | _Values = {<xsl:for-each select="//enum">
|
---|
55 | '<xsl:value-of select="@name"/>':{
|
---|
56 | <xsl:for-each select="const">'<xsl:value-of select="@name"/>':<xsl:value-of select="@value"/><xsl:if test="not(position()=last())">,</xsl:if>
|
---|
57 | </xsl:for-each>}<xsl:if test="not(position()=last())">,</xsl:if>
|
---|
58 |
|
---|
59 | </xsl:for-each>}
|
---|
60 |
|
---|
61 | _ValuesSym = {<xsl:for-each select="//enum">
|
---|
62 | '<xsl:value-of select="@name"/>':{
|
---|
63 | <xsl:for-each select="const">'<xsl:value-of select="@name"/>': '<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">,</xsl:if>
|
---|
64 | </xsl:for-each>}<xsl:if test="not(position()=last())">,</xsl:if>
|
---|
65 |
|
---|
66 | </xsl:for-each>}
|
---|
67 |
|
---|
68 | _ValuesFlat = {<xsl:for-each select="//enum">
|
---|
69 | <xsl:variable name="ename">
|
---|
70 | <xsl:value-of select="@name"/>
|
---|
71 | </xsl:variable>
|
---|
72 | <xsl:for-each select="const">
|
---|
73 | '<xsl:value-of select="$ename"/>_<xsl:value-of select="@name"/>':<xsl:value-of select="@value"/><xsl:if test="not(position()=last())">,</xsl:if>
|
---|
74 | </xsl:for-each>
|
---|
75 | <xsl:if test="not(position()=last())">,</xsl:if>
|
---|
76 | </xsl:for-each>}
|
---|
77 |
|
---|
78 | _ValuesFlatSym = {<xsl:for-each select="//enum">
|
---|
79 | <xsl:variable name="ename">
|
---|
80 | <xsl:value-of select="@name"/>
|
---|
81 | </xsl:variable>
|
---|
82 | <xsl:for-each select="const">
|
---|
83 | <xsl:variable name="eval">
|
---|
84 | <xsl:value-of select="concat($ename, '_', @name)"/>
|
---|
85 | </xsl:variable>
|
---|
86 | '<xsl:value-of select="$eval"/>': '<xsl:value-of select="@name"/>'<xsl:if test="not(position()=last())">,</xsl:if>
|
---|
87 | </xsl:for-each>
|
---|
88 | <xsl:if test="not(position()=last())">,</xsl:if>
|
---|
89 | </xsl:for-each>}
|
---|
90 |
|
---|
91 | def __getattr__(self,attr):
|
---|
92 | if self.isSym:
|
---|
93 | v = self._ValuesFlatSym.get(attr)
|
---|
94 | else:
|
---|
95 | v = self._ValuesFlat.get(attr)
|
---|
96 | if v is not None:
|
---|
97 | return v
|
---|
98 | else:
|
---|
99 | raise AttributeError
|
---|
100 |
|
---|
101 | def all_values(self,enum_name):
|
---|
102 | if self.isSym:
|
---|
103 | vals = self._ValuesSym.get(enum_name)
|
---|
104 | else:
|
---|
105 | vals = self._Values.get(enum_name)
|
---|
106 | if vals is not None:
|
---|
107 | return vals
|
---|
108 | else:
|
---|
109 | return {}
|
---|
110 |
|
---|
111 | </xsl:template>
|
---|
112 | </xsl:stylesheet>
|
---|