VirtualBox

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

Last change on this file since 94521 was 90828, checked in by vboxsync, 3 years ago

Main: bugref:1909: Added API localization

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 98.7 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-2020 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-2020 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_COMMON_CLASS_METHODS(', 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 sanity check, prevents crashes -->
522 <xsl:if test="(count(attribute) + count(method) + sum(@reservedMethods[number()= number()]) + sum(@reservedAttributes[number()= number()])) = 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 // Clear error info, to make in-process calls behave the same as
1232 // cross-apartment calls or out-of-process calls.
1233 VirtualBoxBase::clearError();
1234
1235 HRESULT hrc;
1236
1237 try
1238 {
1239 CheckComArgOutPointerValidThrow(a</xsl:text>
1240 <xsl:value-of select="$attrbasename"/>
1241 <xsl:text>);
1242 </xsl:text>
1243 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1244 <xsl:with-param name="dir" select="'out'"/>
1245 </xsl:apply-templates>
1246 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1247 <xsl:text>
1248#ifdef VBOX_WITH_DTRACE_R3_MAIN
1249 </xsl:text>
1250 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1251 <xsl:text>this);
1252#endif</xsl:text>
1253 </xsl:if>
1254 <xsl:text>
1255 </xsl:text>
1256 <xsl:choose>
1257 <xsl:when test="$limitedAutoCaller = 'true'">
1258 <xsl:text>AutoLimitedCaller</xsl:text>
1259 </xsl:when>
1260 <xsl:otherwise>
1261 <xsl:text>AutoCaller</xsl:text>
1262 </xsl:otherwise>
1263 </xsl:choose>
1264 <xsl:text> autoCaller(this);
1265 hrc = autoCaller.rc();
1266 if (SUCCEEDED(hrc))
1267 {
1268</xsl:text>
1269 <xsl:value-of select="concat(' hrc = get', $attrbasename, '(')"/>
1270 <xsl:variable name="passAutoCaller">
1271 <xsl:call-template name="checkoption">
1272 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1273 <xsl:with-param name="option" select="'passcaller'"/>
1274 </xsl:call-template>
1275 </xsl:variable>
1276 <xsl:if test="$passAutoCaller = 'true'">
1277 <xsl:text>autoCaller, </xsl:text>
1278 </xsl:if>
1279 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1280 <xsl:with-param name="dir" select="'out'"/>
1281 </xsl:apply-templates>
1282 <xsl:text>);
1283 }</xsl:text>
1284 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1285 <xsl:text>
1286#ifdef VBOX_WITH_DTRACE_R3_MAIN
1287 </xsl:text>
1288 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1289 <xsl:text>this, hrc, 0 /*normal*/,</xsl:text>
1290 <xsl:call-template name="emitDTraceParamValue">
1291 <xsl:with-param name="dir">out</xsl:with-param>
1292 </xsl:call-template>
1293 <xsl:text>);
1294#endif</xsl:text>
1295 </xsl:if>
1296 <xsl:text>
1297 }
1298 catch (HRESULT hrc2)
1299 {
1300 hrc = hrc2;</xsl:text>
1301 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1302 <xsl:text>
1303#ifdef VBOX_WITH_DTRACE_R3_MAIN
1304 </xsl:text>
1305 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1306 <xsl:text>this, hrc, 1 /*hrc exception*/,</xsl:text>
1307 <xsl:call-template name="emitDTraceParamValNoTmp-DirNotIn"/>
1308 <xsl:text>);
1309#endif</xsl:text>
1310 </xsl:if>
1311 <xsl:text>
1312 }
1313 catch (...)
1314 {
1315 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);</xsl:text>
1316 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1317 <xsl:text>
1318#ifdef VBOX_WITH_DTRACE_R3_MAIN
1319 </xsl:text>
1320 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1321 <xsl:text>this, hrc, 9 /*unhandled exception*/,</xsl:text>
1322 <xsl:call-template name="emitDTraceParamValNoTmp-DirNotIn"/>
1323 <xsl:text>);
1324#endif</xsl:text>
1325 </xsl:if>
1326 <xsl:text>
1327 }
1328
1329 LogRelFlow(("{%p} %s: leave </xsl:text>
1330 <xsl:apply-templates select="@type" mode="logparamtext">
1331 <xsl:with-param name="dir" select="'out'"/>
1332 <xsl:with-param name="isref" select="''"/>
1333 </xsl:apply-templates>
1334 <xsl:text> hrc=%Rhrc\n", this, </xsl:text>
1335 <xsl:value-of select="concat('&quot;', $topclass, '::get', $dtraceattrname, '&quot;, ')"/>
1336 <xsl:apply-templates select="@type" mode="logparamval">
1337 <xsl:with-param name="dir" select="'out'"/>
1338 <xsl:with-param name="isref" select="''"/>
1339 </xsl:apply-templates>
1340 <xsl:text>, hrc));
1341 return hrc;</xsl:text>
1342 <xsl:if test="$attrbasename = 'MidlDoesNotLikeEmptyInterfaces'">
1343 <xsl:text>
1344#else /* dummy attribute */
1345 NOREF(aMidlDoesNotLikeEmptyInterfaces);
1346 return E_FAIL;
1347#endif /* dummy attribute */</xsl:text>
1348 </xsl:if>
1349 <xsl:text>
1350}
1351</xsl:text>
1352 <xsl:if test="not(@readonly) or @readonly!='yes'">
1353 <xsl:text>
1354</xsl:text>
1355 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMSETTER(', $attrbasename, ')(')"/>
1356 <xsl:call-template name="emitPublicParameter">
1357 <xsl:with-param name="dir">in</xsl:with-param>
1358 </xsl:call-template>
1359 <!-- @todo check in parameters if possible -->
1360 <xsl:text>)
1361{
1362 LogRelFlow(("{%p} %s: enter </xsl:text>
1363 <xsl:apply-templates select="@type" mode="logparamtext">
1364 <xsl:with-param name="dir" select="'in'"/>
1365 <xsl:with-param name="isref" select="''"/>
1366 </xsl:apply-templates>
1367 <xsl:text>\n", this, </xsl:text>
1368 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
1369 <xsl:apply-templates select="@type" mode="logparamval">
1370 <xsl:with-param name="dir" select="'in'"/>
1371 <xsl:with-param name="isref" select="''"/>
1372 </xsl:apply-templates>
1373 <xsl:text>));
1374</xsl:text>
1375 <xsl:if test="ancestor::interface[@wrap-gen-hook = 'yes']">
1376 <xsl:text>
1377 i_callHook(__FUNCTION__);</xsl:text>
1378 </xsl:if>
1379<xsl:text>
1380 // Clear error info, to make in-process calls behave the same as
1381 // cross-apartment calls or out-of-process calls.
1382 VirtualBoxBase::clearError();
1383
1384 HRESULT hrc;
1385
1386 try
1387 {
1388 </xsl:text>
1389 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1390 <xsl:with-param name="dir" select="'in'"/>
1391 </xsl:apply-templates>
1392 <xsl:text>
1393
1394#ifdef VBOX_WITH_DTRACE_R3_MAIN
1395 </xsl:text>
1396 <xsl:value-of select="translate(concat('VBOXAPI_', $topclass, '_SET_', $dtraceattrname, '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1397 <xsl:text>this, </xsl:text>
1398 <xsl:call-template name="emitDTraceParamValue">
1399 <xsl:with-param name="dir">in</xsl:with-param>
1400 </xsl:call-template>
1401 <xsl:text>);
1402#endif
1403 </xsl:text>
1404 <xsl:choose>
1405 <xsl:when test="$limitedAutoCaller = 'true'">
1406 <xsl:text>AutoLimitedCaller</xsl:text>
1407 </xsl:when>
1408 <xsl:otherwise>
1409 <xsl:text>AutoCaller</xsl:text>
1410 </xsl:otherwise>
1411 </xsl:choose>
1412 <xsl:text> autoCaller(this);
1413 hrc = autoCaller.rc();
1414 if (SUCCEEDED(hrc))
1415 {
1416</xsl:text>
1417 <xsl:value-of select="concat(' hrc = set', $attrbasename, '(')"/>
1418 <xsl:if test="$passAutoCaller = 'true'">
1419 <xsl:text>autoCaller, </xsl:text>
1420 </xsl:if>
1421 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1422 <xsl:with-param name="dir" select="'in'"/>
1423 </xsl:apply-templates>
1424 <xsl:text>);
1425 }
1426#ifdef VBOX_WITH_DTRACE_R3_MAIN
1427 </xsl:text>
1428 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1429 <xsl:text>this, hrc, 0 /*normal*/,</xsl:text>
1430 <xsl:call-template name="emitDTraceParamValue">
1431 <xsl:with-param name="dir">in</xsl:with-param>
1432 </xsl:call-template>
1433 <xsl:text>);
1434#endif
1435 }
1436 catch (HRESULT hrc2)
1437 {
1438 hrc = hrc2;
1439#ifdef VBOX_WITH_DTRACE_R3_MAIN
1440 </xsl:text>
1441 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1442 <xsl:text>this, hrc, 1 /*hrc exception*/,</xsl:text>
1443 <xsl:call-template name="emitDTraceParamValNoTmp-DirIn"/>
1444 <xsl:text>);
1445#endif
1446 }
1447 catch (...)
1448 {
1449 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1450#ifdef VBOX_WITH_DTRACE_R3_MAIN
1451 </xsl:text>
1452 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1453 <xsl:text>this, hrc, 9 /*unhandled exception*/,</xsl:text>
1454 <xsl:call-template name="emitDTraceParamValNoTmp-DirIn"/>
1455 <xsl:text>);
1456#endif
1457 }
1458
1459 LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, </xsl:text>
1460 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
1461 <xsl:text>hrc));
1462 return hrc;
1463}
1464</xsl:text>
1465 </xsl:if>
1466
1467 <xsl:call-template name="emitTargetEnd">
1468 <xsl:with-param name="target" select="$target"/>
1469 </xsl:call-template>
1470
1471 <xsl:call-template name="xsltprocNewlineOutputHack"/>
1472</xsl:template>
1473
1474<!-- - - - - - - - - - - - - - - - - - - - - - -
1475 Emit DTrace probes for the given attribute.
1476 - - - - - - - - - - - - - - - - - - - - - - -->
1477<xsl:template match="attribute" mode="dtrace-probes">
1478 <xsl:param name="topclass"/>
1479 <xsl:param name="dtracetopclass"/>
1480 <xsl:param name="target"/>
1481
1482 <xsl:variable name="dtraceattrname">
1483 <xsl:choose>
1484 <xsl:when test="@dtracename">
1485 <xsl:value-of select="@dtracename"/>
1486 </xsl:when>
1487 <xsl:otherwise>
1488 <!-- attrbasename -->
1489 <xsl:call-template name="capitalize">
1490 <xsl:with-param name="str" select="@name"/>
1491 </xsl:call-template>
1492 </xsl:otherwise>
1493 </xsl:choose>
1494 </xsl:variable>
1495
1496 <xsl:if test="@name != 'midlDoesNotLikeEmptyInterfaces'">
1497 <xsl:text> probe </xsl:text>
1498 <!-- <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__enter(struct ', $topclass)"/> -->
1499 <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__enter(void')"/>
1500 <xsl:text> *a_pThis);
1501 probe </xsl:text>
1502 <!-- <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__return(struct ', $topclass, ' *a_pThis')"/> -->
1503 <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__return(void *a_pThis')"/>
1504 <xsl:text>, uint32_t a_hrc, int32_t enmWhy, </xsl:text>
1505 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1506 <xsl:with-param name="dir">out</xsl:with-param>
1507 </xsl:apply-templates>
1508 <xsl:text>);
1509</xsl:text>
1510 </xsl:if>
1511 <xsl:if test="(not(@readonly) or @readonly!='yes') and @name != 'midlDoesNotLikeEmptyInterfaces'">
1512 <xsl:text> probe </xsl:text>
1513 <!-- <xsl:value-of select="concat($topclass, '__set__', $dtraceattrname, '__enter(struct ', $topclass, ' *a_pThis, ')"/>-->
1514 <xsl:value-of select="concat($topclass, '__set__', $dtraceattrname, '__enter(void *a_pThis, ')"/>
1515 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1516 <xsl:with-param name="dir" select="'in'"/>
1517 </xsl:apply-templates>
1518 <xsl:text>);
1519 probe </xsl:text>
1520 <!-- <xsl:value-of select="concat($dtracetopclass, '__set__', $dtraceattrname, '__return(struct ', $topclass, ' *a_pThis')"/> -->
1521 <xsl:value-of select="concat($dtracetopclass, '__set__', $dtraceattrname, '__return(void *a_pThis')"/>
1522 <xsl:text>, uint32_t a_hrc, int32_t enmWhy, </xsl:text>
1523 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1524 <xsl:with-param name="dir">in</xsl:with-param>
1525 </xsl:apply-templates>
1526 <xsl:text>);
1527</xsl:text>
1528 </xsl:if>
1529</xsl:template>
1530
1531<!-- - - - - - - - - - - - - - - - - - - - - - -
1532 Emit all attributes of an interface (current node).
1533 - - - - - - - - - - - - - - - - - - - - - - -->
1534<xsl:template name="emitAttributes">
1535 <xsl:param name="topclass"/>
1536 <xsl:param name="dtracetopclass"/>
1537 <xsl:param name="pmode"/>
1538
1539 <xsl:variable name="name" select="@name"/>
1540 <!-- first recurse to emit all base interfaces -->
1541 <xsl:variable name="extends" select="@extends"/>
1542 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
1543 <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
1544 <xsl:call-template name="emitAttributes">
1545 <xsl:with-param name="topclass" select="$topclass"/>
1546 <xsl:with-param name="pmode" select="$pmode"/>
1547 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1548 </xsl:call-template>
1549 </xsl:for-each>
1550 </xsl:if>
1551
1552 <xsl:choose>
1553 <xsl:when test="$pmode='code'">
1554 <xsl:text>//
1555</xsl:text>
1556 <xsl:value-of select="concat('// ', $name, ' properties')"/>
1557 <xsl:text>
1558//
1559
1560</xsl:text>
1561 </xsl:when>
1562 <xsl:when test="$pmode != 'dtrace-probes'">
1563 <xsl:value-of select="concat($G_sNewLine, ' /** @name ', translate(substring($pmode, 1, 1), $G_lowerCase, $G_upperCase), substring($pmode,2), ' ', $name, ' properties', $G_sNewLine)"/>
1564 <xsl:text> * @{ */
1565</xsl:text>
1566 </xsl:when>
1567 </xsl:choose>
1568 <xsl:choose>
1569 <xsl:when test="$pmode='public'">
1570 <xsl:apply-templates select="./attribute | ./if" mode="public">
1571 <xsl:with-param name="emitmode" select="'attribute'"/>
1572 </xsl:apply-templates>
1573 <xsl:variable name="reservedAttributes" select="@reservedAttributes"/>
1574 <xsl:if test="$reservedAttributes > 0">
1575 <!-- tricky way to do a "for" loop without recursion -->
1576 <xsl:for-each select="(//*)[position() &lt;= $reservedAttributes]">
1577 <xsl:text> STDMETHOD(COMGETTER(InternalAndReservedAttribute</xsl:text>
1578 <xsl:value-of select="concat(position(), $name)"/>
1579 <xsl:text>))(ULONG *aReserved);&#x0A;</xsl:text>
1580 </xsl:for-each>
1581 </xsl:if>
1582 </xsl:when>
1583 <xsl:when test="$pmode='wrapped'">
1584 <xsl:apply-templates select="./attribute | ./if" mode="wrapped">
1585 <xsl:with-param name="emitmode" select="'attribute'"/>
1586 </xsl:apply-templates>
1587 </xsl:when>
1588 <xsl:when test="$pmode='code'">
1589 <xsl:apply-templates select="./attribute | ./if" mode="code">
1590 <xsl:with-param name="topclass" select="$topclass"/>
1591 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1592 <xsl:with-param name="emitmode" select="'attribute'"/>
1593 </xsl:apply-templates>
1594 <xsl:variable name="reservedAttributes" select="@reservedAttributes"/>
1595 <xsl:if test="$reservedAttributes > 0">
1596 <!-- tricky way to do a "for" loop without recursion -->
1597 <xsl:for-each select="(//*)[position() &lt;= $reservedAttributes]">
1598 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMGETTER(InternalAndReservedAttribute', position(), $name, ')(ULONG *aReserved)&#x0A;')"/>
1599 <xsl:text>{
1600 NOREF(aReserved);
1601 return E_NOTIMPL;
1602}
1603
1604</xsl:text>
1605 </xsl:for-each>
1606 </xsl:if>
1607 </xsl:when>
1608 <xsl:when test="$pmode = 'dtrace-probes'">
1609 <xsl:apply-templates select="./attribute | ./if" mode="dtrace-probes">
1610 <xsl:with-param name="topclass" select="$topclass"/>
1611 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1612 <xsl:with-param name="emitmode" select="'attribute'"/>
1613 </xsl:apply-templates>
1614 </xsl:when>
1615 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitAttributes</xsl:message></xsl:otherwise>
1616 </xsl:choose>
1617
1618 <!-- close doxygen @name -->
1619 <xsl:if test="($pmode != 'code') and ($pmode != 'dtrace-probes')" >
1620 <xsl:text> /** @} */
1621</xsl:text>
1622 </xsl:if>
1623</xsl:template>
1624
1625<xsl:template name="emitTargetBegin">
1626 <xsl:param name="target"/>
1627
1628 <xsl:choose>
1629 <xsl:when test="$target = ''"/>
1630 <xsl:when test="$target = 'xpidl'">
1631 <xsl:text>#ifdef VBOX_WITH_XPCOM
1632</xsl:text>
1633 </xsl:when>
1634 <xsl:when test="$target = 'midl'">
1635 <xsl:text>#ifndef VBOX_WITH_XPCOM
1636</xsl:text>
1637 </xsl:when>
1638 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitTargetBegin: target=<xsl:value-of select="$target"/></xsl:message></xsl:otherwise>
1639 </xsl:choose>
1640</xsl:template>
1641
1642<xsl:template name="emitTargetEnd">
1643 <xsl:param name="target"/>
1644
1645 <xsl:choose>
1646 <xsl:when test="$target = ''"/>
1647 <xsl:when test="$target = 'xpidl'">
1648 <xsl:text>#endif /* VBOX_WITH_XPCOM */
1649</xsl:text>
1650 </xsl:when>
1651 <xsl:when test="$target = 'midl'">
1652 <xsl:text>#endif /* !VBOX_WITH_XPCOM */
1653</xsl:text>
1654 </xsl:when>
1655 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitTargetEnd target=<xsl:value-of select="$target"/></xsl:message></xsl:otherwise>
1656 </xsl:choose>
1657</xsl:template>
1658
1659
1660<!-- - - - - - - - - - - - - - - - - - - - - - -
1661 emit method
1662 - - - - - - - - - - - - - - - - - - - - - - -->
1663
1664<xsl:template match="method" mode="public">
1665 <xsl:param name="target"/>
1666
1667 <xsl:call-template name="emitTargetBegin">
1668 <xsl:with-param name="target" select="$target"/>
1669 </xsl:call-template>
1670
1671 <xsl:variable name="methodindent">
1672 <xsl:call-template name="tospace">
1673 <xsl:with-param name="str" select="@name"/>
1674 </xsl:call-template>
1675 </xsl:variable>
1676
1677 <xsl:text> STDMETHOD(</xsl:text>
1678 <xsl:call-template name="capitalize">
1679 <xsl:with-param name="str" select="@name"/>
1680 </xsl:call-template>
1681 <xsl:text>)(</xsl:text>
1682 <xsl:for-each select="param">
1683 <xsl:call-template name="emitPublicParameter">
1684 <xsl:with-param name="dir" select="@dir"/>
1685 </xsl:call-template>
1686 <xsl:if test="not(position()=last())">
1687 <xsl:text>,
1688 </xsl:text>
1689 <xsl:value-of select="$methodindent"/>
1690 </xsl:if>
1691 </xsl:for-each>
1692 <xsl:text>);
1693</xsl:text>
1694
1695 <xsl:call-template name="emitTargetEnd">
1696 <xsl:with-param name="target" select="$target"/>
1697 </xsl:call-template>
1698</xsl:template>
1699
1700<xsl:template match="method" mode="wrapped">
1701 <xsl:param name="target"/>
1702
1703 <xsl:call-template name="emitTargetBegin">
1704 <xsl:with-param name="target" select="$target"/>
1705 </xsl:call-template>
1706
1707 <xsl:variable name="methodindent">
1708 <xsl:call-template name="tospace">
1709 <xsl:with-param name="str" select="@name"/>
1710 </xsl:call-template>
1711 </xsl:variable>
1712
1713 <xsl:text> virtual HRESULT </xsl:text>
1714 <xsl:call-template name="uncapitalize">
1715 <xsl:with-param name="str" select="@name"/>
1716 </xsl:call-template>
1717 <xsl:text>(</xsl:text>
1718 <xsl:variable name="passAutoCaller">
1719 <xsl:call-template name="checkoption">
1720 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1721 <xsl:with-param name="option" select="'passcaller'"/>
1722 </xsl:call-template>
1723 </xsl:variable>
1724 <xsl:if test="$passAutoCaller = 'true'">
1725 <xsl:text>AutoCaller &amp;aAutoCaller</xsl:text>
1726 <xsl:if test="count(param) > 0">
1727 <xsl:text>,
1728 </xsl:text>
1729 <xsl:value-of select="$methodindent"/>
1730 </xsl:if>
1731 </xsl:if>
1732 <xsl:for-each select="param">
1733 <xsl:apply-templates select="@type" mode="wrapped">
1734 <xsl:with-param name="dir" select="@dir"/>
1735 </xsl:apply-templates>
1736 <xsl:if test="not(position()=last())">
1737 <xsl:text>,
1738 </xsl:text>
1739 <xsl:value-of select="$methodindent"/>
1740 </xsl:if>
1741 </xsl:for-each>
1742 <xsl:text>) = 0;
1743</xsl:text>
1744
1745 <xsl:call-template name="emitTargetEnd">
1746 <xsl:with-param name="target" select="$target"/>
1747 </xsl:call-template>
1748</xsl:template>
1749
1750<xsl:template match="method" mode="code">
1751 <xsl:param name="topclass"/>
1752 <xsl:param name="dtracetopclass"/>
1753 <xsl:param name="target"/>
1754
1755 <xsl:call-template name="emitTargetBegin">
1756 <xsl:with-param name="target" select="$target"/>
1757 </xsl:call-template>
1758
1759 <xsl:variable name="methodindent">
1760 <xsl:call-template name="tospace">
1761 <xsl:with-param name="str" select="@name"/>
1762 </xsl:call-template>
1763 </xsl:variable>
1764 <xsl:variable name="methodclassindent">
1765 <xsl:call-template name="tospace">
1766 <xsl:with-param name="str" select="concat($topclass, @name)"/>
1767 </xsl:call-template>
1768 </xsl:variable>
1769 <xsl:variable name="methodbasename">
1770 <xsl:call-template name="capitalize">
1771 <xsl:with-param name="str" select="@name"/>
1772 </xsl:call-template>
1773 </xsl:variable>
1774 <xsl:variable name="limitedAutoCaller">
1775 <xsl:call-template name="checkoption">
1776 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1777 <xsl:with-param name="option" select="'limitedcaller'"/>
1778 </xsl:call-template>
1779 </xsl:variable>
1780 <xsl:variable name="dtracemethodname">
1781 <xsl:choose>
1782 <xsl:when test="@dtracename">
1783 <xsl:value-of select="@dtracename"/>
1784 </xsl:when>
1785 <xsl:otherwise>
1786 <xsl:value-of select="@name"/>
1787 </xsl:otherwise>
1788 </xsl:choose>
1789 </xsl:variable>
1790 <xsl:variable name="dtracenamehack"> <!-- Ugly hack to deal with Session::assignMachine and similar. -->
1791 <xsl:if test="name(..) = 'if'">
1792 <xsl:value-of select="concat('__', ../@target)"/>
1793 </xsl:if>
1794 </xsl:variable>
1795
1796 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::', $methodbasename, '(')"/>
1797 <xsl:for-each select="param">
1798 <xsl:call-template name="emitPublicParameter">
1799 <xsl:with-param name="dir" select="@dir"/>
1800 </xsl:call-template>
1801 <xsl:if test="not(position()=last())">
1802 <xsl:text>,
1803 </xsl:text>
1804 <xsl:value-of select="$methodclassindent"/>
1805 </xsl:if>
1806 </xsl:for-each>
1807 <xsl:text>)
1808{
1809 LogRelFlow(("{%p} %s: enter</xsl:text>
1810 <xsl:for-each select="param">
1811 <xsl:text> </xsl:text>
1812 <xsl:apply-templates select="@type" mode="logparamtext">
1813 <xsl:with-param name="dir" select="@dir"/>
1814 <xsl:with-param name="isref" select="'yes'"/>
1815 </xsl:apply-templates>
1816 </xsl:for-each>
1817 <xsl:text>\n", this</xsl:text>
1818 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1819 <xsl:for-each select="param">
1820 <xsl:text>, </xsl:text>
1821 <xsl:apply-templates select="@type" mode="logparamval">
1822 <xsl:with-param name="dir" select="@dir"/>
1823 <xsl:with-param name="isref" select="'yes'"/>
1824 </xsl:apply-templates>
1825 </xsl:for-each>
1826 <xsl:text>));
1827</xsl:text>
1828 <xsl:if test="ancestor::interface[@wrap-gen-hook = 'yes']">
1829 <xsl:text>
1830 i_callHook(__FUNCTION__);</xsl:text>
1831 </xsl:if>
1832<xsl:text>
1833 // Clear error info, to make in-process calls behave the same as
1834 // cross-apartment calls or out-of-process calls.
1835 VirtualBoxBase::clearError();
1836
1837 HRESULT hrc;
1838
1839 try
1840 {
1841</xsl:text>
1842 <!-- @todo check in parameters if possible -->
1843 <xsl:for-each select="param">
1844 <xsl:if test="@dir!='in'">
1845 <xsl:text> CheckComArgOutPointerValidThrow(a</xsl:text>
1846 <xsl:call-template name="capitalize">
1847 <xsl:with-param name="str" select="@name"/>
1848 </xsl:call-template>
1849 <xsl:text>);
1850</xsl:text>
1851 </xsl:if>
1852 </xsl:for-each>
1853<xsl:text>
1854</xsl:text>
1855 <xsl:for-each select="param">
1856 <xsl:text>
1857 </xsl:text>
1858 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1859 <xsl:with-param name="dir" select="@dir"/>
1860 </xsl:apply-templates>
1861 </xsl:for-each>
1862 <xsl:text>
1863
1864#ifdef VBOX_WITH_DTRACE_R3_MAIN
1865 </xsl:text>
1866 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1867 <xsl:text>this</xsl:text>
1868 <xsl:for-each select="param[@dir='in']">
1869 <xsl:text>, </xsl:text>
1870 <xsl:call-template name="emitDTraceParamValue">
1871 <xsl:with-param name="dir" select="@dir"/>
1872 </xsl:call-template>
1873 </xsl:for-each>
1874 <xsl:text>);
1875#endif
1876 </xsl:text>
1877 <xsl:choose>
1878 <xsl:when test="$limitedAutoCaller = 'true'">
1879 <xsl:text>AutoLimitedCaller</xsl:text>
1880 </xsl:when>
1881 <xsl:otherwise>
1882 <xsl:text>AutoCaller</xsl:text>
1883 </xsl:otherwise>
1884 </xsl:choose>
1885 <xsl:text> autoCaller(this);
1886 hrc = autoCaller.rc();
1887 if (SUCCEEDED(hrc))
1888 {
1889</xsl:text>
1890 <xsl:value-of select="concat(' hrc = ', @name, '(')"/>
1891 <xsl:variable name="passAutoCaller">
1892 <xsl:call-template name="checkoption">
1893 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1894 <xsl:with-param name="option" select="'passcaller'"/>
1895 </xsl:call-template>
1896 </xsl:variable>
1897 <xsl:if test="$passAutoCaller = 'true'">
1898 <xsl:text>autoCaller</xsl:text>
1899 <xsl:if test="count(param) > 0">
1900 <xsl:text>,
1901 </xsl:text>
1902 <xsl:value-of select="$methodindent"/>
1903 </xsl:if>
1904 </xsl:if>
1905 <xsl:for-each select="param">
1906 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1907 <xsl:with-param name="dir" select="@dir"/>
1908 </xsl:apply-templates>
1909 <xsl:if test="not(position()=last())">
1910 <xsl:text>,
1911 </xsl:text>
1912 <xsl:value-of select="$methodindent"/>
1913 </xsl:if>
1914 </xsl:for-each>
1915 <xsl:text>);
1916 }
1917#ifdef VBOX_WITH_DTRACE_R3_MAIN
1918 </xsl:text>
1919 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1920 <xsl:text>this, hrc, 0 /*normal*/</xsl:text>
1921 <xsl:for-each select="param">
1922 <xsl:text>, </xsl:text>
1923 <xsl:call-template name="emitDTraceParamValue">
1924 <xsl:with-param name="dir" select="@dir"/>
1925 </xsl:call-template>
1926 </xsl:for-each>
1927 <xsl:text>);
1928#endif
1929 }
1930 catch (HRESULT hrc2)
1931 {
1932 hrc = hrc2;
1933#ifdef VBOX_WITH_DTRACE_R3_MAIN
1934 </xsl:text>
1935 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1936 <xsl:text>this, hrc, 1 /*hrc exception*/</xsl:text>
1937 <xsl:for-each select="param">
1938 <xsl:text>, </xsl:text>
1939 <xsl:call-template name="emitDTraceParamValNoTmp"/>
1940 </xsl:for-each>
1941 <xsl:text>);
1942#endif
1943 }
1944 catch (...)
1945 {
1946 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1947#ifdef VBOX_WITH_DTRACE_R3_MAIN
1948 </xsl:text>
1949 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1950 <xsl:text>this, hrc, 9 /*unhandled exception*/</xsl:text>
1951 <xsl:for-each select="param">
1952 <xsl:text>, </xsl:text>
1953 <xsl:call-template name="emitDTraceParamValNoTmp"/>
1954 </xsl:for-each>
1955 <xsl:text>);
1956#endif
1957 }
1958
1959 LogRelFlow(("{%p} %s: leave</xsl:text>
1960 <xsl:for-each select="param">
1961 <xsl:if test="@dir!='in'">
1962 <xsl:text> </xsl:text>
1963 <xsl:apply-templates select="@type" mode="logparamtext">
1964 <xsl:with-param name="dir" select="@dir"/>
1965 <xsl:with-param name="isref" select="''"/>
1966 </xsl:apply-templates>
1967 </xsl:if>
1968 </xsl:for-each>
1969 <xsl:text> hrc=%Rhrc\n", this</xsl:text>
1970 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1971 <xsl:for-each select="param">
1972 <xsl:if test="@dir!='in'">
1973 <xsl:text>, </xsl:text>
1974 <xsl:apply-templates select="@type" mode="logparamval">
1975 <xsl:with-param name="dir" select="@dir"/>
1976 <xsl:with-param name="isref" select="''"/>
1977 </xsl:apply-templates>
1978 </xsl:if>
1979 </xsl:for-each>
1980 <xsl:text>, hrc));
1981 return hrc;
1982}
1983</xsl:text>
1984
1985 <xsl:call-template name="emitTargetEnd">
1986 <xsl:with-param name="target" select="$target"/>
1987 </xsl:call-template>
1988
1989 <xsl:text>
1990</xsl:text>
1991</xsl:template>
1992
1993<!-- - - - - - - - - - - - - - - - - - - - - - -
1994 Emits the DTrace probes for a method.
1995 - - - - - - - - - - - - - - - - - - - - - - -->
1996<xsl:template match="method" mode="dtrace-probes">
1997 <xsl:param name="topclass"/>
1998 <xsl:param name="dtracetopclass"/>
1999 <xsl:param name="target"/>
2000
2001 <xsl:variable name="dtracemethodname">
2002 <xsl:choose>
2003 <xsl:when test="@dtracename">
2004 <xsl:value-of select="@dtracename"/>
2005 </xsl:when>
2006 <xsl:otherwise>
2007 <xsl:value-of select="@name"/>
2008 </xsl:otherwise>
2009 </xsl:choose>
2010 </xsl:variable>
2011 <xsl:variable name="dtracenamehack"> <!-- Ugly hack to deal with Session::assignMachine and similar. -->
2012 <xsl:if test="name(..) = 'if'">
2013 <xsl:value-of select="concat('__', ../@target)"/>
2014 </xsl:if>
2015 </xsl:variable>
2016
2017 <xsl:text> probe </xsl:text>
2018 <!-- <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__enter(struct ', $dtracetopclass, ' *a_pThis')"/> -->
2019 <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__enter(void *a_pThis')"/>
2020 <xsl:for-each select="param[@dir='in']">
2021 <xsl:text>, </xsl:text>
2022 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
2023 <xsl:with-param name="dir" select="'@dir'"/>
2024 </xsl:apply-templates>
2025 </xsl:for-each>
2026 <xsl:text>);
2027 probe </xsl:text>
2028 <!-- <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, '__return(struct ', $dtracetopclass, ' *a_pThis')"/> -->
2029 <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__return(void *a_pThis')"/>
2030 <xsl:text>, uint32_t a_hrc, int32_t enmWhy</xsl:text>
2031 <xsl:for-each select="param">
2032 <xsl:text>, </xsl:text>
2033 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
2034 <xsl:with-param name="dir" select="'@dir'"/>
2035 </xsl:apply-templates>
2036 </xsl:for-each>
2037 <xsl:text>);
2038</xsl:text>
2039
2040</xsl:template>
2041
2042
2043<xsl:template name="emitIf">
2044 <xsl:param name="passmode"/>
2045 <xsl:param name="target"/>
2046 <xsl:param name="topclass"/>
2047 <xsl:param name="emitmode"/>
2048 <xsl:param name="dtracetopclass"/>
2049
2050 <xsl:if test="($target = 'xpidl') or ($target = 'midl')">
2051 <xsl:choose>
2052 <xsl:when test="$passmode='public'">
2053 <xsl:choose>
2054 <xsl:when test="$emitmode='method'">
2055 <xsl:apply-templates select="method" mode="public">
2056 <xsl:with-param name="target" select="$target"/>
2057 </xsl:apply-templates>
2058 </xsl:when>
2059 <xsl:when test="$emitmode='attribute'">
2060 <xsl:apply-templates select="attribute" mode="public">
2061 <xsl:with-param name="target" select="$target"/>
2062 </xsl:apply-templates>
2063 </xsl:when>
2064 <xsl:otherwise/>
2065 </xsl:choose>
2066 </xsl:when>
2067 <xsl:when test="$passmode='wrapped'">
2068 <xsl:choose>
2069 <xsl:when test="$emitmode='method'">
2070 <xsl:apply-templates select="method" mode="wrapped">
2071 <xsl:with-param name="target" select="$target"/>
2072 </xsl:apply-templates>
2073 </xsl:when>
2074 <xsl:when test="$emitmode='attribute'">
2075 <xsl:apply-templates select="attribute" mode="wrapped">
2076 <xsl:with-param name="target" select="$target"/>
2077 </xsl:apply-templates>
2078 </xsl:when>
2079 <xsl:otherwise/>
2080 </xsl:choose>
2081 </xsl:when>
2082 <xsl:when test="$passmode='code'">
2083 <xsl:choose>
2084 <xsl:when test="$emitmode='method'">
2085 <xsl:apply-templates select="method" mode="code">
2086 <xsl:with-param name="target" select="$target"/>
2087 <xsl:with-param name="topclass" select="$topclass"/>
2088 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2089 </xsl:apply-templates>
2090 </xsl:when>
2091 <xsl:when test="$emitmode='attribute'">
2092 <xsl:apply-templates select="attribute" mode="code">
2093 <xsl:with-param name="target" select="$target"/>
2094 <xsl:with-param name="topclass" select="$topclass"/>
2095 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2096 </xsl:apply-templates>
2097 </xsl:when>
2098 <xsl:otherwise/>
2099 </xsl:choose>
2100 </xsl:when>
2101 <xsl:when test="$passmode = 'dtrace-probes'">
2102 <xsl:choose>
2103 <xsl:when test="$emitmode = 'method'">
2104 <xsl:apply-templates select="method" mode="dtrace-probes">
2105 <xsl:with-param name="target" select="$target"/>
2106 <xsl:with-param name="topclass" select="$topclass"/>
2107 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2108 </xsl:apply-templates>
2109 </xsl:when>
2110 <xsl:when test="$emitmode = 'attribute'">
2111 <xsl:apply-templates select="attribute" mode="dtrace-probes">
2112 <xsl:with-param name="target" select="$target"/>
2113 <xsl:with-param name="topclass" select="$topclass"/>
2114 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2115 </xsl:apply-templates>
2116 </xsl:when>
2117 <xsl:otherwise/>
2118 </xsl:choose>
2119 </xsl:when>
2120 <xsl:otherwise/>
2121 </xsl:choose>
2122 </xsl:if>
2123</xsl:template>
2124
2125<xsl:template match="if" mode="public">
2126 <xsl:param name="emitmode"/>
2127
2128 <xsl:call-template name="emitIf">
2129 <xsl:with-param name="passmode" select="'public'"/>
2130 <xsl:with-param name="target" select="@target"/>
2131 <xsl:with-param name="emitmode" select="$emitmode"/>
2132 </xsl:call-template>
2133</xsl:template>
2134
2135<xsl:template match="if" mode="wrapped">
2136 <xsl:param name="emitmode"/>
2137
2138 <xsl:call-template name="emitIf">
2139 <xsl:with-param name="passmode" select="'wrapped'"/>
2140 <xsl:with-param name="target" select="@target"/>
2141 <xsl:with-param name="emitmode" select="$emitmode"/>
2142 </xsl:call-template>
2143</xsl:template>
2144
2145<xsl:template match="if" mode="code">
2146 <xsl:param name="topclass"/>
2147 <xsl:param name="emitmode"/>
2148 <xsl:param name="dtracetopclass"/>
2149
2150 <xsl:call-template name="emitIf">
2151 <xsl:with-param name="passmode" select="'code'"/>
2152 <xsl:with-param name="target" select="@target"/>
2153 <xsl:with-param name="emitmode" select="$emitmode"/>
2154 <xsl:with-param name="topclass" select="$topclass"/>
2155 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2156 </xsl:call-template>
2157</xsl:template>
2158
2159<xsl:template match="if" mode="dtrace-probes">
2160 <xsl:param name="topclass"/>
2161 <xsl:param name="emitmode"/>
2162 <xsl:param name="dtracetopclass"/>
2163
2164 <xsl:call-template name="emitIf">
2165 <xsl:with-param name="passmode" select="'dtrace-probes'"/>
2166 <xsl:with-param name="target" select="@target"/>
2167 <xsl:with-param name="emitmode" select="$emitmode"/>
2168 <xsl:with-param name="topclass" select="$topclass"/>
2169 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2170 </xsl:call-template>
2171</xsl:template>
2172
2173<!-- - - - - - - - - - - - - - - - - - - - - - -
2174 emit all methods of the current interface
2175 - - - - - - - - - - - - - - - - - - - - - - -->
2176<xsl:template name="emitMethods">
2177 <xsl:param name="topclass"/>
2178 <xsl:param name="pmode"/>
2179 <xsl:param name="dtracetopclass"/>
2180
2181 <xsl:variable name="name" select="@name"/>
2182 <!-- first recurse to emit all base interfaces -->
2183 <xsl:variable name="extends" select="@extends"/>
2184 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
2185 <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
2186 <xsl:call-template name="emitMethods">
2187 <xsl:with-param name="topclass" select="$topclass"/>
2188 <xsl:with-param name="pmode" select="$pmode"/>
2189 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2190 </xsl:call-template>
2191 </xsl:for-each>
2192 </xsl:if>
2193
2194 <xsl:choose>
2195 <xsl:when test="$pmode='code'">
2196 <xsl:text>//
2197</xsl:text>
2198 <xsl:value-of select="concat('// ', $name, ' methods')"/>
2199 <xsl:text>
2200//
2201
2202</xsl:text>
2203 </xsl:when>
2204 <xsl:when test="$pmode='dtrace-probes'"/>
2205 <xsl:otherwise>
2206 <xsl:value-of select="concat($G_sNewLine, ' /** @name ', translate(substring($pmode, 1, 1), $G_lowerCase, $G_upperCase), substring($pmode,2), ' ', $name, ' methods', $G_sNewLine)"/>
2207 <xsl:text> * @{ */
2208</xsl:text>
2209 </xsl:otherwise>
2210 </xsl:choose>
2211 <xsl:choose>
2212 <xsl:when test="$pmode='public'">
2213 <xsl:apply-templates select="./method | ./if" mode="public">
2214 <xsl:with-param name="emitmode" select="'method'"/>
2215 </xsl:apply-templates>
2216 <xsl:variable name="reservedMethods" select="@reservedMethods"/>
2217 <xsl:if test="$reservedMethods > 0">
2218 <!-- tricky way to do a "for" loop without recursion -->
2219 <xsl:for-each select="(//*)[position() &lt;= $reservedMethods]">
2220 <xsl:text> STDMETHOD(InternalAndReservedMethod</xsl:text>
2221 <xsl:value-of select="concat(position(), $name)"/>
2222 <xsl:text>)();&#x0A;</xsl:text>
2223 </xsl:for-each>
2224 </xsl:if>
2225 </xsl:when>
2226 <xsl:when test="$pmode='wrapped'">
2227 <xsl:apply-templates select="./method | ./if" mode="wrapped">
2228 <xsl:with-param name="emitmode" select="'method'"/>
2229 </xsl:apply-templates>
2230 </xsl:when>
2231 <xsl:when test="$pmode='code'">
2232 <xsl:apply-templates select="./method | ./if" mode="code">
2233 <xsl:with-param name="topclass" select="$topclass"/>
2234 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2235 <xsl:with-param name="emitmode" select="'method'"/>
2236 </xsl:apply-templates>
2237 <xsl:variable name="reservedMethods" select="@reservedMethods"/>
2238 <xsl:if test="$reservedMethods > 0">
2239 <!-- tricky way to do a "for" loop without recursion -->
2240 <xsl:for-each select="(//*)[position() &lt;= $reservedMethods]">
2241 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::InternalAndReservedMethod', position(), $name, '()&#x0A;')"/>
2242 <xsl:text>{
2243 return E_NOTIMPL;
2244}
2245
2246</xsl:text>
2247 </xsl:for-each>
2248 </xsl:if>
2249 </xsl:when>
2250 <xsl:when test="$pmode='dtrace-probes'">
2251 <xsl:apply-templates select="./method | ./if" mode="dtrace-probes">
2252 <xsl:with-param name="topclass" select="$topclass"/>
2253 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2254 <xsl:with-param name="emitmode" select="'method'"/>
2255 </xsl:apply-templates>
2256 </xsl:when>
2257 <xsl:otherwise/>
2258 </xsl:choose>
2259
2260 <!-- close doxygen @name -->
2261 <xsl:if test="($pmode != 'code') and ($pmode != 'dtrace-probes')" >
2262 <xsl:text> /** @} */
2263</xsl:text>
2264 </xsl:if>
2265</xsl:template>
2266
2267<!-- - - - - - - - - - - - - - - - - - - - - - -
2268 emit all attributes and methods declarations of the current interface
2269 - - - - - - - - - - - - - - - - - - - - - - -->
2270<xsl:template name="emitInterfaceDecls">
2271 <xsl:param name="pmode"/>
2272
2273 <!-- attributes -->
2274 <xsl:call-template name="emitAttributes">
2275 <xsl:with-param name="pmode" select="$pmode"/>
2276 </xsl:call-template>
2277
2278 <!-- methods -->
2279 <xsl:call-template name="emitMethods">
2280 <xsl:with-param name="pmode" select="$pmode"/>
2281 </xsl:call-template>
2282</xsl:template>
2283
2284<!-- - - - - - - - - - - - - - - - - - - - - - -
2285 emit auxiliary method declarations of the current interface
2286 - - - - - - - - - - - - - - - - - - - - - - -->
2287<xsl:template name="emitAuxMethodDecls">
2288 <!-- currently nothing, maybe later some generic FinalConstruct/... helper declaration for ComObjPtr -->
2289</xsl:template>
2290
2291<!-- - - - - - - - - - - - - - - - - - - - - - -
2292 emit the header file of the current interface
2293 - - - - - - - - - - - - - - - - - - - - - - -->
2294<xsl:template name="emitHeader">
2295 <xsl:param name="addinterfaces"/>
2296
2297 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.h')"/>
2298
2299 <xsl:apply-templates select="." mode="startfile">
2300 <xsl:with-param name="file" select="$filename"/>
2301 </xsl:apply-templates>
2302 <xsl:call-template name="fileheader">
2303 <xsl:with-param name="name" select="$filename"/>
2304 <xsl:with-param name="class" select="substring(@name, 2)"/>
2305 <xsl:with-param name="type" select="'header'"/>
2306 </xsl:call-template>
2307 <xsl:apply-templates select="." mode="classheader">
2308 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2309 </xsl:apply-templates>
2310
2311 <!-- interface attributes/methods (public) -->
2312 <xsl:call-template name="emitInterfaceDecls">
2313 <xsl:with-param name="pmode" select="'public'"/>
2314 </xsl:call-template>
2315
2316 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2317 <!-- This is super tricky, as the for-each switches to the node set,
2318 which means the normal document isn't available any more. We get
2319 the data we need, uses a for-each to switch document and then a
2320 key() to look up the interface by name. -->
2321 <xsl:variable name="addifname">
2322 <xsl:value-of select="string(.)"/>
2323 </xsl:variable>
2324 <xsl:for-each select="$G_root">
2325 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2326 <xsl:call-template name="emitInterfaceDecls">
2327 <xsl:with-param name="pmode" select="'public'"/>
2328 </xsl:call-template>
2329 </xsl:for-each>
2330 </xsl:for-each>
2331 </xsl:for-each>
2332
2333 <!-- auxiliary methods (public) -->
2334 <xsl:call-template name="emitAuxMethodDecls"/>
2335
2336 <!-- switch to private -->
2337 <xsl:text>
2338private:</xsl:text>
2339
2340 <!-- wrapped interface attributes/methods (private) -->
2341 <xsl:call-template name="emitInterfaceDecls">
2342 <xsl:with-param name="pmode" select="'wrapped'"/>
2343 </xsl:call-template>
2344
2345 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2346 <!-- This is super tricky, as the for-each switches to the node set,
2347 which means the normal document isn't available any more. We get
2348 the data we need, uses a for-each to switch document and then a
2349 key() to look up the interface by name. -->
2350 <xsl:variable name="addifname">
2351 <xsl:value-of select="string(.)"/>
2352 </xsl:variable>
2353 <xsl:for-each select="$G_root">
2354 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2355 <xsl:call-template name="emitInterfaceDecls">
2356 <xsl:with-param name="pmode" select="'wrapped'"/>
2357 </xsl:call-template>
2358 </xsl:for-each>
2359 </xsl:for-each>
2360 </xsl:for-each>
2361
2362 <xsl:apply-templates select="." mode="classfooter"/>
2363 <xsl:apply-templates select="." mode="endfile">
2364 <xsl:with-param name="file" select="$filename"/>
2365 </xsl:apply-templates>
2366</xsl:template>
2367
2368<!-- - - - - - - - - - - - - - - - - - - - - - -
2369 emit all attributes and methods definitions (pmode=code) or probes (pmode=dtrace-probes) of the current interface
2370 - - - - - - - - - - - - - - - - - - - - - - -->
2371<xsl:template name="emitInterfaceDefs">
2372 <xsl:param name="addinterfaces"/>
2373 <xsl:param name="pmode" select="'code'"/>
2374
2375 <xsl:variable name="topclass" select="substring(@name, 2)"/>
2376 <xsl:variable name="dtracetopclass">
2377 <xsl:choose>
2378 <xsl:when test="@dtracename"><xsl:value-of select="@dtracename"/></xsl:when>
2379 <xsl:otherwise><xsl:value-of select="$topclass"/></xsl:otherwise>
2380 </xsl:choose>
2381 </xsl:variable>
2382
2383 <xsl:if test="$pmode = 'code'">
2384 <xsl:value-of select="concat('DEFINE_EMPTY_CTOR_DTOR(', $topclass, 'Wrap)', $G_sNewLine, $G_sNewLine)"/>
2385 </xsl:if>
2386
2387 <!-- attributes -->
2388 <xsl:call-template name="emitAttributes">
2389 <xsl:with-param name="topclass" select="$topclass"/>
2390 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2391 <xsl:with-param name="pmode" select="$pmode"/>
2392 </xsl:call-template>
2393
2394 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2395 <!-- This is super tricky, as the for-each switches to the node set,
2396 which means the normal document isn't available any more. We get
2397 the data we need, uses a for-each to switch document and then a
2398 key() to look up the interface by name. -->
2399 <xsl:variable name="addifname">
2400 <xsl:value-of select="string(.)"/>
2401 </xsl:variable>
2402 <xsl:for-each select="$G_root">
2403 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2404 <xsl:call-template name="emitAttributes">
2405 <xsl:with-param name="topclass" select="$topclass"/>
2406 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2407 <xsl:with-param name="pmode" select="$pmode"/>
2408 </xsl:call-template>
2409 </xsl:for-each>
2410 </xsl:for-each>
2411 </xsl:for-each>
2412
2413 <!-- methods -->
2414 <xsl:call-template name="xsltprocNewlineOutputHack"/>
2415 <xsl:call-template name="emitMethods">
2416 <xsl:with-param name="topclass" select="$topclass"/>
2417 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2418 <xsl:with-param name="pmode" select="$pmode"/>
2419 </xsl:call-template>
2420
2421 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2422 <!-- This is super tricky, as the for-each switches to the node set,
2423 which means the normal document isn't available any more. We get
2424 the data we need, uses a for-each to switch document and then a
2425 key() to look up the interface by name. -->
2426 <xsl:variable name="addifname">
2427 <xsl:value-of select="string(.)"/>
2428 </xsl:variable>
2429 <xsl:for-each select="$G_root">
2430 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2431 <xsl:call-template name="emitMethods">
2432 <xsl:with-param name="topclass" select="$topclass"/>
2433 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2434 <xsl:with-param name="pmode" select="$pmode"/>
2435 </xsl:call-template>
2436 </xsl:for-each>
2437 </xsl:for-each>
2438 </xsl:for-each>
2439</xsl:template>
2440
2441<!-- - - - - - - - - - - - - - - - - - - - - - -
2442 emit auxiliary method declarations of the current interface
2443 - - - - - - - - - - - - - - - - - - - - - - -->
2444<xsl:template name="emitAuxMethodDefs">
2445 <xsl:param name="pmode" select="'code'"/>
2446 <!-- currently nothing, maybe later some generic FinalConstruct/... implementation -->
2447</xsl:template>
2448
2449
2450<!-- - - - - - - - - - - - - - - - - - - - - - -
2451 emit the code file of the current interface
2452 - - - - - - - - - - - - - - - - - - - - - - -->
2453<xsl:template name="emitCode">
2454 <xsl:param name="addinterfaces"/>
2455
2456 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.cpp')"/>
2457
2458 <xsl:apply-templates select="." mode="startfile">
2459 <xsl:with-param name="file" select="$filename"/>
2460 </xsl:apply-templates>
2461 <xsl:call-template name="fileheader">
2462 <xsl:with-param name="name" select="$filename"/>
2463 <xsl:with-param name="class" select="substring(@name, 2)"/>
2464 <xsl:with-param name="type" select="'code'"/>
2465 </xsl:call-template>
2466 <xsl:apply-templates select="." mode="codeheader">
2467 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2468 </xsl:apply-templates>
2469
2470 <!-- interface attributes/methods (public) -->
2471 <xsl:call-template name="emitInterfaceDefs">
2472 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2473 </xsl:call-template>
2474
2475 <!-- auxiliary methods (public) -->
2476 <xsl:call-template name="emitAuxMethodDefs"/>
2477
2478 <xsl:apply-templates select="." mode="codefooter">
2479 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2480 </xsl:apply-templates>
2481 <xsl:apply-templates select="." mode="endfile">
2482 <xsl:with-param name="file" select="$filename"/>
2483 </xsl:apply-templates>
2484</xsl:template>
2485
2486<!-- - - - - - - - - - - - - - - - - - - - - - -
2487 emit the DTrace probes for the current interface
2488 - - - - - - - - - - - - - - - - - - - - - - -->
2489<xsl:template name="emitDTraceProbes">
2490 <xsl:param name="addinterfaces"/>
2491
2492 <!-- interface attributes/methods (public) -->
2493 <xsl:call-template name="emitInterfaceDefs">
2494 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2495 <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
2496 </xsl:call-template>
2497
2498 <!-- auxiliary methods (public) -->
2499 <xsl:call-template name="emitAuxMethodDefs">
2500 <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
2501 </xsl:call-template>
2502
2503</xsl:template>
2504
2505<!-- - - - - - - - - - - - - - - - - - - - - - -
2506 wildcard match, ignore everything which has no explicit match
2507 - - - - - - - - - - - - - - - - - - - - - - -->
2508
2509<xsl:template match="*"/>
2510
2511<!-- - - - - - - - - - - - - - - - - - - - - - -
2512 ignore all if tags except those for XPIDL or MIDL target
2513 - - - - - - - - - - - - - - - - - - - - - - -->
2514
2515<xsl:template match="if">
2516 <xsl:if test="(@target = 'xpidl') or (@target = 'midl')">
2517 <xsl:apply-templates/>
2518 </xsl:if>
2519</xsl:template>
2520
2521<!-- - - - - - - - - - - - - - - - - - - - - - -
2522 interface match
2523 - - - - - - - - - - - - - - - - - - - - - - -->
2524
2525<xsl:template match="interface">
2526 <xsl:if test="not(@internal='yes') and not(@autogen='VBoxEvent') and not(@supportsErrorInfo='no')">
2527 <xsl:call-template name="emitInterface"/>
2528 </xsl:if>
2529</xsl:template>
2530
2531<!-- - - - - - - - - - - - - - - - - - - - - - -
2532 application match
2533 - - - - - - - - - - - - - - - - - - - - - - -->
2534
2535<xsl:template match="application">
2536 <xsl:apply-templates/>
2537</xsl:template>
2538
2539<!-- - - - - - - - - - - - - - - - - - - - - - -
2540 library match
2541 - - - - - - - - - - - - - - - - - - - - - - -->
2542
2543<xsl:template match="library">
2544 <xsl:apply-templates/>
2545</xsl:template>
2546
2547<!-- - - - - - - - - - - - - - - - - - - - - - -
2548 root match
2549 - - - - - - - - - - - - - - - - - - - - - - -->
2550
2551<xsl:template match="/idl">
2552 <xsl:choose>
2553 <xsl:when test="$generating = 'headers'">
2554 <xsl:apply-templates/>
2555 </xsl:when>
2556 <xsl:when test="$generating = 'sources'">
2557 <xsl:apply-templates/>
2558 </xsl:when>
2559 <xsl:when test="$generating = 'dtrace-probes'">
2560 <xsl:apply-templates/>
2561 </xsl:when>
2562 <xsl:otherwise>
2563 <xsl:message terminate="yes">
2564 Unknown string parameter value: generating='<xsl:value-of select="$generating"/>'
2565 </xsl:message>
2566 </xsl:otherwise>
2567 </xsl:choose>
2568</xsl:template>
2569
2570</xsl:stylesheet>
2571<!-- vi: set tabstop=4 shiftwidth=4 expandtab: -->
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use