OLD | NEW |
1 <!-- Generate a C header file from the Modem Manager specification. | 1 <!-- Generate a C header file from the Modem Manager specification. |
2 | 2 |
3 Copyright (C) 2006, 2007 Collabora Limited | 3 Copyright (C) 2006, 2007 Collabora Limited |
4 | 4 |
5 This library is free software; you can redistribute it and/or | 5 This library is free software; you can redistribute it and/or |
6 modify it under the terms of the GNU Lesser General Public | 6 modify it under the terms of the GNU Lesser General Public |
7 License as published by the Free Software Foundation; either | 7 License as published by the Free Software Foundation; either |
8 version 2.1 of the License, or (at your option) any later version. | 8 version 2.1 of the License, or (at your option) any later version. |
9 | 9 |
10 This library is distributed in the hope that it will be useful, | 10 This library is distributed in the hope that it will be useful, |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 Lesser General Public License for more details. | 13 Lesser General Public License for more details. |
14 | 14 |
15 You should have received a copy of the GNU Lesser General Public | 15 You should have received a copy of the GNU Lesser General Public |
16 License along with this library; if not, write to the Free Software | 16 License along with this library; if not, write to the Free Software |
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18 --> | 18 --> |
19 | |
20 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | 19 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
21 xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" | 20 xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" |
22 exclude-result-prefixes="tp"> | 21 exclude-result-prefixes="tp"> |
23 <!--Don't move the declaration of the HTML namespace up here - XMLNSs | 22 <!--Don't move the declaration of the HTML namespace up here - XMLNSs |
24 don't work ideally in the presence of two things that want to use the | 23 don't work ideally in the presence of two things that want to use the |
25 absence of a prefix, sadly. --> | 24 absence of a prefix, sadly. --> |
26 | 25 |
| 26 <xsl:strip-space elements="node interface property tp:errors tp:mapping |
| 27 tp:member"/> |
27 <xsl:template match="*" mode="identity"> | 28 <xsl:template match="*" mode="identity"> |
28 <xsl:copy> | 29 <xsl:copy> |
29 <xsl:apply-templates mode="identity"/> | 30 <xsl:apply-templates mode="identity"/> |
30 </xsl:copy> | 31 </xsl:copy> |
31 </xsl:template> | 32 </xsl:template> |
32 | |
33 <xsl:template match="tp:docstring"> | 33 <xsl:template match="tp:docstring"> |
34 </xsl:template> | 34 </xsl:template> |
35 | |
36 <xsl:template match="tp:realdocstring"> | 35 <xsl:template match="tp:realdocstring"> |
37 /* <xsl:apply-templates select="node()" mode="identity"/> */ | 36 /* <xsl:apply-templates select="node()" mode="identity"/> */ |
38 </xsl:template> | 37 </xsl:template> |
39 | |
40 <xsl:template match="tp:errors"> | 38 <xsl:template match="tp:errors"> |
41 <xsl:apply-templates/> | 39 <xsl:apply-templates/> |
42 </xsl:template> | 40 </xsl:template> |
43 | |
44 <xsl:template match="tp:generic-types"> | 41 <xsl:template match="tp:generic-types"> |
45 <xsl:call-template name="do-types"/> | 42 <xsl:call-template name="do-types"/> |
46 </xsl:template> | 43 </xsl:template> |
47 | |
48 <xsl:template name="do-types"> | 44 <xsl:template name="do-types"> |
49 <xsl:if test="tp:simple-type"> | 45 <xsl:if test="tp:simple-type"> |
50 <xsl:apply-templates select="tp:simple-type"/> | 46 <xsl:apply-templates select="tp:simple-type"/> |
51 </xsl:if> | 47 </xsl:if> |
52 | |
53 <xsl:if test="tp:enum"> | 48 <xsl:if test="tp:enum"> |
54 <xsl:apply-templates select="tp:enum"/> | 49 <xsl:apply-templates select="tp:enum"/> |
55 </xsl:if> | 50 </xsl:if> |
56 | |
57 <xsl:if test="tp:flags"> | 51 <xsl:if test="tp:flags"> |
58 <xsl:apply-templates select="tp:flags"/> | 52 <xsl:apply-templates select="tp:flags"/> |
59 </xsl:if> | 53 </xsl:if> |
60 </xsl:template> | 54 </xsl:template> |
61 | |
62 <xsl:template match="tp:error"> | 55 <xsl:template match="tp:error"> |
63 <xsl:apply-templates select="tp:docstring"/> | 56 <xsl:apply-templates select="tp:docstring"/> |
64 <xsl:variable name="nameprefix"> | 57 <xsl:variable name="nameprefix"> |
65 <xsl:value-of select="translate(substring-after(../@namespace, 'org.free
desktop.ModemManager.'), | 58 <xsl:value-of select="translate(substring-after(../@namespace, 'org.free
desktop.ModemManager.'), |
66 'abcdefghijklmnopqrstuvwxyz. ', | 59 'abcdefghijklmnopqrstuvwxyz. ', |
67 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> | 60 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> |
68 </xsl:variable> | 61 </xsl:variable> |
69 <xsl:variable name="name"> | 62 <xsl:variable name="name"> |
70 <xsl:value-of select="translate(@name, | 63 <xsl:value-of select="translate(@name, |
71 'abcdefghijklmnopqrstuvwxyz. ', | 64 'abcdefghijklmnopqrstuvwxyz. ', |
72 'ABCDEFGHIJKLMNOPQRSTUVWXYZ__')"/> | 65 'ABCDEFGHIJKLMNOPQRSTUVWXYZ__')"/> |
73 </xsl:variable> | 66 </xsl:variable> |
74 #define <xsl:value-of select="concat('MM_ERROR_', $nameprefix, '_', $name, ' ')"
/> "<xsl:value-of select="translate(@name, ' ', '')"/>" | 67 #define <xsl:value-of select="concat('MM_ERROR_', $nameprefix, '_', $name)"/> "<
xsl:value-of select="translate(@name, ' ', '')"/>"</xsl:template> |
75 </xsl:template> | |
76 | 68 |
77 <xsl:template match="tp:flags"> | 69 <xsl:template match="tp:flags"> |
78 /* <xsl:value-of select="@name"/> */ | 70 /* <xsl:value-of select="@name"/> flag values */ |
79 <xsl:apply-templates select="tp:docstring" /> | 71 <xsl:apply-templates select="tp:docstring" /> |
80 <xsl:variable name="value-prefix"> | 72 <xsl:variable name="value-prefix"> |
81 <xsl:choose> | 73 <xsl:choose> |
82 <xsl:when test="@value-prefix"> | 74 <xsl:when test="@value-prefix"> |
83 <xsl:value-of select="@value-prefix"/> | 75 <xsl:value-of select="@value-prefix"/> |
84 </xsl:when> | 76 </xsl:when> |
85 <xsl:otherwise> | 77 <xsl:otherwise> |
86 <xsl:value-of select="@name"/> | 78 <xsl:value-of select="@name"/> |
87 </xsl:otherwise> | 79 </xsl:otherwise> |
88 </xsl:choose> | 80 </xsl:choose> |
89 </xsl:variable> | 81 </xsl:variable> |
90 <xsl:for-each select="tp:flag"> | 82 <xsl:for-each select="tp:flag"> |
91 <xsl:choose> | 83 <xsl:choose> |
92 <xsl:when test="tp:docstring"> | 84 <xsl:when test="tp:docstring"> |
93 » <xsl:apply-templates select="tp:docstring" /> | 85 » <xsl:apply-templates select="tp:docstring"/> |
94 </xsl:when> | 86 </xsl:when> |
95 </xsl:choose> | 87 </xsl:choose> |
96 #define <xsl:value-of select="concat($value-prefix, '_', @suffix, ' ') "/><xsl:v
alue-of select="@value"/> | 88 #define <xsl:value-of select="concat($value-prefix, '_', @suffix)"/><xsl:text> <
/xsl:text><xsl:value-of select="@value"/> |
97 | 89 </xsl:for-each><xsl:text> |
98 </xsl:for-each> | 90 </xsl:text> |
99 </xsl:template> | 91 </xsl:template> |
100 | 92 |
101 <xsl:template match="tp:enum"> | 93 <xsl:template match="tp:enum"> |
102 /* <xsl:value-of select="@name"/> */ | 94 /* <xsl:value-of select="@name"/> enum values */ |
103 <xsl:apply-templates select="tp:docstring" /> | 95 <xsl:apply-templates select="tp:docstring" /> |
104 <xsl:variable name="value-prefix"> | 96 <xsl:variable name="value-prefix"> |
105 <xsl:choose> | 97 <xsl:choose> |
106 <xsl:when test="@value-prefix"> | 98 <xsl:when test="@value-prefix"> |
107 <xsl:value-of select="@value-prefix"/> | 99 <xsl:value-of select="@value-prefix"/> |
108 </xsl:when> | 100 </xsl:when> |
109 <xsl:otherwise> | 101 <xsl:otherwise> |
110 <xsl:value-of select="@name"/> | 102 <xsl:value-of select="@name"/> |
111 </xsl:otherwise> | 103 </xsl:otherwise> |
112 </xsl:choose> | 104 </xsl:choose> |
113 </xsl:variable> | 105 </xsl:variable> |
114 <xsl:for-each select="tp:enumvalue"> | 106 <xsl:for-each select="tp:enumvalue"> |
115 <xsl:choose> | 107 <xsl:choose> |
116 <xsl:when test="tp:docstring"> | 108 <xsl:when test="tp:docstring"> |
117 <xsl:apply-templates select="tp:docstring" /> | 109 <xsl:apply-templates select="tp:docstring" /> |
118 </xsl:when> | 110 </xsl:when> |
119 </xsl:choose> | 111 </xsl:choose> |
120 #define <xsl:value-of select="concat($value-prefix, '_', @suffix, ' ')"/><xsl:va
lue-of select="@value"/> | 112 #define <xsl:value-of select="concat($value-prefix, '_', @suffix, ' ')"/><xsl:va
lue-of select="@value"/> |
121 </xsl:for-each> | 113 </xsl:for-each><xsl:text> |
| 114 </xsl:text> |
122 </xsl:template> | 115 </xsl:template> |
123 | 116 |
124 <xsl:template match="tp:possible-errors/tp:error"> | 117 <xsl:template match="tp:possible-errors/tp:error"> |
125 <xsl:variable name="name" select="@name"/> | 118 <xsl:variable name="name" select="@name"/> |
126 <xsl:choose> | 119 <xsl:choose> |
127 <xsl:when test="tp:docstring"> | 120 <xsl:when test="tp:docstring"> |
128 <xsl:apply-templates select="tp:docstring"/> | 121 <xsl:apply-templates select="tp:docstring"/> |
129 </xsl:when> | 122 </xsl:when> |
130 <xsl:when test="//tp:errors/tp:error[concat(../@namespace, '.', translate(
@name, ' ', ''))=$name]/tp:docstring"> | 123 <xsl:when test="//tp:errors/tp:error[concat(../@namespace, '.', translate(
@name, ' ', ''))=$name]/tp:docstring"> |
131 <xsl:apply-templates select="//tp:errors/tp:error[concat(../@namespace,
'.', translate(@name, ' ', ''))=$name]/tp:docstring"/> <em xmlns="http://www.w3.
org/1999/xhtml">(generic description)</em> | 124 <xsl:apply-templates select="//tp:errors/tp:error[concat(../@namespace,
'.', translate(@name, ' ', ''))=$name]/tp:docstring"/> <em xmlns="http://www.w3.
org/1999/xhtml">(generic description)</em> |
132 </xsl:when> | 125 </xsl:when> |
133 <xsl:otherwise> | 126 <xsl:otherwise> |
134 (Undocumented.) | 127 (Undocumented.) |
135 </xsl:otherwise> | 128 </xsl:otherwise> |
136 </xsl:choose> | 129 </xsl:choose> |
137 </xsl:template> | 130 </xsl:template> |
138 | 131 |
139 <xsl:template match="signal"> | 132 <xsl:template match="signal"> |
140 <xsl:variable name="varname"> | 133 <xsl:variable name="varname"> |
141 <xsl:value-of select="translate(@name, | 134 <xsl:value-of select="translate(@name, |
142 'abcdefghijklmnopqrstuvwxyz. ', | 135 'abcdefghijklmnopqrstuvwxyz. ', |
143 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> | 136 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> |
144 </xsl:variable> | 137 </xsl:variable> |
145 #define <xsl:value-of select="concat('MM_SIGNAL_', $varname)"/> "<xsl:value-of s
elect="@name"/>" | 138 <xsl:variable name="intname"> |
146 | 139 <xsl:choose> |
147 </xsl:template> | 140 <xsl:when test="starts-with(../@name, 'org.freedesktop.ModemManager.')"> |
| 141 <xsl:value-of select="translate(substring-after(../@name, 'org.freedes
ktop.ModemManager.'), |
| 142 » » » 'abcdefghijklmnopqrstuvwxyz. ', |
| 143 » » » 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> |
| 144 </xsl:when> |
| 145 <xsl:otherwise> |
| 146 <xsl:text>MANAGER</xsl:text> |
| 147 </xsl:otherwise> |
| 148 </xsl:choose> |
| 149 </xsl:variable> |
| 150 #define <xsl:value-of select="concat('MM_', $intname, '_SIGNAL_', $varname)"/> "
<xsl:value-of select="@name"/>"</xsl:template> |
148 | 151 |
149 <xsl:template match="method"> | 152 <xsl:template match="method"> |
150 <xsl:variable name="varname"> | 153 <xsl:variable name="varname"> |
151 <xsl:value-of select="translate(@name, | 154 <xsl:value-of select="translate(@name, |
152 'abcdefghijklmnopqrstuvwxyz. ', | 155 'abcdefghijklmnopqrstuvwxyz. ', |
153 » » » 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> | 156 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> |
154 </xsl:variable> | 157 </xsl:variable> |
155 #define <xsl:value-of select="concat('MM_METHOD_', $varname)"/> "<xsl:value-of s
elect="@name"/>" | 158 <xsl:variable name="intname"> |
156 </xsl:template> | 159 <xsl:choose> |
| 160 <xsl:when test="starts-with(../@name, 'org.freedesktop.ModemManager.')"> |
| 161 <xsl:value-of select="translate(substring-after(../@name, 'org.freedes
ktop.ModemManager.'), |
| 162 » » » 'abcdefghijklmnopqrstuvwxyz. ', |
| 163 » » » 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> |
| 164 </xsl:when> |
| 165 <xsl:otherwise> |
| 166 <xsl:text>MANAGER</xsl:text> |
| 167 </xsl:otherwise> |
| 168 </xsl:choose> |
| 169 </xsl:variable> |
| 170 #define <xsl:value-of select="concat('MM_', $intname, '_METHOD_', $varname)"/> "
<xsl:value-of select="@name"/>"</xsl:template> |
157 | 171 |
158 <xsl:template match="tp:copyright"> | 172 <xsl:template match="tp:copyright"> |
159 </xsl:template> | 173 </xsl:template> |
160 | 174 |
161 <xsl:output method="text" indent="no" encoding="ascii" | 175 <xsl:output method="text" indent="no" encoding="ascii" |
162 omit-xml-declaration="yes" /> | 176 omit-xml-declaration="yes" /> |
163 | 177 |
164 <xsl:template match="/tp:spec"> | 178 <xsl:template match="/tp:spec"> |
165 /* Generated Header file do not edit */ | 179 /* Generated Header file do not edit */ |
166 /* <xsl:value-of select="tp:title"/> */ | 180 /* <xsl:value-of select="tp:title"/> */ |
167 | |
168 <xsl:if test="tp:version"> | 181 <xsl:if test="tp:version"> |
169 /* | 182 /* |
170 * <xsl:text> version </xsl:text> <xsl:value-of select="tp:version"/> | 183 * <xsl:text> version </xsl:text> <xsl:value-of select="tp:version"/> |
171 */ | 184 */ |
172 </xsl:if> | 185 </xsl:if> |
173 | |
174 #define MM_MODEMMANAGER_PATH "/org/freedesktop/ModemManager" | 186 #define MM_MODEMMANAGER_PATH "/org/freedesktop/ModemManager" |
175 #define MM_MODEMMANAGER_SERVICE "org.freedesktop.ModemManager" | 187 #define MM_MODEMMANAGER_SERVICE "org.freedesktop.ModemManager" |
176 | 188 |
177 /************** | 189 /************** |
178 * Interfaces * | 190 * Interfaces * |
179 **************/ | 191 **************/ |
180 <xsl:for-each select="node/interface"> | 192 <xsl:for-each select="node/interface"> |
181 <xsl:apply-templates select="tp:docstring"/> | 193 <xsl:apply-templates select="tp:docstring"/> |
182 <xsl:variable name="varname"> | 194 <xsl:variable name="varname"> |
183 <xsl:choose> | 195 <xsl:choose> |
184 <xsl:when test="contains(@name, 'org.freedesktop.ModemManager.')"> | 196 <xsl:when test="starts-with(@name, 'org.freedesktop.ModemManager.')"> |
185 <xsl:value-of select="translate(substring-after(@name, 'org.freedesktop.
ModemManager.'), | 197 <xsl:value-of select="translate(substring-after(@name, 'org.freedesktop.
ModemManager.'), |
186 'abcdefghijklmnopqrstuvwxyz. ', | 198 'abcdefghijklmnopqrstuvwxyz. ', |
187 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> | 199 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> |
188 </xsl:when> | 200 </xsl:when> |
189 <xsl:otherwise> | 201 <xsl:otherwise> |
190 <xsl:value-of select="translate(substring-after(@name, 'org.freedesktop.
'), | 202 <xsl:value-of select="translate(substring-after(@name, 'org.freedesktop.
'), |
191 'abcdefghijklmnopqrstuvwxyz. ', | 203 'abcdefghijklmnopqrstuvwxyz. ', |
192 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> | 204 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/> |
193 </xsl:otherwise> | 205 </xsl:otherwise> |
194 </xsl:choose> | 206 </xsl:choose> |
195 </xsl:variable> | 207 </xsl:variable> |
196 #define <xsl:value-of select="concat('MM_', $varname, '_INTERFACE ')"/> "<xsl:va
lue-of select="@name"/>"</xsl:for-each> | 208 #define <xsl:value-of select="concat('MM_', $varname, '_INTERFACE ')"/> "<xsl:va
lue-of select="@name"/>"</xsl:for-each> |
197 | 209 |
198 /*************** | 210 /*********************** |
199 * Enums/Flags * | 211 * Methods/Enums/Flags * |
200 ***************/ | 212 ***********************/ |
201 <xsl:apply-templates select="node"/> | 213 <xsl:for-each select="node/interface"> |
202 | 214 /* |
| 215 * Interface <xsl:value-of select="@name"/> |
| 216 */ |
| 217 <xsl:apply-templates select="method"/> |
| 218 <xsl:if test="count(method[*])!=0"> |
| 219 <xsl:text> |
| 220 </xsl:text> |
| 221 </xsl:if> |
| 222 <xsl:apply-templates select="signal"/> |
| 223 <xsl:if test="count(signal[*])!=0"> |
| 224 <xsl:text> |
| 225 </xsl:text> |
| 226 </xsl:if> |
| 227 <xsl:apply-templates select="tp:enum"/> |
| 228 <xsl:apply-templates select="tp:flags"/> |
| 229 </xsl:for-each> |
203 /********** | 230 /********** |
204 * Errors * | 231 * Errors * |
205 **********/ | 232 **********/ |
206 <xsl:apply-templates select="tp:errors"/> | 233 <xsl:apply-templates select="tp:errors"/> |
207 | 234 |
| 235 <!-- Ensure that the file ends with a newline --> |
| 236 <xsl:text> |
| 237 </xsl:text> |
208 </xsl:template> | 238 </xsl:template> |
209 </xsl:stylesheet> | 239 </xsl:stylesheet> |
210 | 240 |
211 <!-- vim:set sw=2 sts=2 et: --> | 241 <!-- vim:set sw=2 sts=2 et: --> |
OLD | NEW |