VirtualBox

source: vbox/trunk/src/VBox/Main/idl/apiwrap-server.xsl@ 53915

Last change on this file since 53915 was 53915, checked in by vboxsync, 10 years ago

apiwrap-server.xsl: Work around stupid xsltproc performance issue when outputting large 'text' format documents. Force it to split up the output buffer every so often.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 94.5 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 apiwrap-server.xsl:
5 XSLT stylesheet that generates C++ API wrappers (server side) from
6 VirtualBox.xidl.
7
8 Copyright (C) 2010-2015 Oracle Corporation
9
10 This file is part of VirtualBox Open Source Edition (OSE), as
11 available from http://www.virtualbox.org. This file is free software;
12 you can redistribute it and/or modify it under the terms of the GNU
13 General Public License (GPL) as published by the Free Software
14 Foundation, in version 2 as it comes in the "COPYING" file of the
15 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17-->
18
19<xsl:stylesheet
20 version="1.0"
21 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
22 xmlns:exsl="http://exslt.org/common"
23 extension-element-prefixes="exsl">
24
25<xsl:output method="text"/>
26
27<xsl:strip-space elements="*"/>
28
29<!-- - - - - - - - - - - - - - - - - - - - - - -
30 global XSLT variables
31 - - - - - - - - - - - - - - - - - - - - - - -->
32
33<xsl:variable name="G_xsltFilename" select="'apiwrap-server.xsl'"/>
34
35<xsl:variable name="G_root" select="/"/>
36
37<xsl:variable name="G_sNewLine">
38 <xsl:text>
39</xsl:text>
40</xsl:variable>
41
42<xsl:include href="typemap-shared.inc.xsl"/>
43
44<!-- - - - - - - - - - - - - - - - - - - - - - -
45 Keys for more efficiently looking up types.
46 - - - - - - - - - - - - - - - - - - - - - - -->
47
48<xsl:key name="G_keyEnumsByName" match="//enum[@name]" use="@name"/>
49<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
50
51
52<!-- - - - - - - - - - - - - - - - - - - - - - -
53 Utility templates.
54 - - - - - - - - - - - - - - - - - - - - - - -->
55
56<!-- Hack Alert! This template helps xsltproc split up the output text elements
57 and avoid reallocating them into the MB range. Calls to this
58 template is made occationally while generating larger output
59 file. It's not necessary for small stuff like header.
60
61 The trick we're playing on xsltproc has to do with CDATA
62 and/or the escape setting of the xsl:text element. It forces
63 xsltproc to allocate a new output element, thus preventing
64 things from growing out of proportions and slowing us down.
65
66 This was successfully employed to reduce a 18+ seconds run to
67 around one second (possibly less due to kmk overhead).
68 -->
69<xsl:template name="xsltprocNewlineOutputHack">
70 <xsl:text disable-output-escaping="yes"><![CDATA[
71]]></xsl:text>
72</xsl:template>
73
74<!-- - - - - - - - - - - - - - - - - - - - - - -
75templates for file separation
76 - - - - - - - - - - - - - - - - - - - - - - -->
77
78<xsl:template match="interface" mode="startfile">
79 <xsl:param name="file"/>
80
81 <xsl:call-template name="xsltprocNewlineOutputHack"/>
82 <xsl:value-of select="concat($G_sNewLine, '// ##### BEGINFILE &quot;', $file, '&quot;', $G_sNewLine)"/>
83</xsl:template>
84
85<xsl:template match="interface" mode="endfile">
86 <xsl:param name="file"/>
87
88 <xsl:value-of select="concat($G_sNewLine, '// ##### ENDFILE &quot;', $file, '&quot;', $G_sNewLine)"/>
89</xsl:template>
90
91<!-- - - - - - - - - - - - - - - - - - - - - - -
92templates for file headers/footers
93 - - - - - - - - - - - - - - - - - - - - - - -->
94
95<xsl:template name="fileheader">
96 <xsl:param name="class"/>
97 <xsl:param name="name"/>
98 <xsl:param name="type"/>
99
100 <xsl:text>/** @file
101</xsl:text>
102 <xsl:value-of select="concat(' * VirtualBox API class wrapper ', $type, ' for I', $class, '.')"/>
103 <xsl:text>
104 *
105 * DO NOT EDIT! This is a generated file.
106 * Generated from: src/VBox/Main/idl/VirtualBox.xidl
107 * Generator: src/VBox/Main/idl/apiwrap-server.xsl
108 */
109
110/**
111 * Copyright (C) 2010-2015 Oracle Corporation
112 *
113 * This file is part of VirtualBox Open Source Edition (OSE), as
114 * available from http://www.virtualbox.org. This file is free software;
115 * you can redistribute it and/or modify it under the terms of the GNU
116 * General Public License (GPL) as published by the Free Software
117 * Foundation, in version 2 as it comes in the "COPYING" file of the
118 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
119 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
120 */
121
122</xsl:text>
123</xsl:template>
124
125<!-- Emits COM_INTERFACE_ENTRY statements for the current interface node and whatever it inherits from. -->
126<xsl:template name="emitCOMInterfaces">
127 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY(', @name, ')' , $G_sNewLine)"/>
128 <!-- now recurse to emit all base interfaces -->
129 <xsl:variable name="extends" select="@extends"/>
130 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
131 <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
132 <xsl:call-template name="emitCOMInterfaces"/>
133 </xsl:for-each>
134 </xsl:if>
135</xsl:template>
136
137<xsl:template match="interface" mode="classheader">
138 <xsl:param name="addinterfaces"/>
139 <xsl:value-of select="concat('#ifndef ', substring(@name, 2), 'Wrap_H_', $G_sNewLine)"/>
140 <xsl:value-of select="concat('#define ', substring(@name, 2), 'Wrap_H_')"/>
141 <xsl:text>
142
143#include "VirtualBoxBase.h"
144#include "Wrapper.h"
145
146</xsl:text>
147 <xsl:value-of select="concat('class ATL_NO_VTABLE ', substring(@name, 2), 'Wrap:')"/>
148 <xsl:text>
149 public VirtualBoxBase,
150</xsl:text>
151 <xsl:value-of select="concat(' VBOX_SCRIPTABLE_IMPL(', @name, ')')"/>
152 <xsl:if test="count(exsl:node-set($addinterfaces)/token) > 0">
153 <xsl:text>,</xsl:text>
154 </xsl:if>
155 <xsl:value-of select="$G_sNewLine"/>
156 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
157 <xsl:value-of select="concat(' VBOX_SCRIPTABLE_IMPL(', text(), ')')"/>
158 <xsl:if test="not(position()=last())">
159 <xsl:text>,</xsl:text>
160 </xsl:if>
161 <xsl:value-of select="$G_sNewLine"/>
162 </xsl:for-each>
163 <xsl:text>{
164 Q_OBJECT
165
166public:
167</xsl:text>
168 <xsl:value-of select="concat(' VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(', substring(@name, 2), 'Wrap, ', @name, ')', $G_sNewLine)"/>
169 <xsl:value-of select="concat(' DECLARE_NOT_AGGREGATABLE(', substring(@name, 2), 'Wrap)', $G_sNewLine)"/>
170 <xsl:text> DECLARE_PROTECT_FINAL_CONSTRUCT()
171
172</xsl:text>
173 <xsl:value-of select="concat(' BEGIN_COM_MAP(', substring(@name, 2), 'Wrap)', $G_sNewLine)"/>
174 <xsl:text> COM_INTERFACE_ENTRY(ISupportErrorInfo)
175</xsl:text>
176 <xsl:call-template name="emitCOMInterfaces"/>
177 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY2(IDispatch, ', @name, ')', $G_sNewLine)"/>
178 <xsl:variable name="manualAddInterfaces">
179 <xsl:call-template name="checkoption">
180 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
181 <xsl:with-param name="option" select="'manualaddinterfaces'"/>
182 </xsl:call-template>
183 </xsl:variable>
184 <xsl:if test="not($manualAddInterfaces = 'true')">
185 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
186 <!-- This is super tricky, as the for-each switches to the node set,
187 which means the normal document isn't available any more. We get
188 the data we need, uses a for-each to switch document and then a
189 key() to look up the interface by name. -->
190 <xsl:variable name="addifname">
191 <xsl:value-of select="string(.)"/>
192 </xsl:variable>
193 <xsl:for-each select="$G_root">
194 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
195 <xsl:call-template name="emitCOMInterfaces"/>
196 </xsl:for-each>
197 </xsl:for-each>
198 </xsl:for-each>
199 </xsl:if>
200 <xsl:text> COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
201 END_COM_MAP()
202
203</xsl:text>
204 <xsl:value-of select="concat(' DECLARE_EMPTY_CTOR_DTOR(', substring(@name, 2), 'Wrap)', $G_sNewLine)"/>
205</xsl:template>
206
207<xsl:template match="interface" mode="classfooter">
208 <xsl:param name="addinterfaces"/>
209 <xsl:text>};
210
211</xsl:text>
212 <xsl:value-of select="concat('#endif // !', substring(@name, 2), 'Wrap_H_', $G_sNewLine)"/>
213</xsl:template>
214
215<xsl:template match="interface" mode="codeheader">
216 <xsl:param name="addinterfaces"/>
217 <xsl:value-of select="concat('#define LOG_GROUP_MAIN_OVERRIDE LOG_GROUP_MAIN_', translate(substring(@name, 2), $G_lowerCase, $G_upperCase), $G_sNewLine, $G_sNewLine)"/>
218 <xsl:value-of select="concat('#include &quot;', substring(@name, 2), 'Wrap.h&quot;', $G_sNewLine)"/>
219 <xsl:text>#include "Logging.h"
220#ifdef VBOX_WITH_DTRACE_R3_MAIN
221# include "dtrace/VBoxAPI.h"
222#endif
223
224</xsl:text>
225</xsl:template>
226
227<xsl:template name="emitISupports">
228 <xsl:param name="classname"/>
229 <xsl:param name="extends"/>
230 <xsl:param name="addinterfaces"/>
231 <xsl:param name="depth"/>
232 <xsl:param name="interfacelist"/>
233
234 <xsl:choose>
235 <xsl:when test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
236 <xsl:variable name="newextends" select="key('G_keyInterfacesByName', $extends)/@extends"/>
237 <xsl:variable name="newiflist" select="concat($interfacelist, ', ', $extends)"/>
238 <xsl:call-template name="emitISupports">
239 <xsl:with-param name="classname" select="$classname"/>
240 <xsl:with-param name="extends" select="$newextends"/>
241 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
242 <xsl:with-param name="depth" select="$depth + 1"/>
243 <xsl:with-param name="interfacelist" select="$newiflist"/>
244 </xsl:call-template>
245 </xsl:when>
246 <xsl:otherwise>
247 <xsl:variable name="addinterfaces_ns" select="exsl:node-set($addinterfaces)"/>
248 <xsl:choose>
249 <xsl:when test="count($addinterfaces_ns/token) > 0">
250 <xsl:variable name="addifname" select="$addinterfaces_ns/token[1]"/>
251 <xsl:variable name="addif" select="key('G_keyInterfacesByName', $addifname)/@extends"/>
252 <xsl:variable name="newextends" select="$addif/@extends"/>
253 <xsl:variable name="newaddinterfaces" select="$addinterfaces_ns/token[position() > 1]"/>
254 <xsl:variable name="newiflist" select="concat($interfacelist, ', ', $addifname)"/>
255 <xsl:call-template name="emitISupports">
256 <xsl:with-param name="classname" select="$classname"/>
257 <xsl:with-param name="extends" select="$newextends"/>
258 <xsl:with-param name="addinterfaces" select="$newaddinterfaces"/>
259 <xsl:with-param name="depth" select="$depth + 1"/>
260 <xsl:with-param name="interfacelist" select="$newiflist"/>
261 </xsl:call-template>
262 </xsl:when>
263 <xsl:otherwise>
264 <xsl:value-of select="concat('NS_IMPL_THREADSAFE_ISUPPORTS', $depth, '_CI(', $classname, ', ', $interfacelist, ')', $G_sNewLine)"/>
265 </xsl:otherwise>
266 </xsl:choose>
267 </xsl:otherwise>
268 </xsl:choose>
269</xsl:template>
270
271<xsl:template match="interface" mode="codefooter">
272 <xsl:param name="addinterfaces"/>
273 <xsl:text>#ifdef VBOX_WITH_XPCOM
274</xsl:text>
275 <xsl:value-of select="concat('NS_DECL_CLASSINFO(', substring(@name, 2), 'Wrap)', $G_sNewLine)"/>
276
277 <xsl:variable name="manualAddInterfaces">
278 <xsl:call-template name="checkoption">
279 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
280 <xsl:with-param name="option" select="'manualaddinterfaces'"/>
281 </xsl:call-template>
282 </xsl:variable>
283 <xsl:choose>
284 <xsl:when test="$manualAddInterfaces = 'true'">
285 <xsl:variable name="nulladdinterfaces"></xsl:variable>
286 <xsl:call-template name="emitISupports">
287 <xsl:with-param name="classname" select="concat(substring(@name, 2), 'Wrap')"/>
288 <xsl:with-param name="extends" select="@extends"/>
289 <xsl:with-param name="addinterfaces" select="$nulladdinterfaces"/>
290 <xsl:with-param name="depth" select="1"/>
291 <xsl:with-param name="interfacelist" select="@name"/>
292 </xsl:call-template>
293 </xsl:when>
294 <xsl:otherwise>
295 <xsl:call-template name="emitISupports">
296 <xsl:with-param name="classname" select="concat(substring(@name, 2), 'Wrap')"/>
297 <xsl:with-param name="extends" select="@extends"/>
298 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
299 <xsl:with-param name="depth" select="1"/>
300 <xsl:with-param name="interfacelist" select="@name"/>
301 </xsl:call-template>
302 </xsl:otherwise>
303 </xsl:choose>
304 <xsl:text>#endif // VBOX_WITH_XPCOM
305</xsl:text>
306</xsl:template>
307
308
309<!-- - - - - - - - - - - - - - - - - - - - - - -
310 templates for dealing with names and parameters
311 - - - - - - - - - - - - - - - - - - - - - - -->
312
313<xsl:template name="tospace">
314 <xsl:param name="str"/>
315 <xsl:value-of select="translate($str, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_', ' ')"/>
316</xsl:template>
317
318<xsl:template name="checkoption">
319 <xsl:param name="optionlist"/>
320 <xsl:param name="option"/>
321 <xsl:value-of select="string-length($option) > 0 and contains(concat(',', translate($optionlist, ' ', ''), ','), concat(',', $option, ','))"/>
322</xsl:template>
323
324<xsl:template name="getattrlist">
325 <xsl:param name="val"/>
326 <xsl:param name="separator" select="','"/>
327
328 <xsl:if test="$val and $val != ''">
329 <xsl:choose>
330 <xsl:when test="contains($val,$separator)">
331 <token>
332 <xsl:value-of select="substring-before($val,$separator)"/>
333 </token>
334 <xsl:call-template name="getattrlist">
335 <xsl:with-param name="val" select="substring-after($val,$separator)"/>
336 <xsl:with-param name="separator" select="$separator"/>
337 </xsl:call-template>
338 </xsl:when>
339 <xsl:otherwise>
340 <token><xsl:value-of select="$val"/></token>
341 </xsl:otherwise>
342 </xsl:choose>
343 </xsl:if>
344</xsl:template>
345
346<xsl:template name="translatepublictype">
347 <xsl:param name="type"/>
348 <xsl:param name="dir"/>
349 <xsl:param name="mod"/>
350
351 <xsl:choose>
352 <xsl:when test="$type='wstring' or $type='uuid'">
353 <xsl:if test="$dir='in'">
354 <xsl:text>IN_</xsl:text>
355 </xsl:if>
356 <xsl:text>BSTR</xsl:text>
357 </xsl:when>
358
359 <xsl:when test="$type='$unknown'">
360 <xsl:text>IUnknown *</xsl:text>
361 </xsl:when>
362
363 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
364 <xsl:value-of select="concat($type, ' *')"/>
365 </xsl:when>
366
367 <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
368 <xsl:value-of select="concat($type, '_T')"/>
369 </xsl:when>
370
371 <!-- Micro optimizations: Put off wraptypefield calculation as long as possible; Check interfaces before enums. -->
372 <xsl:otherwise>
373 <!-- get C++ glue type from IDL type from table in typemap-shared.inc.xsl -->
374 <xsl:variable name="gluetypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename"/>
375 <xsl:choose>
376 <xsl:when test="string-length($gluetypefield)">
377 <xsl:value-of select="$gluetypefield"/>
378 </xsl:when>
379
380 <xsl:otherwise>
381 <xsl:call-template name="fatalError">
382 <xsl:with-param name="msg" select="concat('translatepublictype: Type &quot;', $type, '&quot; is not supported.')"/>
383 </xsl:call-template>
384 </xsl:otherwise>
385 </xsl:choose>
386 </xsl:otherwise>
387 </xsl:choose>
388 <xsl:if test="$mod='ptr'">
389 <xsl:text> *</xsl:text>
390 </xsl:if>
391</xsl:template>
392
393<xsl:template name="translatewrappedtype">
394 <xsl:param name="type"/>
395 <xsl:param name="dir"/>
396 <xsl:param name="mod"/>
397 <xsl:param name="safearray"/>
398
399 <xsl:choose>
400 <xsl:when test="$type='wstring'">
401 <xsl:if test="$dir='in' and not($safearray='yes')">
402 <xsl:text>const </xsl:text>
403 </xsl:if>
404 <xsl:text>com::Utf8Str &amp;</xsl:text>
405 </xsl:when>
406
407 <xsl:when test="$type='uuid'">
408 <xsl:if test="$dir='in'">
409 <xsl:text>const </xsl:text>
410 </xsl:if>
411 <xsl:text>com::Guid &amp;</xsl:text>
412 </xsl:when>
413
414 <xsl:when test="$type='$unknown'">
415 <xsl:if test="$dir='in' and not($safearray='yes')">
416 <xsl:text>const </xsl:text>
417 </xsl:if>
418 <xsl:text>ComPtr&lt;IUnknown&gt; &amp;</xsl:text>
419 </xsl:when>
420
421 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
422 <xsl:if test="$dir='in' and not($safearray='yes')">
423 <xsl:text>const </xsl:text>
424 </xsl:if>
425 <xsl:value-of select="concat('ComPtr&lt;', $type, '&gt; &amp;')"/>
426 </xsl:when>
427
428 <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
429 <xsl:value-of select="concat($type, '_T')"/>
430 </xsl:when>
431
432 <!-- Micro optimizations: Put off wraptypefield calculation as long as possible; Check interfaces before enums. -->
433 <xsl:otherwise>
434 <!-- get C++ wrap type from IDL type from table in typemap-shared.inc.xsl -->
435 <xsl:variable name="wraptypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename"/>
436 <xsl:choose>
437 <xsl:when test="string-length($wraptypefield)">
438 <xsl:value-of select="$wraptypefield"/>
439 </xsl:when>
440
441 <xsl:otherwise>
442 <xsl:call-template name="fatalError">
443 <xsl:with-param name="msg" select="concat('translatewrappedtype: Type &quot;', $type, '&quot; is not supported.')"/>
444 </xsl:call-template>
445 </xsl:otherwise>
446 </xsl:choose>
447 </xsl:otherwise>
448 </xsl:choose>
449 <xsl:if test="$mod='ptr'">
450 <xsl:text> *</xsl:text>
451 </xsl:if>
452</xsl:template>
453
454<xsl:template name="translatefmtspectype">
455 <xsl:param name="type"/>
456 <xsl:param name="dir"/>
457 <xsl:param name="mod"/>
458 <xsl:param name="safearray"/>
459 <xsl:param name="isref"/>
460
461 <!-- get C format string for IDL type from table in typemap-shared.inc.xsl -->
462 <xsl:variable name="wrapfmt" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluefmt"/>
463 <xsl:choose>
464 <xsl:when test="$mod='ptr' or ($isref='yes' and $dir!='in')">
465 <xsl:text>%p</xsl:text>
466 </xsl:when>
467 <xsl:when test="$safearray='yes'">
468 <xsl:text>%zu</xsl:text>
469 </xsl:when>
470 <xsl:when test="string-length($wrapfmt)">
471 <xsl:value-of select="$wrapfmt"/>
472 </xsl:when>
473 <xsl:when test="$type='$unknown'">
474 <xsl:text>%p</xsl:text>
475 </xsl:when>
476 <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
477 <xsl:text>%RU32</xsl:text>
478 </xsl:when>
479 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
480 <xsl:text>%p</xsl:text>
481 </xsl:when>
482 <xsl:otherwise>
483 <xsl:call-template name="fatalError">
484 <xsl:with-param name="msg" select="concat('translatefmtcpectype: Type &quot;', $type, '&quot; is not supported.')"/>
485 </xsl:call-template>
486 </xsl:otherwise>
487 </xsl:choose>
488</xsl:template>
489
490<xsl:template name="translatedtracetype">
491 <xsl:param name="type"/>
492 <xsl:param name="dir"/>
493 <xsl:param name="mod"/>
494
495 <!-- get dtrace probe type from IDL type from table in typemap-shared.inc.xsl -->
496 <xsl:variable name="dtracetypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@dtracename"/>
497 <xsl:choose>
498 <xsl:when test="string-length($dtracetypefield)">
499 <xsl:value-of select="$dtracetypefield"/>
500 </xsl:when>
501 <xsl:when test="$type='$unknown'">
502 <!-- <xsl:text>struct IUnknown *</xsl:text> -->
503 <xsl:text>void *</xsl:text>
504 </xsl:when>
505 <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
506 <!-- <xsl:value-of select="concat($type, '_T')"/> - later we can emit enums into dtrace the library -->
507 <xsl:text>int</xsl:text>
508 </xsl:when>
509 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
510 <!--
511 <xsl:value-of select="concat('struct ', $type, ' *')"/>
512 -->
513 <xsl:text>void *</xsl:text>
514 </xsl:when>
515 <xsl:otherwise>
516 <xsl:call-template name="fatalError">
517 <xsl:with-param name="msg" select="concat('translatedtracetype Type &quot;', $type, '&quot; is not supported.')"/>
518 </xsl:call-template>
519 </xsl:otherwise>
520 </xsl:choose>
521 <xsl:if test="$mod='ptr'">
522 <xsl:text> *</xsl:text>
523 </xsl:if>
524</xsl:template>
525
526
527<!-- - - - - - - - - - - - - - - - - - - - - - -
528 templates for handling entire interfaces and their contents
529 - - - - - - - - - - - - - - - - - - - - - - -->
530
531<!-- Called on interface node. -->
532<xsl:template name="emitInterface">
533 <!-- sources, headers and dtrace-probes all needs attribute lists -->
534 <xsl:variable name="addinterfaces">
535 <xsl:call-template name="getattrlist">
536 <xsl:with-param name="val" select="@wrap-hint-server-addinterfaces"/>
537 </xsl:call-template>
538 </xsl:variable>
539
540 <xsl:choose>
541 <xsl:when test="$generating = 'sources'">
542 <xsl:if test="(position() mod 2) = $reminder">
543 <xsl:call-template name="emitCode">
544 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
545 </xsl:call-template>
546 </xsl:if>
547 </xsl:when>
548 <xsl:when test="$generating = 'headers'">
549 <xsl:call-template name="emitHeader">
550 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
551 </xsl:call-template>
552 </xsl:when>
553 <xsl:when test="$generating = 'dtrace-probes'">
554 <xsl:call-template name="emitDTraceProbes">
555 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
556 </xsl:call-template>
557 </xsl:when>
558 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitInterface</xsl:message></xsl:otherwise>
559 </xsl:choose>
560</xsl:template>
561
562<!-- Called on a method param or attribute node. -->
563<xsl:template name="emitPublicParameter">
564 <xsl:param name="dir"/>
565
566 <xsl:variable name="gluetype">
567 <xsl:call-template name="translatepublictype">
568 <xsl:with-param name="type" select="@type"/>
569 <xsl:with-param name="dir" select="$dir"/>
570 <xsl:with-param name="mod" select="@mod"/>
571 </xsl:call-template>
572 </xsl:variable>
573
574 <xsl:choose>
575 <xsl:when test="@safearray='yes'">
576 <xsl:choose>
577 <xsl:when test="$dir='in'">
578 <xsl:text>ComSafeArrayIn(</xsl:text>
579 </xsl:when>
580 <xsl:otherwise>
581 <xsl:text>ComSafeArrayOut(</xsl:text>
582 </xsl:otherwise>
583 </xsl:choose>
584 <xsl:value-of select="$gluetype"/>
585 <xsl:text>, a</xsl:text>
586 <xsl:call-template name="capitalize">
587 <xsl:with-param name="str" select="@name"/>
588 </xsl:call-template>
589 <xsl:text>)</xsl:text>
590 </xsl:when>
591 <xsl:otherwise>
592 <xsl:value-of select="$gluetype"/>
593 <xsl:if test="substring($gluetype,string-length($gluetype))!='*'">
594 <xsl:text> </xsl:text>
595 </xsl:if>
596 <xsl:if test="$dir != 'in'">
597 <xsl:text>*</xsl:text>
598 </xsl:if>
599 <xsl:text>a</xsl:text>
600 <xsl:call-template name="capitalize">
601 <xsl:with-param name="str" select="@name"/>
602 </xsl:call-template>
603 </xsl:otherwise>
604 </xsl:choose>
605</xsl:template>
606
607<xsl:template match="attribute/@type | param/@type" mode="wrapped">
608 <xsl:param name="dir"/>
609
610 <xsl:variable name="wraptype">
611 <xsl:call-template name="translatewrappedtype">
612 <xsl:with-param name="type" select="."/>
613 <xsl:with-param name="dir" select="$dir"/>
614 <xsl:with-param name="mod" select="../@mod"/>
615 <xsl:with-param name="safearray" select="../@safearray"/>
616 </xsl:call-template>
617 </xsl:variable>
618 <xsl:variable name="lastchar">
619 <xsl:value-of select="substring($wraptype, string-length($wraptype))"/>
620 </xsl:variable>
621
622 <xsl:choose>
623 <xsl:when test="../@safearray='yes'">
624 <xsl:if test="$dir='in'">
625 <xsl:text>const </xsl:text>
626 </xsl:if>
627 <xsl:text>std::vector&lt;</xsl:text>
628 <xsl:choose>
629 <xsl:when test="$lastchar = '&amp;'">
630 <xsl:variable name="wraptype2">
631 <xsl:value-of select="substring($wraptype, 1, string-length($wraptype)-2)"/>
632 </xsl:variable>
633 <xsl:value-of select="$wraptype2"/>
634 <xsl:if test="substring($wraptype2,string-length($wraptype2)) = '&gt;'">
635 <xsl:text> </xsl:text>
636 </xsl:if>
637 </xsl:when>
638 <xsl:when test="lastchar = '&gt;'">
639 <xsl:value-of select="concat($wraptype, ' ')"/>
640 </xsl:when>
641 <xsl:otherwise>
642 <xsl:value-of select="$wraptype"/>
643 </xsl:otherwise>
644 </xsl:choose>
645 <xsl:text>&gt; &amp;</xsl:text>
646 </xsl:when>
647 <xsl:otherwise>
648 <xsl:value-of select="$wraptype"/>
649 <xsl:if test="$lastchar != '&amp;'">
650 <xsl:if test="$lastchar != '*'">
651 <xsl:text> </xsl:text>
652 </xsl:if>
653 <xsl:if test="$dir != 'in'">
654 <xsl:text>*</xsl:text>
655 </xsl:if>
656 </xsl:if>
657 </xsl:otherwise>
658 </xsl:choose>
659 <xsl:text>a</xsl:text>
660 <xsl:call-template name="capitalize">
661 <xsl:with-param name="str" select="../@name"/>
662 </xsl:call-template>
663</xsl:template>
664
665<xsl:template match="attribute/@type | param/@type" mode="logparamtext">
666 <xsl:param name="dir"/>
667 <xsl:param name="isref"/>
668
669 <xsl:if test="$isref!='yes' and ($dir='out' or $dir='ret')">
670 <xsl:text>*</xsl:text>
671 </xsl:if>
672 <xsl:text>a</xsl:text>
673 <xsl:call-template name="capitalize">
674 <xsl:with-param name="str" select="../@name"/>
675 </xsl:call-template>
676 <xsl:text>=</xsl:text>
677 <xsl:call-template name="translatefmtspectype">
678 <xsl:with-param name="type" select="."/>
679 <xsl:with-param name="dir" select="$dir"/>
680 <xsl:with-param name="mod" select="../@mod"/>
681 <xsl:with-param name="safearray" select="../@safearray"/>
682 <xsl:with-param name="isref" select="$isref"/>
683 </xsl:call-template>
684</xsl:template>
685
686<xsl:template match="attribute/@type | param/@type" mode="logparamval">
687 <xsl:param name="dir"/>
688 <xsl:param name="isref"/>
689
690 <xsl:choose>
691 <xsl:when test="../@safearray='yes' and $isref!='yes'">
692 <xsl:text>ComSafeArraySize(</xsl:text>
693 <xsl:if test="$isref!='yes' and $dir!='in'">
694 <xsl:text>*</xsl:text>
695 </xsl:if>
696 </xsl:when>
697 <xsl:when test="$isref!='yes' and $dir!='in'">
698 <xsl:text>*</xsl:text>
699 </xsl:when>
700 </xsl:choose>
701 <xsl:text>a</xsl:text>
702 <xsl:call-template name="capitalize">
703 <xsl:with-param name="str" select="../@name"/>
704 </xsl:call-template>
705 <xsl:choose>
706 <xsl:when test="../@safearray='yes' and $isref!='yes'">
707 <xsl:text>)</xsl:text>
708 </xsl:when>
709 </xsl:choose>
710</xsl:template>
711
712<!-- Emits the DTrace probe parameter value (using tmps), invoked on param or attribute node. -->
713<xsl:template name="emitDTraceParamValue">
714 <xsl:param name="dir"/>
715
716 <xsl:variable name="viatmpvar">
717 <xsl:for-each select="@type">
718 <xsl:call-template name="paramconversionviatmp">
719 <xsl:with-param name="dir" select="$dir"/>
720 </xsl:call-template>
721 </xsl:for-each>
722 </xsl:variable>
723
724 <xsl:variable name="type" select="@type"/>
725 <xsl:choose>
726 <!-- Doesn't help to inline paramconversionviatmp: <xsl:when test="$type = 'wstring' or $type = '$unknown' or $type = 'uuid' or @safearray = 'yes' or count(key('G_keyInterfacesByName', $type)) > 0"> -->
727 <xsl:when test="$viatmpvar = 'yes'">
728 <xsl:variable name="tmpname">
729 <xsl:text>Tmp</xsl:text>
730 <xsl:call-template name="capitalize">
731 <xsl:with-param name="str" select="@name"/>
732 </xsl:call-template>
733 </xsl:variable>
734
735 <xsl:choose>
736 <xsl:when test="@safearray = 'yes'">
737 <xsl:text>(uint32_t)</xsl:text>
738 <xsl:value-of select="$tmpname"/>
739 <xsl:text>.array().size(), </xsl:text>
740 <!-- Later:
741 <xsl:value-of select="concat($tmpname, '.array().data(), ')"/>
742 -->
743 <xsl:text>NULL /*for now*/</xsl:text>
744 </xsl:when>
745 <xsl:when test="$type = 'wstring'">
746 <xsl:value-of select="$tmpname"/>
747 <xsl:text>.str().c_str()</xsl:text>
748 </xsl:when>
749 <xsl:when test="$type = 'uuid'">
750 <xsl:value-of select="$tmpname"/>
751 <xsl:text>.uuid().toStringCurly().c_str()</xsl:text>
752 </xsl:when>
753 <xsl:when test="$type = '$unknown'">
754 <xsl:text>(void *)</xsl:text>
755 <xsl:value-of select="$tmpname"/>
756 <xsl:text>.ptr()</xsl:text>
757 </xsl:when>
758 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
759 <xsl:text>(void *)</xsl:text>
760 <xsl:value-of select="$tmpname"/>
761 <xsl:text>.ptr()</xsl:text>
762 </xsl:when>
763 <xsl:otherwise>
764 <xsl:value-of select="$tmpname"/>
765 </xsl:otherwise>
766 </xsl:choose>
767 </xsl:when>
768
769 <xsl:otherwise>
770 <xsl:if test="$dir != 'in'">
771 <xsl:text>*</xsl:text>
772 </xsl:if>
773 <xsl:text>a</xsl:text>
774 <xsl:call-template name="capitalize">
775 <xsl:with-param name="str" select="@name"/>
776 </xsl:call-template>
777
778 <xsl:if test="$type = 'boolean'">
779 <xsl:text> != FALSE</xsl:text>
780 </xsl:if>
781 </xsl:otherwise>
782 </xsl:choose>
783</xsl:template>
784
785<!--
786Same as emitDTraceParamValue except no temporary variables are used (they are out of scope).
787Note! There are two other instances of this code with different @dir values, see below.
788-->
789<xsl:template name="emitDTraceParamValNoTmp">
790 <!-- To speed this up, the logic of paramconversionviatmp has been duplicated/inlined here. -->
791 <xsl:variable name="type" select="@type"/>
792 <xsl:choose>
793 <xsl:when test="@safearray = 'yes'">
794 <xsl:text>0, 0</xsl:text>
795 </xsl:when>
796 <xsl:when test="$type = 'wstring' or $type = '$unknown' or $type = 'uuid' or count(key('G_keyInterfacesByName', $type)) > 0">
797 <xsl:text>0</xsl:text>
798 </xsl:when>
799 <xsl:otherwise>
800 <xsl:if test="@dir != 'in'">
801 <xsl:text>*</xsl:text>
802 </xsl:if>
803 <xsl:text>a</xsl:text>
804 <xsl:call-template name="capitalize">
805 <xsl:with-param name="str" select="@name"/>
806 </xsl:call-template>
807 <xsl:if test="$type = 'boolean'">
808 <xsl:text> != FALSE</xsl:text>
809 </xsl:if>
810 </xsl:otherwise>
811 </xsl:choose>
812</xsl:template>
813
814<!-- Copy of emitDTraceParamValNoTmp with @dir = 'in' for speeding up the code (noticable difference). -->
815<xsl:template name="emitDTraceParamValNoTmp-DirIn">
816 <xsl:variable name="type" select="@type"/>
817 <xsl:choose>
818 <xsl:when test="@safearray = 'yes'">
819 <xsl:text>0, 0</xsl:text>
820 </xsl:when>
821 <xsl:when test="$type = 'wstring' or $type = '$unknown' or $type = 'uuid' or count(key('G_keyInterfacesByName', $type)) > 0">
822 <xsl:text>0</xsl:text>
823 </xsl:when>
824 <xsl:otherwise>
825 <xsl:text>a</xsl:text>
826 <xsl:call-template name="capitalize">
827 <xsl:with-param name="str" select="@name"/>
828 </xsl:call-template>
829 <xsl:if test="$type = 'boolean'">
830 <xsl:text> != FALSE</xsl:text>
831 </xsl:if>
832 </xsl:otherwise>
833 </xsl:choose>
834</xsl:template>
835
836<!-- Copy of emitDTraceParamValNoTmp with @dir != 'in' for speeding up attributes (noticable difference). -->
837<xsl:template name="emitDTraceParamValNoTmp-DirNotIn">
838 <xsl:variable name="type" select="@type"/>
839 <xsl:choose>
840 <xsl:when test="@safearray = 'yes'">
841 <xsl:text>0, 0</xsl:text>
842 </xsl:when>
843 <xsl:when test="$type = 'wstring' or $type = '$unknown' or $type = 'uuid' or count(key('G_keyInterfacesByName', $type)) > 0">
844 <xsl:text>0</xsl:text>
845 </xsl:when>
846 <xsl:otherwise>
847 <xsl:text>*a</xsl:text>
848 <xsl:call-template name="capitalize">
849 <xsl:with-param name="str" select="@name"/>
850 </xsl:call-template>
851 <xsl:if test="$type = 'boolean'">
852 <xsl:text> != FALSE</xsl:text>
853 </xsl:if>
854 </xsl:otherwise>
855 </xsl:choose>
856</xsl:template>
857
858<xsl:template match="attribute/@type | param/@type" mode="dtraceparamdecl">
859 <xsl:param name="dir"/>
860
861 <xsl:variable name="gluetype">
862 <xsl:call-template name="translatedtracetype">
863 <xsl:with-param name="type" select="."/>
864 <xsl:with-param name="dir" select="$dir"/>
865 <xsl:with-param name="mod" select="../@mod"/>
866 </xsl:call-template>
867 </xsl:variable>
868
869 <!-- Safe arrays get an extra size parameter. -->
870 <xsl:if test="../@safearray='yes'">
871 <xsl:text>uint32_t a_c</xsl:text>
872 <xsl:call-template name="capitalize">
873 <xsl:with-param name="str" select="../@name"/>
874 </xsl:call-template>
875 <xsl:text>, </xsl:text>
876 </xsl:if>
877
878 <xsl:value-of select="$gluetype"/>
879 <xsl:choose>
880 <xsl:when test="../@safearray='yes'">
881 <xsl:text> *a_pa</xsl:text>
882 </xsl:when>
883 <xsl:otherwise>
884 <xsl:if test="substring($gluetype,string-length($gluetype))!='*'">
885 <xsl:text> </xsl:text>
886 </xsl:if>
887 <xsl:text>a_</xsl:text>
888 </xsl:otherwise>
889 </xsl:choose>
890
891 <xsl:call-template name="capitalize">
892 <xsl:with-param name="str" select="../@name"/>
893 </xsl:call-template>
894</xsl:template>
895
896<!-- Call this to determine whether a temporary conversion variable is used for the current parameter.
897Returns empty if not needed, non-empty ('yes') if needed. -->
898<xsl:template name="paramconversionviatmp">
899 <xsl:param name="dir"/>
900 <xsl:variable name="type" select="."/>
901 <xsl:choose>
902 <xsl:when test="$type = 'wstring' or $type = '$unknown' or $type = 'uuid'">
903 <xsl:text>yes</xsl:text>
904 </xsl:when>
905 <xsl:when test="../@safearray = 'yes'">
906 <xsl:text>yes</xsl:text>
907 </xsl:when>
908 <xsl:when test="$type = 'boolean' or $type = 'long' or $type = 'long' or $type = 'long long'"/> <!-- XXX: drop this? -->
909 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
910 <xsl:text>yes</xsl:text>
911 </xsl:when>
912 </xsl:choose>
913</xsl:template>
914
915<!-- Call this to get the argument conversion class, if any is needed. -->
916<xsl:template name="paramconversionclass">
917 <xsl:param name="dir"/>
918
919 <xsl:variable name="type" select="."/>
920 <xsl:choose>
921 <xsl:when test="$type='$unknown'">
922 <xsl:if test="../@safearray='yes'">
923 <xsl:text>Array</xsl:text>
924 </xsl:if>
925 <xsl:choose>
926 <xsl:when test="$dir='in'">
927 <xsl:text>ComTypeInConverter&lt;IUnknown&gt;</xsl:text>
928 </xsl:when>
929 <xsl:otherwise>
930 <xsl:text>ComTypeOutConverter&lt;IUnknown&gt;</xsl:text>
931 </xsl:otherwise>
932 </xsl:choose>
933 </xsl:when>
934
935 <xsl:when test="$type='wstring'">
936 <xsl:if test="../@safearray='yes'">
937 <xsl:text>Array</xsl:text>
938 </xsl:if>
939 <xsl:choose>
940 <xsl:when test="$dir='in'">
941 <xsl:text>BSTRInConverter</xsl:text>
942 </xsl:when>
943 <xsl:otherwise>
944 <xsl:text>BSTROutConverter</xsl:text>
945 </xsl:otherwise>
946 </xsl:choose>
947 </xsl:when>
948
949 <xsl:when test="$type='uuid'">
950 <xsl:if test="../@safearray='yes'">
951 <xsl:text>Array</xsl:text>
952 </xsl:if>
953 <xsl:choose>
954 <xsl:when test="$dir='in'">
955 <xsl:text>UuidInConverter</xsl:text>
956 </xsl:when>
957 <xsl:otherwise>
958 <xsl:text>UuidOutConverter</xsl:text>
959 </xsl:otherwise>
960 </xsl:choose>
961 </xsl:when>
962
963 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
964 <xsl:if test="../@safearray='yes'">
965 <xsl:text>Array</xsl:text>
966 </xsl:if>
967 <xsl:choose>
968 <xsl:when test="$dir='in'">
969 <xsl:text>ComTypeInConverter</xsl:text>
970 </xsl:when>
971 <xsl:otherwise>
972 <xsl:text>ComTypeOutConverter</xsl:text>
973 </xsl:otherwise>
974 </xsl:choose>
975 <xsl:value-of select="concat('&lt;', $type, '&gt;')"/>
976 </xsl:when>
977
978 <xsl:when test="../@safearray='yes'">
979 <xsl:text>Array</xsl:text>
980 <xsl:choose>
981 <xsl:when test="$dir='in'">
982 <xsl:text>InConverter</xsl:text>
983 </xsl:when>
984 <xsl:otherwise>
985 <xsl:text>OutConverter</xsl:text>
986 </xsl:otherwise>
987 </xsl:choose>
988 <xsl:variable name="gluetype">
989 <xsl:call-template name="translatepublictype">
990 <xsl:with-param name="type" select="."/>
991 <xsl:with-param name="dir" select="$dir"/>
992 <xsl:with-param name="mod" select="../@mod"/>
993 </xsl:call-template>
994 </xsl:variable>
995 <xsl:value-of select="concat('&lt;', $gluetype, '&gt;')"/>
996 </xsl:when>
997 </xsl:choose>
998</xsl:template>
999
1000<!-- Emits code for converting the parameter to a temporary variable. -->
1001<xsl:template match="attribute/@type | param/@type" mode="paramvalconversion2tmpvar">
1002 <xsl:param name="dir"/>
1003
1004 <xsl:variable name="conversionclass">
1005 <xsl:call-template name="paramconversionclass">
1006 <xsl:with-param name="dir" select="$dir"/>
1007 </xsl:call-template>
1008 </xsl:variable>
1009
1010 <xsl:if test="$conversionclass != ''">
1011 <xsl:value-of select="$conversionclass"/>
1012 <xsl:text> Tmp</xsl:text>
1013 <xsl:call-template name="capitalize">
1014 <xsl:with-param name="str" select="../@name"/>
1015 </xsl:call-template>
1016 <xsl:text>(</xsl:text>
1017 <xsl:if test="../@safearray = 'yes'">
1018 <xsl:choose>
1019 <xsl:when test="$dir = 'in'">
1020 <xsl:text>ComSafeArrayInArg(</xsl:text>
1021 </xsl:when>
1022 <xsl:otherwise>
1023 <xsl:text>ComSafeArrayOutArg(</xsl:text>
1024 </xsl:otherwise>
1025 </xsl:choose>
1026 </xsl:if>
1027 <xsl:text>a</xsl:text>
1028 <xsl:call-template name="capitalize">
1029 <xsl:with-param name="str" select="../@name"/>
1030 </xsl:call-template>
1031 <xsl:if test="../@safearray = 'yes'">
1032 <xsl:text>)</xsl:text>
1033 </xsl:if>
1034 <xsl:text>);</xsl:text>
1035 </xsl:if>
1036
1037</xsl:template>
1038
1039<!-- Partner to paramvalconversion2tmpvar that emits the parameter when calling call the internal worker method. -->
1040<xsl:template match="attribute/@type | param/@type" mode="paramvalconversionusingtmp">
1041 <xsl:param name="dir"/>
1042
1043 <xsl:variable name="viatmpvar">
1044 <xsl:call-template name="paramconversionviatmp">
1045 <xsl:with-param name="dir" select="$dir"/>
1046 </xsl:call-template>
1047 </xsl:variable>
1048 <xsl:variable name="type" select="."/>
1049
1050 <xsl:choose>
1051 <xsl:when test="$viatmpvar = 'yes'">
1052 <xsl:text>Tmp</xsl:text>
1053 <xsl:call-template name="capitalize">
1054 <xsl:with-param name="str" select="../@name"/>
1055 </xsl:call-template>
1056
1057 <xsl:choose>
1058 <xsl:when test="../@safearray='yes'">
1059 <xsl:text>.array()</xsl:text>
1060 </xsl:when>
1061 <xsl:when test="$type = 'wstring'">
1062 <xsl:text>.str()</xsl:text>
1063 </xsl:when>
1064 <xsl:when test="$type = 'uuid'">
1065 <xsl:text>.uuid()</xsl:text>
1066 </xsl:when>
1067 <xsl:when test="$type = '$unknown'">
1068 <xsl:text>.ptr()</xsl:text>
1069 </xsl:when>
1070 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
1071 <xsl:text>.ptr()</xsl:text>
1072 </xsl:when>
1073 <xsl:otherwise><xsl:message terminate="yes">Oops #1</xsl:message></xsl:otherwise>
1074 </xsl:choose>
1075 </xsl:when>
1076
1077 <xsl:otherwise>
1078 <xsl:text>a</xsl:text>
1079 <xsl:call-template name="capitalize">
1080 <xsl:with-param name="str" select="../@name"/>
1081 </xsl:call-template>
1082
1083 <!-- Make sure BOOL values we pass down are either TRUE or FALSE. -->
1084 <xsl:if test="$type = 'boolean' and $dir = 'in'">
1085 <xsl:text> != FALSE</xsl:text>
1086 </xsl:if>
1087 </xsl:otherwise>
1088 </xsl:choose>
1089
1090</xsl:template>
1091
1092<!-- - - - - - - - - - - - - - - - - - - - - - -
1093 emit attribute
1094 - - - - - - - - - - - - - - - - - - - - - - -->
1095
1096<xsl:template match="attribute" mode="public">
1097 <xsl:param name="target"/>
1098
1099 <xsl:call-template name="emitTargetBegin">
1100 <xsl:with-param name="target" select="$target"/>
1101 </xsl:call-template>
1102
1103 <xsl:variable name="attrbasename">
1104 <xsl:call-template name="capitalize">
1105 <xsl:with-param name="str" select="@name"/>
1106 </xsl:call-template>
1107 </xsl:variable>
1108
1109 <xsl:value-of select="concat(' STDMETHOD(COMGETTER(', $attrbasename, '))(')"/>
1110 <xsl:call-template name="emitPublicParameter">
1111 <xsl:with-param name="dir">out</xsl:with-param>
1112 </xsl:call-template>
1113 <xsl:text>);
1114</xsl:text>
1115
1116 <xsl:if test="not(@readonly) or @readonly!='yes'">
1117 <xsl:value-of select="concat(' STDMETHOD(COMSETTER(', $attrbasename, '))(')"/>
1118 <xsl:call-template name="emitPublicParameter">
1119 <xsl:with-param name="dir">in</xsl:with-param>
1120 </xsl:call-template>
1121 <xsl:text>);
1122</xsl:text>
1123 </xsl:if>
1124
1125 <xsl:call-template name="emitTargetEnd">
1126 <xsl:with-param name="target" select="$target"/>
1127 </xsl:call-template>
1128</xsl:template>
1129
1130<xsl:template match="attribute" mode="wrapped">
1131 <xsl:param name="target"/>
1132
1133 <xsl:call-template name="emitTargetBegin">
1134 <xsl:with-param name="target" select="$target"/>
1135 </xsl:call-template>
1136
1137 <xsl:variable name="attrbasename">
1138 <xsl:call-template name="capitalize">
1139 <xsl:with-param name="str" select="@name"/>
1140 </xsl:call-template>
1141 </xsl:variable>
1142
1143 <xsl:value-of select="concat(' virtual HRESULT get', $attrbasename, '(')"/>
1144 <xsl:variable name="passAutoCaller">
1145 <xsl:call-template name="checkoption">
1146 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1147 <xsl:with-param name="option" select="'passcaller'"/>
1148 </xsl:call-template>
1149 </xsl:variable>
1150 <xsl:if test="$passAutoCaller = 'true'">
1151 <xsl:text>AutoCaller &amp;aAutoCaller, </xsl:text>
1152 </xsl:if>
1153 <xsl:apply-templates select="@type" mode="wrapped">
1154 <xsl:with-param name="dir" select="'out'"/>
1155 </xsl:apply-templates>
1156 <xsl:text>) = 0;
1157</xsl:text>
1158
1159 <xsl:if test="not(@readonly) or @readonly!='yes'">
1160 <xsl:value-of select="concat(' virtual HRESULT set', $attrbasename, '(')"/>
1161 <xsl:if test="$passAutoCaller = 'true'">
1162 <xsl:text>AutoCaller &amp;aAutoCaller, </xsl:text>
1163 </xsl:if>
1164 <xsl:apply-templates select="@type" mode="wrapped">
1165 <xsl:with-param name="dir" select="'in'"/>
1166 </xsl:apply-templates>
1167 <xsl:text>) = 0;
1168</xsl:text>
1169 </xsl:if>
1170
1171 <xsl:call-template name="emitTargetEnd">
1172 <xsl:with-param name="target" select="$target"/>
1173 </xsl:call-template>
1174</xsl:template>
1175
1176<xsl:template match="attribute" mode="code">
1177 <xsl:param name="topclass"/>
1178 <xsl:param name="dtracetopclass"/>
1179 <xsl:param name="target"/>
1180
1181 <xsl:call-template name="emitTargetBegin">
1182 <xsl:with-param name="target" select="$target"/>
1183 </xsl:call-template>
1184
1185 <xsl:variable name="attrbasename">
1186 <xsl:call-template name="capitalize">
1187 <xsl:with-param name="str" select="@name"/>
1188 </xsl:call-template>
1189 </xsl:variable>
1190 <xsl:variable name="limitedAutoCaller">
1191 <xsl:call-template name="checkoption">
1192 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1193 <xsl:with-param name="option" select="'limitedcaller'"/>
1194 </xsl:call-template>
1195 </xsl:variable>
1196
1197 <xsl:variable name="dtraceattrname">
1198 <xsl:choose>
1199 <xsl:when test="@dtracename">
1200 <xsl:value-of select="@dtracename"/>
1201 </xsl:when>
1202 <xsl:otherwise>
1203 <xsl:value-of select="$attrbasename"/>
1204 </xsl:otherwise>
1205 </xsl:choose>
1206 </xsl:variable>
1207
1208 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMGETTER(', $attrbasename, ')(')"/>
1209 <xsl:call-template name="emitPublicParameter">
1210 <xsl:with-param name="dir">out</xsl:with-param>
1211 </xsl:call-template>
1212 <xsl:text>)
1213{
1214 LogRelFlow(("{%p} %s: enter </xsl:text>
1215 <xsl:apply-templates select="@type" mode="logparamtext">
1216 <xsl:with-param name="dir" select="'out'"/>
1217 <xsl:with-param name="isref" select="'yes'"/>
1218 </xsl:apply-templates>
1219 <xsl:text>\n", this, </xsl:text>
1220 <xsl:value-of select="concat('&quot;', $topclass, '::get', $attrbasename, '&quot;, ')"/>
1221 <xsl:apply-templates select="@type" mode="logparamval">
1222 <xsl:with-param name="dir" select="'out'"/>
1223 <xsl:with-param name="isref" select="'yes'"/>
1224 </xsl:apply-templates>
1225 <xsl:text>));
1226
1227 VirtualBoxBase::clearError();
1228
1229 HRESULT hrc;
1230
1231 try
1232 {
1233 CheckComArgOutPointerValidThrow(a</xsl:text>
1234 <xsl:value-of select="$attrbasename"/>
1235 <xsl:text>);
1236 </xsl:text>
1237 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1238 <xsl:with-param name="dir" select="'out'"/>
1239 </xsl:apply-templates>
1240 <xsl:if test="$attrbasename != 'MidlDoesNotLikEmptyInterfaces'">
1241 <xsl:text>
1242#ifdef VBOX_WITH_DTRACE_R3_MAIN
1243 </xsl:text>
1244 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1245 <xsl:text>this);
1246#endif</xsl:text>
1247 </xsl:if>
1248 <xsl:text>
1249
1250 </xsl:text>
1251 <xsl:choose>
1252 <xsl:when test="$limitedAutoCaller = 'true'">
1253 <xsl:text>AutoLimitedCaller</xsl:text>
1254 </xsl:when>
1255 <xsl:otherwise>
1256 <xsl:text>AutoCaller</xsl:text>
1257 </xsl:otherwise>
1258 </xsl:choose>
1259 <xsl:text> autoCaller(this);
1260 if (FAILED(autoCaller.rc()))
1261 throw autoCaller.rc();
1262
1263</xsl:text>
1264 <xsl:value-of select="concat(' hrc = get', $attrbasename, '(')"/>
1265 <xsl:variable name="passAutoCaller">
1266 <xsl:call-template name="checkoption">
1267 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1268 <xsl:with-param name="option" select="'passcaller'"/>
1269 </xsl:call-template>
1270 </xsl:variable>
1271 <xsl:if test="$passAutoCaller = 'true'">
1272 <xsl:text>autoCaller, </xsl:text>
1273 </xsl:if>
1274 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1275 <xsl:with-param name="dir" select="'out'"/>
1276 </xsl:apply-templates>
1277 <xsl:text>);
1278</xsl:text>
1279 <xsl:if test="$attrbasename != 'MidlDoesNotLikEmptyInterfaces'">
1280 <xsl:text>
1281#ifdef VBOX_WITH_DTRACE_R3_MAIN
1282 </xsl:text>
1283 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1284 <xsl:text>this, hrc, 0 /*normal*/,</xsl:text>
1285 <xsl:call-template name="emitDTraceParamValue">
1286 <xsl:with-param name="dir">out</xsl:with-param>
1287 </xsl:call-template>
1288 <xsl:text>);
1289#endif
1290</xsl:text>
1291 </xsl:if>
1292 <xsl:text>
1293 }
1294 catch (HRESULT hrc2)
1295 {
1296 hrc = hrc2;</xsl:text>
1297 <xsl:if test="$attrbasename != 'MidlDoesNotLikEmptyInterfaces'">
1298 <xsl:text>
1299#ifdef VBOX_WITH_DTRACE_R3_MAIN
1300 </xsl:text>
1301 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1302 <xsl:text>this, hrc, 1 /*hrc exception*/,</xsl:text>
1303 <xsl:call-template name="emitDTraceParamValNoTmp-DirNotIn"/>
1304 <xsl:text>);
1305#endif
1306</xsl:text>
1307 </xsl:if>
1308 <xsl:text>
1309 }
1310 catch (...)
1311 {
1312 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);</xsl:text>
1313 <xsl:if test="$attrbasename != 'MidlDoesNotLikEmptyInterfaces'">
1314 <xsl:text>
1315#ifdef VBOX_WITH_DTRACE_R3_MAIN
1316 </xsl:text>
1317 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1318 <xsl:text>this, hrc, 9 /*unhandled exception*/,</xsl:text>
1319 <xsl:call-template name="emitDTraceParamValNoTmp-DirNotIn"/>
1320 <xsl:text>);
1321#endif
1322</xsl:text>
1323 </xsl:if>
1324 <xsl:text>
1325 }
1326
1327 LogRelFlow(("{%p} %s: leave </xsl:text>
1328 <xsl:apply-templates select="@type" mode="logparamtext">
1329 <xsl:with-param name="dir" select="'out'"/>
1330 <xsl:with-param name="isref" select="''"/>
1331 </xsl:apply-templates>
1332 <xsl:text> hrc=%Rhrc\n", this, </xsl:text>
1333 <xsl:value-of select="concat('&quot;', $topclass, '::get', $dtraceattrname, '&quot;, ')"/>
1334 <xsl:apply-templates select="@type" mode="logparamval">
1335 <xsl:with-param name="dir" select="'out'"/>
1336 <xsl:with-param name="isref" select="''"/>
1337 </xsl:apply-templates>
1338 <xsl:text>, hrc));
1339 return hrc;
1340}
1341</xsl:text>
1342 <xsl:if test="not(@readonly) or @readonly!='yes'">
1343 <xsl:text>
1344</xsl:text>
1345 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMSETTER(', $attrbasename, ')(')"/>
1346 <xsl:call-template name="emitPublicParameter">
1347 <xsl:with-param name="dir">in</xsl:with-param>
1348 </xsl:call-template>
1349 <!-- @todo check in parameters if possible -->
1350 <xsl:text>)
1351{
1352 LogRelFlow(("{%p} %s: enter </xsl:text>
1353 <xsl:apply-templates select="@type" mode="logparamtext">
1354 <xsl:with-param name="dir" select="'in'"/>
1355 <xsl:with-param name="isref" select="''"/>
1356 </xsl:apply-templates>
1357 <xsl:text>\n", this, </xsl:text>
1358 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
1359 <xsl:apply-templates select="@type" mode="logparamval">
1360 <xsl:with-param name="dir" select="'in'"/>
1361 <xsl:with-param name="isref" select="''"/>
1362 </xsl:apply-templates>
1363 <xsl:text>));
1364
1365 VirtualBoxBase::clearError();
1366
1367 HRESULT hrc;
1368
1369 try
1370 {
1371 </xsl:text>
1372 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1373 <xsl:with-param name="dir" select="'in'"/>
1374 </xsl:apply-templates>
1375 <xsl:text>
1376
1377#ifdef VBOX_WITH_DTRACE_R3_MAIN
1378 </xsl:text>
1379 <xsl:value-of select="translate(concat('VBOXAPI_', $topclass, '_SET_', $dtraceattrname, '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1380 <xsl:text>this, </xsl:text>
1381 <xsl:call-template name="emitDTraceParamValue">
1382 <xsl:with-param name="dir">in</xsl:with-param>
1383 </xsl:call-template>
1384 <xsl:text>);
1385#endif
1386
1387 </xsl:text>
1388 <xsl:choose>
1389 <xsl:when test="$limitedAutoCaller = 'true'">
1390 <xsl:text>AutoLimitedCaller</xsl:text>
1391 </xsl:when>
1392 <xsl:otherwise>
1393 <xsl:text>AutoCaller</xsl:text>
1394 </xsl:otherwise>
1395 </xsl:choose>
1396 <xsl:text> autoCaller(this);
1397 if (FAILED(autoCaller.rc()))
1398 throw autoCaller.rc();
1399
1400</xsl:text>
1401 <xsl:value-of select="concat(' hrc = set', $attrbasename, '(')"/>
1402 <xsl:if test="$passAutoCaller = 'true'">
1403 <xsl:text>autoCaller, </xsl:text>
1404 </xsl:if>
1405 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1406 <xsl:with-param name="dir" select="'in'"/>
1407 </xsl:apply-templates>
1408 <xsl:text>);
1409
1410#ifdef VBOX_WITH_DTRACE_R3_MAIN
1411 </xsl:text>
1412 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1413 <xsl:text>this, hrc, 0 /*normal*/,</xsl:text>
1414 <xsl:call-template name="emitDTraceParamValue">
1415 <xsl:with-param name="dir">in</xsl:with-param>
1416 </xsl:call-template>
1417 <xsl:text>);
1418#endif
1419 }
1420 catch (HRESULT hrc2)
1421 {
1422 hrc = hrc2;
1423#ifdef VBOX_WITH_DTRACE_R3_MAIN
1424 </xsl:text>
1425 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1426 <xsl:text>this, hrc, 1 /*hrc exception*/,</xsl:text>
1427 <xsl:call-template name="emitDTraceParamValNoTmp-DirIn"/>
1428 <xsl:text>);
1429#endif
1430 }
1431 catch (...)
1432 {
1433 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1434#ifdef VBOX_WITH_DTRACE_R3_MAIN
1435 </xsl:text>
1436 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1437 <xsl:text>this, hrc, 9 /*unhandled exception*/,</xsl:text>
1438 <xsl:call-template name="emitDTraceParamValNoTmp-DirIn"/>
1439 <xsl:text>);
1440#endif
1441 }
1442
1443 LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, </xsl:text>
1444 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
1445 <xsl:text>hrc));
1446 return hrc;
1447}
1448</xsl:text>
1449 </xsl:if>
1450
1451 <xsl:call-template name="emitTargetEnd">
1452 <xsl:with-param name="target" select="$target"/>
1453 </xsl:call-template>
1454
1455 <xsl:call-template name="xsltprocNewlineOutputHack"/>
1456</xsl:template>
1457
1458<!-- - - - - - - - - - - - - - - - - - - - - - -
1459 Emit DTrace probes for the given attribute.
1460 - - - - - - - - - - - - - - - - - - - - - - -->
1461<xsl:template match="attribute" mode="dtrace-probes">
1462 <xsl:param name="topclass"/>
1463 <xsl:param name="dtracetopclass"/>
1464 <xsl:param name="target"/>
1465
1466 <xsl:variable name="dtraceattrname">
1467 <xsl:choose>
1468 <xsl:when test="@dtracename">
1469 <xsl:value-of select="@dtracename"/>
1470 </xsl:when>
1471 <xsl:otherwise>
1472 <!-- attrbasename -->
1473 <xsl:call-template name="capitalize">
1474 <xsl:with-param name="str" select="@name"/>
1475 </xsl:call-template>
1476 </xsl:otherwise>
1477 </xsl:choose>
1478 </xsl:variable>
1479
1480 <xsl:if test="@name != 'midlDoesNotLikEmptyInterfaces'">
1481 <xsl:text> probe </xsl:text>
1482 <!-- <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__enter(struct ', $topclass)"/> -->
1483 <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__enter(void')"/>
1484 <xsl:text> *a_pThis);
1485 probe </xsl:text>
1486 <!-- <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__return(struct ', $topclass, ' *a_pThis')"/> -->
1487 <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__return(void *a_pThis')"/>
1488 <xsl:text>, uint32_t a_hrc, int32_t enmWhy, </xsl:text>
1489 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1490 <xsl:with-param name="dir">out</xsl:with-param>
1491 </xsl:apply-templates>
1492 <xsl:text>);
1493</xsl:text>
1494 </xsl:if>
1495 <xsl:if test="(not(@readonly) or @readonly!='yes') and @name != 'midlDoesNotLikEmptyInterfaces'">
1496 <xsl:text> probe </xsl:text>
1497 <!-- <xsl:value-of select="concat($topclass, '__set__', $dtraceattrname, '__enter(struct ', $topclass, ' *a_pThis, ')"/>-->
1498 <xsl:value-of select="concat($topclass, '__set__', $dtraceattrname, '__enter(void *a_pThis, ')"/>
1499 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1500 <xsl:with-param name="dir" select="'in'"/>
1501 </xsl:apply-templates>
1502 <xsl:text>);
1503 probe </xsl:text>
1504 <!-- <xsl:value-of select="concat($dtracetopclass, '__set__', $dtraceattrname, '__return(struct ', $topclass, ' *a_pThis')"/> -->
1505 <xsl:value-of select="concat($dtracetopclass, '__set__', $dtraceattrname, '__return(void *a_pThis')"/>
1506 <xsl:text>, uint32_t a_hrc, int32_t enmWhy, </xsl:text>
1507 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1508 <xsl:with-param name="dir">in</xsl:with-param>
1509 </xsl:apply-templates>
1510 <xsl:text>);
1511</xsl:text>
1512 </xsl:if>
1513</xsl:template>
1514
1515<!-- - - - - - - - - - - - - - - - - - - - - - -
1516 Emit all attributes of an interface (current node).
1517 - - - - - - - - - - - - - - - - - - - - - - -->
1518<xsl:template name="emitAttributes">
1519 <xsl:param name="topclass"/>
1520 <xsl:param name="dtracetopclass"/>
1521 <xsl:param name="pmode"/>
1522
1523 <!-- first recurse to emit all base interfaces -->
1524 <xsl:variable name="extends" select="@extends"/>
1525 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
1526 <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
1527 <xsl:call-template name="emitAttributes">
1528 <xsl:with-param name="topclass" select="$topclass"/>
1529 <xsl:with-param name="pmode" select="$pmode"/>
1530 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1531 </xsl:call-template>
1532 </xsl:for-each>
1533 </xsl:if>
1534
1535 <xsl:choose>
1536 <xsl:when test="$pmode='code'">
1537 <xsl:text>//
1538</xsl:text>
1539 <xsl:value-of select="concat('// ', @name, ' properties')"/>
1540 <xsl:text>
1541//
1542
1543</xsl:text>
1544 </xsl:when>
1545 <xsl:when test="$pmode != 'dtrace-probes'">
1546 <xsl:value-of select="concat($G_sNewLine, ' // ', $pmode, ' ', @name, ' properties', $G_sNewLine)"/>
1547 </xsl:when>
1548 </xsl:choose>
1549 <xsl:choose>
1550 <xsl:when test="$pmode='public'">
1551 <xsl:apply-templates select="./attribute | ./if" mode="public">
1552 <xsl:with-param name="emitmode" select="'attribute'"/>
1553 </xsl:apply-templates>
1554 </xsl:when>
1555 <xsl:when test="$pmode='wrapped'">
1556 <xsl:apply-templates select="./attribute | ./if" mode="wrapped">
1557 <xsl:with-param name="emitmode" select="'attribute'"/>
1558 </xsl:apply-templates>
1559 </xsl:when>
1560 <xsl:when test="$pmode='code'">
1561 <xsl:apply-templates select="./attribute | ./if" mode="code">
1562 <xsl:with-param name="topclass" select="$topclass"/>
1563 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1564 <xsl:with-param name="emitmode" select="'attribute'"/>
1565 </xsl:apply-templates>
1566 </xsl:when>
1567 <xsl:when test="$pmode = 'dtrace-probes'">
1568 <xsl:apply-templates select="./attribute | ./if" mode="dtrace-probes">
1569 <xsl:with-param name="topclass" select="$topclass"/>
1570 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1571 <xsl:with-param name="emitmode" select="'attribute'"/>
1572 </xsl:apply-templates>
1573 </xsl:when>
1574 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitAttributes</xsl:message></xsl:otherwise>
1575 </xsl:choose>
1576</xsl:template>
1577
1578<xsl:template name="emitTargetBegin">
1579 <xsl:param name="target"/>
1580
1581 <xsl:choose>
1582 <xsl:when test="$target = ''"/>
1583 <xsl:when test="$target = 'xpidl'">
1584 <xsl:text>#ifdef VBOX_WITH_XPCOM
1585</xsl:text>
1586 </xsl:when>
1587 <xsl:when test="$target = 'midl'">
1588 <xsl:text>#ifndef VBOX_WITH_XPCOM
1589</xsl:text>
1590 </xsl:when>
1591 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitTargetBegin: target=<xsl:value-of select="$target"/></xsl:message></xsl:otherwise>
1592 </xsl:choose>
1593</xsl:template>
1594
1595<xsl:template name="emitTargetEnd">
1596 <xsl:param name="target"/>
1597
1598 <xsl:choose>
1599 <xsl:when test="$target = ''"/>
1600 <xsl:when test="$target = 'xpidl'">
1601 <xsl:text>#endif /* VBOX_WITH_XPCOM */
1602</xsl:text>
1603 </xsl:when>
1604 <xsl:when test="$target = 'midl'">
1605 <xsl:text>#endif /* !VBOX_WITH_XPCOM */
1606</xsl:text>
1607 </xsl:when>
1608 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitTargetEnd target=<xsl:value-of select="$target"/></xsl:message></xsl:otherwise>
1609 </xsl:choose>
1610</xsl:template>
1611
1612
1613<!-- - - - - - - - - - - - - - - - - - - - - - -
1614 emit method
1615 - - - - - - - - - - - - - - - - - - - - - - -->
1616
1617<xsl:template match="method" mode="public">
1618 <xsl:param name="target"/>
1619
1620 <xsl:call-template name="emitTargetBegin">
1621 <xsl:with-param name="target" select="$target"/>
1622 </xsl:call-template>
1623
1624 <xsl:variable name="methodindent">
1625 <xsl:call-template name="tospace">
1626 <xsl:with-param name="str" select="@name"/>
1627 </xsl:call-template>
1628 </xsl:variable>
1629
1630 <xsl:text> STDMETHOD(</xsl:text>
1631 <xsl:call-template name="capitalize">
1632 <xsl:with-param name="str" select="@name"/>
1633 </xsl:call-template>
1634 <xsl:text>)(</xsl:text>
1635 <xsl:for-each select="param">
1636 <xsl:call-template name="emitPublicParameter">
1637 <xsl:with-param name="dir" select="@dir"/>
1638 </xsl:call-template>
1639 <xsl:if test="not(position()=last())">
1640 <xsl:text>,
1641 </xsl:text>
1642 <xsl:value-of select="$methodindent"/>
1643 </xsl:if>
1644 </xsl:for-each>
1645 <xsl:text>);
1646</xsl:text>
1647
1648 <xsl:call-template name="emitTargetEnd">
1649 <xsl:with-param name="target" select="$target"/>
1650 </xsl:call-template>
1651</xsl:template>
1652
1653<xsl:template match="method" mode="wrapped">
1654 <xsl:param name="target"/>
1655
1656 <xsl:call-template name="emitTargetBegin">
1657 <xsl:with-param name="target" select="$target"/>
1658 </xsl:call-template>
1659
1660 <xsl:variable name="methodindent">
1661 <xsl:call-template name="tospace">
1662 <xsl:with-param name="str" select="@name"/>
1663 </xsl:call-template>
1664 </xsl:variable>
1665
1666 <xsl:text> virtual HRESULT </xsl:text>
1667 <xsl:call-template name="uncapitalize">
1668 <xsl:with-param name="str" select="@name"/>
1669 </xsl:call-template>
1670 <xsl:text>(</xsl:text>
1671 <xsl:variable name="passAutoCaller">
1672 <xsl:call-template name="checkoption">
1673 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1674 <xsl:with-param name="option" select="'passcaller'"/>
1675 </xsl:call-template>
1676 </xsl:variable>
1677 <xsl:if test="$passAutoCaller = 'true'">
1678 <xsl:text>AutoCaller &amp;aAutoCaller</xsl:text>
1679 <xsl:if test="count(param) > 0">
1680 <xsl:text>,
1681 </xsl:text>
1682 <xsl:value-of select="$methodindent"/>
1683 </xsl:if>
1684 </xsl:if>
1685 <xsl:for-each select="param">
1686 <xsl:apply-templates select="@type" mode="wrapped">
1687 <xsl:with-param name="dir" select="@dir"/>
1688 </xsl:apply-templates>
1689 <xsl:if test="not(position()=last())">
1690 <xsl:text>,
1691 </xsl:text>
1692 <xsl:value-of select="$methodindent"/>
1693 </xsl:if>
1694 </xsl:for-each>
1695 <xsl:text>) = 0;
1696</xsl:text>
1697
1698 <xsl:call-template name="emitTargetEnd">
1699 <xsl:with-param name="target" select="$target"/>
1700 </xsl:call-template>
1701</xsl:template>
1702
1703<xsl:template match="method" mode="code">
1704 <xsl:param name="topclass"/>
1705 <xsl:param name="dtracetopclass"/>
1706 <xsl:param name="target"/>
1707
1708 <xsl:call-template name="emitTargetBegin">
1709 <xsl:with-param name="target" select="$target"/>
1710 </xsl:call-template>
1711
1712 <xsl:variable name="methodindent">
1713 <xsl:call-template name="tospace">
1714 <xsl:with-param name="str" select="@name"/>
1715 </xsl:call-template>
1716 </xsl:variable>
1717 <xsl:variable name="methodclassindent">
1718 <xsl:call-template name="tospace">
1719 <xsl:with-param name="str" select="concat($topclass, @name)"/>
1720 </xsl:call-template>
1721 </xsl:variable>
1722 <xsl:variable name="methodbasename">
1723 <xsl:call-template name="capitalize">
1724 <xsl:with-param name="str" select="@name"/>
1725 </xsl:call-template>
1726 </xsl:variable>
1727 <xsl:variable name="limitedAutoCaller">
1728 <xsl:call-template name="checkoption">
1729 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1730 <xsl:with-param name="option" select="'limitedcaller'"/>
1731 </xsl:call-template>
1732 </xsl:variable>
1733 <xsl:variable name="dtracemethodname">
1734 <xsl:choose>
1735 <xsl:when test="@dtracename">
1736 <xsl:value-of select="@dtracename"/>
1737 </xsl:when>
1738 <xsl:otherwise>
1739 <xsl:value-of select="@name"/>
1740 </xsl:otherwise>
1741 </xsl:choose>
1742 </xsl:variable>
1743 <xsl:variable name="dtracenamehack"> <!-- Ugly hack to deal with Session::assignMachine and similar. -->
1744 <xsl:if test="name(..) = 'if'">
1745 <xsl:value-of select="concat('__', ../@target)"/>
1746 </xsl:if>
1747 </xsl:variable>
1748
1749 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::', $methodbasename, '(')"/>
1750 <xsl:for-each select="param">
1751 <xsl:call-template name="emitPublicParameter">
1752 <xsl:with-param name="dir" select="@dir"/>
1753 </xsl:call-template>
1754 <xsl:if test="not(position()=last())">
1755 <xsl:text>,
1756 </xsl:text>
1757 <xsl:value-of select="$methodclassindent"/>
1758 </xsl:if>
1759 </xsl:for-each>
1760 <xsl:text>)
1761{
1762 LogRelFlow(("{%p} %s:enter</xsl:text>
1763 <xsl:for-each select="param">
1764 <xsl:text> </xsl:text>
1765 <xsl:apply-templates select="@type" mode="logparamtext">
1766 <xsl:with-param name="dir" select="@dir"/>
1767 <xsl:with-param name="isref" select="'yes'"/>
1768 </xsl:apply-templates>
1769 </xsl:for-each>
1770 <xsl:text>\n", this</xsl:text>
1771 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1772 <xsl:for-each select="param">
1773 <xsl:text>, </xsl:text>
1774 <xsl:apply-templates select="@type" mode="logparamval">
1775 <xsl:with-param name="dir" select="@dir"/>
1776 <xsl:with-param name="isref" select="'yes'"/>
1777 </xsl:apply-templates>
1778 </xsl:for-each>
1779 <xsl:text>));
1780
1781 VirtualBoxBase::clearError();
1782
1783 HRESULT hrc;
1784
1785 try
1786 {
1787</xsl:text>
1788 <!-- @todo check in parameters if possible -->
1789 <xsl:for-each select="param">
1790 <xsl:if test="@dir!='in'">
1791 <xsl:text> CheckComArgOutPointerValidThrow(a</xsl:text>
1792 <xsl:call-template name="capitalize">
1793 <xsl:with-param name="str" select="@name"/>
1794 </xsl:call-template>
1795 <xsl:text>);
1796</xsl:text>
1797 </xsl:if>
1798 </xsl:for-each>
1799<xsl:text>
1800</xsl:text>
1801 <xsl:for-each select="param">
1802 <xsl:text>
1803 </xsl:text>
1804 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1805 <xsl:with-param name="dir" select="@dir"/>
1806 </xsl:apply-templates>
1807 </xsl:for-each>
1808 <xsl:text>
1809#ifdef VBOX_WITH_DTRACE_R3_MAIN
1810 </xsl:text>
1811 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1812 <xsl:text>this</xsl:text>
1813 <xsl:for-each select="param[@dir='in']">
1814 <xsl:text>, </xsl:text>
1815 <xsl:call-template name="emitDTraceParamValue">
1816 <xsl:with-param name="dir" select="@dir"/>
1817 </xsl:call-template>
1818 </xsl:for-each>
1819 <xsl:text>);
1820#endif
1821
1822 </xsl:text>
1823 <xsl:choose>
1824 <xsl:when test="$limitedAutoCaller = 'true'">
1825 <xsl:text>AutoLimitedCaller</xsl:text>
1826 </xsl:when>
1827 <xsl:otherwise>
1828 <xsl:text>AutoCaller</xsl:text>
1829 </xsl:otherwise>
1830 </xsl:choose>
1831 <xsl:text> autoCaller(this);
1832 if (FAILED(autoCaller.rc()))
1833 throw autoCaller.rc();
1834
1835</xsl:text>
1836 <xsl:value-of select="concat(' hrc = ', @name, '(')"/>
1837 <xsl:variable name="passAutoCaller">
1838 <xsl:call-template name="checkoption">
1839 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1840 <xsl:with-param name="option" select="'passcaller'"/>
1841 </xsl:call-template>
1842 </xsl:variable>
1843 <xsl:if test="$passAutoCaller = 'true'">
1844 <xsl:text>autoCaller</xsl:text>
1845 <xsl:if test="count(param) > 0">
1846 <xsl:text>,
1847 </xsl:text>
1848 <xsl:value-of select="$methodindent"/>
1849 </xsl:if>
1850 </xsl:if>
1851 <xsl:for-each select="param">
1852 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1853 <xsl:with-param name="dir" select="@dir"/>
1854 </xsl:apply-templates>
1855 <xsl:if test="not(position()=last())">
1856 <xsl:text>,
1857 </xsl:text>
1858 <xsl:value-of select="$methodindent"/>
1859 </xsl:if>
1860 </xsl:for-each>
1861 <xsl:text>);
1862
1863#ifdef VBOX_WITH_DTRACE_R3_MAIN
1864 </xsl:text>
1865 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1866 <xsl:text>this, hrc, 0 /*normal*/</xsl:text>
1867 <xsl:for-each select="param">
1868 <xsl:text>, </xsl:text>
1869 <xsl:call-template name="emitDTraceParamValue">
1870 <xsl:with-param name="dir" select="@dir"/>
1871 </xsl:call-template>
1872 </xsl:for-each>
1873 <xsl:text>);
1874#endif
1875 }
1876 catch (HRESULT hrc2)
1877 {
1878 hrc = hrc2;
1879#ifdef VBOX_WITH_DTRACE_R3_MAIN
1880 </xsl:text>
1881 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1882 <xsl:text>this, hrc, 1 /*hrc exception*/</xsl:text>
1883 <xsl:for-each select="param">
1884 <xsl:text>, </xsl:text>
1885 <xsl:call-template name="emitDTraceParamValNoTmp"/>
1886 </xsl:for-each>
1887 <xsl:text>);
1888#endif
1889 }
1890 catch (...)
1891 {
1892 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1893#ifdef VBOX_WITH_DTRACE_R3_MAIN
1894 </xsl:text>
1895 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1896 <xsl:text>this, hrc, 9 /*unhandled exception*/</xsl:text>
1897 <xsl:for-each select="param">
1898 <xsl:text>, </xsl:text>
1899 <xsl:call-template name="emitDTraceParamValNoTmp"/>
1900 </xsl:for-each>
1901 <xsl:text>);
1902#endif
1903 }
1904
1905 LogRelFlow(("{%p} %s: leave</xsl:text>
1906 <xsl:for-each select="param">
1907 <xsl:if test="@dir!='in'">
1908 <xsl:text> </xsl:text>
1909 <xsl:apply-templates select="@type" mode="logparamtext">
1910 <xsl:with-param name="dir" select="@dir"/>
1911 <xsl:with-param name="isref" select="''"/>
1912 </xsl:apply-templates>
1913 </xsl:if>
1914 </xsl:for-each>
1915 <xsl:text> hrc=%Rhrc\n", this</xsl:text>
1916 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1917 <xsl:for-each select="param">
1918 <xsl:if test="@dir!='in'">
1919 <xsl:text>, </xsl:text>
1920 <xsl:apply-templates select="@type" mode="logparamval">
1921 <xsl:with-param name="dir" select="@dir"/>
1922 <xsl:with-param name="isref" select="''"/>
1923 </xsl:apply-templates>
1924 </xsl:if>
1925 </xsl:for-each>
1926 <xsl:text>, hrc));
1927 return hrc;
1928}
1929</xsl:text>
1930
1931 <xsl:call-template name="emitTargetEnd">
1932 <xsl:with-param name="target" select="$target"/>
1933 </xsl:call-template>
1934
1935 <xsl:text>
1936</xsl:text>
1937</xsl:template>
1938
1939<!-- - - - - - - - - - - - - - - - - - - - - - -
1940 Emits the DTrace probes for a method.
1941 - - - - - - - - - - - - - - - - - - - - - - -->
1942<xsl:template match="method" mode="dtrace-probes">
1943 <xsl:param name="topclass"/>
1944 <xsl:param name="dtracetopclass"/>
1945 <xsl:param name="target"/>
1946
1947 <xsl:variable name="dtracemethodname">
1948 <xsl:choose>
1949 <xsl:when test="@dtracename">
1950 <xsl:value-of select="@dtracename"/>
1951 </xsl:when>
1952 <xsl:otherwise>
1953 <xsl:value-of select="@name"/>
1954 </xsl:otherwise>
1955 </xsl:choose>
1956 </xsl:variable>
1957 <xsl:variable name="dtracenamehack"> <!-- Ugly hack to deal with Session::assignMachine and similar. -->
1958 <xsl:if test="name(..) = 'if'">
1959 <xsl:value-of select="concat('__', ../@target)"/>
1960 </xsl:if>
1961 </xsl:variable>
1962
1963 <xsl:text> probe </xsl:text>
1964 <!-- <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__enter(struct ', $dtracetopclass, ' *a_pThis')"/> -->
1965 <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__enter(void *a_pThis')"/>
1966 <xsl:for-each select="param[@dir='in']">
1967 <xsl:text>, </xsl:text>
1968 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1969 <xsl:with-param name="dir" select="'@dir'"/>
1970 </xsl:apply-templates>
1971 </xsl:for-each>
1972 <xsl:text>);
1973 probe </xsl:text>
1974 <!-- <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, '__return(struct ', $dtracetopclass, ' *a_pThis')"/> -->
1975 <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__return(void *a_pThis')"/>
1976 <xsl:text>, uint32_t a_hrc, int32_t enmWhy</xsl:text>
1977 <xsl:for-each select="param">
1978 <xsl:text>, </xsl:text>
1979 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1980 <xsl:with-param name="dir" select="'@dir'"/>
1981 </xsl:apply-templates>
1982 </xsl:for-each>
1983 <xsl:text>);
1984</xsl:text>
1985
1986</xsl:template>
1987
1988
1989<xsl:template name="emitIf">
1990 <xsl:param name="passmode"/>
1991 <xsl:param name="target"/>
1992 <xsl:param name="topclass"/>
1993 <xsl:param name="emitmode"/>
1994 <xsl:param name="dtracetopclass"/>
1995
1996 <xsl:if test="($target = 'xpidl') or ($target = 'midl')">
1997 <xsl:choose>
1998 <xsl:when test="$passmode='public'">
1999 <xsl:choose>
2000 <xsl:when test="$emitmode='method'">
2001 <xsl:apply-templates select="method" mode="public">
2002 <xsl:with-param name="target" select="$target"/>
2003 </xsl:apply-templates>
2004 </xsl:when>
2005 <xsl:when test="$emitmode='attribute'">
2006 <xsl:apply-templates select="attribute" mode="public">
2007 <xsl:with-param name="target" select="$target"/>
2008 </xsl:apply-templates>
2009 </xsl:when>
2010 <xsl:otherwise/>
2011 </xsl:choose>
2012 </xsl:when>
2013 <xsl:when test="$passmode='wrapped'">
2014 <xsl:choose>
2015 <xsl:when test="$emitmode='method'">
2016 <xsl:apply-templates select="method" mode="wrapped">
2017 <xsl:with-param name="target" select="$target"/>
2018 </xsl:apply-templates>
2019 </xsl:when>
2020 <xsl:when test="$emitmode='attribute'">
2021 <xsl:apply-templates select="attribute" mode="wrapped">
2022 <xsl:with-param name="target" select="$target"/>
2023 </xsl:apply-templates>
2024 </xsl:when>
2025 <xsl:otherwise/>
2026 </xsl:choose>
2027 </xsl:when>
2028 <xsl:when test="$passmode='code'">
2029 <xsl:choose>
2030 <xsl:when test="$emitmode='method'">
2031 <xsl:apply-templates select="method" mode="code">
2032 <xsl:with-param name="target" select="$target"/>
2033 <xsl:with-param name="topclass" select="$topclass"/>
2034 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2035 </xsl:apply-templates>
2036 </xsl:when>
2037 <xsl:when test="$emitmode='attribute'">
2038 <xsl:apply-templates select="attribute" mode="code">
2039 <xsl:with-param name="target" select="$target"/>
2040 <xsl:with-param name="topclass" select="$topclass"/>
2041 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2042 </xsl:apply-templates>
2043 </xsl:when>
2044 <xsl:otherwise/>
2045 </xsl:choose>
2046 </xsl:when>
2047 <xsl:when test="$passmode = 'dtrace-probes'">
2048 <xsl:choose>
2049 <xsl:when test="$emitmode = 'method'">
2050 <xsl:apply-templates select="method" mode="dtrace-probes">
2051 <xsl:with-param name="target" select="$target"/>
2052 <xsl:with-param name="topclass" select="$topclass"/>
2053 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2054 </xsl:apply-templates>
2055 </xsl:when>
2056 <xsl:when test="$emitmode = 'attribute'">
2057 <xsl:apply-templates select="attribute" mode="dtrace-probes">
2058 <xsl:with-param name="target" select="$target"/>
2059 <xsl:with-param name="topclass" select="$topclass"/>
2060 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2061 </xsl:apply-templates>
2062 </xsl:when>
2063 <xsl:otherwise/>
2064 </xsl:choose>
2065 </xsl:when>
2066 <xsl:otherwise/>
2067 </xsl:choose>
2068 </xsl:if>
2069</xsl:template>
2070
2071<xsl:template match="if" mode="public">
2072 <xsl:param name="emitmode"/>
2073
2074 <xsl:call-template name="emitIf">
2075 <xsl:with-param name="passmode" select="'public'"/>
2076 <xsl:with-param name="target" select="@target"/>
2077 <xsl:with-param name="emitmode" select="$emitmode"/>
2078 </xsl:call-template>
2079</xsl:template>
2080
2081<xsl:template match="if" mode="wrapped">
2082 <xsl:param name="emitmode"/>
2083
2084 <xsl:call-template name="emitIf">
2085 <xsl:with-param name="passmode" select="'wrapped'"/>
2086 <xsl:with-param name="target" select="@target"/>
2087 <xsl:with-param name="emitmode" select="$emitmode"/>
2088 </xsl:call-template>
2089</xsl:template>
2090
2091<xsl:template match="if" mode="code">
2092 <xsl:param name="topclass"/>
2093 <xsl:param name="emitmode"/>
2094 <xsl:param name="dtracetopclass"/>
2095
2096 <xsl:call-template name="emitIf">
2097 <xsl:with-param name="passmode" select="'code'"/>
2098 <xsl:with-param name="target" select="@target"/>
2099 <xsl:with-param name="emitmode" select="$emitmode"/>
2100 <xsl:with-param name="topclass" select="$topclass"/>
2101 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2102 </xsl:call-template>
2103</xsl:template>
2104
2105<xsl:template match="if" mode="dtrace-probes">
2106 <xsl:param name="topclass"/>
2107 <xsl:param name="emitmode"/>
2108 <xsl:param name="dtracetopclass"/>
2109
2110 <xsl:call-template name="emitIf">
2111 <xsl:with-param name="passmode" select="'dtrace-probes'"/>
2112 <xsl:with-param name="target" select="@target"/>
2113 <xsl:with-param name="emitmode" select="$emitmode"/>
2114 <xsl:with-param name="topclass" select="$topclass"/>
2115 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2116 </xsl:call-template>
2117</xsl:template>
2118
2119<!-- - - - - - - - - - - - - - - - - - - - - - -
2120 emit all methods of the current interface
2121 - - - - - - - - - - - - - - - - - - - - - - -->
2122<xsl:template name="emitMethods">
2123 <xsl:param name="topclass"/>
2124 <xsl:param name="pmode"/>
2125 <xsl:param name="dtracetopclass"/>
2126
2127 <!-- first recurse to emit all base interfaces -->
2128 <xsl:variable name="extends" select="@extends"/>
2129 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
2130 <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
2131 <xsl:call-template name="emitMethods">
2132 <xsl:with-param name="topclass" select="$topclass"/>
2133 <xsl:with-param name="pmode" select="$pmode"/>
2134 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2135 </xsl:call-template>
2136 </xsl:for-each>
2137 </xsl:if>
2138
2139 <xsl:choose>
2140 <xsl:when test="$pmode='code'">
2141 <xsl:text>//
2142</xsl:text>
2143 <xsl:value-of select="concat('// ', @name, ' methods')"/>
2144 <xsl:text>
2145//
2146
2147</xsl:text>
2148 </xsl:when>
2149 <xsl:when test="$pmode='dtrace-probes'"/>
2150 <xsl:otherwise>
2151 <xsl:value-of select="concat($G_sNewLine, ' // ', $pmode, ' ', @name, ' methods', $G_sNewLine)"/>
2152 </xsl:otherwise>
2153 </xsl:choose>
2154 <xsl:choose>
2155 <xsl:when test="$pmode='public'">
2156 <xsl:apply-templates select="./method | ./if" mode="public">
2157 <xsl:with-param name="emitmode" select="'method'"/>
2158 </xsl:apply-templates>
2159 </xsl:when>
2160 <xsl:when test="$pmode='wrapped'">
2161 <xsl:apply-templates select="./method | ./if" mode="wrapped">
2162 <xsl:with-param name="emitmode" select="'method'"/>
2163 </xsl:apply-templates>
2164 </xsl:when>
2165 <xsl:when test="$pmode='code'">
2166 <xsl:apply-templates select="./method | ./if" mode="code">
2167 <xsl:with-param name="topclass" select="$topclass"/>
2168 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2169 <xsl:with-param name="emitmode" select="'method'"/>
2170 </xsl:apply-templates>
2171 </xsl:when>
2172 <xsl:when test="$pmode='dtrace-probes'">
2173 <xsl:apply-templates select="./method | ./if" mode="dtrace-probes">
2174 <xsl:with-param name="topclass" select="$topclass"/>
2175 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2176 <xsl:with-param name="emitmode" select="'method'"/>
2177 </xsl:apply-templates>
2178 </xsl:when>
2179 <xsl:otherwise/>
2180 </xsl:choose>
2181</xsl:template>
2182
2183<!-- - - - - - - - - - - - - - - - - - - - - - -
2184 emit all attributes and methods declarations of the current interface
2185 - - - - - - - - - - - - - - - - - - - - - - -->
2186<xsl:template name="emitInterfaceDecls">
2187 <xsl:param name="pmode"/>
2188
2189 <!-- attributes -->
2190 <xsl:call-template name="emitAttributes">
2191 <xsl:with-param name="pmode" select="$pmode"/>
2192 </xsl:call-template>
2193
2194 <!-- methods -->
2195 <xsl:call-template name="emitMethods">
2196 <xsl:with-param name="pmode" select="$pmode"/>
2197 </xsl:call-template>
2198</xsl:template>
2199
2200<!-- - - - - - - - - - - - - - - - - - - - - - -
2201 emit auxiliary method declarations of the current interface
2202 - - - - - - - - - - - - - - - - - - - - - - -->
2203<xsl:template name="emitAuxMethodDecls">
2204 <!-- currently nothing, maybe later some generic FinalConstruct/... helper declaration for ComObjPtr -->
2205</xsl:template>
2206
2207<!-- - - - - - - - - - - - - - - - - - - - - - -
2208 emit the header file of the current interface
2209 - - - - - - - - - - - - - - - - - - - - - - -->
2210<xsl:template name="emitHeader">
2211 <xsl:param name="addinterfaces"/>
2212
2213 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.h')"/>
2214
2215 <xsl:apply-templates select="." mode="startfile">
2216 <xsl:with-param name="file" select="$filename"/>
2217 </xsl:apply-templates>
2218 <xsl:call-template name="fileheader">
2219 <xsl:with-param name="name" select="$filename"/>
2220 <xsl:with-param name="class" select="substring(@name, 2)"/>
2221 <xsl:with-param name="type" select="'header'"/>
2222 </xsl:call-template>
2223 <xsl:apply-templates select="." mode="classheader">
2224 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2225 </xsl:apply-templates>
2226
2227 <!-- interface attributes/methods (public) -->
2228 <xsl:call-template name="emitInterfaceDecls">
2229 <xsl:with-param name="pmode" select="'public'"/>
2230 </xsl:call-template>
2231
2232 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2233 <!-- This is super tricky, as the for-each switches to the node set,
2234 which means the normal document isn't available any more. We get
2235 the data we need, uses a for-each to switch document and then a
2236 key() to look up the interface by name. -->
2237 <xsl:variable name="addifname">
2238 <xsl:value-of select="string(.)"/>
2239 </xsl:variable>
2240 <xsl:for-each select="$G_root">
2241 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2242 <xsl:call-template name="emitInterfaceDecls">
2243 <xsl:with-param name="pmode" select="'public'"/>
2244 </xsl:call-template>
2245 </xsl:for-each>
2246 </xsl:for-each>
2247 </xsl:for-each>
2248
2249 <!-- auxiliary methods (public) -->
2250 <xsl:call-template name="emitAuxMethodDecls"/>
2251
2252 <!-- switch to private -->
2253 <xsl:text>
2254private:</xsl:text>
2255
2256 <!-- wrapped interface attributes/methods (private) -->
2257 <xsl:call-template name="emitInterfaceDecls">
2258 <xsl:with-param name="pmode" select="'wrapped'"/>
2259 </xsl:call-template>
2260
2261 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2262 <!-- This is super tricky, as the for-each switches to the node set,
2263 which means the normal document isn't available any more. We get
2264 the data we need, uses a for-each to switch document and then a
2265 key() to look up the interface by name. -->
2266 <xsl:variable name="addifname">
2267 <xsl:value-of select="string(.)"/>
2268 </xsl:variable>
2269 <xsl:for-each select="$G_root">
2270 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2271 <xsl:call-template name="emitInterfaceDecls">
2272 <xsl:with-param name="pmode" select="'wrapped'"/>
2273 </xsl:call-template>
2274 </xsl:for-each>
2275 </xsl:for-each>
2276 </xsl:for-each>
2277
2278 <xsl:apply-templates select="." mode="classfooter"/>
2279 <xsl:apply-templates select="." mode="endfile">
2280 <xsl:with-param name="file" select="$filename"/>
2281 </xsl:apply-templates>
2282</xsl:template>
2283
2284<!-- - - - - - - - - - - - - - - - - - - - - - -
2285 emit all attributes and methods definitions (pmode=code) or probes (pmode=dtrace-probes) of the current interface
2286 - - - - - - - - - - - - - - - - - - - - - - -->
2287<xsl:template name="emitInterfaceDefs">
2288 <xsl:param name="addinterfaces"/>
2289 <xsl:param name="pmode" select="'code'"/>
2290
2291 <xsl:variable name="topclass" select="substring(@name, 2)"/>
2292 <xsl:variable name="dtracetopclass">
2293 <xsl:choose>
2294 <xsl:when test="@dtracename"><xsl:value-of select="@dtracename"/></xsl:when>
2295 <xsl:otherwise><xsl:value-of select="$topclass"/></xsl:otherwise>
2296 </xsl:choose>
2297 </xsl:variable>
2298
2299 <xsl:if test="$pmode = 'code'">
2300 <xsl:value-of select="concat('DEFINE_EMPTY_CTOR_DTOR(', $topclass, 'Wrap)', $G_sNewLine, $G_sNewLine)"/>
2301 </xsl:if>
2302
2303 <!-- attributes -->
2304 <xsl:call-template name="emitAttributes">
2305 <xsl:with-param name="topclass" select="$topclass"/>
2306 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2307 <xsl:with-param name="pmode" select="$pmode"/>
2308 </xsl:call-template>
2309
2310 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2311 <!-- This is super tricky, as the for-each switches to the node set,
2312 which means the normal document isn't available any more. We get
2313 the data we need, uses a for-each to switch document and then a
2314 key() to look up the interface by name. -->
2315 <xsl:variable name="addifname">
2316 <xsl:value-of select="string(.)"/>
2317 </xsl:variable>
2318 <xsl:for-each select="$G_root">
2319 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2320 <xsl:call-template name="emitAttributes">
2321 <xsl:with-param name="topclass" select="$topclass"/>
2322 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2323 <xsl:with-param name="pmode" select="$pmode"/>
2324 </xsl:call-template>
2325 </xsl:for-each>
2326 </xsl:for-each>
2327 </xsl:for-each>
2328
2329 <!-- methods -->
2330 <xsl:call-template name="xsltprocNewlineOutputHack"/>
2331 <xsl:call-template name="emitMethods">
2332 <xsl:with-param name="topclass" select="$topclass"/>
2333 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2334 <xsl:with-param name="pmode" select="$pmode"/>
2335 </xsl:call-template>
2336
2337 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2338 <!-- This is super tricky, as the for-each switches to the node set,
2339 which means the normal document isn't available any more. We get
2340 the data we need, uses a for-each to switch document and then a
2341 key() to look up the interface by name. -->
2342 <xsl:variable name="addifname">
2343 <xsl:value-of select="string(.)"/>
2344 </xsl:variable>
2345 <xsl:for-each select="$G_root">
2346 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2347 <xsl:call-template name="emitMethods">
2348 <xsl:with-param name="topclass" select="$topclass"/>
2349 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2350 <xsl:with-param name="pmode" select="$pmode"/>
2351 </xsl:call-template>
2352 </xsl:for-each>
2353 </xsl:for-each>
2354 </xsl:for-each>
2355</xsl:template>
2356
2357<!-- - - - - - - - - - - - - - - - - - - - - - -
2358 emit auxiliary method declarations of the current interface
2359 - - - - - - - - - - - - - - - - - - - - - - -->
2360<xsl:template name="emitAuxMethodDefs">
2361 <xsl:param name="pmode" select="'code'"/>
2362 <!-- currently nothing, maybe later some generic FinalConstruct/... implementation -->
2363</xsl:template>
2364
2365
2366<!-- - - - - - - - - - - - - - - - - - - - - - -
2367 emit the code file of the current interface
2368 - - - - - - - - - - - - - - - - - - - - - - -->
2369<xsl:template name="emitCode">
2370 <xsl:param name="addinterfaces"/>
2371
2372 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.cpp')"/>
2373
2374 <xsl:apply-templates select="." mode="startfile">
2375 <xsl:with-param name="file" select="$filename"/>
2376 </xsl:apply-templates>
2377 <xsl:call-template name="fileheader">
2378 <xsl:with-param name="name" select="$filename"/>
2379 <xsl:with-param name="class" select="substring(@name, 2)"/>
2380 <xsl:with-param name="type" select="'code'"/>
2381 </xsl:call-template>
2382 <xsl:apply-templates select="." mode="codeheader">
2383 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2384 </xsl:apply-templates>
2385
2386 <!-- interface attributes/methods (public) -->
2387 <xsl:call-template name="emitInterfaceDefs">
2388 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2389 </xsl:call-template>
2390
2391 <!-- auxiliary methods (public) -->
2392 <xsl:call-template name="emitAuxMethodDefs"/>
2393
2394 <xsl:apply-templates select="." mode="codefooter">
2395 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2396 </xsl:apply-templates>
2397 <xsl:apply-templates select="." mode="endfile">
2398 <xsl:with-param name="file" select="$filename"/>
2399 </xsl:apply-templates>
2400</xsl:template>
2401
2402<!-- - - - - - - - - - - - - - - - - - - - - - -
2403 emit the DTrace probes for the current interface
2404 - - - - - - - - - - - - - - - - - - - - - - -->
2405<xsl:template name="emitDTraceProbes">
2406 <xsl:param name="addinterfaces"/>
2407
2408 <!-- interface attributes/methods (public) -->
2409 <xsl:call-template name="emitInterfaceDefs">
2410 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2411 <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
2412 </xsl:call-template>
2413
2414 <!-- auxiliary methods (public) -->
2415 <xsl:call-template name="emitAuxMethodDefs">
2416 <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
2417 </xsl:call-template>
2418
2419</xsl:template>
2420
2421<!-- - - - - - - - - - - - - - - - - - - - - - -
2422 wildcard match, ignore everything which has no explicit match
2423 - - - - - - - - - - - - - - - - - - - - - - -->
2424
2425<xsl:template match="*"/>
2426
2427<!-- - - - - - - - - - - - - - - - - - - - - - -
2428 ignore all if tags except those for XPIDL or MIDL target
2429 - - - - - - - - - - - - - - - - - - - - - - -->
2430
2431<xsl:template match="if">
2432 <xsl:if test="(@target = 'xpidl') or (@target = 'midl')">
2433 <xsl:apply-templates/>
2434 </xsl:if>
2435</xsl:template>
2436
2437<!-- - - - - - - - - - - - - - - - - - - - - - -
2438 interface match
2439 - - - - - - - - - - - - - - - - - - - - - - -->
2440
2441<xsl:template match="interface">
2442 <xsl:if test="not(@internal='yes') and not(@supportsErrorInfo='no')">
2443 <xsl:call-template name="emitInterface"/>
2444 </xsl:if>
2445</xsl:template>
2446
2447<!-- - - - - - - - - - - - - - - - - - - - - - -
2448 library match
2449 - - - - - - - - - - - - - - - - - - - - - - -->
2450
2451<xsl:template match="library">
2452 <xsl:apply-templates/>
2453</xsl:template>
2454
2455<!-- - - - - - - - - - - - - - - - - - - - - - -
2456 root match
2457 - - - - - - - - - - - - - - - - - - - - - - -->
2458
2459<xsl:template match="/idl">
2460 <xsl:choose>
2461 <xsl:when test="$generating = 'headers'">
2462 <xsl:apply-templates/>
2463 </xsl:when>
2464 <xsl:when test="$generating = 'sources'">
2465 <xsl:apply-templates/>
2466 </xsl:when>
2467 <xsl:when test="$generating = 'dtrace-probes'">
2468 <xsl:apply-templates/>
2469 </xsl:when>
2470 <xsl:otherwise>
2471 <xsl:message terminate="yes">
2472 Unknown string parameter value: generating='<xsl:value-of select="$generating"/>'
2473 </xsl:message>
2474 </xsl:otherwise>
2475 </xsl:choose>
2476</xsl:template>
2477
2478</xsl:stylesheet>
2479<!-- vi: set tabstop=4 shiftwidth=4 expandtab: -->
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