1 | <?xml version="1.0" ?> |
---|
2 | |
---|
3 | <!-- |
---|
4 | Copyright (c) 2002-2003 The Trustees of Indiana University. |
---|
5 | All rights reserved. |
---|
6 | Copyright (c) 2000-2001 University of Notre Dame. All rights reserved. |
---|
7 | |
---|
8 | The software included in this source file is licensed under the terms and |
---|
9 | conditions of the Software License, version 1.0, in the file LICENSE at the |
---|
10 | top level of the Caramel distribution. --> |
---|
11 | |
---|
12 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
---|
13 | <xsl:template name="unparse-cpp"> |
---|
14 | <xsl:param name="typeref"/> |
---|
15 | <xsl:param name="definition_list"/> |
---|
16 | <xsl:param name="priority">0</xsl:param> |
---|
17 | <xsl:param name="ignore-cv" select="false()"/> |
---|
18 | <xsl:param name="ignore-references" select="false()"/> |
---|
19 | <xsl:param name="notations"/> |
---|
20 | <xsl:param name="ignore-notation" select="false()"/> |
---|
21 | <xsl:param name="print-updated-notation" select="false()"/> |
---|
22 | <xsl:param name="use-typename" select="false()"/> |
---|
23 | <xsl:param name="const-if-not-mutable-value" select="'const-if-not-mutable'"/> |
---|
24 | |
---|
25 | <xsl:variable name="notation_check"> |
---|
26 | <xsl:if test="not($ignore-notation)"> <!-- Prevent infinite recursion --> |
---|
27 | <xsl:call-template name="unparse-cpp"> |
---|
28 | <xsl:with-param name="typeref" select="$typeref"/> |
---|
29 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
30 | <xsl:with-param name="priority">0</xsl:with-param> |
---|
31 | <xsl:with-param name="ignore-cv" select="true()"/> |
---|
32 | <xsl:with-param name="ignore-references" select="true()"/> |
---|
33 | <xsl:with-param name="notations" select="$notations"/> |
---|
34 | <xsl:with-param name="ignore-notation" select="true()"/> |
---|
35 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
36 | </xsl:call-template> |
---|
37 | </xsl:if> |
---|
38 | </xsl:variable> |
---|
39 | |
---|
40 | <!-- |
---|
41 | <xsl:message>Notation check: <xsl:value-of select="$notation_check"/> |
---|
42 | Notations: <xsl:value-of select="$notations"/> |
---|
43 | </xsl:message> --> |
---|
44 | |
---|
45 | <xsl:variable name="this_op_priority" select="document('cpp-operators.xml')/operator-list/op[@name=name($typeref)]/apply/@priority"/> |
---|
46 | |
---|
47 | <xsl:variable name="result"> |
---|
48 | |
---|
49 | <xsl:variable name="subcall_priority"> |
---|
50 | <xsl:choose> |
---|
51 | <xsl:when test="true() or ($this_op_priority > $priority)"> |
---|
52 | <xsl:value-of select="$this_op_priority"/> |
---|
53 | </xsl:when> |
---|
54 | <!-- <xsl:otherwise>0</xsl:otherwise> --> |
---|
55 | </xsl:choose> |
---|
56 | </xsl:variable> |
---|
57 | |
---|
58 | <xsl:if test="$this_op_priority <= $priority">(</xsl:if> |
---|
59 | |
---|
60 | <xsl:choose> |
---|
61 | |
---|
62 | <xsl:when test="name($typeref)='sample-value'" |
---|
63 | >boost::sample_value < <xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="ignore-references" select="$ignore-references"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template> >()</xsl:when> |
---|
64 | |
---|
65 | <xsl:when test="name($typeref)='reference-to'" |
---|
66 | ><xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="priority" select="$subcall_priority"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template><xsl:if test="not($ignore-references)"> &</xsl:if></xsl:when> |
---|
67 | |
---|
68 | <xsl:when test="name($typeref)='pointer-to'" |
---|
69 | ><xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="priority" select="$subcall_priority"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/></xsl:call-template> *</xsl:when> |
---|
70 | |
---|
71 | <xsl:when test="name($typeref)='const'" |
---|
72 | ><xsl:if test="not($ignore-cv)">const </xsl:if><xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="priority" select="$subcall_priority"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="ignore-references" select="$ignore-references"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template> |
---|
73 | </xsl:when> |
---|
74 | |
---|
75 | <xsl:when test="name($typeref)='const-if-not-mutable'" |
---|
76 | ><xsl:if test="not($ignore-cv)"><xsl:value-of select="$const-if-not-mutable-value"/><xsl:if test="$const-if-not-mutable-value"><xsl:text> </xsl:text></xsl:if></xsl:if><xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="priority" select="$subcall_priority"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="ignore-references" select="$ignore-references"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template> |
---|
77 | </xsl:when> |
---|
78 | |
---|
79 | <xsl:when test="name($typeref)='volatile'" |
---|
80 | ><xsl:if test="not($ignore-cv)">volatile </xsl:if><xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="priority" select="$subcall_priority"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="ignore-references" select="$ignore-references"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template> |
---|
81 | </xsl:when> |
---|
82 | |
---|
83 | <xsl:when test="name($typeref)='apply-template'"> |
---|
84 | <xsl:value-of select="$typeref/@name"/><<xsl:for-each select="$typeref/*"> |
---|
85 | <xsl:if test="position()!=1">, </xsl:if><xsl:comment/> |
---|
86 | <xsl:call-template name="unparse-cpp"> |
---|
87 | <xsl:with-param name="typeref" select="."/> |
---|
88 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
89 | <xsl:with-param name="ignore-cv" select="$ignore-cv"/> |
---|
90 | <xsl:with-param name="notations" select="$notations"/> |
---|
91 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
92 | </xsl:call-template></xsl:for-each |
---|
93 | ><xsl:comment/>></xsl:when> |
---|
94 | |
---|
95 | <xsl:when test="name($typeref)='get-member-type'"> |
---|
96 | <xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template>::<xsl:value-of select="$typeref/@name"/> |
---|
97 | </xsl:when> |
---|
98 | |
---|
99 | <xsl:when test="name($typeref)='type'"> |
---|
100 | <xsl:variable name="typeref_value" select="normalize-space(substring-before(substring-after($definition_list,concat('@(@',$typeref/@name,'=')),'@)@'))"/> |
---|
101 | <xsl:choose> |
---|
102 | <xsl:when test="$typeref_value=''"> |
---|
103 | <xsl:value-of select="$typeref/@name"/><xsl:comment/> |
---|
104 | </xsl:when> |
---|
105 | <xsl:otherwise> |
---|
106 | <xsl:value-of select="$typeref_value"/><xsl:comment/> |
---|
107 | </xsl:otherwise> |
---|
108 | </xsl:choose> |
---|
109 | </xsl:when> |
---|
110 | |
---|
111 | <xsl:when test="name($typeref)='documentation'"/> |
---|
112 | |
---|
113 | <xsl:when test="document('cpp-operators.xml')/operator-list/op[@name=name($typeref)]"> |
---|
114 | <xsl:variable name="op_file" select="document('cpp-operators.xml')/operator-list"/> |
---|
115 | <xsl:variable name="op_info" select="$op_file/op[@name=name($typeref)]/apply/."/> |
---|
116 | |
---|
117 | <xsl:call-template name="unparse-operator-definition"> |
---|
118 | <xsl:with-param name="typeref" select="$typeref"/> |
---|
119 | <xsl:with-param name="operator_nodeset" select="$op_info/child::node()"/> |
---|
120 | <xsl:with-param name="my_priority" select="$subcall_priority"/> |
---|
121 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
122 | <xsl:with-param name="notations" select="$notations"/> |
---|
123 | <xsl:with-param name="ignore-cv" select="$ignore-cv"/> |
---|
124 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
125 | <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/> |
---|
126 | </xsl:call-template> |
---|
127 | |
---|
128 | </xsl:when> |
---|
129 | |
---|
130 | <xsl:otherwise> |
---|
131 | (Unrecognized tag <xsl:value-of select="name($typeref)"/>) |
---|
132 | </xsl:otherwise> |
---|
133 | </xsl:choose> |
---|
134 | |
---|
135 | <!-- Close parenthesis code moved below --> |
---|
136 | |
---|
137 | </xsl:variable> |
---|
138 | |
---|
139 | <!-- <xsl:message>ignore-notation = <xsl:value-of select="$ignore-notation"/></xsl:message> --> |
---|
140 | <!-- <xsl:message>notation_check = <xsl:value-of select="$notation_check"/></xsl:message> --> |
---|
141 | <!-- <xsl:message>notations = <xsl:value-of select="$notations"/></xsl:message> --> |
---|
142 | <!-- <xsl:message>result = <xsl:value-of select="$result"/></xsl:message> --> |
---|
143 | |
---|
144 | <xsl:variable name="used_notation" select="boolean($notation_check) and boolean(substring-before(substring-after($notations, concat('@@(@@', $notation_check, '@@=@@')),'@@)@@'))"/> |
---|
145 | |
---|
146 | <xsl:variable name="notations2"> |
---|
147 | <!-- Possibly replace from result of unparse-operator-definition --> |
---|
148 | <xsl:choose> |
---|
149 | <xsl:when test="contains($result, ' *@@@* ')"> |
---|
150 | <xsl:value-of select="substring-after($result, ' *@@@* ')"/> |
---|
151 | </xsl:when> |
---|
152 | <xsl:otherwise> |
---|
153 | <xsl:value-of select="$notations"/> |
---|
154 | </xsl:otherwise> |
---|
155 | </xsl:choose> |
---|
156 | </xsl:variable> |
---|
157 | |
---|
158 | <xsl:variable name="result2"> |
---|
159 | <!-- Possibly replace from result of unparse-operator-definition --> |
---|
160 | <xsl:choose> |
---|
161 | <xsl:when test="contains($result, ' *@@@* ')"> |
---|
162 | <xsl:value-of select="substring-before($result, ' *@@@* ')"/> |
---|
163 | </xsl:when> |
---|
164 | <xsl:otherwise> |
---|
165 | <xsl:value-of select="$result"/> |
---|
166 | </xsl:otherwise> |
---|
167 | </xsl:choose> |
---|
168 | <!-- Close parenthesis code --> |
---|
169 | <xsl:if test="$this_op_priority <= $priority">)</xsl:if> |
---|
170 | </xsl:variable> |
---|
171 | |
---|
172 | <xsl:variable name="notation_varlist"> |
---|
173 | <xsl:choose> |
---|
174 | <xsl:when test="$used_notation"> |
---|
175 | <xsl:value-of select="substring-before(substring-after($notations2, concat('@@(@@', $notation_check, '@@=@@')), '@@)@@')"/> |
---|
176 | </xsl:when> |
---|
177 | <xsl:otherwise> |
---|
178 | <xsl:value-of select="$result2"/> |
---|
179 | </xsl:otherwise> |
---|
180 | </xsl:choose> |
---|
181 | </xsl:variable> |
---|
182 | |
---|
183 | <xsl:variable name="new_varlist" select="substring-after(normalize-space($notation_varlist), ' ')"/> |
---|
184 | |
---|
185 | <xsl:variable name="notation_var"> |
---|
186 | <xsl:choose> |
---|
187 | <xsl:when test="not($used_notation)"> |
---|
188 | <xsl:value-of select="$result2"/> |
---|
189 | </xsl:when> |
---|
190 | <xsl:when test="$new_varlist=''"> |
---|
191 | <xsl:value-of select="$notation_varlist"/> |
---|
192 | </xsl:when> |
---|
193 | <xsl:otherwise> |
---|
194 | <xsl:value-of select="substring-before(normalize-space($notation_varlist), ' ')"/> |
---|
195 | </xsl:otherwise> |
---|
196 | </xsl:choose> |
---|
197 | </xsl:variable> |
---|
198 | |
---|
199 | <!-- Generate new notation list --> |
---|
200 | <xsl:variable name="new_notations"> |
---|
201 | <xsl:choose> |
---|
202 | <xsl:when test="$used_notation"> |
---|
203 | <xsl:value-of select="normalize-space(concat('@@(@@', $notation_check, '@@=@@', $new_varlist, '@@)@@', $notations2))"/> |
---|
204 | <!-- Duplicate entries always use first occurrance, so I can optimize this --> |
---|
205 | </xsl:when> |
---|
206 | <xsl:otherwise><xsl:value-of select="$notations2"/></xsl:otherwise> |
---|
207 | </xsl:choose> |
---|
208 | </xsl:variable> |
---|
209 | |
---|
210 | <!-- <xsl:message>final_result = <xsl:value-of select="normalize-space($final_result)"/></xsl:message> --> |
---|
211 | |
---|
212 | <xsl:call-template name="add-typename"><xsl:with-param name="really-do-it" select="$use-typename"/><xsl:with-param name="type"><xsl:value-of select="normalize-space($notation_var)"/></xsl:with-param></xsl:call-template><xsl:if test="$print-updated-notation"> *@@@* <xsl:value-of select="$new_notations"/></xsl:if> |
---|
213 | |
---|
214 | </xsl:template> |
---|
215 | |
---|
216 | <xsl:template name="unparse-operator-definition"> |
---|
217 | <xsl:param name="typeref"/> |
---|
218 | <xsl:param name="operator_nodeset"/> |
---|
219 | <xsl:param name="current_start">1</xsl:param> |
---|
220 | <xsl:param name="my_priority"/> |
---|
221 | <xsl:param name="definition_list"/> |
---|
222 | <xsl:param name="notations"/> |
---|
223 | <xsl:param name="ignore-cv"/> |
---|
224 | <xsl:param name="self"/> |
---|
225 | <xsl:param name="use-code-block" select="false()"/> |
---|
226 | <xsl:param name="print-updated-notation" select="false()"/> |
---|
227 | <xsl:param name="const-if-not-mutable-value"/> |
---|
228 | |
---|
229 | <xsl:variable name="op_current" select="$operator_nodeset[position()=1]"/> |
---|
230 | <xsl:variable name="op_rest" select="$operator_nodeset[position()!=1]"/> |
---|
231 | |
---|
232 | <xsl:choose> |
---|
233 | |
---|
234 | <xsl:when test="count($operator_nodeset)=0"> |
---|
235 | <xsl:if test="$print-updated-notation"> *@@@* <xsl:value-of select="$notations"/></xsl:if> |
---|
236 | </xsl:when> |
---|
237 | |
---|
238 | <xsl:when test="$op_current != $op_current/../*"> <!-- If I am not an element --> |
---|
239 | <xsl:value-of select="$op_current"/> |
---|
240 | <xsl:call-template name="unparse-operator-definition"> |
---|
241 | <xsl:with-param name="typeref" select="$typeref"/> |
---|
242 | <xsl:with-param name="operator_nodeset" select="$op_rest"/> |
---|
243 | <xsl:with-param name="my_priority" select="$my_priority"/> |
---|
244 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
245 | <xsl:with-param name="notations" select="$notations"/> |
---|
246 | <xsl:with-param name="self" select="$self"/> |
---|
247 | <xsl:with-param name="use-code-block" select="$use-code-block"/> |
---|
248 | <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/> |
---|
249 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
250 | </xsl:call-template> |
---|
251 | </xsl:when> |
---|
252 | |
---|
253 | <xsl:when test="name($op_current)='name'"> |
---|
254 | <xsl:value-of select="$typeref/@name"/> |
---|
255 | <xsl:call-template name="unparse-operator-definition"> |
---|
256 | <xsl:with-param name="typeref" select="$typeref"/> |
---|
257 | <xsl:with-param name="operator_nodeset" select="$op_rest"/> |
---|
258 | <xsl:with-param name="my_priority" select="$my_priority"/> |
---|
259 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
260 | <xsl:with-param name="notations" select="$notations"/> |
---|
261 | <xsl:with-param name="ignore-cv" select="$ignore-cv"/> |
---|
262 | <xsl:with-param name="self" select="$self"/> |
---|
263 | <xsl:with-param name="use-code-block" select="$use-code-block"/> |
---|
264 | <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/> |
---|
265 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
266 | </xsl:call-template> |
---|
267 | </xsl:when> |
---|
268 | |
---|
269 | <xsl:when test="name($op_current)='self'"> |
---|
270 | <xsl:call-template name="concept.link"> |
---|
271 | <xsl:with-param name="name" select="string($self)"/> |
---|
272 | </xsl:call-template> |
---|
273 | <xsl:call-template name="unparse-operator-definition"> |
---|
274 | <xsl:with-param name="typeref" select="$typeref"/> |
---|
275 | <xsl:with-param name="operator_nodeset" select="$op_rest"/> |
---|
276 | <xsl:with-param name="my_priority" select="$my_priority"/> |
---|
277 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
278 | <xsl:with-param name="notations" select="$notations"/> |
---|
279 | <xsl:with-param name="ignore-cv" select="$ignore-cv"/> |
---|
280 | <xsl:with-param name="self" select="$self"/> |
---|
281 | <xsl:with-param name="use-code-block" select="$use-code-block"/> |
---|
282 | <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/> |
---|
283 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
284 | </xsl:call-template> |
---|
285 | </xsl:when> |
---|
286 | |
---|
287 | <xsl:when test="name($op_current)='arg'"> |
---|
288 | <xsl:variable name="num" select="$op_current/@num"/> |
---|
289 | <xsl:variable name="assoc" select="$op_current/../@assoc"/> |
---|
290 | <xsl:variable name="my_priority_before" select="$my_priority"/> |
---|
291 | <xsl:variable name="my_priority"> |
---|
292 | <xsl:choose> |
---|
293 | <xsl:when test="count($op_current/@priority)"> |
---|
294 | <xsl:value-of select="$op_current/@priority"/> |
---|
295 | </xsl:when> |
---|
296 | <xsl:when test="$assoc and ($num = $assoc)"> |
---|
297 | <xsl:value-of select="$my_priority_before - 1"/> |
---|
298 | </xsl:when> |
---|
299 | <xsl:otherwise> |
---|
300 | <xsl:value-of select="$my_priority"/> |
---|
301 | </xsl:otherwise> |
---|
302 | </xsl:choose> |
---|
303 | </xsl:variable> |
---|
304 | <xsl:variable name="typeref-result"> |
---|
305 | <xsl:call-template name="unparse-cpp"> |
---|
306 | <xsl:with-param name="typeref" select="$typeref/*[position()=$num]"/> |
---|
307 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
308 | <xsl:with-param name="priority" select="$my_priority"/> |
---|
309 | <xsl:with-param name="ignore-cv" select="$ignore-cv"/> |
---|
310 | <xsl:with-param name="notations" select="$notations"/> |
---|
311 | <xsl:with-param name="print-updated-notation" select="true()"/> |
---|
312 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
313 | </xsl:call-template> |
---|
314 | </xsl:variable> |
---|
315 | <xsl:variable name="typeref-print" select="normalize-space(substring-before($typeref-result, ' *@@@* '))"/> |
---|
316 | <xsl:variable name="new_notations" select="normalize-space(substring-after($typeref-result, ' *@@@* '))"/> |
---|
317 | |
---|
318 | <xsl:choose> |
---|
319 | <xsl:when test="$use-code-block"> |
---|
320 | <type><xsl:value-of select="$typeref-print"/></type> |
---|
321 | </xsl:when> |
---|
322 | <xsl:otherwise> |
---|
323 | <xsl:value-of select="$typeref-print"/> |
---|
324 | </xsl:otherwise> |
---|
325 | </xsl:choose> |
---|
326 | |
---|
327 | <xsl:call-template name="unparse-operator-definition"> |
---|
328 | <xsl:with-param name="typeref" select="$typeref"/> |
---|
329 | <xsl:with-param name="operator_nodeset" select="$op_rest"/> |
---|
330 | <xsl:with-param name="my_priority" select="$my_priority_before"/> |
---|
331 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
332 | <xsl:with-param name="notations" select="$new_notations"/> |
---|
333 | <xsl:with-param name="ignore-cv" select="$ignore-cv"/> |
---|
334 | <xsl:with-param name="self" select="$self"/> |
---|
335 | <xsl:with-param name="use-code-block" select="$use-code-block"/> |
---|
336 | <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/> |
---|
337 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
338 | </xsl:call-template> |
---|
339 | </xsl:when> |
---|
340 | |
---|
341 | <xsl:when test="name($op_current)='arg-list'"> |
---|
342 | <xsl:variable name="start" select="$op_current/@start"/> |
---|
343 | <xsl:variable name="typeref-result"> |
---|
344 | <xsl:choose> |
---|
345 | <xsl:when test="$current_start >= $start"> |
---|
346 | <xsl:call-template name="unparse-cpp"> |
---|
347 | <xsl:with-param name="typeref" select="$typeref/*[$current_start]"/> |
---|
348 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
349 | <xsl:with-param name="priority" select="$my_priority"/> |
---|
350 | <xsl:with-param name="ignore-cv" select="$ignore-cv"/> |
---|
351 | <xsl:with-param name="notations" select="$notations"/> |
---|
352 | <xsl:with-param name="print-updated-notation" select="true()"/> |
---|
353 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
354 | </xsl:call-template> |
---|
355 | </xsl:when> |
---|
356 | |
---|
357 | <xsl:otherwise> |
---|
358 | *@@@* <xsl:value-of select="$notations"/> |
---|
359 | </xsl:otherwise> |
---|
360 | </xsl:choose> |
---|
361 | </xsl:variable> |
---|
362 | |
---|
363 | <xsl:variable name="typeref-print" select="normalize-space(substring-before($typeref-result, ' *@@@* '))"/> |
---|
364 | <xsl:variable name="new_notations" select="normalize-space(substring-after($typeref-result, ' *@@@* '))"/> |
---|
365 | |
---|
366 | <xsl:choose> |
---|
367 | <xsl:when test="$use-code-block"> |
---|
368 | <type><xsl:value-of select="$typeref-print"/></type> |
---|
369 | </xsl:when> |
---|
370 | <xsl:otherwise> |
---|
371 | <xsl:value-of select="$typeref-print"/> |
---|
372 | </xsl:otherwise> |
---|
373 | </xsl:choose> |
---|
374 | |
---|
375 | <xsl:if test="$current_start >= $start"> |
---|
376 | <xsl:if test="$current_start!=count($typeref/*)">, </xsl:if> |
---|
377 | </xsl:if> |
---|
378 | |
---|
379 | <xsl:choose> |
---|
380 | <xsl:when test="$current_start != count($typeref/*)"> |
---|
381 | <xsl:call-template name="unparse-operator-definition"> |
---|
382 | <xsl:with-param name="typeref" select="$typeref"/> |
---|
383 | <xsl:with-param name="operator_nodeset" select="$operator_nodeset"/> |
---|
384 | <xsl:with-param name="current_start" select="$current_start + 1"/> |
---|
385 | <xsl:with-param name="my_priority" select="$my_priority"/> |
---|
386 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
387 | <xsl:with-param name="notations" select="$new_notations"/> |
---|
388 | <xsl:with-param name="ignore-cv" select="$ignore-cv"/> |
---|
389 | <xsl:with-param name="self" select="$self"/> |
---|
390 | <xsl:with-param name="use-code-block" select="$use-code-block"/> |
---|
391 | <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/> |
---|
392 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
393 | </xsl:call-template> |
---|
394 | </xsl:when> |
---|
395 | <xsl:otherwise> |
---|
396 | <xsl:call-template name="unparse-operator-definition"> |
---|
397 | <xsl:with-param name="typeref" select="$typeref"/> |
---|
398 | <xsl:with-param name="operator_nodeset" select="$op_rest"/> |
---|
399 | <xsl:with-param name="my_priority" select="$my_priority"/> |
---|
400 | <xsl:with-param name="definition_list" select="$definition_list"/> |
---|
401 | <xsl:with-param name="notations" select="$new_notations"/> |
---|
402 | <xsl:with-param name="ignore-cv" select="$ignore-cv"/> |
---|
403 | <xsl:with-param name="self" select="$self"/> |
---|
404 | <xsl:with-param name="use-code-block" select="$use-code-block"/> |
---|
405 | <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/> |
---|
406 | </xsl:call-template> |
---|
407 | </xsl:otherwise> |
---|
408 | </xsl:choose> |
---|
409 | </xsl:when> |
---|
410 | |
---|
411 | <xsl:otherwise>Invalid tag in operator definition: <xsl:value-of select="name($op_current)"/></xsl:otherwise> |
---|
412 | |
---|
413 | </xsl:choose> |
---|
414 | </xsl:template> |
---|
415 | |
---|
416 | <xsl:template name="add-typename"> |
---|
417 | <!-- Adds typename to the front of a string if it is necessary. --> |
---|
418 | <xsl:param name="type"/> <!-- string to prepend to --> |
---|
419 | <xsl:param name="params" select="/concept/param | /concept/define-type | /concept/associated-type"/> |
---|
420 | <!-- nodeset of param tags for concept --> |
---|
421 | <!-- associated types are assumed to be dependent --> |
---|
422 | <xsl:param name="really-do-it"/> <!-- really change anything? --> |
---|
423 | |
---|
424 | <xsl:variable name="type-after-last-scope"> |
---|
425 | <xsl:call-template name="substring-before-last"> |
---|
426 | <xsl:with-param name="string" select="$type"/> |
---|
427 | <xsl:with-param name="to-find" select="'::'"/> |
---|
428 | </xsl:call-template> |
---|
429 | </xsl:variable> |
---|
430 | |
---|
431 | <xsl:variable name="tokenized-type-after-last-scope"> |
---|
432 | <xsl:call-template name="rough-tokenize"> |
---|
433 | <xsl:with-param name="string" select="$type-after-last-scope"/> |
---|
434 | </xsl:call-template> |
---|
435 | </xsl:variable> |
---|
436 | |
---|
437 | <xsl:choose> |
---|
438 | <xsl:when test="$really-do-it and boolean($params[contains($tokenized-type-after-last-scope, concat(' ', @name, ' '))])"> |
---|
439 | <!-- If the tokenized string contains any of the param names in a |
---|
440 | token by itself, return true. Return false otherwise --> |
---|
441 | <xsl:comment/>typename <xsl:value-of select="$type"/><xsl:comment/> |
---|
442 | </xsl:when> |
---|
443 | <xsl:otherwise><xsl:value-of select="$type"/></xsl:otherwise> |
---|
444 | </xsl:choose> |
---|
445 | </xsl:template> |
---|
446 | |
---|
447 | <xsl:template name="substring-before-last"> |
---|
448 | <xsl:param name="string"/> |
---|
449 | <xsl:param name="to-find"/> |
---|
450 | <xsl:param name="string-processed-so-far"/> <!-- internal --> |
---|
451 | <!-- Find the substring of $string before the last occurrance of |
---|
452 | $to-find, returning '' if it was not found. --> |
---|
453 | |
---|
454 | <xsl:choose> |
---|
455 | <xsl:when test="contains($string, $to-find)"> |
---|
456 | <xsl:call-template name="substring-before-last"> |
---|
457 | <xsl:with-param name="string" select="substring-after($string, $to-find)"/> |
---|
458 | <xsl:with-param name="to-find" select="$to-find"/> |
---|
459 | <xsl:with-param name="string-processed-so-far" select="concat($string-processed-so-far, substring-before($string, $to-find), $to-find)"/> |
---|
460 | </xsl:call-template> |
---|
461 | </xsl:when> |
---|
462 | |
---|
463 | <xsl:otherwise> |
---|
464 | <xsl:value-of select="substring($string-processed-so-far, 1, string-length($string-processed-so-far)-(string-length($to-find)))"/> |
---|
465 | </xsl:otherwise> |
---|
466 | </xsl:choose> |
---|
467 | </xsl:template> |
---|
468 | |
---|
469 | <xsl:template name="substring-after-last"> |
---|
470 | <xsl:param name="string"/> |
---|
471 | <xsl:param name="to-find"/> |
---|
472 | <!-- Find the substring of $string after the last occurrance of |
---|
473 | $to-find, returning the original string if it was not found. --> |
---|
474 | |
---|
475 | <xsl:choose> |
---|
476 | <xsl:when test="contains($string, $to-find)"> |
---|
477 | <xsl:call-template name="substring-after-last"> |
---|
478 | <xsl:with-param name="string" select="substring-after($string, $to-find)"/> |
---|
479 | <xsl:with-param name="to-find" select="$to-find"/> |
---|
480 | </xsl:call-template> |
---|
481 | </xsl:when> |
---|
482 | |
---|
483 | <xsl:otherwise> |
---|
484 | <xsl:value-of select="$string"/> |
---|
485 | </xsl:otherwise> |
---|
486 | </xsl:choose> |
---|
487 | </xsl:template> |
---|
488 | |
---|
489 | <xsl:template name="rough-tokenize"> |
---|
490 | <xsl:param name="string"/> |
---|
491 | <!-- Do a rough tokenization of the string. Right now, just translate |
---|
492 | all non-token-chars to spaces, normalize-space the result, and prepend |
---|
493 | and append spaces. --> |
---|
494 | |
---|
495 | <xsl:value-of select="concat(' ', normalize-space(translate($string, '<>,./?;:[]{}-=\\_+|!@#$%^&*()', ' ')), ' ')"/> |
---|
496 | </xsl:template> |
---|
497 | </xsl:stylesheet> |
---|