VirtualBox

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

Last change on this file was 103977, checked in by vboxsync, 5 weeks ago

Apply RT_OVERRIDE/NS_OVERRIDE where required to shut up clang.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use