VirtualBox

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

Last change on this file since 107044 was 106065, checked in by vboxsync, 2 months ago

Manual copyright year updates.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette