VirtualBox

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

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

IGuestProcess needs a dummy attribute to work with the midl proxy stub stuff. Correct a silly spelling mistake in that dummy.

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