VirtualBox

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

最後變更 在這個檔案從96308是 96308,由 vboxsync 提交於 3 年 前

src/VBox/Main: XML/XSL comment fixes

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

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