VirtualBox

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

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

micro opts.

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