VirtualBox

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

Last change on this file since 79812 was 79737, checked in by vboxsync, 5 years ago

Main/apiwrap-server.xsl: Emit proper doxygen @name groupings in headers for better copying & pasting into the implementation.

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