VirtualBox

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

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

comimpl.xsl: Use xsl:key + key() to access interfaces[@name=?] and enum[@name=?]. Also, inserted a new-output-buffer command.

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